1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*0841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*0841af79SAndrew Rist * distributed with this work for additional information
6*0841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*0841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist * with the License. You may obtain a copy of the License at
10*0841af79SAndrew Rist *
11*0841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*0841af79SAndrew Rist *
13*0841af79SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist * software distributed under the License is distributed on an
15*0841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist * KIND, either express or implied. See the License for the
17*0841af79SAndrew Rist * specific language governing permissions and limitations
18*0841af79SAndrew Rist * under the License.
19*0841af79SAndrew Rist *
20*0841af79SAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "aryattrs.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/getncast.hxx>
28cdf0e10cSrcweir #include <ary/cpp/c_class.hxx>
29cdf0e10cSrcweir #include <ary/cpp/c_enum.hxx>
30cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
31cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx>
32cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx>
33cdf0e10cSrcweir #include <ary/cpp/cp_ce.hxx>
34cdf0e10cSrcweir #include <ary/cpp/cp_type.hxx>
35cdf0e10cSrcweir #include "strconst.hxx"
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir
39cdf0e10cSrcweir
40cdf0e10cSrcweir //******************** HtmlDisplay_Impl *********************//
41cdf0e10cSrcweir
42cdf0e10cSrcweir const char *
Get_ClassTypeKey(const ary::cpp::Class & i_rClass)43cdf0e10cSrcweir Get_ClassTypeKey( const ary::cpp::Class & i_rClass )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir return i_rClass.ClassKey() == ary::cpp::CK_class
46cdf0e10cSrcweir ? C_sHFTypeTitle_Class
47cdf0e10cSrcweir : i_rClass.ClassKey() == ary::cpp::CK_struct
48cdf0e10cSrcweir ? C_sHFTypeTitle_Struct
49cdf0e10cSrcweir : C_sHFTypeTitle_Union;
50cdf0e10cSrcweir
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir const char *
Get_TypeKey(const ary::cpp::CodeEntity & i_rCe)54cdf0e10cSrcweir Get_TypeKey( const ary::cpp::CodeEntity & i_rCe )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir if ( ary::is_type<ary::cpp::Class>(i_rCe) )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir return Get_ClassTypeKey(
59cdf0e10cSrcweir ary::ary_cast<ary::cpp::Class>(i_rCe) );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir if ( ary::is_type<ary::cpp::Enum>(i_rCe) )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir return "enum";
64cdf0e10cSrcweir }
65cdf0e10cSrcweir return "";
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
68cdf0e10cSrcweir bool
Ce_IsInternal(const ary::cpp::CodeEntity & i_rCe)69cdf0e10cSrcweir Ce_IsInternal( const ary::cpp::CodeEntity & i_rCe )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir return NOT i_rCe.IsVisible();
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir const char *
SyntaxText_PreName(const ary::cpp::Function & i_rFunction,const ary::cpp::Gate & i_rAryGate)75cdf0e10cSrcweir SyntaxText_PreName( const ary::cpp::Function & i_rFunction,
76cdf0e10cSrcweir const ary::cpp::Gate & i_rAryGate )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir static StreamStr sResult( 150 );
79cdf0e10cSrcweir sResult.seekp(0);
80cdf0e10cSrcweir
81cdf0e10cSrcweir // write pre-name:
82cdf0e10cSrcweir const ary::cpp::FunctionFlags & rFlags = i_rFunction.Flags();
83cdf0e10cSrcweir if ( rFlags.IsStaticLocal() OR rFlags.IsStaticMember() )
84cdf0e10cSrcweir sResult << "static ";
85cdf0e10cSrcweir if ( rFlags.IsExplicit() )
86cdf0e10cSrcweir sResult << "explicit ";
87cdf0e10cSrcweir if ( rFlags.IsMutable() )
88cdf0e10cSrcweir sResult << "mutable ";
89cdf0e10cSrcweir if ( i_rFunction.Virtuality() != ary::cpp::VIRTUAL_none )
90cdf0e10cSrcweir sResult << "virtual ";
91cdf0e10cSrcweir i_rAryGate.Types().Get_TypeText( sResult, i_rFunction.ReturnType() );
92cdf0e10cSrcweir sResult << " ";
93cdf0e10cSrcweir
94cdf0e10cSrcweir return sResult.c_str();
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir const char *
SyntaxText_PostName(const ary::cpp::Function & i_rFunction,const ary::cpp::Gate & i_rAryGate)98cdf0e10cSrcweir SyntaxText_PostName( const ary::cpp::Function & i_rFunction,
99cdf0e10cSrcweir const ary::cpp::Gate & i_rAryGate )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir static StreamStr sResult( 850 );
102cdf0e10cSrcweir sResult.seekp(0);
103cdf0e10cSrcweir
104cdf0e10cSrcweir // parameters and con_vol
105cdf0e10cSrcweir i_rAryGate.Ces().Get_SignatureText( sResult, i_rFunction.Signature(), &i_rFunction.ParamInfos() );
106cdf0e10cSrcweir
107cdf0e10cSrcweir // write Exceptions:
108cdf0e10cSrcweir const std::vector< ary::cpp::Type_id > *
109cdf0e10cSrcweir pThrow = i_rFunction.Exceptions();
110cdf0e10cSrcweir if ( pThrow)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir
113cdf0e10cSrcweir std::vector< ary::cpp::Type_id >::const_iterator
114cdf0e10cSrcweir it = pThrow->begin();
115cdf0e10cSrcweir std::vector< ary::cpp::Type_id >::const_iterator
116cdf0e10cSrcweir it_end = pThrow->end();
117cdf0e10cSrcweir
118cdf0e10cSrcweir if (it != it_end)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir sResult << " throw( ";
121cdf0e10cSrcweir i_rAryGate.Types().Get_TypeText(sResult, *it);
122cdf0e10cSrcweir
123cdf0e10cSrcweir for ( ++it; it != it_end; ++it )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir sResult << ", ";
126cdf0e10cSrcweir i_rAryGate.Types().Get_TypeText(sResult, *it);
127cdf0e10cSrcweir }
128cdf0e10cSrcweir sResult << " )";
129cdf0e10cSrcweir }
130cdf0e10cSrcweir else
131cdf0e10cSrcweir {
132cdf0e10cSrcweir sResult << " throw( )";
133cdf0e10cSrcweir }
134cdf0e10cSrcweir } // endif // pThrow
135cdf0e10cSrcweir
136cdf0e10cSrcweir // abstractness:
137cdf0e10cSrcweir if ( i_rFunction.Virtuality() == ary::cpp::VIRTUAL_abstract )
138cdf0e10cSrcweir sResult << " = 0";
139cdf0e10cSrcweir
140cdf0e10cSrcweir // finish:
141cdf0e10cSrcweir sResult << ";";
142cdf0e10cSrcweir
143cdf0e10cSrcweir return sResult.c_str();
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir bool
Get_TypeText(const char * & o_rPreName,const char * & o_rName,const char * & o_rPostName,ary::cpp::Type_id i_nTypeid,const ary::cpp::Gate & i_rAryGate)147cdf0e10cSrcweir Get_TypeText( const char * & o_rPreName,
148cdf0e10cSrcweir const char * & o_rName,
149cdf0e10cSrcweir const char * & o_rPostName,
150cdf0e10cSrcweir ary::cpp::Type_id i_nTypeid,
151cdf0e10cSrcweir const ary::cpp::Gate & i_rAryGate )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir static StreamStr sResult_PreName(250);
154cdf0e10cSrcweir static StreamStr sResult_Name(250);
155cdf0e10cSrcweir static StreamStr sResult_PostName(250);
156cdf0e10cSrcweir
157cdf0e10cSrcweir sResult_PreName.seekp(0);
158cdf0e10cSrcweir sResult_Name.seekp(0);
159cdf0e10cSrcweir sResult_PostName.seekp(0);
160cdf0e10cSrcweir
161cdf0e10cSrcweir bool ret = i_rAryGate.Types().Get_TypeText(
162cdf0e10cSrcweir sResult_PreName,
163cdf0e10cSrcweir sResult_Name,
164cdf0e10cSrcweir sResult_PostName,
165cdf0e10cSrcweir i_nTypeid );
166cdf0e10cSrcweir if ( sResult_PreName.tellp() > 0 )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir char cLast = *( sResult_PreName.c_str() + (sResult_PreName.tellp() - 1) );
169cdf0e10cSrcweir if (cLast != ':' AND cLast != ' ')
170cdf0e10cSrcweir sResult_PreName << " ";
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir
174cdf0e10cSrcweir if (ret)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir o_rPreName = sResult_PreName.c_str();
177cdf0e10cSrcweir o_rName = sResult_Name.c_str();
178cdf0e10cSrcweir o_rPostName = sResult_PostName.c_str();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir else
181cdf0e10cSrcweir {
182cdf0e10cSrcweir o_rPreName = o_rName = o_rPostName = "";
183cdf0e10cSrcweir }
184cdf0e10cSrcweir return ret;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir
188cdf0e10cSrcweir
189cdf0e10cSrcweir
190cdf0e10cSrcweir //********************* FunctionParam_Iterator *****************//
191cdf0e10cSrcweir
192cdf0e10cSrcweir
FunctionParam_Iterator()193cdf0e10cSrcweir FunctionParam_Iterator::FunctionParam_Iterator()
194cdf0e10cSrcweir : // itTypes
195cdf0e10cSrcweir // itTypes_end
196cdf0e10cSrcweir // itNames_andMore
197cdf0e10cSrcweir // itNames_andMore_end
198cdf0e10cSrcweir eConVol(ary::cpp::CONVOL_none)
199cdf0e10cSrcweir {
200cdf0e10cSrcweir static std::vector<ary::cpp::Type_id> aTypesNull_;
201cdf0e10cSrcweir static StringVector aNamesNull_;
202cdf0e10cSrcweir
203cdf0e10cSrcweir itTypes = itTypes_end = aTypesNull_.end();
204cdf0e10cSrcweir itNames_andMore = itNames_andMore_end = aNamesNull_.end();
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
~FunctionParam_Iterator()207cdf0e10cSrcweir FunctionParam_Iterator::~FunctionParam_Iterator()
208cdf0e10cSrcweir {
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir FunctionParam_Iterator &
operator ++()212cdf0e10cSrcweir FunctionParam_Iterator::operator++()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir if ( IsValid() )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir ++itTypes;
217cdf0e10cSrcweir ++itNames_andMore;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir return *this;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir void
Assign(const ary::cpp::Function & i_rFunction)223cdf0e10cSrcweir FunctionParam_Iterator::Assign( const ary::cpp::Function & i_rFunction )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir const ary::cpp::OperationSignature &
226cdf0e10cSrcweir rSigna = i_rFunction.Signature();
227cdf0e10cSrcweir
228cdf0e10cSrcweir const std::vector<ary::cpp::Type_id> &
229cdf0e10cSrcweir rTypes = rSigna.Parameters();
230cdf0e10cSrcweir const StringVector &
231cdf0e10cSrcweir rNames = i_rFunction.ParamInfos();
232cdf0e10cSrcweir
233cdf0e10cSrcweir if ( rTypes.size() != rNames.size() OR rTypes.size() == 0 )
234cdf0e10cSrcweir return;
235cdf0e10cSrcweir
236cdf0e10cSrcweir itTypes = rTypes.begin();
237cdf0e10cSrcweir itTypes_end = rTypes.end();
238cdf0e10cSrcweir itNames_andMore = rNames.begin();
239cdf0e10cSrcweir itNames_andMore_end = rNames.end();
240cdf0e10cSrcweir
241cdf0e10cSrcweir eConVol = rSigna.ConVol();
242cdf0e10cSrcweir }
243