1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <precomp.h> 29 #include "pe_enval.hxx" 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <cosv/tpl/tpltools.hxx> 34 #include <ary/cpp/c_gate.hxx> 35 #include <ary/cpp/cp_ce.hxx> 36 #include "pe_expr.hxx" 37 38 39 40 namespace cpp { 41 42 43 PE_EnumValue::PE_EnumValue( Cpp_PE * i_pParent ) 44 : Cpp_PE(i_pParent), 45 pStati( new PeStatusArray<PE_EnumValue> ) 46 // pSpExpression, 47 // pSpuInitExpression 48 { 49 Setup_StatusFunctions(); 50 51 pSpExpression = new SP_Expression(*this); 52 pSpuInitExpression = new SPU_Expression(*pSpExpression, 0, &PE_EnumValue::SpReturn_InitExpression); 53 } 54 55 PE_EnumValue::~PE_EnumValue() 56 { 57 } 58 59 void 60 PE_EnumValue::Call_Handler( const cpp::Token & i_rTok ) 61 { 62 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text()); 63 } 64 65 void 66 PE_EnumValue::Setup_StatusFunctions() 67 { 68 typedef CallFunction<PE_EnumValue>::F_Tok F_Tok; 69 70 static F_Tok stateF_start[] = { &PE_EnumValue::On_start_Identifier }; 71 static INT16 stateT_start[] = { Tid_Identifier }; 72 73 static F_Tok stateF_afterName[] = { &PE_EnumValue::On_afterName_SwBracket_Right, 74 &PE_EnumValue::On_afterName_Comma, 75 &PE_EnumValue::On_afterName_Assign }; 76 static INT16 stateT_afterName[] = { Tid_SwBracket_Right, 77 Tid_Comma, 78 Tid_Assign }; 79 80 static F_Tok stateF_expectFinish[] = { &PE_EnumValue::On_expectFinish_SwBracket_Right, 81 &PE_EnumValue::On_expectFinish_Comma }; 82 static INT16 stateT_expectFinish[] = { Tid_SwBracket_Right, 83 Tid_Comma }; 84 85 SEMPARSE_CREATE_STATUS(PE_EnumValue, start, Hdl_SyntaxError); 86 SEMPARSE_CREATE_STATUS(PE_EnumValue, afterName, Hdl_SyntaxError); 87 SEMPARSE_CREATE_STATUS(PE_EnumValue, expectFinish, Hdl_SyntaxError); 88 } 89 90 void 91 PE_EnumValue::InitData() 92 { 93 pStati->SetCur(start); 94 95 sName.clear(); 96 sInitExpression.clear(); 97 } 98 99 void 100 PE_EnumValue::TransferData() 101 { 102 pStati->SetCur(size_of_states); 103 104 ary::cpp::EnumValue & 105 rEnVal = Env().AryGate().Ces().Store_EnumValue( 106 Env().Context(), sName, sInitExpression ); 107 Env().Event_Store_EnumValue(rEnVal); 108 } 109 110 void 111 PE_EnumValue::Hdl_SyntaxError( const char * i_sText) 112 { 113 StdHandlingOfSyntaxError(i_sText); 114 } 115 116 void 117 PE_EnumValue::SpReturn_InitExpression() 118 { 119 pStati->SetCur(expectFinish); 120 121 sInitExpression = pSpuInitExpression->Child().Result_Text(); 122 } 123 124 void 125 PE_EnumValue::On_start_Identifier(const char * i_sText) 126 { 127 SetTokenResult(done, stay); 128 pStati->SetCur(afterName); 129 130 sName = i_sText; 131 } 132 133 void 134 PE_EnumValue::On_afterName_SwBracket_Right(const char *) 135 { 136 SetTokenResult(not_done, pop_success); 137 } 138 139 void 140 PE_EnumValue::On_afterName_Comma(const char * ) 141 { 142 SetTokenResult(done, pop_success); 143 } 144 145 void 146 PE_EnumValue::On_afterName_Assign(const char * ) 147 { 148 pSpuInitExpression->Push(done); 149 } 150 151 void 152 PE_EnumValue::On_expectFinish_SwBracket_Right(const char * ) 153 { 154 SetTokenResult(not_done, pop_success); 155 } 156 157 void 158 PE_EnumValue::On_expectFinish_Comma(const char * ) 159 { 160 SetTokenResult(done, pop_success); 161 } 162 163 164 } // namespace cpp 165 166 167 168 169