1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fehelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_idlc.hxx"
33 #include <idlc/fehelper.hxx>
34 #include <idlc/errorhandler.hxx>
35 #include <idlc/astarray.hxx>
36 #include "idlc/idlc.hxx"
38 using namespace ::rtl
;
40 FeDeclarator::FeDeclarator(const OString
& name
, DeclaratorType declType
, AstDeclaration
* pComplPart
)
41 : m_pComplexPart(pComplPart
)
43 , m_declType(declType
)
47 FeDeclarator::~FeDeclarator()
51 sal_Bool
FeDeclarator::checkType(AstDeclaration
const * type
)
54 sal_Int32 count
= m_name
.lastIndexOf( ':' );
56 tmp
= m_name
.copy( count
+1 );
58 if (tmp
== type
->getLocalName())
64 AstType
const * FeDeclarator::compose(AstDeclaration
const * pDecl
)
73 if ( !pDecl
->isType() )
75 idlc()->error()->noTypeError(pDecl
);
78 pType
= (AstType
*)pDecl
;
79 if (m_declType
== FD_simple
|| m_pComplexPart
== NULL
)
82 if (m_pComplexPart
->getNodeType() == NT_array
)
84 pArray
= (AstArray
*)m_pComplexPart
;
85 pArray
->setType(pType
);
87 // insert array type in global scope
88 AstScope
* pScope
= idlc()->scopes()->bottom();
91 AstDeclaration
* pDecl2
= pScope
->addDeclaration(pArray
);
92 if ( (AstDeclaration
*)pArray
!= pDecl2
)
94 delete m_pComplexPart
;
95 m_pComplexPart
= pDecl2
;
101 return NULL
; // return through this statement should not happen
104 FeInheritanceHeader::FeInheritanceHeader(
105 NodeType nodeType
, ::rtl::OString
* pName
, ::rtl::OString
* pInherits
,
106 std::vector
< rtl::OString
> * typeParameters
)
107 : m_nodeType(nodeType
)
111 if (typeParameters
!= 0) {
112 m_typeParameters
= *typeParameters
;
114 initializeInherits(pInherits
);
117 void FeInheritanceHeader::initializeInherits(::rtl::OString
* pInherits
)
121 AstScope
* pScope
= idlc()->scopes()->topNonNull();
122 AstDeclaration
* pDecl
= pScope
->lookupByName(*pInherits
);
125 AstDeclaration
const * resolved
= resolveTypedefs(pDecl
);
126 if ( resolved
->getNodeType() == getNodeType()
127 && (resolved
->getNodeType() != NT_interface
128 || static_cast< AstInterface
const * >(
129 resolved
)->isDefined()) )
131 if ( idlc()->error()->checkPublished( pDecl
) )
138 idlc()->error()->inheritanceError(
139 getNodeType(), getName(), pDecl
);
144 idlc()->error()->lookupError(*pInherits
);