[C++-sig] Help! Py++ Generated Binding Won't Compile

Roman Yakovenko roman.yakovenko at gmail.com
Thu Apr 12 11:15:13 CEST 2007


On 4/12/07, Rocketman at JSC <snemeth at houston.rr.com> wrote:
>
> First of all--thanks for you guys putting in all the work to bring us
Py++,
> pygccxml, and boost.python--lots of hard work and I'm hoping to put it all
> to good use and save us some tax dollars.

:-)

> So here I am trying to generate bindings for the same C++ sim code, but
I've
> run into snag.  Below I'll post the two header files I think are involved,
> Py++ script, Py++ messages, and the compiler errors.

Few comments

1. You didn't specified call policies for functions registerEvent and
registerVehicle. If you just saves references to the objects I suggest you
to take a look on
http://boost.org/libs/python/doc/v2/with_custodian_and_ward.html call policy
and to read tutorials. If Executive class also manages their life-time, than
this is other story. Call policies are **very** important.

2. Event class is using raw PyObject type. There is a much better way:
http://boost.org/libs/python/doc/tutorial/doc/html/python/object.html

3. You don't really have to exclude getPtr methods. You can use call
policies to deal with them, even if this is a pointer to an array. Take a
look on Py++ defined call policies:
http://language-binding.net/pyplusplus/documentation/functions/call_policies.html

4. Py++ warnings is there for you. For example

> WARNING: BallForce [class]
> > warning W1040: The declaration is unexposed, but there are other
> > declarations, which refer to it. This could
> > cause "no to_python converter found" run time error. Declarations:
> > Ball::force [variable]

Py++ says you that you are exposing Ball::force member variable, while you
don't expose BallForce class( the type of the variable ). So when user will
try to use "force" variable he will get an error.

Of course you can disable them:
http://language-binding.net/pyplusplus/documentation/feedback.html

Now about your errors. My guess is that they are caused by missing call
policies for functions setAction and setCondition. In order to be sure I
need to see generated code.

> I don't have any clue where the problem is from these messages.  Note the
> compiler mentions the 2nd to the last } of the generated wrapper
> Pyxis_wrap.cpp file and all the rest of the compiler messages don't appear
> to be in my code.  If I remove the Event and Executive class--all builds
up
> fine.
>
> Thanks in advance for any help.

HTH.

P.S. It is much better to post small and complete hand-written example +
error message.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070412/e9440ea3/attachment.htm>


More information about the Cplusplus-sig mailing list