1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <idlc/astoperation.hxx>
21 #include <idlc/asttype.hxx>
22 #include <idlc/astbasetype.hxx>
23 #include <idlc/astparameter.hxx>
24 #include <idlc/errorhandler.hxx>
26 #include <registry/writer.hxx>
28 using namespace ::rtl
;
30 void AstOperation::setExceptions(DeclList
const * pExceptions
)
32 if (pExceptions
!= 0) {
33 m_exceptions
= *pExceptions
;
37 bool AstOperation::isVariadic() const {
38 DeclList::const_iterator
i(getIteratorEnd());
39 return i
!= getIteratorBegin()
40 && static_cast< AstParameter
const * >(*(--i
))->isRest();
43 bool AstOperation::dumpBlob(typereg::Writer
& rBlob
, sal_uInt16 index
)
45 sal_uInt16 nParam
= getNodeCount(NT_parameter
);
46 sal_uInt16 nExcep
= nExceptions();
47 RTMethodMode methodMode
= RT_MODE_TWOWAY
;
49 OUString returnTypeName
;
50 if (m_pReturnType
== 0) {
51 returnTypeName
= "void";
53 returnTypeName
= OStringToOUString(
54 m_pReturnType
->getRelativName(), RTL_TEXTENCODING_UTF8
);
57 index
, getDocumentation(), methodMode
,
58 OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8
),
59 returnTypeName
, nParam
, nExcep
);
63 DeclList::const_iterator iter
= getIteratorBegin();
64 DeclList::const_iterator end
= getIteratorEnd();
65 AstDeclaration
* pDecl
= NULL
;
66 RTParamMode paramMode
;
67 sal_uInt16 paramIndex
= 0;
71 if ( pDecl
->getNodeType() == NT_parameter
)
73 AstParameter
* pParam
= (AstParameter
*)pDecl
;
74 switch (pParam
->getDirection())
77 paramMode
= RT_PARAM_IN
;
80 paramMode
= RT_PARAM_OUT
;
83 paramMode
= RT_PARAM_INOUT
;
86 paramMode
= RT_PARAM_INVALID
;
89 if (pParam
->isRest()) {
90 paramMode
= static_cast< RTParamMode
>(
91 paramMode
| RT_PARAM_REST
);
94 rBlob
.setMethodParameterData(
95 index
, paramIndex
++, paramMode
,
97 pDecl
->getLocalName(), RTL_TEXTENCODING_UTF8
),
99 pParam
->getType()->getRelativName(),
100 RTL_TEXTENCODING_UTF8
));
108 DeclList::iterator iter
= m_exceptions
.begin();
109 DeclList::iterator end
= m_exceptions
.end();
110 sal_uInt16 exceptIndex
= 0;
111 while ( iter
!= end
)
113 rBlob
.setMethodExceptionTypeName(
114 index
, exceptIndex
++,
116 (*iter
)->getRelativName(), RTL_TEXTENCODING_UTF8
));
124 AstDeclaration
* AstOperation::addDeclaration(AstDeclaration
* pDecl
)
126 return AstScope::addDeclaration(pDecl
);
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */