summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2003-12-12 23:09:58 +0000
committerMark Spruiell <mes@zeroc.com>2003-12-12 23:09:58 +0000
commit66a04b231063d2e8a52c319d639b63fc5986a10a (patch)
treea75289f28ccc09973d52ad0026c62f678f5d8ea3 /cpp/src/slice2java/Gen.cpp
parentComments explaining why we have handshake timeouts set to a min of 5s and (diff)
downloadice-66a04b231063d2e8a52c319d639b63fc5986a10a.tar.bz2
ice-66a04b231063d2e8a52c319d639b63fc5986a10a.tar.xz
ice-66a04b231063d2e8a52c319d639b63fc5986a10a.zip
Adding support for global metadata. Removing the --package option in
slice2java. Using global metadata to define packaging in slice2java, slice2freezej.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp516
1 files changed, 249 insertions, 267 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index ef533a1b235..0f7244303e6 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -62,8 +62,8 @@ sliceModeToIceMode(const OperationPtr& op)
return mode;
}
-Slice::JavaVisitor::JavaVisitor(const string& dir, const string& package) :
- JavaGenerator(dir, package)
+Slice::JavaVisitor::JavaVisitor(const string& dir) :
+ JavaGenerator(dir)
{
}
@@ -72,7 +72,7 @@ Slice::JavaVisitor::~JavaVisitor()
}
string
-Slice::JavaVisitor::getParams(const OperationPtr& op, const string& scope)
+Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package)
{
string params;
ParamDeclList paramList = op->parameters();
@@ -82,7 +82,7 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& scope)
{
params += ", ";
}
- string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, scope);
+ string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package);
params += typeString;
params += ' ';
params += fixKwd((*q)->name());
@@ -91,13 +91,13 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& scope)
}
string
-Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& scope, bool amd)
+Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& package, bool amd)
{
string name = fixKwd(op->name());
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string classNameAsync = getAbsolute(cl->scoped(), scope, amd ? "AMD_" : "AMI_", '_' + name);
+ string classNameAsync = getAbsolute(cl, package, amd ? "AMD_" : "AMI_", '_' + name);
string params = classNameAsync + " __cb";
ParamDeclList paramList = op->parameters();
@@ -105,7 +105,7 @@ Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& scope,
{
if(!(*q)->isOutParam())
{
- string typeString = typeToString((*q)->type(), TypeModeIn, scope);
+ string typeString = typeToString((*q)->type(), TypeModeIn, package);
params += ", ";
params += typeString;
params += ' ';
@@ -116,13 +116,13 @@ Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& scope,
}
string
-Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& scope)
+Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& package)
{
string params;
TypePtr ret = op->returnType();
if(ret)
{
- string retS = typeToString(ret, TypeModeIn, scope);
+ string retS = typeToString(ret, TypeModeIn, package);
params += retS;
params += " __ret";
}
@@ -135,7 +135,7 @@ Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& scope
{
params += ", ";
}
- string typeString = typeToString((*q)->type(), TypeModeIn, scope);
+ string typeString = typeToString((*q)->type(), TypeModeIn, package);
params += typeString;
params += ' ';
params += fixKwd((*q)->name());
@@ -211,7 +211,7 @@ Slice::JavaVisitor::getArgsAsyncCB(const OperationPtr& op)
}
void
-Slice::JavaVisitor::writeThrowsClause(const string& scope, const ExceptionList& throws)
+Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList& throws)
{
//
// Don't include local exceptions in the throws clause
@@ -235,7 +235,7 @@ Slice::JavaVisitor::writeThrowsClause(const string& scope, const ExceptionList&
{
out << "," << nl;
}
- out << getAbsolute((*r)->scoped(), scope);
+ out << getAbsolute(*r, package);
count++;
}
}
@@ -245,7 +245,7 @@ Slice::JavaVisitor::writeThrowsClause(const string& scope, const ExceptionList&
}
void
-Slice::JavaVisitor::writeDelegateThrowsClause(const string& scope, const ExceptionList& throws)
+Slice::JavaVisitor::writeDelegateThrowsClause(const string& package, const ExceptionList& throws)
{
Output& out = output();
out.inc();
@@ -262,7 +262,7 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& scope, const Excepti
if(!(*r)->isLocal())
{
out << "," << nl;
- out << getAbsolute((*r)->scoped(), scope);
+ out << getAbsolute(*r, package);
}
}
out.restoreIndent();
@@ -271,7 +271,7 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& scope, const Excepti
void
Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string& name, int& iter,
- const list<string>& metaData)
+ const StringList& metaData)
{
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
@@ -350,7 +350,7 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string
string listType = findMetaData(metaData);
if(listType.empty())
{
- list<string> l = seq->getMetaData();
+ StringList l = seq->getMetaData();
listType = findMetaData(l);
}
@@ -381,7 +381,7 @@ void
Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
{
string name = fixKwd(p->name());
- string scope = p->scope();
+ string package = getPackage(p);
string scoped = p->scoped();
ClassList bases = p->bases();
@@ -397,8 +397,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
StringList::const_iterator firstIter = ids.begin();
StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped);
assert(scopedIter != ids.end());
- StringList::difference_type scopedPos
- = ice_distance(firstIter, scopedIter);
+ StringList::difference_type scopedPos = ice_distance(firstIter, scopedIter);
out << sp << nl << "public static final String[] __ids =";
out << sb;
@@ -498,18 +497,18 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
iter = 0;
for(q = inParams.begin(); q != inParams.end(); ++q)
{
- string typeS = typeToString(q->first, TypeModeIn, scope);
+ string typeS = typeToString(q->first, TypeModeIn, package);
BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
{
out << nl << typeS << "Holder " << fixKwd(q->second) << " = new " << typeS << "Holder();";
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), false, iter, true,
- std::list<std::string>(), std::string());
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), false, iter, true,
+ StringList(), string());
}
else
{
out << nl << typeS << ' ' << fixKwd(q->second) << ';';
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), false, iter);
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), false, iter);
}
}
if(op->sendsClasses())
@@ -522,7 +521,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
//
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- string typeS = typeToString(q->first, TypeModeOut, scope);
+ string typeS = typeToString(q->first, TypeModeOut, package);
out << nl << typeS << ' ' << fixKwd(q->second) << " = new " << typeS << "();";
}
@@ -537,7 +536,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << nl;
if(ret)
{
- string retS = typeToString(ret, TypeModeReturn, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
out << retS << " __ret = ";
}
out << "__obj." << opName << '(';
@@ -562,11 +561,11 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
//
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), true, iter, true);
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), true, iter, true);
}
if(ret)
{
- writeMarshalUnmarshalCode(out, scope, ret, "__ret", true, iter);
+ writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter);
}
if(op->returnsClasses())
{
@@ -583,7 +582,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
ExceptionList::const_iterator t;
for(t = throws.begin(); t != throws.end(); ++t)
{
- string exS = getAbsolute((*t)->scoped(), scope);
+ string exS = getAbsolute(*t, package);
out << nl << "catch(" << exS << " ex)";
out << sb;
out << nl << "__os.writeUserException(ex);";
@@ -620,18 +619,18 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
iter = 0;
for(q = inParams.begin(); q != inParams.end(); ++q)
{
- string typeS = typeToString(q->first, TypeModeIn, scope);
+ string typeS = typeToString(q->first, TypeModeIn, package);
BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
{
out << nl << typeS << "Holder " << fixKwd(q->second) << " = new " << typeS << "Holder();";
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), false, iter, true,
- std::list<std::string>(), std::string());
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), false, iter, true,
+ StringList(), string());
}
else
{
out << nl << typeS << ' ' << fixKwd(q->second) << ';';
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), false, iter);
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), false, iter);
}
}
if(op->sendsClasses())
@@ -756,11 +755,11 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
string base;
if(cl->isInterface())
{
- base = getAbsolute(cl->scoped(), scope, "_", "Disp");
+ base = getAbsolute(cl, package, "_", "Disp");
}
else
{
- base = getAbsolute(cl->scoped(), scope);
+ base = getAbsolute(cl, package);
}
out << nl << "return " << base << ".___" << opName << "(this, in, __current);";
}
@@ -777,11 +776,9 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
}
}
-Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& package,
- const string& dir) :
+Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir) :
_base(base),
_includePaths(includePaths),
- _package(package),
_dir(dir)
{
}
@@ -799,60 +796,60 @@ Slice::Gen::operator!() const
void
Slice::Gen::generate(const UnitPtr& p)
{
- OpsVisitor opsVisitor(_dir, _package);
+ OpsVisitor opsVisitor(_dir);
p->visit(&opsVisitor);
- TypesVisitor typesVisitor(_dir, _package);
+ TypesVisitor typesVisitor(_dir);
p->visit(&typesVisitor);
- HolderVisitor holderVisitor(_dir, _package);
+ HolderVisitor holderVisitor(_dir);
p->visit(&holderVisitor);
- HelperVisitor helperVisitor(_dir, _package);
+ HelperVisitor helperVisitor(_dir);
p->visit(&helperVisitor);
- ProxyVisitor proxyVisitor(_dir, _package);
+ ProxyVisitor proxyVisitor(_dir);
p->visit(&proxyVisitor);
- DelegateVisitor delegateVisitor(_dir, _package);
+ DelegateVisitor delegateVisitor(_dir);
p->visit(&delegateVisitor);
- DelegateMVisitor delegateMVisitor(_dir, _package);
+ DelegateMVisitor delegateMVisitor(_dir);
p->visit(&delegateMVisitor);
- DelegateDVisitor delegateDVisitor(_dir, _package);
+ DelegateDVisitor delegateDVisitor(_dir);
p->visit(&delegateDVisitor);
- DispatcherVisitor dispatcherVisitor(_dir, _package);
+ DispatcherVisitor dispatcherVisitor(_dir);
p->visit(&dispatcherVisitor);
- AsyncVisitor asyncVisitor(_dir, _package);
+ AsyncVisitor asyncVisitor(_dir);
p->visit(&asyncVisitor);
}
void
Slice::Gen::generateTie(const UnitPtr& p)
{
- TieVisitor tieVisitor(_dir, _package);
+ TieVisitor tieVisitor(_dir);
p->visit(&tieVisitor);
}
void
Slice::Gen::generateImpl(const UnitPtr& p)
{
- ImplVisitor implVisitor(_dir, _package);
+ ImplVisitor implVisitor(_dir);
p->visit(&implVisitor);
}
void
Slice::Gen::generateImplTie(const UnitPtr& p)
{
- ImplTieVisitor implTieVisitor(_dir, _package);
+ ImplTieVisitor implTieVisitor(_dir);
p->visit(&implTieVisitor);
}
-Slice::Gen::OpsVisitor::OpsVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::OpsVisitor::OpsVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -860,10 +857,9 @@ bool
Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
{
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "_", "Operations");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "_", "Operations");
//
// Don't generate an Operations interface for non-abstract classes
@@ -902,7 +898,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
{
first = false;
}
- out << getAbsolute((*q)->scoped(), scope, "_", "Operations");
+ out << getAbsolute(*q, package, "_", "Operations");
}
++q;
}
@@ -928,7 +924,7 @@ Slice::Gen::OpsVisitor::visitOperation(const OperationPtr& p)
string name = fixKwd(p->name());
ContainerPtr container = p->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string scope = cl->scope();
+ string package = getPackage(cl);
TypePtr ret;
string params;
@@ -937,15 +933,15 @@ Slice::Gen::OpsVisitor::visitOperation(const OperationPtr& p)
if(amd)
{
- params = getParamsAsync(p, scope, true);
+ params = getParamsAsync(p, package, true);
}
else
{
- params = getParams(p, scope);
+ params = getParams(p, package);
ret = p->returnType();
}
- string retS = typeToString(ret, TypeModeReturn, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
Output& out = output();
@@ -963,12 +959,12 @@ Slice::Gen::OpsVisitor::visitOperation(const OperationPtr& p)
ExceptionList throws = p->throws();
throws.sort();
throws.unique();
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << ';';
}
-Slice::Gen::TieVisitor::TieVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::TieVisitor::TieVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -976,10 +972,9 @@ bool
Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
{
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "_", "Tie");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "_", "Tie");
//
// Don't generate a TIE class for a non-abstract class
@@ -1059,29 +1054,30 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
+ bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
string opName = fixKwd((*r)->name());
+ if(hasAMD)
+ {
+ opName += "_async";
+ }
TypePtr ret = (*r)->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
-
- string params = getParams((*r), scope);
- string args = getArgs(*r);
+ string retS = typeToString(ret, TypeModeReturn, package);
- bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
+ string params, args;
+ if(hasAMD)
+ {
+ params = getParamsAsync((*r), package, true);
+ args = getArgsAsync(*r);
+ }
+ else
+ {
+ params = getParams((*r), package);
+ args = getArgs(*r);
+ }
out << sp;
- out << nl << "public " << (hasAMD ? "void" : retS) << nl << opName;
- if(hasAMD)
- {
- out << "_async";
- }
- out << '(';
- if(hasAMD)
- {
- ContainedPtr definingContainer = ContainedPtr::dynamicCast((*r)->container());
- out << "AMD_" << fixKwd(definingContainer->name()) << '_' << opName << " __cb, ";
- }
- out << params;
+ out << nl << "public " << (hasAMD ? "void" : retS) << nl << opName << '(' << params;
if(!p->isLocal())
{
@@ -1096,15 +1092,14 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
ExceptionList throws = (*r)->throws();
throws.sort();
throws.unique();
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << sb;
out << nl;
if(ret && !hasAMD)
{
out << "return ";
}
- out << "_ice_delegate." << opName << (hasAMD ? "_async(__cb, " : "(");
- out << args;
+ out << "_ice_delegate." << opName << "(" << args;
if(!p->isLocal())
{
if(!args.empty())
@@ -1124,8 +1119,8 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::TypesVisitor::TypesVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::TypesVisitor::TypesVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -1133,10 +1128,9 @@ bool
Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped);
+ string package = getPackage(p);
+ string absolute = getAbsolute(p);
if(!open(absolute))
{
@@ -1166,7 +1160,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
- out << ',' << nl << getAbsolute((*q)->scoped(), scope);
+ out << ',' << nl << getAbsolute(*q, package);
q++;
}
}
@@ -1196,7 +1190,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
out << " extends ";
ClassDefPtr base = bases.front();
- out << getAbsolute(base->scoped(), scope);
+ out << getAbsolute(base, package);
bases.pop_front();
}
@@ -1213,7 +1207,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
- implements.push_back(getAbsolute((*q)->scoped(), scope));
+ implements.push_back(getAbsolute(*q, package));
q++;
}
}
@@ -1228,7 +1222,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(q != implements.begin())
{
- out << nl << ',';
+ out << ',' << nl;
}
out << *q;
q++;
@@ -1285,8 +1279,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
- list<string> metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
+ StringList metaData = (*d)->getMetaData();
+ writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
}
out << nl << "__os.endWriteSlice();";
out << nl << "super.__write(__os, __marshalFacets);";
@@ -1326,8 +1320,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
}
string memberName = fixKwd((*d)->name());
- string memberScope = fixKwd((*d)->scope());
- string memberType = typeToString((*d)->type(), TypeModeMember, memberScope);
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
out << nl << memberName << " = (" << memberType << ")v;";
if(allClassMembers.size() > 1)
{
@@ -1373,7 +1366,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
long classMemberCount = allClassMembers.size() - classMembers.size();
for(d = members.begin(); d != members.end(); ++d)
{
- list<string> metaData = (*d)->getMetaData();
+ StringList metaData = (*d)->getMetaData();
ostringstream patchParams;
BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
@@ -1383,7 +1376,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
patchParams << "new Patcher(" << classMemberCount++ << ')';
}
}
- writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
+ writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
patchParams.str());
}
out << nl << "__is.endReadSlice();";
@@ -1408,8 +1401,8 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
string name = fixKwd(p->name());
string scoped = p->scoped();
ExceptionPtr base = p->base();
- string scope = p->scope();
- string absolute = getAbsolute(scoped);
+ string package = getPackage(p);
+ string absolute = getAbsolute(p);
if(!open(absolute))
{
@@ -1433,7 +1426,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
}
else
{
- out << getAbsolute(base->scoped(), p->scope());
+ out << getAbsolute(base, package);
}
out << sb;
@@ -1454,7 +1447,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
{
string name = fixKwd(p->name());
string scoped = p->scoped();
- string scope = p->scope();
+ string package = getPackage(p);
ExceptionPtr base = p->base();
DataMemberList members = p->dataMembers();
@@ -1463,13 +1456,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)";
out << sb;
- out << nl << "__os.writeString(\"" << p->scoped() << "\");";
+ out << nl << "__os.writeString(\"" << scoped << "\");";
out << nl << "__os.startWriteSlice();";
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
- list<string> metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
+ StringList metaData = (*d)->getMetaData();
+ writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
}
out << nl << "__os.endWriteSlice();";
if(base)
@@ -1512,8 +1505,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
}
string memberName = fixKwd((*d)->name());
- string memberScope = fixKwd((*d)->scope());
- string memberType = typeToString((*d)->type(), TypeModeMember, memberScope);
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
out << nl << memberName << " = (" << memberType << ")v;";
if(allClassMembers.size() > 1)
{
@@ -1566,8 +1558,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
patchParams << "new Patcher(" << classMemberCount++ << ')';
}
}
- list<string> metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
+ StringList metaData = (*d)->getMetaData();
+ writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
patchParams.str());
}
out << nl << "__is.endReadSlice();";
@@ -1597,8 +1589,7 @@ bool
Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
{
string name = fixKwd(p->name());
- string scoped = p->scoped();
- string absolute = getAbsolute(scoped);
+ string absolute = getAbsolute(p);
if(!open(absolute))
{
@@ -1616,7 +1607,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
void
Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
{
- string scope = p->scope();
+ string package = getPackage(p);
Output& out = output();
@@ -1624,7 +1615,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
DataMemberList::const_iterator d;
int iter;
- string typeS = typeToString(p, TypeModeIn, scope);
+ string typeS = typeToString(p, TypeModeIn, package);
out << sp << nl << "public boolean" << nl << "equals(java.lang.Object rhs)";
out << sb;
@@ -1687,11 +1678,11 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
SequencePtr seq = SequencePtr::dynamicCast((*d)->type());
if(seq)
{
- list<string> metaData = (*d)->getMetaData();
+ StringList metaData = (*d)->getMetaData();
string listType = findMetaData(metaData);
if(listType.empty())
{
- list<string> l = seq->getMetaData();
+ StringList l = seq->getMetaData();
listType = findMetaData(l);
}
if(!listType.empty())
@@ -1730,7 +1721,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(d = members.begin(); d != members.end(); ++d)
{
string memberName = fixKwd((*d)->name());
- list<string> metaData = (*d)->getMetaData();
+ StringList metaData = (*d)->getMetaData();
writeHashCode(out, (*d)->type(), memberName, iter, metaData);
}
out << nl << "return __h;";
@@ -1751,8 +1742,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
- list<string> metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
+ StringList metaData = (*d)->getMetaData();
+ writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
}
out << eb;
@@ -1791,8 +1782,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
}
string memberName = fixKwd((*d)->name());
- string memberScope = fixKwd((*d)->scope());
- string memberType = typeToString((*d)->type(), TypeModeMember, memberScope);
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
out << nl << memberName << " = (" << memberType << ")v;";
if(classMembers.size() > 1)
{
@@ -1841,8 +1831,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
patchParams << "new Patcher(" << classMemberCount++ << ')';
}
}
- list<string> metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
+ StringList metaData = (*d)->getMetaData();
+ writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
patchParams.str());
}
out << eb;
@@ -1858,8 +1848,8 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
string name = fixKwd(p->name());
ContainerPtr container = p->container();
ContainedPtr contained = ContainedPtr::dynamicCast(container);
- list<string> metaData = p->getMetaData();
- string s = typeToString(p->type(), TypeModeMember, contained->scope(), metaData);
+ StringList metaData = p->getMetaData();
+ string s = typeToString(p->type(), TypeModeMember, getPackage(contained), metaData);
Output& out = output();
out << sp << nl << "public " << s << ' ' << name << ';';
}
@@ -1868,8 +1858,7 @@ void
Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
{
string name = fixKwd(p->name());
- string scoped = p->scoped();
- string absolute = getAbsolute(scoped);
+ string absolute = getAbsolute(p);
EnumeratorList enumerators = p->getEnumerators();
EnumeratorList::const_iterator en;
size_t sz = enumerators.size();
@@ -1968,9 +1957,8 @@ void
Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
{
string name = fixKwd(p->name());
- string scoped = p->scoped();
- string scope = p->scope();
- string absolute = getAbsolute(scoped);
+ string package = getPackage(p);
+ string absolute = getAbsolute(p);
TypePtr type = p->type();
if(!open(absolute))
@@ -1980,7 +1968,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
Output& out = output();
out << sp << nl << "public interface " << name;
out << sb;
- out << nl << typeToString(type, TypeModeIn, scope) << " value = ";
+ out << nl << typeToString(type, TypeModeIn, package) << " value = ";
BuiltinPtr bp;
EnumPtr ep;
@@ -2074,7 +2062,13 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
}
else if(ep = EnumPtr::dynamicCast(type))
{
- out << getAbsolute(ep->scoped(), scope) << '.' << fixKwd(p->value());
+ string val = p->value();
+ string::size_type pos = val.rfind(':');
+ if(pos != string::npos)
+ {
+ val.erase(0, pos + 1);
+ }
+ out << getAbsolute(ep, package) << '.' << fixKwd(val);
}
else
{
@@ -2084,8 +2078,8 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
close();
}
-Slice::Gen::HolderVisitor::HolderVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::HolderVisitor::HolderVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -2098,9 +2092,9 @@ Slice::Gen::HolderVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
string name = fixKwd(p->name());
- string absolute = getAbsolute(p->scoped());
+ string absolute = getAbsolute(p, "", "", "PrxHolder");
- if(open(absolute + "PrxHolder"))
+ if(open(absolute))
{
Output& out = output();
out << sp << nl << "public final class " << name << "PrxHolder";
@@ -2152,13 +2146,12 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p)
ContainedPtr contained = ContainedPtr::dynamicCast(p);
assert(contained);
string name = fixKwd(contained->name());
- string absolute = getAbsolute(contained->scoped());
- string holder = absolute + "Holder";
+ string absolute = getAbsolute(contained, "", "", "Holder");
- if(open(holder))
+ if(open(absolute))
{
Output& out = output();
- string typeS = typeToString(p, TypeModeIn, contained->scope());
+ string typeS = typeToString(p, TypeModeIn, getPackage(contained));
out << sp << nl << "public final class " << name << "Holder";
out << sb;
out << sp << nl << "public" << nl << name << "Holder()";
@@ -2200,8 +2193,8 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p)
}
}
-Slice::Gen::HelperVisitor::HelperVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::HelperVisitor::HelperVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -2219,8 +2212,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
string name = fixKwd(p->name());
string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped);
+ string package = getPackage(p);
+ string absolute = getAbsolute(p);
if(!open(absolute + "PrxHelper"))
{
@@ -2247,9 +2240,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationPtr op = *r;
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
- string params = getParams(op, scope);
+ string params = getParams(op, package);
string args = getArgs(op);
ExceptionList throws = op->throws();
@@ -2262,7 +2255,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
//
out << sp;
out << nl << "public " << retS << nl << opName << '(' << params << ')';
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << sb;
out << nl;
if(ret)
@@ -2284,7 +2277,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << ", ";
}
out << "java.util.Map __context)";
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << sb;
out << nl << "int __cnt = 0;";
out << nl << "while(true)";
@@ -2333,7 +2326,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->hasMetaData("ami") || op->hasMetaData("ami"))
{
- string paramsAMI = getParamsAsync(op, scope, false);
+ string paramsAMI = getParamsAsync(op, package, false);
string argsAMI = getArgsAsync(op);
//
@@ -2487,10 +2480,10 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
}
string name = fixKwd(p->name());
- string absolute = getAbsolute(p->scoped());
+ string absolute = getAbsolute(p);
string helper = absolute + "Helper";
- string scope = p->scope();
- string typeS = typeToString(p, TypeModeIn, scope);
+ string package = getPackage(p);
+ string typeS = typeToString(p, TypeModeIn, package);
if(open(helper))
{
@@ -2503,14 +2496,14 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << typeS << " __v)";
out << sb;
iter = 0;
- writeSequenceMarshalUnmarshalCode(out, scope, p, "__v", true, iter, false);
+ writeSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
out << eb;
out << sp << nl << "public static " << typeS << nl << "read(IceInternal.BasicStream __is)";
out << sb;
out << nl << typeS << " __v;";
iter = 0;
- writeSequenceMarshalUnmarshalCode(out, scope, p, "__v", false, iter, false);
+ writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
out << nl << "return __v;";
out << eb;
@@ -2533,16 +2526,16 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
TypePtr key = p->keyType();
TypePtr value = p->valueType();
- string absolute = getAbsolute(p->scoped());
+ string absolute = getAbsolute(p);
string helper = absolute + "Helper";
if(open(helper))
{
Output& out = output();
string name = fixKwd(p->name());
- string scope = p->scope();
- string keyS = typeToString(key, TypeModeIn, scope);
- string valueS = typeToString(value, TypeModeIn, scope);
+ string package = getPackage(p);
+ string keyS = typeToString(key, TypeModeIn, package);
+ string valueS = typeToString(value, TypeModeIn, package);
int iter;
int i;
@@ -2635,9 +2628,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
if(val.empty())
{
- val = "((" + typeToString(type, TypeModeIn, scope) + ')' + arg + ')';
+ val = "((" + typeToString(type, TypeModeIn, package) + ')' + arg + ')';
}
- writeMarshalUnmarshalCode(out, scope, type, val, true, iter, false);
+ writeMarshalUnmarshalCode(out, package, type, val, true, iter, false);
}
out << eb;
out << eb;
@@ -2806,17 +2799,17 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
}
else
{
- string s = typeToString(type, TypeModeIn, scope);
+ string s = typeToString(type, TypeModeIn, package);
BuiltinPtr builtin2 = BuiltinPtr::dynamicCast(type);
if((builtin2 && builtin2->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(type))
{
- writeMarshalUnmarshalCode(out, scope, type, arg, false, iter, false, list<string>(),
+ writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false, StringList(),
"new Patcher(__r, __key)");
}
else
{
out << nl << s << ' ' << arg << ';';
- writeMarshalUnmarshalCode(out, scope, type, arg, false, iter, false);
+ writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false);
}
}
}
@@ -2833,8 +2826,8 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
}
}
-Slice::Gen::ProxyVisitor::ProxyVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::ProxyVisitor::ProxyVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -2847,12 +2840,11 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped);
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "", "Prx");
- if(!open(absolute + "Prx"))
+ if(!open(absolute))
{
return false;
}
@@ -2873,7 +2865,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
- out << getAbsolute((*q)->scoped(), scope) << "Prx";
+ out << getAbsolute(*q, package, "", "Prx");
if(++q != bases.end())
{
out << ',' << nl;
@@ -2901,13 +2893,13 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string name = fixKwd(p->name());
ContainerPtr container = p->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string scope = cl->scope();
+ string package = getPackage(cl);
Output& out = output();
TypePtr ret = p->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
- string params = getParams(p, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
+ string params = getParams(p, package);
ExceptionList throws = p->throws();
throws.sort();
throws.unique();
@@ -2918,7 +2910,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
//
out << sp;
out << nl << "public " << retS << ' ' << name << '(' << params << ')';
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << ';';
out << nl << "public " << retS << ' ' << name << '(' << params;
if(!params.empty())
@@ -2926,12 +2918,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
out << ", ";
}
out << "java.util.Map __context)";
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << ';';
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
- string paramsAMI = getParamsAsync(p, scope, false);
+ string paramsAMI = getParamsAsync(p, package, false);
//
// Write two versions of the operation - with and without a
@@ -2943,8 +2935,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
}
}
-Slice::Gen::DelegateVisitor::DelegateVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::DelegateVisitor::DelegateVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -2957,10 +2949,9 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "_", "Del");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "_", "Del");
if(!open(absolute))
{
@@ -2980,7 +2971,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
- out << getAbsolute((*q)->scoped(), scope, "_", "Del");
+ out << getAbsolute(*q, package, "_", "Del");
if(++q != bases.end())
{
out << ',' << nl;
@@ -2999,9 +2990,9 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationPtr op = *r;
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
- string params = getParams(op, scope);
+ string params = getParams(op, package);
ExceptionList throws = op->throws();
throws.sort();
@@ -3014,12 +3005,12 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
out << ", ";
}
out << "java.util.Map __context)";
- writeDelegateThrowsClause(scope, throws);
+ writeDelegateThrowsClause(package, throws);
out << ';';
if(p->hasMetaData("ami") || op->hasMetaData("ami"))
{
- string paramsAMI = getParamsAsync(op, scope, false);
+ string paramsAMI = getParamsAsync(op, package, false);
out << sp;
out << nl << "void " << opName << "_async(" << paramsAMI << ", java.util.Map __context);";
@@ -3032,8 +3023,8 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::DelegateMVisitor::DelegateMVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::DelegateMVisitor::DelegateMVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -3046,10 +3037,9 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "_", "DelM");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "_", "DelM");
if(!open(absolute))
{
@@ -3069,7 +3059,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationPtr op = *r;
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
int iter;
TypeStringList inParams;
@@ -3094,7 +3084,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
throws.unique();
throws.erase(remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal)), throws.end());
- string params = getParams(op, scope);
+ string params = getParams(op, package);
out << sp;
out << nl << "public " << retS << nl << opName << '(' << params;
@@ -3103,7 +3093,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
out << ", ";
}
out << "java.util.Map __context)";
- writeDelegateThrowsClause(scope, throws);
+ writeDelegateThrowsClause(package, throws);
out << sb;
out << nl << "IceInternal.Outgoing __out = getOutgoing(\"" << op->name() << "\", " << sliceModeToIceMode(op)
@@ -3121,7 +3111,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
iter = 0;
for(q = inParams.begin(); q != inParams.end(); ++q)
{
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), true, iter);
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), true, iter);
}
if(op->sendsClasses())
{
@@ -3141,7 +3131,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
{
- out << nl << "catch(" << getAbsolute((*t)->scoped(), scope) << " __ex)";
+ out << nl << "catch(" << getAbsolute(*t, package) << " __ex)";
out << sb;
out << nl << "throw __ex;";
out << eb;
@@ -3159,7 +3149,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
}
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), false, iter, true);
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), false, iter, true);
}
if(ret)
{
@@ -3172,7 +3162,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
else
{
out << nl << retS << " __ret;";
- writeMarshalUnmarshalCode(out, scope, ret, "__ret", false, iter);
+ writeMarshalUnmarshalCode(out, package, ret, "__ret", false, iter);
}
}
if(op->returnsClasses())
@@ -3208,7 +3198,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->hasMetaData("ami") || op->hasMetaData("ami"))
{
- string paramsAMI = getParamsAsync(op, scope, false);
+ string paramsAMI = getParamsAsync(op, package, false);
out << sp;
out << nl << "public void" << nl << opName << "_async(" << paramsAMI << ", java.util.Map __context)";
@@ -3223,7 +3213,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
iter = 0;
for(q = inParams.begin(); q != inParams.end(); ++q)
{
- writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), true, iter);
+ writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), true, iter);
}
if(op->sendsClasses())
{
@@ -3240,8 +3230,8 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::DelegateDVisitor::DelegateDVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::DelegateDVisitor::DelegateDVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -3254,10 +3244,9 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "_", "DelD");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "_", "DelD");
if(!open(absolute))
{
@@ -3277,14 +3266,14 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationPtr op = *r;
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
throws.erase(remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal)), throws.end());
- string params = getParams(op, scope);
+ string params = getParams(op, package);
string args = getArgs(op);
out << sp;
@@ -3294,7 +3283,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
out << ", ";
}
out << "java.util.Map __context)";
- writeDelegateThrowsClause(scope, throws);
+ writeDelegateThrowsClause(package, throws);
out << sb;
if(p->hasMetaData("amd") || op->hasMetaData("amd"))
{
@@ -3302,7 +3291,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
}
else
{
- list<string> metaData = op->getMetaData();
+ StringList metaData = op->getMetaData();
out << nl << "Ice.Current __current = new Ice.Current();";
out << nl << "__initCurrent(__current, \"" << op->name() << "\", " << sliceModeToIceMode(op)
<< ", __context);";
@@ -3357,7 +3346,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->hasMetaData("ami") || op->hasMetaData("ami"))
{
- string paramsAMI = getParamsAsync(op, scope, false);
+ string paramsAMI = getParamsAsync(op, package, false);
out << sp;
out << nl << "public void" << nl << opName << "_async(" << paramsAMI << ", java.util.Map __context)";
@@ -3373,8 +3362,8 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::DispatcherVisitor::DispatcherVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::DispatcherVisitor::DispatcherVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -3387,10 +3376,8 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "_", "Disp");
+ string absolute = getAbsolute(p, "", "_", "Disp");
if(!open(absolute))
{
@@ -3418,15 +3405,15 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::BaseImplVisitor::BaseImplVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::BaseImplVisitor::BaseImplVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
void
-Slice::Gen::BaseImplVisitor::writeDecl(Output& out, const string& scope, const string& name, const TypePtr& type)
+Slice::Gen::BaseImplVisitor::writeDecl(Output& out, const string& package, const string& name, const TypePtr& type)
{
- out << nl << typeToString(type, TypeModeIn, scope) << ' ' << name;
+ out << nl << typeToString(type, TypeModeIn, package) << ' ' << name;
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
@@ -3484,7 +3471,7 @@ Slice::Gen::BaseImplVisitor::writeDecl(Output& out, const string& scope, const s
if(en)
{
EnumeratorList enumerators = en->getEnumerators();
- out << " = " << getAbsolute(en->scoped()) << '.' << fixKwd(enumerators.front()->name());
+ out << " = " << getAbsolute(en, package) << '.' << fixKwd(enumerators.front()->name());
}
else
{
@@ -3550,13 +3537,13 @@ Slice::Gen::BaseImplVisitor::writeReturn(Output& out, const TypePtr& type)
}
void
-Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, const OperationPtr& op, bool local)
+Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package, const OperationPtr& op, bool local)
{
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
- string retS = typeToString(ret, TypeModeReturn, scope);
- string params = getParams(op, scope);
+ string retS = typeToString(ret, TypeModeReturn, package);
+ string params = getParams(op, package);
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
@@ -3566,13 +3553,13 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co
ParamDeclList paramList = op->parameters();
ParamDeclList::const_iterator q;
- out << sp << nl << "public void" << nl << opName << "_async(" << getParamsAsync(op, scope, true)
+ out << sp << nl << "public void" << nl << opName << "_async(" << getParamsAsync(op, package, true)
<< ", Ice.Current __current)";
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << sb;
@@ -3587,13 +3574,13 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co
}
if(ret)
{
- writeDecl(out, scope, result, ret);
+ writeDecl(out, package, result, ret);
}
for(q = paramList.begin(); q != paramList.end(); ++q)
{
if((*q)->isOutParam())
{
- writeDecl(out, scope, fixKwd((*q)->name()), (*q)->type());
+ writeDecl(out, package, fixKwd((*q)->name()), (*q)->type());
}
}
@@ -3633,7 +3620,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
- writeThrowsClause(scope, throws);
+ writeThrowsClause(package, throws);
out << sb;
@@ -3649,8 +3636,8 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co
}
}
-Slice::Gen::ImplVisitor::ImplVisitor(const string& dir, const string& package) :
- BaseImplVisitor(dir, package)
+Slice::Gen::ImplVisitor::ImplVisitor(const string& dir) :
+ BaseImplVisitor(dir)
{
}
@@ -3663,10 +3650,9 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "", "I");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "", "I");
if(!open(absolute))
{
@@ -3702,7 +3688,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- writeOperation(out, scope, *r, p->isLocal());
+ writeOperation(out, package, *r, p->isLocal());
}
out << eb;
@@ -3711,8 +3697,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::ImplTieVisitor::ImplTieVisitor(const string& dir, const string& package) :
- BaseImplVisitor(dir, package)
+Slice::Gen::ImplTieVisitor::ImplTieVisitor(const string& dir) :
+ BaseImplVisitor(dir)
{
}
@@ -3725,10 +3711,9 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
}
string name = fixKwd(p->name());
- string scoped = p->scoped();
ClassList bases = p->bases();
- string scope = p->scope();
- string absolute = getAbsolute(scoped, "", "", "I");
+ string package = getPackage(p);
+ string absolute = getAbsolute(p, "", "", "I");
if(!open(absolute))
{
@@ -3777,13 +3762,13 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "/*";
out << nl << " * Implemented by " << fixKwd(bases.front()->name()) << 'I';
out << nl << " *";
- writeOperation(out, scope, *r, p->isLocal());
+ writeOperation(out, package, *r, p->isLocal());
out << sp;
out << nl << "*/";
}
else
{
- writeOperation(out, scope, *r, p->isLocal());
+ writeOperation(out, package, *r, p->isLocal());
}
}
@@ -3793,8 +3778,8 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::AsyncVisitor::AsyncVisitor(const string& dir, const string& package) :
- JavaVisitor(dir, package)
+Slice::Gen::AsyncVisitor::AsyncVisitor(const string& dir) :
+ JavaVisitor(dir)
{
}
@@ -3810,15 +3795,14 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
}
string name = fixKwd(p->name());
- string classScope = fixKwd(cl->scope());
+ string classPkg = getPackage(cl);
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
string classNameAMI = "AMI_" + fixKwd(cl->name());
- string classScopedAMI = classScope + classNameAMI;
- string absoluteAMI = getAbsolute(classScopedAMI);
+ string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name);
- if(!open(absoluteAMI + '_' + name))
+ if(!open(absoluteAMI))
{
return;
}
@@ -3844,7 +3828,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
TypeStringList::const_iterator q;
int iter;
- string paramsAMI = getParamsAsyncCB(p, classScope);
+ string paramsAMI = getParamsAsyncCB(p, classPkg);
string argsAMI = getArgsAsyncCB(p);
out << sp << nl << "public abstract class " << classNameAMI << '_' << name
@@ -3860,7 +3844,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
out << sb;
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- string typeS = typeToString(q->first, TypeModeIn, classScope);
+ string typeS = typeToString(q->first, TypeModeIn, classPkg);
BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
{
@@ -3873,7 +3857,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
}
if(ret)
{
- string retS = typeToString(ret, TypeModeIn, classScope);
+ string retS = typeToString(ret, TypeModeIn, classPkg);
BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
{
@@ -3904,7 +3888,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
out << eb;
for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
{
- out << nl << "catch(" << getAbsolute((*r)->scoped(), classScope) << " __ex)";
+ out << nl << "catch(" << getAbsolute(*r, classPkg) << " __ex)";
out << sb;
out << nl << "throw __ex;";
out << eb;
@@ -3924,7 +3908,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
}
else
{
- writeMarshalUnmarshalCode(out, classScope, q->first, fixKwd(q->second), false, iter);
+ writeMarshalUnmarshalCode(out, classPkg, q->first, fixKwd(q->second), false, iter);
}
}
if(ret)
@@ -3936,7 +3920,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
}
else
{
- writeMarshalUnmarshalCode(out, classScope, ret, "__ret", false, iter);
+ writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", false, iter);
}
}
if(p->returnsClasses())
@@ -3967,17 +3951,15 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
{
string classNameAMD = "AMD_" + fixKwd(cl->name());
- string classScopedAMD = classScope + classNameAMD;
- string absoluteAMD = getAbsolute(classScopedAMD);
+ string absoluteAMD = getAbsolute(cl, "", "AMD_", "_" + name);
string classNameAMDI = "_AMD_" + fixKwd(cl->name());
- string classScopedAMDI = classScope + classNameAMDI;
- string absoluteAMDI = getAbsolute(classScopedAMDI);
+ string absoluteAMDI = getAbsolute(cl, "", "_AMD_", "_" + name);
- string paramsAMD = getParamsAsyncCB(p, classScope);
+ string paramsAMD = getParamsAsyncCB(p, classPkg);
{
- if(!open(absoluteAMD + '_' + name))
+ if(!open(absoluteAMD))
{
return;
}
@@ -3994,7 +3976,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
}
{
- if(!open(absoluteAMDI + '_' + name))
+ if(!open(absoluteAMDI))
{
return;
}
@@ -4040,13 +4022,13 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
out << nl << "IceInternal.BasicStream __os = this.__os();";
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- string typeS = typeToString(q->first, TypeModeIn, classScope);
- writeMarshalUnmarshalCode(out, classScope, q->first, fixKwd(q->second), true, iter);
+ string typeS = typeToString(q->first, TypeModeIn, classPkg);
+ writeMarshalUnmarshalCode(out, classPkg, q->first, fixKwd(q->second), true, iter);
}
if(ret)
{
- string retS = typeToString(ret, TypeModeIn, classScope);
- writeMarshalUnmarshalCode(out, classScope, ret, "__ret", true, iter);
+ string retS = typeToString(ret, TypeModeIn, classPkg);
+ writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", true, iter);
}
if(p->returnsClasses())
{
@@ -4079,7 +4061,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
ExceptionList::const_iterator r;
for(r = throws.begin(); r != throws.end(); ++r)
{
- string exS = getAbsolute((*r)->scoped(), classScope);
+ string exS = getAbsolute(*r, classPkg);
out << nl << "catch(" << exS << " __ex)";
out << sb;
out << nl << "__os().writeUserException(__ex);";