summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2007-09-04 11:14:53 +0800
committerMatthew Newhook <matthew@zeroc.com>2007-09-04 11:14:53 +0800
commita55b88dc20dacaf23c5fce8415daf28c63388ccf (patch)
tree713968abb7de9959600eb59461bd97384b0c4d74 /cpp
parentbug 2442 - slice2java generating bad impl code (diff)
downloadice-a55b88dc20dacaf23c5fce8415daf28c63388ccf.tar.bz2
ice-a55b88dc20dacaf23c5fce8415daf28c63388ccf.tar.xz
ice-a55b88dc20dacaf23c5fce8415daf28c63388ccf.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2369
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES4
-rwxr-xr-xcpp/allTests.py1
-rw-r--r--cpp/include/Slice/PythonUtil.h10
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp18
-rw-r--r--cpp/src/Slice/JavaUtil.cpp2
-rw-r--r--cpp/src/Slice/PythonUtil.cpp33
-rw-r--r--cpp/src/Slice/RubyUtil.cpp5
-rw-r--r--cpp/src/slice2cpp/Gen.cpp62
-rw-r--r--cpp/test/Makefile1
-rw-r--r--cpp/test/Makefile.mak1
-rw-r--r--cpp/test/Slice/Makefile21
-rw-r--r--cpp/test/Slice/Makefile.mak19
-rw-r--r--cpp/test/Slice/keyword/.depend4
-rw-r--r--cpp/test/Slice/keyword/Client.cpp175
-rw-r--r--cpp/test/Slice/keyword/Key.ice81
-rw-r--r--cpp/test/Slice/keyword/Makefile32
-rw-r--r--cpp/test/Slice/keyword/Makefile.mak38
-rwxr-xr-xcpp/test/Slice/keyword/run.py42
18 files changed, 495 insertions, 54 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index 61a61640a9b..50e002cf7f9 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -9,6 +9,10 @@ Changes since version 3.2.X (binary incompatible)
of the communicator's logger from properties. This plugin must
implement a LoggerPlugin. See manual for more details.
+- Fixed a variety of bugs with slice2cpp where incorrect code
+ would be generated when C++ reserved words are used as Slice
+ identifiers.
+
- It is no longer possible to provide input files on the
command line for icestormadmin nor icegridadmin.
diff --git a/cpp/allTests.py b/cpp/allTests.py
index ac3800b38b3..24f5b065f50 100755
--- a/cpp/allTests.py
+++ b/cpp/allTests.py
@@ -73,6 +73,7 @@ tests = [ \
"IceUtil/uuid", \
"IceUtil/timer", \
"Slice/errorDetection", \
+ "Slice/keyword", \
"Ice/proxy", \
"Ice/operations", \
"Ice/exceptions", \
diff --git a/cpp/include/Slice/PythonUtil.h b/cpp/include/Slice/PythonUtil.h
index d0caa2a2dcf..fdd1f98fc1c 100644
--- a/cpp/include/Slice/PythonUtil.h
+++ b/cpp/include/Slice/PythonUtil.h
@@ -46,11 +46,13 @@ SLICE_API std::string fixIdent(const std::string&);
SLICE_API std::string getPackageMetadata(const Slice::ContainedPtr&);
//
-// Get the fully-qualified name of the given definition, including any package
-// defined via metadata. If a suffix is provided, it is prepended to the
-// definition's unqualified name.
+// Get the fully-qualified name of the given definition, including any
+// package defined via metadata. If a suffix is provided, it is
+// prepended to the definition's unqualified name. If the nameSuffix
+// is provided, it is appended to the containers name.
//
-SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, const std::string& = std::string());
+SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, const std::string& = std::string(),
+ const std::string& = std::string());
//
// Emit a comment header.
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 5624801b8e5..03e1a85bc18 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -329,7 +329,7 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList&
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- return "const " + fixKwd(cl->scoped()) + "Ptr&";
+ return "const " + fixKwd(cl->scoped() + "Ptr&");
}
StructPtr st = StructPtr::dynamicCast(type);
@@ -337,7 +337,7 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList&
{
if(findMetaData(st->getMetaData(), false) == "class")
{
- return "const " + fixKwd(st->scoped()) + "Ptr&";
+ return "const " + fixKwd(st->scoped() + "Ptr&");
}
return "const " + fixKwd(st->scoped()) + "&";
}
@@ -345,7 +345,7 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList&
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
- return "const " + fixKwd(proxy->_class()->scoped()) + "Prx&";
+ return "const " + fixKwd(proxy->_class()->scoped() + "Prx&");
}
EnumPtr en = EnumPtr::dynamicCast(type);
@@ -445,7 +445,7 @@ Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- return fixKwd(cl->scoped()) + "Ptr&";
+ return fixKwd(cl->scoped() + "Ptr&");
}
StructPtr st = StructPtr::dynamicCast(type);
@@ -453,7 +453,7 @@ Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList
{
if(findMetaData(st->getMetaData(), false) == "class")
{
- return fixKwd(st->scoped()) + "Ptr&";
+ return fixKwd(st->scoped() + "Ptr&");
}
return fixKwd(st->scoped()) + "&";
}
@@ -461,7 +461,7 @@ Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
- return fixKwd(proxy->_class()->scoped()) + "Prx&";
+ return fixKwd(proxy->_class()->scoped() + "Prx&");
}
SequencePtr seq = SequencePtr::dynamicCast(type);
@@ -526,6 +526,12 @@ lookupKwd(const string& name)
//
// Keyword list. *Must* be kept in alphabetical order.
//
+ // Note that this keyword list unnecessarily contains C++ keywords
+ // that are illegal slice identifiers -- namely identifiers that
+ // contain underscores (and_eq, for example), and slice keywords
+ // (class, int, etc.). They have not been removed so that the
+ // keyword list is kept complete.
+ //
static const string keywordList[] =
{
"and", "and_eq", "asm", "auto", "bit_and", "bit_or", "bool", "break", "case", "catch", "char",
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index 4ad55ef7432..8f27fb78708 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -216,7 +216,7 @@ lookupKwd(const string& name)
// NOTE: Any changes made to this list must also be made in BasicStream.java.
//
static const string keywordList[] =
- {
+ {
"abstract", "assert", "boolean", "break", "byte", "case", "catch",
"char", "checkedCast", "class", "clone", "const", "continue", "default", "do",
"double", "else", "enum", "equals", "extends", "false", "final", "finalize",
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp
index 0261e7aa516..fdc6449285d 100644
--- a/cpp/src/Slice/PythonUtil.cpp
+++ b/cpp/src/Slice/PythonUtil.cpp
@@ -107,7 +107,7 @@ private:
//
// Return a Python symbol for the given parser element.
//
- string getSymbol(const ContainedPtr&);
+ string getSymbol(const ContainedPtr&, const string& = string());
//
// Emit Python code to assign the given symbol in the current module.
@@ -367,7 +367,7 @@ Slice::Python::CodeVisitor::visitClassDecl(const ClassDeclPtr& p)
_out << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')";
if(!p->isLocal())
{
- _out << nl << "_M_" << type << "Prx = IcePy.declareProxy('" << scoped << "')";
+ _out << nl << "_M_" << getAbsolute(p, "_t_", "Prx") << " = IcePy.declareProxy('" << scoped << "')";
}
_out.dec();
_classHistory.insert(scoped); // Avoid redundant declarations.
@@ -381,6 +381,9 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
string type = getAbsolute(p, "_t_");
string abs = getAbsolute(p);
string name = fixIdent(p->name());
+ string prxAbs = getAbsolute(p, "", "Prx");
+ string prxName = fixIdent(p->name() + "Prx");
+ string prxType = getAbsolute(p, "_t_", "Prx");
ClassList bases = p->bases();
ClassDefPtr base;
OperationList ops = p->operations();
@@ -590,8 +593,8 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
if(!p->isLocal())
{
- _out << sp << nl << "_M_" << abs << "Prx = Ice.createTempClass()";
- _out << nl << "class " << name << "Prx(";
+ _out << sp << nl << "_M_" << prxAbs << " = Ice.createTempClass()";
+ _out << nl << "class " << prxName << "(";
if(bases.empty())
{
_out << "Ice.ObjectPrx";
@@ -601,7 +604,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassList::const_iterator q = bases.begin();
while(q != bases.end())
{
- _out << getSymbol(*q) << "Prx";
+ _out << getSymbol(*q, "Prx");
if(++q != bases.end())
{
_out << ", ";
@@ -671,19 +674,19 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp << nl << "def checkedCast(proxy, facetOrCtx=None, _ctx=None):";
_out.inc();
- _out << nl << "return _M_" << abs << "Prx.ice_checkedCast(proxy, '" << scoped << "', facetOrCtx, _ctx)";
+ _out << nl << "return _M_" << prxAbs << ".ice_checkedCast(proxy, '" << scoped << "', facetOrCtx, _ctx)";
_out.dec();
_out << nl << "checkedCast = staticmethod(checkedCast)";
_out << sp << nl << "def uncheckedCast(proxy, facet=None):";
_out.inc();
- _out << nl << "return _M_" << abs << "Prx.ice_uncheckedCast(proxy, facet)";
+ _out << nl << "return _M_" << prxAbs << ".ice_uncheckedCast(proxy, facet)";
_out.dec();
_out << nl << "uncheckedCast = staticmethod(uncheckedCast)";
_out.dec();
- _out << sp << nl << "_M_" << type << "Prx = IcePy.defineProxy('" << scoped << "', " << name << "Prx)";
+ _out << sp << nl << "_M_" << prxType << " = IcePy.defineProxy('" << scoped << "', " << prxName << ")";
}
if(_classHistory.count(scoped) == 0 && p->canBeCyclic())
@@ -882,7 +885,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- registerName(name + "Prx");
+ registerName(prxName);
}
_out.dec();
@@ -1455,12 +1458,12 @@ Slice::Python::CodeVisitor::visitConst(const ConstPtr& p)
}
string
-Slice::Python::CodeVisitor::getSymbol(const ContainedPtr& p)
+Slice::Python::CodeVisitor::getSymbol(const ContainedPtr& p, const string& nameSuffix)
{
//
// An explicit reference to another type must always be prefixed with "_M_".
//
- return "_M_" + getAbsolute(p);
+ return "_M_" + getAbsolute(p, "", nameSuffix);
}
void
@@ -1541,7 +1544,7 @@ Slice::Python::CodeVisitor::writeType(const TypePtr& p)
ProxyPtr prx = ProxyPtr::dynamicCast(p);
if(prx)
{
- _out << "_M_" << getAbsolute(prx->_class(), "_t_") << "Prx";
+ _out << "_M_" << getAbsolute(prx->_class(), "_t_", "Prx");
return;
}
@@ -1951,7 +1954,7 @@ Slice::Python::getPackageMetadata(const ContainedPtr& cont)
}
string
-Slice::Python::getAbsolute(const ContainedPtr& cont, const string& suffix)
+Slice::Python::getAbsolute(const ContainedPtr& cont, const string& suffix, const string& nameSuffix)
{
string scope = scopedToName(cont->scope());
@@ -1970,11 +1973,11 @@ Slice::Python::getAbsolute(const ContainedPtr& cont, const string& suffix)
if(suffix.empty())
{
- return scope + fixIdent(cont->name());
+ return scope + fixIdent(cont->name() + nameSuffix);
}
else
{
- return scope + suffix + fixIdent(cont->name());
+ return scope + suffix + fixIdent(cont->name() + nameSuffix);
}
}
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index bd995ce21aa..07bdebd46d6 100644
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -1738,6 +1738,11 @@ Slice::Ruby::fixIdent(const string& ident, IdentStyle style)
case IdentNormal:
break;
case IdentToUpper:
+ // Special case BEGIN & END for class/module names.
+ if(id == "BEGIN" || id == "END")
+ {
+ return id + "_";
+ }
if(id[0] >= 'a' && id[0] <= 'z')
{
id[0] += 'A' - 'a';
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 986d5269f77..0d70727d44f 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -450,9 +450,7 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p)
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
- string name = fixKwd(p->name());
-
- H << sp << nl << "namespace " << name << nl << '{';
+ H << sp << nl << "namespace " << fixKwd(p->name()) << nl << '{';
return true;
}
@@ -498,7 +496,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
{
string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
allTypes.push_back(typeName);
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ allParamDecls.push_back(typeName + " __ice_" + fixKwd((*q)->name()));
}
if(base)
@@ -506,7 +504,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
DataMemberList baseDataMembers = base->allDataMembers();
for(q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
{
- baseParams.push_back("__ice_" + (*q)->name());
+ baseParams.push_back("__ice_" + fixKwd((*q)->name()));
}
}
@@ -891,7 +889,8 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
}
H << name << spar << types << epar << ';';
- C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << paramDecls << epar << " :";
+ C << sp << nl << fixKwd(p->scoped()).substr(2) << "::"
+ << fixKwd(p->name()) << spar << paramDecls << epar << " :";
C.inc();
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -1053,23 +1052,23 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
H << eb << ';';
if(findMetaData(p->getMetaData(), false) == "class")
{
- H << sp << nl << "typedef ::IceUtil::Handle< " << scoped << "> " << name << "Ptr;";
+ H << sp << nl << "typedef ::IceUtil::Handle< " << scoped << "> " << p->name() + "Ptr;";
if(!p->isLocal() && _stream)
{
H << sp << nl << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << name << "Ptr&);";
- H << nl << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name
+ << p->name() << "Ptr&);";
+ H << nl << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << p->name()
<< "Ptr&);";
C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "Ptr& __v)";
+ << "(const ::Ice::OutputStreamPtr& __outS, const " << fixKwd(p->scoped() + "Ptr") << "& __v)";
C << sb;
C << nl << "__v->ice_write(__outS);";
C << eb;
C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "Ptr& __v)";
+ << "(const ::Ice::InputStreamPtr& __inS, " << fixKwd(p->scoped() + "Ptr") << "& __v)";
C << sb;
C << nl << "__v->ice_read(__inS);";
C << eb;
@@ -1882,7 +1881,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
}
H << fixKwd(name) << spar << args << "0" << epar << ';';
H << eb;
- H << nl << deprecateSymbol << retS << ' ' << fixKwd(name) << spar << paramsDecl << "const ::Ice::Context& __ctx" << epar;
+ H << nl << deprecateSymbol << retS << ' ' << fixKwd(name) << spar << paramsDecl << "const ::Ice::Context& __ctx"
+ << epar;
H << sb;
H << nl;
if(ret)
@@ -1896,7 +1896,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
H.dec();
H << nl << "private:";
H.inc();
- H << sp << nl << _dllExport << retS << ' ' << fixKwd(name) << spar << params << "const ::Ice::Context*" << epar << ';';
+ H << sp << nl << _dllExport << retS << ' ' << fixKwd(name) << spar << params << "const ::Ice::Context*" << epar
+ << ';';
H << nl;
H.dec();
H << nl << "public:";
@@ -1952,19 +1953,22 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string classScope = fixKwd(cl->scope());
string classScopedAMI = classScope + classNameAMI;
- H << nl << _dllExport << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&")
+ H << nl << _dllExport << "void " << name << "_async" << spar
+ << ("const " + classScopedAMI + '_' + p->name() + "Ptr&")
<< paramsAMI << epar << ';';
- H << nl << _dllExport << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&")
+ H << nl << _dllExport << "void " << name << "_async" << spar
+ << ("const " + classScopedAMI + '_' + p->name() + "Ptr&")
<< paramsAMI << "const ::Ice::Context&" << epar << ';';
C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar
- << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << epar;
+ << ("const " + classScopedAMI + '_' + p->name() + "Ptr& __cb") << paramsDeclAMI << epar;
C << sb;
C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "0" << epar << ';';
C << eb;
C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar
- << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << "const ::Ice::Context& __ctx"
+ << ("const " + classScopedAMI + '_' + p->name() + "Ptr& __cb")
+ << paramsDeclAMI << "const ::Ice::Context& __ctx"
<< epar;
C << sb;
C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "&__ctx" << epar << ';';
@@ -2809,9 +2813,9 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- H << nl << "typedef " << name << "Prx ProxyType;";
+ H << nl << "typedef " << p->name() << "Prx ProxyType;";
}
- H << nl << "typedef " << name << "Ptr PointerType;";
+ H << nl << "typedef " << p->name() << "Ptr PointerType;";
H << nl;
vector<string> params;
@@ -2969,11 +2973,11 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << sp;
C << nl << "::Ice::ObjectPtr";
- C << nl << fixKwd(p->scoped()).substr(2) << "::ice_clone() const";
+ C << nl << scoped.substr(2) << "::ice_clone() const";
C << sb;
if(!p->isAbstract())
{
- C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << fixKwd(p->scoped()) << "(*this);";
+ C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << scoped << "(*this);";
C << nl << "return __p;";
}
else
@@ -3036,14 +3040,14 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << eb << ';';
C << sp;
- C << nl << "bool" << nl << fixKwd(p->scoped()).substr(2)
+ C << nl << "bool" << nl << scoped.substr(2)
<< "::ice_isA(const ::std::string& _s, const ::Ice::Current&) const";
C << sb;
C << nl << "return ::std::binary_search(" << flatName << ", " << flatName << " + " << ids.size() << ", _s);";
C << eb;
C << sp;
- C << nl << "::std::vector< ::std::string>" << nl << fixKwd(p->scoped()).substr(2)
+ C << nl << "::std::vector< ::std::string>" << nl << scoped.substr(2)
<< "::ice_ids(const ::Ice::Current&) const";
C << sb;
C << nl << "return ::std::vector< ::std::string>(&" << flatName << "[0], &" << flatName
@@ -3051,14 +3055,14 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << eb;
C << sp;
- C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2)
+ C << nl << "const ::std::string&" << nl << scoped.substr(2)
<< "::ice_id(const ::Ice::Current&) const";
C << sb;
C << nl << "return " << flatName << '[' << scopedPos << "];";
C << eb;
C << sp;
- C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2) << "::ice_staticId()";
+ C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_staticId()";
C << sb;
C << nl << "return " << flatName << '[' << scopedPos << "];";
C << eb;
@@ -3135,7 +3139,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
<< ", current.operation);";
C << nl << "if(r.first == r.second)";
C << sb;
- C << nl << "throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);";
+ C << nl << "throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, "
+ << "current.facet, current.operation);";
C << eb;
C << sp;
C << nl << "switch(r.first - " << flatName << ')';
@@ -3151,7 +3156,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << eb;
C << sp;
C << nl << "assert(false);";
- C << nl << "throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);";
+ C << nl << "throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, "
+ << "current.facet, current.operation);";
C << eb;
@@ -4284,7 +4290,7 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
C << sp;
C << nl << "void" << nl << scope.substr(2) << "ice_read" << name << "(const ::Ice::InputStreamPtr& __inS, "
- << scoped << "Ptr& __v)";
+ << scope << name << "Ptr& __v)";
C << sb;
C << nl << "::Ice::ReadObjectCallbackPtr __cb = new ::Ice::ReadObjectCallbackI(" << scope << "__patch__"
<< name << "Ptr, &__v);";
diff --git a/cpp/test/Makefile b/cpp/test/Makefile
index d7820b95c61..59dbc105836 100644
--- a/cpp/test/Makefile
+++ b/cpp/test/Makefile
@@ -12,6 +12,7 @@ top_srcdir = ..
include $(top_srcdir)/config/Make.rules
SUBDIRS = IceUtil \
+ Slice \
Ice \
IceSSL \
IceStorm \
diff --git a/cpp/test/Makefile.mak b/cpp/test/Makefile.mak
index e31c48fec56..1a9d6a70d3b 100644
--- a/cpp/test/Makefile.mak
+++ b/cpp/test/Makefile.mak
@@ -12,6 +12,7 @@ top_srcdir = ..
!include $(top_srcdir)/config/Make.rules.mak
SUBDIRS = IceUtil \
+ Slice \
Ice \
IceSSL \
Glacier2 \
diff --git a/cpp/test/Slice/Makefile b/cpp/test/Slice/Makefile
new file mode 100644
index 00000000000..864904542da
--- /dev/null
+++ b/cpp/test/Slice/Makefile
@@ -0,0 +1,21 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ../..
+
+include $(top_srcdir)/config/Make.rules
+
+SUBDIRS = keyword
+
+$(EVERYTHING)::
+ @for subdir in $(SUBDIRS); \
+ do \
+ echo "making $@ in $$subdir"; \
+ ( cd $$subdir && $(MAKE) $@ ) || exit 1; \
+ done
diff --git a/cpp/test/Slice/Makefile.mak b/cpp/test/Slice/Makefile.mak
new file mode 100644
index 00000000000..6b822657c05
--- /dev/null
+++ b/cpp/test/Slice/Makefile.mak
@@ -0,0 +1,19 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ..\..
+
+!include $(top_srcdir)\config\Make.rules.mak
+
+SUBDIRS = keyword
+
+$(EVERYTHING)::
+ @for %i in ( $(SUBDIRS) ) do \
+ @echo "making $@ in %i" && \
+ cmd /c "cd %i && $(MAKE) -nologo -f Makefile.mak $@" || exit 1
diff --git a/cpp/test/Slice/keyword/.depend b/cpp/test/Slice/keyword/.depend
new file mode 100644
index 00000000000..52576334989
--- /dev/null
+++ b/cpp/test/Slice/keyword/.depend
@@ -0,0 +1,4 @@
+Client$(OBJEXT): Client.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/Process.h ../../../include/Ice/Outgoing.h ../../../include/Ice/Direct.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h Key.h
+Key$(OBJEXT): Key.cpp Key.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/InstanceF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/Stream.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h
+Key.cpp: Key.ice
+Key.ice: $(SLICE2CPP) $(SLICEPARSERLIB)
diff --git a/cpp/test/Slice/keyword/Client.cpp b/cpp/test/Slice/keyword/Client.cpp
new file mode 100644
index 00000000000..8d9bb8dd931
--- /dev/null
+++ b/cpp/test/Slice/keyword/Client.cpp
@@ -0,0 +1,175 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <Key.h>
+
+using namespace std;
+
+class breakI : public _cpp_and::_cpp_break
+{
+public:
+ virtual void case_async(const ::_cpp_and::AMD_break_casePtr& cb, ::Ice::Int, const ::Ice::Current&)
+ {
+ cb->ice_response(0);
+ }
+};
+
+class charI: public _cpp_and::_cpp_char
+{
+public:
+ virtual void _cpp_explicit(const ::Ice::Current& current)
+ {
+ assert(current.operation == "explicit");
+ }
+};
+
+class complI: public _cpp_and::_cpp_compl
+{
+public:
+ virtual void foo(const _cpp_and::charPrx&, Ice::Int&, const ::Ice::Current&)
+ {
+ }
+};
+
+class doI : public _cpp_and::_cpp_do
+{
+public:
+ virtual void case_async(const ::_cpp_and::AMD_break_casePtr&, ::Ice::Int, const ::Ice::Current&)
+ {
+ }
+ virtual void _cpp_explicit(const ::Ice::Current&)
+ {
+ }
+ virtual void foo(const _cpp_and::charPrx&, Ice::Int&, const ::Ice::Current&)
+ {
+ }
+};
+
+class friendI : public _cpp_and::_cpp_friend
+{
+public:
+ virtual _cpp_and::_cpp_auto
+ _cpp_goto(_cpp_and::_cpp_continue, const _cpp_and::_cpp_auto&, const _cpp_and::deletePtr&,
+ const _cpp_and::complPtr&, const _cpp_and::doPtr&, const _cpp_and::breakPrx&,
+ const _cpp_and::charPrx&, const _cpp_and::complPrx&, const _cpp_and::doPrx&,
+ ::Ice::Int, ::Ice::Int, ::Ice::Int, ::Ice::Int)
+ {
+ return _cpp_and::_cpp_auto();
+ }
+};
+
+class fooI : public _cpp_and::AMI_compl_foo
+{
+public:
+
+ virtual void ice_response(Ice::Int) {}
+ virtual void ice_exception(const ::Ice::Exception&) {}
+};
+
+//
+// This section of the test is present to ensure that the C++ types
+// are named correctly. It is not expected to run.
+//
+void
+testtypes()
+{
+ _cpp_and::_cpp_continue a = _cpp_and::_cpp_asm;
+ assert(a);
+
+ _cpp_and::_cpp_auto b;
+ b._cpp_default = 0;
+
+ _cpp_and::deletePtr c = new _cpp_and::_cpp_delete();
+ c->_cpp_else = "";
+
+ _cpp_and::breakPrx d;
+ int d2;
+ d->_cpp_case(0, d2);
+ _cpp_and::breakPtr d1 = new breakI();
+
+ _cpp_and::charPrx e;
+ e->_cpp_explicit();
+ _cpp_and::charPtr e1 = new charI();
+
+ _cpp_and::complPrx f;
+ f->foo_async(new fooI(), e);
+ _cpp_and::complPtr f1 = new complI();
+
+ _cpp_and::doPrx g;
+ g->_cpp_case(0, d2);
+ g->_cpp_explicit();
+ _cpp_and::doPtr g1 = new doI();
+
+ _cpp_and::_cpp_extern h;
+ _cpp_and::_cpp_for i;
+ _cpp_and::_cpp_return j;
+ j._cpp_signed = 0;
+ _cpp_and::_cpp_sizeof k;
+ k._cpp_static = 0;
+ k._cpp_switch = 1;
+ k._cpp_signed = 2;
+
+ _cpp_and::friendPtr l = new friendI();
+
+ const int m = _cpp_and::_cpp_template;
+ assert(m == _cpp_and::_cpp_template);
+}
+
+int
+run(const Ice::CommunicatorPtr& communicator)
+{
+ communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp");
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
+ adapter->add(new charI, communicator->stringToIdentity("test"));
+ adapter->activate();
+
+ cout << "Testing operation name... " << flush;
+ _cpp_and::charPrx p = _cpp_and::charPrx::uncheckedCast(
+ adapter->createProxy(communicator->stringToIdentity("test")));
+ p->_cpp_explicit();
+ cout << "ok!" << endl;
+
+ return EXIT_SUCCESS;
+}
+
+int
+main(int argc, char* argv[])
+{
+ int status;
+ Ice::CommunicatorPtr communicator;
+
+ try
+ {
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(argc, argv);
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(communicator);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+
+ if(communicator)
+ {
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ }
+
+ return status;
+}
diff --git a/cpp/test/Slice/keyword/Key.ice b/cpp/test/Slice/keyword/Key.ice
new file mode 100644
index 00000000000..790f5277746
--- /dev/null
+++ b/cpp/test/Slice/keyword/Key.ice
@@ -0,0 +1,81 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+module and
+{
+
+enum continue
+{
+ asm
+};
+
+struct auto
+{
+ int default;
+};
+
+["cpp:class"] struct delete
+{
+ string else;
+};
+
+interface break
+{
+ ["amd"] void case(int catch, out int try);
+};
+
+interface char
+{
+ void explicit();
+};
+
+class compl
+{
+ ["ami"] void foo(char* export, out int volatile);
+};
+
+class do extends compl implements char, break
+{
+};
+
+sequence<auto> extern;
+
+dictionary<string,auto> for;
+
+exception return
+{
+ int signed;
+};
+
+exception sizeof extends return
+{
+ int static; int switch;
+};
+
+local interface friend
+{
+ auto goto(continue if, auto d, delete inline, compl private, do mutable, break* namespace,
+ char* new, compl* not, do* operator, int or, int protected, int public, int register)
+ throws return, sizeof;
+};
+
+const int template = 0;
+const int this = 0;
+const int throw = 0;
+const int typedef = 0;
+const int typeid = 0;
+const int typename = 0;
+const int union = 0;
+const int unsigned = 0;
+const int using = 0;
+const int virtual = 0;
+const int while = 0;
+const int xor = 0;
+
+};
diff --git a/cpp/test/Slice/keyword/Makefile b/cpp/test/Slice/keyword/Makefile
new file mode 100644
index 00000000000..c5f5f5e2813
--- /dev/null
+++ b/cpp/test/Slice/keyword/Makefile
@@ -0,0 +1,32 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ../../..
+
+CLIENT = client
+
+TARGETS = $(CLIENT)
+
+COBJS = Client.o \
+ Key.o
+
+SRCS = $(COBJS:.o=.cpp)
+
+SLICE_SRCS = Key.ice
+
+include $(top_srcdir)/config/Make.rules
+
+CPPFLAGS := -I. -I../../include $(CPPFLAGS)
+SLICE2CPPFLAGS := --stream $(SLICE2CPPFLAGS)
+
+$(CLIENT): $(COBJS)
+ rm -f $@
+ $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS)
+
+include .depend
diff --git a/cpp/test/Slice/keyword/Makefile.mak b/cpp/test/Slice/keyword/Makefile.mak
new file mode 100644
index 00000000000..b859b99f893
--- /dev/null
+++ b/cpp/test/Slice/keyword/Makefile.mak
@@ -0,0 +1,38 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+CLIENT = client.exe
+
+TARGETS = $(CLIENT)
+
+COBJS = Key.obj \
+ Client.obj
+
+SRCS = $(COBJS:.obj=.cpp)
+
+!include $(top_srcdir)/config/Make.rules.mak
+
+CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+SLICE2CPPFLAGS = --stream $(SLICE2CPPFLAGS)
+
+!if "$(CPP_COMPILER)" != "BCC2006" && "$(OPTIMIZE)" != "yes"
+CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb)
+!endif
+
+$(CLIENT): $(COBJS)
+ $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
+
+clean::
+ del /q Key.cpp Key.h
+
+!include .depend
diff --git a/cpp/test/Slice/keyword/run.py b/cpp/test/Slice/keyword/run.py
new file mode 100755
index 00000000000..e033a8e4d1a
--- /dev/null
+++ b/cpp/test/Slice/keyword/run.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import os, sys
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
+ break
+else:
+ raise "can't find toplevel directory!"
+
+sys.path.append(os.path.join(toplevel, "config"))
+import TestUtil
+
+name = os.path.join("Slice", "keyword")
+testdir = os.path.join(toplevel, "test", name)
+
+cwd = os.getcwd()
+os.chdir(testdir)
+
+client = os.path.join(testdir, "client")
+
+print "starting client...",
+clientPipe = os.popen(client + " 2>&1")
+print "ok"
+
+TestUtil.printOutputFromPipe(clientPipe);
+
+clientStatus = TestUtil.closePipe(clientPipe)
+
+if clientStatus:
+ sys.exit(1)
+
+sys.exit(0)