Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/serialization/StdDeserializer.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | void CStdDeserializer::GetScriptBackref(size_t tag, JS::MutableHandleObject ret) | ||||
ENSURE(m_ScriptBackrefs.size() > tag); | ENSURE(m_ScriptBackrefs.size() > tag); | ||||
ret.set(m_ScriptBackrefs[tag]); | ret.set(m_ScriptBackrefs[tag]); | ||||
} | } | ||||
//////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////// | ||||
JS::Value CStdDeserializer::ReadScriptVal(const char* UNUSED(name), JS::HandleObject appendParent) | JS::Value CStdDeserializer::ReadScriptVal(const char* UNUSED(name), JS::HandleObject appendParent) | ||||
{ | { | ||||
ScriptInterface::Request rq(m_ScriptInterface); | ScriptRequest rq(m_ScriptInterface); | ||||
uint8_t type; | uint8_t type; | ||||
NumberU8_Unbounded("type", type); | NumberU8_Unbounded("type", type); | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case SCRIPT_TYPE_VOID: | case SCRIPT_TYPE_VOID: | ||||
return JS::UndefinedValue(); | return JS::UndefinedValue(); | ||||
▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CStdDeserializer::ScriptString(const char* name, JS::MutableHandleString out) | void CStdDeserializer::ScriptString(const char* name, JS::MutableHandleString out) | ||||
{ | { | ||||
#if BYTE_ORDER != LITTLE_ENDIAN | #if BYTE_ORDER != LITTLE_ENDIAN | ||||
#error TODO: probably need to convert JS strings from little-endian | #error TODO: probably need to convert JS strings from little-endian | ||||
#endif | #endif | ||||
ScriptInterface::Request rq(m_ScriptInterface); | ScriptRequest rq(m_ScriptInterface); | ||||
bool isLatin1; | bool isLatin1; | ||||
Bool("isLatin1", isLatin1); | Bool("isLatin1", isLatin1); | ||||
if (isLatin1) | if (isLatin1) | ||||
{ | { | ||||
std::vector<JS::Latin1Char> str; | std::vector<JS::Latin1Char> str; | ||||
ReadStringLatin1(name, str); | ReadStringLatin1(name, str); | ||||
Show All 14 Lines | |||||
void CStdDeserializer::ScriptVal(const char* name, JS::MutableHandleValue out) | void CStdDeserializer::ScriptVal(const char* name, JS::MutableHandleValue out) | ||||
{ | { | ||||
out.set(ReadScriptVal(name, nullptr)); | out.set(ReadScriptVal(name, nullptr)); | ||||
} | } | ||||
void CStdDeserializer::ScriptObjectAppend(const char* name, JS::HandleValue objVal) | void CStdDeserializer::ScriptObjectAppend(const char* name, JS::HandleValue objVal) | ||||
{ | { | ||||
ScriptInterface::Request rq(m_ScriptInterface); | ScriptRequest rq(m_ScriptInterface); | ||||
if (!objVal.isObject()) | if (!objVal.isObject()) | ||||
throw PSERROR_Deserialize_ScriptError(); | throw PSERROR_Deserialize_ScriptError(); | ||||
JS::RootedObject obj(rq.cx, &objVal.toObject()); | JS::RootedObject obj(rq.cx, &objVal.toObject()); | ||||
ReadScriptVal(name, obj); | ReadScriptVal(name, obj); | ||||
} | } |
Wildfire Games · Phabricator