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 ************************************************************************/
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>
56 #define DF &PE_Interface::On_Default
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
,
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
,
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
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()
104 bIsPreDeclaration(false),
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
);
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()
134 PE_Interface::ProcessToken( const Token
& i_rToken
)
136 i_rToken
.Trigger(*this);
141 PE_Interface::Process_MetaType( const TokMetaType
& i_rToken
)
143 CallHandler( i_rToken
.Text(), tt_metatype
);
147 PE_Interface::Process_Identifier( const TokIdentifier
& i_rToken
)
149 CallHandler( i_rToken
.Text(), tt_identifier
);
153 PE_Interface::Process_Punctuation( const TokPunctuation
& i_rToken
)
155 CallHandler( i_rToken
.Text(), tt_punctuation
);
159 PE_Interface::Process_NameSeparator()
161 CallHandler( "", tt_startoftype
);
165 PE_Interface::Process_BuiltInType( const TokBuiltInType
& i_rToken
)
167 CallHandler( i_rToken
.Text(), tt_startoftype
);
171 PE_Interface::Process_TypeModifier( const TokTypeModifier
& i_rToken
)
173 CallHandler( i_rToken
.Text(), tt_startoftype
);
177 PE_Interface::Process_Stereotype( const TokStereotype
& i_rToken
)
179 CallHandler( i_rToken
.Text(), tt_stereotype
);
183 PE_Interface::Process_Default()
185 SetResult(done
, stay
);
190 PE_Interface::On_need_uik_MetaType(SAL_UNUSED_PARAMETER
const char *)
192 // Deprecated, data will be ignored
193 SetResult(done
, stay
);
198 PE_Interface::On_uik_Identifier(SAL_UNUSED_PARAMETER
const char *)
200 // Deprecated, data will be ignored
201 SetResult(done
, stay
);
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)
216 PE_Interface::On_need_ident_MetaType(SAL_UNUSED_PARAMETER
const char *)
218 SetResult(done
, stay
);
223 PE_Interface::On_ident_Identifier(SAL_UNUSED_PARAMETER
const char *)
225 SetResult(done
, stay
);
229 PE_Interface::On_ident_Punctuation(const char * i_sText
)
231 SetResult(done
, stay
);
232 if (strcmp(")",i_sText
) == 0)
234 eState
= need_interface
;
239 PE_Interface::On_need_interface_MetaType(SAL_UNUSED_PARAMETER
const char *)
241 SetResult(done
, stay
);
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
;
254 PE_Interface::On_wait_for_base_Punctuation(const char * i_sText
)
256 if (i_sText
[0] != ';')
261 SetResult(done
, push_sure
, pPE_Type
.Ptr());
267 SetResult(done
,stay
);
271 SetResult(not_done
, pop_failure
);
277 bIsPreDeclaration
= true;
278 SetResult(done
, pop_success
);
284 PE_Interface::On_need_curlbr_open_Punctuation(const char * i_sText
)
286 if (i_sText
[0] == '{')
290 SetResult(done
, stay
);
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
);
307 On_std_GotoFunction(i_sText
);
311 PE_Interface::On_std_Punctuation(const char * i_sText
)
316 SetResult(done
, stay
);
317 eState
= need_finish
;
319 case ';': // Appears after base interface declarations.
320 SetResult(done
, stay
);
323 SetResult(not_done
, pop_failure
);
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
);
342 SetResult(not_done
, pop_failure
);
346 PE_Interface::On_std_GotoFunction(SAL_UNUSED_PARAMETER
const char * )
348 SetResult(not_done
, push_sure
, pPE_Function
.Ptr());
349 eState
= in_function
;
353 PE_Interface::On_std_GotoAttribute(SAL_UNUSED_PARAMETER
const char * )
355 SetResult(not_done
, push_sure
, pPE_Attribute
.Ptr());
356 eState
= in_attribute
;
360 PE_Interface::On_std_GotoBaseInterface(SAL_UNUSED_PARAMETER
const char * )
362 SetResult(done
, push_sure
, pPE_Type
.Ptr());
363 eState
= in_base_interface
;
367 PE_Interface::On_need_finish_Punctuation(const char * i_sText
)
372 SetResult(done
, pop_success
);
376 SetResult(not_done
, pop_failure
);
382 PE_Interface::On_Default(SAL_UNUSED_PARAMETER
const char *)
384 SetResult(not_done
, pop_failure
);
388 PE_Interface::InitData()
390 eState
= need_interface
;
393 bIsPreDeclaration
= false;
397 bOptionalMember
= false;
401 PE_Interface::TransferData()
403 if (NOT bIsPreDeclaration
)
405 csv_assert(sData_Name
.size() > 0);
406 csv_assert(nCurInterface
.IsValid());
419 PE_Interface::ReceiveData()
424 eState
= need_curlbr_open
;
432 case in_base_interface
:
435 pPE_Type
->SetOptional();
436 bOptionalMember
= false;
438 pCurInterface
->Add_Base(
440 pPE_Type
->ReleaseDocu());
456 PE_Interface::store_Interface()
458 pCurInterface
= & Gate().Ces().Store_Interface(
459 CurNamespace().CeId(),
462 nCurInterface
= pCurInterface
->CeId();
463 PassDocuAt(*pCurInterface
);
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */