Hi, I'm trying to call an interpreted function from compiled code. I followed the various examples on the web and finally had a problem when the function is bytecoded. The prototype of the function is : FrVect* xxxx( int, FrVect**, FrVect*); and when I try to call it (bytecoded), I get the following warning/error : Error: Incorrect assignment to , wrong type 'long**' FILE: LINE:0 *** Break *** segmentation violation For the sake of completeness, below is the relevant parts of my code. Everything works fine if I call a purely interpreted function (the G__INTERPRETEDFUNC case below) When I try to load this code in root (with a .L testpro.C++), compiling it and load manually the script, everything works smoothly... I'm really puzzled. Can anyone help ? Damir //_____________________________________________________________________________ FrVect* RA_UserScriptExec(char* functionname, int numvect, FrVect** vectlist, FrVect* outvect) { G__CallFunc func; G__ClassInfo globalscope; G__MethodInfo method; FrVect* (*p2f)(int,FrVect**,FrVect*); char temp[200]; FrVect* result; if(functionname) { long dummy; // find the function and resolve overloading method=globalscope.GetMethod(functionname,"int,FrVect**,FrVect*",&dummy); if (method.IsValid()) { // get pointer to function after overloading resolution p2f=(FrVect* (*)(int,FrVect**,FrVect*))method.PointerToFunc(); // check what kind of pointer is it switch(G__isinterpretedp2f(p2f)) { case G__INTERPRETEDFUNC: // reconstruct function call as string sprintf(temp,"%s(%d,(FrVect**)0x%x, (FrVect*)0x%x)",functionname,numvect,vectlist,outvect); result=(FrVect*)(G__int(G__calc(temp))); break; case G__COMPILEDINTERFACEMETHOD: // using interface method func.SetFunc((G__InterfaceMethod)p2f); func.SetArg((long)numvect); func.SetArg((long)vectlist); func.SetArg((long)outvect); result=(FrVect*)(func.ExecInt((void*)NULL)); break; case G__COMPILEDTRUEFUNC: // using true pointer to function result= p2f(numvect,vectlist,outvect); break; case G__BYTECODEFUNC: // bytecode version of interpreted func cout << "seen as bytecode" <<endl; func.SetBytecode((struct G__bytecodefunc*)p2f); func.SetArg((long)numvect); func.SetArg((long)vectlist); func.SetArg((long)outvect); result=(FrVect*)(func.ExecInt((void*)NULL)); cout<<outvect<<" "<<result<<endl; break; case G__UNKNOWNFUNC: // this case will never happen result=p2f(numvect,vectlist,outvect); break; } return(result); } else { cerr << "unknown function " << functionname << endl; } } else { cerr << "unknown function " << functionname << endl; } return(NULL); } -- ===================================================================== | Damir Buskulic | Universite de Savoie/LAPP | | | Chemin de Bellevue, B.P. 110 | | Tel : +33 (0)450091600 | F-74941 Annecy-le-Vieux Cedex | | e-mail: buskulic@lapp.in2p3.fr | FRANCE | ===================================================================== mailto:buskulic@lapp.in2p3.fr
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET