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 void AstOperation::setExceptions(DeclList
const * pExceptions
)
30 if (pExceptions
!= 0) {
31 m_exceptions
= *pExceptions
;
35 bool AstOperation::isVariadic() const {
36 DeclList::const_iterator
i(getIteratorEnd());
37 return i
!= getIteratorBegin()
38 && static_cast< AstParameter
const * >(*(--i
))->isRest();
41 bool AstOperation::dumpBlob(typereg::Writer
& rBlob
, sal_uInt16 index
)
43 sal_uInt16 nParam
= getNodeCount(NT_parameter
);
44 sal_uInt16 nExcep
= nExceptions();
45 RTMethodMode methodMode
= RTMethodMode::TWOWAY
;
47 OUString returnTypeName
;
48 if (m_pReturnType
== 0) {
49 returnTypeName
= "void";
51 returnTypeName
= OStringToOUString(
52 m_pReturnType
->getRelativName(), RTL_TEXTENCODING_UTF8
);
55 index
, getDocumentation(), methodMode
,
56 OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8
),
57 returnTypeName
, nParam
, nExcep
);
61 DeclList::const_iterator iter
= getIteratorBegin();
62 DeclList::const_iterator end
= getIteratorEnd();
63 RTParamMode paramMode
;
64 sal_uInt16 paramIndex
= 0;
67 AstDeclaration
* pDecl
= *iter
;
68 if ( pDecl
->getNodeType() == NT_parameter
)
70 AstParameter
* pParam
= static_cast<AstParameter
*>(pDecl
);
71 switch (pParam
->getDirection())
74 paramMode
= RT_PARAM_IN
;
77 paramMode
= RT_PARAM_OUT
;
80 paramMode
= RT_PARAM_INOUT
;
83 paramMode
= RT_PARAM_INVALID
;
86 if (pParam
->isRest()) {
87 paramMode
= static_cast< RTParamMode
>(
88 paramMode
| RT_PARAM_REST
);
91 rBlob
.setMethodParameterData(
92 index
, paramIndex
++, paramMode
,
94 pDecl
->getLocalName(), RTL_TEXTENCODING_UTF8
),
96 pParam
->getType()->getRelativName(),
97 RTL_TEXTENCODING_UTF8
));
105 DeclList::iterator iter
= m_exceptions
.begin();
106 DeclList::iterator end
= m_exceptions
.end();
107 sal_uInt16 exceptIndex
= 0;
108 while ( iter
!= end
)
110 rBlob
.setMethodExceptionTypeName(
111 index
, exceptIndex
++,
113 (*iter
)->getRelativName(), RTL_TEXTENCODING_UTF8
));
121 AstDeclaration
* AstOperation::addDeclaration(AstDeclaration
* pDecl
)
123 return AstScope::addDeclaration(pDecl
);
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */