[C++-sig] Re: call python method from C++

David Abrahams dave at boost-consulting.com
Fri Jan 30 16:39:05 CET 2004


"Fabrizio" <fabrizio.duhem at free.fr> writes:

> D:\test\boost_python\Release>python test.py
> Traceback (most recent call last):
>   File "test.py", line 27, in ?
>     eriser.Update(a)
> TypeError: Update() takes exactly 2 arguments (1 given)
>
>
>
> C++ code
>
> class IRenderable
> {
> public:
>  virtual   ~IRenderable() {}
>  virtual void Init()    {}
>  virtual void Render()   {}
>  virtual void Update(float dt) {}
> };
>
>
> class IRenderableWrapper : public IRenderable
> {
> public:
>  PyObject* self;
>
>  IRenderableWrapper(PyObject* self_) : self(self_) {}
>
>  void Init()
>  {
>   return boost::python::call_method<void>(self, "Init");
>  }
>
>  void DefaultInit()
>  {
>   return IRenderable::Init();
>  }
>
>  void Render()
>  {
>   return boost::python::call_method<void>(self, "Render");
>  }
>
>  void DefaultRender()
>  {
>   return IRenderable::Render();
>  }
>
>  void Update(float dt)
>  {
>   return boost::python::call_method<void>(self, "Update");
----------------------------------------------------------^
Your problem is right here

You need to pass dt to the Update method.

HTH,
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list