/src/tools/wrappers-generator/c_variable.e
Specman e | 134 lines | 93 code | 13 blank | 28 comment | 2 complexity | e2df5fc793ca352df7ffe0f5b5b5969b MD5 | raw file
1class C_VARIABLE 2 3inherit 4 CONTEXTED_NODE 5 IDENTIFIED_NODE 6 MOVABLE_NODE 7 -- hence a NAMED_NODE and a FILED_NODE 8 TYPED_NODE 9 STORABLE_NODE 10 WRAPPER_FEATURE 11 12create {GCCXML_TREE} 13 make 14 15feature {ANY} 16 store 17 do 18 symbols.put(Current, c_string_name) 19 variables.add_first(Current) 20 end 21 22 is_to_be_emitted: BOOLEAN 23 do 24 Result := (is_public or has_assigned_name) and then (global or else headers.has(c_file.c_string_name)) 25 end 26 27 wrap_on (a_stream: OUTPUT_STREAM) 28 do 29 if not has_wrapper then 30 log("Variable `#(1)' does not have a wrapper type (address of query emitted anyway)%N" # c_string_name) 31 buffer.reset 32 buffer.append(once " -- Variable #(1) in file %"#(2)%" does not have a wrapper type%N" # 33 c_string_name # c_file.c_string_name ) 34 -- TODO: provide the reason; using developer_exception_name 35 -- triggers some recursion bug AFAIK. Paolo 2009-10-02 36 37 buffer.append(once " address_of_#(1): POINTER%N% 38 % -- Address of #(1)%N% 39 % external %"plug_in%"%N% 40 % alias %"{%N% 41 % location: %".%"%N% 42 % module_name: %"plugin%"%N% 43 % feature_name: %"&#(2)%"%N% 44 % }%"%N% 45 % end%N%N" # 46 eiffel_feature(c_string_name) # c_string_name) 47 -- For debugging purpose the line where the node occurred were once 48 -- printed in the comment, like this: 49 50 -- buffer.append(once 51 -- " address_of_#(1): POINTER%N% 52 -- % -- Address of #(1) (node at line #(2))%N% 53 -- % external %"plug_in%"%N% 54 -- % alias %"{%N% 55 -- % location: %".%"%N% 56 -- % module_name: %"plugin%"%N% 57 -- % feature_name: %"&#(3)%"%N% 58 -- % }%"%N% 59 -- % end%N%N" # eiffel_feature(c_string_name) # line_row.to_utf8 # c_string_name) 60 61 -- this information is not printed anymore to make the generated 62 -- classes a little more stable, avoiding unnecessary changes. 63 elseif not is_public then 64 log(once "Skipping 'hidden' variable `#(1)'%N" # c_string_name) 65 buffer.append(once "%T-- `hidden' variable #(1) skipped.%N" # c_string_name) 66 elseif not namespace.is_main then 67 log(once "Skipping variable `#(1)' belonging to namespace #(2)%N" # c_string_name # namespace.c_string_name) 68 buffer.append(once "%T-- variable #(1) in namespace #(2) skipped.%N" # c_string_name # namespace.c_string_name) 69 else 70 log(once "Variable #(1)%N" # c_string_name) 71 buffer.append(once "%T#(1): #(2)%N% 72 % -- #(1)%N% 73 % external %"plug_in%"%N% 74 % alias %"{%N% 75 % location: %".%"%N% 76 % module_name: %"plugin%"%N% 77 % feature_name: %"#(3)%"%N% 78 % }%"%N% 79 % end%N% 80 %%N% 81 % address_of_#(1): POINTER%N% 82 % -- Address of #(1)%N% 83 % external %"plug_in%"%N% 84 % alias %"{%N% 85 % location: %".%"%N% 86 % module_name: %"plugin%"%N% 87 % feature_name: %"&#(3)%"%N% 88 % }%"%N% 89 % end%N% 90 %%N% 91 % set_#(1) (a_value: #(2))%N% 92 % -- Set variable #(1) value%N% 93 % external %"plug_in%"%N% 94 % alias %"{%N% 95 % location: %".%"%N% 96 % module_name: %"plugin%"%N% 97 % feature_name: %"set_#(3)%"%N% 98 % }%"%N% 99 % end%N%N" # 100 eiffel_feature(c_string_name) # wrapper_type # c_string_name) 101 ("#define set_#(1)(a_value) #(1) = (a_value);%N" # c_string_name).print_on(include) 102 end 103 buffer.print_on(a_stream) 104 end 105 106 is_void: BOOLEAN False 107 108 wrapper_type: STRING 109 do 110 Result := types.at(dequalify(type)).wrapper_type 111 end 112 113 has_wrapper: BOOLEAN 114 do 115 Result := types.at(dequalify(type)).has_wrapper 116 end 117 118 is_fundamental: BOOLEAN 119 do 120 Result := types.at(dequalify(type)).is_fundamental 121 end 122 123end -- class C_VARIABLE 124-- Copyright (C) 2008-2017: Paolo Redaelli 125-- wrappers-generator is free software: you can redistribute it and/or modify it 126-- under the terms of the GNU General Public License as publhed by the Free 127-- Software Foundation, either version 2 of the License, or (at your option) 128-- any later version. 129-- wrappers-generator is distributed in the hope that it will be useful, but 130-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 131-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 132-- more details. 133-- You should have received a copy of the GNU General Public License along with 134-- th program. If not, see <http://www.gnu.org/licenses/>.