summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES3
-rw-r--r--cpp/include/Ice/Exception.h4
-rw-r--r--cpp/include/IceUtil/CtrlCHandler.h2
-rw-r--r--cpp/include/IceUtil/Exception.h9
-rw-r--r--cpp/include/IceUtil/ThreadException.h21
-rw-r--r--cpp/include/IceUtil/UUID.h6
-rw-r--r--cpp/include/IceXML/Parser.h3
-rw-r--r--cpp/include/Transform/Exception.h3
-rw-r--r--cpp/src/IceUtil/CtrlCHandler.cpp6
-rw-r--r--cpp/src/IceUtil/Exception.cpp12
-rw-r--r--cpp/src/IceUtil/ThreadException.cpp24
-rw-r--r--cpp/src/IceUtil/UUID.cpp6
-rw-r--r--cpp/src/IceXML/Parser.cpp6
-rw-r--r--cpp/src/Transform/Exception.cpp6
-rw-r--r--cpp/src/Transform/Node.cpp6
-rw-r--r--cpp/src/Transform/Node.h3
-rw-r--r--cpp/src/slice2cpp/Gen.cpp25
17 files changed, 101 insertions, 44 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index 56a7e6844e8..0704b9debdf 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,6 +1,9 @@
Changes since version 1.2.0
---------------------------
+- Changed Ice::Exception::ice_name() to return const std::string&
+ instead of returning a string by value.
+
- Added support for "global" metadata, which can only be specified
once in a file and must appear before any definitions. The syntax
is similar to that of local metadata, but with an extra set of
diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h
index 7f03ae118b5..6b977165ec1 100644
--- a/cpp/include/Ice/Exception.h
+++ b/cpp/include/Ice/Exception.h
@@ -36,7 +36,7 @@ class ICE_API LocalException : public IceUtil::Exception
public:
LocalException(const char*, int);
- virtual std::string ice_name() const = 0;
+ virtual const std::string& ice_name() const = 0;
virtual Exception* ice_clone() const = 0;
virtual void ice_throw() const = 0;
};
@@ -45,7 +45,7 @@ class ICE_API UserException : public IceUtil::Exception
{
public:
- virtual std::string ice_name() const = 0;
+ virtual const std::string& ice_name() const = 0;
virtual Exception* ice_clone() const = 0;
virtual void ice_throw() const = 0;
diff --git a/cpp/include/IceUtil/CtrlCHandler.h b/cpp/include/IceUtil/CtrlCHandler.h
index b455c2c1fd7..a3d2200351b 100644
--- a/cpp/include/IceUtil/CtrlCHandler.h
+++ b/cpp/include/IceUtil/CtrlCHandler.h
@@ -66,7 +66,7 @@ class ICE_UTIL_API CtrlCHandlerException : public Exception
public:
CtrlCHandlerException(const char*, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
};
diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h
index 0039364d884..ff1221f6731 100644
--- a/cpp/include/IceUtil/Exception.h
+++ b/cpp/include/IceUtil/Exception.h
@@ -27,7 +27,7 @@ public:
Exception();
Exception(const char*, int);
virtual ~Exception();
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
@@ -38,6 +38,7 @@ private:
const char* _file;
int _line;
+ static ::std::string _name;
};
ICE_UTIL_API std::ostream& operator<<(std::ostream&, const Exception&);
@@ -47,9 +48,13 @@ class ICE_UTIL_API NullHandleException : public Exception
public:
NullHandleException(const char*, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
+
+private:
+
+ static ::std::string _name;
};
}
diff --git a/cpp/include/IceUtil/ThreadException.h b/cpp/include/IceUtil/ThreadException.h
index b834fb692f7..2a39b93d2d8 100644
--- a/cpp/include/IceUtil/ThreadException.h
+++ b/cpp/include/IceUtil/ThreadException.h
@@ -25,7 +25,7 @@ class ICE_UTIL_API ThreadSyscallException : public Exception
public:
ThreadSyscallException(const char*, int, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
@@ -34,6 +34,7 @@ public:
private:
const int _error;
+ static ::std::string _name;
};
class ICE_UTIL_API ThreadLockedException : public Exception
@@ -41,9 +42,13 @@ class ICE_UTIL_API ThreadLockedException : public Exception
public:
ThreadLockedException(const char*, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
+
+private:
+
+ static ::std::string _name;
};
class ICE_UTIL_API ThreadStartedException : public Exception
@@ -51,9 +56,13 @@ class ICE_UTIL_API ThreadStartedException : public Exception
public:
ThreadStartedException(const char*, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
+
+private:
+
+ static ::std::string _name;
};
class ICE_UTIL_API ThreadNotStartedException : public Exception
@@ -61,9 +70,13 @@ class ICE_UTIL_API ThreadNotStartedException : public Exception
public:
ThreadNotStartedException(const char*, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
+
+private:
+
+ static ::std::string _name;
};
}
diff --git a/cpp/include/IceUtil/UUID.h b/cpp/include/IceUtil/UUID.h
index a1902d120f5..b99fefe66eb 100644
--- a/cpp/include/IceUtil/UUID.h
+++ b/cpp/include/IceUtil/UUID.h
@@ -26,9 +26,13 @@ class ICE_UTIL_API UUIDGenerationException : public Exception
public:
UUIDGenerationException(const char*, int);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual Exception* ice_clone() const;
virtual void ice_throw() const;
+
+private:
+
+ static ::std::string _name;
};
ICE_UTIL_API std::string generateUUID();
diff --git a/cpp/include/IceXML/Parser.h b/cpp/include/IceXML/Parser.h
index 40c29e98ea5..3c2205df153 100644
--- a/cpp/include/IceXML/Parser.h
+++ b/cpp/include/IceXML/Parser.h
@@ -40,7 +40,7 @@ public:
ParserException(const std::string&);
ParserException(const char*, int, const std::string&);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual IceUtil::Exception* ice_clone() const;
virtual void ice_throw() const;
@@ -50,6 +50,7 @@ public:
private:
std::string _reason;
+ static std::string _name;
};
class Node;
diff --git a/cpp/include/Transform/Exception.h b/cpp/include/Transform/Exception.h
index 93cd81c5c31..4a860430730 100644
--- a/cpp/include/Transform/Exception.h
+++ b/cpp/include/Transform/Exception.h
@@ -33,7 +33,7 @@ class TRANSFORM_API TransformException : public IceUtil::Exception
public:
TransformException(const char*, int, const std::string&);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual IceUtil::Exception* ice_clone() const;
virtual void ice_throw() const;
@@ -43,6 +43,7 @@ public:
private:
std::string _reason;
+ static std::string _name;
};
} // End of namespace Transform
diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp
index d77dd20744d..c54efff40b1 100644
--- a/cpp/src/IceUtil/CtrlCHandler.cpp
+++ b/cpp/src/IceUtil/CtrlCHandler.cpp
@@ -33,10 +33,12 @@ CtrlCHandlerException::CtrlCHandlerException(const char* file, int line) :
{
}
-string
+static string ctrlCHandlerName = "IceUtil::CtrlCHandlerException";
+
+const string&
CtrlCHandlerException::ice_name() const
{
- return "IceUtil::CtrlCHandlerException";
+ return ctrlCHandlerName;
}
Exception*
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index c3cf3424053..795b9217b12 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -39,10 +39,12 @@ IceUtil::Exception::~Exception()
{
}
-string
+string IceUtil::Exception::_name = "IceUtil::Exception";
+
+const string&
IceUtil::Exception::ice_name() const
{
- return "IceUtil::Exception";
+ return _name;
}
void
@@ -95,10 +97,12 @@ IceUtil::NullHandleException::NullHandleException(const char* file, int line) :
}
}
-string
+string IceUtil::NullHandleException::_name = "IceUtil::NullHandleException";
+
+const string&
IceUtil::NullHandleException::ice_name() const
{
- return "IceUtil::NullHandleException";
+ return _name;
}
IceUtil::Exception*
diff --git a/cpp/src/IceUtil/ThreadException.cpp b/cpp/src/IceUtil/ThreadException.cpp
index 857fc962987..0cafa6612bd 100644
--- a/cpp/src/IceUtil/ThreadException.cpp
+++ b/cpp/src/IceUtil/ThreadException.cpp
@@ -22,10 +22,12 @@ IceUtil::ThreadSyscallException::ThreadSyscallException(const char* file, int li
{
}
-string
+string IceUtil::ThreadSyscallException::_name = "IceUtil::ThreadSyscallException";
+
+const string&
IceUtil::ThreadSyscallException::ice_name() const
{
- return "IceUtil::ThreadSyscallException";
+ return _name;
}
void
@@ -88,10 +90,12 @@ IceUtil::ThreadLockedException::ThreadLockedException(const char* file, int line
{
}
-string
+string IceUtil::ThreadLockedException::_name = "IceUtil::ThreadLockedException";
+
+const string&
IceUtil::ThreadLockedException::ice_name() const
{
- return "IceUtil::ThreadLockedException";
+ return _name;
}
IceUtil::Exception*
@@ -111,10 +115,12 @@ IceUtil::ThreadStartedException::ThreadStartedException(const char* file, int li
{
}
-string
+string IceUtil::ThreadStartedException::_name = "IceUtil::ThreadStartedException";
+
+const string&
IceUtil::ThreadStartedException::ice_name() const
{
- return "IceUtil::ThreadStartedException";
+ return _name;
}
IceUtil::Exception*
@@ -134,10 +140,12 @@ IceUtil::ThreadNotStartedException::ThreadNotStartedException(const char* file,
{
}
-string
+string IceUtil::ThreadNotStartedException::_name = "IceUtil::ThreadNotStartedException";
+
+const string&
IceUtil::ThreadNotStartedException::ice_name() const
{
- return "IceUtil::ThreadNotStartedException";
+ return _name;
}
IceUtil::Exception*
diff --git a/cpp/src/IceUtil/UUID.cpp b/cpp/src/IceUtil/UUID.cpp
index bcefe9fe008..acdd3af223f 100644
--- a/cpp/src/IceUtil/UUID.cpp
+++ b/cpp/src/IceUtil/UUID.cpp
@@ -59,10 +59,12 @@ IceUtil::UUIDGenerationException::UUIDGenerationException(const char* file, int
{
}
-string
+string IceUtil::UUIDGenerationException::_name = "IceUtil::UUIDGenerationException";
+
+const string&
IceUtil::UUIDGenerationException::ice_name() const
{
- return "IceUtil::UUIDGenerationException";
+ return _name;
}
IceUtil::Exception*
diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp
index f973ef03f27..7231005b74f 100644
--- a/cpp/src/IceXML/Parser.cpp
+++ b/cpp/src/IceXML/Parser.cpp
@@ -33,10 +33,12 @@ IceXML::ParserException::ParserException(const char* file, int line, const strin
{
}
-string
+string IceXML::ParserException::_name = "IceXML::ParserException";
+
+const string&
IceXML::ParserException::ice_name() const
{
- return "IceXML::ParserException";
+ return _name;
}
void
diff --git a/cpp/src/Transform/Exception.cpp b/cpp/src/Transform/Exception.cpp
index 4240f450fb7..e6b030bf178 100644
--- a/cpp/src/Transform/Exception.cpp
+++ b/cpp/src/Transform/Exception.cpp
@@ -24,10 +24,12 @@ Transform::TransformException::TransformException(const char* file, int line, co
{
}
-string
+string Transform::TransformException::_name = "Transform:TransformException";
+
+const string&
Transform::TransformException::ice_name() const
{
- return "Transform::TransformException";
+ return _name;
}
void
diff --git a/cpp/src/Transform/Node.cpp b/cpp/src/Transform/Node.cpp
index 9b37554f172..754d18b29aa 100644
--- a/cpp/src/Transform/Node.cpp
+++ b/cpp/src/Transform/Node.cpp
@@ -75,10 +75,12 @@ Transform::EvaluateException::EvaluateException(const char* file, int line, cons
{
}
-string
+string Transform::EvaluateException::_name = "Transform::EvaluateException";
+
+const string&
Transform::EvaluateException::ice_name() const
{
- return "Transform::EvaluateException";
+ return _name;
}
void
diff --git a/cpp/src/Transform/Node.h b/cpp/src/Transform/Node.h
index dcebd33cdaa..908152f4be4 100644
--- a/cpp/src/Transform/Node.h
+++ b/cpp/src/Transform/Node.h
@@ -31,7 +31,7 @@ class EvaluateException : public IceUtil::Exception
public:
EvaluateException(const char*, int, const std::string&);
- virtual std::string ice_name() const;
+ virtual const std::string& ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual IceUtil::Exception* ice_clone() const;
virtual void ice_throw() const;
@@ -41,6 +41,7 @@ public:
private:
std::string _reason;
+ static std::string _name;
};
class SymbolTable
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 04fc5a890fb..b2b7074b082 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -375,10 +375,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
C << eb;
}
- H << nl << "virtual ::std::string ice_name() const;";
- C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::ice_name() const";
+ H << nl << "virtual const ::std::string& ice_name() const;";
+ C << sp << nl << "::std::string " << scoped.substr(2) << "::_name = \"" << p->scoped().substr(2) << "\";";
+ C << sp << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_name() const";
C << sb;
- C << nl << "return \"" << p->scoped().substr(2) << "\";";
+ C << nl << "return " << scoped.substr(2) << "::_name;";
C << eb;
if(p->isLocal())
@@ -509,6 +510,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << eb << ";";
C << sp << nl << "static __F__" << name << "__Init __F__" << name << "__i;";
}
+
+ H.dec();
+ H << sp << nl << "private:";
+ H.inc();
+ H << sp << nl << "static ::std::string _name;";
+
H << eb << ';';
}
@@ -1985,19 +1992,19 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
C << sp;
C << nl << "void ";
- C << nl << scoped.substr(2) << "::__copyMembers(" << scoped << "Ptr to) const";
+ C << nl << scoped.substr(2) << "::__copyMembers(" << scoped << "Ptr __to) const";
C << sb;
string winUpcall;
string unixUpcall;
if(!bases.empty() && !bases.front()->isInterface())
{
- winUpcall = fixKwd(bases.front()->name()) + "::__copyMembers(to);";
- unixUpcall = fixKwd(bases.front()->scoped()) + "::__copyMembers(to);";
+ winUpcall = fixKwd(bases.front()->name()) + "::__copyMembers(__to);";
+ unixUpcall = fixKwd(bases.front()->scoped()) + "::__copyMembers(__to);";
}
else
{
- winUpcall = "Object::__copyMembers(to);";
- unixUpcall = "::Ice::Object::__copyMembers(to);";
+ winUpcall = "Object::__copyMembers(__to);";
+ unixUpcall = "::Ice::Object::__copyMembers(__to);";
}
C.zeroIndent();
C << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERBUG
@@ -2013,7 +2020,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
DataMemberList dataMembers = p->dataMembers();
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- C << nl << "to->" << (*q)->name() << " = " << (*q)->name() << ";";
+ C << nl << "__to->" << (*q)->name() << " = " << (*q)->name() << ";";
}
C << eb;