9 var is_variable
= false
11 var is_parameter_name
= false
12 var class_objc
: nullable ObjcClass = null
13 var method_objc
: ObjcMethod is noinit
14 var attribute_objc
: ObjcAttribute is noinit
15 var param
: Param is noinit
16 var model
= new ObjcModel
18 redef fun visit
(n
) do n
.accept_objc
(self)
22 fun accept_objc
(v
: Interpretor) do visit_children
(v
)
26 redef fun accept_objc
(v
) do
30 redef class Nlines_interface
31 redef fun accept_objc
(v
) do
32 var interface_block
= n_interface_block
33 var inheritance_block
= n_inheritance
35 if interface_block
!= null then
36 for class_objc
in v
.model
.classes
do
37 if class_objc
.name
== n_class
.text
then
38 v
.class_objc
= class_objc
41 if v
.class_objc
== null then
42 v
.class_objc
= new ObjcClass(n_class
.text
)
43 v
.model
.classes
.add
(v
.class_objc
)
45 if inheritance_block
!= null then v
.enter_visit
(inheritance_block
)
46 v
.enter_visit
(interface_block
)
51 redef class Ninheritance_add
52 redef fun accept_objc
(v
) do
53 var additional
= n_additional
54 v
.enter_visit
(n_classe
)
55 if additional
!= null then v
.enter_visit
(additional
)
59 redef class Nclasse_class
60 redef fun accept_objc
(v
) do
61 v
.class_objc
.super_names
.add
(n_class
.text
)
65 redef class Nadditional_add
66 redef fun accept_objc
(v
) do
67 v
.enter_visit
(n_classe
)
71 redef class Ninterface_block_instance
72 redef fun accept_objc
(v
) do
73 v
.enter_visit
(n_instance_declaration
)
77 redef class Ninstance_declaration_signature
78 redef fun accept_objc
(v
) do
79 v
.enter_visit
(n_signature_block
)
83 redef class Ninstance_declaration_property
84 redef fun accept_objc
(v
) do
85 v
.enter_visit
(n_property_declaration
)
89 redef class Nproperty_declaration_property
90 redef fun accept_objc
(v
) do
91 v
.enter_visit
(n_property
)
95 redef class Nsignature_block_signature
96 redef fun accept_objc
(v
) do
97 if n_signature
.children
.to_s
.has
("signature_named") or n_signature
.children
.to_s
.has
("signature_single") then
98 v
.method_objc
= new ObjcMethod
100 v
.enter_visit
(n_scope
)
102 var signature_return_type
= n_signature_return_type
103 if signature_return_type
!= null then v
.enter_visit
(signature_return_type
)
105 v
.enter_visit
(n_signature
)
107 v
.class_objc
.methods
.add
(v
.method_objc
)
112 redef class Nscope_instance
113 redef fun accept_objc
(v
) do
114 v
.method_objc
.scope
= '-'
118 redef class Nscope_class
119 redef fun accept_objc
(v
) do
120 v
.method_objc
.scope
= '+'
124 redef class Nsignature_return_type_return
125 redef fun accept_objc
(v
) do
126 v
.enter_visit
(n_type
)
130 redef class Nsignature_named
131 redef fun accept_objc
(v
) do
134 v
.enter_visit
(n_left
)
135 v
.is_parameter_name
= true
136 v
.enter_visit
(n_right
)
137 v
.is_parameter_name
= false
138 v
.enter_visit
(n_signature_type
)
140 v
.method_objc
.params
.add
(v
.param
)
144 redef class Nsignature_single
145 redef fun accept_objc
(v
) do
147 v
.param
.is_single
= true
148 v
.enter_visit
(n_term
)
149 v
.method_objc
.params
.add
(v
.param
)
153 redef class Nsignature_type_anonymous
154 redef fun accept_objc
(v
) do
155 v
.enter_visit
(n_type
)
156 v
.method_objc
.is_commented
= true
160 redef class Nsignature_type_table
161 redef fun accept_objc
(v
) do
162 v
.enter_visit
(n_type
)
163 v
.param
.is_table
= true
167 redef class Nsignature_type_pointer
168 redef fun accept_objc
(v
) do
169 v
.enter_visit
(n_type
)
170 v
.param
.is_pointer
= true
174 redef class Nsignature_type_unsigned
175 redef fun accept_objc
(v
) do
176 v
.method_objc
.is_commented
= true
177 v
.param
.is_pointer
= true
181 redef class Nsignature_type_protocol
182 redef fun accept_objc
(v
) do
183 v
.enter_visit
(n_type
)
184 v
.method_objc
.is_commented
= true
188 redef class Nsignature_type_normal
189 redef fun accept_objc
(v
) do
190 v
.enter_visit
(n_type
)
194 redef class Nterm_private
195 redef fun accept_objc
(v
) do
196 if v
.is_parameter_name
then
197 v
.param
.variable_name
= n_private
.text
198 else if v
.is_variable
then
199 v
.attribute_objc
.name
= n_private
.text
201 v
.param
.name
= n_private
.text
206 redef class Nterm_class
207 redef fun accept_objc
(v
) do
208 if v
.is_parameter_name
then
209 v
.param
.variable_name
= n_class
.text
210 else if v
.is_variable
then
211 v
.attribute_objc
.name
= n_class
.text
213 v
.param
.name
= n_class
.text
218 redef class Nterm_var
219 redef fun accept_objc
(v
) do
220 if v
.is_parameter_name
then
221 v
.param
.variable_name
= n_id
.text
222 else if v
.is_variable
then
223 v
.attribute_objc
.name
= n_id
.text
225 v
.param
.name
= n_id
.text
230 redef class Nproperty_property
231 redef fun accept_objc
(v
) do
232 var protocol
= n_protocols
233 if protocol
== null then
235 v
.attribute_objc
= new ObjcAttribute
236 v
.enter_visit
(n_left
)
237 v
.enter_visit
(n_type
)
238 v
.class_objc
.attributes
.add
(v
.attribute_objc
)
239 v
.is_variable
= false
244 redef class Ntype_type
245 redef fun accept_objc
(v
) do
246 v
.enter_visit
(n_data_type
)
250 redef class Ndata_type_more
251 redef fun accept_objc
(v
) do
252 v
.enter_visit
(n_more_type
)
256 redef class Ndata_type_otype
257 redef fun accept_objc
(v
) do
258 if v
.is_variable
then
259 v
.attribute_objc
.return_type
= n_class
.text
260 else if v
.is_method
then
261 v
.method_objc
.return_type
= n_class
.text
263 v
.param
.return_type
= n_class
.text
268 redef class Nmore_type_stype
269 redef fun accept_objc
(v
) do
270 v
.enter_visit
(n_specific_type
)
274 redef class Nmore_type_ptype
275 redef fun accept_objc
(v
) do
276 v
.enter_visit
(n_primitive_type
)
280 redef class Nspecific_type_i
281 redef fun accept_objc
(v
) do
282 if v
.is_variable
then
283 v
.attribute_objc
.return_type
= "id"
284 else if v
.is_method
then
285 v
.method_objc
.return_type
= "id"
287 v
.param
.return_type
= "id"
292 redef class Nspecific_type_b
293 redef fun accept_objc
(v
) do
294 if v
.is_variable
then
295 v
.attribute_objc
.return_type
= "Bool"
296 else if v
.is_method
then
297 v
.method_objc
.return_type
= "Bool"
299 v
.param
.return_type
= "Bool"
304 redef class Nspecific_type_val
305 redef fun accept_objc
(v
) do
306 if v
.is_variable
then
307 v
.attribute_objc
.return_type
= "va_list"
308 else if v
.is_method
then
309 v
.method_objc
.return_type
= "va_list"
311 v
.param
.return_type
= "va_list"
316 redef class Nspecific_type_v
317 redef fun accept_objc
(v
) do
318 if v
.is_variable
then
319 v
.attribute_objc
.return_type
= "void"
320 else if v
.is_method
then
321 v
.method_objc
.return_type
= "void"
323 v
.param
.return_type
= "void"
328 redef class Nprimitive_type_ui8
329 redef fun accept_objc
(v
) do
330 if v
.is_variable
then
331 v
.attribute_objc
.return_type
= "uint8_t"
332 else if v
.is_method
then
333 v
.method_objc
.return_type
= "uint8_t"
335 v
.param
.return_type
= "uint8_t"
340 redef class Nprimitive_type_ui16
341 redef fun accept_objc
(v
) do
342 if v
.is_variable
then
343 v
.attribute_objc
.return_type
= "uint16_t"
344 else if v
.is_method
then
345 v
.method_objc
.return_type
= "uint16_t"
347 v
.param
.return_type
= "uint16_t"
352 redef class Nprimitive_type_ui32
353 redef fun accept_objc
(v
) do
354 if v
.is_variable
then
355 v
.attribute_objc
.return_type
= "uint32_t"
356 else if v
.is_method
then
357 v
.method_objc
.return_type
= "uint32_t"
359 v
.param
.return_type
= "uint32_t"
364 redef class Nprimitive_type_ui64
365 redef fun accept_objc
(v
) do
366 if v
.is_variable
then
367 v
.attribute_objc
.return_type
= "uint64_t"
368 else if v
.is_method
then
369 v
.method_objc
.return_type
= "uint64_t"
371 v
.param
.return_type
= "uint64_t"
376 redef class Nprimitive_type_i8
377 redef fun accept_objc
(v
) do
378 if v
.is_variable
then
379 v
.attribute_objc
.return_type
= "int8_t"
380 else if v
.is_method
then
381 v
.method_objc
.return_type
= "int8_t"
383 v
.param
.return_type
= "int8_t"
388 redef class Nprimitive_type_i16
389 redef fun accept_objc
(v
) do
390 if v
.is_variable
then
391 v
.attribute_objc
.return_type
= "int16_t"
392 else if v
.is_method
then
393 v
.method_objc
.return_type
= "int16_t"
395 v
.param
.return_type
= "int16_t"
400 redef class Nprimitive_type_i32
401 redef fun accept_objc
(v
) do
402 if v
.is_variable
then
403 v
.attribute_objc
.return_type
= "int32_t"
404 else if v
.is_method
then
405 v
.method_objc
.return_type
= "int32_t"
407 v
.param
.return_type
= "int32_t"
412 redef class Nprimitive_type_i64
413 redef fun accept_objc
(v
) do
414 if v
.is_variable
then
415 v
.attribute_objc
.return_type
= "int64_t"
416 else if v
.is_method
then
417 v
.method_objc
.return_type
= "int64_t"
419 v
.param
.return_type
= "int64_t"
424 redef class Nprimitive_type_uc
425 redef fun accept_objc
(v
) do
426 if v
.is_variable
then
427 v
.attribute_objc
.return_type
= "unichar"
428 else if v
.is_method
then
429 v
.method_objc
.return_type
= "unichar"
431 v
.param
.return_type
= "unichar"
436 redef class Nprimitive_type_c
437 redef fun accept_objc
(v
) do
438 if v
.is_variable
then
439 v
.attribute_objc
.return_type
= "char"
440 else if v
.is_method
then
441 v
.method_objc
.return_type
= "char"
443 v
.param
.return_type
= "char"
448 redef class Nprimitive_type_s
449 redef fun accept_objc
(v
) do
450 if v
.is_variable
then
451 v
.attribute_objc
.return_type
= "short"
452 else if v
.is_method
then
453 v
.method_objc
.return_type
= "short"
455 v
.param
.return_type
= "short"
460 redef class Nprimitive_type_si
461 redef fun accept_objc
(v
) do
462 if v
.is_variable
then
463 v
.attribute_objc
.return_type
= "short int"
464 else if v
.is_method
then
465 v
.method_objc
.return_type
= "short int"
467 v
.param
.return_type
= "short int"
472 redef class Nprimitive_type_i
473 redef fun accept_objc
(v
) do
474 if v
.is_variable
then
475 v
.attribute_objc
.return_type
= "int"
476 else if v
.is_method
then
477 v
.method_objc
.return_type
= "int"
479 v
.param
.return_type
= "int"
484 redef class Nprimitive_type_l
485 redef fun accept_objc
(v
) do
486 if v
.is_variable
then
487 v
.attribute_objc
.return_type
= "long"
488 else if v
.is_method
then
489 v
.method_objc
.return_type
= "long"
491 v
.param
.return_type
= "long"
496 redef class Nprimitive_type_li
497 redef fun accept_objc
(v
) do
498 if v
.is_variable
then
499 v
.attribute_objc
.return_type
= "long int"
500 else if v
.is_method
then
501 v
.method_objc
.return_type
= "long int"
503 v
.param
.return_type
= "long int"
508 redef class Nprimitive_type_ll
509 redef fun accept_objc
(v
) do
510 if v
.is_variable
then
511 v
.attribute_objc
.return_type
= "long long"
512 else if v
.is_method
then
513 v
.method_objc
.return_type
= "long long"
515 v
.param
.return_type
= "long long"
520 redef class Nprimitive_type_lli
521 redef fun accept_objc
(v
) do
522 if v
.is_variable
then
523 v
.attribute_objc
.return_type
= "long long int"
524 else if v
.is_method
then
525 v
.method_objc
.return_type
= "long long int"
527 v
.param
.return_type
= "long long int"
532 redef class Nprimitive_type_f
533 redef fun accept_objc
(v
) do
534 if v
.is_variable
then
535 v
.attribute_objc
.return_type
= "float"
536 else if v
.is_method
then
537 v
.method_objc
.return_type
= "float"
539 v
.param
.return_type
= "float"
544 redef class Nprimitive_type_d
545 redef fun accept_objc
(v
) do
546 if v
.is_variable
then
547 v
.attribute_objc
.return_type
= "double"
548 else if v
.is_method
then
549 v
.method_objc
.return_type
= "double"
551 v
.param
.return_type
= "double"
556 redef class Nprimitive_type_ld
557 redef fun accept_objc
(v
) do
558 if v
.is_variable
then
559 v
.attribute_objc
.return_type
= "long double"
560 else if v
.is_method
then
561 v
.method_objc
.return_type
= "long double"
563 v
.param
.return_type
= "long double"