示例#1
0
void VJSDirectory::_getInternalStore( XBOX::VJSParms_getProperty& ioParms, CUAGDirectory* inDirectory)
{
	CDB4DBase* base = inDirectory->RetainAndExposeDB();
	if (base != NULL)
	{
		ioParms.ReturnValue(base->CreateJSDatabaseObject(ioParms.GetContext()));
		ReleaseRefCountable( &base);	// sc 20/06/2012
	}
	else
		ioParms.ReturnNullValue();
}
示例#2
0
void VJSStorageClass::_GetProperty (XBOX::VJSParms_getProperty &ioParms, VJSStorageObject *inStorageObject)
{
	xbox_assert(inStorageObject != NULL);

	XBOX::VString	name;

	if (!ioParms.GetPropertyName(name))

		ioParms.ReturnNullValue();

	else if (name.EqualToUSASCIICString("length")) {

		XBOX::VJSValue	length(ioParms.GetContext());

		length.SetNumber(inStorageObject->NumberKeysValues());

		ioParms.ReturnValue(length);

	} else {
		
		XBOX::VJSValue	value(ioParms.GetContext());

		value.SetNull();

		sLONG	i;

		for (i = 0; i < kNumberMethods; i++) 

			if (name.EqualToUSASCIICString(kMethodNames[i])) {

				ioParms.ForwardToParent();				
				break;

			}

		if (i == kNumberMethods) {

			inStorageObject->GetKeyValue(name, &value);
			ioParms.ReturnValue(value);

		}

	}
}
void VJSImage::_getMeta( XBOX::VJSParms_getProperty& ioParms, VJSPictureContainer* inPict)
{
	VPicture* pic = inPict->GetPict();
	if (inPict->MetaInfoInited())
	{
		ioParms.ReturnValue(VJSValue(ioParms.GetContextRef(), inPict->GetMetaInfo()));
	}
	else if (pic != nil)
	{
		/*
		const VPictureData* picdata = pic->RetainNthPictData(1);
		if (picdata != nil)
		*/
		{
			//const VValueBag* metadata = picdata->RetainMetadatas();
			const VValueBag* metadata = inPict->RetainMetaBag();
			if (metadata != nil)
			{
				VString jsons;
				metadata->GetJSONString(jsons, JSON_UniqueSubElementsAreNotArrays);
				VJSJSON json(ioParms.GetContextRef());
				metadata->Release();

				VJSValue result(json.Parse(jsons));

				if (!result.IsUndefined())
				{
	#if 0
					// plante pour l'instant, il faut que je comprenne
					inPict->SetMetaInfo(result, ioParms.GetContextRef());
					ioParms.ReturnValue(VJSValue(ioParms.GetContextRef(), inPict->GetMetaInfo()));
	#else
					ioParms.ReturnValue(VJSValue(ioParms.GetContextRef(), result));
	#endif
				}
				else
					ioParms.ReturnNullValue();
			}
			//picdata->Release();
		}
	}
}