summaryrefslogtreecommitdiff
path: root/cpp/src/Slice
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 /cpp/src/Slice
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
Diffstat (limited to 'cpp/src/Slice')
-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
4 files changed, 177 insertions, 190 deletions
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);
}
}
}