diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 181 | ||||
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 33 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 259 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 11 |
4 files changed, 289 insertions, 195 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index eec8c8d26eb..4154018bc18 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -132,25 +132,25 @@ Slice::typeToString(const TypePtr& type) ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); if(cl) { - return cl->scoped() + "Ptr"; + return fixKwd(cl->scoped()) + "Ptr"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); if(proxy) { - return proxy->_class()->scoped() + "Prx"; + return fixKwd(proxy->_class()->scoped()) + "Prx"; } ContainedPtr contained = ContainedPtr::dynamicCast(type); if(contained) { - return contained->scoped(); + return fixKwd(contained->scoped()); } EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - return en->scoped(); + return fixKwd(en->scoped()); } return "???"; @@ -194,25 +194,25 @@ Slice::inputTypeToString(const TypePtr& type) ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); if(cl) { - return "const " + cl->scoped() + "Ptr&"; + return "const " + fixKwd(cl->scoped()) + "Ptr&"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); if(proxy) { - return "const " + proxy->_class()->scoped() + "Prx&"; + return "const " + fixKwd(proxy->_class()->scoped()) + "Prx&"; } EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - return en->scoped(); + return fixKwd(en->scoped()); } ContainedPtr contained = ContainedPtr::dynamicCast(type); if(contained) { - return "const " + contained->scoped() + "&"; + return "const " + fixKwd(contained->scoped()) + "&"; } return "???"; @@ -245,28 +245,116 @@ Slice::outputTypeToString(const TypePtr& type) ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); if(cl) { - return cl->scoped() + "Ptr&"; + return fixKwd(cl->scoped()) + "Ptr&"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); if(proxy) { - return proxy->_class()->scoped() + "Prx&"; + return fixKwd(proxy->_class()->scoped()) + "Prx&"; } ContainedPtr contained = ContainedPtr::dynamicCast(type); if(contained) { - return contained->scoped() + "&"; + return fixKwd(contained->scoped()) + "&"; } return "???"; } +// +// If the passed name is a keyword, return the name with a "_cxx_" prefix; +// otherwise, return the name unchanged. +// + +static string +lookupKwd(const string& name) +{ + // + // Keyword list. *Must* be kept in alphabetical order. + // + static const string keywordList[] = + { + "asm", "auto", "bool", "break", "case", "catch", "char", "class", "const", "const_cast", + "continue", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", + "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", + "mutable", "namespace", "new", "operator", "private", "protected", "public", "register", + "reinterpret_cast", "return", "short", "signed", "sizeof", "static", "static_cast", "struct", + "switch", "template", "this", "throw", "true", "try", "typedef", "typeid", "typename", "union", + "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while" + }; + bool found = binary_search(&keywordList[0], + &keywordList[sizeof(keywordList) / sizeof(*keywordList)], + name); + return found ? "_cpp_" + name : name; +} + +// +// Split a scoped name into its components and return the components as a list of (unscoped) identifiers. +// +static StringList +splitScopedName(const string& scoped) +{ + assert(scoped[0] == ':'); + StringList ids; + string::size_type next = 0; + string::size_type pos; + while((pos = scoped.find("::", next)) != string::npos) + { + pos += 2; + if(pos != scoped.size()) + { + string::size_type endpos = scoped.find("::", pos); + if (endpos != string::npos) + { + ids.push_back(scoped.substr(pos, endpos - pos)); + } + } + next = pos; + } + if(next != scoped.size()) + { + ids.push_back(scoped.substr(next)); + } + else + { + ids.push_back(""); + } + + return ids; +} + +// +// If the passed name is a scoped name, return the identical scoped name, +// but with all components that are C++ keywords replaced by +// their "_cxx_"-prefixed version; otherwise, if the passed name is +// not scoped, but a C++ keyword, return the "_cxx_"-prefixed name; +// otherwise, return the name unchanged. +// +string +Slice::fixKwd(const string& name) +{ + if(name[0] != ':') + { + return lookupKwd(name); + } + StringList ids = splitScopedName(name); + transform(ids.begin(), ids.end(), ids.begin(), ptr_fun(lookupKwd)); + stringstream result; + for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i) + { + result << "::" + *i; + } + return result.str(); +} + void Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal, const string& str, bool pointer) { + string fixedParam = fixKwd(param); + string stream; if(str.empty()) { @@ -306,17 +394,17 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& { if(marshal) { - out << nl << stream << deref << func << param << ");"; + out << nl << stream << deref << func << fixedParam << ");"; } else { - out << nl << stream << deref << func << "::Ice::Object::ice_staticId(), 0, " << param << ");"; + out << nl << stream << deref << func << "::Ice::Object::ice_staticId(), 0, " << fixedParam << ");"; } return; } else { - out << nl << stream << deref << func << param << ");"; + out << nl << stream << deref << func << fixedParam << ");"; return; } } @@ -327,7 +415,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& out << sb; if(marshal) { - out << nl << "::Ice::ObjectPtr " << obj << " = " << param << ';'; + out << nl << "::Ice::ObjectPtr " << obj << " = " << fixedParam << ';'; out << nl << stream << deref << func << obj << ");"; } else @@ -338,9 +426,9 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& string type; if(def && !def->isAbstract()) { - factory = cl->scoped(); + factory = fixKwd(cl->scoped()); factory += "::_factory"; - type = cl->scoped(); + type = fixKwd(cl->scoped()); type += "::ice_staticId()"; } else @@ -349,7 +437,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& type = "\"\""; } out << nl << stream << deref << func << type << ", " << factory << ", " << obj << ");"; - out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");"; + out << nl << fixedParam << " = " << fixKwd(cl->scoped()) << "Ptr::dynamicCast(" << obj << ");"; } out << eb; @@ -359,7 +447,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& StructPtr st = StructPtr::dynamicCast(type); if(st) { - out << nl << param << ".__" << func << (pointer ? "" : "&") << stream << ");"; + out << nl << fixedParam << ".__" << func << (pointer ? "" : "&") << stream << ");"; return; } @@ -369,12 +457,13 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); if(builtin && builtin->kind() != Builtin::KindObject && builtin->kind() != Builtin::KindObjectProxy) { - out << nl << stream << deref << func << param << ");"; + out << nl << stream << deref << func << fixedParam << ");"; } else { - out << nl << seq->scope() << "__" << func << (pointer ? "" : "&") << stream << ", " << param << ", " - << seq->scope() << "__U__" << seq->name() << "());"; + string scope = fixKwd(seq->scope()); + out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", " + << fixedParam << ", " << scope << "__U__" << seq->name() << "());"; } return; } @@ -382,8 +471,9 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& DictionaryPtr dict = DictionaryPtr::dynamicCast(type); if(dict) { - out << nl << dict->scope() << "__" << func << (pointer ? "" : "&") << stream << ", " << param << ", " - << dict->scope() << "__U__" << dict->name() << "());"; + string scope = fixKwd(dict->scope()); + out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", " + << fixedParam << ", " << scope << "__U__" << dict->name() << "());"; return; } @@ -395,7 +485,8 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& constructed = proxy->_class(); } - out << nl << constructed->scope() << "__" << func << (pointer ? "" : "&") << stream << ", " << param << ");"; + out << nl << fixKwd(constructed->scope()) << "__" << func << (pointer ? "" : "&") << stream << ", " + << fixedParam << ");"; } void @@ -435,7 +526,7 @@ Slice::writeAllocateCode(Output& out, const list<pair<TypePtr, string> >& params for(list<pair<TypePtr, string> >::const_iterator p = ps.begin(); p != ps.end(); ++p) { - out << nl << typeToString(p->first) << ' ' << p->second << ';'; + out << nl << typeToString(p->first) << ' ' << fixKwd(p->second) << ';'; } } @@ -499,6 +590,8 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const tagName = tn; } + string fixedParam = fixKwd(param); + string streamFunc = marshal ? "write" : "read"; string genFunc = marshal ? "ice_marshal(" : "ice_unmarshal("; @@ -510,11 +603,11 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const streamFunc += outputBuiltinTable[builtin->kind()]; if(marshal) { - out << nl << stream << deref << streamFunc << "(" << tagName << ", " << param << ");"; + out << nl << stream << deref << streamFunc << "(" << tagName << ", " << fixedParam << ");"; } else { - out << nl << param << " = " << stream << deref << streamFunc << "(" << tagName + out << nl << fixedParam << " = " << stream << deref << streamFunc << "(" << tagName << ", ::Ice::Object::ice_staticId(), 0);"; } return; @@ -524,11 +617,11 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const if(marshal) { out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] - << "(" << tagName << ", " << param << ");"; + << "(" << tagName << ", " << fixedParam << ");"; } else { - out << nl << param << " = " << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] + out << nl << fixedParam << " = " << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "(" << tagName << ");"; } return; @@ -541,7 +634,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const out << sb; if(marshal) { - out << nl << "::Ice::ObjectPtr " << obj << " = " << param << ';'; + out << nl << "::Ice::ObjectPtr " << obj << " = " << fixedParam << ';'; out << nl << stream << deref << streamFunc << "Object(" << tagName << ", " << obj << ");"; } else @@ -552,9 +645,9 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const string type; if(def && !def->isAbstract()) { - factory = cl->scoped(); + factory = fixKwd(cl->scoped()); factory += "::_factory"; - type = cl->scoped(); + type = fixKwd(cl->scoped()); type += "::ice_staticId()"; } else @@ -564,7 +657,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } out << nl << obj << " = " << stream << deref << streamFunc << "Object(" << tagName << ", " << type << ", " << factory << ");"; - out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");"; + out << nl << fixedParam << " = " << fixKwd(cl->scoped()) << "Ptr::dynamicCast(" << obj << ");"; } out << eb; @@ -574,7 +667,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const StructPtr st = StructPtr::dynamicCast(type); if(st) { - out << nl << param << "." << genFunc << tagName << ", " << (pointer ? "" : "&") << stream << ");"; + out << nl << fixedParam << "." << genFunc << tagName << ", " << (pointer ? "" : "&") << stream << ");"; return; } @@ -587,18 +680,19 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const if(marshal) { out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "Seq(" - << tagName << ", " << param << ");"; + << tagName << ", " << fixedParam << ");"; } else { - out << nl << param << " = " << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] + out << nl << fixedParam << " = " << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "Seq(" << tagName << ");"; } } else { - out << nl << seq->scope() << genFunc << tagName << ", " << (pointer ? "" : "&") << stream - << ", " << param << ", " << seq->scope() << "__U__" << seq->name() << "());"; + string scope = fixKwd(seq->scope()); + out << nl << scope << genFunc << tagName << ", " << (pointer ? "" : "&") << stream + << ", " << fixedParam << ", " << scope << "__U__" << seq->name() << "());"; } return; } @@ -606,8 +700,9 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const DictionaryPtr dict = DictionaryPtr::dynamicCast(type); if(dict) { - out << nl << dict->scope() << genFunc << tagName << ", " << (pointer ? "" : "&") << stream - << ", " << param << ", " << dict->scope() << "__U__" << dict->name() << "());"; + string scope = fixKwd(dict->scope()); + out << nl << scope << genFunc << tagName << ", " << (pointer ? "" : "&") << stream + << ", " << fixedParam << ", " << scope << "__U__" << dict->name() << "());"; return; } @@ -619,8 +714,8 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const constructed = proxy->_class(); } - out << nl << constructed->scope() << genFunc << tagName << ", " << (pointer ? "" : "&") << stream - << ", " << param << ");"; + out << nl << fixKwd(constructed->scope()) << genFunc << tagName << ", " << (pointer ? "" : "&") << stream + << ", " << fixedParam << ");"; } void diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 853379fd3ab..aa1ca23274b 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -152,9 +152,9 @@ string Slice::JavaGenerator::fixKwd(const string& name) const { // - // Alphabetical list of Java keywords + // Keyword list. *Must* be kept in alphabetical order. // - static const char* keywords[] = + static const string keywordList[] = { "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "clone", "const", "continue", "default", "do", @@ -166,31 +166,10 @@ Slice::JavaGenerator::fixKwd(const string& name) const "synchronized", "this", "throw", "throws", "toString", "transient", "true", "try", "void", "volatile", "wait", "while" }; - - int i = 0; - int j = sizeof(keywords) / sizeof(const char*); - - while(i < j) - { - int mid = (i + j) / 2; - string str = keywords[mid]; - int n = str.compare(name); - if(n == 0) - { - string result = "_" + name; - return result; - } - else if(n > 0) - { - j = mid; - } - else - { - i = mid + 1; - } - } - - return name; + bool found = binary_search(&keywordList[0], + &keywordList[sizeof(keywordList) / sizeof(*keywordList)], + name); + return found ? "_" + name : name; } string diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index b85d779b9cb..ec573668885 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -12,6 +12,7 @@ #include <Slice/CPlusPlusUtil.h> #include <Gen.h> #include <limits> +#include <iterator> #include <sys/stat.h> @@ -283,7 +284,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -305,8 +306,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr&) bool Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); ExceptionPtr base = p->base(); H << sp << nl << "class " << name << " : "; @@ -324,7 +325,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) } else { - H << "public " << base->scoped(); + H << "public " << fixKwd(base->scoped()); } H.restoreIndent(); H << sb; @@ -345,7 +346,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) } else { - C << nl << base->scoped() << "(file, line)"; + C << nl << fixKwd(base->scoped()) << "(file, line)"; } C.dec(); C << sb; @@ -355,7 +356,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << _dllExport << "virtual ::std::string ice_name() const;"; C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::ice_name() const"; C << sb; - C << nl << "static const ::std::string name(\"" << scoped.substr(2) << "\");"; + C << nl << "static const ::std::string name(\"" << p->scoped().substr(2) << "\");"; C << nl << "return name;"; C << eb; @@ -382,7 +383,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) StringList exceptionIds; transform(allBases.begin(), allBases.end(), back_inserter(exceptionIds), ::IceUtil::constMemFun(&Exception::scoped)); - exceptionIds.push_front(scoped); + exceptionIds.push_front(p->scoped()); exceptionIds.push_back("::Ice::UserException"); StringList::const_iterator q; @@ -417,8 +418,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { if(!p->isLocal()) { - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); ExceptionPtr base = p->base(); @@ -475,7 +476,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) bool Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "struct " << name; H << sb; @@ -486,8 +487,8 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) void Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) { - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); H << sp; H << nl << _dllExport << "bool operator==(const " << name << "&) const;"; @@ -508,7 +509,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << eb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - C << nl << "if(" << (*q)->name() << " != __rhs." << (*q)->name() << ')'; + C << nl << "if(" << fixKwd((*q)->name()) << " != __rhs." << fixKwd((*q)->name()) << ')'; C << sb; C << nl << "return true;"; C << eb; @@ -523,11 +524,11 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << eb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - C << nl << "if(" << (*q)->name() << " < __rhs." << (*q)->name() << ')'; + C << nl << "if(" << fixKwd((*q)->name()) << " < __rhs." << fixKwd((*q)->name()) << ')'; C << sb; C << nl << "return true;"; C << eb; - C << nl << "else if(__rhs." << (*q)->name() << " < " << (*q)->name() << ')'; + C << nl << "else if(__rhs." << fixKwd((*q)->name()) << " < " << fixKwd((*q)->name()) << ')'; C << sb; C << nl << "return false;"; C << eb; @@ -584,7 +585,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) void Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); string s = typeToString(p->type()); H << sp << nl << s << ' ' << name << ';'; } @@ -592,7 +593,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) void Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); TypePtr type = p->type(); string s = typeToString(type); if(s[0] == ':') @@ -605,8 +606,8 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) if(!p->isLocal() && (!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); // // TODO: ice_marshal/ice_unmarshal, __write/__read can be @@ -709,7 +710,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) void Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); TypePtr keyType = p->keyType(); TypePtr valueType = p->valueType(); string ks = typeToString(keyType); @@ -722,21 +723,21 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) if(!p->isLocal()) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); // // TODO: ice_marshal/ice_unmarshal, __write/__read can be // moved into the helper. // H << sp << nl << "class __U__" << name << " { };"; - H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name - << ");"; - H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");"; + H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name + << "&, __U__" << name << ");"; + H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name + << "&, __U__" << name << ");"; H << sp << nl << _dllExport << "void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&, const " - << name << "&, __U__" << name - << ");"; + << name << "&, __U__" << name << ");"; H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, " << name << "&, __U__" << name << ");"; @@ -828,14 +829,14 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) void Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); EnumeratorList enumerators = p->getEnumerators(); H << sp << nl << "enum " << name; H << sb; EnumeratorList::const_iterator en = enumerators.begin(); while(en != enumerators.end()) { - H << nl << (*en)->name(); + H << nl << fixKwd((*en)->name()); if(++en != enumerators.end()) { H << ','; @@ -845,8 +846,8 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) if(!p->isLocal()) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); int sz = enumerators.size(); assert(sz <= 0x7fffffff); // 64-bit enums are not supported @@ -937,7 +938,7 @@ void Slice::Gen::TypesVisitor::visitConstDef(const ConstDefPtr& p) { H << sp; - H << nl << "const " << typeToString(p->type()) << " " << p->name() << " = "; + H << nl << "const " << typeToString(p->type()) << " " << fixKwd(p->name()) << " = "; BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type()); if(bp && bp->kind() == Builtin::KindString) @@ -988,7 +989,15 @@ Slice::Gen::TypesVisitor::visitConstDef(const ConstDefPtr& p) } else { - H << p->value(); + EnumPtr ep = EnumPtr::dynamicCast(p->type()); + if(ep) + { + H << fixKwd(p->value()); + } + else + { + H << p->value(); + } } H << ";"; @@ -1002,11 +1011,11 @@ Slice::Gen::TypesVisitor::emitExceptionBase(const ExceptionPtr& base, const std: C.zeroIndent(); C << nl << "#ifdef _WIN32"; // COMPILERBUG C.restoreIndent(); - C << nl << base->name() << "::" << call << ";"; + C << nl << fixKwd(base->name()) << "::" << call << ";"; C.zeroIndent(); C << nl << "#else"; C.restoreIndent(); - C << nl << base->scoped() << "::" << call << ";"; + C << nl << fixKwd(base->scoped()) << "::" << call << ";"; C.zeroIndent(); C << nl << "#endif"; C.restoreIndent(); @@ -1045,7 +1054,7 @@ Slice::Gen::ProxyDeclVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1066,7 +1075,7 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p) return; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "class " << name << ';'; H << nl << _dllExport << "bool operator==(const " << name << "&, const " << name << "&);"; @@ -1106,7 +1115,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1127,8 +1136,8 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); H << sp << nl << "class " << _dllExport << name << " : "; @@ -1142,7 +1151,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::const_iterator q = bases.begin(); while(q != bases.end()) { - H << "virtual public ::IceProxy" << (*q)->scoped(); + H << "virtual public ::IceProxy" << fixKwd((*q)->scoped()); if(++q != bases.end()) { H << ',' << nl; @@ -1162,8 +1171,8 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) void Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); H.dec(); H << sp << nl << "private: "; @@ -1208,9 +1217,9 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) void Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { - string name = p->name(); - string scoped = p->scoped(); - string scope = p->scope(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); string retS = returnTypeToString(ret); @@ -1229,8 +1238,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; - args += q->second; + paramsDecl += fixKwd(q->second); + args += fixKwd(q->second); params += ", "; paramsDecl += ", "; args += ", "; @@ -1242,8 +1251,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; - args += q->second; + paramsDecl += fixKwd(q->second); + args += fixKwd(q->second); params += ", "; paramsDecl += ", "; args += ", "; @@ -1332,7 +1341,7 @@ Slice::Gen::DelegateVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1353,7 +1362,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); ClassList bases = p->bases(); H << sp << nl << "class " << _dllExport << name << " : "; @@ -1367,7 +1376,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::const_iterator q = bases.begin(); while(q != bases.end()) { - H << "virtual public ::IceDelegate" << (*q)->scoped(); + H << "virtual public ::IceDelegate" << fixKwd((*q)->scoped()); if(++q != bases.end()) { H << ',' << nl; @@ -1392,7 +1401,7 @@ Slice::Gen::DelegateVisitor::visitClassDefEnd(const ClassDefPtr& p) void Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); TypePtr ret = p->returnType(); string retS = returnTypeToString(ret); @@ -1454,7 +1463,7 @@ Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1475,8 +1484,8 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); H << sp << nl << "class " << _dllExport << name << " : "; @@ -1491,7 +1500,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::const_iterator q = bases.begin(); while(q != bases.end()) { - H << nl << "virtual public ::IceDelegateM" << (*q)->scoped(); + H << nl << "virtual public ::IceDelegateM" << fixKwd((*q)->scoped()); if(++q != bases.end()) { H << ','; @@ -1516,8 +1525,8 @@ Slice::Gen::DelegateMVisitor::visitClassDefEnd(const ClassDefPtr& p) void Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) { - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); string retS = returnTypeToString(ret); @@ -1535,7 +1544,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; + paramsDecl += fixKwd(q->second); params += ", "; paramsDecl += ", "; } @@ -1546,7 +1555,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; + paramsDecl += fixKwd(q->second); params += ", "; paramsDecl += ", "; } @@ -1561,7 +1570,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) H << sp << nl << "virtual " << retS << ' ' << name << params << ';'; C << sp << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl; C << sb; - C << nl << "static const ::std::string __operation(\"" << name << "\");"; + C << nl << "static const ::std::string __operation(\"" << p->name() << "\");"; list<string> metaData = p->getMetaData(); bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end(); C << nl << "::IceInternal::Outgoing __out(__connection, __reference, __operation, " @@ -1598,7 +1607,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) { C << nl << "case " << cnt++ << ':'; C << sb; - C << nl << (*r)->scoped() << " __ex;"; + C << nl << fixKwd((*r)->scoped()) << " __ex;"; C << nl << "__ex.__read(__is);"; C << nl << "throw __ex;"; C << eb; @@ -1652,7 +1661,7 @@ Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1673,8 +1682,8 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); H << sp << nl << "class " << _dllExport << name << " : "; @@ -1689,7 +1698,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::const_iterator q = bases.begin(); while(q != bases.end()) { - H << nl << "virtual public ::IceDelegateD" << (*q)->scoped(); + H << nl << "virtual public ::IceDelegateD" << fixKwd((*q)->scoped()); if(++q != bases.end()) { H << ','; @@ -1717,8 +1726,8 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); string retS = returnTypeToString(ret); @@ -1737,8 +1746,8 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; - args += q->second; + paramsDecl += fixKwd(q->second); + args += fixKwd(q->second); params += ", "; paramsDecl += ", "; args += ", "; @@ -1750,8 +1759,8 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; - args += q->second; + paramsDecl += fixKwd(q->second); + args += fixKwd(q->second); params += ", "; paramsDecl += ", "; args += ", "; @@ -1767,12 +1776,13 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << nl << "::Ice::Current __current;"; list<string> metaData = p->getMetaData(); bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end(); - C << nl << "__initCurrent(__current, \"" << name << "\", " << (nonmutating ? "true" : "false") + C << nl << "__initCurrent(__current, \"" << p->name() << "\", " << (nonmutating ? "true" : "false") << ", __context);"; C << nl << "while(true)"; C << sb; C << nl << "::IceInternal::Direct __direct(__adapter, __current);"; - C << nl << cl->scoped() << "* __servant = dynamic_cast< " << cl->scoped() << "*>(__direct.facetServant().get());"; + C << nl << fixKwd(cl->scoped()) << "* __servant = dynamic_cast< " + << fixKwd(cl->scoped()) << "*>(__direct.facetServant().get());"; C << nl << "if(!__servant)"; C << sb; C << nl << "::Ice::OperationNotExistException __opEx(__FILE__, __LINE__);"; @@ -1798,7 +1808,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) ExceptionList::const_iterator r; for(r = throws.begin(); r != throws.end(); ++r) { - C << nl << "catch(const " << (*r)->scoped() << "&)"; + C << nl << "catch(const " << fixKwd((*r)->scoped()) << "&)"; C << sb; C << nl << "throw;"; C << eb; @@ -1832,9 +1842,9 @@ Slice::Gen::ObjectDeclVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); - H << sp << nl << "namespace " << name << nl << '{'; + H << sp << nl << "namespace " << fixKwd(name) << nl << '{'; return true; } @@ -1848,7 +1858,7 @@ Slice::Gen::ObjectDeclVisitor::visitModuleEnd(const ModulePtr& p) void Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "class " << name << ';'; H << nl << _dllExport << "bool operator==(const " << name << "&, const " << name << "&);"; @@ -1869,7 +1879,7 @@ Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1886,8 +1896,8 @@ Slice::Gen::ObjectVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) { - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); string exp1; @@ -1923,7 +1933,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::const_iterator q = bases.begin(); while(q != bases.end()) { - H << "virtual public " << (*q)->scoped(); + H << "virtual public " << fixKwd((*q)->scoped()); if(++q != bases.end()) { H << ',' << nl; @@ -1940,15 +1950,16 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) { ClassList allBases = p->allBases(); StringList ids; - transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&ClassDef::scoped)); + transform(allBases.begin(), allBases.end(), back_inserter(ids), + ::IceUtil::constMemFun(&ClassDef::scoped)); StringList other; - other.push_back(scoped); + other.push_back(p->scoped()); other.push_back("::Ice::Object"); other.sort(); ids.merge(other); ids.unique(); StringList::const_iterator firstIter = ids.begin(); - StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped); + StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), p->scoped()); assert(scopedIter != ids.end()); int scopedPos = distance(firstIter, scopedIter); @@ -2011,8 +2022,8 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) void Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); if(!p->isLocal()) { @@ -2148,7 +2159,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) if(!p->isAbstract()) { - string name = p->name(); + string name = fixKwd(p->name()); string factoryName = "__F__"; factoryName += name; C << sp; @@ -2168,7 +2179,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << eb << ";"; C << sp; C << nl << "::Ice::ObjectFactoryPtr " << scoped.substr(2) << "::_factory = new " - << "__F__" << p->name() << ";"; + << "__F__" << fixKwd(p->name()) << ";"; C << sp << nl << "const ::Ice::ObjectFactoryPtr&" << nl << scoped.substr(2) << "::ice_factory()"; C << sb; C << nl << "return _factory;"; @@ -2240,9 +2251,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) { ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string name = p->name(); - string scoped = p->scoped(); - string scope = p->scope(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); string retS = returnTypeToString(ret); @@ -2268,8 +2279,8 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; - args += q->second; + paramsDecl += fixKwd(q->second); + args += fixKwd(q->second); } for(q = outParams.begin(); q != outParams.end(); ++q) @@ -2285,8 +2296,8 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) params += typeString; paramsDecl += typeString; paramsDecl += ' '; - paramsDecl += q->second; - args += q->second; + paramsDecl += fixKwd(q->second); + args += fixKwd(q->second); } if(!cl->isLocal()) @@ -2361,7 +2372,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) ExceptionList::const_iterator r; for(r = throws.begin(); r != throws.end(); ++r) { - C << nl << "catch(const " << (*r)->scoped() << "& __ex)"; + C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)"; C << sb; C << nl << "__os->write(__ex);"; C << nl << "return ::IceInternal::DispatchUserException;"; @@ -2376,7 +2387,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) void Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p) { - string name = p->name(); + string name = fixKwd(p->name()); string s = typeToString(p->type()); H << sp; H << nl << s << ' ' << name << ';'; @@ -2390,11 +2401,11 @@ Slice::Gen::ObjectVisitor::emitClassBase(const ClassDefPtr& base, const std::str C.zeroIndent(); C << nl << "#ifdef _WIN32"; // COMPILERBUG C.restoreIndent(); - C << nl << base->name() << "::" << call << ";"; + C << nl << fixKwd(base->name()) << "::" << call << ";"; C.zeroIndent(); C << nl << "#else"; C.restoreIndent(); - C << nl << base->scoped() << "::" << call << ";"; + C << nl << fixKwd(base->scoped()) << "::" << call << ";"; C.zeroIndent(); C << nl << "#endif"; C.restoreIndent(); @@ -2445,7 +2456,7 @@ Slice::Gen::IceInternalVisitor::visitUnitEnd(const UnitPtr& p) void Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p) { - string scoped = p->scoped(); + string scoped = fixKwd(p->scoped()); H << sp; H << nl << _dllExport << "void incRef(" << scoped << "*);"; @@ -2467,8 +2478,8 @@ Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p) bool Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); C << sp; C << nl << "void" << nl << "IceInternal::incRef(" << scoped << "* p)"; @@ -2506,7 +2517,7 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) C << nl << "if(f == b->ice_getFacet())"; C << sb; C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; - C << nl << "if(!d && b->ice_isA(\"" << scoped << "\"))"; + C << nl << "if(!d && b->ice_isA(\"" << p->scoped() << "\"))"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ";"; C << nl << "d->__copyFrom(b);"; @@ -2517,7 +2528,7 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) C << nl << "::Ice::ObjectPrx bb = b->ice_newFacet(f);"; C << nl << "try"; C << sb; - C << nl << "if(bb->ice_isA(\"" << scoped << "\"))"; + C << nl << "if(bb->ice_isA(\"" << p->scoped() << "\"))"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ";"; C << nl << "d->__copyFrom(bb);"; @@ -2572,7 +2583,7 @@ Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp; H << nl << "namespace " << name << nl << '{'; @@ -2590,8 +2601,8 @@ Slice::Gen::HandleVisitor::visitModuleEnd(const ModulePtr& p) void Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) { - string name = p->name(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scoped = fixKwd(p->scoped()); H << sp; H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name << "Ptr;"; @@ -2616,8 +2627,8 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!p->isLocal()) { - string scoped = p->scoped(); - string scope = p->scope(); + string scoped = fixKwd(p->scoped()); + string scope = fixKwd(p->scope()); C << sp; C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped @@ -2736,7 +2747,7 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type) StructPtr st = StructPtr::dynamicCast(type); if(st) { - out << nl << "return " << st->scoped() << "();"; + out << nl << "return " << fixKwd(st->scoped()) << "();"; return; } @@ -2744,20 +2755,20 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type) if(en) { EnumeratorList enumerators = en->getEnumerators(); - out << nl << "return " << en->scope() << enumerators.front()->name() << ';'; + out << nl << "return " << fixKwd(en->scope()) << fixKwd(enumerators.front()->name()) << ';'; return; } SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - out << nl << "return " << seq->scoped() << "();"; + out << nl << "return " << fixKwd(seq->scoped()) << "();"; return; } DictionaryPtr dict = DictionaryPtr::dynamicCast(type); assert(dict); - out << nl << "return " << dict->scoped() << "();"; + out << nl << "return " << fixKwd(dict->scoped()) << "();"; } bool @@ -2768,7 +2779,7 @@ Slice::Gen::ImplVisitor::visitModuleStart(const ModulePtr& p) return false; } - string name = p->name(); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -2790,9 +2801,9 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - string name = p->name(); - string scope = p->scope(); - string scoped = p->scoped(); + string name = fixKwd(p->name()); + string scope = fixKwd(p->scope()); + string scoped = fixKwd(p->scoped()); string cls = scope.substr(2) + name + "I"; ClassList bases = p->bases(); @@ -2809,7 +2820,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::const_iterator q; for(q = bases.begin(); q != bases.end(); ++q) { - H << ',' << nl << "virtual public " << (*q)->scoped() << "I"; + H << ',' << nl << "virtual public " << fixKwd((*q)->scoped()) << "I"; } H.restoreIndent(); @@ -2827,7 +2838,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); - string opName = op->name(); + string opName = fixKwd(op->name()); TypePtr ret = op->returnType(); string retS = returnTypeToString(ret); @@ -2876,7 +2887,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) C << ',' << nl; } string typeString = inputTypeToString(q->first); - C << typeString << ' ' << q->second; + C << typeString << ' ' << fixKwd(q->second); } for(q = outParams.begin(); q != outParams.end(); ++q) { @@ -2885,7 +2896,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) C << ',' << nl; } string typeString = outputTypeToString(q->first); - C << typeString << ' ' << q->second; + C << typeString << ' ' << fixKwd(q->second); } if(!p->isLocal()) { diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index ef0c5962708..d46c211cbe6 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -1785,7 +1785,16 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) void Slice::Gen::TypesVisitor::visitConstDef(const ConstDefPtr& p) { - // TODO: emit constant definition +#if 0 + string name = fixKwd(p->name()); + string absolute = getAbsolute(p->scoped()); + + if(open(absolute + "PrxHolder")) + Output& out = output(); + out << "This is a definition for constant " << p->name() << endl; + out << eb; + close(); +#endif } Slice::Gen::HolderVisitor::HolderVisitor(const string& dir, |