Branch data 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 : 118616 : void AstOperation::setExceptions(DeclList const * pExceptions)
31 : : {
32 [ + + ]: 118616 : if (pExceptions != 0) {
33 [ - + ]: 24600 : if (isOneway()) {
34 : 0 : idlc()->error()->error1(EIDL_ONEWAY_RAISE_CONFLICT, this);
35 : : }
36 : 24600 : m_exceptions = *pExceptions;
37 : : }
38 : 118616 : }
39 : :
40 : 93010 : bool AstOperation::isVariadic() const {
41 : 93010 : DeclList::const_iterator i(getIteratorEnd());
42 [ + - ]: 186020 : return i != getIteratorBegin()
43 [ + + ][ + + ]: 186020 : && static_cast< AstParameter const * >(*(--i))->isRest();
44 : : }
45 : :
46 : 7843 : sal_Bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
47 : : {
48 [ + - ]: 7843 : sal_uInt16 nParam = getNodeCount(NT_parameter);
49 : 7843 : sal_uInt16 nExcep = nExceptions();
50 : 7843 : RTMethodMode methodMode = RT_MODE_TWOWAY;
51 : :
52 [ + + ]: 7843 : if ( isOneway() )
53 : 578 : methodMode = RT_MODE_ONEWAY;
54 : :
55 : 7843 : rtl::OUString returnTypeName;
56 [ + + ]: 7843 : if (m_pReturnType == 0) {
57 [ + - ]: 242 : returnTypeName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("void"));
58 : : } else {
59 : : returnTypeName = rtl::OStringToOUString(
60 [ + - ][ + - ]: 7601 : m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8);
61 : : }
62 : : rBlob.setMethodData(
63 : 7843 : index, getDocumentation(), methodMode,
64 : 7843 : OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
65 [ + - + - ]: 15686 : returnTypeName, nParam, nExcep);
66 : :
67 [ + + ]: 7843 : if ( nParam )
68 : : {
69 : 5062 : DeclList::const_iterator iter = getIteratorBegin();
70 : 5062 : DeclList::const_iterator end = getIteratorEnd();
71 : 5062 : AstDeclaration* pDecl = NULL;
72 : : RTParamMode paramMode;
73 : 5062 : sal_uInt16 paramIndex = 0;
74 [ + + ]: 13920 : while ( iter != end )
75 : : {
76 : 8858 : pDecl = *iter;
77 [ + - ]: 8858 : if ( pDecl->getNodeType() == NT_parameter )
78 : : {
79 : 8858 : AstParameter* pParam = (AstParameter*)pDecl;
80 [ + + + - ]: 8858 : switch (pParam->getDirection())
81 : : {
82 : : case DIR_IN :
83 : 8617 : paramMode = RT_PARAM_IN;
84 : 8617 : break;
85 : : case DIR_OUT :
86 : 146 : paramMode = RT_PARAM_OUT;
87 : 146 : break;
88 : : case DIR_INOUT :
89 : 95 : paramMode = RT_PARAM_INOUT;
90 : 95 : break;
91 : : default:
92 : 0 : paramMode = RT_PARAM_INVALID;
93 : 0 : break;
94 : : }
95 [ + + ]: 8858 : if (pParam->isRest()) {
96 : : paramMode = static_cast< RTParamMode >(
97 : 2 : paramMode | RT_PARAM_REST);
98 : : }
99 : :
100 : : rBlob.setMethodParameterData(
101 : : index, paramIndex++, paramMode,
102 : : OStringToOUString(
103 : 8858 : pDecl->getLocalName(), RTL_TEXTENCODING_UTF8),
104 : : OStringToOUString(
105 [ + - ]: 8858 : pParam->getType()->getRelativName(),
106 [ + - + - ]: 17716 : RTL_TEXTENCODING_UTF8));
[ + - ]
107 : : }
108 : 8858 : ++iter;
109 : : }
110 : : }
111 : :
112 [ + + ]: 7843 : if ( nExcep )
113 : : {
114 : 2342 : DeclList::iterator iter = m_exceptions.begin();
115 : 2342 : DeclList::iterator end = m_exceptions.end();
116 : 2342 : sal_uInt16 exceptIndex = 0;
117 [ + + ]: 5542 : while ( iter != end )
118 : : {
119 : : rBlob.setMethodExceptionTypeName(
120 : : index, exceptIndex++,
121 : : OStringToOUString(
122 [ + - ][ + - ]: 3200 : (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8));
[ + - ]
123 : 3200 : ++iter;
124 : : }
125 : : }
126 : :
127 : 7843 : return sal_True;
128 : : }
129 : :
130 : 93114 : AstDeclaration* AstOperation::addDeclaration(AstDeclaration* pDecl)
131 : : {
132 [ + - ]: 93114 : if ( pDecl->getNodeType() == NT_parameter )
133 : : {
134 : 93114 : AstParameter* pParam = (AstParameter*)pDecl;
135 [ + + + - : 134860 : if ( isOneway() &&
- + ][ - + ]
136 : 41746 : (pParam->getDirection() == DIR_OUT || pParam->getDirection() == DIR_INOUT) )
137 : : {
138 : 0 : idlc()->error()->error2(EIDL_ONEWAY_CONFLICT, pDecl, this);
139 : 0 : return NULL;
140 : : }
141 : : }
142 : 93114 : return AstScope::addDeclaration(pDecl);
143 : : }
144 : :
145 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|