void VJSGlobalClass::do_include( VJSParms_callStaticFunction& inParms, VJSGlobalObject *inGlobalObject) { // EvaluateScript() uses NULL (this is default) as inThisObject argument. // This works fine currently, but would it be better (if any problem) to pass global (application) object instead? // See WAK0074064. VFile* file = inParms.RetainFileParam(1, false); if (file != NULL) { bool newlyRegistered = inGlobalObject->RegisterIncludedFile( file); // sc 15/06/2010 the file must be registered if (inParms.GetBoolParam(2,"refresh","auto") || newlyRegistered) { inParms.GetContext().EvaluateScript( file, NULL, inParms.GetExceptionRefPointer()); } file->Release(); } else { VString pathname; if (inParms.IsStringParam(1) && inParms.GetStringParam( 1, pathname)) { VFolder* folder = inGlobalObject->GetRuntimeDelegate()->RetainScriptsFolder(); if (folder != NULL) { file = new VFile( *folder, pathname, FPS_POSIX); bool newlyRegistered = inGlobalObject->RegisterIncludedFile( file); // sc 15/06/2010 the file must be registered if (inParms.GetBoolParam(2,"refresh","auto") || newlyRegistered) { inParms.GetContext().EvaluateScript( file, NULL, inParms.GetExceptionRefPointer()); } ReleaseRefCountable( &file); } ReleaseRefCountable( &folder); } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_FILE, "1"); } }
void VJSGlobalClass::do_testMe( VJSParms_callStaticFunction& inParms, VJSGlobalObject*) { VJSObject globalObject( inParms.GetContext().GetGlobalObject()); VString functionName; inParms.GetStringParam( 1, functionName); std::vector<VJSValue> values; size_t count = inParms.CountParams(); for( size_t i = 2 ; i <= count ; ++i) values.push_back( inParms.GetParamValue( i)); VJSValue result( inParms.GetContextRef()); bool ok = globalObject.CallMemberFunction( functionName, &values, &result, inParms.GetExceptionRefPointer()); inParms.ReturnValue( result); }