From 2a33c4476fc06b925d74b8face30ac0b30fdeeff Mon Sep 17 00:00:00 2001 From: Itms Date: Fri, 2 Sep 2016 16:54:00 +0000 Subject: [PATCH] SpiderMonkey 38 upgrade: 34/35 Use the C++ API for Maps. Patch by leper. Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1121332 This was SVN commit r18688. --- .../serialization/BinarySerializer.cpp | 41 +++++++++---------- .../serialization/StdDeserializer.cpp | 10 ++--- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/source/simulation2/serialization/BinarySerializer.cpp b/source/simulation2/serialization/BinarySerializer.cpp index 2f8616d13c..467b991bba 100644 --- a/source/simulation2/serialization/BinarySerializer.cpp +++ b/source/simulation2/serialization/BinarySerializer.cpp @@ -232,28 +232,28 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val) } else if (protokey == JSProto_Map) { - // TODO: There's no C++ API (yet) to work with maps. This code relies on the internal - // structure of the Iterator object returned by Map.entries(). This is not ideal - // because the structure could change in the future (and actually does change with v31). - // Change this code if SpiderMonkey gets such an API. - u32 mapSize; - m_ScriptInterface.GetProperty(val, "size", mapSize); - m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_MAP); - m_Serializer.NumberU32_Unbounded("map size", mapSize); + m_Serializer.NumberU32_Unbounded("map size", JS::MapSize(cx, obj)); JS::RootedValue keyValueIterator(cx); - m_ScriptInterface.CallFunction(val, "entries", &keyValueIterator); - for (u32 i=0; i