summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-05-03 17:08:12 +0000
committerMark Spruiell <mes@zeroc.com>2002-05-03 17:08:12 +0000
commite6b371f866b491382c467a149751c5d87778fcab (patch)
tree6114c862519fbdef72885cfff216a4c4cef9f446 /cpp/src
parentadding shutdown hook (diff)
downloadice-e6b371f866b491382c467a149751c5d87778fcab.tar.bz2
ice-e6b371f866b491382c467a149751c5d87778fcab.tar.xz
ice-e6b371f866b491382c467a149751c5d87778fcab.zip
cleaning up sample impls
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2java/Gen.cpp132
-rw-r--r--cpp/src/slice2java/Gen.h4
2 files changed, 14 insertions, 122 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 2312ecbcab9..a27a06ed821 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -3139,150 +3139,57 @@ Slice::Gen::BaseImplVisitor::BaseImplVisitor(const string& dir,
}
void
-Slice::Gen::BaseImplVisitor::writeAssign(Output& out, const string& scope,
- const TypePtr& type, const string& name,
- int& iter)
+Slice::Gen::BaseImplVisitor::writeReturn(Output& out, const TypePtr& type)
{
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if (builtin)
{
switch (builtin->kind())
{
- case Builtin::KindByte:
+ case Builtin::KindBool:
{
- out << nl << name << " = (byte)0;";
+ out << nl << "return false;";
break;
}
- case Builtin::KindBool:
+ case Builtin::KindByte:
{
- out << nl << name << " = false;";
+ out << nl << "return (byte)0;";
break;
}
case Builtin::KindShort:
{
- out << nl << name << " = (short)0;";
+ out << nl << "return (short)0;";
break;
}
case Builtin::KindInt:
- {
- out << nl << name << " = 0;";
- break;
- }
case Builtin::KindLong:
{
- out << nl << name << " = 0L;";
+ out << nl << "return 0;";
break;
}
case Builtin::KindFloat:
{
- out << nl << name << " = 0.0f;";
+ out << nl << "return (float)0.0;";
break;
}
case Builtin::KindDouble:
{
- out << nl << name << " = 0.0;";
+ out << nl << "return 0.0;";
break;
}
case Builtin::KindString:
- {
- out << nl << name << " = \"\";";
- break;
- }
case Builtin::KindObject:
- {
- out << nl << name << " = null;";
- break;
- }
case Builtin::KindObjectProxy:
- {
- out << nl << name << " = null;";
- break;
- }
case Builtin::KindLocalObject:
{
- out << nl << name << " = null;";
+ out << nl << "return null;";
break;
}
}
return;
}
- ProxyPtr prx = ProxyPtr::dynamicCast(type);
- if (prx)
- {
- out << nl << name << " = null;";
- return;
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if (cl)
- {
- out << nl << name << " = null;";
- return;
- }
-
- StructPtr st = StructPtr::dynamicCast(type);
- if (st)
- {
- string typeS = getAbsolute(st->scoped(), scope);
- out << nl << name << " = new " << typeS << "();";
- DataMemberList members = st->dataMembers();
- DataMemberList::const_iterator d;
- for (d = members.begin(); d != members.end(); ++d)
- {
- string memberName = name + "." + fixKwd((*d)->name());
- writeAssign(out, scope, (*d)->type(), memberName, iter);
- }
- return;
- }
-
- EnumPtr en = EnumPtr::dynamicCast(type);
- if (en)
- {
- string typeS = getAbsolute(en->scoped(), scope);
- EnumeratorList enumerators = en->getEnumerators();
- out << nl << name << " = " << typeS << '.'
- << fixKwd(enumerators.front()->name()) << ';';
- return;
- }
-
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if (seq)
- {
- //
- // Determine sequence depth
- //
- int depth = 0;
- TypePtr origContent = seq->type();
- SequencePtr s = SequencePtr::dynamicCast(origContent);
- while (s)
- {
- depth++;
- origContent = s->type();
- s = SequencePtr::dynamicCast(origContent);
- }
-
- string origContentS = typeToString(origContent, TypeModeIn, scope);
- out << nl << name << " = new " << origContentS << "[5]";
- while (depth--)
- {
- out << "[]";
- }
- out << ';';
- out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < "
- << name << ".length; __i" << iter << "++)";
- out << sb;
- ostringstream elem;
- elem << name << "[__i" << iter << ']';
- iter++;
- writeAssign(out, scope, seq->type(), elem.str(), iter);
- out << eb;
- return;
- }
-
- DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
- assert(dict);
- out << nl << name << " = new java.util.HashMap();";
+ out << nl << "return null;";
}
void
@@ -3312,27 +3219,12 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co
out << sb;
- TypeStringList outParams = op->outputParameters();
- TypeStringList::const_iterator q;
- int iter = 0;
-
- //
- // Assign values to 'out' params
- //
- for (q = outParams.begin(); q != outParams.end(); ++q)
- {
- string param = fixKwd(q->second) + ".value";
- writeAssign(out, scope, q->first, param, iter);
- }
-
//
// Return value
//
if (ret)
{
- out << sp << nl << retS << " __r;";
- writeAssign(out, scope, ret, "__r", iter);
- out << nl << "return __r;";
+ writeReturn(out, ret);
}
out << eb;
diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h
index a078444bba5..9a616f859da 100644
--- a/cpp/src/slice2java/Gen.h
+++ b/cpp/src/slice2java/Gen.h
@@ -200,9 +200,9 @@ private:
protected:
//
- // Generate code to assign a value
+ // Generate code to return a value
//
- void writeAssign(::IceUtil::Output&, const std::string&, const TypePtr&, const std::string&, int&);
+ void writeReturn(::IceUtil::Output&, const TypePtr&);
//
// Generate an operation