Help me with CINT usage

Hi!

I’m new to CINT and want to find out whether I understand its possibilities correctly.
I want to upgrade from Tiny C Compiler to CINT, from C to C++, but didn’t find in CINT appropriate APIs for next things.

My scenario:

===== script code ======

[code]class A
{ public:
void Func(int);
};

extern A* a1;

void main()
{
a1->Func(123);
}[/code]

===== runtime application ======

[code]class A
{ public:
void Func(int x) {m_x = x; }

private:
int m_x;
};

void main()
{
A a;
char source[] = “script code here as a string”;

context = CINT_Compile(source);
context.SetSymbol("a1", &a);
context.SetSymbol("A::Func", &A::Func);
context.Run();
// a.m_x == 123

}[/code]

What CINT APIs should I use for this if it ever possible?

Thanks.

Hi,

It is indeed possible/easy to do this in CINT (but in order to mix compiled and interpreted code you would need to generate dictionary at compile time).

I recommend that you give Cling a try (CINT’s successor based on llvm and clang).

[code]
int main( int argc, char **argv ) {
{
A a;

// Set up the interpreter
cling::Interpreter interp(argc, argv);
if (interp.getOptions().Help) {
return 0;
}

interp.loadFile(“header.h”)

stringstream ss;
ss << “A a1 = (A)” << (void*)&a << “;\n”;
ss << “a1->Func(123);\n”;
interp.process(ss.str().c_str());

}[/code]

Cheers,
Philippe.

Thanks for your answer.

I had tried llvm approach earlier. But I had failed to make it as lightweight as possible: I want to use CINT as scripting engine for game development to compile code on the fly in memory.

Where can I read about dictionaru creation and external linkage? Are there any application project examples with similar scenario?

See root.cern.ch/drupal/content/cint
and in particular root.cern.ch/viewvc/branches/v5- … kecint.txt
and root.cern.ch/viewvc/branches/v5- … extlib.txt

Cheers,
Philippe.