Пример #1
0
static void _AddToList (XBOX::VJSContext &inContext, const XBOX::VString &inConstructorName, XBOX::VJSObject &inConstructedObject)
{
	if (inContext.GetGlobalObject().HasProperty(inConstructorName)) {

		XBOX::VJSObject	workerObject	= inContext.GetGlobalObject().GetPropertyAsObject(inConstructorName);

		if (workerObject.IsObject() && workerObject.HasProperty("list")) {

			XBOX::VJSValue	value	= workerObject.GetProperty("list");

			if (value.IsArray()) {

				XBOX::VJSArray	listArray(value);
				sLONG			i;

				for (i = 0; i < listArray.GetLength(); i++) {

					value = listArray.GetValueAt(i);
					if (value.IsNull()) {

						listArray.SetValueAt(i, inConstructedObject);
						break;

					}	

				}
				if (i == listArray.GetLength()) 

					listArray.PushValue(inConstructedObject);

			} else {

				xbox_assert(false);

			}

		} else {

			xbox_assert(false);

		}
			
	} else {

		xbox_assert(false);

	}
}
bool VRIAJSRuntimeContext::_AttachToJSContext( XBOX::VJSContext& inContext)
{
	bool done = inContext.GetGlobalObjectPrivateInstance()->SetSpecific( 'riax', this, VJSSpecifics::DestructorReleaseVObject);
	if (done)
	{
		Retain();
	}
	return done;
}
XBOX::VJSValue VJSStructuredClone::_ConstructObject (XBOX::VJSContext inContext, const XBOX::VString &inConstructorName, XBOX::VJSValue inArgument)
{
	XBOX::VJSObject				object = inContext.GetGlobalObject().GetPropertyAsObject(inConstructorName);
	std::vector<XBOX::VJSValue>	arguments;
	XBOX::VJSValue				value(inContext);

	arguments.push_back(inArgument);
	if (object.CallAsConstructor(&arguments, &object, NULL)) 

		value.SetValueRef((JS4D::ObjectRef) object.GetObjectRef());

	else

		value.SetUndefined();

	return value;
}
bool VRIAJSRuntimeContext::_DetachFromJSContext( XBOX::VJSContext& inContext)
{
	assert( VRIAJSRuntimeContext::GetFromJSContext( inContext) == this);
	return inContext.GetGlobalObjectPrivateInstance()->SetSpecific( 'riax', NULL, VJSSpecifics::DestructorReleaseVObject);
}