bool texmgr::RecompileExpressions(int iSlot) { char *expr = m_tex[iSlot].m_szExpr; // QUICK FIX: if the string ONLY has spaces and linefeeds, erase it, // because for some strange reason this would cause an error in compileCode(). { char *p = expr; while (*p==' ' || *p==LINEFEED_CONTROL_CHAR) p++; if (*p == 0) expr[0] = 0; } // replace linefeed control characters with spaces, so they don't mess up the code compiler, // and strip out any comments ('//') before sending to CompileCode(). char buf[sizeof(m_tex[iSlot].m_szExpr)]; StripLinefeedCharsAndComments(expr, buf); if (buf[0]) { #ifndef _NO_EXPR_ //resetVars(m_tex[iSlot].m_vars); //g_dumpmsg("texmgr: compiling string: "); //g_dumpmsg(buf); if ( ! (m_tex[iSlot].m_codehandle = NSEEL_code_compile(m_tex[iSlot].tex_eel_ctx, buf))) { //g_dumpmsg(" -error!"); //MessageBox( NULL, "error in per-frame code", "MILKDROP ERROR", MB_OK|MB_SETFOREGROUND|MB_TOPMOST ); //sprintf(pg->m_szUserMessage, "warning: preset \"%s\": error in 'per_frame' code", m_szDesc); //pg->m_fShowUserMessageUntilThisTime = pg->m_fAnimTime + 6.0f; } else { //g_dumpmsg(" -ok!"); //pg->m_fShowUserMessageUntilThisTime = pg->m_fAnimTime; // clear any old error msg. } //resetVars(NULL); return (m_tex[iSlot].m_codehandle != 0); #endif } return true; }
IPlugEEL::IPlugEEL(IPlugInstanceInfo instanceInfo) : IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mGain(1.) { TRACE; vm = NSEEL_VM_alloc(); // create virtual machine mVmOutput = NSEEL_VM_regvar(vm, "x"); // register a variable into vm to get a value out memset(codetext, 0, 65536); strcpy(codetext, "x=rand(2)-1.;"); codehandle = NSEEL_code_compile(vm, codetext, 0); // compile code //arguments are: name, defaultVal, minVal, maxVal, step, label GetParam(kGain)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%"); GetParam(kGain)->SetShape(2.); IGraphics* pGraphics = MakeGraphics(this, kWidth, kHeight); pGraphics->AttachPanelBackground(&COLOR_RED); IBitmap knob = pGraphics->LoadIBitmap(KNOB_ID, KNOB_FN, kKnobFrames); pGraphics->AttachControl(new IKnobMultiControl(this, kGainX, kGainY, kGain, &knob)); IRECT textRect(5, 70, kWidth-5, kHeight-5); IText textProps(15, &COLOR_BLACK, "Arial", IText::kStyleNormal, IText::kAlignNear, 0, IText::kQualityDefault); mTextControl = new AlgDisplay(this, textRect, &textProps, codetext); pGraphics->AttachControl(mTextControl); AttachGraphics(pGraphics); //MakePreset("preset 1", ... ); MakeDefaultPreset((char *) "-", kNumPrograms); }
NSEEL_CODEHANDLE AVS_EEL_IF_Compile(void *context, char *code) { NSEEL_CODEHANDLE ret; EnterCriticalSection(&g_eval_cs); ret=NSEEL_code_compile((NSEEL_VMCTX)context,code,0); if (!ret) { if (g_log_errors) { char *expr = NSEEL_code_getcodeerror((NSEEL_VMCTX)context); if (expr) { int l=strlen(expr); if (l > 512) l=512; movestringover(last_error_string,l+2); memcpy(last_error_string,expr,l); last_error_string[l]='\r'; last_error_string[l+1]='\n'; } } } LeaveCriticalSection(&g_eval_cs); return ret; }