Exemple #1
0
ExtVariant::ExtVariant(const ExtVariant& other)
{
	type = other.getType();
	strValue = other.getString();
	intValue = other.getInt();
	doubleValue = other.getDouble();
	booleanValue = other.getBoolean();
	objectValue = *other.getObject();
}
void NPVariantObject::ExtVariantToNPVariant(std::map<const ExtObject*, NPObject*>& objectsMap, NPP _instance,
		const ExtVariant& value, NPVariant& variant)
{
	switch(value.getType())
	{
	case EV_STRING:
		{
			const std::string& strValue = value.getString();
			NPUTF8* newValue = static_cast<NPUTF8*>(NPN_MemAlloc(strValue.size()));
			memcpy(newValue, strValue.c_str(), strValue.size());

			STRINGN_TO_NPVARIANT(newValue, strValue.size(), variant);
			break;
		}
	case EV_INT32:
		INT32_TO_NPVARIANT(value.getInt(), variant);
		break;
	case EV_DOUBLE:
		DOUBLE_TO_NPVARIANT(value.getDouble(), variant);
		break;
	case EV_BOOLEAN:
		BOOLEAN_TO_NPVARIANT(value.getBoolean(), variant);
		break;
	case EV_OBJECT:
		{
			lightspark::ExtObject* obj = value.getObject();
			OBJECT_TO_NPVARIANT(NPObjectObject::getNPObject(objectsMap, _instance, obj), variant);
			break;
		}
	case EV_NULL:
		NULL_TO_NPVARIANT(variant);
		break;
	case EV_VOID:
	default:
		VOID_TO_NPVARIANT(variant);
		break;
	}
}