From 44ea5d14140cccdc77a5fd8e2473804e879880df Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 23 Nov 2012 13:41:15 +0100 Subject: 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 --- idlc/inc/idlc/idlc.hxx | 2 +- idlc/source/astdeclaration.cxx | 3 +-- idlc/source/idlc.cxx | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'idlc') diff --git a/idlc/inc/idlc/idlc.hxx b/idlc/inc/idlc/idlc.hxx index df110603425f..30f54362b4bf 100644 --- a/idlc/inc/idlc/idlc.hxx +++ b/idlc/inc/idlc/idlc.hxx @@ -78,7 +78,7 @@ public: m_documentation = documentation; m_bIsDocValid = sal_True; } - sal_Bool isDocValid(); + OUString processDocumentation(); sal_Bool isInMainFile() { return m_bIsInMainfile; } void setInMainfile(sal_Bool bInMainfile) diff --git a/idlc/source/astdeclaration.cxx b/idlc/source/astdeclaration.cxx index 7a1bf314b3ed..ef0996323153 100644 --- a/idlc/source/astdeclaration.cxx +++ b/idlc/source/astdeclaration.cxx @@ -76,8 +76,7 @@ AstDeclaration::AstDeclaration(NodeType type, const OString& name, AstScope* pSc m_bImported = sal_True; } - if ( idlc()->isDocValid() ) - m_documentation = OStringToOUString(idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8); + m_documentation = idlc()->processDocumentation(); m_bPublished = idlc()->isPublished(); } diff --git a/idlc/source/idlc.cxx b/idlc/source/idlc.cxx index a064e7b1d4a3..895a54554ff6 100644 --- a/idlc/source/idlc.cxx +++ b/idlc/source/idlc.cxx @@ -274,11 +274,19 @@ void Idlc::reset() m_includes.clear(); } -sal_Bool Idlc::isDocValid() +OUString Idlc::processDocumentation() { - if ( m_bGenerateDoc ) - return m_bIsDocValid; - return sal_False;; + OUString doc; + if (m_bIsDocValid) { + OString raw(getDocumentation()); + if (m_bGenerateDoc) { + doc = OStringToOUString(raw, RTL_TEXTENCODING_UTF8); + } else if (raw.indexOf("@deprecated") != -1) { + //TODO: this check is somewhat crude + doc = "@deprecated"; + } + } + return doc; } static void lcl_writeString(::osl::File & rFile, ::osl::FileBase::RC & o_rRC, -- cgit