[pypy-dev] PyPy, C/C++ and Wrappyr

wlavrijsen at lbl.gov wlavrijsen at lbl.gov
Mon Aug 15 20:37:17 CEST 2011


Hi Vincent,

> b2World from Box2D/Dynamics/b2World.h has the problem. I exported the
> header file using this command:
> gccxml -o box2d_gccxml.xml /usr/local/include/Box2D/Box2D.h

which version of gccxml do you use? There haven't been any actual releases
of the tool. This is with trunk:

   <Constructor id="_1615" name="b2World" explicit="1" context="_600" access="public" mangled="_ZN7b2WorldC1ERK6b2Vec2b *INTERNAL* " demangled="b2World::b2World(b2Vec2 const&amp;, bool)" location="f19:45" file="f19" line="45" extern="1">
     <Argument name="gravity" type="_1245" location="f19:45" file="f19" line="45"/>
     <Argument name="doSleep" type="_1185" location="f19:45" file="f19" line="45"/>
   </Constructor>

Of course, the generated copy constructor is there as well.

> Where can I find documentation of cppyy?

There's no documentation yet, as it's not yet production quality. I've made
a small write-up for internal purposes (i.e. a few very friendly users :) ).
I still want to be able to change what is exposed to the user until it is
production quality.

That said, here's the gist of it: install ROOT, then use genreflex to
generate the descriptions:

   http://root.cern.ch/drupal/content/generating-reflex-dictionaries

Build pypy-c with cppyy support (use the reflex-support branch):

   $ pypy translate.py -O jit --gcrootfinder=shadowstack targetpypystandalone.py --withmod-cppyy

Then use the information like so (assuming myClassDict.so contains the info
for a class MyClass):

   >>>> import cppyy
   >>>> cppyy.load_reflection_info( "myClassDict.so" )
   >>>> m = cppyy.gbl.MyClass()
   >>>> result = m.CallMyMethod()
   >>>>

If you want to enable the fast path, patch-up genreflex with the patch that
is included in pypy/module/cppyy, but that's only needed for benchmarks, not
for just showing the functionality.

On the CPython side and within our build environment the genreflex portions
are hidden behind the build system and class loader, so our users only do:

   >>> import PyCintex
   >>> m = PyCintex.gbl.MyClass()
   >>> result = m.CallMyMethod()
   >>>

Again, this isn't production code. The b2World example should be fine AFAICS,
but things like std::basic_ostream (std::cout) are a different matter (I'm
working on that right now, as a user's code choked on it, due to a deadly
cocktail of virtual inheritance and public data members: they require an
actual instance for offset calculation and the instantiation of a temp
basic_ostream for that purpose went "plink" ... ).

Best regards,
            Wim
-- 
WLavrijsen at lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net


More information about the pypy-dev mailing list