diff options
Diffstat (limited to 'idlc')
-rw-r--r-- | idlc/source/astdeclaration.cxx | 51 | ||||
-rw-r--r-- | idlc/source/astenum.cxx | 60 | ||||
-rw-r--r-- | idlc/source/astscope.cxx | 51 | ||||
-rw-r--r-- | idlc/source/options.cxx | 74 |
4 files changed, 117 insertions, 119 deletions
diff --git a/idlc/source/astdeclaration.cxx b/idlc/source/astdeclaration.cxx index 58939868aac3..8ef76cc1f50e 100644 --- a/idlc/source/astdeclaration.cxx +++ b/idlc/source/astdeclaration.cxx @@ -125,38 +125,37 @@ bool AstDeclaration::hasAncestor(AstDeclaration* pDecl) bool AstDeclaration::dump(RegistryKey& rKey) { AstScope* pScope = declAsScope(this); - bool bRet = true; + if ( !pScope ) + return true; - if ( pScope ) + bool bRet = true; + DeclList::const_iterator iter = pScope->getIteratorBegin(); + DeclList::const_iterator end = pScope->getIteratorEnd(); + AstDeclaration* pDecl = nullptr; + while ( iter != end && bRet) { - DeclList::const_iterator iter = pScope->getIteratorBegin(); - DeclList::const_iterator end = pScope->getIteratorEnd(); - AstDeclaration* pDecl = nullptr; - while ( iter != end && bRet) + pDecl = *iter; + if ( pDecl->isInMainfile() ) { - pDecl = *iter; - if ( pDecl->isInMainfile() ) + switch ( pDecl->getNodeType() ) { - switch ( pDecl->getNodeType() ) - { - case NT_module: - case NT_constants: - case NT_interface: - case NT_struct: - case NT_exception: - case NT_enum: - case NT_typedef: - case NT_service: - case NT_singleton: - bRet = pDecl->dump(rKey); - break; - default: - break; - } + case NT_module: + case NT_constants: + case NT_interface: + case NT_struct: + case NT_exception: + case NT_enum: + case NT_typedef: + case NT_service: + case NT_singleton: + bRet = pDecl->dump(rKey); + break; + default: + break; } - - ++iter; } + + ++iter; } return bRet; } diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx index 54324337de6d..7dff49d36c06 100644 --- a/idlc/source/astenum.cxx +++ b/idlc/source/astenum.cxx @@ -66,37 +66,37 @@ bool AstEnum::dump(RegistryKey& rKey) } sal_uInt16 nConst = getNodeCount(NT_enum_val); - if ( nConst > 0 ) + if ( nConst <= 0 ) + return true; + + typereg::Writer aBlob( + m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0, + getDocumentation(), "", RT_TYPE_ENUM, m_bPublished, + OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0, + nConst, 0, 0); + + DeclList::const_iterator iter = getIteratorBegin(); + DeclList::const_iterator end = getIteratorEnd(); + sal_uInt16 index = 0; + while ( iter != end ) { - typereg::Writer aBlob( - m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0, - getDocumentation(), "", RT_TYPE_ENUM, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0, - nConst, 0, 0); - - DeclList::const_iterator iter = getIteratorBegin(); - DeclList::const_iterator end = getIteratorEnd(); - sal_uInt16 index = 0; - while ( iter != end ) - { - AstDeclaration* pDecl = *iter; - if ( pDecl->getNodeType() == NT_enum_val ) - static_cast<AstConstant*>(pDecl)->dumpBlob(aBlob, index++, false); - - ++iter; - } - - sal_uInt32 aBlobSize; - void const * pBlob = aBlob.getBlob(&aBlobSize); - - if (localKey.setValue("", RegValueType::BINARY, - const_cast<RegValue>(pBlob), aBlobSize) != RegError::NO_ERROR) - { - fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", - idlc()->getOptions()->getProgramName().getStr(), - getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr()); - return false; - } + AstDeclaration* pDecl = *iter; + if ( pDecl->getNodeType() == NT_enum_val ) + static_cast<AstConstant*>(pDecl)->dumpBlob(aBlob, index++, false); + + ++iter; + } + + sal_uInt32 aBlobSize; + void const * pBlob = aBlob.getBlob(&aBlobSize); + + if (localKey.setValue("", RegValueType::BINARY, + const_cast<RegValue>(pBlob), aBlobSize) != RegError::NO_ERROR) + { + fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", + idlc()->getOptions()->getProgramName().getStr(), + getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr()); + return false; } return true; diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx index ca6214129c87..0795df6eeb2c 100644 --- a/idlc/source/astscope.cxx +++ b/idlc/source/astscope.cxx @@ -151,37 +151,36 @@ AstDeclaration* AstScope::lookupByName(const OString& scopedName) } } - if ( bFindFirstScope && (firstScope != scopedName) ) + if ( !bFindFirstScope || (firstScope == scopedName) ) + return pDecl; + + sal_Int32 i = 0; + sal_Int32 nOffset = 2; + do { - sal_Int32 i = 0; - sal_Int32 nOffset = 2; - do + pScope = declAsScope(pDecl); + if( pScope ) { - pScope = declAsScope(pDecl); - if( pScope ) - { - pDecl = pScope->lookupByNameLocal(scopedName.getToken(nOffset, ':', i )); - nOffset = 1; - } - if( !pDecl ) - break; - } while( i != -1 ); + pDecl = pScope->lookupByNameLocal(scopedName.getToken(nOffset, ':', i )); + nOffset = 1; + } + if( !pDecl ) + break; + } while( i != -1 ); - if ( !pDecl ) + if ( !pDecl ) + { + // last try if is not the global scope and the scopeName isn't specify global too + pDecl = scopeAsDecl(this); + if ( pDecl && !pDecl->getLocalName().isEmpty() ) { - // last try if is not the global scope and the scopeName isn't specify global too - pDecl = scopeAsDecl(this); - if ( pDecl && !pDecl->getLocalName().isEmpty() ) - { - pScope = pDecl->getScope(); - if ( pScope ) - pDecl = pScope->lookupByName(scopedName); - } else - { - pDecl = nullptr; - } + pScope = pDecl->getScope(); + if ( pScope ) + pDecl = pScope->lookupByName(scopedName); + } else + { + pDecl = nullptr; } - } return pDecl; diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index 2418e13afdf0..9f020777d54d 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -56,53 +56,53 @@ bool Options::checkArgument (std::vector< std::string > & rArgs, char const * ar { bool result = ((arg != nullptr) && (len > 0)); OSL_PRECOND(result, "idlc::Options::checkArgument(): invalid arguments"); - if (result) + if (!result) + return false; + + switch(arg[0]) { - switch(arg[0]) + case '@': + result = len > 1; + if (result) { - case '@': - result = len > 1; - if (result) - { - // "@<cmdfile>" - result = Options::checkCommandFile (rArgs, &(arg[1])); - } - break; - case '-': - result = len > 1; - if (result) + // "@<cmdfile>" + result = Options::checkCommandFile (rArgs, &(arg[1])); + } + break; + case '-': + result = len > 1; + if (result) + { + // "-<option>" + switch (arg[1]) { - // "-<option>" - switch (arg[1]) + case 'O': + case 'M': + case 'I': + case 'D': { - case 'O': - case 'M': - case 'I': - case 'D': + // "-<option>[<param>] + std::string option(&(arg[0]), 2); + rArgs.push_back(option); + if (len > 2) { - // "-<option>[<param>] - std::string option(&(arg[0]), 2); - rArgs.push_back(option); - if (len > 2) - { - // "-<option><param>" - std::string param(&(arg[2]), len - 2); - rArgs.push_back(param); - } - break; + // "-<option><param>" + std::string param(&(arg[2]), len - 2); + rArgs.push_back(param); } - default: - // "-<option>" ([long] option, w/o param) - rArgs.emplace_back(arg, len); break; } + default: + // "-<option>" ([long] option, w/o param) + rArgs.emplace_back(arg, len); + break; } - break; - default: - // "<param>" - rArgs.emplace_back(arg, len); - break; } + break; + default: + // "<param>" + rArgs.emplace_back(arg, len); + break; } return result; } |