void VJSRequireClass::_CallAsFunction (VJSParms_callAsFunction &ioParms) { XBOX::VString idString; if (!ioParms.GetStringParam(1, idString)) { XBOX::vThrowError(XBOX::VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1"); return; } XBOX::VJSContext context(ioParms.GetContext()); VJSModuleState *moduleState; XBOX::JS4D::ObjectRef objectRef; if ((moduleState = VJSModuleState::GetModuleState(context)) == NULL || (objectRef = moduleState->GetRequireFunctionRef()) == NULL) return; XBOX::VJSObject requireFunction(ioParms.GetContext(), objectRef); std::vector<XBOX::VJSValue> arguments; XBOX::VJSValue result(context); XBOX::JS4D::ExceptionRef exception; for (sLONG i = 0; i < ioParms.CountParams(); i++) arguments.push_back(ioParms.GetParamValue(i + 1)); if (!context.GetGlobalObject().CallFunction(requireFunction, &arguments, &result, &exception)) ioParms.SetException(exception); else ioParms.ReturnValue(result); }
void VJSTextStream::_CallAsFunction (VJSParms_callAsFunction &ioParms) { ioParms.ReturnValue(VJSTextStream::_Construct(ioParms)); }