bool wxScriptFunctionCINT::Exec(wxScriptVar &ret, wxScriptVar *arg) const { // create the string with the arguments to give to the function wxString cmd = GetCallString(arg); // exec the function G__value returnvalue = G__calc(cmd); // for float & double we need special conversion if (m_tReturn.GetGenericType() == wxSTG_FLOAT || m_tReturn.GetGenericType() == wxSTG_DOUBLE) { ret.Set(m_tReturn.GetGenericType(), wxString::Format(wxT("%f"), G__double(returnvalue))); return TRUE; } // for all other types, we just get an int... long res = G__int(returnvalue); // ... and transform it into the correct value ret.Set(m_tReturn.GetGenericType(), res); return TRUE; }
int ExecP2F::DoP2F(char* s,double d) { char temp[200]; int result; G__CallFunc func; int (*p)(char*,double); /* pointer to function is not set */ if(!p2f) return(0); /* exec pointer to function */ switch(mode) { case G__INTERPRETEDFUNC: // reconstruct function call as string sprintf(temp,"%s(%ld,%g)",fname,s,d); #ifdef __CINT__ result=G__calc(temp); #else result=G__int(G__calc(temp)); #endif break; case G__BYTECODEFUNC: // calling bytecode function func.SetBytecode((struct G__bytecodefunc*)p2f); func.SetArg((long)s); func.SetArg((double)d); result=func.ExecInt((void*)NULL); break; case G__COMPILEDINTERFACEMETHOD: // using interface method func.SetFunc((G__InterfaceMethod)p2f); func.SetArg((long)s); func.SetArg((double)d); result=func.ExecInt((void*)NULL); break; case G__COMPILEDTRUEFUNC: // using true pointer to function p = (int (*)(char*,double))p2f; result=(*p)(s,d); break; case G__UNKNOWNFUNC: // this case will never happen p = (int (*)(char*,double))p2f; result=(*p)(s,d); break; } return(result); }
static LRESULT Wm_PaintProc(HWND hWnd) { PAINTSTRUCT ps; HDC PaintDC; // TODO: Add any drawing code here... if(GetUpdateRect(hWnd,NULL,TRUE)) { char tmp[200]; PaintDC=BeginPaint(hWnd,&ps); sprintf(tmp,"DrawGr((HDC)%ld",PaintDC); G__calc(tmp); /* Call Cint parser */ /* DrawGr(PaintDC); */ EndPaint(hWnd, &ps); } return 0; }
DWORD WINAPI CCintocxCtrl::CintThread(LPVOID lpvThreadParm) { DWORD dwResult=0; int flag=1; G__value result; int iresult; char arg[G__LONGLINE]; CCintocxCtrl *origin; EVENTID eid; #ifndef WIN32EVENT CSingleLock WaitForCintEvent(&CintEvent); #else CintEvent = CreateEvent(NULL,FALSE,FALSE,"CintEvent"); #endif while(flag) { // Wait for event from GUI thread IsBusy=0; #ifndef WIN32EVENT WaitForCintEvent.Lock(INFINITE); #else WaitForSingleObject(CintEvent,INFINITE); #endif IsBusy=1; while(0==EventQue.Pop(arg,&origin,&eid)) { switch(eid) { case INITEVENT: // start cint with specified argument iresult=G__init_cint(arg); sprintf(arg,"%d",iresult); origin->m_result = arg; break; case EVALEVENT: // start cint with default if not started already if(!G__getcintready()) iresult=G__init_cint("cint"); // evaluate scheduled expression result=G__calc(arg); // translate return value to string value2string(arg,&result); origin->m_result = arg; break; case TERMINATEEVENT: // terminate cint and kill thread G__scratch_all(); goto terminate_thread; } // notify evaldone to GUI thread origin->FireEvalDone(); } } // while(flag) terminate_thread: IsBusy=0; IsCintThreadActive = 0 ; #ifndef WIN32EVENT WaitForCintEvent.Unlock(3); #else CloseHandle(CintEvent); #endif G__FreeConsole(); return(dwResult); }