1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: c_funct.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include <ary/cpp/c_funct.hxx>
36 // NOT FULLY DECLARED SERVICES
38 #include <ary/cpp/c_funct.hxx>
46 using namespace ::ary::cpp
;
49 class Parameter_2_NonTypeParamInfo
53 const S_Parameter
& i_rParam
) const;
56 class Parameter_2_Type
60 const S_Parameter
& i_rParam
) const
61 { return i_rParam
.nType
; }
65 A vector with Strings like this:
66 "ParamName" or "ParamName[ArraySize]" or "ParamName = InitValue".
68 StringVector
Create_NonTypeParameterInfos(
69 const std::vector
<S_Parameter
> &
72 A vector of the parameters' type ids.
75 Create_ParameterTypeList(
76 const std::vector
<S_Parameter
> &
79 } // namspace anonymous
87 Function::Function( const String
& i_sLocalName
,
89 E_Protection i_eProtection
,
91 Type_id i_nReturnType
,
92 const std::vector
<S_Parameter
> &
95 E_Virtuality i_eVirtuality
,
96 FunctionFlags i_aFlags
,
98 const std::vector
<Type_id
> &
100 : aEssentials( i_sLocalName
,
103 aTemplateParameterTypes(),
104 aSignature( Create_ParameterTypeList(i_parameters
),
106 nReturnType(i_nReturnType
),
107 eProtection(i_eProtection
),
108 eVirtuality(i_eVirtuality
),
110 aParameterInfos( Create_NonTypeParameterInfos(i_parameters
) ),
111 pExceptions( i_bThrowExists
? new ExceptionTypeList(i_rExceptions
) : 0 )
115 Function::~Function()
120 Function::IsIdentical( const Function
& i_f
) const
123 LocalName() == i_f
.LocalName()
125 Owner() == i_f
.Owner()
127 aSignature
== i_f
.aSignature
129 nReturnType
== i_f
.nReturnType
131 eProtection
== i_f
.eProtection
133 eVirtuality
== i_f
.eVirtuality
137 ( ( NOT pExceptions AND NOT i_f
.pExceptions
)
139 ( pExceptions AND i_f
.pExceptions
140 ? *pExceptions
== *i_f
.pExceptions
144 aTemplateParameterTypes
.size() == i_f
.aTemplateParameterTypes
.size();
148 Function::Add_TemplateParameterType( const String
& i_sLocalName
,
149 Type_id i_nIdAsType
)
151 aTemplateParameterTypes
.push_back(
152 List_TplParam::value_type(i_sLocalName
, i_nIdAsType
) );
157 Function::inq_LocalName() const
159 return aEssentials
.LocalName();
163 Function::inq_Owner() const
165 return aEssentials
.Owner();
169 Function::inq_Location() const
171 return aEssentials
.Location();
175 Function::do_Accept(csv::ProcessorIfc
& io_processor
) const
177 csv::CheckedCall(io_processor
,*this);
181 Function::get_AryClass() const
197 Parameter_2_NonTypeParamInfo::operator()( const ary::cpp::S_Parameter
& i_rParam
) const
199 static StreamStr
aParamName_(1020);
200 aParamName_
.seekp(0);
202 aParamName_
<< i_rParam
.sName
;
203 if ( i_rParam
.sSizeExpression
.length() > 0 )
206 << i_rParam
.sSizeExpression
209 if ( i_rParam
.sInitExpression
.length() > 0 )
212 << i_rParam
.sInitExpression
;
215 return aParamName_
.c_str();
220 Create_NonTypeParameterInfos( const std::vector
<S_Parameter
> & i_rParameters
)
222 static Parameter_2_NonTypeParamInfo
226 ret(i_rParameters
.size(), String::Null_());
227 std::transform( i_rParameters
.begin(), i_rParameters
.end(),
229 aTransformFunction_
);
234 Create_ParameterTypeList( const std::vector
<S_Parameter
> & i_rParameters
)
236 static Parameter_2_Type
240 ret(i_rParameters
.size(), Type_id(0));
241 std::transform( i_rParameters
.begin(), i_rParameters
.end(),
243 aTransformFunction_
);
250 } // namespace anonymous