Reflex Dictionary Generator Antti Hahto
What? Replacing the CINT Dictionary Generator with a new one, using Reflex API
Why? CINT memory requirements large (no dynamic allocation) Root written in C++ object oriented way, CINT is not. Previous DictGen using also Python → lacking uniformity Data structures already in the Reflex format The advantages of modern object oriented programming maintainability, flexibility, re-usability, data encapsuling...
Do I need one? 1) Interactive usage through scripting languages Root scripts in c++, no need to compile to see the results immediately 2) Making objects persistent Writing/retrieving objects from disk Using Root I/O, for an example
Reflection A program can observe and modify its structural information while running Usually, when a C++ program source is compiled into a machine code, information about the structure is lost Reflection is a preservation of the original structure, in a way of producing some additional metadata (dictionary) Poorly supported in C++, unlike for example in Java
How? A dictionary is built for types, scopes and members Dictionary is then loaded into the reflection database Metainformation is provided for the user
The structure User’s.h - file CINT/ Pyroot Dictionary CINT Root services Dynamic Library file.so Old Dictgen Reflex datastruct Cint datastruct Reflex datastruct New Dictgen loads
Object oriented architecture Each type capable of generating its own dictionary information (“ DataMemberGen(type666,"a") “) in addition to its c++ code code representation (“ int a; ”) Dictionary generation via hierarchy; class generates information about itself and then forwards the request to all its members.
Object oriented architecture globalscope.G() Namespace.G() class/struct.G() funct.member Datamember.G() Fundamental.G() enum (union) int.G() Int Mynamespace::MyClas s::Member::fNumber
An example namespace Alaska { class Elephant { private: unsigned fEnergy_level; public: void Eat_nuts(unsigned amount) { for(unsigned i=0; i<amount; ++i) { ++fEnergy_level;} }};}... NamespaceBuilder nsb0( "Alaska" ); Type type_666 = TypeBuilder("unsigned int"); ClassBuilder("Alaska::Elephant", typeid(Alaska::Elephant), sizeof(Alaska::Elephant), PUBLIC | CLASS).AddFunctionMember(FunctionTypeBuilder(t ype_void, type_666), "Eat_nuts", method_3555, 0, "amount", PUBLIC)
DictGen class A new class, taking care of common tasks in dictionary generation and configuration Member functions: Use_recursive(true/false) Use_selection("filename") Add_extra_header(“filename”) Dump("filename")
Testing procedure.h - file Dictionary Reflex datastruct New Dictgen Gcc_xml Gendict.py Dictionary ==
Status, ToDo Successfully generates dictionaries for tested header files .xml selection file usage / Linkdef and unions not fully implemented Needs testing for more complicated & large files