Example #1
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.GetContext(), 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>();
					if (group != nil)
						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 VJSUser::_putInto(VJSParms_callStaticFunction& ioParms, CUAGUser* inUser)
{
	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 = putUserIntoGroup(ioParms, inUser, s);
				}
				else if (val.IsInstanceOf("Group"))
				{
					CUAGGroup* group = val.GetObjectPrivateData<VJSGroup>();
					err = inUser->PutIntoGroup(group);
				}
			}
		}
		else if (ioParms.IsStringParam(i))
		{
			VString s;
			ioParms.GetStringParam(i, s);
			err = putUserIntoGroup(ioParms, inUser, s);
		}
		else
		{
			CUAGGroup* group = ioParms.GetParamObjectPrivateData<VJSGroup>(i);
			err = inUser->PutIntoGroup(group);
		}
	}
}