Generating dictionnaries for Python with genreflex

Hi Rooters

I am trying to build a dictionnary for my classes using reflex and use this dictionnary for interaction in Python.The example in the ROOT manual shows how to do this using ACLiC and it works for me. But the dictionnary was created using Cint and I want to use the new “Reflex” library.

I was able to create a dictionnary for “MyClass” using genreflex, compile it, and put it in a library. But inside Python, when I tried to do “from ROOT import MyClass” it fails. I guess this is because PyRoot uses Cint, not Cintex. Is it possible to do that: meaning creating a dictionnary with reflex that PyRoot can understand?

Thanks

Machine is Linux box on a dual Xeon 5140
Versions of my software:
gcc 4.2.2
Python 2.5.1 (buit with the gcc 4.2.2 and -fwrapv CC flags)
ROOT 5.17/04 (built with gcc 4.2.2 and --enable-reflex --enable-cintex --enable-python)
gccxml 0.7 built from the package from service-spi.web.cern.ch (and with gcc version 4.1 since gccxml cannot work right now with version 4.2)

Matthieu,

PyROOT has only limited functionality when it comes to Reflex, and that functionality is off by default. Instead, use PyCintex. E.g.:[code]>>> import PyCintex

PyCintex.loadDictionary( ‘myDict.so’ )
MyClass = PyCintex.gbl.MyClass[/code]
PyCintex is a mix of PyROOT and Cintex. The latter fills CINT dictionaries from Reflex ones, so that PyROOT can use them.

HTH,
Wim

Hi Wim

Thank you for your answer, it works! PyReflex seems to be exacly what I want right now because it is not intrusive.

So I know that PyReflex allows me to use dictionnary created from genreflex from inside Python but can I use the Refex library from inside Python? Instead of using Python’s own introspection abalities, I would like to use Reflex’ reflection that seems to me far superior.

For instance I would like to do:

c1 = Type.ByName(“MyClass”)
obj = c1.Construct()

I guess that I need to do some “import”, I tried to do “from PyCintex import Type” but it doesn’t work.

Is there any documentation on PyReflex?

Thanks

Matthieu,

not sure what you’re asking … are you referring to PyCintex as ‘PyReflex’ or are you talking about the (now defunct) pyreflex product?

Otherwise, yes there is a Reflex dictionary of Reflex, and yes, it can be used through PyCintex. Please have a look here: https://twiki.cern.ch/twiki/bin/view/LCG/RELAX.

You can load the RELAX dictionaries just like your own Reflex dictionaries, then import types like Type, Scope, etc. For example:[code]import PyCintex

PyCintex.loadDict( “RELAX/libSTLRflx” )
PyCintex.loadDict( “RELAX/libReflexRflx” )

top = PyCintex.gbl.ROOT.Reflex.Scope.ByName( ‘::’ )[/code]
As an exercise, a while back, I used RELAX and ctypes to auto-generate a functional python-side C-API from Python.h, and that went fine. I presume things still work.

Cheers,
Wim