summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-02-20 14:27:41 +0100
committerBenoit Foucher <benoit@zeroc.com>2015-02-20 14:27:41 +0100
commitaf1544e7b81e8708c5fdee05a59328558a3030fe (patch)
tree0933eb39159b8cf714aab7fe5901d0515674d7c6
parentSimplification to Atomic usage (diff)
downloadice-af1544e7b81e8708c5fdee05a59328558a3030fe.tar.bz2
ice-af1544e7b81e8708c5fdee05a59328558a3030fe.tar.xz
ice-af1544e7b81e8708c5fdee05a59328558a3030fe.zip
Fix for ICE-6268, initialize enum, string and structs in Java/C#/Objective-C/JavaScript
-rw-r--r--cpp/include/Slice/JavaUtil.h2
-rw-r--r--cpp/include/Slice/Parser.h11
-rw-r--r--cpp/src/IceGrid/Makefile3
-rw-r--r--cpp/src/Slice/JavaUtil.cpp270
-rw-r--r--cpp/src/Slice/Parser.cpp70
-rw-r--r--cpp/src/Slice/PythonUtil.cpp16
-rw-r--r--cpp/src/Slice/RubyUtil.cpp11
-rw-r--r--cpp/src/slice2cs/Gen.cpp44
-rw-r--r--cpp/src/slice2cs/Gen.h1
-rw-r--r--cpp/src/slice2freezej/Main.cpp19
-rw-r--r--cpp/src/slice2java/Gen.cpp92
-rw-r--r--cpp/src/slice2js/Gen.cpp252
-rw-r--r--cpp/src/slice2js/Gen.h14
-rw-r--r--cpp/src/slice2objc/Gen.cpp139
-rw-r--r--cpp/src/slice2objc/Gen.h5
-rw-r--r--cpp/src/slice2php/Main.cpp16
-rw-r--r--cs/src/Ice/Incoming.cs50
-rw-r--r--cs/src/IcePatch2/Makefile2
-rw-r--r--cs/test/Ice/defaultValue/AllTests.cs51
-rw-r--r--cs/test/Ice/defaultValue/Test.ice64
-rw-r--r--java/src/Ice/src/main/java/IceInternal/IncomingBase.java4
-rw-r--r--java/test/src/main/java/test/Ice/defaultValue/AllTests.java45
-rw-r--r--java/test/src/main/java/test/Ice/defaultValue/Test.ice52
-rw-r--r--js/test/Ice/defaultValue/Client.js58
-rw-r--r--js/test/Ice/defaultValue/Test.ice52
-rw-r--r--objc/test/Ice/defaultValue/AllTests.m34
-rw-r--r--objc/test/Ice/defaultValue/DefaultValueTest.ice52
-rw-r--r--php/test/Ice/defaultValue/Client.php35
-rw-r--r--php/test/Ice/defaultValue/Test.ice52
-rw-r--r--py/test/Ice/defaultValue/AllTests.py39
-rw-r--r--py/test/Ice/defaultValue/Test.ice55
-rw-r--r--rb/test/Ice/defaultValue/AllTests.rb48
-rw-r--r--rb/test/Ice/defaultValue/Test.ice52
33 files changed, 1164 insertions, 546 deletions
diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h
index 9a3d81f85e9..3bb0c692e7e 100644
--- a/cpp/include/Slice/JavaUtil.h
+++ b/cpp/include/Slice/JavaUtil.h
@@ -233,6 +233,8 @@ protected:
std::string&, std::string&) const;
bool getSequenceTypes(const SequencePtr&, const std::string&, const StringList&, std::string&, std::string&) const;
+ bool sequenceHasHolder(const SequencePtr&) const;
+
virtual JavaOutput* createOutput();
static const std::string _getSetMetaData;
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h
index d416ca6f18c..257e1df5987 100644
--- a/cpp/include/Slice/Parser.h
+++ b/cpp/include/Slice/Parser.h
@@ -47,7 +47,7 @@ namespace Slice
{
#if defined(_WIN32) && !defined(__MINGW32__)
-
+
const IceUtil::Int64 Int32Max = 0x7fffffffi64;
const IceUtil::Int64 Int32Min = -Int32Max - 1i64;
@@ -594,7 +594,7 @@ private:
class SLICE_API Operation : virtual public Contained, virtual public Container
{
public:
-
+
//
// Note: The order of definitions here *must* match the order of
// definitions of ::Ice::OperationMode in slice/Ice/Current.ice!
@@ -838,7 +838,7 @@ public:
protected:
- Dictionary(const ContainerPtr&, const std::string&, const TypePtr&, const StringList&, const TypePtr&,
+ Dictionary(const ContainerPtr&, const std::string&, const TypePtr&, const StringList&, const TypePtr&,
const StringList&, bool);
friend class Container;
@@ -988,8 +988,9 @@ public:
virtual std::string kindOf() const;
virtual void visit(ParserVisitor*, bool);
+
protected:
-
+
DataMember(const ContainerPtr&, const std::string&, const TypePtr&, bool, int, const SyntaxTreeBasePtr&,
const std::string&, const std::string&);
friend class ClassDef;
@@ -1078,7 +1079,7 @@ public:
virtual void visit(ParserVisitor*, bool);
BuiltinPtr builtin(Builtin::Kind); // Not const, as builtins are created on the fly. (Lazy initialization.)
-
+
void addTopLevelModule(const std::string&, const std::string&);
std::set<std::string> getTopLevelModules(const std::string&) const;
diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile
index 90292dcb1c1..0fcb6e7e453 100644
--- a/cpp/src/IceGrid/Makefile
+++ b/cpp/src/IceGrid/Makefile
@@ -121,8 +121,7 @@ $(NODE_SERVER): $(NODE_SVR_OBJS) $(LIBTARGETS)
$(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(NODE_SVR_OBJS) -lIceGrid -lIceStorm -lIceStormService -lIceBox -lGlacier2 \
-lFreeze -lIcePatch2 $(EXPAT_RPATH_LINK) -lIceXML -lIceSSL $(OPENSSL_RPATH_LINK) $(LIBS)
-../IceGrid/IceLocatorDiscovery.h IceLocatorDiscovery.cpp: \
- $(slicedir)/IceLocatorDiscovery/IceLocatorDiscovery.ice $(SLICE2CPP) $(SLICEPARSERLIB)
+../IceLocatorDiscovery/%.h %.cpp: $(slicedir)/IceLocatorDiscovery/%.ice $(SLICE2CPP) $(SLICEPARSERLIB)
rm -f $(*F).h $(*F).cpp
$(SLICE2CPP) $(SLICE2CPPFLAGS) $(slicedir)/IceLocatorDiscovery/$(*F).ice
@touch $(*F).cpp
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index c6ba85f14a2..e42490a0e4c 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -839,47 +839,20 @@ Slice::JavaGenerator::typeToString(const TypePtr& type,
{
if(mode == TypeModeOut)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type());
- if(builtin && builtin->kind() == Builtin::KindByte)
- {
- string prefix = "java:serializable:";
- string meta;
- if(seq->findMetaData(prefix, meta))
- {
- return string("Ice.Holder<") + meta.substr(prefix.size()) + " >";
- }
- prefix = "java:protobuf:";
- if(seq->findMetaData(prefix, meta))
- {
- return string("Ice.Holder<") + meta.substr(prefix.size()) + " >";
- }
- }
-
- if(builtin &&
- (builtin->kind() == Builtin::KindByte || builtin->kind() == Builtin::KindShort ||
- builtin->kind() == Builtin::KindInt || builtin->kind() == Builtin::KindLong ||
- builtin->kind() == Builtin::KindFloat || builtin->kind() == Builtin::KindDouble))
- {
- string prefix = "java:buffer";
- string meta;
- string ignore;
- if(seq->findMetaData(prefix, meta) || findMetaData(prefix, metaData, ignore))
- {
- return string("Ice.Holder<") + typeToBufferString(seq->type()) + ">";
- }
- }
-
- //
- // Only use the type's generated holder if the instance and
- // formal types match.
- //
string instanceType, formalType;
getSequenceTypes(seq, "", metaData, instanceType, formalType);
- string origInstanceType, origFormalType;
- getSequenceTypes(seq, "", StringList(), origInstanceType, origFormalType);
- if(formalType == origFormalType && instanceType == origInstanceType)
+ if(sequenceHasHolder(seq))
{
- return getAbsolute(seq, package, "", "Holder");
+ //
+ // Only use the type's generated holder if the instance and
+ // formal types match.
+ //
+ string origInstanceType, origFormalType;
+ getSequenceTypes(seq, "", StringList(), origInstanceType, origFormalType);
+ if(formalType == origFormalType && instanceType == origInstanceType)
+ {
+ return getAbsolute(seq, package, "", "Holder");
+ }
}
//
@@ -891,37 +864,6 @@ Slice::JavaGenerator::typeToString(const TypePtr& type,
}
else
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type());
- if(builtin && builtin->kind() == Builtin::KindByte)
- {
- string prefix = "java:serializable:";
- string meta;
- if(seq->findMetaData(prefix, meta))
- {
- return meta.substr(prefix.size());
- }
-
- prefix = "java:protobuf:";
- if(seq->findMetaData(prefix, meta))
- {
- return meta.substr(prefix.size());
- }
- }
-
- if(builtin &&
- (builtin->kind() == Builtin::KindByte || builtin->kind() == Builtin::KindShort ||
- builtin->kind() == Builtin::KindInt || builtin->kind() == Builtin::KindLong ||
- builtin->kind() == Builtin::KindFloat || builtin->kind() == Builtin::KindDouble))
- {
- string prefix = "java:buffer";
- string meta;
- string ignore;
- if(seq->findMetaData(prefix, meta) || findMetaData(prefix, metaData, ignore))
- {
- return typeToBufferString(seq->type());
- }
- }
-
string instanceType, formalType;
getSequenceTypes(seq, package, metaData, instanceType, formalType);
return formal ? formalType : instanceType;
@@ -1511,11 +1453,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
{
out << nl << stream << ".skipSize();";
}
- out << nl << v << " = " << typeS << ".__readNew(" << stream << ");";
+ out << nl << v << " = " << typeS << ".__read(" << stream << ", " << v << ");";
}
else
{
- out << nl << v << " = " << typeS << ".__readNew(" << stream << ");";
+ out << nl << v << " = " << typeS << ".__read(" << stream << ", " << v << ");";
}
}
return;
@@ -2042,7 +1984,14 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
}
else
{
- out << nl << typeS << ' ' << arg << ';';
+ if(StructPtr::dynamicCast(type))
+ {
+ out << nl << typeS << ' ' << arg << " = null;";
+ }
+ else
+ {
+ out << nl << typeS << ' ' << arg << ';';
+ }
writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, arg, false, iter, false);
}
}
@@ -2359,7 +2308,14 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
}
else
{
- out << nl << cont << " __elem;";
+ if(StructPtr::dynamicCast(type))
+ {
+ out << nl << cont << " __elem = null;";
+ }
+ else
+ {
+ out << nl << cont << " __elem;";
+ }
writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, "__elem", false, iter, false);
}
if(!isObject)
@@ -2877,7 +2833,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
out << nl << stream << ".skipSize();";
}
}
- out << nl << v << " = " << typeS << ".ice_readNew(" << stream << ");";
+ out << nl << v << " = " << typeS << ".ice_read(" << stream << ", " << v << ");";
}
return;
}
@@ -3216,7 +3172,14 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
}
else
{
- out << nl << s << ' ' << arg << ';';
+ if(StructPtr::dynamicCast(type))
+ {
+ out << nl << s << ' ' << arg << " = null;";
+ }
+ else
+ {
+ out << nl << s << ' ' << arg << ';';
+ }
writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, false, iter, false);
}
}
@@ -3532,7 +3495,14 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out,
}
else
{
- out << nl << cont << " __elem;";
+ if(StructPtr::dynamicCast(type))
+ {
+ out << nl << cont << " __elem = null;";
+ }
+ else
+ {
+ out << nl << cont << " __elem;";
+ }
writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", false, iter, false);
}
if(!isObject)
@@ -3876,18 +3846,6 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
string& instanceType,
string& formalType) const
{
- bool customType = false;
-
- //
- // Collect metadata for a custom type.
- //
- string ct, at;
- customType = getTypeMetaData(metaData, ct, at);
- if(!customType)
- {
- customType = getTypeMetaData(dict->getMetaData(), ct, at);
- }
-
//
// Get the types of the key and value.
//
@@ -3895,36 +3853,25 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
string valueTypeStr = typeToObjectString(dict->valueType(), TypeModeIn, package);
//
- // Handle a custom type.
+ // Collect metadata for a custom type.
//
- if(customType)
+ if(getTypeMetaData(metaData, instanceType, formalType) ||
+ getTypeMetaData(dict->getMetaData(), instanceType, formalType))
{
- assert(!ct.empty());
- instanceType = ct;
- formalType = at;
+ assert(!instanceType.empty());
+ if(formalType.empty())
+ {
+ formalType = "java.util.Map<" + keyTypeStr + ", " + valueTypeStr + ">";
+ }
+ return true;
}
//
// Return a default type for the platform.
//
- if(instanceType.empty())
- {
- instanceType = "java.util.HashMap<" + keyTypeStr + ", " + valueTypeStr + ">";
- }
-
- //
- // If a formal type is not defined, we use the instance type as the default.
- // If instead we chose a default formal type, such as Map<K, V>, then we
- // might inadvertently generate uncompilable code. The Java5 compiler does not
- // allow polymorphic assignment between generic types if it can weaken the
- // compile-time type safety rules.
- //
- if(formalType.empty())
- {
- formalType = "java.util.Map<" + keyTypeStr + ", " + valueTypeStr + ">";
- }
-
- return customType;
+ instanceType = "java.util.HashMap<" + keyTypeStr + ", " + valueTypeStr + ">";
+ formalType = "java.util.Map<" + keyTypeStr + ", " + valueTypeStr + ">";
+ return false;
}
bool
@@ -3934,59 +3881,98 @@ Slice::JavaGenerator::getSequenceTypes(const SequencePtr& seq,
string& instanceType,
string& formalType) const
{
- bool customType = false;
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type());
+ if(builtin)
+ {
+ if(builtin->kind() == Builtin::KindByte)
+ {
+ string prefix = "java:serializable:";
+ string meta;
+ if(seq->findMetaData(prefix, meta))
+ {
+ instanceType = formalType = meta.substr(prefix.size());
+ return true;
+ }
+ prefix = "java:protobuf:";
+ if(seq->findMetaData(prefix, meta))
+ {
+ instanceType = formalType = meta.substr(prefix.size());
+ return true;
+ }
+ }
+
+ if((builtin->kind() == Builtin::KindByte || builtin->kind() == Builtin::KindShort ||
+ builtin->kind() == Builtin::KindInt || builtin->kind() == Builtin::KindLong ||
+ builtin->kind() == Builtin::KindFloat || builtin->kind() == Builtin::KindDouble))
+ {
+ string prefix = "java:buffer";
+ string meta;
+ string ignore;
+ if(seq->findMetaData(prefix, meta) || findMetaData(prefix, metaData, ignore))
+ {
+ instanceType = formalType = typeToBufferString(seq->type());
+ return true;
+ }
+ }
+ }
//
// Collect metadata for a custom type.
//
- string ct, at;
- customType = getTypeMetaData(metaData, ct, at);
- if(!customType)
+ if(getTypeMetaData(metaData, instanceType, formalType) ||
+ getTypeMetaData(seq->getMetaData(), instanceType, formalType))
{
- customType = getTypeMetaData(seq->getMetaData(), ct, at);
+ assert(!instanceType.empty());
+ if(formalType.empty())
+ {
+ formalType = "java.util.List<" + typeToObjectString(seq->type(), TypeModeIn, package) + ">";
+ }
+ return true;
}
//
- // Get the inner type.
+ // The default mapping is a native array.
//
- string typeStr = typeToObjectString(seq->type(), TypeModeIn, package);
+ instanceType = formalType = typeToString(seq->type(), TypeModeIn, package, metaData) + "[]";
+ return false;
+}
- //
- // Handle a custom type.
- //
- if(customType)
+bool
+Slice::JavaGenerator::sequenceHasHolder(const SequencePtr& p) const
+{
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type());
+ if(builtin && builtin->kind() == Builtin::KindByte)
{
- assert(!ct.empty());
- instanceType = ct;
-
- if(!at.empty())
+ string prefix = "java:serializable:";
+ string meta;
+ if(p->findMetaData(prefix, meta))
{
- formalType = at;
+ return false;
}
- else
+ prefix = "java:protobuf:";
+ if(p->findMetaData(prefix, meta))
{
- //
- // If a formal type is not defined, we use the instance type as the default.
- // If instead we chose a default formal type, such as List<T>, then we
- // might inadvertently generate uncompilable code. The Java5 compiler does not
- // allow polymorphic assignment between generic types if it can weaken the
- // compile-time type safety rules.
- //
- formalType = "java.util.List<" + typeStr + ">";
+ return false;
}
}
- //
- // The default mapping is a native array.
- //
- if(instanceType.empty())
+ if(builtin &&
+ (builtin->kind() == Builtin::KindByte || builtin->kind() == Builtin::KindShort ||
+ builtin->kind() == Builtin::KindInt || builtin->kind() == Builtin::KindLong ||
+ builtin->kind() == Builtin::KindFloat || builtin->kind() == Builtin::KindDouble))
{
- instanceType = formalType = typeToString(seq->type(), TypeModeIn, package) + "[]";
+ string meta;
+ string prefix = "java:buffer";
+ if(p->findMetaData(prefix, meta))
+ {
+ return false;
+ }
}
- return customType;
+ return true;
}
+
JavaOutput*
Slice::JavaGenerator::createOutput()
{
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 2e6f4f79fe3..37c9ef49a74 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -543,7 +543,7 @@ Slice::Container::createModule(const string& name)
ContainedList matches = _unit->findContents(thisScope() + name);
matches.sort(); // Modules can occur many times...
matches.unique(); // ... but we only want one instance of each.
-
+
if(thisScope() == "::")
{
_unit->addTopLevelModule(_unit->currentFile(), name);
@@ -658,7 +658,7 @@ Slice::Container::createClassDef(const string& name, int id, bool intf, const Cl
}
ClassDecl::checkBasesAreLegal(name, intf, local, bases, _unit);
-
+
ClassDefPtr def = new ClassDef(this, name, id, intf, bases, local);
_contents.push_back(def);
@@ -700,7 +700,7 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local)
}
return 0;
}
-
+
ClassDeclPtr clDecl = ClassDeclPtr::dynamicCast(*p);
if(clDecl)
{
@@ -710,7 +710,7 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local)
}
return 0;
}
-
+
bool differsOnlyInCase = matches.front()->name() != name;
if(differsOnlyInCase)
{
@@ -925,7 +925,7 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const
string msg = "non-local sequence `" + name + "' cannot have local element type";
_unit->error(msg);
}
-
+
SequencePtr p = new Sequence(this, name, type, metaData, local);
_contents.push_back(p);
return p;
@@ -948,7 +948,7 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c
return 0;
}
}
-
+
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
@@ -975,7 +975,7 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c
}
return 0;
}
-
+
nameIsLegal(name, "dictionary"); // Don't return here -- we create the dictionary anyway.
if(nt == Real)
@@ -1855,7 +1855,7 @@ Slice::Container::hasContentsWithMetaData(const string& meta) const
if(container && container->hasContentsWithMetaData(meta))
{
return true;
- }
+ }
}
return false;
@@ -1937,7 +1937,7 @@ Slice::Container::mergeModules()
{
continue;
}
-
+
DefinitionContextPtr dc1 = mod1->definitionContext();
assert(dc1);
StringList metaData1 = dc1->getMetaData();
@@ -1987,7 +1987,7 @@ Slice::Container::mergeModules()
_unit->removeContent(*q);
q = _contents.erase(q);
}
-
+
mod1->mergeModules();
}
}
@@ -2061,7 +2061,7 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing)
{
return true;
}
-
+
//
// Split off first component.
//
@@ -2312,7 +2312,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined,
_unit->error(msg);
return false;
}
-
+
if(intf && !intfOther)
{
string msg = "interface `";
@@ -2323,7 +2323,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined,
_unit->error(msg);
return false;
}
-
+
if(!local && localOther)
{
string msg = "non-local `";
@@ -2334,7 +2334,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined,
_unit->error(msg);
return false;
}
-
+
if(local && !localOther)
{
string msg = "local `";
@@ -2345,7 +2345,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined,
_unit->error(msg);
return false;
}
-
+
return true;
}
@@ -2965,7 +2965,7 @@ Slice::ClassDecl::addPartition(GraphPartitionList& gpl,
// Convert the list of partitions of class definitions into a
// list of lists, with each member list containing the operation
// names defined by the interfaces in each partition.
-//
+//
Slice::ClassDecl::StringPartitionList
Slice::ClassDecl::toStringPartitionList(const GraphPartitionList& gpl)
{
@@ -3140,7 +3140,7 @@ Slice::ClassDef::createOperation(const string& name,
msg += name + "' with local return type";
_unit->error(msg);
}
-
+
_hasOperations = true;
OperationPtr op = new Operation(this, name, returnType, optional, tag, mode);
_contents.push_back(op);
@@ -3164,7 +3164,7 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type, bool
string msg = "Class data member `" + name + "' cannot be a value object.";
_unit->error(msg);
return 0;
- }
+ }
ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
if(classDecl != 0 && !classDecl->isLocal())
@@ -3176,7 +3176,7 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type, bool
}
}
- assert(!isInterface());
+ assert(!isInterface());
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
@@ -3640,7 +3640,7 @@ Slice::ClassDef::ClassDef(const ContainerPtr& container, const string& name, int
assert(p == _bases.begin() || (*p)->isInterface());
}
#endif
-
+
if(_compactId >= 0)
{
_unit->addTypeId(_compactId, scoped());
@@ -4091,7 +4091,7 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type, bool op
if(_unit->profile() == IceE)
{
if(!isLocal())
- {
+ {
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if((builtin && builtin->kind() == Builtin::KindObject))
{
@@ -4108,7 +4108,7 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type, bool op
}
}
}
-
+
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
@@ -4624,7 +4624,7 @@ Slice::Dictionary::legalKeyType(const TypePtr& type, bool& containsSequence)
}
Slice::Dictionary::Dictionary(const ContainerPtr& container, const string& name, const TypePtr& keyType,
- const StringList& keyMetaData, const TypePtr& valueType,
+ const StringList& keyMetaData, const TypePtr& valueType,
const StringList& valueMetaData, bool local) :
SyntaxTreeBase(container->unit()),
Type(container->unit()),
@@ -4904,9 +4904,9 @@ Slice::Const::visit(ParserVisitor* visitor, bool)
Slice::Const::Const(const ContainerPtr& container, const string& name, const TypePtr& type,
const StringList& typeMetaData, const SyntaxTreeBasePtr& valueType, const string& value,
const string& literal) :
- SyntaxTreeBase(container->unit()),
+ SyntaxTreeBase(container->unit()),
Contained(container, name),
- _type(type),
+ _type(type),
_typeMetaData(typeMetaData),
_valueType(valueType),
_value(value),
@@ -5275,13 +5275,13 @@ Slice::Operation::attributes() const
assert(classDef != 0);
classDef->findMetaData("freeze:", freezeMD);
}
-
+
if(freezeMD != "")
{
int result = 0;
freezeMD = freezeMD.substr(strlen("freeze:"));
-
+
int i = 0;
while(i < 2)
{
@@ -5303,12 +5303,12 @@ Slice::Operation::attributes() const
{
freezeMD = (result == 0) ? ":supports" : ":required";
}
-
+
//
// Remove ":"
//
freezeMD = freezeMD.substr(1);
-
+
int i = 0;
while(i < 4)
{
@@ -5327,7 +5327,7 @@ Slice::Operation::attributes() const
}
i++;
}
-
+
if(i == 4)
{
emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation");
@@ -6132,12 +6132,12 @@ Slice::Unit::parse(const string& filename, FILE* file, bool debug, Slice::Featur
pushDefinitionContext();
//
- // MCPP Fix: mcpp doesn't always output the first #line when mcpp_lib_main is
- // called repeatedly. We scan a fake #line here to ensure the top definition
+ // MCPP Fix: mcpp doesn't always output the first #line when mcpp_lib_main is
+ // called repeatedly. We scan a fake #line here to ensure the top definition
// context is correctly initialized.
//
scanPosition(string("#line 1 " + _topLevelFile).c_str());
-
+
slice_in = file;
int status = slice_parse();
if(_errors)
@@ -6294,7 +6294,7 @@ Slice::CICompare::operator()(const string& s1, const string& s2) const
}
#if defined(__SUNPRO_CC)
-bool
+bool
Slice::cICompare(const std::string& s1, const std::string& s2)
{
CICompare c;
@@ -6314,7 +6314,7 @@ Slice::DerivedToBaseCompare::operator()(const ExceptionPtr& e1, const ExceptionP
}
#if defined(__SUNPRO_CC)
-bool
+bool
Slice::derivedToBaseCompare(const ExceptionPtr& e1, const ExceptionPtr& e2)
{
return e2->isBaseOf(e1);
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp
index cefa4d31a6d..adeffc18a40 100644
--- a/cpp/src/Slice/PythonUtil.cpp
+++ b/cpp/src/Slice/PythonUtil.cpp
@@ -121,7 +121,7 @@ private:
//
// Write an initializer value for a given type.
//
- void writeInitializer(const TypePtr&);
+ void writeInitializer(const DataMemberPtr&);
//
// Add a value to a hash code.
@@ -1674,8 +1674,9 @@ Slice::Python::CodeVisitor::writeType(const TypePtr& p)
}
void
-Slice::Python::CodeVisitor::writeInitializer(const TypePtr& p)
+Slice::Python::CodeVisitor::writeInitializer(const DataMemberPtr& m)
{
+ TypePtr p = m->type();
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
@@ -1988,7 +1989,7 @@ Slice::Python::CodeVisitor::writeConstructorParams(const MemberInfoList& members
}
else
{
- writeInitializer(member->type());
+ writeInitializer(member);
}
}
}
@@ -2450,15 +2451,16 @@ Slice::Python::MetaDataVisitor::visitUnitStart(const UnitPtr& p)
string s = *r;
if(_history.count(s) == 0)
{
+ _history.insert(s);
if(s.find(prefix) == 0)
{
static const string packagePrefix = "python:package:";
- if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size())
+ if(s.find(packagePrefix) == 0 && s.size() > packagePrefix.size())
{
- emitWarning(file, "", "ignoring invalid global metadata `" + s + "'");
+ continue;
}
+ emitWarning(file, "", "ignoring invalid global metadata `" + s + "'");
}
- _history.insert(s);
}
}
}
@@ -2601,9 +2603,7 @@ void
Slice::Python::MetaDataVisitor::reject(const ContainedPtr& cont)
{
StringList localMetaData = cont->getMetaData();
-
static const string prefix = "python:";
-
for(StringList::const_iterator p = localMetaData.begin(); p != localMetaData.end(); ++p)
{
if(p->find(prefix) == 0)
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index c895d3fbf55..bc90db3f1b3 100644
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -64,7 +64,7 @@ private:
//
// Get an initializer value for a given type.
//
- string getInitializer(const TypePtr&);
+ string getInitializer(const DataMemberPtr&);
//
// Add a value to a hash code.
@@ -113,8 +113,8 @@ lookupKwd(const string& name)
// conflict with a Slice identifier, so names such as "inspect" and
// "send" are included but "to_s" is not.
//
- static const string keywordList[] =
- {
+ static const string keywordList[] =
+ {
"BEGIN", "END", "alias", "and", "begin", "break", "case", "class", "clone", "def", "display", "do", "dup",
"else", "elsif", "end", "ensure", "extend", "false", "for", "freeze", "hash", "if", "in", "initialize_copy",
"inspect", "instance_eval", "instance_variable_get", "instance_variable_set", "instance_variables", "method",
@@ -1363,8 +1363,9 @@ Slice::Ruby::CodeVisitor::writeType(const TypePtr& p)
}
string
-Slice::Ruby::CodeVisitor::getInitializer(const TypePtr& p)
+Slice::Ruby::CodeVisitor::getInitializer(const DataMemberPtr& m)
{
+ TypePtr p = m->type();
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
@@ -1582,7 +1583,7 @@ Slice::Ruby::CodeVisitor::writeConstructorParams(const MemberInfoList& members)
}
else
{
- _out << getInitializer(member->type());
+ _out << getInitializer(member);
}
}
}
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 63adc6076c2..6693a6fdc9f 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -2045,6 +2045,27 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
}
}
+bool
+Slice::CsVisitor::requiresDataMemberInitializers(const DataMemberList& members)
+{
+ for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
+ {
+ if((*p)->defaultValueType())
+ {
+ return true;
+ }
+ else if((*p)->optional())
+ {
+ return true;
+ }
+ else if(BuiltinPtr::dynamicCast((*p)->type()) || StructPtr::dynamicCast((*p)->type()))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
void
Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, int baseTypes, bool propertyMapping)
{
@@ -2070,6 +2091,20 @@ Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, int
_out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString((*p)->type(), true)
<< "();";
}
+ else
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*p)->type());
+ if(builtin && builtin->kind() == Builtin::KindString)
+ {
+ _out << nl << fixId((*p)->name(), baseTypes) << " = \"\";";
+ }
+
+ StructPtr st = StructPtr::dynamicCast((*p)->type());
+ if(st)
+ {
+ _out << nl << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, false) << "();";
+ }
+ }
}
}
@@ -3555,9 +3590,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << sp << nl << "#region Constructors";
- const bool hasDefaultValues = p->hasDefaultValues();
-
- if(hasDefaultValues)
+ const bool hasDataMemberInitializers = requiresDataMemberInitializers(dataMembers);
+ if(hasDataMemberInitializers)
{
_out << sp << nl << "private void initDM__()";
_out << sb;
@@ -3569,7 +3603,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
emitGeneratedCodeAttribute();
_out << nl << "public " << name << "()";
_out << sb;
- if(hasDefaultValues)
+ if(hasDataMemberInitializers)
{
_out << nl << "initDM__();";
}
@@ -3579,7 +3613,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
emitGeneratedCodeAttribute();
_out << nl << "public " << name << "(_System.Exception ex__) : base(ex__)";
_out << sb;
- if(hasDefaultValues)
+ if(hasDataMemberInitializers)
{
_out << nl << "initDM__();";
}
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index baa30e6cd79..6ccf03488c6 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -55,6 +55,7 @@ protected:
//
// Generate assignment statements for those data members that have default values.
//
+ bool requiresDataMemberInitializers(const DataMemberList&);
void writeDataMemberInitializers(const DataMemberList&, int = 0, bool = false);
std::string toCsIdent(const std::string&);
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index a2b65ccbb22..ae6b1beaf87 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -939,6 +939,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
out << nl << "Patcher __p = new Patcher();";
patchParams = "__p";
}
+ else if(StructPtr::dynamicCast(type))
+ {
+ out << nl << typeS << " __r = null;";
+ }
else
{
out << nl << typeS << " __r;";
@@ -1082,7 +1086,14 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
list<string> metaData;
string patchParams;
- out << nl << indexKeyTypeS << " r;";
+ if(StructPtr::dynamicCast(indexTypes[i]))
+ {
+ out << nl << indexKeyTypeS << " r = null;";
+ }
+ else
+ {
+ out << nl << indexKeyTypeS << " r;";
+ }
BuiltinPtr b = BuiltinPtr::dynamicCast(indexTypes[i]);
if(b != 0)
@@ -1737,7 +1748,7 @@ compile(int argc, char* argv[])
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
-
+
if(dependxml)
{
cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
@@ -1811,7 +1822,7 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
}
-
+
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
@@ -1821,7 +1832,7 @@ compile(int argc, char* argv[])
}
}
}
-
+
if(dependxml)
{
cout << "</dependencies>\n";
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index fe9e2de65fb..0cfbdc57c37 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -669,6 +669,10 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa
out << nl << retS << "Holder __ret = new " << retS << "Holder();";
holder = true;
}
+ else if(StructPtr::dynamicCast(ret))
+ {
+ out << nl << retS << " __ret = null;";
+ }
else
{
out << nl << retS << " __ret;";
@@ -1270,6 +1274,10 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr&
{
out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
}
+ else if(StructPtr::dynamicCast(paramType))
+ {
+ out << nl << typeS << ' ' << paramName << " = null;";
+ }
else
{
out << nl << typeS << ' ' << paramName << ';';
@@ -1414,6 +1422,10 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr&
{
out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
}
+ else if(StructPtr::dynamicCast(paramType))
+ {
+ out << nl << typeS << ' ' << paramName << " = null;";
+ }
else
{
out << nl << typeS << ' ' << paramName << ';';
@@ -1920,6 +1932,7 @@ Slice::JavaVisitor::writeDataMemberInitializers(Output& out, const DataMemberLis
{
for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
{
+ TypePtr t = (*p)->type();
if((*p)->defaultValueType())
{
if((*p)->optional())
@@ -1927,16 +1940,38 @@ Slice::JavaVisitor::writeDataMemberInitializers(Output& out, const DataMemberLis
string capName = (*p)->name();
capName[0] = toupper(static_cast<unsigned char>(capName[0]));
out << nl << "set" << capName << '(';
- writeConstantValue(out, (*p)->type(), (*p)->defaultValueType(), (*p)->defaultValue(), package);
+ writeConstantValue(out, t, (*p)->defaultValueType(), (*p)->defaultValue(), package);
out << ");";
}
else
{
out << nl << fixKwd((*p)->name()) << " = ";
- writeConstantValue(out, (*p)->type(), (*p)->defaultValueType(), (*p)->defaultValue(), package);
+ writeConstantValue(out, t, (*p)->defaultValueType(), (*p)->defaultValue(), package);
out << ';';
}
}
+ else
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(t);
+ if(builtin && builtin->kind() == Builtin::KindString)
+ {
+ out << nl << fixKwd((*p)->name()) << " = \"\";";
+ }
+
+ EnumPtr en = EnumPtr::dynamicCast(t);
+ if(en)
+ {
+ string firstEnum = fixKwd(en->getEnumerators().front()->name());
+ out << nl << fixKwd((*p)->name()) << " = " << getAbsolute(en, package) << '.' << firstEnum << ';';
+ }
+
+ StructPtr st = StructPtr::dynamicCast(t);
+ if(st)
+ {
+ string memberType = typeToString(st, TypeModeMember, package, (*p)->getMetaData());
+ out << nl << fixKwd((*p)->name()) << " = new " << memberType << "();";
+ }
+ }
}
}
@@ -2904,7 +2939,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Implement interfaces
//
-
+
if(p->isAbstract())
{
if(!p->isLocal())
@@ -3261,7 +3296,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
out << nl << "assert false; // impossible";
out << eb;
out << nl << "return c;";
-
+
}
else
{
@@ -3836,10 +3871,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << sp << nl << "public " << name << "()";
out << sb;
- if(p->hasDefaultValues())
- {
- writeDataMemberInitializers(out, members, package);
- }
+ writeDataMemberInitializers(out, members, package);
out << eb;
//
@@ -4062,9 +4094,12 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << eb;
out << eb;
- out << sp << nl << "static public " << name << nl << "__readNew(IceInternal.BasicStream __is)";
+ out << sp << nl << "static public " << name << nl << "__read(IceInternal.BasicStream __is, " << name << " __v)";
out << sb;
- out << nl << name << " __v = new " << name << "();";
+ out << nl << "if(__v == null)";
+ out << sb;
+ out << nl << " __v = new " << name << "();";
+ out << eb;
out << nl << "__v.__read(__is);";
out << nl << "return __v;";
out << eb;
@@ -4083,9 +4118,12 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << eb;
out << eb;
- out << sp << nl << "static public " << name << nl << "ice_readNew(Ice.InputStream __inS)";
+ out << sp << nl << "static public " << name << nl << "ice_read(Ice.InputStream __inS, " << name << " __v)";
out << sb;
- out << nl << name << " __v = new " << name << "();";
+ out << nl << "if(__v == null)";
+ out << sb;
+ out << nl << " __v = new " << name << "();";
+ out << eb;
out << nl << "__v.ice_read(__inS);";
out << nl << "return __v;";
out << eb;
@@ -4648,36 +4686,10 @@ Slice::Gen::HolderVisitor::visitStructStart(const StructPtr& p)
void
Slice::Gen::HolderVisitor::visitSequence(const SequencePtr& p)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type());
- if(builtin && builtin->kind() == Builtin::KindByte)
- {
- string prefix = "java:serializable:";
- string meta;
- if(p->findMetaData(prefix, meta))
- {
- return; // No holders for serializable types.
- }
- prefix = "java:protobuf:";
- if(p->findMetaData(prefix, meta))
- {
- return; // No holders for protobuf types.
- }
- }
-
- if(builtin &&
- (builtin->kind() == Builtin::KindByte || builtin->kind() == Builtin::KindShort ||
- builtin->kind() == Builtin::KindInt || builtin->kind() == Builtin::KindLong ||
- builtin->kind() == Builtin::KindFloat || builtin->kind() == Builtin::KindDouble))
+ if(sequenceHasHolder(p))
{
- string meta;
- string prefix = "java:buffer";
- if(p->findMetaData(prefix, meta))
- {
- return; // No holders for buffer types.
- }
+ writeHolder(p);
}
-
- writeHolder(p);
}
void
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp
index 1597220563e..b7e5a8bdd55 100644
--- a/cpp/src/slice2js/Gen.cpp
+++ b/cpp/src/slice2js/Gen.cpp
@@ -34,14 +34,6 @@ using namespace IceUtilInternal;
namespace
{
-bool
-isObjectType(const TypePtr& type)
-{
- BuiltinPtr b = BuiltinPtr::dynamicCast(type);
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- return cl || (b && b->kind() == Builtin::KindObject);
-}
-
string
sliceModeToIceMode(Operation::Mode opMode)
{
@@ -178,35 +170,79 @@ Slice::JsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const
}
void
-Slice::JsVisitor::writeMarshalDataMember(const DataMemberPtr& member)
+Slice::JsVisitor::writeMarshalDataMembers(const DataMemberList& dataMembers)
{
- if(member->optional())
- {
- writeOptionalMarshalUnmarshalCode(_out, member->type(), "this." + fixId(member->name()), member->tag(), true);
- }
- else
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, member->type(), "this." + fixId(member->name()), true);
+ if((*q)->optional())
+ {
+ writeOptionalMarshalUnmarshalCode(_out, (*q)->type(), "this." + fixId((*q)->name()), (*q)->tag(), true);
+ }
+ else
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(), "this." + fixId((*q)->name()), true);
+ }
}
}
void
-Slice::JsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member)
+Slice::JsVisitor::writeUnmarshalDataMembers(const DataMemberList& dataMembers)
{
- if(member->optional())
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeOptionalMarshalUnmarshalCode(_out, member->type(), "this." + fixId(member->name()),
- member->tag(), false);
+ if(isClassType((*q)->type()))
+ {
+ _out << nl << "var self = this;";
+ break;
+ }
}
- else
+
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, member->type(), "this." + fixId(member->name()), false);
+ if((*q)->optional())
+ {
+ writeOptionalMarshalUnmarshalCode(_out, (*q)->type(), "this." + fixId((*q)->name()), (*q)->tag(), false);
+ }
+ else
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(), "this." + fixId((*q)->name()), false);
+ }
}
}
void
-Slice::JsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
+Slice::JsVisitor::writeInitDataMembers(const DataMemberList& dataMembers, const string& scope)
{
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ const string m = fixId((*q)->name());
+ if((*q)->optional())
+ {
+ if((*q)->defaultValueType())
+ {
+ _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
+ writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ _out << ';';
+ }
+ else
+ {
+ _out << nl << "this." << m << " = " << m << ';';
+ }
+ }
+ else
+ {
+ _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
+ if((*q)->defaultValueType())
+ {
+ writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ _out << getValue(scope, (*q)->type());
+ }
+ _out << ';';
+ }
+ }
}
vector<string>
@@ -387,6 +423,10 @@ Slice::JsVisitor::getValue(const string& scope, const TypePtr& type)
return "0.0";
break;
}
+ case Builtin::KindString:
+ {
+ return "\"\"";
+ }
default:
{
return "null";
@@ -398,7 +438,13 @@ Slice::JsVisitor::getValue(const string& scope, const TypePtr& type)
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- return getReference(scope, (*en->getEnumerators().begin())->scoped());
+ return getReference(scope, en->scoped()) + '.' + fixId((*en->getEnumerators().begin())->name());
+ }
+
+ StructPtr st = StructPtr::dynamicCast(type);
+ if(st)
+ {
+ return "new " + typeToString(type) + "()";
}
return "null";
@@ -1047,17 +1093,6 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
allParamNames.push_back(fixId((*q)->name()));
}
- bool hasClassMembers = false;
- vector<string> paramNames;
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- paramNames.push_back(fixId((*q)->name()));
- if(!hasClassMembers && isClassType((*q)->type()))
- {
- hasClassMembers = true;
- }
- }
-
vector<string> baseParamNames;
DataMemberList baseDataMembers;
@@ -1083,37 +1118,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << nl << baseRef << ".call" << spar << "this" << baseParamNames << epar << ';';
}
-
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- const string m = fixId((*q)->name());
- if((*q)->optional())
- {
- if((*q)->defaultValueType())
- {
- _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- _out << ';';
- }
- else
- {
- _out << nl << "this." << m << " = " << m << ';';
- }
- }
- else
- {
- _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
- if((*q)->defaultValueType())
- {
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- }
- else
- {
- _out << getValue(scope, (*q)->type());
- }
- _out << ';';
- }
- }
+ writeInitDataMembers(dataMembers, scope);
_out << eb;
}
else
@@ -1208,22 +1213,11 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << nl << "function(__os)";
_out << sb;
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalDataMember(*q);
- }
+ writeMarshalDataMembers(dataMembers);
_out << eb << ",";
-
_out << nl << "function(__is)";
_out << sb;
- if(hasClassMembers)
- {
- _out << nl << "var self = this;";
- }
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeUnmarshalDataMember(*q);
- }
+ writeUnmarshalDataMembers(dataMembers);
_out << eb << ",";
_out << nl;
}
@@ -1367,7 +1361,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(ret)
{
_out << '[' << encodeTypeForOperation(ret);
- const bool isObj = isObjectType(ret);
+ const bool isObj = isClassType(ret);
if(isObj)
{
_out << ", true";
@@ -1398,7 +1392,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
}
TypePtr t = (*pli)->type();
_out << '[' << encodeTypeForOperation(t);
- const bool isObj = isObjectType(t);
+ const bool isObj = isClassType(t);
if(isObj)
{
_out << ", true";
@@ -1431,7 +1425,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
}
TypePtr t = (*pli)->type();
_out << '[' << encodeTypeForOperation(t);
- const bool isObj = isObjectType(t);
+ const bool isObj = isClassType(t);
if(isObj)
{
_out << ", true";
@@ -1549,17 +1543,6 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
allParamNames.push_back(fixId((*q)->name()));
}
- vector<string> paramNames;
- bool hasClassMembers = false;
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- paramNames.push_back(fixId((*q)->name()));
- if(!hasClassMembers && ClassDeclPtr::dynamicCast((*q)->type()))
- {
- hasClassMembers = true;
- }
- }
-
vector<string> baseParamNames;
DataMemberList baseDataMembers;
@@ -1580,36 +1563,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
_out << nl << "function" << spar << allParamNames << "_cause" << epar;
_out << sb;
_out << nl << baseRef << ".call" << spar << "this" << baseParamNames << "_cause" << epar << ';';
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- const string m = fixId((*q)->name());
- if((*q)->optional())
- {
- if((*q)->defaultValueType())
- {
- _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- _out << ';';
- }
- else
- {
- _out << nl << "this." << m << " = " << m << ';';
- }
- }
- else
- {
- _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
- if((*q)->defaultValueType())
- {
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- }
- else
- {
- _out << getValue(scope, (*q)->type());
- }
- _out << ';';
- }
- }
+ writeInitDataMembers(dataMembers, scope);
_out << eb << ",";
_out << nl << baseRef << ",";
_out << nl << "\"" << p->scoped().substr(2) << "\"";
@@ -1623,21 +1577,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
{
_out << nl << "function(__os)";
_out << sb;
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalDataMember(*q);
- }
+ writeMarshalDataMembers(dataMembers);
_out << eb << ",";
_out << nl << "function(__is)";
_out << sb;
- if(hasClassMembers)
- {
- _out << nl << "var self = this;";
- }
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeUnmarshalDataMember(*q);
- }
+ writeUnmarshalDataMembers(dataMembers);
_out << eb;
}
else
@@ -1692,26 +1636,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
_out.inc();
_out << nl << "function" << spar << paramNames << epar;
_out << sb;
- bool hasClassMembers = false;
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- if(!hasClassMembers && isClassType((*q)->type()))
- {
- hasClassMembers = true;
- }
-
- string memberName = fixId((*q)->name());
- _out << nl << "this." << memberName << " = " << memberName << " !== undefined ? " << memberName << " : ";
- if((*q)->defaultValueType())
- {
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- }
- else
- {
- _out << getValue(scope, (*q)->type());
- }
- _out << ';';
- }
+ writeInitDataMembers(dataMembers, scope);
_out << eb << ",";
_out << nl << (legalKeyType ? "true" : "false");
@@ -1721,25 +1646,12 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
_out << ",";
_out << nl << "function(__os)";
_out << sb;
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalDataMember(*q);
- }
+ writeMarshalDataMembers(dataMembers);
_out << eb << ",";
-
_out << nl << "function(__is)";
_out << sb;
- if(hasClassMembers)
- {
- _out << nl << "var self = this;";
- }
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeUnmarshalDataMember(*q);
- }
- _out << eb << ","
- << nl << p->minWireSize() << ", "
- << nl << (p->isVariableLength() ? "false" : "true");
+ writeUnmarshalDataMembers(dataMembers);
+ _out << eb << "," << nl << p->minWireSize() << ", " << nl << (p->isVariableLength() ? "false" : "true");
_out.dec();
_out << ");";
}
diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h
index 86011de4bc8..8b788ae334b 100644
--- a/cpp/src/slice2js/Gen.h
+++ b/cpp/src/slice2js/Gen.h
@@ -26,10 +26,10 @@ protected:
void writeMarshalUnmarshalParams(const ParamDeclList&, const OperationPtr&, bool);
void writePostUnmarshalParams(const ParamDeclList&, const OperationPtr&);
- void writeMarshalDataMember(const DataMemberPtr&);
- void writeUnmarshalDataMember(const DataMemberPtr&);
+ void writeMarshalDataMembers(const DataMemberList&);
+ void writeUnmarshalDataMembers(const DataMemberList&);
+ void writeInitDataMembers(const DataMemberList&, const std::string&);
- virtual void writeDispatchAndMarshalling(const ClassDefPtr&);
virtual std::vector<std::string> getParams(const OperationPtr&);
virtual std::vector<std::string> getParamsAsync(const OperationPtr&, bool, bool = false);
virtual std::vector<std::string> getParamsAsyncCB(const OperationPtr&, bool = false, bool = true);
@@ -40,7 +40,7 @@ protected:
std::string getValue(const std::string&, const TypePtr&);
void writeConstantValue(const std::string&, const TypePtr&, const SyntaxTreeBasePtr&, const std::string&);
-
+
static StringList splitComment(const ContainedPtr&);
void writeDocComment(const ContainedPtr&, const std::string&, const std::string& = "");
@@ -55,7 +55,7 @@ public:
const std::vector<std::string>&,
const std::string&,
bool);
-
+
Gen(const std::string&,
const std::vector<std::string>&,
const std::string&,
@@ -75,7 +75,7 @@ private:
std::string _fileBase;
bool _icejs;
bool _useStdout;
-
+
void printHeader();
class RequireVisitor : public JsVisitor
@@ -132,7 +132,7 @@ private:
std::vector<std::string> _seenModules;
bool _icejs;
};
-
+
class ExportVisitor : public JsVisitor
{
public:
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index 033706758cc..35a8cba1996 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -111,7 +111,7 @@ Slice::ObjCVisitor::~ObjCVisitor()
}
void
-Slice::ObjCVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const OperationPtr& op, bool marshal,
+Slice::ObjCVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const OperationPtr& op, bool marshal,
bool reference)
{
ParamDeclList optionals;
@@ -174,7 +174,7 @@ Slice::ObjCVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped);
assert(scopedIter != ids.end());
StringList::difference_type scopedPos = IceUtilInternal::distance(firstIter, scopedIter);
-
+
_M << sp << nl << "static NSString *" << name << "_ids__[] = ";
_M << sb;
{
@@ -200,7 +200,7 @@ Slice::ObjCVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
assert(cl);
string opName = getName(op);
- _M << sp << nl << "+(BOOL)" << op->name() << "___:(id<" << name << ">)target_ current:(ICECurrent *)current "
+ _M << sp << nl << "+(BOOL)" << op->name() << "___:(id<" << name << ">)target_ current:(ICECurrent *)current "
<< "is:(id<ICEInputStream>)is_ os:(id<ICEOutputStream>)os_";
_M << sb;
@@ -269,7 +269,7 @@ Slice::ObjCVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
}
_M << ";";
}
- _M << nl << "[os_ startEncapsulation:encoding format:" << opFormatTypeToString(*r) << "];";
+ _M << nl << "[os_ startEncapsulation:encoding format:" << opFormatTypeToString(*r) << "];";
TypePtr returnType = op->returnType();
if(returnType)
{
@@ -1010,7 +1010,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
//
// Init, factory, copyWithZone and dealloc methods.
//
- writeInit(p, dataMembers, baseDataMembers, allDataMembers, p->hasDefaultValues(), BaseTypeObject, Other);
+ writeInit(p, dataMembers, baseDataMembers, allDataMembers, requiresMemberInit(dataMembers), BaseTypeObject, Other);
writeFactory(p, allDataMembers, BaseTypeObject, Other);
writeCopyWithZone(p, allDataMembers, BaseTypeObject, Other);
writeMemberDealloc(dataMembers, BaseTypeObject, preserved && !basePreserved);
@@ -1043,7 +1043,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
OperationPtr op = *r;
_H << nl << "+(BOOL)" << op->name() << "___:(id<" << name
- << ">)target current:(ICECurrent *)current "
+ << ">)target current:(ICECurrent *)current "
<< "is:(id<ICEInputStream>)is_ os:(id<ICEOutputStream>)os_;";
}
@@ -1053,7 +1053,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_M << sp << nl << "-(void) writeImpl__:(id<ICEOutputStream>)os_";
_M << sb;
- _M << nl << "[os_ startSlice:@\"" << p->scoped() << "\" compactId: " << p->compactId() << " lastSlice:"
+ _M << nl << "[os_ startSlice:@\"" << p->scoped() << "\" compactId: " << p->compactId() << " lastSlice:"
<< (!hasBaseClass ? "YES" : "NO") << "];";
writeMemberMarshal(dataMembers, optionalMembers, BaseTypeObject);
_M << nl << "[os_ endSlice];";
@@ -1077,7 +1077,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
writeDispatchAndMarshalling(p);
if(preserved && !basePreserved)
- {
+ {
_M << nl << "-(void) write__:(id<ICEOutputStream>)os";
_M << sb;
_M << nl << "[os startObject:slicedData__];";
@@ -1118,7 +1118,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
retString = inTypeToString(returnType, p->returnIsOptional());
params = getServerParams(p);
}
-
+
_H << nl << "-(" << retString << ") " << name << params;
if(!cl->isLocal())
{
@@ -1138,7 +1138,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
// TODO: add supports for parameters when needed.
_H << nl << "-(id<ICEAsyncResult>) begin_" << name << ";";
_H << nl << "-(id<ICEAsyncResult>) begin_" << name << ":(void(^)(ICEException*))exception;";
- _H << nl << "-(id<ICEAsyncResult>) begin_" << name
+ _H << nl << "-(id<ICEAsyncResult>) begin_" << name
<< ":(void(^)(ICEException*))exception sent:(void(^)(BOOL))sent;";
_H << nl << "-(void) end_" << name << ":(id<ICEAsyncResult>)result;";
}
@@ -1203,7 +1203,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
DataMemberList optionalMembers = p->orderedOptionalDataMembers();
DataMemberList allDataMembers = p->allDataMembers();
DataMemberList::const_iterator q;
-
+
DataMemberList baseDataMembers;
if(p->base())
{
@@ -1250,7 +1250,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_M << eb;
ContainerType ct = p->isLocal() ? LocalException : Other;
- writeInit(p, dataMembers, baseDataMembers, allDataMembers, p->hasDefaultValues(), BaseTypeException, ct);
+ writeInit(p, dataMembers, baseDataMembers, allDataMembers, requiresMemberInit(dataMembers), BaseTypeException, ct);
writeFactory(p, allDataMembers, BaseTypeException, ct);
writeCopyWithZone(p, allDataMembers, BaseTypeException, ct);
writeMemberDealloc(dataMembers, BaseTypeException, preserved && !basePreserved);
@@ -1279,7 +1279,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
{
_M << sp << nl << "-(void) writeImpl__:(id<ICEOutputStream>)os_";
_M << sb;
- _M << nl << "[os_ startSlice:@\"" << p->scoped() << "\" compactId:-1 lastSlice:"
+ _M << nl << "[os_ startSlice:@\"" << p->scoped() << "\" compactId:-1 lastSlice:"
<< (!base ? "YES" : "NO") << "];";
writeMemberMarshal(dataMembers, optionalMembers, BaseTypeException);
_M << nl << "[os_ endSlice];";
@@ -1362,7 +1362,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
writeProperties(dataMembers, BaseTypeObject);
writeSynthesize(dataMembers, BaseTypeObject);
- writeInit(p, dataMembers, DataMemberList(), dataMembers, p->hasDefaultValues(), BaseTypeObject, Other);
+ writeInit(p, dataMembers, DataMemberList(), dataMembers, requiresMemberInit(dataMembers), BaseTypeObject, Other);
writeFactory(p, dataMembers, BaseTypeObject, Other);
writeCopyWithZone(p, dataMembers, BaseTypeObject, Other);
writeMemberDealloc(dataMembers, BaseTypeObject);
@@ -1397,12 +1397,12 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
//
_H << nl << "-(void) write__:(id<ICEOutputStream>)os_;";
_H << nl << "-(void) read__:(id<ICEInputStream>)is_;";
-
+
_M << sp << nl << "-(void) write__:(id<ICEOutputStream>)os_";
_M << sb;
writeMemberMarshal(dataMembers, DataMemberList(), BaseTypeObject);
_M << eb;
-
+
_M << sp << nl << "-(void) read__:(id<ICEInputStream>)is_";
_M << sb;
writeMemberUnmarshal(dataMembers, DataMemberList(), BaseTypeObject);
@@ -1539,8 +1539,8 @@ Slice::Gen::TypesVisitor::writeConstantValue(IceUtilInternal::Output& out, const
void
Slice::Gen::TypesVisitor::writeInit(const ContainedPtr& p, const DataMemberList& dataMembers,
- const DataMemberList& baseDataMembers, const DataMemberList& allDataMembers,
- bool hasDefaultValues, int baseType, ContainerType ct) const
+ const DataMemberList& baseDataMembers, const DataMemberList& allDataMembers,
+ bool requiresMemberInit, int baseType, ContainerType ct) const
{
if(dataMembers.empty())
{
@@ -1548,12 +1548,12 @@ Slice::Gen::TypesVisitor::writeInit(const ContainedPtr& p, const DataMemberList&
}
_H << sp;
- if(hasDefaultValues)
+ if(requiresMemberInit)
{
_H << nl << "-(id) init;";
_M << sp << nl << "-(id) init";
_M << sb;
- _M << nl << "self = [super init];";
+ _M << nl << "self = [super init];";
_M << nl << "if(!self)";
_M << sb;
_M << nl << "return nil;";
@@ -1601,7 +1601,7 @@ Slice::Gen::TypesVisitor::writeFactory(const ContainedPtr& p, const DataMemberLi
writeMemberSignature(dataMembers, baseType, ct);
_H << ";";
_M << sb;
-
+
//
// The cast avoids a compiler warning that is emitted if different structs
// have members with the same name but different types.
@@ -1616,7 +1616,7 @@ Slice::Gen::TypesVisitor::writeFactory(const ContainedPtr& p, const DataMemberLi
_M << eb;
//
- // TODO: DEPRECATED: we used to
+ // TODO: DEPRECATED: we used to
//
string deprecatedFactoryMethod = getFactoryMethod(p, true);
if(factoryMethod != deprecatedFactoryMethod)
@@ -1638,7 +1638,7 @@ Slice::Gen::TypesVisitor::writeFactory(const ContainedPtr& p, const DataMemberLi
}
void
-Slice::Gen::TypesVisitor::writeCopyWithZone(const ContainedPtr& p, const DataMemberList& dataMembers,
+Slice::Gen::TypesVisitor::writeCopyWithZone(const ContainedPtr& p, const DataMemberList& dataMembers,
int baseType, ContainerType ct) const
{
if(dataMembers.empty())
@@ -1765,14 +1765,39 @@ Slice::Gen::TypesVisitor::writeMemberCall(const DataMemberList& dataMembers, int
}
}
+bool
+Slice::Gen::TypesVisitor::requiresMemberInit(const DataMemberList& members) const
+{
+ for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
+ {
+ if((*p)->defaultValueType())
+ {
+ return true;
+ }
+
+ if((*p)->optional())
+ {
+ return true;
+ }
+
+ TypePtr t = (*p)->type();
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(t);
+ if((builtin && builtin->kind() == Builtin::KindString) || EnumPtr::dynamicCast(t) || StructPtr::dynamicCast(t))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
void
Slice::Gen::TypesVisitor::writeMemberDefaultValueInit(const DataMemberList& dataMembers, int baseType) const
{
for(DataMemberList::const_iterator p = dataMembers.begin(); p != dataMembers.end(); ++p)
{
+ string name = fixId((*p)->name(), baseType);
if((*p)->defaultValueType())
{
- string name = fixId((*p)->name(), baseType);
if((*p)->optional())
{
_M << nl << "self->has_" << name << "__ = YES;";
@@ -1781,6 +1806,27 @@ Slice::Gen::TypesVisitor::writeMemberDefaultValueInit(const DataMemberList& data
writeConstantValue(_M, (*p)->type(), (*p)->defaultValue());
_M << ";";
}
+ else
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*p)->type());
+ if(builtin && builtin->kind() == Builtin::KindString)
+ {
+ _M << nl << "self->" << name << " = @\"\";";
+ }
+
+ EnumPtr en = EnumPtr::dynamicCast((*p)->type());
+ if(en)
+ {
+ string firstEnum = fixName(en->getEnumerators().front());
+ _M << nl << "self->" << name << " = " << firstEnum << ';';
+ }
+
+ StructPtr st = StructPtr::dynamicCast((*p)->type());
+ if(st)
+ {
+ _M << nl << "self->" << name << " = [[" << typeToString(st) << " alloc] init];";
+ }
+ }
}
}
@@ -1871,11 +1917,11 @@ Slice::Gen::TypesVisitor::writeOptionalDataMemberSelectors(const DataMemberList&
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- if(!(*q)->optional())
- {
+ if(!(*q)->optional())
+ {
continue;
}
-
+
TypePtr type = (*q)->type();
string typeString = inTypeToString(type, false);
@@ -2053,7 +2099,7 @@ Slice::Gen::TypesVisitor::writeMemberDealloc(const DataMemberList& dataMembers,
}
void
-Slice::Gen::TypesVisitor::writeMemberMarshal(const DataMemberList& dataMembers, const DataMemberList& optionalMembers,
+Slice::Gen::TypesVisitor::writeMemberMarshal(const DataMemberList& dataMembers, const DataMemberList& optionalMembers,
int baseType) const
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -2230,12 +2276,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Proxy helper
- //
+ //
{
string name = moduleName(findModule(p)) + p->name() + "PrxHelper";
_H << sp << nl << _dllExport << "@interface " << name << " : ICEProxyHelper";
_H << nl << "@end";
-
+
_M << sp << nl << "@implementation " << name;
_M << nl << "+(id) readRetained:(id<ICEInputStream>)stream";
_M << sb;
@@ -2257,7 +2303,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_H << sp << nl << _dllExport << "@interface " << name << " : ICEObjectHelper";
_H << nl << "@end";
-
+
_M << sp << nl << "@implementation " << name;
_M << nl << "+(void) readRetained:(ICEObject*ICE_STRONG_QUALIFIER*)obj stream:(id<ICEInputStream>)stream";
_M << sb;
@@ -2416,7 +2462,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
{
_H << sp << nl << _dllExport << "@interface " << name << " : ICEObjectDictionaryHelper";
_H << nl << "@end";
-
+
_M << sp << nl << "@implementation " << name;
_M << nl << "+(id) readRetained:(id<ICEInputStream>)stream";
_M << sb;
@@ -2549,7 +2595,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
_H << sp << nl << _dllExport << "@interface " << name << "Prx : ICEObjectPrx <" << name << "Prx>";
_H << nl << "+(NSString *) ice_staticId;";
-
+
_M << sp << nl << "@implementation " << name << "Prx";
for(r = ops.begin(); r != ops.end(); ++r)
{
@@ -2612,7 +2658,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_M << ";";
}
- }
+ }
string marshal;
string marshalArgs = getMarshalArgs(*r);
@@ -2647,13 +2693,13 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
_M << (unmarshalArgs.empty() ? ":is_" : " is:is_") << " ok:ok_]; };";
unmarshal = "unmarshal_";
}
- else
+ else
{
unmarshal = "nil";
}
_M << nl << "[self invoke__:@\"" << (*r)->name() << "\" mode:" << sliceModeToIceMode((*r)->sendMode())
- << " format:" << opFormatTypeToString(*r) << " marshal:" << marshal
+ << " format:" << opFormatTypeToString(*r) << " marshal:" << marshal
<< " unmarshal:" << unmarshal << " context:ctx_];";
if(returnType)
{
@@ -2669,7 +2715,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
_M << nl << "return [self begin_" << (*r)->name() << marshalArgs;
_M << (marshalArgs.empty() ? "" : " context") << ":nil];";
_M << eb;
-
+
//
// Write begin_ version with context.
//
@@ -2682,7 +2728,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
_M << "{ [" << className << "Prx " << (*r)->name() << "_marshal___" << marshalArgs;
_M << (marshalArgs.empty() ? "" : " os") << ":os_]; };";
}
- _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
+ _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
<< sliceModeToIceMode((*r)->sendMode()) << " format:" << opFormatTypeToString(*r)
<< " marshal:" << marshal
<< " returnsData:" << ((*r)->returnsData() ? "YES" : "NO")
@@ -2691,7 +2737,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Write end_ operation
- //
+ //
_M << sp << nl << "-(" << retString << ") end_" << (*r)->name() << unmarshalParams;
if(!unmarshalParams.empty())
{
@@ -2710,7 +2756,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_M << ";";
}
- }
+ }
if((*r)->returnsData())
{
_M << nl << "ICEUnmarshalCB unmarshal_ = ^(id<ICEInputStream> is_, BOOL ok_) ";
@@ -2842,21 +2888,21 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
_M << eb << ";";
if(returnType || !outParams.empty())
{
- _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
+ _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
<< sliceModeToIceMode((*r)->sendMode()) << " format:" << opFormatTypeToString(*r)
- << " marshal:" << marshal
+ << " marshal:" << marshal
<< " completed:completed_ response:(response_ != nil) exception:exception_ sent:sent_ context:ctx_];";
}
else
{
- _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
+ _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
<< sliceModeToIceMode((*r)->sendMode()) << " format:" << opFormatTypeToString(*r)
<< " marshal:" << marshal << " completed:completed_ response:YES exception:exception_ sent:sent_ context:ctx_];";
}
}
else
{
- _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
+ _M << nl << "return [self begin_invoke__:@\"" << (*r)->name() << "\" mode:"
<< sliceModeToIceMode((*r)->sendMode()) << " format:" << opFormatTypeToString(*r)
<< " marshal:" << marshal << " response:response_ exception:exception_ sent:sent_ context:ctx_];";
}
@@ -2917,7 +2963,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
_H << " os";
}
_H << ":(id<ICEOutputStream>)os_;";
-
+
_M << sp << nl << "+(void) " << p->name() << "_marshal___" << marshalParams;
if(!marshalParams.empty())
{
@@ -3018,7 +3064,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
_M << nl << "[is_ endEncapsulation];";
_M << eb;
}
-
+
if(returnType)
{
_M << nl << "return ret_;";
@@ -3026,4 +3072,3 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
_M << eb;
}
}
-
diff --git a/cpp/src/slice2objc/Gen.h b/cpp/src/slice2objc/Gen.h
index 4cff82707d5..70a42ad37f7 100644
--- a/cpp/src/slice2objc/Gen.h
+++ b/cpp/src/slice2objc/Gen.h
@@ -131,17 +131,18 @@ private:
enum ContainerType { LocalException, Other };
void writeConstantValue(IceUtilInternal::Output&, const TypePtr&, const std::string&) const;
- void writeInit(const ContainedPtr&, const DataMemberList&, const DataMemberList&, const DataMemberList&, bool,
+ void writeInit(const ContainedPtr&, const DataMemberList&, const DataMemberList&, const DataMemberList&, bool,
int, ContainerType) const;
void writeFactory(const ContainedPtr&, const DataMemberList&, int, ContainerType) const;
void writeCopyWithZone(const ContainedPtr&, const DataMemberList&, int, ContainerType) const;
void writeMembers(const DataMemberList&, int) const;
void writeMemberSignature(const DataMemberList&, int, ContainerType) const;
void writeMemberCall(const DataMemberList&, int, ContainerType, Escape) const;
+ bool requiresMemberInit(const DataMemberList&) const;
void writeMemberDefaultValueInit(const DataMemberList&, int) const;
void writeMemberInit(const DataMemberList&, int) const;
void writeProperties(const DataMemberList&, int) const;
- void writeSynthesize(const DataMemberList&, int) const;
+ void writeSynthesize(const DataMemberList&, int) const;
void writeOptionalDataMemberSelectors(const DataMemberList&, int) const;
void writeMemberHashCode(const DataMemberList&, int) const;
void writeMemberEquals(const DataMemberList&, int) const;
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 6c7d5789b56..bb992c77a96 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -84,7 +84,7 @@ private:
//
// Write a default value for a given type.
//
- void writeDefaultValue(const TypePtr&);
+ void writeDefaultValue(const DataMemberPtr&);
struct MemberInfo
{
@@ -950,7 +950,7 @@ CodeVisitor::visitEnum(const EnumPtr& p)
_out << sb;
_out << nl << "class " << name;
_out << sb;
-
+
{
long i = 0;
for(EnumeratorList::iterator q = enums.begin(); q != enums.end(); ++q, ++i)
@@ -1129,8 +1129,9 @@ CodeVisitor::writeType(const TypePtr& p)
}
void
-CodeVisitor::writeDefaultValue(const TypePtr& p)
+CodeVisitor::writeDefaultValue(const DataMemberPtr& m)
{
+ TypePtr p = m->type();
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
@@ -1187,8 +1188,7 @@ CodeVisitor::writeDefaultValue(const TypePtr& p)
// Instead we use null as the default value and allocate an instance in
// the constructor.
//
- StructPtr st = StructPtr::dynamicCast(p);
- if(st)
+ if(StructPtr::dynamicCast(p))
{
_out << "null";
return;
@@ -1392,7 +1392,7 @@ CodeVisitor::writeConstructorParams(const MemberInfoList& members)
}
else
{
- writeDefaultValue(member->type());
+ writeDefaultValue(member);
}
}
}
@@ -1573,7 +1573,7 @@ static void
usage(const char* n)
{
getErrorStream() << "Usage: " << n << " [options] slice-files...\n";
- getErrorStream() <<
+ getErrorStream() <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
@@ -1611,7 +1611,7 @@ compile(int argc, char* argv[])
opts.addOpt("", "all");
opts.addOpt("", "checksum");
opts.addOpt("n", "namespace");
-
+
vector<string> args;
try
{
diff --git a/cs/src/Ice/Incoming.cs b/cs/src/Ice/Incoming.cs
index 08372370c53..b8f1ca2d9e1 100644
--- a/cs/src/Ice/Incoming.cs
+++ b/cs/src/Ice/Incoming.cs
@@ -17,7 +17,7 @@ namespace IceInternal
public class IncomingBase
{
- protected internal IncomingBase(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
+ protected internal IncomingBase(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
Ice.ObjectAdapter adapter, bool response, byte compress, int requestId)
{
instance_ = instance;
@@ -102,17 +102,17 @@ namespace IceInternal
os_.writeByte((byte)0);
os_.startWriteEncaps(current_.encoding, format);
}
-
+
//
// We still return the stream even if no response is expected. The
// servant code might still write some out parameters if for
// example a method with out parameters somehow and erroneously
- // invoked as oneway (or if the invocation is invoked on a
+ // invoked as oneway (or if the invocation is invoked on a
// blobject and the blobject erroneously writes a response).
//
return os_;
}
-
+
public void endWriteParams__(bool ok)
{
if(!ok && observer_ != null)
@@ -129,7 +129,7 @@ namespace IceInternal
os_.endWriteEncaps();
}
}
-
+
public void writeEmptyParams__()
{
if(response_)
@@ -139,7 +139,7 @@ namespace IceInternal
os_.writeEmptyEncaps(current_.encoding);
}
}
-
+
public void writeParamEncaps__(byte[] v, bool ok)
{
if(!ok && observer_ != null)
@@ -168,11 +168,11 @@ namespace IceInternal
os__.writeUserException(ex);
endWriteParams__(false);
}
-
+
//
// These functions allow this object to be reused, rather than reallocated.
//
- public virtual void reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
+ public virtual void reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
Ice.ObjectAdapter adapter, bool response, byte compress, int requestId)
{
instance_ = instance;
@@ -262,7 +262,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.userException();
- }
+ }
//
// The operation may have already marshaled a reply; we must overwrite that reply.
@@ -309,12 +309,12 @@ namespace IceInternal
}
catch(Ice.RequestFailedException ex)
{
- if(ex.id == null)
+ if(ex.id == null || ex.id.name == null || ex.id.name.Length == 0)
{
ex.id = current_.id;
}
- if(ex.facet == null)
+ if(ex.facet == null || ex.facet.Length == 0)
{
ex.facet = current_.facet;
}
@@ -332,7 +332,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.ice_name());
- }
+ }
if(response_)
{
@@ -391,7 +391,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.ice_name());
- }
+ }
if(response_)
{
@@ -419,7 +419,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.ice_name());
- }
+ }
if(response_)
{
@@ -447,7 +447,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.ice_name());
- }
+ }
if(response_)
{
@@ -475,7 +475,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.ice_name());
- }
+ }
if(response_)
{
@@ -511,7 +511,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.ice_name());
- }
+ }
if(response_)
{
@@ -539,7 +539,7 @@ namespace IceInternal
if(observer_ != null)
{
observer_.failed(ex.GetType().FullName);
- }
+ }
if(response_)
{
@@ -595,7 +595,7 @@ namespace IceInternal
if(response)
{
os_.writeBlob(IceInternal.Protocol.replyHdr);
-
+
//
// Add the request ID.
//
@@ -612,7 +612,7 @@ namespace IceInternal
//
// These functions allow this object to be reused, rather than reallocated.
//
- public override void reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
+ public override void reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
Ice.ObjectAdapter adapter, bool response, byte compress, int requestId)
{
_cb = null;
@@ -626,7 +626,7 @@ namespace IceInternal
if(response)
{
os_.writeBlob(IceInternal.Protocol.replyHdr);
-
+
//
// Add the request ID.
//
@@ -687,7 +687,7 @@ namespace IceInternal
// Read the encapsulation size.
int size = _is.readInt();
_is.pos(_is.pos() - 4);
-
+
observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size);
if(observer_ != null)
{
@@ -721,7 +721,7 @@ namespace IceInternal
catch(Ice.UserException ex)
{
Ice.EncodingVersion encoding = _is.skipEncaps(); // Required for batch requests.
-
+
if(observer_ != null)
{
observer_.userException();
@@ -789,7 +789,7 @@ namespace IceInternal
// Skip the input parameters, this is required for reading
// the next batch request if dispatching batch requests.
//
- _is.skipEncaps();
+ _is.skipEncaps();
if(servantManager != null && servantManager.hasServant(current_.id))
{
@@ -904,7 +904,7 @@ namespace IceInternal
current_.encoding = _is.startReadEncaps();
return _is;
}
-
+
public void endReadParams()
{
_is.endReadEncaps();
diff --git a/cs/src/IcePatch2/Makefile b/cs/src/IcePatch2/Makefile
index 590463356b9..4b64dab84df 100644
--- a/cs/src/IcePatch2/Makefile
+++ b/cs/src/IcePatch2/Makefile
@@ -24,7 +24,7 @@ GDIR = generated
include $(top_srcdir)/config/Make.rules.cs
-MCSFLAGS := $(MCSFLAGS) -target:library -out:$(TARGETS)
+MCSFLAGS := $(MCSFLAGS) -target:library -out:$(TARGETS) -warnaserror-
MCSFLAGS := $(MCSFLAGS) -keyfile:$(KEYFILE)
MCSFLAGS := $(MCSFLAGS) /doc:$(assembliesdir)/$(PKG).xml /nowarn:1591
diff --git a/cs/test/Ice/defaultValue/AllTests.cs b/cs/test/Ice/defaultValue/AllTests.cs
index 81a9ea69ea2..dffe175a540 100644
--- a/cs/test/Ice/defaultValue/AllTests.cs
+++ b/cs/test/Ice/defaultValue/AllTests.cs
@@ -50,7 +50,7 @@ public class AllTests : TestCommon.TestApp
test(v.nc1 == Test.Nested.Color.red);
test(v.nc2 == Test.Nested.Color.green);
test(v.nc3 == Test.Nested.Color.blue);
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -148,7 +148,7 @@ public class AllTests : TestCommon.TestApp
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007"));
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -174,7 +174,7 @@ public class AllTests : TestCommon.TestApp
test(v.nc1 == Test.Nested.Color.red);
test(v.nc2 == Test.Nested.Color.green);
test(v.nc3 == Test.Nested.Color.blue);
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -194,7 +194,7 @@ public class AllTests : TestCommon.TestApp
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007");
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -214,7 +214,7 @@ public class AllTests : TestCommon.TestApp
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007");
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.c1 == Test.Color.red);
test(v.c2 == Test.Color.green);
test(v.c3 == Test.Color.blue);
@@ -240,7 +240,7 @@ public class AllTests : TestCommon.TestApp
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str.Equals("foo bar"));
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -278,7 +278,7 @@ public class AllTests : TestCommon.TestApp
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str.Equals("foo bar"));
- test(v.noDefault == null);
+ test(v.noDefault.Equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -288,5 +288,42 @@ public class AllTests : TestCommon.TestApp
}
WriteLine("ok");
+
+ Write("testing default constructor... ");
+ Flush();
+ {
+ Test.StructNoDefaults v = new Test.StructNoDefaults();
+ test(v.bo == false);
+ test(v.b == 0);
+ test(v.s == 0);
+ test(v.i == 0);
+ test(v.l == 0);
+ test(v.f == 0.0);
+ test(v.d == 0.0);
+ test(v.str.Equals(""));
+ test(v.c1 == Test.Color.red);
+ test(v.bs == null);
+ test(v.iseq == null);
+ test(v.st.a == 0);
+ test(v.st2 != null);
+ test(v.dict == null);
+
+ Test.ExceptionNoDefaults e = new Test.ExceptionNoDefaults();
+ test(e.str.Equals(""));
+ test(e.c1 == Test.Color.red);
+ test(e.bs == null);
+ test(e.st.a == 0);
+ test(e.st2 != null);
+ test(e.dict == null);
+
+ Test.ClassNoDefaults cl = new Test.ClassNoDefaults();
+ test(cl.str.Equals(""));
+ test(cl.c1 == Test.Color.red);
+ test(cl.bs == null);
+ test(cl.st.a == 0);
+ test(cl.st2 != null);
+ test(cl.dict == null);
+ }
+ WriteLine("ok");
}
}
diff --git a/cs/test/Ice/defaultValue/Test.ice b/cs/test/Ice/defaultValue/Test.ice
index f8d5f82a4b1..2f89d136102 100644
--- a/cs/test/Ice/defaultValue/Test.ice
+++ b/cs/test/Ice/defaultValue/Test.ice
@@ -183,7 +183,7 @@ class Derived extends Base
Color c1 = ::Test::red;
Color c2 = Test::green;
Color c3 = blue;
-
+
Nested::Color nc1 = ::Test::Nested::red;
Nested::Color nc2 = Nested::green;
Nested::Color nc3 = Nested::blue;
@@ -214,7 +214,7 @@ exception DerivedEx extends BaseEx
Color c1 = ConstColor1;
Color c2 = ConstColor2;
Color c3 = ConstColor3;
-
+
Nested::Color nc1 = ConstNestedColor1;
Nested::Color nc2 = ConstNestedColor2;
Nested::Color nc3 = ConstNestedColor3;
@@ -289,4 +289,64 @@ exception ExceptionProperty
double zeroDotD = 0;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct InnerStruct2
+{
+ string a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq iseq;
+ InnerStruct st;
+ InnerStruct2 st2;
+ IntStringDict dict;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ InnerStruct2 st2;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ InnerStruct2 st2;
+ IntStringDict dict;
+};
+
};
diff --git a/java/src/Ice/src/main/java/IceInternal/IncomingBase.java b/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
index 5a537ccb248..0ce16f152ec 100644
--- a/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
+++ b/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
@@ -325,12 +325,12 @@ class IncomingBase
}
catch(Ice.RequestFailedException ex)
{
- if(ex.id == null)
+ if(ex.id == null || ex.id.name == null || ex.id.name.isEmpty())
{
ex.id = _current.id;
}
- if(ex.facet == null)
+ if(ex.facet == null || ex.facet.isEmpty())
{
ex.facet = _current.facet;
}
diff --git a/java/test/src/main/java/test/Ice/defaultValue/AllTests.java b/java/test/src/main/java/test/Ice/defaultValue/AllTests.java
index 0e2ac7fd606..4541cf21009 100644
--- a/java/test/src/main/java/test/Ice/defaultValue/AllTests.java
+++ b/java/test/src/main/java/test/Ice/defaultValue/AllTests.java
@@ -46,7 +46,7 @@ public class AllTests
test(v.nc1 == test.Ice.defaultValue.Test.Nested.Color.red);
test(v.nc2 == test.Ice.defaultValue.Test.Nested.Color.green);
test(v.nc3 == test.Ice.defaultValue.Test.Nested.Color.blue);
- test(v.noDefault == null);
+ test(v.noDefault.equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -84,7 +84,7 @@ public class AllTests
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str.equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \007 \u0007"));
- test(v.noDefault == null);
+ test(v.noDefault.equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -110,7 +110,7 @@ public class AllTests
test(v.nc1 == test.Ice.defaultValue.Test.Nested.Color.red);
test(v.nc2 == test.Ice.defaultValue.Test.Nested.Color.green);
test(v.nc3 == test.Ice.defaultValue.Test.Nested.Color.blue);
- test(v.noDefault == null);
+ test(v.noDefault.equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -130,7 +130,7 @@ public class AllTests
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \007 \u0007");
- test(v.noDefault == null);
+ test(v.noDefault.equals(""));
test(v.zeroI == 0);
test(v.zeroL == 0);
test(v.zeroF == 0);
@@ -150,7 +150,7 @@ public class AllTests
test(v.f == 5.1F);
test(v.d == 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \007 \u0007");
- test(v.noDefault == null);
+ test(v.noDefault.equals(""));
test(v.c1 == Color.red);
test(v.c2 == Color.green);
test(v.c3 == Color.blue);
@@ -166,5 +166,40 @@ public class AllTests
}
out.println("ok");
+
+ out.write("testing default constructor... ");
+ out.flush();
+ {
+ test.Ice.defaultValue.Test.StructNoDefaults v = new test.Ice.defaultValue.Test.StructNoDefaults();
+ test(v.bo == false);
+ test(v.b == 0);
+ test(v.s == 0);
+ test(v.i == 0);
+ test(v.l == 0);
+ test(v.f == 0.0);
+ test(v.d == 0.0);
+ test(v.str.equals(""));
+ test(v.c1 == test.Ice.defaultValue.Test.Color.red);
+ test(v.bs == null);
+ test(v.is == null);
+ test(v.st != null);
+ test(v.dict == null);
+
+ test.Ice.defaultValue.Test.ExceptionNoDefaults e = new test.Ice.defaultValue.Test.ExceptionNoDefaults();
+ test(e.str.equals(""));
+ test(e.c1 == test.Ice.defaultValue.Test.Color.red);
+ test(e.bs == null);
+ test(e.st != null);
+ test(e.dict == null);
+
+ test.Ice.defaultValue.Test.ClassNoDefaults cl = new test.Ice.defaultValue.Test.ClassNoDefaults();
+ test(cl.str.equals(""));
+ test(cl.c1 == test.Ice.defaultValue.Test.Color.red);
+ test(cl.bs == null);
+ test(cl.st != null);
+ test(cl.dict == null);
+ }
+
+ out.println("ok");
}
}
diff --git a/java/test/src/main/java/test/Ice/defaultValue/Test.ice b/java/test/src/main/java/test/Ice/defaultValue/Test.ice
index f3b38bd08b2..1978cf9c9e1 100644
--- a/java/test/src/main/java/test/Ice/defaultValue/Test.ice
+++ b/java/test/src/main/java/test/Ice/defaultValue/Test.ice
@@ -153,4 +153,56 @@ exception DerivedEx extends BaseEx
Nested::Color nc3 = ConstNestedColor3;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq is;
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};
diff --git a/js/test/Ice/defaultValue/Client.js b/js/test/Ice/defaultValue/Client.js
index 02c43fd827e..9721990229a 100644
--- a/js/test/Ice/defaultValue/Client.js
+++ b/js/test/Ice/defaultValue/Client.js
@@ -31,7 +31,7 @@
}
}
};
-
+
Promise.try(
function()
{
@@ -52,14 +52,14 @@
test(v.nc1 === Test.Nested.Color.red);
test(v.nc2 === Test.Nested.Color.green);
test(v.nc3 === Test.Nested.Color.blue);
- test(v.noDefault === null);
+ test(v.noDefault === "");
test(v.zeroI === 0);
test(v.zeroL.equals(new Ice.Long(0, 0)));
test(v.zeroF === 0);
test(v.zeroDotF === 0);
test(v.zeroD === 0);
test(v.zeroDotD === 0);
-
+
v = new Test.Struct2();
test(v.boolTrue === Test.ConstBool);
test(v.b === Test.ConstByte);
@@ -75,7 +75,7 @@
test(v.nc1 === Test.ConstNestedColor1);
test(v.nc2 === Test.ConstNestedColor2);
test(v.nc3 === Test.ConstNestedColor3);
-
+
v = new Test.Base();
test(!v.boolFalse);
test(v.boolTrue);
@@ -86,14 +86,14 @@
test(v.f === 5.1);
test(v.d === 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
- test(v.noDefault === null);
+ test(v.noDefault === "");
test(v.zeroI === 0);
test(v.zeroL.equals(new Ice.Long(0, 0)));
test(v.zeroF === 0);
test(v.zeroDotF === 0);
test(v.zeroD === 0);
test(v.zeroDotD === 0);
-
+
v = new Test.Derived();
test(!v.boolFalse);
test(v.boolTrue);
@@ -110,14 +110,14 @@
test(v.nc1 === Test.Nested.Color.red);
test(v.nc2 === Test.Nested.Color.green);
test(v.nc3 === Test.Nested.Color.blue);
- test(v.noDefault === null);
+ test(v.noDefault === "");
test(v.zeroI === 0);
test(v.zeroL.equals(new Ice.Long(0, 0)));
test(v.zeroF === 0);
test(v.zeroDotF === 0);
test(v.zeroD === 0);
test(v.zeroDotD === 0);
-
+
v = new Test.BaseEx();
test(!v.boolFalse);
test(v.boolTrue);
@@ -128,14 +128,14 @@
test(v.f === 5.1);
test(v.d === 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
- test(v.noDefault === null);
+ test(v.noDefault === "");
test(v.zeroI === 0);
test(v.zeroL.equals(new Ice.Long(0, 0)));
test(v.zeroF === 0);
test(v.zeroDotF === 0);
test(v.zeroD === 0);
test(v.zeroDotD === 0);
-
+
v = new Test.DerivedEx();
test(!v.boolFalse);
test(v.boolTrue);
@@ -146,7 +146,7 @@
test(v.f === 5.1);
test(v.d === 6.2);
test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
- test(v.noDefault === null);
+ test(v.noDefault === "");
test(v.c1 === Test.Color.red);
test(v.c2 === Test.Color.green);
test(v.c3 === Test.Color.blue);
@@ -159,7 +159,41 @@
test(v.zeroDotF === 0);
test(v.zeroD === 0);
test(v.zeroDotD === 0);
-
+
+ out.writeLine("ok");
+
+
+ out.write("testing default constructor... ");
+
+ var v2 = new Test.StructNoDefaults();
+ test(v2.bo == false);
+ test(v2.b == 0);
+ test(v2.s == 0);
+ test(v2.i == 0);
+ test(v2.l == 0);
+ test(v2.f == 0.0);
+ test(v2.d == 0.0);
+ test(v2.str == "");
+ test(v2.c1 == Test.Color.red);
+ test(v2.bs == null);
+ test(v2.is == null);
+ test(v2.st != null && v2.st instanceof Test.InnerStruct);
+ test(v2.dict == null);
+
+ var e = new Test.ExceptionNoDefaults();
+ test(e.str == "");
+ test(e.c1 == Test.Color.red);
+ test(e.bs == null);
+ test(e.st != null && e.st instanceof Test.InnerStruct);
+ test(e.dict == null);
+
+ var cl = new Test.ClassNoDefaults();
+ test(cl.str == "");
+ test(cl.c1 == Test.Color.red);
+ test(cl.bs == null);
+ test(cl.st != null && cl.st instanceof Test.InnerStruct);
+ test(cl.dict == null);
+
out.writeLine("ok");
}
).then(
diff --git a/js/test/Ice/defaultValue/Test.ice b/js/test/Ice/defaultValue/Test.ice
index d4247ed5115..08b525e16c6 100644
--- a/js/test/Ice/defaultValue/Test.ice
+++ b/js/test/Ice/defaultValue/Test.ice
@@ -179,4 +179,56 @@ exception DerivedEx extends BaseEx
Nested::Color nc3 = ConstNestedColor3;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq is;
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};
diff --git a/objc/test/Ice/defaultValue/AllTests.m b/objc/test/Ice/defaultValue/AllTests.m
index 2cd9dcd2dc3..31be19f650b 100644
--- a/objc/test/Ice/defaultValue/AllTests.m
+++ b/objc/test/Ice/defaultValue/AllTests.m
@@ -107,4 +107,38 @@ defaultValueAllTests()
}
tprintf("ok\n");
+
+ tprintf("testing default constructor... ");
+
+ {
+ TestDefaultValueStructNoDefaults* v = [TestDefaultValueStructNoDefaults structNoDefaults];
+ test(v.bo == NO);
+ test(v.b == 0);
+ test(v.s == 0);
+ test(v.i == 0);
+ test(v.l == 0);
+ test(v.f == 0.0);
+ test(v.d == 0.0);
+ test([v.str isEqual:@""]);
+ test(v.c1 == TestDefaultValuered);
+ test(v.bs == nil);
+ test(v.is == nil);
+ test(v.st != nil);
+ test(v.dict == nil);
+
+ TestDefaultValueExceptionNoDefaults* e = [TestDefaultValueExceptionNoDefaults exceptionNoDefaults];
+ test([e.str isEqual:@""]);
+ test(e.c1 == TestDefaultValuered);
+ test(e.bs == nil);
+ test(e.st != nil);
+ test(e.dict == nil);
+
+ TestDefaultValueClassNoDefaults* cl = [TestDefaultValueClassNoDefaults classNoDefaults];
+ test([cl.str isEqual:@""]);
+ test(cl.c1 == TestDefaultValuered);
+ test(cl.bs == nil);
+ test(cl.st != nil);
+ test(cl.dict == nil);
+ }
+ tprintf("ok\n");
}
diff --git a/objc/test/Ice/defaultValue/DefaultValueTest.ice b/objc/test/Ice/defaultValue/DefaultValueTest.ice
index be7de5abc0f..876b763a393 100644
--- a/objc/test/Ice/defaultValue/DefaultValueTest.ice
+++ b/objc/test/Ice/defaultValue/DefaultValueTest.ice
@@ -84,4 +84,56 @@ exception DerivedEx extends BaseEx
Color c = green;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq is;
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};
diff --git a/php/test/Ice/defaultValue/Client.php b/php/test/Ice/defaultValue/Client.php
index eda45edfdeb..b3e9dd7117d 100644
--- a/php/test/Ice/defaultValue/Client.php
+++ b/php/test/Ice/defaultValue/Client.php
@@ -186,6 +186,41 @@ function allTests()
test($v->zeroDotD == 0);
}
echo "ok\n";
+
+ echo "testing default constructor... ";
+ flush();
+ {
+ $v = $NS ? eval("return new Test\\StructNoDefaults;") : eval("return new Test_StructNoDefaults;");
+ $innerStructClass = $NS ? "Test\\InnerStruct" : "Test_InnerStruct";
+ test($v->bo == false);
+ test($v->b == 0);
+ test($v->s == 0);
+ test($v->i == 0);
+ test($v->l == 0);
+ test($v->f == 0.0);
+ test($v->d == 0.0);
+ test($v->str == "");
+ test($v->c1 == $red);
+ test($v->bs == null);
+ test($v->is == null);
+ test($v->dict == null);
+ test($v->st instanceof $innerStructClass);
+
+ $e = $NS ? eval("return new Test\\ExceptionNoDefaults;") : eval("return new Test_ExceptionNoDefaults;");
+ test($e->str == '');
+ test($e->c1 == $red);
+ test($e->bs == null);
+ test($e->st instanceof $innerStructClass);
+ test($e->dict == null);
+
+ $cl = $NS ? eval("return new Test\\ClassNoDefaults;") : eval("return new Test_ClassNoDefaults;");
+ test($cl->str == '');
+ test($cl->c1 == $red);
+ test($cl->bs == null);
+ test($cl->st instanceof $innerStructClass);
+ test($cl->dict == null);
+ }
+ echo "ok\n";
}
allTests();
diff --git a/php/test/Ice/defaultValue/Test.ice b/php/test/Ice/defaultValue/Test.ice
index 37a2f642df2..d9e7f669134 100644
--- a/php/test/Ice/defaultValue/Test.ice
+++ b/php/test/Ice/defaultValue/Test.ice
@@ -152,4 +152,56 @@ exception DerivedEx extends BaseEx
Nested::Color nc3 = ConstNestedColor3;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq is;
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};
diff --git a/py/test/Ice/defaultValue/AllTests.py b/py/test/Ice/defaultValue/AllTests.py
index af38110db4a..bc529c4b90e 100644
--- a/py/test/Ice/defaultValue/AllTests.py
+++ b/py/test/Ice/defaultValue/AllTests.py
@@ -41,7 +41,7 @@ def allTests():
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test.Struct2()
test(v.boolTrue == Test.ConstBool)
test(v.b == Test.ConstByte)
@@ -63,7 +63,7 @@ def allTests():
test(v.zeroDotF == Test.ConstZeroDotF)
test(v.zeroD == Test.ConstZeroD)
test(v.zeroDotD == Test.ConstZeroDotD)
-
+
v = Test.Base()
test(not v.boolFalse)
test(v.boolTrue)
@@ -81,7 +81,7 @@ def allTests():
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test.Derived()
test(not v.boolFalse)
test(v.boolTrue)
@@ -149,3 +149,36 @@ def allTests():
test(v.zeroDotD == 0)
print("ok")
+
+ sys.stdout.write("testing default constructor... ")
+ sys.stdout.flush()
+ v = Test.StructNoDefaults()
+ test(v.bo == False)
+ test(v.b == 0)
+ test(v.s == 0)
+ test(v.i == 0)
+ test(v.l == 0)
+ test(v.f == 0.0)
+ test(v.d == 0.0)
+ test(v.str == '')
+ test(v.c1 == Test.Color.red)
+ test(v.bs is None)
+ test(v.iseq is None)
+ test(isinstance(v.st, Test.InnerStruct));
+ test(v.dict is None);
+
+ e = Test.ExceptionNoDefaults()
+ test(e.str == '')
+ test(e.c1 == Test.Color.red)
+ test(e.bs is None)
+ test(isinstance(e.st, Test.InnerStruct));
+ test(e.dict is None);
+
+ c = Test.ClassNoDefaults()
+ test(c.str == '')
+ test(c.c1 == Test.Color.red)
+ test(c.bs is None)
+ test(isinstance(c.st, Test.InnerStruct));
+ test(c.dict is None);
+
+ print("ok")
diff --git a/py/test/Ice/defaultValue/Test.ice b/py/test/Ice/defaultValue/Test.ice
index 49126d9265a..101a42883f3 100644
--- a/py/test/Ice/defaultValue/Test.ice
+++ b/py/test/Ice/defaultValue/Test.ice
@@ -21,6 +21,7 @@ enum Color { red, green, blue };
};
+
struct Struct1
{
bool boolFalse = false;
@@ -77,7 +78,7 @@ struct Struct2
long l = ConstLong;
float f = ConstFloat;
double d = ConstDouble;
- string str = ConstString;
+ string str = ConstString;
Color c1 = ConstColor1;
Color c2 = ConstColor2;
Color c3 = ConstColor3;
@@ -152,4 +153,56 @@ exception DerivedEx extends BaseEx
Nested::Color nc3 = ConstNestedColor3;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq iseq;
+ IntStringDict dict;
+ InnerStruct st;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};
diff --git a/rb/test/Ice/defaultValue/AllTests.rb b/rb/test/Ice/defaultValue/AllTests.rb
index 49356180006..59f9de1d384 100644
--- a/rb/test/Ice/defaultValue/AllTests.rb
+++ b/rb/test/Ice/defaultValue/AllTests.rb
@@ -56,7 +56,7 @@ def allTests()
test(v.zeroDotF == Test::ConstZeroDotF)
test(v.zeroD == Test::ConstZeroD)
test(v.zeroDotD == Test::ConstZeroDotD)
-
+
v = Test::Base.new
test(!v.boolFalse)
test(v.boolTrue)
@@ -68,14 +68,13 @@ def allTests()
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\v\f\a\b? \007 \x07")
test(v.noDefault == '')
- test(v.noDefault == '')
test(v.zeroI == 0)
test(v.zeroL == 0)
test(v.zeroF == 0)
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test::Derived.new
test(!v.boolFalse)
test(v.boolTrue)
@@ -93,14 +92,13 @@ def allTests()
test(v.nc2 == Test::Nested::Color::Green)
test(v.nc3 == Test::Nested::Color::Blue)
test(v.noDefault == '')
- test(v.noDefault == '')
test(v.zeroI == 0)
test(v.zeroL == 0)
test(v.zeroF == 0)
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test::BaseEx.new
test(!v.boolFalse)
test(v.boolTrue)
@@ -112,14 +110,13 @@ def allTests()
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\v\f\a\b? \007 \x07")
test(v.noDefault == '')
- test(v.noDefault == '')
test(v.zeroI == 0)
test(v.zeroL == 0)
test(v.zeroF == 0)
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test::DerivedEx.new
test(!v.boolFalse)
test(v.boolTrue)
@@ -144,6 +141,41 @@ def allTests()
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
puts "ok"
+
+ print "testing default constructor... "
+ STDOUT.flush
+
+ v = Test::StructNoDefaults.new
+ test(v.bo == false)
+ test(v.b == 0)
+ test(v.s == 0)
+ test(v.i == 0)
+ test(v.l == 0)
+ test(v.f == 0.0)
+ test(v.d == 0.0)
+ test(v.str == '')
+ test(v.c1 == Test::Color::Red)
+ test(v.bs == nil)
+ test(v.is == nil)
+ test(v.st.instance_of?(Test::InnerStruct));
+ test(v.dict == nil);
+
+ e = Test::ExceptionNoDefaults.new
+ test(e.str == '')
+ test(e.c1 == Test::Color::Red)
+ test(e.bs == nil)
+ test(e.st.instance_of?(Test::InnerStruct));
+ test(e.dict == nil);
+
+ c = Test::ClassNoDefaults.new
+ test(c.str == '')
+ test(c.c1 == Test::Color::Red)
+ test(c.bs == nil)
+ test(c.st.instance_of?(Test::InnerStruct));
+ test(c.dict == nil);
+
+ puts("ok")
+
end
diff --git a/rb/test/Ice/defaultValue/Test.ice b/rb/test/Ice/defaultValue/Test.ice
index 0b8433acdf7..af768270ed7 100644
--- a/rb/test/Ice/defaultValue/Test.ice
+++ b/rb/test/Ice/defaultValue/Test.ice
@@ -152,4 +152,56 @@ exception DerivedEx extends BaseEx
Nested::Color nc3 = ConstNestedColor3;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq is;
+ IntStringDict dict;
+ InnerStruct st;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};