Kaydet (Commit) 0295bd6b authored tarafından Thorsten Behrens's avatar Thorsten Behrens

Remove exception spec from idl-generated c++ headers.

The general agreement in the project is that c++ exception
specs are pointless and add bloat in production code.

See also this rant for more background:
  http://drdobbs.com/cpp/184401544

This removes the code that generates the exception specs on the
generated c++ headers, and fixes up the few places that broke
subsequently because of widening exception specs, which in turn
was due to the rather unfortunate decision to not have a virtual
dtor in XInterface.

Change-Id: I60db26e1cc4d4fe6eeef5975e39497841e92588a
üst 2e1ab301
...@@ -268,7 +268,7 @@ void CppuType::dumpGetCppuTypePostamble(FileStream & out) { ...@@ -268,7 +268,7 @@ void CppuType::dumpGetCppuTypePostamble(FileStream & out) {
" getCppuType(SAL_UNUSED_PARAMETER "); " getCppuType(SAL_UNUSED_PARAMETER ");
dumpType(out, m_typeName); dumpType(out, m_typeName);
dumpTemplateParameters(out); dumpTemplateParameters(out);
out << " const *) SAL_THROW(()) {\n"; out << " const *) { // throw()\n";
inc(); inc();
out << indent() << "return ::cppu::UnoType< "; out << indent() << "return ::cppu::UnoType< ";
dumpType(out, m_typeName); dumpType(out, m_typeName);
...@@ -537,7 +537,7 @@ void CppuType::dumpHFileContent( ...@@ -537,7 +537,7 @@ void CppuType::dumpHFileContent(
out << "inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType("; out << "inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType(";
dumpType(out, m_typeName, true); dumpType(out, m_typeName, true);
dumpTemplateParameters(out); dumpTemplateParameters(out);
out << " *) SAL_THROW(());\n\n#endif\n"; out << " *); // throw()\n\n#endif\n";
} }
void CppuType::dumpGetCppuType(FileStream & out) { void CppuType::dumpGetCppuType(FileStream & out) {
...@@ -546,7 +546,7 @@ void CppuType::dumpGetCppuType(FileStream & out) { ...@@ -546,7 +546,7 @@ void CppuType::dumpGetCppuType(FileStream & out) {
<< ("inline ::com::sun::star::uno::Type const & SAL_CALL" << ("inline ::com::sun::star::uno::Type const & SAL_CALL"
" getCppuType(SAL_UNUSED_PARAMETER "); " getCppuType(SAL_UNUSED_PARAMETER ");
dumpType(out, m_typeName, true, false); dumpType(out, m_typeName, true, false);
out << " *) SAL_THROW(()) {\n"; out << " *) { // throw()\n";
inc(); inc();
out << indent() out << indent()
<< ("return ::cppu::UnoType< ::com::sun::star::uno::XInterface" << ("return ::cppu::UnoType< ::com::sun::star::uno::XInterface"
...@@ -558,7 +558,7 @@ void CppuType::dumpGetCppuType(FileStream & out) { ...@@ -558,7 +558,7 @@ void CppuType::dumpGetCppuType(FileStream & out) {
<< ("inline ::com::sun::star::uno::Type const & SAL_CALL" << ("inline ::com::sun::star::uno::Type const & SAL_CALL"
" getCppuType(SAL_UNUSED_PARAMETER "); " getCppuType(SAL_UNUSED_PARAMETER ");
dumpType(out, m_typeName, true, false); dumpType(out, m_typeName, true, false);
out << " *) SAL_THROW(()) {\n"; out << " *) { // throw()\n";
inc(); inc();
out << indent() out << indent()
<< ("return ::cppu::UnoType< ::com::sun::star::uno::Exception" << ("return ::cppu::UnoType< ::com::sun::star::uno::Exception"
...@@ -1426,7 +1426,7 @@ void InterfaceType::dumpDeclaration(FileStream& o) ...@@ -1426,7 +1426,7 @@ void InterfaceType::dumpDeclaration(FileStream& o)
o << "protected:\n"; o << "protected:\n";
inc(); inc();
o << indent() << "~" << m_name o << indent() << "~" << m_name
<< ("() throw () {} // avoid warnings about virtual members and" << ("() {} // nothrow(); avoid warnings about virtual members and"
" non-virtual dtor\n"); " non-virtual dtor\n");
dec(); dec();
o << "};\n\n"; o << "};\n\n";
...@@ -1496,7 +1496,6 @@ void InterfaceType::dumpAttributes(FileStream& o) ...@@ -1496,7 +1496,6 @@ void InterfaceType::dumpAttributes(FileStream& o)
o << "virtual "; o << "virtual ";
dumpType(o, fieldType); dumpType(o, fieldType);
o << " SAL_CALL get" << fieldName << "()"; o << " SAL_CALL get" << fieldName << "()";
dumpAttributeExceptionSpecification(o, name, RT_MODE_ATTRIBUTE_GET);
o << " = 0;\n"; o << " = 0;\n";
if ((access & RT_ACCESS_READONLY) == 0) if ((access & RT_ACCESS_READONLY) == 0)
...@@ -1507,7 +1506,6 @@ void InterfaceType::dumpAttributes(FileStream& o) ...@@ -1507,7 +1506,6 @@ void InterfaceType::dumpAttributes(FileStream& o)
o << "virtual void SAL_CALL set" << fieldName << "( "; o << "virtual void SAL_CALL set" << fieldName << "( ";
dumpType(o, fieldType, byRef, byRef); dumpType(o, fieldType, byRef, byRef);
o << " _" << fieldName.toAsciiLowerCase() << " )"; o << " _" << fieldName.toAsciiLowerCase() << " )";
dumpAttributeExceptionSpecification(o, name, RT_MODE_ATTRIBUTE_SET);
o << " = 0;\n"; o << " = 0;\n";
} }
} }
...@@ -1593,7 +1591,6 @@ void InterfaceType::dumpMethods(FileStream& o) ...@@ -1593,7 +1591,6 @@ void InterfaceType::dumpMethods(FileStream& o)
if (j+1 < (sal_uInt16)paramCount) o << ", "; if (j+1 < (sal_uInt16)paramCount) o << ", ";
} }
o << " )"; o << " )";
dumpExceptionSpecification(o, i, bWithRunTimeExcp);
o << " = 0;\n"; o << " = 0;\n";
} }
} }
...@@ -2223,53 +2220,6 @@ void InterfaceType::dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes ...@@ -2223,53 +2220,6 @@ void InterfaceType::dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes
} }
} }
void InterfaceType::dumpExceptionSpecification(
FileStream & out, sal_uInt32 methodIndex, bool runtimeException)
{
out << " throw (";
bool first = true;
if (methodIndex <= SAL_MAX_UINT16) {
sal_uInt16 count = m_reader.getMethodExceptionCount(
static_cast< sal_uInt16 >(methodIndex));
for (sal_uInt16 i = 0; i < count; ++i) {
rtl::OUString name(
m_reader.getMethodExceptionTypeName(
static_cast< sal_uInt16 >(methodIndex), i));
if ( name != "com/sun/star/uno/RuntimeException" )
{
if (!first) {
out << ", ";
}
first = false;
out << scopedCppName(
rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8));
}
}
}
if (runtimeException) {
if (!first) {
out << ", ";
}
out << "::com::sun::star::uno::RuntimeException";
}
out << ")";
}
void InterfaceType::dumpAttributeExceptionSpecification(
FileStream & out, rtl::OUString const & name, RTMethodMode sort)
{
sal_uInt16 methodCount = m_reader.getMethodCount();
for (sal_uInt16 i = 0; i < methodCount; ++i) {
if (m_reader.getMethodFlags(i) == sort
&& m_reader.getMethodName(i) == name)
{
dumpExceptionSpecification(out, i, true);
return;
}
}
dumpExceptionSpecification(out, 0xFFFFFFFF, true);
}
void InterfaceType::dumpExceptionTypeName( void InterfaceType::dumpExceptionTypeName(
FileStream & out, char const * prefix, sal_uInt32 index, rtl::OUString name) FileStream & out, char const * prefix, sal_uInt32 index, rtl::OUString name)
{ {
...@@ -2528,7 +2478,7 @@ void StructureType::dumpDeclaration(FileStream& o) ...@@ -2528,7 +2478,7 @@ void StructureType::dumpDeclaration(FileStream& o)
} }
o << " {\n"; o << " {\n";
inc(); inc();
o << indent() << "inline " << m_name << "() SAL_THROW(());\n"; o << indent() << "inline " << m_name << "(); // throw()\n";
sal_uInt16 members = m_reader.getFieldCount(); sal_uInt16 members = m_reader.getFieldCount();
if (members > 0 || getInheritedMemberCount() > 0) { if (members > 0 || getInheritedMemberCount() > 0) {
o << "\n" << indent() << "inline " << m_name << "("; o << "\n" << indent() << "inline " << m_name << "(";
...@@ -2553,7 +2503,7 @@ void StructureType::dumpDeclaration(FileStream& o) ...@@ -2553,7 +2503,7 @@ void StructureType::dumpDeclaration(FileStream& o)
m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8) m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8)
<< "_"; << "_";
} }
o << ") SAL_THROW(());\n"; o << "); // throw()\n";
} }
if (members > 0) { if (members > 0) {
o << "\n"; o << "\n";
...@@ -2608,7 +2558,7 @@ sal_Bool StructureType::dumpHxxFile( ...@@ -2608,7 +2558,7 @@ sal_Bool StructureType::dumpHxxFile(
dumpTemplateHead(o); dumpTemplateHead(o);
o << "inline " << m_name; o << "inline " << m_name;
dumpTemplateParameters(o); dumpTemplateParameters(o);
o << "::" << m_name << "() SAL_THROW(())\n"; o << "::" << m_name << "() // throw()\n";
inc(); inc();
OString superType; OString superType;
if (m_reader.getSuperTypeCount() >= 1) { if (m_reader.getSuperTypeCount() >= 1) {
...@@ -2688,7 +2638,7 @@ sal_Bool StructureType::dumpHxxFile( ...@@ -2688,7 +2638,7 @@ sal_Bool StructureType::dumpHxxFile(
// o << " __" << fieldName; // o << " __" << fieldName;
o << " " << fieldName << "_"; o << " " << fieldName << "_";
} }
o << ") SAL_THROW(())\n"; o << ") // throw()\n";
inc(); inc();
first = sal_True; first = sal_True;
...@@ -2754,7 +2704,7 @@ sal_Bool StructureType::dumpHxxFile( ...@@ -2754,7 +2704,7 @@ sal_Bool StructureType::dumpHxxFile(
m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8) m_reader.getFieldName(i), RTL_TEXTENCODING_UTF8)
<< "_"; << "_";
} }
o << ") SAL_THROW(())\n"; o << ") // throw()\n";
o << indent() << "{\n"; o << indent() << "{\n";
inc(); inc();
o << indent() << "return " << m_name; o << indent() << "return " << m_name;
...@@ -3274,7 +3224,7 @@ void ExceptionType::dumpDeclaration(FileStream& o) ...@@ -3274,7 +3224,7 @@ void ExceptionType::dumpDeclaration(FileStream& o)
o << "\n{\npublic:\n"; o << "\n{\npublic:\n";
inc(); inc();
o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name
<< "() SAL_THROW(());\n\n"; << "(); // throw()\n\n";
sal_uInt16 fieldCount = m_reader.getFieldCount(); sal_uInt16 fieldCount = m_reader.getFieldCount();
RTFieldAccess access = RT_ACCESS_INVALID; RTFieldAccess access = RT_ACCESS_INVALID;
...@@ -3309,7 +3259,7 @@ void ExceptionType::dumpDeclaration(FileStream& o) ...@@ -3309,7 +3259,7 @@ void ExceptionType::dumpDeclaration(FileStream& o)
// o << " __" << fieldName; // o << " __" << fieldName;
o << " " << fieldName << "_"; o << " " << fieldName << "_";
} }
o << ") SAL_THROW(());\n\n"; o << "); // throw()\n\n";
} }
o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name << "(" << m_name o << indent() << "inline CPPU_GCC_DLLPRIVATE " << m_name << "(" << m_name
<< " const &);\n\n" << " const &);\n\n"
...@@ -3361,7 +3311,7 @@ sal_Bool ExceptionType::dumpHxxFile( ...@@ -3361,7 +3311,7 @@ sal_Bool ExceptionType::dumpHxxFile(
} }
o << "\n"; o << "\n";
o << "inline " << m_name << "::" << m_name << "() SAL_THROW(())\n"; o << "inline " << m_name << "::" << m_name << "() // throw()\n";
inc(); inc();
OString superType; OString superType;
if (m_reader.getSuperTypeCount() >= 1) { if (m_reader.getSuperTypeCount() >= 1) {
...@@ -3441,7 +3391,7 @@ sal_Bool ExceptionType::dumpHxxFile( ...@@ -3441,7 +3391,7 @@ sal_Bool ExceptionType::dumpHxxFile(
// o << " __" << fieldName; // o << " __" << fieldName;
o << " " << fieldName << "_"; o << " " << fieldName << "_";
} }
o << ") SAL_THROW(())\n"; o << ") // throw()\n";
inc(); inc();
first = sal_True; first = sal_True;
......
...@@ -194,12 +194,6 @@ protected: ...@@ -194,12 +194,6 @@ protected:
bool m_isDeprecated; bool m_isDeprecated;
private: private:
void dumpExceptionSpecification(
FileStream & out, sal_uInt32 methodIndex, bool runtimeException);
void dumpAttributeExceptionSpecification(
FileStream & out, rtl::OUString const & name, RTMethodMode sort);
void dumpExceptionTypeName( void dumpExceptionTypeName(
FileStream & out, char const * prefix, sal_uInt32 index, FileStream & out, char const * prefix, sal_uInt32 index,
rtl::OUString name); rtl::OUString name);
......
...@@ -90,7 +90,7 @@ SAL_WNODEPRECATED_DECLARATIONS_POP ...@@ -90,7 +90,7 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
ChildWindowPane::~ChildWindowPane (void) throw() ChildWindowPane::~ChildWindowPane (void)
{ {
} }
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
sal_uInt16 nChildWindowId, sal_uInt16 nChildWindowId,
ViewShellBase& rViewShellBase, ViewShellBase& rViewShellBase,
::std::auto_ptr<SfxShell> pShell); ::std::auto_ptr<SfxShell> pShell);
virtual ~ChildWindowPane (void) throw(); virtual ~ChildWindowPane (void);
/** Hide the pane. To make the pane visible again, call GetWindow(). /** Hide the pane. To make the pane visible again, call GetWindow().
*/ */
......
...@@ -49,7 +49,7 @@ Pane::Pane ( ...@@ -49,7 +49,7 @@ Pane::Pane (
Pane::~Pane (void) throw() Pane::~Pane (void)
{ {
} }
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
com::sun::star::drawing::framework::XResourceId>& rxPaneId, com::sun::star::drawing::framework::XResourceId>& rxPaneId,
::Window* pWindow) ::Window* pWindow)
throw (); throw ();
virtual ~Pane (void) throw(); virtual ~Pane (void);
virtual void SAL_CALL disposing (void); virtual void SAL_CALL disposing (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment