ridl 2.8.2 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +10 -7
- data/lib/ridl/backend.rb +11 -12
- data/lib/ridl/delegate.rb +166 -59
- data/lib/ridl/expression.rb +68 -28
- data/lib/ridl/genfile.rb +22 -16
- data/lib/ridl/node.rb +609 -192
- data/lib/ridl/options.rb +10 -12
- data/lib/ridl/optparse_ext.rb +32 -34
- data/lib/ridl/parser.rb +1919 -1446
- data/lib/ridl/parser.ry +66 -9
- data/lib/ridl/runner.rb +42 -28
- data/lib/ridl/scanner.rb +207 -175
- data/lib/ridl/type.rb +246 -15
- data/lib/ridl/version.rb +2 -4
- metadata +5 -6
- data/lib/ridl/parser.diff +0 -42
data/lib/ridl/delegate.rb
CHANGED
@@ -13,11 +13,9 @@ require 'ridl/node'
|
|
13
13
|
require 'ridl/expression'
|
14
14
|
|
15
15
|
module IDL
|
16
|
-
|
17
16
|
ORB_PIDL = 'orb.pidlc'.freeze
|
18
17
|
|
19
18
|
class Delegator
|
20
|
-
|
21
19
|
# #pragma handler registry
|
22
20
|
# each keyed entry a callable object:
|
23
21
|
# - responds to #call(delegator, cur_node, pragma_string)
|
@@ -26,6 +24,7 @@ class Delegator
|
|
26
24
|
|
27
25
|
def self.add_pragma_handler(key, h = nil, &block)
|
28
26
|
raise 'add_pragma_handler requires a callable object or a block' unless h&.respond_to?(:call) || block_given?
|
27
|
+
|
29
28
|
@@pragma_handlers[key] = block_given? ? block : h
|
30
29
|
end
|
31
30
|
|
@@ -41,7 +40,7 @@ class Delegator
|
|
41
40
|
@preprocout = params[:output] if @preprocess
|
42
41
|
@ignore_pidl = params[:ignore_pidl] || false
|
43
42
|
@root_namespace = nil
|
44
|
-
|
43
|
+
unless params[:namespace].nil?
|
45
44
|
@root_namespace = IDL::AST::Module.new(params[:namespace], nil, {})
|
46
45
|
end
|
47
46
|
end
|
@@ -58,8 +57,8 @@ class Delegator
|
|
58
57
|
begin
|
59
58
|
@root, @includes = Marshal.load(f)
|
60
59
|
@cur = @root
|
61
|
-
rescue Exception =>
|
62
|
-
IDL.error("RIDL - failed to load ORB pidlc [#{
|
60
|
+
rescue Exception => e
|
61
|
+
IDL.error("RIDL - failed to load ORB pidlc [#{e}]\n You probably need to rebuild the bootstrap file (compile orb.idl to orb.pidlc).")
|
63
62
|
exit(1)
|
64
63
|
ensure
|
65
64
|
f.close
|
@@ -73,6 +72,7 @@ class Delegator
|
|
73
72
|
@last = nil
|
74
73
|
@last_pos = nil
|
75
74
|
end
|
75
|
+
|
76
76
|
def post_parse
|
77
77
|
if @preprocess
|
78
78
|
Marshal.dump([@root, @includes], @preprocout)
|
@@ -100,7 +100,7 @@ class Delegator
|
|
100
100
|
def walk_member(m, w)
|
101
101
|
case m
|
102
102
|
when IDL::AST::Include
|
103
|
-
|
103
|
+
unless m.is_preprocessed?
|
104
104
|
if @expand_includes
|
105
105
|
if m.is_defined?
|
106
106
|
w.enter_include(m)
|
@@ -131,6 +131,7 @@ class Delegator
|
|
131
131
|
_te = w.respond_to?(:enter_home)
|
132
132
|
_tl = w.respond_to?(:leave_home)
|
133
133
|
return unless _te || _tl
|
134
|
+
|
134
135
|
w.enter_home(m) if _te
|
135
136
|
m.walk_members { |cm| walk_member(cm, w) }
|
136
137
|
w.leave_home(m) if _tl
|
@@ -141,6 +142,7 @@ class Delegator
|
|
141
142
|
_te = w.respond_to?(:enter_component)
|
142
143
|
_tl = w.respond_to?(:leave_component)
|
143
144
|
return unless _te || _tl
|
145
|
+
|
144
146
|
w.enter_component(m) if _te
|
145
147
|
m.walk_members { |cm| walk_member(cm, w) }
|
146
148
|
w.leave_component(m) if _tl
|
@@ -149,6 +151,7 @@ class Delegator
|
|
149
151
|
_te = w.respond_to?(:enter_connector)
|
150
152
|
_tl = w.respond_to?(:leave_connector)
|
151
153
|
return unless _te || _tl
|
154
|
+
|
152
155
|
w.enter_connector(m) if _te
|
153
156
|
m.walk_members { |cm| walk_member(cm, w) }
|
154
157
|
w.leave_connector(m) if _tl
|
@@ -200,6 +203,14 @@ class Delegator
|
|
200
203
|
w.visit_enum(m)
|
201
204
|
when IDL::AST::Enumerator
|
202
205
|
w.visit_enumerator(m)
|
206
|
+
when IDL::AST::BitMask
|
207
|
+
w.visit_bitmask(m)
|
208
|
+
when IDL::AST::BitValue
|
209
|
+
w.visit_bitvalue(m)
|
210
|
+
when IDL::AST::BitSet
|
211
|
+
w.visit_bitset(m)
|
212
|
+
when IDL::AST::BitField
|
213
|
+
w.visit_bitfield(m)
|
203
214
|
else
|
204
215
|
raise "Invalid IDL member type for walkthrough: #{m.class.name}"
|
205
216
|
end
|
@@ -210,7 +221,7 @@ class Delegator
|
|
210
221
|
end
|
211
222
|
|
212
223
|
def enter_include(s, fullpath)
|
213
|
-
params = { :
|
224
|
+
params = { filename: s, fullpath: fullpath }
|
214
225
|
params[:defined] = true
|
215
226
|
params[:preprocessed] = @preprocess
|
216
227
|
@cur = @cur.define(IDL::AST::Include, "$INC:" + s, params)
|
@@ -219,13 +230,13 @@ class Delegator
|
|
219
230
|
@cur
|
220
231
|
end
|
221
232
|
|
222
|
-
def leave_include
|
233
|
+
def leave_include
|
223
234
|
set_last
|
224
235
|
@cur = @cur.enclosure
|
225
236
|
end
|
226
237
|
|
227
238
|
def declare_include(s)
|
228
|
-
params = { :
|
239
|
+
params = { filename: s, fullpath: @includes[s].fullpath }
|
229
240
|
params[:defined] = false
|
230
241
|
params[:preprocessed] = @includes[s].is_preprocessed?
|
231
242
|
@cur.define(IDL::AST::Include, "$INC:" + s, params)
|
@@ -258,7 +269,7 @@ class Delegator
|
|
258
269
|
end
|
259
270
|
|
260
271
|
def handle_pragma(pragma_string)
|
261
|
-
unless @@pragma_handlers.values.reduce(false) {|rc, h| h.call(self, @cur, pragma_string) || rc }
|
272
|
+
unless @@pragma_handlers.values.reduce(false) { |rc, h| h.call(self, @cur, pragma_string) || rc }
|
262
273
|
IDL.log(1, "RIDL - unrecognized pragma encountered: #{pragma_string}.")
|
263
274
|
end
|
264
275
|
end
|
@@ -289,7 +300,8 @@ class Delegator
|
|
289
300
|
set_last
|
290
301
|
@cur
|
291
302
|
end
|
292
|
-
|
303
|
+
|
304
|
+
def end_module(_node)
|
293
305
|
set_last(@cur)
|
294
306
|
@cur = @cur.enclosure # must equals to argument mod
|
295
307
|
end
|
@@ -302,6 +314,7 @@ class Delegator
|
|
302
314
|
if global || names.size > 1
|
303
315
|
raise "no scoped identifier allowed for template module: #{(global ? '::' : '') + names.join('::')}"
|
304
316
|
end
|
317
|
+
|
305
318
|
@cur = @cur.define(IDL::AST::TemplateModule, names[0])
|
306
319
|
@cur.annotations.concat(@annotation_stack)
|
307
320
|
@annotation_stack = IDL::AST::Annotations.new
|
@@ -316,7 +329,7 @@ class Delegator
|
|
316
329
|
@template_module_name = nil # reset
|
317
330
|
define_template_module(*tmp)
|
318
331
|
end
|
319
|
-
params = { :
|
332
|
+
params = { type: type }
|
320
333
|
params[:annotations] = @annotation_stack
|
321
334
|
@annotation_stack = IDL::AST::Annotations.new
|
322
335
|
set_last(@cur.define(IDL::AST::TemplateParam, name, params))
|
@@ -330,7 +343,8 @@ class Delegator
|
|
330
343
|
unless template_type.node.is_a?(IDL::AST::TemplateModule)
|
331
344
|
raise "invalid module template specification: #{template_type.node.typename} #{template_type.node.scoped_lm_name}"
|
332
345
|
end
|
333
|
-
|
346
|
+
|
347
|
+
params = { template: template_type.node, template_params: parameters }
|
334
348
|
mod_inst = @cur.define(IDL::AST::Module, name, params)
|
335
349
|
mod_inst.annotations.concat(@annotation_stack)
|
336
350
|
@annotation_stack = IDL::AST::Annotations.new
|
@@ -348,13 +362,14 @@ class Delegator
|
|
348
362
|
@cur
|
349
363
|
end
|
350
364
|
|
351
|
-
def declare_interface(name, attrib=nil)
|
365
|
+
def declare_interface(name, attrib = nil)
|
352
366
|
params = {}
|
353
367
|
params[:abstract] = attrib == :abstract
|
354
368
|
params[:local] = attrib == :local
|
355
369
|
params[:forward] = true
|
356
370
|
params[:pseudo] = false
|
357
371
|
raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
|
372
|
+
|
358
373
|
@cur.define(IDL::AST::Interface, name, params)
|
359
374
|
set_last
|
360
375
|
@cur
|
@@ -372,7 +387,8 @@ class Delegator
|
|
372
387
|
set_last
|
373
388
|
@cur = @cur.define(IDL::AST::Interface, name, params)
|
374
389
|
end
|
375
|
-
|
390
|
+
|
391
|
+
def end_interface(_node)
|
376
392
|
set_last(@cur)
|
377
393
|
@cur = @cur.enclosure # must equals to argument mod
|
378
394
|
end
|
@@ -389,7 +405,7 @@ class Delegator
|
|
389
405
|
@cur = @cur.define(IDL::AST::Home, name, params)
|
390
406
|
end
|
391
407
|
|
392
|
-
def end_home(
|
408
|
+
def end_home(_node)
|
393
409
|
set_last(@cur)
|
394
410
|
@cur = @cur.enclosure
|
395
411
|
end
|
@@ -398,6 +414,7 @@ class Delegator
|
|
398
414
|
params = {}
|
399
415
|
params[:forward] = true
|
400
416
|
raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
|
417
|
+
|
401
418
|
set_last
|
402
419
|
@cur.define(IDL::AST::Component, name, params)
|
403
420
|
end
|
@@ -412,7 +429,7 @@ class Delegator
|
|
412
429
|
@cur = @cur.define(IDL::AST::Component, name, params)
|
413
430
|
end
|
414
431
|
|
415
|
-
def end_component(
|
432
|
+
def end_component(_node)
|
416
433
|
set_last(@cur)
|
417
434
|
@cur = @cur.enclosure
|
418
435
|
end
|
@@ -426,7 +443,7 @@ class Delegator
|
|
426
443
|
@cur = @cur.define(IDL::AST::Connector, name, params)
|
427
444
|
end
|
428
445
|
|
429
|
-
def end_connector(
|
446
|
+
def end_connector(_node)
|
430
447
|
set_last(@cur)
|
431
448
|
@cur = @cur.enclosure
|
432
449
|
end
|
@@ -439,7 +456,7 @@ class Delegator
|
|
439
456
|
@cur = @cur.define(IDL::AST::Porttype, name, params)
|
440
457
|
end
|
441
458
|
|
442
|
-
def end_porttype(
|
459
|
+
def end_porttype(_node)
|
443
460
|
set_last(@cur)
|
444
461
|
@cur = @cur.enclosure
|
445
462
|
end
|
@@ -455,17 +472,18 @@ class Delegator
|
|
455
472
|
@cur
|
456
473
|
end
|
457
474
|
|
458
|
-
def declare_eventtype(name, attrib=nil)
|
475
|
+
def declare_eventtype(name, attrib = nil)
|
459
476
|
params = {}
|
460
477
|
params[:abstract] = attrib == :abstract
|
461
478
|
params[:forward] = true
|
462
479
|
raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
|
480
|
+
|
463
481
|
set_last
|
464
482
|
@cur.define(IDL::AST::Eventtype, name, params)
|
465
483
|
@cur
|
466
484
|
end
|
467
485
|
|
468
|
-
def define_eventtype(name, attrib, inherits={})
|
486
|
+
def define_eventtype(name, attrib, inherits = {})
|
469
487
|
params = {}
|
470
488
|
params[:abstract] = attrib == :abstract
|
471
489
|
params[:custom] = attrib == :custom
|
@@ -478,17 +496,18 @@ class Delegator
|
|
478
496
|
@cur
|
479
497
|
end
|
480
498
|
|
481
|
-
def declare_valuetype(name, attrib=nil)
|
499
|
+
def declare_valuetype(name, attrib = nil)
|
482
500
|
params = {}
|
483
501
|
params[:abstract] = attrib == :abstract
|
484
502
|
params[:forward] = true
|
485
503
|
raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
|
504
|
+
|
486
505
|
set_last
|
487
506
|
@cur.define(IDL::AST::Valuetype, name, params)
|
488
507
|
@cur
|
489
508
|
end
|
490
509
|
|
491
|
-
def define_valuetype(name, attrib, inherits={})
|
510
|
+
def define_valuetype(name, attrib, inherits = {})
|
492
511
|
params = {}
|
493
512
|
params[:abstract] = attrib == :abstract
|
494
513
|
params[:custom] = attrib == :custom
|
@@ -521,7 +540,7 @@ class Delegator
|
|
521
540
|
end
|
522
541
|
|
523
542
|
def define_valuebox(name, type)
|
524
|
-
params = { :
|
543
|
+
params = { type: type }
|
525
544
|
params[:annotations] = @annotation_stack
|
526
545
|
@annotation_stack = IDL::AST::Annotations.new
|
527
546
|
set_last(@cur.define(IDL::AST::Valuebox, name, params))
|
@@ -556,6 +575,7 @@ class Delegator
|
|
556
575
|
if n.nil?
|
557
576
|
raise "cannot find type name '#{nm}' in scope '#{node.scoped_name}'"
|
558
577
|
end
|
578
|
+
|
559
579
|
node = n
|
560
580
|
first = node if first.nil?
|
561
581
|
end
|
@@ -565,8 +585,8 @@ class Delegator
|
|
565
585
|
IDL::AST::Interface, IDL::AST::Home, IDL::AST::Component,
|
566
586
|
IDL::AST::Porttype, IDL::AST::Connector,
|
567
587
|
IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef,
|
568
|
-
IDL::AST::Exception, IDL::AST::Enum,
|
569
|
-
IDL::AST::Valuetype, IDL::AST::Valuebox
|
588
|
+
IDL::AST::Exception, IDL::AST::Enum, IDL::AST::BitMask,
|
589
|
+
IDL::AST::Valuetype, IDL::AST::Valuebox, IDL::AST::BitSet
|
570
590
|
Type::ScopedName.new(node)
|
571
591
|
when IDL::AST::TemplateParam
|
572
592
|
if node.idltype.is_a?(IDL::Type::Const)
|
@@ -578,6 +598,10 @@ class Delegator
|
|
578
598
|
Expression::ScopedName.new(node)
|
579
599
|
when IDL::AST::Enumerator
|
580
600
|
Expression::Enumerator.new(node)
|
601
|
+
when IDL::AST::BitValue
|
602
|
+
Expression::BitValue.new(node)
|
603
|
+
when IDL::AST::BitField
|
604
|
+
Expression::BitField.new(node)
|
581
605
|
else
|
582
606
|
raise "invalid reference to #{node.class.name}: #{node.scoped_name}"
|
583
607
|
end
|
@@ -591,14 +615,17 @@ class Delegator
|
|
591
615
|
when :integer
|
592
616
|
_type = [
|
593
617
|
Type::Octet,
|
618
|
+
Type::TinyShort,
|
594
619
|
Type::Short,
|
595
620
|
Type::Long,
|
596
621
|
Type::LongLong,
|
597
|
-
Type::
|
598
|
-
|
622
|
+
Type::UTinyShort,
|
623
|
+
Type::ULongLong
|
624
|
+
].detect { |t| t::Range === _value }
|
599
625
|
if _type.nil?
|
600
626
|
raise "it's not a valid integer: #{v.to_s}"
|
601
627
|
end
|
628
|
+
|
602
629
|
k.new(_type.new, _value)
|
603
630
|
when :string
|
604
631
|
k.new(Type::String.new, _value)
|
@@ -623,15 +650,18 @@ class Delegator
|
|
623
650
|
else
|
624
651
|
if not ::Integer === _expression.value
|
625
652
|
raise "must be integer: #{_expression.value.inspect}"
|
626
|
-
elsif _expression.value
|
627
|
-
raise "must be positive integer: #{_expression.value
|
653
|
+
elsif _expression.value.negative?
|
654
|
+
raise "must be positive integer: #{_expression.value}"
|
655
|
+
elsif _expression.value.zero?
|
656
|
+
raise "must be positive integer"
|
628
657
|
end
|
658
|
+
|
629
659
|
_expression.value
|
630
660
|
end
|
631
661
|
end
|
632
662
|
|
633
663
|
def define_const(_type, _name, _expression)
|
634
|
-
params = { :
|
664
|
+
params = { type: _type, expression: _expression }
|
635
665
|
params[:annotations] = @annotation_stack
|
636
666
|
@annotation_stack = IDL::AST::Annotations.new
|
637
667
|
set_last(@cur.define(IDL::AST::Const, _name, params))
|
@@ -639,7 +669,7 @@ class Delegator
|
|
639
669
|
end
|
640
670
|
|
641
671
|
def declare_op_header(_oneway, _type, _name)
|
642
|
-
params =
|
672
|
+
params = {}
|
643
673
|
params[:oneway] = (_oneway == :oneway)
|
644
674
|
params[:type] = _type
|
645
675
|
params[:annotations] = @annotation_stack
|
@@ -647,8 +677,9 @@ class Delegator
|
|
647
677
|
set_last
|
648
678
|
@cur = @cur.define(IDL::AST::Operation, _name, params)
|
649
679
|
end
|
680
|
+
|
650
681
|
def declare_op_parameter(_attribute, _type, _name)
|
651
|
-
params =
|
682
|
+
params = {}
|
652
683
|
params[:attribute] = _attribute
|
653
684
|
params[:type] = _type
|
654
685
|
params[:annotations] = @annotation_stack
|
@@ -656,18 +687,20 @@ class Delegator
|
|
656
687
|
set_last(@cur.define(IDL::AST::Parameter, _name, params))
|
657
688
|
@cur
|
658
689
|
end
|
690
|
+
|
659
691
|
def declare_op_footer(_raises, instantiation_context)
|
660
692
|
@cur.raises = _raises || []
|
661
693
|
@cur.context = instantiation_context
|
662
|
-
|
694
|
+
unless @cur.context.nil?
|
663
695
|
raise "context phrase's not supported"
|
664
696
|
end
|
697
|
+
|
665
698
|
set_last(@cur)
|
666
699
|
@cur = @cur.enclosure
|
667
700
|
end
|
668
701
|
|
669
|
-
def declare_attribute(_type, _name, _readonly=false)
|
670
|
-
params =
|
702
|
+
def declare_attribute(_type, _name, _readonly = false)
|
703
|
+
params = {}
|
671
704
|
params[:type] = _type
|
672
705
|
params[:readonly] = _readonly
|
673
706
|
params[:annotations] = @annotation_stack
|
@@ -675,28 +708,33 @@ class Delegator
|
|
675
708
|
set_last(@cur.define(IDL::AST::Attribute, _name, params))
|
676
709
|
end
|
677
710
|
|
678
|
-
def declare_struct(
|
679
|
-
params = { :
|
711
|
+
def declare_struct(name)
|
712
|
+
params = { forward: true }
|
680
713
|
raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
|
714
|
+
|
681
715
|
set_last
|
682
|
-
@cur.define(IDL::AST::Struct,
|
716
|
+
@cur.define(IDL::AST::Struct, name, params)
|
683
717
|
@cur
|
684
718
|
end
|
685
|
-
|
686
|
-
|
719
|
+
|
720
|
+
def define_struct(name, inherits = nil)
|
721
|
+
params = { forward: false }
|
687
722
|
params[:annotations] = @annotation_stack
|
723
|
+
params[:inherits] = inherits
|
688
724
|
@annotation_stack = IDL::AST::Annotations.new
|
689
725
|
set_last
|
690
|
-
@cur = @cur.define(IDL::AST::Struct,
|
726
|
+
@cur = @cur.define(IDL::AST::Struct, name, params)
|
691
727
|
end
|
692
|
-
|
693
|
-
|
728
|
+
|
729
|
+
def declare_member(_type, name)
|
730
|
+
params = {}
|
694
731
|
params[:type] = _type
|
695
732
|
params[:annotations] = @annotation_stack
|
696
733
|
@annotation_stack = IDL::AST::Annotations.new
|
697
|
-
set_last(@cur.define(IDL::AST::Member,
|
734
|
+
set_last(@cur.define(IDL::AST::Member, name, params))
|
698
735
|
@cur
|
699
736
|
end
|
737
|
+
|
700
738
|
def end_struct(node)
|
701
739
|
node.defined = true
|
702
740
|
set_last(@cur)
|
@@ -704,42 +742,48 @@ class Delegator
|
|
704
742
|
@cur = @cur.enclosure
|
705
743
|
ret
|
706
744
|
end
|
707
|
-
|
708
|
-
|
745
|
+
|
746
|
+
def define_exception(name)
|
747
|
+
params = { forward: false }
|
709
748
|
params[:annotations] = @annotation_stack
|
710
749
|
@annotation_stack = IDL::AST::Annotations.new
|
711
750
|
set_last
|
712
|
-
@cur = @cur.define(IDL::AST::Exception,
|
751
|
+
@cur = @cur.define(IDL::AST::Exception, name, params)
|
713
752
|
end
|
714
|
-
|
753
|
+
|
754
|
+
def end_exception(_node)
|
715
755
|
set_last(@cur)
|
716
756
|
ret = IDL::Type::ScopedName.new(@cur)
|
717
757
|
@cur = @cur.enclosure
|
718
758
|
ret
|
719
759
|
end
|
720
760
|
|
721
|
-
def declare_union(
|
722
|
-
params = { :
|
761
|
+
def declare_union(name)
|
762
|
+
params = { forward: true }
|
723
763
|
raise "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
|
764
|
+
|
724
765
|
set_last
|
725
|
-
@cur.define(IDL::AST::Union,
|
766
|
+
@cur.define(IDL::AST::Union, name, params)
|
726
767
|
@cur
|
727
768
|
end
|
728
|
-
|
729
|
-
|
769
|
+
|
770
|
+
def define_union(name)
|
771
|
+
params = { forward: false }
|
730
772
|
params[:annotations] = @annotation_stack
|
731
773
|
@annotation_stack = IDL::AST::Annotations.new
|
732
774
|
set_last
|
733
|
-
@cur = @cur.define(IDL::AST::Union,
|
775
|
+
@cur = @cur.define(IDL::AST::Union, name, params)
|
734
776
|
end
|
777
|
+
|
735
778
|
def define_union_switchtype(union_node, switchtype)
|
736
779
|
union_node.set_switchtype(switchtype)
|
737
780
|
union_node.annotations.concat(@annotation_stack)
|
738
781
|
@annotation_stack = IDL::AST::Annotations.new
|
739
782
|
union_node
|
740
783
|
end
|
784
|
+
|
741
785
|
def define_case(_labels, _type, _name)
|
742
|
-
params =
|
786
|
+
params = {}
|
743
787
|
params[:type] = _type
|
744
788
|
params[:labels] = _labels
|
745
789
|
params[:annotations] = @annotation_stack
|
@@ -747,6 +791,7 @@ class Delegator
|
|
747
791
|
set_last(@cur.define(IDL::AST::UnionMember, _name, params))
|
748
792
|
@cur
|
749
793
|
end
|
794
|
+
|
750
795
|
def end_union(node)
|
751
796
|
node.validate_labels
|
752
797
|
node.defined = true
|
@@ -763,18 +808,80 @@ class Delegator
|
|
763
808
|
set_last
|
764
809
|
@cur = @cur.define(IDL::AST::Enum, _name, params)
|
765
810
|
end
|
811
|
+
|
766
812
|
def declare_enumerator(_name)
|
767
813
|
n = @cur.enumerators.length
|
768
814
|
params = {
|
769
|
-
:
|
770
|
-
:
|
815
|
+
value: n,
|
816
|
+
enum: @cur
|
771
817
|
}
|
772
818
|
params[:annotations] = @annotation_stack
|
773
819
|
@annotation_stack = IDL::AST::Annotations.new
|
774
820
|
set_last(@cur.enclosure.define(IDL::AST::Enumerator, _name, params))
|
775
821
|
@cur
|
776
822
|
end
|
823
|
+
|
777
824
|
def end_enum(node)
|
825
|
+
node.determine_bitbound
|
826
|
+
set_last(@cur)
|
827
|
+
ret = IDL::Type::ScopedName.new(@cur)
|
828
|
+
@cur = @cur.enclosure
|
829
|
+
ret
|
830
|
+
end
|
831
|
+
|
832
|
+
def define_bitmask(name)
|
833
|
+
params = {}
|
834
|
+
params[:annotations] = @annotation_stack
|
835
|
+
@annotation_stack = IDL::AST::Annotations.new
|
836
|
+
set_last
|
837
|
+
@cur = @cur.define(IDL::AST::BitMask, name, params)
|
838
|
+
end
|
839
|
+
|
840
|
+
def declare_bitvalue(name)
|
841
|
+
p = 0
|
842
|
+
unless @cur.bitvalues.empty?
|
843
|
+
p = @cur.bitvalues.last.position.next
|
844
|
+
end
|
845
|
+
params = {
|
846
|
+
position: p,
|
847
|
+
bitmask: @cur,
|
848
|
+
annotations: @annotation_stack
|
849
|
+
}
|
850
|
+
@annotation_stack = IDL::AST::Annotations.new
|
851
|
+
set_last(@cur.define(IDL::AST::BitValue, name, params))
|
852
|
+
@cur
|
853
|
+
end
|
854
|
+
|
855
|
+
def end_bitmask(node)
|
856
|
+
node.determine_bitbound
|
857
|
+
set_last(@cur)
|
858
|
+
ret = IDL::Type::ScopedName.new(@cur)
|
859
|
+
@cur = @cur.enclosure
|
860
|
+
ret
|
861
|
+
end
|
862
|
+
|
863
|
+
def define_bitset(_name, inherits = nil)
|
864
|
+
params = {}
|
865
|
+
params[:annotations] = @annotation_stack
|
866
|
+
params[:inherits] = inherits
|
867
|
+
@annotation_stack = IDL::AST::Annotations.new
|
868
|
+
set_last
|
869
|
+
@cur = @cur.define(IDL::AST::BitSet, _name, params)
|
870
|
+
end
|
871
|
+
|
872
|
+
def declare_bitfield(name_, bits_, idltype_)
|
873
|
+
params = {
|
874
|
+
bits: bits_,
|
875
|
+
bitset: @cur,
|
876
|
+
idltype: idltype_
|
877
|
+
}
|
878
|
+
params[:annotations] = @annotation_stack
|
879
|
+
@annotation_stack = IDL::AST::Annotations.new
|
880
|
+
set_last(@cur.define(IDL::AST::BitField, name_, params))
|
881
|
+
@cur
|
882
|
+
end
|
883
|
+
|
884
|
+
def end_bitset(_node)
|
778
885
|
set_last(@cur)
|
779
886
|
ret = IDL::Type::ScopedName.new(@cur)
|
780
887
|
@cur = @cur.enclosure
|
@@ -782,7 +889,7 @@ class Delegator
|
|
782
889
|
end
|
783
890
|
|
784
891
|
def declare_typedef(_type, _name)
|
785
|
-
params =
|
892
|
+
params = {}
|
786
893
|
params[:type] = _type
|
787
894
|
params[:annotations] = @annotation_stack
|
788
895
|
@annotation_stack = IDL::AST::Annotations.new
|