summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/GenUtil.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-08-09 01:27:06 +0000
committerMarc Laukien <marc@zeroc.com>2001-08-09 01:27:06 +0000
commitcb36054fdc0b1fa7e5718a28cf43f61c2f3ad080 (patch)
treeb8f7f02790bfeb080263e8eb80b4ea89cb24b283 /cpp/src/slice2cpp/GenUtil.cpp
parentconfig fixes (diff)
downloadice-cb36054fdc0b1fa7e5718a28cf43f61c2f3ad080.tar.bz2
ice-cb36054fdc0b1fa7e5718a28cf43f61c2f3ad080.tar.xz
ice-cb36054fdc0b1fa7e5718a28cf43f61c2f3ad080.zip
slice2docbook fixes; cleanup
Diffstat (limited to 'cpp/src/slice2cpp/GenUtil.cpp')
-rw-r--r--cpp/src/slice2cpp/GenUtil.cpp79
1 files changed, 67 insertions, 12 deletions
diff --git a/cpp/src/slice2cpp/GenUtil.cpp b/cpp/src/slice2cpp/GenUtil.cpp
index d8537405028..8de9550af30 100644
--- a/cpp/src/slice2cpp/GenUtil.cpp
+++ b/cpp/src/slice2cpp/GenUtil.cpp
@@ -34,19 +34,27 @@ Slice::typeToString(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if (builtin)
+ {
return builtinTable[builtin->kind()];
+ }
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if (cl)
+ {
return cl->scoped() + "Ptr";
+ }
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if (proxy)
+ {
return proxy->_class()->scoped() + "Prx";
+ }
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if (contained)
+ {
return contained->scoped();
+ }
return "???";
}
@@ -55,7 +63,9 @@ string
Slice::returnTypeToString(const TypePtr& type)
{
if (!type)
+ {
return "void";
+ }
return typeToString(type);
}
@@ -81,27 +91,39 @@ Slice::inputTypeToString(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if (builtin)
+ {
return inputBuiltinTable[builtin->kind()];
+ }
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if (cl)
+ {
return "const " + cl->scoped() + "Ptr&";
+ }
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if (proxy)
+ {
return "const " + proxy->_class()->scoped() + "Prx&";
+ }
EnumPtr en = EnumPtr::dynamicCast(type);
if (en)
+ {
return en->scoped();
+ }
NativePtr native = NativePtr::dynamicCast(type);
if (native)
+ {
return native->scoped();
+ }
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if (contained)
+ {
return "const " + contained->scoped() + "&";
+ }
return "???";
}
@@ -127,23 +149,33 @@ Slice::outputTypeToString(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if (builtin)
+ {
return outputBuiltinTable[builtin->kind()];
+ }
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if (cl)
+ {
return cl->scoped() + "Ptr&";
+ }
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if (proxy)
+ {
return proxy->_class()->scoped() + "Prx&";
+ }
NativePtr native = NativePtr::dynamicCast(type);
if (native)
+ {
return native->scoped();
+ }
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if (contained)
+ {
return contained->scoped() + "&";
+ }
return "???";
}
@@ -169,27 +201,39 @@ Slice::exceptionTypeToString(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if (builtin)
+ {
return inputBuiltinTable[builtin->kind()];
+ }
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if (cl)
+ {
return "const " + cl->scoped() + "PtrE&";
+ }
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if (proxy)
+ {
return "const " + proxy->_class()->scoped() + "PrxE&";
+ }
EnumPtr en = EnumPtr::dynamicCast(type);
if (en)
+ {
return en->scoped();
+ }
NativePtr native = NativePtr::dynamicCast(type);
if (native)
+ {
return native->scoped();
+ }
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if (contained)
+ {
return "const " + contained->scoped() + "&";
+ }
return "???";
}
@@ -220,25 +264,23 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
out << nl << "::Ice::ObjectPtr __obj;";
out << nl << stream << "->read(__obj, " << cl->scoped() << "::__classIds[0]);";
out << nl << "if (!__obj)";
+ out << sb;
ClassDefPtr def = cl->definition();
if (def && !def->isAbstract())
{
- out << sb;
out << nl << "__obj = new " << cl->scoped() << ";";
out << nl << "__obj->__read(__is);";
- out << eb;
}
else
{
- out.inc();
out << nl << "throw ::Ice::NoFactoryException(__FILE__, __LINE__);";
- out.dec();
}
+ out << eb;
out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(__obj);";
out << nl << "if (!" << param << ')';
- out.inc();
+ out << sb;
out << nl << "throw ::Ice::ValueUnmarshalException(__FILE__, __LINE__);";
- out.dec();
+ out << eb;
}
out << eb;
@@ -249,10 +291,14 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
if (vec)
{
if (BuiltinPtr::dynamicCast(vec->type()))
+ {
out << nl << stream << "->" << func << param << ");";
+ }
else
+ {
out << nl << vec->scope() << "::__" << func << stream << ", " << param << ", " << vec->scope()
<< "::__U__" << vec->name() << "());";
+ }
return;
}
@@ -273,21 +319,27 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
void
Slice::writeMarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret)
{
- list<pair<TypePtr, string> >::const_iterator p;
- for (p = params.begin(); p != params.end(); ++p)
+ for (list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p)
+ {
writeMarshalUnmarshalCode(out, p->first, p->second, true);
+ }
if (ret)
+ {
writeMarshalUnmarshalCode(out, ret, "__ret", true);
+ }
}
void
Slice::writeUnmarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret)
{
- list<pair<TypePtr, string> >::const_iterator p;
- for (p = params.begin(); p != params.end(); ++p)
+ for (list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p)
+ {
writeMarshalUnmarshalCode(out, p->first, p->second, false);
+ }
if (ret)
+ {
writeMarshalUnmarshalCode(out, ret, "__ret", false);
+ }
}
void
@@ -295,9 +347,12 @@ Slice::writeAllocateCode(Output& out, const list<pair<TypePtr, string> >& params
{
list<pair<TypePtr, string> > ps = params;
if (ret)
+ {
ps.push_back(make_pair(ret, string("__ret")));
+ }
- list<pair<TypePtr, string> >::const_iterator p;
- for (p = ps.begin(); p != ps.end(); ++p)
+ for (list<pair<TypePtr, string> >::const_iterator p = ps.begin(); p != ps.end(); ++p)
+ {
out << nl << typeToString(p->first) << ' ' << p->second << ';';
+ }
}