Good time of the day to everyone.
I have a question.
There is a sample: C:\cint\demo\Win32App\graph01\
this sample demonstrates how to call external cint script from windows application. Here is the token of the code from that sample
char tmp[200];
PaintDC=BeginPaint(hWnd,&ps);
sprintf(tmp,"DrawGr((HDC)%ld",PaintDC);
G__calc(tmp); /* Call Cint parser */
it shows how to pass argement to the function.
my question is: (or rather to say questions are)
- AFAIU if I’m passing the ‘string’ argument the syntax will look like this:
sprintf(tmp,"MyCintFunction((const char*)\"%s\"","my string argument");
it works
BUT what if I’m have a structure.
for instance:
typedef struct SMyStructure
{
int m_nVal;
char m_sString[16];
} SMyStructure;
and fnuction which accept this structure and pointer to this structure as arguments, how syntax should look in this case?
thank you.
moreover
Am I in the right, saying cint scipt can’t modify any variables passed to it lilke pointers, or references?
I mean all arguments passed to cint script from application might be treated only like [in] variables. There are no any [out]s.
If I’m in the wrong, would you mind to point out how these varibales to be used.
thank you.
pcanal
3
Assuming that CINT has the dictionary for SMyStructure and
that you have a function MyFunc(SMyStructure&):
SMyStructure myobj;
sprintf(tmp,"MyFunc( * ((SMyStructure*)0x%x) )",&myobj);
G__calc(tmp); /* Call Cint parser */
Cheers,
Philippe.
Yes, it should help.
I done something similar to strings
char* strMyString = "sdadas";
sprintf(tmp,"MyFunc( * ((void*)0x%x) )",(int)strMyString);
G__calc(tmp); /* Call Cint parser */
it works.
it is possible to change the context of the string also.
BUT whether it possible to put entire structure at the stack.
for instance I have a function in c script:
int fn_my_function(SMyStructure sMyStruct)
{
....
}
so, this is not a pointer, this is a structure itself.
waht would be syntax for calling then?
thank you.
pcanal
5
The exact same syntax as the one when the function takes a reference.
Philippe.