1*2fe1ca3dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2fe1ca3dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2fe1ca3dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2fe1ca3dSAndrew Rist * distributed with this work for additional information 6*2fe1ca3dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2fe1ca3dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2fe1ca3dSAndrew Rist * "License"); you may not use this file except in compliance 9*2fe1ca3dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2fe1ca3dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2fe1ca3dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2fe1ca3dSAndrew Rist * software distributed under the License is distributed on an 15*2fe1ca3dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2fe1ca3dSAndrew Rist * KIND, either express or implied. See the License for the 17*2fe1ca3dSAndrew Rist * specific language governing permissions and limitations 18*2fe1ca3dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2fe1ca3dSAndrew Rist *************************************************************/ 21*2fe1ca3dSAndrew Rist 22*2fe1ca3dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_idlc.hxx" 26cdf0e10cSrcweir #include <idlc/astoperation.hxx> 27cdf0e10cSrcweir #include <idlc/asttype.hxx> 28cdf0e10cSrcweir #include <idlc/astbasetype.hxx> 29cdf0e10cSrcweir #include <idlc/astparameter.hxx> 30cdf0e10cSrcweir #include <idlc/errorhandler.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include "registry/writer.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir using namespace ::rtl; 35cdf0e10cSrcweir 36cdf0e10cSrcweir void AstOperation::setExceptions(DeclList const * pExceptions) 37cdf0e10cSrcweir { 38cdf0e10cSrcweir if (pExceptions != 0) { 39cdf0e10cSrcweir if (isOneway()) { 40cdf0e10cSrcweir idlc()->error()->error1(EIDL_ONEWAY_RAISE_CONFLICT, this); 41cdf0e10cSrcweir } 42cdf0e10cSrcweir m_exceptions = *pExceptions; 43cdf0e10cSrcweir } 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir bool AstOperation::isVariadic() const { 47cdf0e10cSrcweir DeclList::const_iterator i(getIteratorEnd()); 48cdf0e10cSrcweir return i != getIteratorBegin() 49cdf0e10cSrcweir && static_cast< AstParameter const * >(*(--i))->isRest(); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir sal_Bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir sal_uInt16 nParam = getNodeCount(NT_parameter); 55cdf0e10cSrcweir sal_uInt16 nExcep = nExceptions(); 56cdf0e10cSrcweir RTMethodMode methodMode = RT_MODE_TWOWAY; 57cdf0e10cSrcweir 58cdf0e10cSrcweir if ( isOneway() ) 59cdf0e10cSrcweir methodMode = RT_MODE_ONEWAY; 60cdf0e10cSrcweir 61cdf0e10cSrcweir rtl::OUString returnTypeName; 62cdf0e10cSrcweir if (m_pReturnType == 0) { 63cdf0e10cSrcweir returnTypeName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("void")); 64cdf0e10cSrcweir } else { 65cdf0e10cSrcweir returnTypeName = rtl::OStringToOUString( 66cdf0e10cSrcweir m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir rBlob.setMethodData( 69cdf0e10cSrcweir index, getDocumentation(), methodMode, 70cdf0e10cSrcweir OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8), 71cdf0e10cSrcweir returnTypeName, nParam, nExcep); 72cdf0e10cSrcweir 73cdf0e10cSrcweir if ( nParam ) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir DeclList::const_iterator iter = getIteratorBegin(); 76cdf0e10cSrcweir DeclList::const_iterator end = getIteratorEnd(); 77cdf0e10cSrcweir AstDeclaration* pDecl = NULL; 78cdf0e10cSrcweir RTParamMode paramMode; 79cdf0e10cSrcweir sal_uInt16 paramIndex = 0; 80cdf0e10cSrcweir while ( iter != end ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir pDecl = *iter; 83cdf0e10cSrcweir if ( pDecl->getNodeType() == NT_parameter ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir AstParameter* pParam = (AstParameter*)pDecl; 86cdf0e10cSrcweir switch (pParam->getDirection()) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir case DIR_IN : 89cdf0e10cSrcweir paramMode = RT_PARAM_IN; 90cdf0e10cSrcweir break; 91cdf0e10cSrcweir case DIR_OUT : 92cdf0e10cSrcweir paramMode = RT_PARAM_OUT; 93cdf0e10cSrcweir break; 94cdf0e10cSrcweir case DIR_INOUT : 95cdf0e10cSrcweir paramMode = RT_PARAM_INOUT; 96cdf0e10cSrcweir break; 97cdf0e10cSrcweir default: 98cdf0e10cSrcweir paramMode = RT_PARAM_INVALID; 99cdf0e10cSrcweir break; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir if (pParam->isRest()) { 102cdf0e10cSrcweir paramMode = static_cast< RTParamMode >( 103cdf0e10cSrcweir paramMode | RT_PARAM_REST); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir rBlob.setMethodParameterData( 107cdf0e10cSrcweir index, paramIndex++, paramMode, 108cdf0e10cSrcweir OStringToOUString( 109cdf0e10cSrcweir pDecl->getLocalName(), RTL_TEXTENCODING_UTF8), 110cdf0e10cSrcweir OStringToOUString( 111cdf0e10cSrcweir pParam->getType()->getRelativName(), 112cdf0e10cSrcweir RTL_TEXTENCODING_UTF8)); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir ++iter; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir if ( nExcep ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir DeclList::iterator iter = m_exceptions.begin(); 121cdf0e10cSrcweir DeclList::iterator end = m_exceptions.end(); 122cdf0e10cSrcweir sal_uInt16 exceptIndex = 0; 123cdf0e10cSrcweir while ( iter != end ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir rBlob.setMethodExceptionTypeName( 126cdf0e10cSrcweir index, exceptIndex++, 127cdf0e10cSrcweir OStringToOUString( 128cdf0e10cSrcweir (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8)); 129cdf0e10cSrcweir ++iter; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir return sal_True; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir AstDeclaration* AstOperation::addDeclaration(AstDeclaration* pDecl) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir if ( pDecl->getNodeType() == NT_parameter ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir AstParameter* pParam = (AstParameter*)pDecl; 141cdf0e10cSrcweir if ( isOneway() && 142cdf0e10cSrcweir (pParam->getDirection() == DIR_OUT || pParam->getDirection() == DIR_INOUT) ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir idlc()->error()->error2(EIDL_ONEWAY_CONFLICT, pDecl, this); 145cdf0e10cSrcweir return NULL; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir return AstScope::addDeclaration(pDecl); 149cdf0e10cSrcweir } 150