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 "hfi_method.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/idl/i_exception.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_param.hxx>
29cdf0e10cSrcweir #include <toolkit/hf_docentry.hxx>
30cdf0e10cSrcweir #include <toolkit/hf_funcdecl.hxx>
31cdf0e10cSrcweir #include "hfi_doc.hxx"
32cdf0e10cSrcweir #include "hfi_globalindex.hxx"
33cdf0e10cSrcweir #include "hfi_typetext.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
HF_IdlMethod(Environment & io_rEnv,Xml::Element & o_cell)39cdf0e10cSrcweir HF_IdlMethod::HF_IdlMethod( Environment &           io_rEnv,
40cdf0e10cSrcweir                             Xml::Element &          o_cell)
41cdf0e10cSrcweir     :   HtmlFactory_Idl(io_rEnv,&o_cell)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
~HF_IdlMethod()46cdf0e10cSrcweir HF_IdlMethod::~HF_IdlMethod()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir void
Produce_byData(const String & i_sName,type_id i_nReturnType,param_list & i_rParams,type_list & i_rExceptions,bool i_bOneway,bool i_bEllipse,const client & i_ce) const52cdf0e10cSrcweir HF_IdlMethod::Produce_byData( const String &      i_sName,
53cdf0e10cSrcweir                               type_id             i_nReturnType,
54cdf0e10cSrcweir                               param_list &        i_rParams,
55cdf0e10cSrcweir                               type_list &         i_rExceptions,
56cdf0e10cSrcweir                               bool                i_bOneway,
57cdf0e10cSrcweir                               bool                i_bEllipse,
58cdf0e10cSrcweir                               const client &      i_ce ) const
59cdf0e10cSrcweir {
60cdf0e10cSrcweir     CurOut()
61cdf0e10cSrcweir         >> *new Html::Label(i_sName)
62cdf0e10cSrcweir             << new Html::ClassAttr(C_sMemberTitle)
63cdf0e10cSrcweir             << i_sName;
64cdf0e10cSrcweir     enter_ContentCell();
65cdf0e10cSrcweir     write_Declaration( i_sName,
66cdf0e10cSrcweir                        i_nReturnType,
67cdf0e10cSrcweir                        i_rParams,
68cdf0e10cSrcweir                        i_rExceptions,
69cdf0e10cSrcweir                        i_bOneway,
70cdf0e10cSrcweir                        i_bEllipse );
71cdf0e10cSrcweir     CurOut() << new Html::HorizontalLine;
72cdf0e10cSrcweir     write_Docu(CurOut(), i_ce);
73cdf0e10cSrcweir     leave_ContentCell();
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #if 0 // old
77cdf0e10cSrcweir void
78cdf0e10cSrcweir HF_IdlMethod::write_Declaration( const String &      i_sName,
79cdf0e10cSrcweir                                  type_id             i_nReturnType,
80cdf0e10cSrcweir                                  param_list &        i_rParams,
81cdf0e10cSrcweir                                  type_list &         i_rExceptions,
82cdf0e10cSrcweir                                  bool                i_bOneway,
83cdf0e10cSrcweir                                  bool				 i_bEllipse ) const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     HF_FunctionDeclaration
86cdf0e10cSrcweir         aDecl(CurOut()) ;
87cdf0e10cSrcweir     Xml::Element &
88cdf0e10cSrcweir         front = aDecl.Add_ReturnLine();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     // Front:
91cdf0e10cSrcweir     if (i_bOneway)
92cdf0e10cSrcweir         front << "[oneway] ";
93cdf0e10cSrcweir     if (i_nReturnType.IsValid())
94cdf0e10cSrcweir     {   // Normal function, but not constructors:
95cdf0e10cSrcweir         HF_IdlTypeText
96cdf0e10cSrcweir             aReturn(Env(), front, true);
97cdf0e10cSrcweir         aReturn.Produce_byData(i_nReturnType);
98cdf0e10cSrcweir         front
99cdf0e10cSrcweir             << new Html::LineBreak;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     }
102cdf0e10cSrcweir     front
103cdf0e10cSrcweir         >> *new Html::Bold
104cdf0e10cSrcweir             << i_sName;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     //  Main line:
107cdf0e10cSrcweir     Xml::Element &
108cdf0e10cSrcweir         types = aDecl.Types();
109cdf0e10cSrcweir     Xml::Element &
110cdf0e10cSrcweir         names = aDecl.Names();
111cdf0e10cSrcweir     bool bParams = i_rParams.operator bool();
112cdf0e10cSrcweir     if (bParams)
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         front
115cdf0e10cSrcweir             << "(";
116cdf0e10cSrcweir         HF_IdlTypeText
117cdf0e10cSrcweir             aType( Env(), types, true );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         write_Param( aType, names, (*i_rParams) );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         for (++i_rParams; i_rParams; ++i_rParams)
122cdf0e10cSrcweir         {
123cdf0e10cSrcweir             types
124cdf0e10cSrcweir                 << new Html::LineBreak;
125cdf0e10cSrcweir             names
126cdf0e10cSrcweir                 << ","
127cdf0e10cSrcweir                 << new Html::LineBreak;
128cdf0e10cSrcweir             write_Param( aType, names, (*i_rParams) );
129cdf0e10cSrcweir         }   // end for
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         if (i_bEllipse)
132cdf0e10cSrcweir         {
133cdf0e10cSrcweir             names
134cdf0e10cSrcweir                 << " ...";
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir         names
137cdf0e10cSrcweir             << " )";
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir     else
140cdf0e10cSrcweir         front
141cdf0e10cSrcweir             << "()";
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     if ( i_rExceptions.operator bool() )
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         Xml::Element &
147cdf0e10cSrcweir             rExcOut = aDecl.Add_RaisesLine("raises", NOT bParams);
148cdf0e10cSrcweir         HF_IdlTypeText
149cdf0e10cSrcweir             aExc(Env(), rExcOut, true);
150cdf0e10cSrcweir         aExc.Produce_byData(*i_rExceptions);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir         for (++i_rExceptions; i_rExceptions; ++i_rExceptions)
153cdf0e10cSrcweir         {
154cdf0e10cSrcweir             rExcOut
155cdf0e10cSrcweir                 << ","
156cdf0e10cSrcweir                 << new Html::LineBreak;
157cdf0e10cSrcweir             aExc.Produce_byData(*i_rExceptions);
158cdf0e10cSrcweir         }   // end for
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         rExcOut << " );";
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir     else
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir         if (bParams)
165cdf0e10cSrcweir             aDecl.Names() << ";";
166cdf0e10cSrcweir         else
167cdf0e10cSrcweir             aDecl.Front() << ";";
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir #endif   // 0  old
171cdf0e10cSrcweir 
172cdf0e10cSrcweir void
write_Declaration(const String & i_sName,type_id i_nReturnType,param_list & i_rParams,type_list & i_rExceptions,bool i_bOneway,bool i_bEllipse) const173cdf0e10cSrcweir HF_IdlMethod::write_Declaration( const String &      i_sName,
174cdf0e10cSrcweir                                  type_id             i_nReturnType,
175cdf0e10cSrcweir                                  param_list &        i_rParams,
176cdf0e10cSrcweir                                  type_list &         i_rExceptions,
177cdf0e10cSrcweir                                  bool                i_bOneway,
178cdf0e10cSrcweir                                  bool				 i_bEllipse ) const
179cdf0e10cSrcweir {
180cdf0e10cSrcweir     HF_FunctionDeclaration
181cdf0e10cSrcweir         aDecl(CurOut(), "raises") ;
182cdf0e10cSrcweir     Xml::Element &
183cdf0e10cSrcweir         rReturnLine = aDecl.ReturnCell();
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     // Return line:
186cdf0e10cSrcweir     if (i_bOneway)
187cdf0e10cSrcweir         rReturnLine << "[oneway] ";
188cdf0e10cSrcweir     if (i_nReturnType.IsValid())
189cdf0e10cSrcweir     {   // Normal function, but not constructors:
190cdf0e10cSrcweir         HF_IdlTypeText
191cdf0e10cSrcweir             aReturn(Env(), rReturnLine, true);
192cdf0e10cSrcweir         aReturn.Produce_byData(i_nReturnType);
193cdf0e10cSrcweir     }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     //  Main line:
196cdf0e10cSrcweir     Xml::Element &
197cdf0e10cSrcweir         rNameCell = aDecl.NameCell();
198cdf0e10cSrcweir     rNameCell
199cdf0e10cSrcweir         >> *new Html::Bold
200cdf0e10cSrcweir             << i_sName;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     Xml::Element *
203cdf0e10cSrcweir         pParamEnd  = 0;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     bool bParams = i_rParams.operator bool();
206cdf0e10cSrcweir     if (bParams)
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         rNameCell
209cdf0e10cSrcweir             << "(";
210cdf0e10cSrcweir 
211cdf0e10cSrcweir         pParamEnd  = write_Param( aDecl, *i_rParams );
212cdf0e10cSrcweir         for (++i_rParams; i_rParams; ++i_rParams)
213cdf0e10cSrcweir         {
214cdf0e10cSrcweir             *pParamEnd << ",";
215cdf0e10cSrcweir             pParamEnd  = write_Param( aDecl, *i_rParams );
216cdf0e10cSrcweir         }   // end for
217cdf0e10cSrcweir 
218cdf0e10cSrcweir         if (i_bEllipse)
219cdf0e10cSrcweir         {
220cdf0e10cSrcweir             Xml::Element &
221cdf0e10cSrcweir                 rParamType = aDecl.NewParamTypeCell();
222cdf0e10cSrcweir             rParamType
223cdf0e10cSrcweir                 << " ...";
224cdf0e10cSrcweir             pParamEnd = &rParamType;
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir         *pParamEnd
227cdf0e10cSrcweir             << " )";
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir     else
230cdf0e10cSrcweir     {
231cdf0e10cSrcweir         rNameCell
232cdf0e10cSrcweir             << "()";
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     if ( i_rExceptions.operator bool() )
236cdf0e10cSrcweir     {
237cdf0e10cSrcweir         Xml::Element &
238cdf0e10cSrcweir             rExcOut = aDecl.ExceptionCell();
239cdf0e10cSrcweir         HF_IdlTypeText
240cdf0e10cSrcweir             aExc(Env(), rExcOut, true);
241cdf0e10cSrcweir         aExc.Produce_byData(*i_rExceptions);
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         for (++i_rExceptions; i_rExceptions; ++i_rExceptions)
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             rExcOut
246cdf0e10cSrcweir                 << ","
247cdf0e10cSrcweir                 << new Html::LineBreak;
248cdf0e10cSrcweir             aExc.Produce_byData(*i_rExceptions);
249cdf0e10cSrcweir         }   // end for
250cdf0e10cSrcweir 
251cdf0e10cSrcweir         rExcOut << " );";
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir     else if (bParams)
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         *pParamEnd << ";";
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir     else
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         rNameCell << ";";
260cdf0e10cSrcweir     }
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir #if 0   // old
264cdf0e10cSrcweir void
265cdf0e10cSrcweir HF_IdlMethod::write_Param( HF_IdlTypeText &             o_type,
266cdf0e10cSrcweir                            Xml::Element &               o_names,
267cdf0e10cSrcweir                            const ary::idl::Parameter &  i_param ) const
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     switch ( i_param.Direction() )
270cdf0e10cSrcweir     {
271cdf0e10cSrcweir         case ary::idl::param_in:
272cdf0e10cSrcweir                     o_type.CurOut() << "[in] ";
273cdf0e10cSrcweir                     break;
274cdf0e10cSrcweir         case ary::idl::param_out:
275cdf0e10cSrcweir                     o_type.CurOut() << "[out] ";
276cdf0e10cSrcweir                     break;
277cdf0e10cSrcweir         case ary::idl::param_inout:
278cdf0e10cSrcweir                     o_type.CurOut() << "[inout] ";
279cdf0e10cSrcweir                     break;
280cdf0e10cSrcweir     }   // end switch
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     o_type.Produce_byData( i_param.Type() );
283cdf0e10cSrcweir     o_names
284cdf0e10cSrcweir         << i_param.Name();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir #endif  // 0   old
287cdf0e10cSrcweir 
288cdf0e10cSrcweir Xml::Element *
write_Param(HF_FunctionDeclaration & o_decl,const ary::idl::Parameter & i_param) const289cdf0e10cSrcweir HF_IdlMethod::write_Param( HF_FunctionDeclaration &     o_decl,
290cdf0e10cSrcweir                            const ary::idl::Parameter &  i_param ) const
291cdf0e10cSrcweir {
292cdf0e10cSrcweir     Xml::Element &
293cdf0e10cSrcweir         rTypeCell  = o_decl.NewParamTypeCell();
294cdf0e10cSrcweir     Xml::Element &
295cdf0e10cSrcweir         rNameCell  = o_decl.ParamNameCell();
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     switch ( i_param.Direction() )
298cdf0e10cSrcweir     {
299cdf0e10cSrcweir         case ary::idl::param_in:
300cdf0e10cSrcweir                     rTypeCell << "[in] ";
301cdf0e10cSrcweir                     break;
302cdf0e10cSrcweir         case ary::idl::param_out:
303cdf0e10cSrcweir                     rTypeCell << "[out] ";
304cdf0e10cSrcweir                     break;
305cdf0e10cSrcweir         case ary::idl::param_inout:
306cdf0e10cSrcweir                     rTypeCell << "[inout] ";
307cdf0e10cSrcweir                     break;
308cdf0e10cSrcweir     }   // end switch
309cdf0e10cSrcweir 
310cdf0e10cSrcweir     HF_IdlTypeText
311cdf0e10cSrcweir         aTypeWriter(Env(), rTypeCell, true);
312cdf0e10cSrcweir     aTypeWriter.Produce_byData( i_param.Type() );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     rNameCell
315cdf0e10cSrcweir         << i_param.Name();
316cdf0e10cSrcweir     return &rNameCell;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir const String sContentBorder("0");
320cdf0e10cSrcweir const String sContentWidth("96%");
321cdf0e10cSrcweir const String sContentPadding("5");
322cdf0e10cSrcweir const String sContentSpacing("0");
323cdf0e10cSrcweir 
324cdf0e10cSrcweir const String sBgWhite("#ffffff");
325cdf0e10cSrcweir const String sCenter("center");
326cdf0e10cSrcweir 
327cdf0e10cSrcweir void
enter_ContentCell() const328cdf0e10cSrcweir HF_IdlMethod::enter_ContentCell() const
329cdf0e10cSrcweir {
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     Xml::Element &
332cdf0e10cSrcweir         rContentCell = CurOut()
333cdf0e10cSrcweir                         >> *new Html::Table( sContentBorder,
334cdf0e10cSrcweir                                              sContentWidth,
335cdf0e10cSrcweir                                              sContentPadding,
336cdf0e10cSrcweir                                              sContentSpacing )
337cdf0e10cSrcweir                             << new Html::ClassAttr("table-in-method")
338cdf0e10cSrcweir                             << new Html::BgColorAttr(sBgWhite)
339cdf0e10cSrcweir                             << new Html::AlignAttr(sCenter)
340cdf0e10cSrcweir                             >> *new Html::TableRow
341cdf0e10cSrcweir                                 >> *new Html::TableCell;
342cdf0e10cSrcweir     Out().Enter(rContentCell);
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 
346cdf0e10cSrcweir void
leave_ContentCell() const347cdf0e10cSrcweir HF_IdlMethod::leave_ContentCell() const
348cdf0e10cSrcweir {
349cdf0e10cSrcweir     Out().Leave();
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
352