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

Fabrizio fabrizio.duhem at free.fr
Fri Jan 30 17:11:19 CET 2004


thanx you :-)


"David Abrahams" <dave at boost-consulting.com> a écrit dans le message de
news: ufzdx78fa.fsf at boost-consulting.com...
> "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


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.573 / Virus Database: 363 - Release Date: 28/01/2004








More information about the Cplusplus-sig mailing list