diff options
author | Jose <jose@zeroc.com> | 2014-06-17 19:09:31 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2014-06-17 19:09:31 +0200 |
commit | db7d72e5343b2e03406e5dea9b2d5eb7d5b6385f (patch) | |
tree | 61e4cc928a04956119a5a423c89d2b25b8e66bba | |
parent | Fix for ICE-5321: Ice.Config set to empty value (C++, Java, C#) (diff) | |
download | ice-db7d72e5343b2e03406e5dea9b2d5eb7d5b6385f.tar.bz2 ice-db7d72e5343b2e03406e5dea9b2d5eb7d5b6385f.tar.xz ice-db7d72e5343b2e03406e5dea9b2d5eb7d5b6385f.zip |
JavaScript nested modules patch
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 5 | ||||
-rw-r--r-- | cpp/test/Ice/objects/Test.ice | 36 | ||||
-rw-r--r-- | cpp/test/Ice/objects/TestI.cpp | 28 | ||||
-rw-r--r-- | cpp/test/Ice/objects/TestI.h | 6 | ||||
-rw-r--r-- | js/src/Ice/BasicStream.js | 4 | ||||
-rw-r--r-- | js/src/Ice/Exception.js | 2 | ||||
-rw-r--r-- | js/test/Ice/objects/Client.js | 46 | ||||
-rw-r--r-- | js/test/Ice/objects/Test.ice | 36 |
8 files changed, 157 insertions, 6 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index a95735661f6..1542b04f8fd 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -835,7 +835,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) // // For an inner module we write // - // Foo.Bar = global.Foo ? (global.Foo.Bar || {}) : {}; + // Foo.Bar = Foo.Bar || {}; // const string scoped = getLocalScope(p->scoped()); @@ -850,8 +850,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) } else { - _out << nl << scoped << " = global." << getLocalScope(p->scope()) << " ? (global." << scoped - << " || {}) : {};"; + _out << nl << scoped << " = " << scoped << " || {};"; } } return true; diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice index 51bad251fd7..93771fce993 100644 --- a/cpp/test/Ice/objects/Test.ice +++ b/cpp/test/Ice/objects/Test.ice @@ -105,6 +105,36 @@ class CompactExt(CompactExtId) extends Compact { }; +module Inner +{ + +class A +{ + ::Test::A theA; +}; + +exception Ex +{ + string reason; +}; + +module Sub +{ + +class A +{ + ::Test::Inner::A theA; +}; + +exception Ex +{ + string reason; +}; + +}; + +}; + class Initial { void shutdown(); @@ -126,6 +156,12 @@ class Initial BaseSeq opBaseSeq(BaseSeq inSeq, out BaseSeq outSeq); Compact getCompact(); + + Inner::A getInnerA(); + Inner::Sub::A getInnerSubA(); + + void throwInnerEx() throws Inner::Ex; + void throwInnerSubEx() throws Inner::Sub::Ex; }; class Empty diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp index 595bc6f3e18..a5df2c6d3c9 100644 --- a/cpp/test/Ice/objects/TestI.cpp +++ b/cpp/test/Ice/objects/TestI.cpp @@ -223,6 +223,34 @@ InitialI::getCompact(const Ice::Current&) return new CompactExt(); } +Test::Inner::APtr +InitialI::getInnerA(const Ice::Current&) +{ + return new Inner::A(_b1); +} + +Test::Inner::Sub::APtr +InitialI::getInnerSubA(const Ice::Current&) +{ + return new Inner::Sub::A(new Inner::A(_b1)); +} + +void +InitialI::throwInnerEx(const Ice::Current&) +{ + Inner::Ex ex; + ex.reason = "Inner::Ex"; + throw ex; +} + +void +InitialI::throwInnerSubEx(const Ice::Current&) +{ + Inner::Sub::Ex ex; + ex.reason = "Inner::Sub::Ex"; + throw ex; +} + IPtr InitialI::getJ(const Ice::Current&) { diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h index 8f7b280d9f2..622fb011cb5 100644 --- a/cpp/test/Ice/objects/TestI.h +++ b/cpp/test/Ice/objects/TestI.h @@ -115,6 +115,12 @@ public: virtual Test::CompactPtr getCompact(const Ice::Current&); + virtual Test::Inner::APtr getInnerA(const Ice::Current&); + virtual Test::Inner::Sub::APtr getInnerSubA(const Ice::Current&); + + virtual void throwInnerEx(const Ice::Current&); + virtual void throwInnerSubEx(const Ice::Current&); + private: Ice::ObjectAdapterPtr _adapter; diff --git a/js/src/Ice/BasicStream.js b/js/src/Ice/BasicStream.js index db423be4c91..d0bdb325076 100644 --- a/js/src/Ice/BasicStream.js +++ b/js/src/Ice/BasicStream.js @@ -2765,7 +2765,7 @@ var obj = null, Class; try { - var typeId = id.length > 2 ? id.substr(2).replace("::", ".") : ""; + var typeId = id.length > 2 ? id.substr(2).replace(/::/g, ".") : ""; /*jshint -W061 */ Class = eval(typeId); /*jshint +W061 */ @@ -2863,7 +2863,7 @@ try { - var typeId = id.length > 2 ? id.substr(2).replace("::", ".") : ""; + var typeId = id.length > 2 ? id.substr(2).replace(/::/g, ".") : ""; /*jshint -W061 */ Class = eval(typeId); /*jshint +W061 */ diff --git a/js/src/Ice/Exception.js b/js/src/Ice/Exception.js index 032ace3339d..929b0b22790 100644 --- a/js/src/Ice/Exception.js +++ b/js/src/Ice/Exception.js @@ -62,7 +62,7 @@ if(stack !== undefined) { - var name = object.ice_name ? object.ice_name().replace("::", ".") : ""; + var name = object.ice_name ? object.ice_name().replace(/::/g, ".") : ""; Object.defineProperty(object, "stack", { get: function(){ return stack; diff --git a/js/test/Ice/objects/Client.js b/js/test/Ice/objects/Client.js index 02dbbc3f2eb..45578068894 100644 --- a/js/test/Ice/objects/Client.js +++ b/js/test/Ice/objects/Client.js @@ -167,6 +167,10 @@ return new JI(); case "::Test::H": return new HI(); + case "::Test::Inner::A": + return new Test.Inner.A(); + case "::Test::Inner::Sub::A": + return new Test.Inner.Sub.A(); default: break; } @@ -210,6 +214,8 @@ communicator.addObjectFactory(factory, "::Test::I"); communicator.addObjectFactory(factory, "::Test::J"); communicator.addObjectFactory(factory, "::Test::H"); + communicator.addObjectFactory(factory, "::Test::Inner::A"); + communicator.addObjectFactory(factory, "::Test::Inner::Sub::A"); out.write("testing stringToProxy... "); ref = "initial:default -p 12010"; @@ -432,6 +438,46 @@ test(ex instanceof Ice.UnexpectedObjectException); test(ex.type == "::Test::AlsoEmpty"); test(ex.expectedType == "::Test::Empty"); + } + ).then( + function() + { + out.writeLine("ok"); + out.write("testing inner modules... "); + return initial.getInnerA(); + } + ).then( + function(innerA) + { + test(innerA instanceof Test.Inner.A); + test(innerA.theA instanceof Test.B); + return initial.getInnerSubA(); + } + ).then( + function(innerA) + { + test(innerA instanceof Test.Inner.Sub.A); + test(innerA.theA instanceof Test.Inner.A); + return initial.throwInnerEx(); + } + ).then( + function() + { + test(false); + }, + function(ex) + { + test(ex.reason == "Inner::Ex"); + return initial.throwInnerSubEx(); + } + ).then( + function() + { + test(false); + }, + function(ex) + { + test(ex.reason == "Inner::Sub::Ex"); out.writeLine("ok"); return initial.shutdown(); } diff --git a/js/test/Ice/objects/Test.ice b/js/test/Ice/objects/Test.ice index b8cc98ca9ca..cd73e1a62aa 100644 --- a/js/test/Ice/objects/Test.ice +++ b/js/test/Ice/objects/Test.ice @@ -109,6 +109,36 @@ class CompactExt(CompactExtId) extends Compact { }; +module Inner +{ + +class A +{ + ::Test::A theA; +}; + +exception Ex +{ + string reason; +}; + +module Sub +{ + +class A +{ + ::Test::Inner::A theA; +}; + +exception Ex +{ + string reason; +}; + +}; + +}; + class Initial { void shutdown(); @@ -130,6 +160,12 @@ class Initial BaseSeq opBaseSeq(BaseSeq inSeq, out BaseSeq outSeq); Compact getCompact(); + + Inner::A getInnerA(); + Inner::Sub::A getInnerSubA(); + + void throwInnerEx() throws Inner::Ex; + void throwInnerSubEx() throws Inner::Sub::Ex; }; class Empty |