xref: /aoo41x/main/autodoc/source/ary/cpp/c_funct.cxx (revision d291ea28)
1*d291ea28SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d291ea28SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d291ea28SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d291ea28SAndrew Rist  * distributed with this work for additional information
6*d291ea28SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d291ea28SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d291ea28SAndrew Rist  * "License"); you may not use this file except in compliance
9*d291ea28SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d291ea28SAndrew Rist  *
11*d291ea28SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d291ea28SAndrew Rist  *
13*d291ea28SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d291ea28SAndrew Rist  * software distributed under the License is distributed on an
15*d291ea28SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d291ea28SAndrew Rist  * KIND, either express or implied.  See the License for the
17*d291ea28SAndrew Rist  * specific language governing permissions and limitations
18*d291ea28SAndrew Rist  * under the License.
19*d291ea28SAndrew Rist  *
20*d291ea28SAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
28cdf0e10cSrcweir #include <algorithm>
29cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace
36cdf0e10cSrcweir {
37cdf0e10cSrcweir using namespace ::ary::cpp;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir class Parameter_2_NonTypeParamInfo
41cdf0e10cSrcweir {
42cdf0e10cSrcweir   public:
43cdf0e10cSrcweir     String              operator()(
44cdf0e10cSrcweir                             const S_Parameter & i_rParam ) const;
45cdf0e10cSrcweir };
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class Parameter_2_Type
48cdf0e10cSrcweir {
49cdf0e10cSrcweir   public:
operator ()(const S_Parameter & i_rParam) const50cdf0e10cSrcweir     Type_id             operator()(
51cdf0e10cSrcweir                             const S_Parameter & i_rParam ) const
52cdf0e10cSrcweir                                                 { return i_rParam.nType; }
53cdf0e10cSrcweir };
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /** @return
56cdf0e10cSrcweir     A vector with Strings like this:
57cdf0e10cSrcweir         "ParamName" or "ParamName[ArraySize]" or "ParamName = InitValue".
58cdf0e10cSrcweir */
59cdf0e10cSrcweir StringVector        Create_NonTypeParameterInfos(
60cdf0e10cSrcweir                         const std::vector<S_Parameter> &
61cdf0e10cSrcweir                                             i_rParameters );
62cdf0e10cSrcweir /** @return
63cdf0e10cSrcweir     A vector of the parameters' type ids.
64cdf0e10cSrcweir */
65cdf0e10cSrcweir std::vector<Type_id>
66cdf0e10cSrcweir                     Create_ParameterTypeList(
67cdf0e10cSrcweir                         const std::vector<S_Parameter> &
68cdf0e10cSrcweir                                             i_rParameters );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir }   // namspace anonymous
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir namespace ary
74cdf0e10cSrcweir {
75cdf0e10cSrcweir namespace cpp
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 
Function(const String & i_sLocalName,Ce_id i_nOwner,E_Protection i_eProtection,Lid i_nFile,Type_id i_nReturnType,const std::vector<S_Parameter> & i_parameters,E_ConVol i_conVol,E_Virtuality i_eVirtuality,FunctionFlags i_aFlags,bool i_bThrowExists,const std::vector<Type_id> & i_rExceptions)78cdf0e10cSrcweir Function::Function( const String  &             i_sLocalName,
79cdf0e10cSrcweir                     Ce_id                       i_nOwner,
80cdf0e10cSrcweir                     E_Protection                i_eProtection,
81cdf0e10cSrcweir                     Lid                         i_nFile,
82cdf0e10cSrcweir                     Type_id                     i_nReturnType,
83cdf0e10cSrcweir                     const std::vector<S_Parameter> &
84cdf0e10cSrcweir                                                 i_parameters,
85cdf0e10cSrcweir                     E_ConVol                    i_conVol,
86cdf0e10cSrcweir                     E_Virtuality                i_eVirtuality,
87cdf0e10cSrcweir                     FunctionFlags               i_aFlags,
88cdf0e10cSrcweir                     bool                        i_bThrowExists,
89cdf0e10cSrcweir                     const std::vector<Type_id> &
90cdf0e10cSrcweir                                                 i_rExceptions )
91cdf0e10cSrcweir     :   aEssentials( i_sLocalName,
92cdf0e10cSrcweir                      i_nOwner,
93cdf0e10cSrcweir                      i_nFile ),
94cdf0e10cSrcweir         aTemplateParameterTypes(),
95cdf0e10cSrcweir 		aSignature( Create_ParameterTypeList(i_parameters),
96cdf0e10cSrcweir 		            i_conVol ),
97cdf0e10cSrcweir         nReturnType(i_nReturnType),
98cdf0e10cSrcweir 		eProtection(i_eProtection),
99cdf0e10cSrcweir 		eVirtuality(i_eVirtuality),
100cdf0e10cSrcweir 		aFlags(i_aFlags),
101cdf0e10cSrcweir         aParameterInfos( Create_NonTypeParameterInfos(i_parameters) ),
102cdf0e10cSrcweir         pExceptions( i_bThrowExists ? new ExceptionTypeList(i_rExceptions) : 0 )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
~Function()106cdf0e10cSrcweir Function::~Function()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir bool
IsIdentical(const Function & i_f) const111cdf0e10cSrcweir Function::IsIdentical( const Function & i_f ) const
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     return
114cdf0e10cSrcweir         LocalName() == i_f.LocalName()
115cdf0e10cSrcweir         AND
116cdf0e10cSrcweir         Owner() == i_f.Owner()
117cdf0e10cSrcweir         AND
118cdf0e10cSrcweir         aSignature == i_f.aSignature
119cdf0e10cSrcweir         AND
120cdf0e10cSrcweir         nReturnType == i_f.nReturnType
121cdf0e10cSrcweir         AND
122cdf0e10cSrcweir         eProtection == i_f.eProtection
123cdf0e10cSrcweir         AND
124cdf0e10cSrcweir         eVirtuality == i_f.eVirtuality
125cdf0e10cSrcweir         AND
126cdf0e10cSrcweir         aFlags == i_f.aFlags
127cdf0e10cSrcweir         AND
128cdf0e10cSrcweir         ( ( NOT pExceptions AND NOT i_f.pExceptions )
129cdf0e10cSrcweir           OR
130cdf0e10cSrcweir           ( pExceptions AND i_f.pExceptions
131cdf0e10cSrcweir                 ?   *pExceptions == *i_f.pExceptions
132cdf0e10cSrcweir                 :   false )
133cdf0e10cSrcweir         )
134cdf0e10cSrcweir         AND
135cdf0e10cSrcweir         aTemplateParameterTypes.size() == i_f.aTemplateParameterTypes.size();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir void
Add_TemplateParameterType(const String & i_sLocalName,Type_id i_nIdAsType)139cdf0e10cSrcweir Function::Add_TemplateParameterType( const String  &    i_sLocalName,
140cdf0e10cSrcweir                                      Type_id            i_nIdAsType )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	aTemplateParameterTypes.push_back(
143cdf0e10cSrcweir 		List_TplParam::value_type(i_sLocalName, i_nIdAsType) );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir const String  &
inq_LocalName() const148cdf0e10cSrcweir Function::inq_LocalName() const
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	return aEssentials.LocalName();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir Cid
inq_Owner() const154cdf0e10cSrcweir Function::inq_Owner() const
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	return aEssentials.Owner();
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir Lid
inq_Location() const160cdf0e10cSrcweir Function::inq_Location() const
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	return aEssentials.Location();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir void
do_Accept(csv::ProcessorIfc & io_processor) const166cdf0e10cSrcweir Function::do_Accept(csv::ProcessorIfc & io_processor) const
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     csv::CheckedCall(io_processor,*this);
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir ClassId
get_AryClass() const172cdf0e10cSrcweir Function::get_AryClass() const
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	return class_id;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir }   // namespace cpp
180cdf0e10cSrcweir }   // namespace ary
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 
184cdf0e10cSrcweir namespace
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 
187cdf0e10cSrcweir String
operator ()(const ary::cpp::S_Parameter & i_rParam) const188cdf0e10cSrcweir Parameter_2_NonTypeParamInfo::operator()( const ary::cpp::S_Parameter & i_rParam ) const
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     static StreamStr aParamName_(1020);
191cdf0e10cSrcweir     aParamName_.seekp(0);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     aParamName_ << i_rParam.sName;
194cdf0e10cSrcweir     if ( i_rParam.sSizeExpression.length() > 0 )
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         aParamName_ << '['
197cdf0e10cSrcweir                     << i_rParam.sSizeExpression
198cdf0e10cSrcweir                     << ']';
199cdf0e10cSrcweir     }
200cdf0e10cSrcweir     if ( i_rParam.sInitExpression.length() > 0 )
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir         aParamName_ << " = "
203cdf0e10cSrcweir                     << i_rParam.sInitExpression;
204cdf0e10cSrcweir     }
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     return aParamName_.c_str();
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
210cdf0e10cSrcweir StringVector
Create_NonTypeParameterInfos(const std::vector<S_Parameter> & i_rParameters)211cdf0e10cSrcweir Create_NonTypeParameterInfos( const std::vector<S_Parameter> & i_rParameters )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir     static Parameter_2_NonTypeParamInfo
214cdf0e10cSrcweir         aTransformFunction_;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     StringVector
217cdf0e10cSrcweir         ret(i_rParameters.size(), String::Null_());
218cdf0e10cSrcweir     std::transform( i_rParameters.begin(), i_rParameters.end(),
219cdf0e10cSrcweir                     ret.begin(),
220cdf0e10cSrcweir                     aTransformFunction_ );
221cdf0e10cSrcweir     return ret;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir std::vector<Type_id>
Create_ParameterTypeList(const std::vector<S_Parameter> & i_rParameters)225cdf0e10cSrcweir Create_ParameterTypeList( const std::vector<S_Parameter> & i_rParameters )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     static Parameter_2_Type
228cdf0e10cSrcweir         aTransformFunction_;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     std::vector<Type_id>
231cdf0e10cSrcweir         ret(i_rParameters.size(), Type_id(0));
232cdf0e10cSrcweir     std::transform( i_rParameters.begin(), i_rParameters.end(),
233cdf0e10cSrcweir                     ret.begin(),
234cdf0e10cSrcweir                     aTransformFunction_ );
235cdf0e10cSrcweir     return ret;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 
241cdf0e10cSrcweir }   // namespace anonymous
242