This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I've got a ton of C code that I am converting to Python. I'm using Boost.Python until all the C code is gone (I looked at PyBind11, but one of my deployed environments is on gcc 4.7).
I've got the main C class (Game), and an interposer for talking to Python (Atlantis). I then derive a sub-class PyAtlantis:
class PyAtlantis : public Atlantis, public boost::python::wrapper<Atlantis>
I forward all the methods from Atlantis, using:
get_override("fun_name")(args)
That compiles, but at run time I get:
Traceback (most recent call last):
File "../../atlantis.py", line 43, in <module>
game.enableItem("sword")
Boost.Python.ArgumentError: Python argument types in
PyAtlantis.enableItem(CAtlantis, str)
did not match C signature:
enableItem(PyAtlantis {lvalue}, std::string, bool)
enableItem(PyAtlantis {lvalue}, std::string)
This is the same error I was getting when I just tried to override the functions without the wrapper...
The Python code is:
class CAtlantis(Atlantis.PyAtlantis):
def __init__(self):
pass
game = CAtlantis()
game.enableItem("sword")
The code is https://github.com/nedbrek/Atlantis/tree/PyAtlantis although I haven't pushed this patch yet...
Subreddit
Post Details
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...