bump product version to 6.4.0.3
[LibreOffice.git] / idlc / source / astoperation.cxx
blob4dea37576b24db8f21fa7ce9cad7e4943726cb93
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <astoperation.hxx>
21 #include <asttype.hxx>
22 #include <astbasetype.hxx>
23 #include <astparameter.hxx>
24 #include <errorhandler.hxx>
26 #include <registry/writer.hxx>
28 void AstOperation::setExceptions(DeclList const * pExceptions)
30 if (pExceptions != nullptr) {
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 void AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
43 sal_uInt16 nParam = getNodeCount(NT_parameter);
44 sal_uInt16 nExcep = static_cast<sal_uInt16>(m_exceptions.size());
46 OUString returnTypeName;
47 if (m_pReturnType == nullptr) {
48 returnTypeName = "void";
49 } else {
50 returnTypeName = OStringToOUString(
51 m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8);
53 rBlob.setMethodData(
54 index, getDocumentation(), RTMethodMode::TWOWAY,
55 OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
56 returnTypeName, nParam, nExcep);
58 if ( nParam )
60 DeclList::const_iterator iter = getIteratorBegin();
61 DeclList::const_iterator end = getIteratorEnd();
62 RTParamMode paramMode;
63 sal_uInt16 paramIndex = 0;
64 while ( iter != end )
66 AstDeclaration* pDecl = *iter;
67 if ( pDecl->getNodeType() == NT_parameter )
69 AstParameter* pParam = static_cast<AstParameter*>(pDecl);
70 switch (pParam->getDirection())
72 case DIR_IN :
73 paramMode = RT_PARAM_IN;
74 break;
75 case DIR_OUT :
76 paramMode = RT_PARAM_OUT;
77 break;
78 case DIR_INOUT :
79 paramMode = RT_PARAM_INOUT;
80 break;
81 default:
82 paramMode = RT_PARAM_INVALID;
83 break;
85 if (pParam->isRest()) {
86 paramMode = static_cast< RTParamMode >(
87 paramMode | RT_PARAM_REST);
90 rBlob.setMethodParameterData(
91 index, paramIndex++, paramMode,
92 OStringToOUString(
93 pDecl->getLocalName(), RTL_TEXTENCODING_UTF8),
94 OStringToOUString(
95 pParam->getType()->getRelativName(),
96 RTL_TEXTENCODING_UTF8));
98 ++iter;
102 if ( nExcep )
104 sal_uInt16 exceptIndex = 0;
105 for (auto const& exception : m_exceptions)
107 rBlob.setMethodExceptionTypeName(
108 index, exceptIndex++,
109 OStringToOUString(
110 exception->getRelativName(), RTL_TEXTENCODING_UTF8));
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */