summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-11-23 13:41:15 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-11-23 14:04:51 +0100
commit44ea5d14140cccdc77a5fd8e2473804e879880df (patch)
tree77700e8cddf9176d5bc0604336129c76c22bc824 /codemaker
parentae41f950425f8f832e4a41e47c788b45fdbf243b (diff)
Adding SAL_DEPRECATED_INTERNAL to an implementation function is pointless
...as there are typically no direct calls to it anyway. What is apparently needed is to decorate the cppumaker-generated headers instead: * cppumaker obtains deprecation-information from the documentation strings in .rdb files. As these are normally generated by idlc without documentation included (no -C), idlc got changed to nevertheless contain documentation consisting of just "@deprecated" in this case, to allow to easily tunnel this information to cppumaker always. * The mechanism of parsing for "@deprecated" in documentation strings is somewhat crude, of course. * For now, cppumaker only decorates C++ functions that correspond to UNOIDL interface attributes and methods. More should be possible (but, e.g., being able to decorate a complete C++ class corresponding to a deprecated UNOIDL interface type depends on whether all platforms would accept SAL_DEPRECATED_INTERNAL at the same position in a C++ class declaration. * This could also be extended to other languages than C++/cppumaker. * Always using SAL_DEPRECATED_INERNAL instead of SAL_DEPRECATED for decoration is to keep things simple and our codebase working. Improvements are possible here, too, of course. Change-Id: Ia2917892f780d477652e4cd9f286588a6898c3f5
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx35
-rw-r--r--codemaker/source/cppumaker/cpputype.hxx1
2 files changed, 33 insertions, 3 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index eca01435a4e2..149653f2e757 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -1354,6 +1354,22 @@ OString CppuType::indent() const
//*************************************************************************
// InterfaceType
//*************************************************************************
+
+namespace {
+
+bool isDocumentedDeprecated(OUString const & documentation) {
+ return documentation.indexOf("@deprecated") != -1;
+ //TODO: this check is somewhat crude
+}
+
+void dumpDeprecation(FileStream & o, bool deprecated) {
+ if (deprecated) {
+ o << "SAL_DEPRECATED_INTERNAL(\"marked @deprecated in UNOIDL\") ";
+ }
+}
+
+}
+
InterfaceType::InterfaceType(typereg::Reader& typeReader,
const OString& typeName,
const TypeManager& typeMgr)
@@ -1362,6 +1378,7 @@ InterfaceType::InterfaceType(typereg::Reader& typeReader,
m_inheritedMemberCount = 0;
m_hasAttributes = false;
m_hasMethods = false;
+ m_isDeprecated = isDocumentedDeprecated(m_reader.getDocumentation());
}
InterfaceType::~InterfaceType()
@@ -1465,13 +1482,18 @@ void InterfaceType::dumpAttributes(FileStream& o)
fieldType = rtl::OUStringToOString(
m_reader.getFieldTypeName(i), RTL_TEXTENCODING_UTF8);
+ bool depr = m_isDeprecated
+ || isDocumentedDeprecated(m_reader.getFieldDocumentation(i));
+
if (first)
{
first = sal_False;
o << "\n" << indent() << "// Attributes\n";
}
- o << indent() << "virtual ";
+ o << indent();
+ dumpDeprecation(o, depr);
+ o << "virtual ";
dumpType(o, fieldType);
o << " SAL_CALL get" << fieldName << "()";
dumpAttributeExceptionSpecification(o, name, RT_MODE_ATTRIBUTE_GET);
@@ -1480,7 +1502,9 @@ void InterfaceType::dumpAttributes(FileStream& o)
if ((access & RT_ACCESS_READONLY) == 0)
{
bool byRef = passByReference(fieldType);
- o << indent() << "virtual void SAL_CALL set" << fieldName << "( ";
+ o << indent();
+ dumpDeprecation(o, depr);
+ o << "virtual void SAL_CALL set" << fieldName << "( ";
dumpType(o, fieldType, byRef, byRef);
o << " _" << fieldName.toAsciiLowerCase() << " )";
dumpAttributeExceptionSpecification(o, name, RT_MODE_ATTRIBUTE_SET);
@@ -1529,7 +1553,12 @@ void InterfaceType::dumpMethods(FileStream& o)
o << "\n" << indent() << "// Methods\n";
}
- o << indent() << "virtual ";
+ o << indent();
+ dumpDeprecation(
+ o,
+ (m_isDeprecated
+ || isDocumentedDeprecated(m_reader.getMethodDocumentation(i))));
+ o << "virtual ";
dumpType(o, returnType);
o << " SAL_CALL " << methodName << "( ";
for (sal_uInt16 j=0; j < paramCount; j++)
diff --git a/codemaker/source/cppumaker/cpputype.hxx b/codemaker/source/cppumaker/cpputype.hxx
index a2781cba2557..12abd54cf958 100644
--- a/codemaker/source/cppumaker/cpputype.hxx
+++ b/codemaker/source/cppumaker/cpputype.hxx
@@ -191,6 +191,7 @@ protected:
sal_uInt32 m_inheritedMemberCount;
bool m_hasAttributes;
bool m_hasMethods;
+ bool m_isDeprecated;
private:
void dumpExceptionSpecification(