You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2011/09/09 10:17:02 UTC

svn commit: r1167032 - in /thrift/trunk: compiler/cpp/src/generate/t_js_generator.cc lib/js/test/build.xml lib/js/test/test.js

Author: roger
Date: Fri Sep  9 08:17:02 2011
New Revision: 1167032

URL: http://svn.apache.org/viewvc?rev=1167032&view=rev
Log:
THRIFT-1238 Thrift JS client cannot read map of structures
Patch: Henrique Mendonca

Modified:
    thrift/trunk/compiler/cpp/src/generate/t_js_generator.cc
    thrift/trunk/lib/js/test/build.xml
    thrift/trunk/lib/js/test/test.js

Modified: thrift/trunk/compiler/cpp/src/generate/t_js_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_js_generator.cc?rev=1167032&r1=1167031&r2=1167032&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_js_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_js_generator.cc Fri Sep  9 08:17:02 2011
@@ -1354,6 +1354,13 @@ void t_js_generator::generate_deserializ
   scope_up(out);
 
   if (ttype->is_map()) {
+    out <<
+    indent() << "if (" << i << " > 0 ) {" << endl <<
+    indent() << "  if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << endl <<
+    indent() << "    input.rstack.pop();" << endl <<
+    indent() << "  }" << endl <<
+    indent() << "}" << endl;
+
     generate_deserialize_map_element(out, (t_map*)ttype, prefix);
   } else if (ttype->is_set()) {
     generate_deserialize_set_element(out, (t_set*)ttype, prefix);

Modified: thrift/trunk/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/build.xml?rev=1167032&r1=1167031&r2=1167032&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/build.xml (original)
+++ thrift/trunk/lib/js/test/build.xml Fri Sep  9 08:17:02 2011
@@ -144,7 +144,7 @@
       <exec executable="Xvfb" spawn="true" failonerror="false">
         <arg line=":99" />
       </exec>
-      <java classname="test.Httpd" fork="true" timeout="5000"
+      <java classname="test.Httpd" fork="true" timeout="10000"
         classpathref="test.classpath" failonerror="false" output="${build}/log/unittest.log">
         <arg value="../" />
       </java>

Modified: thrift/trunk/lib/js/test/test.js
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.js?rev=1167032&r1=1167031&r2=1167032&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/test.js (original)
+++ thrift/trunk/lib/js/test/test.js Fri Sep  9 08:17:02 2011
@@ -28,7 +28,18 @@ var client    = new ThriftTest.ThriftTes
 
 // all Languages in UTF-8
 var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Gal
 ego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynors
 k)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
-
+  
+function checkRecursively(map1, map2) {
+  if (typeof map1 !== 'function' && typeof map2 !== 'function') {
+    if (!map1 || typeof map1 !== 'object') {
+        equals(map1, map2);
+    } else {
+      for (var key in map1) {
+        checkRecursively(map1[key], map2[key]);
+      }
+    }
+  }
+}
 
 module("Base Types");
 
@@ -161,7 +172,7 @@ module("deeper!");
       }
     }
     
-    equals(JSON.stringify(mapMapTestOutput), JSON.stringify(mapMapTestExpectedResult));
+    checkRecursively(mapMapTestOutput, mapMapTestExpectedResult);
   });
 
 
@@ -201,8 +212,8 @@ module("Insanity");
   test("testInsanity", function() {
     var insanity = {
       "1":{
-        "3":{
-          "userMap":{ "8":8, "5":5 },
+        "2":{
+          "userMap":{ "5":5, "8":8 },
           "xtructs":[{
               "string_thing":"Goodbye4",
               "byte_thing":4,
@@ -217,8 +228,8 @@ module("Insanity");
             }
           ]
         },
-        "2":{
-          "userMap":{ "8":8, "5":5 },
+        "3":{
+          "userMap":{ "5":5, "8":8 },
           "xtructs":[{
               "string_thing":"Goodbye4",
               "byte_thing":4,
@@ -239,7 +250,8 @@ module("Insanity");
     var res = client.testInsanity("");
     ok(res, JSON.stringify(res));
     ok(insanity, JSON.stringify(insanity));
-    equals(JSON.stringify(res), JSON.stringify(insanity)); //TODO: read and compare maps recursively
+
+    checkRecursively(res, insanity);
   });