Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_iface.cxx
blob7a94938d518fe8f2b575030333bc2dfdd6f3b8e0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include <s2_luidl/pe_iface.hxx>
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_interface.hxx>
35 #include <ary/idl/i_gate.hxx>
36 #include <ary/idl/ip_ce.hxx>
37 #include <ary/doc/d_oldidldocu.hxx>
38 #include <s2_luidl/pe_func2.hxx>
39 #include <s2_luidl/pe_attri.hxx>
40 #include <s2_luidl/pe_type2.hxx>
41 #include <s2_luidl/tk_keyw.hxx>
42 #include <s2_luidl/tk_ident.hxx>
43 #include <s2_luidl/tk_punct.hxx>
44 #include <adc_cl.hxx>
48 namespace csi
50 namespace uidl
53 #ifdef DF
54 #undef DF
55 #endif
56 #define DF &PE_Interface::On_Default
58 PE_Interface::F_TOK
59 PE_Interface::aDispatcher[PE_Interface::e_STATES_MAX][PE_Interface::tt_MAX] =
60 { { DF, DF, DF, DF, DF }, // e_none
61 { &PE_Interface::On_need_uik_MetaType,
62 DF, DF, DF, DF }, // need_uik
63 { DF, &PE_Interface::On_uik_Identifier,
64 &PE_Interface::On_uik_Punctuation,
65 DF, DF }, // uik
66 { &PE_Interface::On_need_ident_MetaType,
67 DF, DF, DF, DF }, // need_ident
68 { DF, &PE_Interface::On_ident_Identifier,
69 &PE_Interface::On_ident_Punctuation,
70 DF, DF }, // ident
71 { &PE_Interface::On_need_interface_MetaType,
72 DF, DF, DF, DF }, // need_interface
73 { DF, &PE_Interface::On_need_name_Identifer,
74 DF, DF, DF }, // need_name
75 { DF, DF, &PE_Interface::On_wait_for_base_Punctuation,
76 DF, DF }, // wait_for_base
77 { DF, DF, DF, DF, DF }, // in_base
78 { DF, DF, &PE_Interface::On_need_curlbr_open_Punctuation,
79 DF, DF }, // need_curlbr_open
80 { &PE_Interface::On_std_Metatype,
81 &PE_Interface::On_std_GotoFunction,
82 &PE_Interface::On_std_Punctuation,
83 &PE_Interface::On_std_GotoFunction,
84 &PE_Interface::On_std_Stereotype }, // e_std
85 { DF, DF, DF, DF, DF }, // in_function
86 { DF, DF, DF, DF, DF }, // in_attribute
87 { DF, DF, &PE_Interface::On_need_finish_Punctuation,
88 DF, DF }, // need_finish
89 { DF, DF, DF, DF, DF } // in_base_interface
94 inline void
95 PE_Interface::CallHandler( const char * i_sTokenText,
96 E_TokenType i_eTokenType )
97 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
101 PE_Interface::PE_Interface()
102 : eState(e_none),
103 sData_Name(),
104 bIsPreDeclaration(false),
105 pCurInterface(0),
106 nCurInterface(0),
107 pPE_Function(0),
108 pPE_Attribute(0),
109 pPE_Type(0),
110 nCurParsed_Base(0),
111 bOptionalMember(false)
113 pPE_Function = new PE_Function(nCurInterface);
114 pPE_Type = new PE_Type(nCurParsed_Base);
115 pPE_Attribute = new PE_Attribute(nCurInterface);
118 void
119 PE_Interface::EstablishContacts( UnoIDL_PE * io_pParentPE,
120 ary::Repository & io_rRepository,
121 TokenProcessing_Result & o_rResult )
123 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
124 pPE_Function->EstablishContacts(this,io_rRepository,o_rResult);
125 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
126 pPE_Attribute->EstablishContacts(this,io_rRepository,o_rResult);
129 PE_Interface::~PE_Interface()
133 void
134 PE_Interface::ProcessToken( const Token & i_rToken )
136 i_rToken.Trigger(*this);
140 void
141 PE_Interface::Process_MetaType( const TokMetaType & i_rToken )
143 CallHandler( i_rToken.Text(), tt_metatype );
146 void
147 PE_Interface::Process_Identifier( const TokIdentifier & i_rToken )
149 CallHandler( i_rToken.Text(), tt_identifier );
152 void
153 PE_Interface::Process_Punctuation( const TokPunctuation & i_rToken )
155 CallHandler( i_rToken.Text(), tt_punctuation );
158 void
159 PE_Interface::Process_NameSeparator()
161 CallHandler( "", tt_startoftype );
164 void
165 PE_Interface::Process_BuiltInType( const TokBuiltInType & i_rToken )
167 CallHandler( i_rToken.Text(), tt_startoftype );
170 void
171 PE_Interface::Process_TypeModifier( const TokTypeModifier & i_rToken )
173 CallHandler( i_rToken.Text(), tt_startoftype );
176 void
177 PE_Interface::Process_Stereotype( const TokStereotype & i_rToken )
179 CallHandler( i_rToken.Text(), tt_stereotype );
182 void
183 PE_Interface::Process_Default()
185 SetResult(done, stay);
189 void
190 PE_Interface::On_need_uik_MetaType(SAL_UNUSED_PARAMETER const char *)
192 // Deprecated, data will be ignored
193 SetResult(done, stay);
194 eState = uik;
197 void
198 PE_Interface::On_uik_Identifier(SAL_UNUSED_PARAMETER const char *)
200 // Deprecated, data will be ignored
201 SetResult(done, stay);
204 void
205 PE_Interface::On_uik_Punctuation(const char * i_sText)
207 // Deprecated, data will be ignored
208 SetResult(done, stay);
209 if (strcmp(",",i_sText) == 0)
211 eState = need_ident;
215 void
216 PE_Interface::On_need_ident_MetaType(SAL_UNUSED_PARAMETER const char *)
218 SetResult(done, stay);
219 eState = ident;
222 void
223 PE_Interface::On_ident_Identifier(SAL_UNUSED_PARAMETER const char *)
225 SetResult(done, stay);
228 void
229 PE_Interface::On_ident_Punctuation(const char * i_sText)
231 SetResult(done, stay);
232 if (strcmp(")",i_sText) == 0)
234 eState = need_interface;
238 void
239 PE_Interface::On_need_interface_MetaType(SAL_UNUSED_PARAMETER const char *)
241 SetResult(done, stay);
242 eState = need_name;
245 void
246 PE_Interface::On_need_name_Identifer(const char * i_sText)
248 SetResult(done, stay);
249 sData_Name = i_sText;
250 eState = wait_for_base;
253 void
254 PE_Interface::On_wait_for_base_Punctuation(const char * i_sText)
256 if (i_sText[0] != ';')
258 switch (i_sText[0])
260 case ':':
261 SetResult(done, push_sure, pPE_Type.Ptr());
262 eState = in_base;
263 break;
264 case '{':
265 store_Interface();
267 SetResult(done,stay);
268 eState = e_std;
269 break;
270 default:
271 SetResult(not_done, pop_failure);
272 eState = e_none;
273 } // end switch
275 else
277 bIsPreDeclaration = true;
278 SetResult(done, pop_success);
279 eState = e_none;
283 void
284 PE_Interface::On_need_curlbr_open_Punctuation(const char * i_sText)
286 if (i_sText[0] == '{')
288 store_Interface();
290 SetResult(done, stay);
291 eState = e_std;
293 else {
294 csv_assert(false);
299 void
300 PE_Interface::On_std_Metatype(const char * i_sText)
302 if (strcmp(i_sText,"attribute") == 0)
303 On_std_GotoAttribute(i_sText);
304 else if (strcmp(i_sText,"interface") == 0)
305 On_std_GotoBaseInterface(i_sText);
306 else
307 On_std_GotoFunction(i_sText);
310 void
311 PE_Interface::On_std_Punctuation(const char * i_sText)
313 switch (i_sText[0])
315 case '}':
316 SetResult(done, stay);
317 eState = need_finish;
318 break;
319 case ';': // Appears after base interface declarations.
320 SetResult(done, stay);
321 break;
322 default:
323 SetResult(not_done, pop_failure);
324 eState = e_none;
325 } // end switch
328 void
329 PE_Interface::On_std_Stereotype(const char * i_sText)
331 if (strcmp(i_sText,"oneway") == 0)
332 On_std_GotoFunction(i_sText);
333 else if ( strcmp(i_sText,"readonly") == 0
334 OR strcmp(i_sText,"bound") == 0 )
335 On_std_GotoAttribute(i_sText);
336 else if (strcmp(i_sText,"optional") == 0)
338 bOptionalMember = true;
339 SetResult(done, stay);
341 else
342 SetResult(not_done, pop_failure);
345 void
346 PE_Interface::On_std_GotoFunction(SAL_UNUSED_PARAMETER const char * )
348 SetResult(not_done, push_sure, pPE_Function.Ptr());
349 eState = in_function;
352 void
353 PE_Interface::On_std_GotoAttribute(SAL_UNUSED_PARAMETER const char * )
355 SetResult(not_done, push_sure, pPE_Attribute.Ptr());
356 eState = in_attribute;
359 void
360 PE_Interface::On_std_GotoBaseInterface(SAL_UNUSED_PARAMETER const char * )
362 SetResult(done, push_sure, pPE_Type.Ptr());
363 eState = in_base_interface;
366 void
367 PE_Interface::On_need_finish_Punctuation(const char * i_sText)
369 switch (i_sText[0])
371 case ';':
372 SetResult(done, pop_success);
373 eState = e_none;
374 break;
375 default:
376 SetResult(not_done, pop_failure);
377 eState = e_none;
378 } // end switch
381 void
382 PE_Interface::On_Default(SAL_UNUSED_PARAMETER const char *)
384 SetResult(not_done, pop_failure);
387 void
388 PE_Interface::InitData()
390 eState = need_interface;
392 sData_Name.clear();
393 bIsPreDeclaration = false;
394 pCurInterface = 0;
395 nCurInterface = 0;
396 nCurParsed_Base = 0;
397 bOptionalMember = false;
400 void
401 PE_Interface::TransferData()
403 if (NOT bIsPreDeclaration)
405 csv_assert(sData_Name.size() > 0);
406 csv_assert(nCurInterface.IsValid());
408 else
410 sData_Name.clear();
411 pCurInterface = 0;
412 nCurInterface = 0;
415 eState = e_none;
418 void
419 PE_Interface::ReceiveData()
421 switch (eState)
423 case in_base:
424 eState = need_curlbr_open;
425 break;
426 case in_function:
427 eState = e_std;
428 break;
429 case in_attribute:
430 eState = e_std;
431 break;
432 case in_base_interface:
433 if (bOptionalMember)
435 pPE_Type->SetOptional();
436 bOptionalMember = false;
438 pCurInterface->Add_Base(
439 nCurParsed_Base,
440 pPE_Type->ReleaseDocu());
441 nCurParsed_Base = 0;
442 eState = e_std;
443 break;
444 default:
445 csv_assert(false);
449 UnoIDL_PE &
450 PE_Interface::MyPE()
452 return *this;
455 void
456 PE_Interface::store_Interface()
458 pCurInterface = & Gate().Ces().Store_Interface(
459 CurNamespace().CeId(),
460 sData_Name,
461 nCurParsed_Base );
462 nCurInterface = pCurInterface->CeId();
463 PassDocuAt(*pCurInterface);
467 } // namespace uidl
468 } // namespace csi
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */