summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2012-09-24 16:00:56 -0700
committerMark Spruiell <mes@zeroc.com>2012-09-24 16:00:56 -0700
commit6bb0a7b82684d1ce59a996848773054ede1f442e (patch)
tree9a9cfbaa225afd5caca819eea9558908c9a64a40 /cpp/src
parentReplaced optionalType in StreamTrait<> by a bool fixedLength member (diff)
downloadice-6bb0a7b82684d1ce59a996848773054ede1f442e.tar.bz2
ice-6bb0a7b82684d1ce59a996848773054ede1f442e.tar.xz
ice-6bb0a7b82684d1ce59a996848773054ede1f442e.zip
Ruby port; Python & C++ fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/StreamI.cpp18
-rwxr-xr-xcpp/src/Slice/RubyUtil.cpp32
-rw-r--r--cpp/src/slice2cpp/Gen.cpp24
3 files changed, 47 insertions, 27 deletions
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
index 0cb438049c7..55aa9b50fd9 100644
--- a/cpp/src/Ice/StreamI.cpp
+++ b/cpp/src/Ice/StreamI.cpp
@@ -80,18 +80,6 @@ UserExceptionReader::__read(BasicStream* is)
read(stream);
}
-bool
-UserExceptionReader::__usesClasses() const
-{
- return usesClasses();
-}
-
-void
-UserExceptionReader::__usesClasses(bool b)
-{
- usesClasses(b);
-}
-
//
// InputStreamI
//
@@ -790,9 +778,3 @@ UserExceptionWriter::__read(BasicStream*)
{
assert(false);
}
-
-bool
-UserExceptionWriter::__usesClasses() const
-{
- return usesClasses();
-}
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index d5f8f771a13..3922d6cbbf2 100755
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -622,8 +622,6 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Interfaces
//
- // TODO: Necessary?
- //
{
int interfaceCount = 0;
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
@@ -644,7 +642,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Data members are represented as an array:
//
- // ['MemberName', MemberType]
+ // ['MemberName', MemberType, Optional, Tag]
//
// where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type.
//
@@ -663,7 +661,8 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << "['" << fixIdent((*q)->name(), IdentNormal) << "', ";
writeType((*q)->type());
- _out << ']';
+ _out << ", " << ((*q)->optional() ? "true" : "false") << ", " << ((*q)->optional() ? (*q)->tag() : 0)
+ << ']';
}
}
if(members.size() > 1)
@@ -677,7 +676,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Define each operation. The arguments to __defineOperation are:
//
- // 'opName', Mode, IsAmd, FormatType, [InParams], [OutParams], ReturnType, [Exceptions]
+ // 'opName', Mode, IsAmd, FormatType, [InParams], [OutParams], ReturnParam, [Exceptions]
//
// where InParams and OutParams are arrays of type descriptions, and Exceptions
// is an array of exception types.
@@ -747,7 +746,10 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << ", ";
}
+ _out << '[';
writeType((*t)->type());
+ _out << ", " << ((*t)->optional() ? "true" : "false") << ", "
+ << ((*t)->optional() ? (*t)->tag() : 0) << ']';
++count;
}
}
@@ -760,7 +762,10 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << ", ";
}
+ _out << '[';
writeType((*t)->type());
+ _out << ", " << ((*t)->optional() ? "true" : "false") << ", "
+ << ((*t)->optional() ? (*t)->tag() : 0) << ']';
++count;
}
}
@@ -768,7 +773,15 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
TypePtr returnType = (*s)->returnType();
if(returnType)
{
+ //
+ // The return type has the same format as an in/out parameter:
+ //
+ // Type, Optional?, OptionalTag
+ //
+ _out << '[';
writeType(returnType);
+ _out << ", " << ((*s)->returnIsOptional() ? "true" : "false") << ", "
+ << ((*s)->returnIsOptional() ? (*s)->returnTag() : 0) << ']';
}
else
{
@@ -932,7 +945,7 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
//
// Data members are represented as an array:
//
- // ['MemberName', MemberType]
+ // ['MemberName', MemberType, Optional, Tag]
//
// where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type.
//
@@ -944,7 +957,8 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
}
_out << "[\"" << fixIdent((*dmli)->name(), IdentNormal) << "\", ";
writeType((*dmli)->type());
- _out << ']';
+ _out << ", " << ((*dmli)->optional() ? "true" : "false") << ", " << ((*dmli)->optional() ? (*dmli)->tag() : 0)
+ << ']';
}
if(members.size() > 1)
{
@@ -1604,6 +1618,10 @@ Slice::Ruby::CodeVisitor::writeConstructorParams(const MemberInfoList& members)
{
writeConstantValue(member->type(), member->defaultValueType(), member->defaultValue());
}
+ else if(member->optional())
+ {
+ _out << "::Ice::Unset";
+ }
else
{
_out << getInitializer(member->type());
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index e46b5aeae43..1edb081c9ad 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -4581,7 +4581,17 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
{
if((*i)->type()->usesClasses())
{
- emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0);
+ if((*i)->optional())
+ {
+ C << nl << "if(" << fixKwd((*i)->name()) << ')';
+ C << sb;
+ emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0);
+ C << eb;
+ }
+ else
+ {
+ emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0);
+ }
}
}
C << eb;
@@ -4617,7 +4627,17 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
{
if((*j)->type()->usesClasses())
{
- emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0);
+ if((*j)->optional())
+ {
+ C << nl << "if(" << fixKwd((*j)->name()) << ')';
+ C << sb;
+ emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0);
+ C << eb;
+ }
+ else
+ {
+ emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0);
+ }
}
}
C << eb;