diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-07-16 12:57:41 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-07-16 12:57:41 -0700 |
commit | 1238e2ecc7dcf77e10dece34fe6b6b074c66d43f (patch) | |
tree | 59e65a7c986490d302de98d554f21e210a6d5b97 /cpp/src/slice2java/Gen.cpp | |
parent | Fix comment in slice AlreadyRegisteredException / NotRegisteredException (diff) | |
download | ice-1238e2ecc7dcf77e10dece34fe6b6b074c66d43f.tar.bz2 ice-1238e2ecc7dcf77e10dece34fe6b6b074c66d43f.tar.xz ice-1238e2ecc7dcf77e10dece34fe6b6b074c66d43f.zip |
bug 2806 - Java holder changes for class/interface types
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 212e2e6a2cd..7f0aeeab492 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -3427,6 +3427,12 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) Output& out = output(); string typeS = typeToString(p, TypeModeIn, getPackage(contained)); out << sp << nl << "public final class " << name << "Holder"; + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); + ClassDeclPtr cl = ClassDeclPtr::dynamicCast(p); + if(!p->isLocal() && ((builtin && builtin->kind() == Builtin::KindObject) || cl)) + { + out << " extends Ice.ObjectHolderBase<" << typeS << ">"; + } out << sb; out << sp << nl << "public" << nl << name << "Holder()"; out << sb; @@ -3435,52 +3441,43 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) out << sb; out << nl << "this.value = value;"; out << eb; - if(!p->isLocal()) + if(!p->isLocal() && ((builtin && builtin->kind() == Builtin::KindObject) || cl)) { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) + out << sp << nl << "public void"; + out << nl << "patch(Ice.Object v)"; + out << sb; + out << nl << "try"; + out << sb; + out << nl << "value = (" << typeS << ")v;"; + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "IceInternal.Ex.throwUOE(type(), v.ice_id());"; + out << eb; + out << eb; + out << sp << nl << "public String" << nl << "type()"; + out << sb; + if(cl) { - out << sp << nl << "public class Patcher implements IceInternal.Patcher"; - if(_stream) + if(cl->isInterface()) { - out << ", Ice.ReadObjectCallback"; + out << nl << "return _" << cl->name() << "Disp.ice_staticId();"; } - out << sb; - out << nl << "public void"; - out << nl << "patch(Ice.Object v)"; - out << sb; - out << nl << "try"; - out << sb; - out << nl << "value = (" << typeS << ")v;"; - out << eb; - out << nl << "catch(ClassCastException ex)"; - out << sb; - out << nl << "IceInternal.Ex.throwUOE(type(), v.ice_id());"; - out << eb; - out << eb; - - out << sp << nl << "public String" << nl << "type()"; - out << sb; - out << nl << "return \"" << p->typeId() << "\";"; - out << eb; - - if(_stream) + else { - out << sp << nl << "public void" << nl << "invoke(Ice.Object v)"; - out << sb; - out << nl << "patch(v);"; - out << eb; + out << nl << "return " << typeS << ".ice_staticId();"; } - out << eb; - - out << sp << nl << "public Patcher"; - out << nl << "getPatcher()"; - out << sb; - out << nl << "return new Patcher();"; - out << eb; } + else + { + out << nl << "return \"" << p->typeId() << "\";"; + } + out << eb; + } + else + { + out << sp << nl << "public " << typeS << " value;"; } - out << sp << nl << "public " << typeS << " value;"; out << eb; close(); } @@ -3854,7 +3851,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out2 << sp << nl << "public static void" << nl << "read(Ice.InputStream __inS, " << name << "Holder __h)"; out2 << sb; - out2 << nl << "__inS.readObject(__h.getPatcher());"; + out2 << nl << "__inS.readObject(__h);"; out2 << eb; out2 << eb; @@ -4451,7 +4448,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) { out << nl << retS << "Holder __ret = new " << retS << "Holder();"; - out << nl << "__is.readObject(__ret.getPatcher());"; + out << nl << "__is.readObject(__ret);"; } else { @@ -5323,7 +5320,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) { - out << nl << "__is.readObject(" << paramName << ".getPatcher());"; + out << nl << "__is.readObject(" << paramName << ");"; } else { @@ -5336,7 +5333,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) { - out << nl << "__is.readObject(__ret.getPatcher());"; + out << nl << "__is.readObject(__ret);"; } else { |