Reflex Dictionary Generator Antti Hahto antti hahtotut fi

  • Slides: 14
Download presentation
Reflex Dictionary Generator Antti Hahto antti. hahto@tut. fi 4. 8. 2006

Reflex Dictionary Generator Antti Hahto antti. hahto@tut. fi 4. 8. 2006

What? u Replacing the CINT Dictionary Generator with a new one, using Reflex API

What? u Replacing the CINT Dictionary Generator with a new one, using Reflex API

Why? u u CINT memory requirements large (no dynamic allocation) Root written in C++

Why? u u CINT memory requirements large (no dynamic allocation) Root written in C++ object oriented way, CINT is not. Previous Dict. Gen using also Python → lacking uniformity Data structures already in the Reflex format The advantages of modern object oriented programming u maintainability, flexibility, re-usability, data encapsuling. . .

Do I need one? 1) Interactive usage through scripting languages u Root scripts in

Do I need one? 1) Interactive usage through scripting languages u Root scripts in c++, no need to compile to see the results immediately 2) Making objects persistent u Writing/retrieving objects from disk u Using Root I/O, for an example

Reflection u u A program can observe and modify its structural information while running

Reflection u u 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? u u u A dictionary is built for types, scopes and members Dictionary

How? u u u 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 Reflex CINT Cint datastruct Root services CINT/ Pyroot

The structure User’s. h - file Reflex CINT Cint datastruct Root services CINT/ Pyroot New Dictgen datastruct Old Dictgen Reflex datastruct Dictionary loads Dynamic Library file. so

Object oriented architecture u Each type capable of generating its own dictionary information (“

Object oriented architecture u Each type capable of generating its own dictionary information (“ Data. Member. Gen(type 666, "a") “) in addition to its c++ code representation (“ int a; ”) u Dictionary generation via hierarchy; class generates information about itself and then forwards the request to all its members.

Object oriented architecture Int Mynamespace: : My. Clas s: : Member: : f. Number

Object oriented architecture Int Mynamespace: : My. Clas s: : Member: : f. Number globalscope. G() Namespace. G() class/struct. G() funct. member (union) Datamember. G() enum Fundamental. G() int. G()

An example namespace Alaska { class Elephant { private: unsigned f. Energy_level; public: void

An example namespace Alaska { class Elephant { private: unsigned f. Energy_level; public: void Eat_nuts(unsigned amount) { for(unsigned i=0; i<amount; ++i) { ++f. Energy_level; } }}; } . . . Namespace. Builder nsb 0( "Alaska" ); Type type_666 = Type. Builder("unsigned int"); Class. Builder("Alaska: : Elephant", typeid(Alaska: : Elephant), sizeof(Alaska: : Elephant), PUBLIC | CLASS). Add. Function. Member(Function. Type. Builder(t ype_void, type_666), "Eat_nuts", method_3555, 0, "amount", PUBLIC)

Dict. Gen class u A new class, taking care of common tasks in dictionary

Dict. Gen class u A new class, taking care of common tasks in dictionary generation and configuration u Member functions: Use_recursive(true/false) Use_selection("filename") Add_extra_header(“filename”) Dump("filename")

Testing procedure. h - file Reflex New Dictgen datastruct Gcc_xml Gendict. py Dictionary ==

Testing procedure. h - file Reflex New Dictgen datastruct Gcc_xml Gendict. py Dictionary == Dictionary

Status, To. Do u Successfully generates dictionaries for tested header files u . xml

Status, To. Do u Successfully generates dictionaries for tested header files u . xml selection file usage / Linkdef and unions not fully implemented Needs testing for more complicated & large files u