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: astoperation.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/astoperation.hxx>
34 #include <idlc/asttype.hxx>
35 #include <idlc/astbasetype.hxx>
36 #include <idlc/astparameter.hxx>
37 #include <idlc/errorhandler.hxx>
39 #include "registry/writer.hxx"
41 using namespace ::rtl
;
43 void AstOperation::setExceptions(DeclList
const * pExceptions
)
45 if (pExceptions
!= 0) {
47 idlc()->error()->error1(EIDL_ONEWAY_RAISE_CONFLICT
, this);
49 m_exceptions
= *pExceptions
;
53 bool AstOperation::isVariadic() const {
54 DeclList::const_iterator
i(getIteratorEnd());
55 return i
!= getIteratorBegin()
56 && static_cast< AstParameter
const * >(*(--i
))->isRest();
59 sal_Bool
AstOperation::dumpBlob(typereg::Writer
& rBlob
, sal_uInt16 index
)
61 sal_uInt16 nParam
= getNodeCount(NT_parameter
);
62 sal_uInt16 nExcep
= nExceptions();
63 RTMethodMode methodMode
= RT_MODE_TWOWAY
;
66 methodMode
= RT_MODE_ONEWAY
;
68 rtl::OUString returnTypeName
;
69 if (m_pReturnType
== 0) {
70 returnTypeName
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("void"));
72 returnTypeName
= rtl::OStringToOUString(
73 m_pReturnType
->getRelativName(), RTL_TEXTENCODING_UTF8
);
76 index
, getDocumentation(), methodMode
,
77 OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8
),
78 returnTypeName
, nParam
, nExcep
);
82 DeclList::const_iterator iter
= getIteratorBegin();
83 DeclList::const_iterator end
= getIteratorEnd();
84 AstDeclaration
* pDecl
= NULL
;
85 RTParamMode paramMode
;
86 sal_uInt16 paramIndex
= 0;
90 if ( pDecl
->getNodeType() == NT_parameter
)
92 AstParameter
* pParam
= (AstParameter
*)pDecl
;
93 switch (pParam
->getDirection())
96 paramMode
= RT_PARAM_IN
;
99 paramMode
= RT_PARAM_OUT
;
102 paramMode
= RT_PARAM_INOUT
;
105 paramMode
= RT_PARAM_INVALID
;
108 if (pParam
->isRest()) {
109 paramMode
= static_cast< RTParamMode
>(
110 paramMode
| RT_PARAM_REST
);
113 rBlob
.setMethodParameterData(
114 index
, paramIndex
++, paramMode
,
116 pDecl
->getLocalName(), RTL_TEXTENCODING_UTF8
),
118 pParam
->getType()->getRelativName(),
119 RTL_TEXTENCODING_UTF8
));
127 DeclList::iterator iter
= m_exceptions
.begin();
128 DeclList::iterator end
= m_exceptions
.end();
129 sal_uInt16 exceptIndex
= 0;
130 while ( iter
!= end
)
132 rBlob
.setMethodExceptionTypeName(
133 index
, exceptIndex
++,
135 (*iter
)->getRelativName(), RTL_TEXTENCODING_UTF8
));
143 AstDeclaration
* AstOperation::addDeclaration(AstDeclaration
* pDecl
)
145 if ( pDecl
->getNodeType() == NT_parameter
)
147 AstParameter
* pParam
= (AstParameter
*)pDecl
;
149 (pParam
->getDirection() == DIR_OUT
|| pParam
->getDirection() == DIR_INOUT
) )
151 idlc()->error()->error2(EIDL_ONEWAY_CONFLICT
, pDecl
, this);
155 return AstScope::addDeclaration(pDecl
);