Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
25 :
26 : #include "registry/writer.hxx"
27 :
28 : using namespace ::rtl;
29 :
30 103047 : void AstOperation::setExceptions(DeclList const * pExceptions)
31 : {
32 103047 : if (pExceptions != 0) {
33 21805 : m_exceptions = *pExceptions;
34 : }
35 103047 : }
36 :
37 81507 : bool AstOperation::isVariadic() const {
38 81507 : DeclList::const_iterator i(getIteratorEnd());
39 244521 : return i != getIteratorBegin()
40 326028 : && static_cast< AstParameter const * >(*(--i))->isRest();
41 : }
42 :
43 6533 : sal_Bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
44 : {
45 6533 : sal_uInt16 nParam = getNodeCount(NT_parameter);
46 6533 : sal_uInt16 nExcep = nExceptions();
47 6533 : RTMethodMode methodMode = RT_MODE_TWOWAY;
48 :
49 6533 : rtl::OUString returnTypeName;
50 6533 : if (m_pReturnType == 0) {
51 249 : returnTypeName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("void"));
52 : } else {
53 : returnTypeName = rtl::OStringToOUString(
54 6284 : m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8);
55 : }
56 : rBlob.setMethodData(
57 6533 : index, getDocumentation(), methodMode,
58 6533 : OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
59 19599 : returnTypeName, nParam, nExcep);
60 :
61 6533 : if ( nParam )
62 : {
63 4224 : DeclList::const_iterator iter = getIteratorBegin();
64 4224 : DeclList::const_iterator end = getIteratorEnd();
65 4224 : AstDeclaration* pDecl = NULL;
66 : RTParamMode paramMode;
67 4224 : sal_uInt16 paramIndex = 0;
68 15872 : while ( iter != end )
69 : {
70 7424 : pDecl = *iter;
71 7424 : if ( pDecl->getNodeType() == NT_parameter )
72 : {
73 7424 : AstParameter* pParam = (AstParameter*)pDecl;
74 7424 : switch (pParam->getDirection())
75 : {
76 : case DIR_IN :
77 7273 : paramMode = RT_PARAM_IN;
78 7273 : break;
79 : case DIR_OUT :
80 97 : paramMode = RT_PARAM_OUT;
81 97 : break;
82 : case DIR_INOUT :
83 54 : paramMode = RT_PARAM_INOUT;
84 54 : break;
85 : default:
86 0 : paramMode = RT_PARAM_INVALID;
87 0 : break;
88 : }
89 7424 : if (pParam->isRest()) {
90 : paramMode = static_cast< RTParamMode >(
91 2 : paramMode | RT_PARAM_REST);
92 : }
93 :
94 : rBlob.setMethodParameterData(
95 : index, paramIndex++, paramMode,
96 : OStringToOUString(
97 7424 : pDecl->getLocalName(), RTL_TEXTENCODING_UTF8),
98 : OStringToOUString(
99 7424 : pParam->getType()->getRelativName(),
100 14848 : RTL_TEXTENCODING_UTF8));
101 : }
102 7424 : ++iter;
103 : }
104 : }
105 :
106 6533 : if ( nExcep )
107 : {
108 2159 : DeclList::iterator iter = m_exceptions.begin();
109 2159 : DeclList::iterator end = m_exceptions.end();
110 2159 : sal_uInt16 exceptIndex = 0;
111 7313 : while ( iter != end )
112 : {
113 : rBlob.setMethodExceptionTypeName(
114 : index, exceptIndex++,
115 : OStringToOUString(
116 2995 : (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8));
117 2995 : ++iter;
118 : }
119 : }
120 :
121 6533 : return sal_True;
122 : }
123 :
124 81579 : AstDeclaration* AstOperation::addDeclaration(AstDeclaration* pDecl)
125 : {
126 81579 : return AstScope::addDeclaration(pDecl);
127 : }
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|