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);
});