void VJSStream::do_BinaryStream(VJSParms_callStaticFunction& ioParms) { VFile* file = ioParms.RetainFileParam( 1); bool forwrite = ioParms.GetBoolParam( 2, L"Write", L"Read"); if (file != NULL) { VError err = VE_OK; if (forwrite) { if (!file->Exists()) err = file->Create(); } VFileStream* stream = new VFileStream(file); if (err == VE_OK) { if (forwrite) err = stream->OpenWriting(); else err = stream->OpenReading(); } if (err == VE_OK) { ioParms.ReturnValue(VJSStream::CreateInstance(ioParms.GetContextRef(), stream)); } else { delete stream; } } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_FILE, "1"); ReleaseRefCountable( &file); }
void VJSSession::_unPromote(VJSParms_callStaticFunction& ioParms, CUAGSession* inSession) { sLONG promotionToken = 0; ioParms.GetLongParam(1, &promotionToken); CUAGThreadPrivilege* privileges = static_cast<CUAGThreadPrivilege*>(ioParms.GetContext().GetGlobalObjectPrivateInstance()->GetSpecific('uagX')); inSession->UnPromoteFromToken(promotionToken, privileges); }
void VJSLanguageSyntaxTesterDefinitionResults::_GetResult( VJSParms_callStaticFunction &ioParams, IJSLanguageSyntaxTesterDefinitionResults *inResults ) { if (inResults) { sLONG index; if (ioParams.GetLongParam( 1, &index )) { IDefinition definition = inResults->GetResult( index ); VJSObject result(ioParams.GetContextRef()); VJSValue jsval(ioParams.GetContextRef()); result.MakeEmpty(); jsval.SetString( definition.GetName() ); result.SetProperty(L"name", jsval, JS4D::PropertyAttributeNone); jsval.SetString( definition.GetFilePath() ); result.SetProperty(L"file", jsval, JS4D::PropertyAttributeNone); jsval.SetNumber( definition.GetLineNumber() + 1 ); result.SetProperty(L"line", jsval, JS4D::PropertyAttributeNone); ioParams.ReturnValue(result); } } }
void VJSTimer::_ClearTimer (VJSParms_callStaticFunction &ioParms, VJSWorker *inWorker, bool inIsInterval) { xbox_assert(inWorker != NULL); if (!ioParms.CountParams() || !ioParms.IsNumberParam(1)) return; sLONG id; XBOX::VJSTimer *timer; ioParms.GetLongParam(1, &id); if ((timer = inWorker->GetTimerContext()->LookUpTimer(id)) == NULL) return; // No timer with given ID found. if (timer->IsInterval() != inIsInterval) return; // Mismatched call (cannot used clearInterval() to clear a timeout for example). // Mark timer as "cleared". timer->_Clear(); // This will loop the event queue, trying to find the VJSTimerEvent. // // If the clearTimeout() or clearInterval() is executed inside "itself" (in its callback), // this will do nothing. The event is already executing, but as the timer is marked as // "cleared", VJSTimerEvent::Discard() will free it. // // Otherwise, the loop will find the VJSTimerEvent object, calling its Discard() and thus // freeing the timer. inWorker->UnscheduleTimer(timer); }
void VJSRequireClass::_getCurrentPath (VJSParms_callStaticFunction &ioParms, void *) { VJSGlobalObject *globalObject = ioParms.GetContext().GetGlobalObjectPrivateInstance(); xbox_assert(globalObject != NULL); XBOX::VFilePath *path = (XBOX::VFilePath *) globalObject->GetSpecific(VJSContext::kURLSpecificKey); xbox_assert(path != NULL); XBOX::VFilePath parent; if (!path->GetParent(parent)) { ioParms.ReturnString("/"); } else { XBOX::VString posixPath; parent.GetPosixPath(posixPath); ioParms.ReturnString(posixPath); } }
void VJSGlobalClass::do_isoToDate(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*) { VTime dd; VString s; ioParms.GetStringParam(1, s); dd.FromJSONString(s); ioParms.ReturnTime(dd); }
void VJSLanguageSyntaxTesterResults::_GetResult( VJSParms_callStaticFunction &ioParams, IJSLanguageSyntaxTesterResults *inResults ) { if (inResults) { sLONG index; if (ioParams.GetLongParam( 1, &index )) { ioParams.ReturnString( inResults->GetResult( index ) ); } } }
void VJSDataServiceCore::_setEnabled( VJSParms_callStaticFunction& ioParms, VDataService *inService) { VRIAContext *riaContext = VRIAJSRuntimeContext::GetApplicationContextFromJSContext( ioParms.GetContext(), inService->GetApplication()); bool enabled = false; if (ioParms.GetBoolParam( 1, &enabled)) { inService->SetEnabled( enabled); } }
void VJSStorageClass::_removeItem (VJSParms_callStaticFunction &ioParms, VJSStorageObject *inStorageObject) { xbox_assert(inStorageObject != NULL); XBOX::VString name; if (ioParms.CountParams() && ioParms.IsStringParam(1) && ioParms.GetStringParam(1, name)) inStorageObject->RemoveKeyValue(name); }
void VJSDirectory::_filterGroups(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory) { VString s; bool isquery = false; ioParms.GetStringParam(1, s); isquery = ioParms.GetBoolParam(2, "query", "not query"); CUAGGroupVector groups; VError err = inDirectory->FilterGroups(s, isquery, groups); ioParms.ReturnValue(buildArrFromGroups(ioParms, groups, nil)); }
void VJSStream::_PutString(VJSParms_callStaticFunction& ioParms, VStream* inStream) { VString s; if (ioParms.IsStringParam(1)) { ioParms.GetStringParam(1, s); VError err = s.WriteToStream(inStream); } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1"); }
void VJSStream::_PutReal(VJSParms_callStaticFunction& ioParms, VStream* inStream) { Real r = 0; if (ioParms.IsNumberParam(1)) { ioParms.GetRealParam(1, &r); VError err = inStream->PutReal(r); } else vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_NUMBER, "1"); }
void VJSGlobalClass::do_trace( VJSParms_callStaticFunction& inParms, VJSGlobalObject*) { size_t count = inParms.CountParams(); for( size_t i = 1 ; i <= count ; ++i) { VString msg; bool ok = inParms.GetStringParam( i, msg); if (!ok) break; VDebugMgr::Get()->DebugMsg( msg); } }
void VJSGlobalClass::do_GetProgressIndicator(VJSParms_callStaticFunction& ioParms, VJSGlobalObject *inContext) { if (ioParms.IsStringParam(1)) { VString userinfo; ioParms.GetStringParam(1, userinfo); VProgressIndicator* progress = VProgressManager::RetainProgressIndicator(userinfo); if (progress != nil) ioParms.ReturnValue(VJSProgressIndicator::CreateInstance(ioParms.GetContextRef(), progress)); QuickReleaseRefCountable(progress); } }
void VJSGlobalClass::do_displayNotification( VJSParms_callStaticFunction& inParms, VJSGlobalObject*) { VString message; inParms.GetStringParam( 1, message); VString title( "Notification"); inParms.GetStringParam( 2, title); bool critical = false; inParms.GetBoolParam( 3, &critical); VSystem::DisplayNotification( title, message, critical ? EDN_StyleCritical : 0); }
void VJSGlobalClass::do_dateToIso(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*) { VString s; VJSValue jsval(ioParms.GetContextRef()); if (ioParms.CountParams() > 0) { VTime dd; jsval = ioParms.GetParamValue(1); jsval.GetTime(dd); dd.GetJSONString(s); } ioParms.ReturnString(s); }
void VJSSession::_belongsTo(VJSParms_callStaticFunction& ioParms, CUAGSession* inSession) { bool ok = false; CUAGGroup* group = RetainParamGroup(inSession->GetDirectory(), ioParms, 1); if (group != nil) { CUAGThreadPrivilege* privileges = static_cast<CUAGThreadPrivilege*>(ioParms.GetContext().GetGlobalObjectPrivateInstance()->GetSpecific('uagX')); ok = inSession->BelongsTo(group, privileges); } QuickReleaseRefCountable(group); ioParms.ReturnBool(ok); }
void VJSGlobalClass::do_Require(VJSParms_callStaticFunction& ioParms, VJSGlobalObject *inGlobalObject) { xbox_assert(inGlobalObject != NULL); XBOX::VString className; if (ioParms.CountParams() != 1 || !ioParms.IsStringParam(1) || !ioParms.GetStringParam(1, className)) vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1"); else ioParms.ReturnValue(inGlobalObject->Require(ioParms.GetContext(), className)); }
void VJSSession::_promoteWith(VJSParms_callStaticFunction& ioParms, CUAGSession* inSession) { sLONG promotionToken = 0; CUAGGroup* group = RetainParamGroup(inSession->GetDirectory(), ioParms, 1); if (group != nil) { CUAGThreadPrivilege* privileges = static_cast<CUAGThreadPrivilege*>(ioParms.GetContext().GetGlobalObjectPrivateInstance()->GetSpecific('uagX')); promotionToken = inSession->PromoteIntoGroup(group, privileges); } QuickReleaseRefCountable(group); ioParms.ReturnNumber(promotionToken); }
void VJSDirectory::_addGroup(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory) { VError err; VString groupname, fullname; ioParms.GetStringParam(1, groupname); ioParms.GetStringParam(2, fullname); CUAGGroup* group = inDirectory->AddOneGroup(groupname, fullname, err); if (group == nil) ioParms.ReturnNullValue(); else { ioParms.ReturnValue(VJSGroup::CreateInstance(ioParms.GetContext(), group)); group->Release(); } }
void VJSStream::_GetWord(VJSParms_callStaticFunction& ioParms, VStream* inStream) { sWORD w; VError err = inStream->GetWord(w); if (err == VE_OK) ioParms.ReturnNumber(w); }
void VJSStream::_GetString(VJSParms_callStaticFunction& ioParms, VStream* inStream) { VString s; VError err = s.ReadFromStream(inStream); if (err == VE_OK) ioParms.ReturnString(s); }
void VJSDirectory::_getLoginListener(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory) { VError err; VString listenerRef; inDirectory->GetLoginListener(listenerRef); ioParms.ReturnString(listenerRef); }
void VJSStream::_GetLong64(VJSParms_callStaticFunction& ioParms, VStream* inStream) { sLONG8 l8; VError err = inStream->GetLong8(l8); if (err == VE_OK) ioParms.ReturnNumber(l8); }
void VJSStream::_GetReal(VJSParms_callStaticFunction& ioParms, VStream* inStream) { Real r; VError err = inStream->GetReal(r); if (err == VE_OK) ioParms.ReturnNumber(r); }
void VJSStream::_GetByte(VJSParms_callStaticFunction& ioParms, VStream* inStream) { uBYTE c; VError err = inStream->GetByte(c); if (err == VE_OK) ioParms.ReturnNumber(c); }
void VJSGlobalClass::do_GenerateUUID(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*) { VUUID theUUID(true); VString uuidStr; theUUID.GetString(uuidStr); ioParms.ReturnString(uuidStr); }
void VJSTimer::SetTimeout (VJSParms_callStaticFunction &ioParms, VJSGlobalObject *inGlobalObject) { VJSWorker *worker; worker = VJSWorker::RetainWorker(ioParms.GetContext()); VJSTimer::_SetTimer(ioParms, worker, false); XBOX::ReleaseRefCountable<VJSWorker>(&worker); }
void VJSTimer::ClearInterval (VJSParms_callStaticFunction &ioParms, VJSGlobalObject *inGlobalObject) { VJSWorker *worker; worker = VJSWorker::RetainWorker(ioParms.GetContext()); VJSTimer::_ClearTimer(ioParms, worker, true); XBOX::ReleaseRefCountable<VJSWorker>(&worker); }
void VJSDirectory::_computeHA1(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory) { VString userName, password, realm; ioParms.GetStringParam(1, userName); ioParms.GetStringParam(2, password); ioParms.GetStringParam(3, realm); if (realm.IsEmpty()) realm = "Wakanda"; CSecurityManager* securityManager = (CSecurityManager*)VComponentManager::RetainUniqueComponent(CSecurityManager::Component_Type); if (securityManager != nil) { VString ha1 = securityManager->ComputeDigestHA1(userName, password, realm); securityManager->Release(); ioParms.ReturnString(ha1); } }