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 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 VJSGlobalClass::do_ProgressIndicator(VJSParms_callStaticFunction& ioParms, VJSGlobalObject *inContext)
{
	VString sessiontile;
	VString windowtile, userinfo;
	bool caninterrupt = false;
	Real maxvalue = -1;
	VError err = VE_OK;
	
	if (ioParms.IsNumberParam(1))
		ioParms.GetRealParam(1, &maxvalue);
	else
		err = vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_NUMBER, "1");

	if (err == VE_OK )
	{
		if (ioParms.IsStringParam(2))
			ioParms.GetStringParam(2, sessiontile);
		else
			err = vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "2");
	}

	caninterrupt = ioParms.GetBoolParam( 3, L"Can Interrupt", "Cannot Interrupt");

		
	//VProgressIndicator* progress = inContext->GetRuntimeDelegate()->CreateProgressIndicator( windowtile);

	if (err == VE_OK)
	{
		VProgressIndicator* progress = new VProgressIndicator();
		if (progress != NULL)
		{
			if (ioParms.CountParams() >= 4)
			{
				if (ioParms.IsStringParam(4))
				{
					ioParms.GetStringParam(4, windowtile);
					progress->SetTitle(windowtile);
				}
				else
					vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "4");
			}
			if (ioParms.CountParams() >= 5)
			{
				if (ioParms.IsStringParam(5))
				{
					ioParms.GetStringParam(5, userinfo);
					progress->SetUserInfo(userinfo);
				}
				else
					vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "5");
			}
			progress->BeginSession((sLONG8)maxvalue, sessiontile, caninterrupt);
		}
		ioParms.ReturnValue(VJSProgressIndicator::CreateInstance(ioParms.GetContextRef(), progress));
		
		ReleaseRefCountable( &progress);
	}
	else
		ioParms.ReturnNullValue();	
}	
Ejemplo n.º 4
0
VJSArray buildArrFromGroups(VJSParms_callStaticFunction& ioParms, CUAGGroupVector groups, const VString* filter)
{
	VJSArray groupArr(ioParms.GetContextRef());
	for (CUAGGroupVector::iterator cur = groups.begin(), end = groups.end(); cur != end; ++cur)
	{
		if (filter == nil)
		{
			groupArr.PushValue((*cur)->CreateJSGroupObject(ioParms.GetContextRef()));
		}
		else
		{
			VString s;
			(*cur)->GetName(s);
			if (s.CompareToSameKind_Like(filter) == CR_EQUAL)
				groupArr.PushValue((*cur)->CreateJSGroupObject(ioParms.GetContextRef()));
		}
	}

	return groupArr;
}
Ejemplo n.º 5
0
VJSArray buildArrFromUsers(VJSParms_callStaticFunction& ioParms, CUAGUserVector& users, const VString* filter)
{
	VJSArray userArr(ioParms.GetContextRef());
	for (CUAGUserVector::iterator cur = users.begin(), end = users.end(); cur != end; ++cur)
	{
		if (filter == nil)
		{
			userArr.PushValue((*cur)->CreateJSUserObject(ioParms.GetContextRef()));
		}
		else
		{
			VString s;
			(*cur)->GetName(s);
			if (s.CompareToSameKind_Like(filter) == CR_EQUAL)
				userArr.PushValue((*cur)->CreateJSUserObject(ioParms.GetContextRef()));
		}
	}

	return userArr;
}
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_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 VJSGlobalClass::do_GetURLPath(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*)
{
	VString s;
	if (ioParms.IsStringParam(1))
	{
		if (ioParms.GetStringParam(1, s))
		{
			VFullURL url(s);
			VJSArray result(ioParms.GetContextRef());
			const VString* next = url.NextPart();
			while (next != NULL)
			{
				VJSValue elem(ioParms.GetContextRef());
				elem.SetString(*next);
				result.PushValue(elem);
				next = url.NextPart();
			}
			ioParms.ReturnValue(result);
		}
	}
	else
		vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1");
}
Ejemplo n.º 9
0
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.GetContextRef(), group));
		group->Release();
	}
}
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);
}
Ejemplo n.º 11
0
void VJSDirectory::_addUser(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory)
{
	VError err;
	VString username, password, fullname;
	ioParms.GetStringParam(1, username);
	ioParms.GetStringParam(2, password);
	ioParms.GetStringParam(3, fullname);
	CUAGUser* user = inDirectory->AddOneUser(username, password, fullname, err);
	if (user == nil)
		ioParms.ReturnNullValue();
	else
	{
		ioParms.ReturnValue(VJSUser::CreateInstance(ioParms.GetContextRef(), user));
		user->Release();
	}
	
}
Ejemplo n.º 12
0
void VJSDirectory::_getGroup(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory)
{
	StErrorContextInstaller errs(false, true);
	VString s;
	ioParms.GetStringParam(1, s);
	CUAGGroup* group = inDirectory->RetainGroup(s);
	if (group == nil)
	{
		VUUID id;
		id.FromString(s);
		group = inDirectory->RetainGroup(id);
	}
	if (group == nil)
		ioParms.ReturnNullValue();
	else
	{
		ioParms.ReturnValue(VJSGroup::CreateInstance(ioParms.GetContextRef(), group));
		group->Release();
	}
}
Ejemplo n.º 13
0
void VJSDirectory::_getUser(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory)
{
	StErrorContextInstaller errs(false, true);
	VString s;
	ioParms.GetStringParam(1, s);
	CUAGUser* user = inDirectory->RetainUser(s);
	if (user == nil)
	{
		VUUID id;
		id.FromString(s);
		user = inDirectory->RetainUser(id);
	}
	if (user == nil)
		ioParms.ReturnNullValue();
	else
	{
		ioParms.ReturnValue(VJSUser::CreateInstance(ioParms.GetContextRef(), user));
		user->Release();
	}
}
Ejemplo n.º 14
0
void VJSGroup::_removeFrom(VJSParms_callStaticFunction& ioParms, CUAGGroup* inGroup)
{
	VError err = VE_OK;
	sLONG nbparam = ioParms.CountParams();
	for (sLONG i = 1; i <= nbparam /*&& err == VE_OK*/; i++)
	{
		if (ioParms.IsArrayParam(i))
		{
			VJSArray arr(ioParms.GetContextRef(), nil, false);
			ioParms.GetParamArray(i, arr);
			sLONG nbelem = arr.GetLength();
			for (sLONG j = 0; j < nbelem; ++j)
			{
				VJSValue val(arr.GetValueAt(j));
				if (val.IsString())
				{
					VString s;
					val.GetString(s);
					err = removeGroupFromGroup(ioParms, inGroup, s);
				}
				else if (val.IsInstanceOf("Group"))
				{
					CUAGGroup* group = val.GetObjectPrivateData<VJSGroup>();
					err = inGroup->RemoveFromGroup(group);
				}
			}
		}
		else if (ioParms.IsStringParam(i))
		{
			VString s;
			ioParms.GetStringParam(i, s);
			err = removeGroupFromGroup(ioParms, inGroup, s);
		}
		else
		{
			CUAGGroup* group = ioParms.GetParamObjectPrivateData<VJSGroup>(i);
			err = inGroup->RemoveFromGroup(group);
		}
	}
}
void VJSGlobalClass::do_SyncEvent(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*)
{
	VString s;
	bool okresult = false;
	if (ioParms.IsStringParam(1))
	{	ioParms.GetStringParam(1, s);
		if (!s.IsEmpty())
		{
			jsSyncEvent* sync = jsSyncEvent::RetainSyncEvent(s);
			if (sync != nil)
			{
				okresult = true;
				ioParms.ReturnValue(VJSSyncEvent::CreateInstance(ioParms.GetContextRef(), sync));
				sync->Release();
			}
		}
	}
	else
		vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1");
	if (!okresult)
		ioParms.ReturnNullValue();
}
void VJSGlobalClass::do_AtomicSection(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*)
{
	VString s;
	bool okresult = false;
	if (ioParms.IsStringParam(1))
	{
		ioParms.GetStringParam(1, s);
		if (!s.IsEmpty())
		{
			jsAtomicSection* atomsec = jsAtomicSection::RetainAtomicSection(s);
			if (atomsec != nil)
			{
				okresult = true;
				ioParms.ReturnValue(VJSAtomicSection::CreateInstance(ioParms.GetContextRef(), atomsec));
				atomsec->Release();
			}
		}
	}
	else
		vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1");
	if (!okresult)
		ioParms.ReturnNullValue();
}
void VJSGlobalClass::do_GetURLQuery(VJSParms_callStaticFunction& ioParms, VJSGlobalObject*)
{
	VString s;
	if (ioParms.IsStringParam(1) && ioParms.GetStringParam(1, s))
	{
		VFullURL url(s);
		VJSObject result(ioParms.GetContextRef());
		result.MakeEmpty();
		const VValueBag& values = url.GetValues();
		VIndex nbvalues = values.GetAttributesCount();
		for (VIndex i = 1; i <= nbvalues; i++)
		{
			VString attName;
			const VValueSingle* cv = values.GetNthAttribute(i, &attName);
			if (cv != nil)
			{
				result.SetProperty(attName, cv);
			}
		}
		ioParms.ReturnValue(result);
	}
	else
		vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1");
}