1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_idlc.hxx" 30*cdf0e10cSrcweir #include <idlc/astinterface.hxx> 31*cdf0e10cSrcweir #include <idlc/astattribute.hxx> 32*cdf0e10cSrcweir #include <idlc/astoperation.hxx> 33*cdf0e10cSrcweir #include "idlc/idlc.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "registry/version.h" 36*cdf0e10cSrcweir #include "registry/writer.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir using namespace ::rtl; 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir AstInterface::AstInterface(const ::rtl::OString& name, 41*cdf0e10cSrcweir AstInterface const * pInherits, 42*cdf0e10cSrcweir AstScope* pScope) 43*cdf0e10cSrcweir : AstType(NT_interface, name, pScope) 44*cdf0e10cSrcweir , AstScope(NT_interface) 45*cdf0e10cSrcweir , m_mandatoryInterfaces(0) 46*cdf0e10cSrcweir , m_bIsDefined(false) 47*cdf0e10cSrcweir , m_bForwarded(sal_False) 48*cdf0e10cSrcweir , m_bForwardedInSameFile(sal_False) 49*cdf0e10cSrcweir , m_bSingleInheritance(pInherits != 0) 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir if (pInherits != 0) { 52*cdf0e10cSrcweir addInheritedInterface(pInherits, false, rtl::OUString()); 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir AstInterface::~AstInterface() 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir AstInterface::DoubleDeclarations AstInterface::checkInheritedInterfaceClashes( 61*cdf0e10cSrcweir AstInterface const * ifc, bool optional) const 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir DoubleDeclarations doubleDecls; 64*cdf0e10cSrcweir std::set< rtl::OString > seen; 65*cdf0e10cSrcweir checkInheritedInterfaceClashes( 66*cdf0e10cSrcweir doubleDecls, seen, ifc, true, optional, optional); 67*cdf0e10cSrcweir return doubleDecls; 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir void AstInterface::addInheritedInterface( 71*cdf0e10cSrcweir AstType const * ifc, bool optional, rtl::OUString const & documentation) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir m_inheritedInterfaces.push_back( 74*cdf0e10cSrcweir InheritedInterface(ifc, optional, documentation)); 75*cdf0e10cSrcweir if (!optional) { 76*cdf0e10cSrcweir ++m_mandatoryInterfaces; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir AstInterface const * resolved = resolveInterfaceTypedefs(ifc); 79*cdf0e10cSrcweir addVisibleInterface(resolved, true, optional); 80*cdf0e10cSrcweir if (optional) { 81*cdf0e10cSrcweir addOptionalVisibleMembers(resolved); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir AstInterface::DoubleMemberDeclarations AstInterface::checkMemberClashes( 86*cdf0e10cSrcweir AstDeclaration const * member) const 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir DoubleMemberDeclarations doubleMembers; 89*cdf0e10cSrcweir checkMemberClashes(doubleMembers, member, true); 90*cdf0e10cSrcweir return doubleMembers; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir void AstInterface::addMember(AstDeclaration /*TODO: const*/ * member) { 94*cdf0e10cSrcweir addDeclaration(member); 95*cdf0e10cSrcweir m_visibleMembers.insert( 96*cdf0e10cSrcweir VisibleMembers::value_type( 97*cdf0e10cSrcweir member->getLocalName(), VisibleMember(member))); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir void AstInterface::forwardDefined(AstInterface const & def) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir setImported(def.isImported()); 103*cdf0e10cSrcweir setInMainfile(def.isInMainfile()); 104*cdf0e10cSrcweir setLineNumber(def.getLineNumber()); 105*cdf0e10cSrcweir setFileName(def.getFileName()); 106*cdf0e10cSrcweir setDocumentation(def.getDocumentation()); 107*cdf0e10cSrcweir m_inheritedInterfaces = def.m_inheritedInterfaces; 108*cdf0e10cSrcweir m_mandatoryInterfaces = def.m_mandatoryInterfaces; 109*cdf0e10cSrcweir m_bIsDefined = true; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir sal_Bool AstInterface::dump(RegistryKey& rKey) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir if ( !isDefined() ) 115*cdf0e10cSrcweir return sal_True; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir RegistryKey localKey; 118*cdf0e10cSrcweir if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey)) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n", 121*cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(), 122*cdf0e10cSrcweir getFullName().getStr(), OUStringToOString(rKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr()); 123*cdf0e10cSrcweir return sal_False; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir if (m_mandatoryInterfaces > SAL_MAX_UINT16 127*cdf0e10cSrcweir || m_inheritedInterfaces.size() - m_mandatoryInterfaces 128*cdf0e10cSrcweir > SAL_MAX_UINT16) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir fprintf( 131*cdf0e10cSrcweir stderr, "%s: interface %s has too many direct base interfaces\n", 132*cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(), 133*cdf0e10cSrcweir getScopedName().getStr()); 134*cdf0e10cSrcweir return false; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir sal_uInt16 nBaseTypes = static_cast< sal_uInt16 >(m_mandatoryInterfaces); 137*cdf0e10cSrcweir sal_uInt16 nAttributes = 0; 138*cdf0e10cSrcweir sal_uInt16 nMethods = 0; 139*cdf0e10cSrcweir sal_uInt16 nReferences = static_cast< sal_uInt16 >( 140*cdf0e10cSrcweir m_inheritedInterfaces.size() - m_mandatoryInterfaces); 141*cdf0e10cSrcweir typereg_Version version 142*cdf0e10cSrcweir = (nBaseTypes <= 1 && nReferences == 0 && !m_bPublished 143*cdf0e10cSrcweir ? TYPEREG_VERSION_0 : TYPEREG_VERSION_1); 144*cdf0e10cSrcweir {for (DeclList::const_iterator i(getIteratorBegin()); i != getIteratorEnd(); 145*cdf0e10cSrcweir ++i) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir switch ((*i)->getNodeType()) { 148*cdf0e10cSrcweir case NT_attribute: 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir if (!increment(&nAttributes, "attributes")) { 151*cdf0e10cSrcweir return false; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir // AstAttribute * attr = static_cast< AstAttribute * >(*i); 154*cdf0e10cSrcweir AstAttribute * attr = (AstAttribute *)(*i); 155*cdf0e10cSrcweir if (attr->isBound()) { 156*cdf0e10cSrcweir version = TYPEREG_VERSION_1; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir DeclList::size_type getCount = attr->getGetExceptionCount(); 159*cdf0e10cSrcweir if (getCount > SAL_MAX_UINT16) { 160*cdf0e10cSrcweir fprintf( 161*cdf0e10cSrcweir stderr, 162*cdf0e10cSrcweir ("%s: raises clause of getter for attribute %s of" 163*cdf0e10cSrcweir " interface %s is too long\n"), 164*cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(), 165*cdf0e10cSrcweir (*i)->getLocalName().getStr(), 166*cdf0e10cSrcweir getScopedName().getStr()); 167*cdf0e10cSrcweir return false; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir if (getCount > 0) { 170*cdf0e10cSrcweir version = TYPEREG_VERSION_1; 171*cdf0e10cSrcweir if (!increment(&nMethods, "attributes")) { 172*cdf0e10cSrcweir return false; 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir DeclList::size_type setCount = attr->getSetExceptionCount(); 176*cdf0e10cSrcweir if (setCount > SAL_MAX_UINT16) { 177*cdf0e10cSrcweir fprintf( 178*cdf0e10cSrcweir stderr, 179*cdf0e10cSrcweir ("%s: raises clause of setter for attribute %s of" 180*cdf0e10cSrcweir " interface %s is too long\n"), 181*cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(), 182*cdf0e10cSrcweir (*i)->getLocalName().getStr(), 183*cdf0e10cSrcweir getScopedName().getStr()); 184*cdf0e10cSrcweir return false; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir if (setCount > 0) { 187*cdf0e10cSrcweir version = TYPEREG_VERSION_1; 188*cdf0e10cSrcweir if (!increment(&nMethods, "attributes")) { 189*cdf0e10cSrcweir return false; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir break; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir case NT_operation: 196*cdf0e10cSrcweir if (!increment(&nMethods, "methods")) { 197*cdf0e10cSrcweir return false; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir break; 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir default: 202*cdf0e10cSrcweir OSL_ASSERT(false); 203*cdf0e10cSrcweir break; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir }} 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir OUString emptyStr; 208*cdf0e10cSrcweir typereg::Writer aBlob( 209*cdf0e10cSrcweir version, getDocumentation(), emptyStr, RT_TYPE_INTERFACE, m_bPublished, 210*cdf0e10cSrcweir OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), nBaseTypes, 211*cdf0e10cSrcweir nAttributes, nMethods, nReferences); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir sal_uInt16 superTypeIndex = 0; 214*cdf0e10cSrcweir sal_uInt16 referenceIndex = 0; 215*cdf0e10cSrcweir {for (InheritedInterfaces::iterator i = m_inheritedInterfaces.begin(); 216*cdf0e10cSrcweir i != m_inheritedInterfaces.end(); ++i) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir if (i->isOptional()) { 219*cdf0e10cSrcweir aBlob.setReferenceData( 220*cdf0e10cSrcweir referenceIndex++, i->getDocumentation(), RT_REF_SUPPORTS, 221*cdf0e10cSrcweir RT_ACCESS_OPTIONAL, 222*cdf0e10cSrcweir OStringToOUString( 223*cdf0e10cSrcweir i->getInterface()->getRelativName(), 224*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8)); 225*cdf0e10cSrcweir } else { 226*cdf0e10cSrcweir aBlob.setSuperTypeName( 227*cdf0e10cSrcweir superTypeIndex++, 228*cdf0e10cSrcweir OStringToOUString( 229*cdf0e10cSrcweir i->getInterface()->getRelativName(), 230*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8)); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir }} 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir sal_uInt16 attributeIndex = 0; 235*cdf0e10cSrcweir sal_uInt16 methodIndex = 0; 236*cdf0e10cSrcweir {for (DeclList::const_iterator i(getIteratorBegin()); i != getIteratorEnd(); 237*cdf0e10cSrcweir ++i) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir switch ((*i)->getNodeType()) { 240*cdf0e10cSrcweir case NT_attribute: 241*cdf0e10cSrcweir // static_cast< AstAttribute * >(*i)->dumpBlob( 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir ((AstAttribute *)(*i))->dumpBlob( 244*cdf0e10cSrcweir aBlob, attributeIndex++, &methodIndex); 245*cdf0e10cSrcweir break; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir case NT_operation: 248*cdf0e10cSrcweir // static_cast< AstOperation * >(*i)->dumpBlob(aBlob, methodIndex++); 249*cdf0e10cSrcweir ((AstOperation *)(*i))->dumpBlob(aBlob, methodIndex++); 250*cdf0e10cSrcweir break; 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir default: 253*cdf0e10cSrcweir OSL_ASSERT(false); 254*cdf0e10cSrcweir break; 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir }} 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir sal_uInt32 aBlobSize; 259*cdf0e10cSrcweir void const * pBlob = aBlob.getBlob(&aBlobSize); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, (RegValue)pBlob, aBlobSize)) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", 264*cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(), 265*cdf0e10cSrcweir getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr()); 266*cdf0e10cSrcweir return sal_False; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir return true; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir void AstInterface::checkInheritedInterfaceClashes( 273*cdf0e10cSrcweir DoubleDeclarations & doubleDeclarations, 274*cdf0e10cSrcweir std::set< rtl::OString > & seenInterfaces, AstInterface const * ifc, 275*cdf0e10cSrcweir bool direct, bool optional, bool mainOptional) const 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir if (direct || optional 278*cdf0e10cSrcweir || seenInterfaces.insert(ifc->getScopedName()).second) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir VisibleInterfaces::const_iterator visible( 281*cdf0e10cSrcweir m_visibleInterfaces.find(ifc->getScopedName())); 282*cdf0e10cSrcweir if (visible != m_visibleInterfaces.end()) { 283*cdf0e10cSrcweir switch (visible->second) { 284*cdf0e10cSrcweir case INTERFACE_INDIRECT_OPTIONAL: 285*cdf0e10cSrcweir if (direct && optional) { 286*cdf0e10cSrcweir doubleDeclarations.interfaces.push_back(ifc); 287*cdf0e10cSrcweir return; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir break; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir case INTERFACE_DIRECT_OPTIONAL: 292*cdf0e10cSrcweir if (direct || !mainOptional) { 293*cdf0e10cSrcweir doubleDeclarations.interfaces.push_back(ifc); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir return; 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir case INTERFACE_INDIRECT_MANDATORY: 298*cdf0e10cSrcweir if (direct) { 299*cdf0e10cSrcweir doubleDeclarations.interfaces.push_back(ifc); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir return; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir case INTERFACE_DIRECT_MANDATORY: 304*cdf0e10cSrcweir if (direct || (!optional && !mainOptional)) { 305*cdf0e10cSrcweir doubleDeclarations.interfaces.push_back(ifc); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir return; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir if (direct || !optional) { 311*cdf0e10cSrcweir {for (DeclList::const_iterator i(ifc->getIteratorBegin()); 312*cdf0e10cSrcweir i != ifc->getIteratorEnd(); ++i) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir checkMemberClashes( 315*cdf0e10cSrcweir doubleDeclarations.members, *i, !mainOptional); 316*cdf0e10cSrcweir }} 317*cdf0e10cSrcweir {for (InheritedInterfaces::const_iterator i( 318*cdf0e10cSrcweir ifc->m_inheritedInterfaces.begin()); 319*cdf0e10cSrcweir i != ifc->m_inheritedInterfaces.end(); ++i) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir checkInheritedInterfaceClashes( 322*cdf0e10cSrcweir doubleDeclarations, seenInterfaces, i->getResolved(), 323*cdf0e10cSrcweir false, i->isOptional(), mainOptional); 324*cdf0e10cSrcweir }} 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir void AstInterface::checkMemberClashes( 330*cdf0e10cSrcweir DoubleMemberDeclarations & doubleMembers, AstDeclaration const * member, 331*cdf0e10cSrcweir bool checkOptional) const 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir VisibleMembers::const_iterator i( 334*cdf0e10cSrcweir m_visibleMembers.find(member->getLocalName())); 335*cdf0e10cSrcweir if (i != m_visibleMembers.end()) { 336*cdf0e10cSrcweir if (i->second.mandatory != 0) { 337*cdf0e10cSrcweir if (i->second.mandatory->getScopedName() != member->getScopedName()) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir DoubleMemberDeclaration d; 340*cdf0e10cSrcweir d.first = i->second.mandatory; 341*cdf0e10cSrcweir d.second = member; 342*cdf0e10cSrcweir doubleMembers.push_back(d); 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir } else if (checkOptional) { 345*cdf0e10cSrcweir for (VisibleMember::Optionals::const_iterator j( 346*cdf0e10cSrcweir i->second.optionals.begin()); 347*cdf0e10cSrcweir j != i->second.optionals.end(); ++j) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir if (j->second->getScopedName() != member->getScopedName()) { 350*cdf0e10cSrcweir DoubleMemberDeclaration d; 351*cdf0e10cSrcweir d.first = j->second; 352*cdf0e10cSrcweir d.second = member; 353*cdf0e10cSrcweir doubleMembers.push_back(d); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir void AstInterface::addVisibleInterface( 361*cdf0e10cSrcweir AstInterface const * ifc, bool direct, bool optional) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir InterfaceKind kind = optional 364*cdf0e10cSrcweir ? direct ? INTERFACE_DIRECT_OPTIONAL : INTERFACE_INDIRECT_OPTIONAL 365*cdf0e10cSrcweir : direct ? INTERFACE_DIRECT_MANDATORY : INTERFACE_INDIRECT_MANDATORY; 366*cdf0e10cSrcweir std::pair< VisibleInterfaces::iterator, bool > result( 367*cdf0e10cSrcweir m_visibleInterfaces.insert( 368*cdf0e10cSrcweir VisibleInterfaces::value_type(ifc->getScopedName(), kind))); 369*cdf0e10cSrcweir bool seen = !result.second 370*cdf0e10cSrcweir && result.first->second >= INTERFACE_INDIRECT_MANDATORY; 371*cdf0e10cSrcweir if (!result.second && kind > result.first->second) { 372*cdf0e10cSrcweir result.first->second = kind; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir if (!optional && !seen) { 375*cdf0e10cSrcweir {for (DeclList::const_iterator i(ifc->getIteratorBegin()); 376*cdf0e10cSrcweir i != ifc->getIteratorEnd(); ++i) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir m_visibleMembers.insert( 379*cdf0e10cSrcweir VisibleMembers::value_type( 380*cdf0e10cSrcweir (*i)->getLocalName(), VisibleMember(*i))); 381*cdf0e10cSrcweir }} 382*cdf0e10cSrcweir {for (InheritedInterfaces::const_iterator i( 383*cdf0e10cSrcweir ifc->m_inheritedInterfaces.begin()); 384*cdf0e10cSrcweir i != ifc->m_inheritedInterfaces.end(); ++i) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir addVisibleInterface(i->getResolved(), false, i->isOptional()); 387*cdf0e10cSrcweir }} 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void AstInterface::addOptionalVisibleMembers(AstInterface const * ifc) { 392*cdf0e10cSrcweir {for (DeclList::const_iterator i(ifc->getIteratorBegin()); 393*cdf0e10cSrcweir i != ifc->getIteratorEnd(); ++i) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir VisibleMembers::iterator visible( 396*cdf0e10cSrcweir m_visibleMembers.find((*i)->getLocalName())); 397*cdf0e10cSrcweir if (visible == m_visibleMembers.end()) { 398*cdf0e10cSrcweir visible = m_visibleMembers.insert( 399*cdf0e10cSrcweir VisibleMembers::value_type( 400*cdf0e10cSrcweir (*i)->getLocalName(), VisibleMember())).first; 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir if (visible->second.mandatory == 0) { 403*cdf0e10cSrcweir visible->second.optionals.insert( 404*cdf0e10cSrcweir VisibleMember::Optionals::value_type(ifc->getScopedName(), *i)); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir }} 407*cdf0e10cSrcweir {for (InheritedInterfaces::const_iterator i( 408*cdf0e10cSrcweir ifc->m_inheritedInterfaces.begin()); 409*cdf0e10cSrcweir i != ifc->m_inheritedInterfaces.end(); ++i) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir if (!i->isOptional()) { 412*cdf0e10cSrcweir addOptionalVisibleMembers(i->getResolved()); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir }} 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir bool AstInterface::increment(sal_uInt16 * counter, char const * sort) const { 418*cdf0e10cSrcweir if (*counter == SAL_MAX_UINT16) { 419*cdf0e10cSrcweir fprintf( 420*cdf0e10cSrcweir stderr, "%s: interface %s has too many direct %s\n", 421*cdf0e10cSrcweir idlc()->getOptions()->getProgramName().getStr(), 422*cdf0e10cSrcweir getScopedName().getStr(), sort); 423*cdf0e10cSrcweir return false; 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir ++*counter; 426*cdf0e10cSrcweir return true; 427*cdf0e10cSrcweir } 428