ridl 2.9.0 → 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 +8 -7
- data/lib/ridl/delegate.rb +81 -4
- data/lib/ridl/expression.rb +3 -1
- data/lib/ridl/node.rb +285 -8
- data/lib/ridl/options.rb +1 -1
- data/lib/ridl/parser.rb +1922 -1446
- data/lib/ridl/parser.ry +66 -9
- data/lib/ridl/runner.rb +9 -2
- data/lib/ridl/scanner.rb +64 -63
- data/lib/ridl/type.rb +133 -2
- data/lib/ridl/version.rb +1 -1
- metadata +5 -6
- data/lib/ridl/parser.diff +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c813bc37b6ebda1ec576dd678c82e9764a3ecf7160b199c7c55794c7da36c3c8
|
4
|
+
data.tar.gz: 83b7e565b4a8bacdef3b3d3e5cdef124b2314018d54050f48ab5ef8ae4a8d28a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88ac006539e173dae2972e9c8fa5181afdc7d6418c047b241600b8142507e5f16ee7a977f11e23333a685afc1b8da9cb554a84f36de27089d10c94b0c420e1bb
|
7
|
+
data.tar.gz: 6ab751d08491dd63c33a4608f2ae17d6f603aa401dcf282ef81b9761bbf765463ddbd64a6b79e05e95bfc61f841313347f0abfd65e8287ca256cf4894ce2eb89
|
data/README.rdoc
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
{rdoc-image:https://badge.fury.io/rb/ridl.svg}[https://badge.fury.io/rb/ridl]
|
2
|
-
{rdoc-image:https://github.com/RemedyIT/ridl/workflows/r2corba/badge.svg}[https://github.com/RemedyIT/ridl/actions?query=workflow%3Ar2corba]
|
3
|
-
{rdoc-image:https://github.com/RemedyIT/ridl/workflows/taox11/badge.svg}[https://github.com/RemedyIT/ridl/actions?query=workflow%3Ataox11]
|
4
|
-
{rdoc-image:https://github.com/RemedyIT/ridl/workflows/ciaox11/badge.svg}[https://github.com/RemedyIT/ridl/actions?query=workflow%3Aciaox11]
|
2
|
+
{rdoc-image:https://github.com/RemedyIT/ridl/actions/workflows/r2corba.yml/badge.svg}[https://github.com/RemedyIT/ridl/actions?query=workflow%3Ar2corba]
|
3
|
+
{rdoc-image:https://github.com/RemedyIT/ridl/actions/workflows/taox11.yml/badge.svg}[https://github.com/RemedyIT/ridl/actions?query=workflow%3Ataox11]
|
5
4
|
{rdoc-image:https://www.codefactor.io/repository/github/remedyit/ridl/badge}[https://www.codefactor.io/repository/github/remedyit/ridl]
|
6
5
|
|
7
6
|
= RIDL Compiler
|
@@ -20,9 +19,11 @@ RIDL provides a framework for implementing compiler/generators for OMG standard
|
|
20
19
|
* a builtin IDL preprocessor expression parser/evaluator
|
21
20
|
* a flexible framework for pluggable (and stackable) backends
|
22
21
|
* basic support for backend code re-generation
|
23
|
-
* compliant with the {OMG IDL 3.5}[https://www.omg.org/spec/IDL/3.5] standard
|
22
|
+
* compliant with the {OMG IDL 3.5}[https://www.omg.org/spec/IDL/3.5] standard
|
23
|
+
* support for {OMG IDL 4.2}[https://www.omg.org/spec/IDL/4.2] annotations
|
24
|
+
* support for IDL 4.2 map, int8/uint8, explicitly-named integer types, bitmask, bitset, empty struct, and struct inheritance
|
24
25
|
|
25
|
-
Remedy IT has developed multiple backends for RIDL. These include:
|
26
|
+
Remedy IT has developed multiple backends for RIDL. These include the following open source backends:
|
26
27
|
* {R2CORBA}[https://www.remedy.nl/opensource/r2corba.html] generating Ruby code
|
27
28
|
* {TAOX11}[https://www.taox11.org] generating C++11 code
|
28
29
|
* {AXCIOMA}[https://www.axcioma.org] generating C++11 code
|
@@ -49,6 +50,6 @@ The RIDL Gem is a Ruby-only Gem without any dependencies.
|
|
49
50
|
|
50
51
|
A new RIDL ruby gem release can be made by incrementing the RIDL version in link:lib/ridl/version.rb and create a new release on {github}[https://github.com/RemedyIT/ridl/releases] matching the new version (for example v2.7.0). The github {Ruby Gem Release}[https://github.com/RemedyIT/ridl/actions?query=workflow%3A%22Ruby+Gem+Release%22] action will automatically create a new gem and push it to {Rubygems.org}[https://www.rubygems.org/gems/ridl].
|
51
52
|
|
52
|
-
== Regenerating `lib/
|
53
|
+
== Regenerating `lib/ridl/parser.rb`
|
53
54
|
|
54
|
-
The file `lib/
|
55
|
+
The file `lib/ridl/parser.rb` can be regenerated using `racc -o parser.rb -F -E parser.ry`. The option `-E` embeds the racc parser within RIDL which is required for RIDL because jruby doesn't contain `RACC` as cruby does.
|
data/lib/ridl/delegate.rb
CHANGED
@@ -203,6 +203,14 @@ class Delegator
|
|
203
203
|
w.visit_enum(m)
|
204
204
|
when IDL::AST::Enumerator
|
205
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)
|
206
214
|
else
|
207
215
|
raise "Invalid IDL member type for walkthrough: #{m.class.name}"
|
208
216
|
end
|
@@ -577,8 +585,8 @@ class Delegator
|
|
577
585
|
IDL::AST::Interface, IDL::AST::Home, IDL::AST::Component,
|
578
586
|
IDL::AST::Porttype, IDL::AST::Connector,
|
579
587
|
IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef,
|
580
|
-
IDL::AST::Exception, IDL::AST::Enum,
|
581
|
-
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
|
582
590
|
Type::ScopedName.new(node)
|
583
591
|
when IDL::AST::TemplateParam
|
584
592
|
if node.idltype.is_a?(IDL::Type::Const)
|
@@ -590,6 +598,10 @@ class Delegator
|
|
590
598
|
Expression::ScopedName.new(node)
|
591
599
|
when IDL::AST::Enumerator
|
592
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)
|
593
605
|
else
|
594
606
|
raise "invalid reference to #{node.class.name}: #{node.scoped_name}"
|
595
607
|
end
|
@@ -603,9 +615,11 @@ class Delegator
|
|
603
615
|
when :integer
|
604
616
|
_type = [
|
605
617
|
Type::Octet,
|
618
|
+
Type::TinyShort,
|
606
619
|
Type::Short,
|
607
620
|
Type::Long,
|
608
621
|
Type::LongLong,
|
622
|
+
Type::UTinyShort,
|
609
623
|
Type::ULongLong
|
610
624
|
].detect { |t| t::Range === _value }
|
611
625
|
if _type.nil?
|
@@ -638,6 +652,8 @@ class Delegator
|
|
638
652
|
raise "must be integer: #{_expression.value.inspect}"
|
639
653
|
elsif _expression.value.negative?
|
640
654
|
raise "must be positive integer: #{_expression.value}"
|
655
|
+
elsif _expression.value.zero?
|
656
|
+
raise "must be positive integer"
|
641
657
|
end
|
642
658
|
|
643
659
|
_expression.value
|
@@ -701,9 +717,10 @@ class Delegator
|
|
701
717
|
@cur
|
702
718
|
end
|
703
719
|
|
704
|
-
def define_struct(name)
|
720
|
+
def define_struct(name, inherits = nil)
|
705
721
|
params = { forward: false }
|
706
722
|
params[:annotations] = @annotation_stack
|
723
|
+
params[:inherits] = inherits
|
707
724
|
@annotation_stack = IDL::AST::Annotations.new
|
708
725
|
set_last
|
709
726
|
@cur = @cur.define(IDL::AST::Struct, name, params)
|
@@ -804,7 +821,67 @@ class Delegator
|
|
804
821
|
@cur
|
805
822
|
end
|
806
823
|
|
807
|
-
def end_enum(
|
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)
|
808
885
|
set_last(@cur)
|
809
886
|
ret = IDL::Type::ScopedName.new(@cur)
|
810
887
|
@cur = @cur.enclosure
|
data/lib/ridl/expression.rb
CHANGED
@@ -148,13 +148,15 @@ module IDL
|
|
148
148
|
IDL::Type::LongLong, IDL::Type::ULongLong,
|
149
149
|
IDL::Type::Long, IDL::Type::ULong,
|
150
150
|
IDL::Type::Short, IDL::Type::UShort,
|
151
|
+
IDL::Type::TinyShort, IDL::Type::UTinyShort,
|
151
152
|
IDL::Type::Octet
|
152
153
|
]
|
153
154
|
|
154
155
|
def Integer2.suite_sign(_t, _v)
|
155
156
|
[[IDL::Type::LongLong, IDL::Type::ULongLong],
|
156
157
|
[IDL::Type::Long, IDL::Type::ULong],
|
157
|
-
[IDL::Type::Short, IDL::Type::UShort]
|
158
|
+
[IDL::Type::Short, IDL::Type::UShort],
|
159
|
+
[IDL::Type::TinyShort, IDL::Type::UTinyShort]
|
158
160
|
].each do |t|
|
159
161
|
next unless t.include? _t
|
160
162
|
|
data/lib/ridl/node.rb
CHANGED
@@ -269,7 +269,7 @@ module IDL::AST
|
|
269
269
|
|
270
270
|
def define(_type, _name, params = {})
|
271
271
|
unless is_definable?(_type)
|
272
|
-
raise "#{_type
|
272
|
+
raise "#{_type} is not definable in #{self.typename}."
|
273
273
|
end
|
274
274
|
|
275
275
|
node = search_self(_name)
|
@@ -382,12 +382,17 @@ module IDL::AST
|
|
382
382
|
class UnionMember < Member; end
|
383
383
|
class Enum < Leaf; end
|
384
384
|
class Enumerator < Leaf; end
|
385
|
+
class BitMask < Node; end
|
386
|
+
class BitValue < Leaf; end
|
387
|
+
class BitSet < Node; end
|
388
|
+
class BitField < Leaf; end
|
385
389
|
|
386
390
|
class Module < Node
|
387
391
|
DEFINABLE = [
|
388
392
|
IDL::AST::Module, IDL::AST::Interface, IDL::AST::Valuebox, IDL::AST::Valuetype, IDL::AST::Const, IDL::AST::Struct,
|
389
393
|
IDL::AST::Union, IDL::AST::Enum, IDL::AST::Enumerator, IDL::AST::Typedef, IDL::AST::Include,
|
390
|
-
IDL::AST::Home, IDL::AST::Porttype, IDL::AST::Component, IDL::AST::Connector
|
394
|
+
IDL::AST::Home, IDL::AST::Porttype, IDL::AST::Component, IDL::AST::Connector, IDL::AST::BitMask, IDL::AST::BitValue,
|
395
|
+
IDL::AST::BitSet, IDL::AST::BitField
|
391
396
|
]
|
392
397
|
attr_reader :anchor, :next, :template, :template_params
|
393
398
|
|
@@ -742,6 +747,8 @@ module IDL::AST
|
|
742
747
|
IDL::Type::Union, # 'union'
|
743
748
|
IDL::Type::Exception, # 'exception'
|
744
749
|
IDL::Type::Enum # 'enum'
|
750
|
+
IDL::Type::BitMask# 'bitmask'
|
751
|
+
IDL::Type::BitSet# 'bitset'
|
745
752
|
# no further checks
|
746
753
|
when IDL::Type::Sequence # 'sequence' or 'sequence<...>'
|
747
754
|
_tptype = _tp.idltype
|
@@ -2515,6 +2522,24 @@ module IDL::AST
|
|
2515
2522
|
@forward = params[:forward] ? true : false
|
2516
2523
|
super(_name, _enclosure)
|
2517
2524
|
@idltype = IDL::Type::Struct.new(self)
|
2525
|
+
@base = set_base(params[:inherits])
|
2526
|
+
end
|
2527
|
+
|
2528
|
+
def set_base(inherits)
|
2529
|
+
unless inherits.nil?
|
2530
|
+
rtc = inherits.resolved_type
|
2531
|
+
unless rtc.node.is_defined?
|
2532
|
+
raise "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{rtc.node.typename} #{rtc.node.scoped_lm_name}"
|
2533
|
+
end
|
2534
|
+
unless rtc.node.is_a?(IDL::AST::Struct)
|
2535
|
+
raise "#{typename} #{scoped_lm_name} cannot inherit from non structure #{rtc.node.typename} #{rtc.node.scoped_lm_name}"
|
2536
|
+
end
|
2537
|
+
inherits.node
|
2538
|
+
end
|
2539
|
+
end
|
2540
|
+
|
2541
|
+
def base
|
2542
|
+
@base
|
2518
2543
|
end
|
2519
2544
|
|
2520
2545
|
def is_defined?
|
@@ -2545,6 +2570,10 @@ module IDL::AST
|
|
2545
2570
|
@children.find_all { |c| c.is_a? IDL::AST::Member }
|
2546
2571
|
end
|
2547
2572
|
|
2573
|
+
def types
|
2574
|
+
@children.reject { |c| c.is_a? IDL::AST::Member }
|
2575
|
+
end
|
2576
|
+
|
2548
2577
|
def is_local?(recurstk = [])
|
2549
2578
|
# not local if forward decl or recursion detected
|
2550
2579
|
return false if is_forward? || recurstk.include?(self)
|
@@ -2556,10 +2585,11 @@ module IDL::AST
|
|
2556
2585
|
end
|
2557
2586
|
|
2558
2587
|
def marshal_dump
|
2559
|
-
super() << @idltype << @defined << @recursive << @forward
|
2588
|
+
super() << @idltype << @defined << @recursive << @forward << @base
|
2560
2589
|
end
|
2561
2590
|
|
2562
2591
|
def marshal_load(vars)
|
2592
|
+
@base = vars.pop
|
2563
2593
|
@forward = vars.pop
|
2564
2594
|
@recursive = vars.pop
|
2565
2595
|
@defined = vars.pop
|
@@ -2706,6 +2736,10 @@ module IDL::AST
|
|
2706
2736
|
@children.find_all { |c| c.is_a? IDL::AST::UnionMember }
|
2707
2737
|
end
|
2708
2738
|
|
2739
|
+
def types
|
2740
|
+
@children.reject { |c| c.is_a? IDL::AST::UnionMember }
|
2741
|
+
end
|
2742
|
+
|
2709
2743
|
def is_local?(recurstk = [])
|
2710
2744
|
# not local if forward decl or recursion detected
|
2711
2745
|
return false if is_forward? || recurstk.include?(self)
|
@@ -2722,6 +2756,7 @@ module IDL::AST
|
|
2722
2756
|
|
2723
2757
|
def default_label
|
2724
2758
|
swtype = @switchtype.resolved_type
|
2759
|
+
return nil if IDL::Type::WChar === swtype # No default label detection for wchar
|
2725
2760
|
lbls = members.collect { |m| m.labels.include?(:default) ? [] : m.labels.collect { |l| l.value } }.flatten
|
2726
2761
|
lbls = lbls.sort unless IDL::Type::Boolean === swtype ## work around bug in Ruby 1.9.2
|
2727
2762
|
def_lbl = swtype.min
|
@@ -2828,20 +2863,25 @@ module IDL::AST
|
|
2828
2863
|
end # UnionMember
|
2829
2864
|
|
2830
2865
|
class Enum < Leaf
|
2831
|
-
attr_reader :idltype
|
2866
|
+
attr_reader :idltype, :bitbound, :bitbound_bits
|
2832
2867
|
|
2833
|
-
def initialize(_name,
|
2834
|
-
super(_name,
|
2868
|
+
def initialize(_name, enclosure, params)
|
2869
|
+
super(_name, enclosure)
|
2835
2870
|
@enums = []
|
2836
2871
|
@idltype = IDL::Type::Enum.new(self)
|
2872
|
+
@bitbound = IDL::Type::ULong.new
|
2873
|
+
@bitbound_bits = 32
|
2874
|
+
annotations.concat(params[:annotations])
|
2837
2875
|
end
|
2838
2876
|
|
2839
2877
|
def marshal_dump
|
2840
|
-
super() << @idltype << @enums
|
2878
|
+
super() << @idltype << @bitbound << @bitbound_bits << @enums
|
2841
2879
|
end
|
2842
2880
|
|
2843
2881
|
def marshal_load(vars)
|
2844
2882
|
@enums = vars.pop
|
2883
|
+
@bitbound = vars.pop
|
2884
|
+
@bitbound_bits = vars.pop
|
2845
2885
|
@idltype = vars.pop
|
2846
2886
|
super(vars)
|
2847
2887
|
end
|
@@ -2854,6 +2894,19 @@ module IDL::AST
|
|
2854
2894
|
@enums << n
|
2855
2895
|
end
|
2856
2896
|
|
2897
|
+
def determine_bitbound
|
2898
|
+
bitbound = annotations[:bit_bound].first
|
2899
|
+
unless bitbound.nil?
|
2900
|
+
@bitbound_bits = bitbound.fields[:value]
|
2901
|
+
raise "Missing number of bits for bit_bound annotation for #{name}" if @bitbound_bits.nil?
|
2902
|
+
raise "Illegal negative bit_bound #{bits} value for #{name}" if @bitbound_bits.negative?
|
2903
|
+
raise "Illegal zero bit_bound value for #{name}, not #{bits}" if @bitbound_bits.zero?
|
2904
|
+
raise "Bitbound for #{name} must be <= 32" unless @bitbound_bits <= 32
|
2905
|
+
end
|
2906
|
+
@bitbound = IDL::Type::UTinyShort.new if @bitbound_bits.between?(1,8)
|
2907
|
+
@bitbound = IDL::Type::UShort.new if @bitbound_bits.between?(9,16)
|
2908
|
+
end
|
2909
|
+
|
2857
2910
|
def instantiate(instantiation_context, _enclosure)
|
2858
2911
|
super(instantiation_context, _enclosure, {})
|
2859
2912
|
end
|
@@ -2890,11 +2943,235 @@ module IDL::AST
|
|
2890
2943
|
end
|
2891
2944
|
end # Enumerator
|
2892
2945
|
|
2893
|
-
class
|
2946
|
+
class BitMask < Node
|
2947
|
+
DEFINABLE = [IDL::AST::BitValue]
|
2948
|
+
attr_reader :idltype, :bitbound, :bitbound_bits
|
2949
|
+
|
2950
|
+
def initialize(name, enclosure, params)
|
2951
|
+
super(name, enclosure)
|
2952
|
+
@bitvalues = []
|
2953
|
+
@idltype = IDL::Type::BitMask.new(self)
|
2954
|
+
annotations.concat(params[:annotations])
|
2955
|
+
end
|
2956
|
+
|
2957
|
+
def marshal_dump
|
2958
|
+
super() << @idltype << @bitbound << @bitbound_bits << @bitvalues
|
2959
|
+
end
|
2960
|
+
|
2961
|
+
def marshal_load(vars)
|
2962
|
+
@bitvalues = vars.pop
|
2963
|
+
@bitbound_bits = vars.pop
|
2964
|
+
@bitbound = vars.pop
|
2965
|
+
@idltype = vars.pop
|
2966
|
+
super(vars)
|
2967
|
+
end
|
2968
|
+
|
2969
|
+
def bitvalues
|
2970
|
+
@bitvalues
|
2971
|
+
end
|
2972
|
+
|
2973
|
+
def add_bitvalue(n)
|
2974
|
+
@bitvalues << n
|
2975
|
+
end
|
2976
|
+
|
2977
|
+
def determine_bitbound
|
2978
|
+
bitbound = annotations[:bit_bound].first
|
2979
|
+
@bitbound_bits = @bitvalues.size
|
2980
|
+
unless bitbound.nil?
|
2981
|
+
@bitbound_bits = bitbound.fields[:value]
|
2982
|
+
raise "Missing number of bits for bit_bound annotation for #{name}" if @bitbound_bits.nil?
|
2983
|
+
raise "Illegal negative bit_bound #{bits} value for #{name}" if @bitbound_bits.negative?
|
2984
|
+
raise "Illegal zero bit_bound value for #{name}, not #{bits}" if @bitbound_bits.zero?
|
2985
|
+
raise "Bitbound for #{name} must be <= 64" unless @bitbound_bits <= 64
|
2986
|
+
end
|
2987
|
+
@bitbound = IDL::Type::UTinyShort.new if @bitbound_bits.between?(1,8)
|
2988
|
+
@bitbound = IDL::Type::UShort.new if @bitbound_bits.between?(9,16)
|
2989
|
+
@bitbound = IDL::Type::ULong.new if @bitbound_bits.between?(17,32)
|
2990
|
+
@bitbound = IDL::Type::ULongLong.new if @bitbound_bits.between?(33,64)
|
2991
|
+
end
|
2992
|
+
|
2993
|
+
def instantiate(instantiation_context, _enclosure)
|
2994
|
+
super(instantiation_context, _enclosure, {})
|
2995
|
+
end
|
2996
|
+
end # BitMask
|
2997
|
+
|
2998
|
+
class BitValue < Leaf
|
2999
|
+
attr_reader :idltype, :bitmask, :position
|
3000
|
+
|
3001
|
+
def initialize(name, enclosure, params)
|
3002
|
+
super(name, enclosure)
|
3003
|
+
@idltype = IDL::Type::ULong.new
|
3004
|
+
@bitmask = params[:bitmask]
|
3005
|
+
@position = params[:position]
|
3006
|
+
annotations.concat(params[:annotations])
|
3007
|
+
position_annotation = annotations[:position].first
|
3008
|
+
unless position_annotation.nil?
|
3009
|
+
@position = position_annotation.fields[:value]
|
3010
|
+
end
|
3011
|
+
@bitmask.add_bitvalue(self)
|
3012
|
+
end
|
3013
|
+
|
3014
|
+
def marshal_dump
|
3015
|
+
super() << @idltype << @bitmask << @position
|
3016
|
+
end
|
3017
|
+
|
3018
|
+
def marshal_load(vars)
|
3019
|
+
@position = vars.pop
|
3020
|
+
@bitmask = vars.pop
|
3021
|
+
@idltype = vars.pop
|
3022
|
+
super(vars)
|
3023
|
+
end
|
3024
|
+
|
3025
|
+
def instantiate(instantiation_context, _enclosure)
|
3026
|
+
# find already instantiated BitMask parent
|
3027
|
+
_bitmask = _enclosure.resolve(@bitmask.name)
|
3028
|
+
raise "Unable to resolve instantiated BitMask scope for bitvalue #{@bitmask.name}::#{name} instantiation" unless _bitmask
|
3029
|
+
|
3030
|
+
super(instantiation_context, _enclosure, { bitmask: _bitmask, position: @position })
|
3031
|
+
end
|
3032
|
+
end # BitValue
|
3033
|
+
|
3034
|
+
class BitSet < Node
|
3035
|
+
DEFINABLE = [IDL::AST::BitField]
|
2894
3036
|
attr_reader :idltype
|
2895
3037
|
|
3038
|
+
def initialize(_name, enclosure, params)
|
3039
|
+
super(_name, enclosure)
|
3040
|
+
@bitfields = []
|
3041
|
+
@bitset_bits = 0
|
3042
|
+
@idltype = IDL::Type::BitSet.new(self)
|
3043
|
+
@base = set_base(params[:inherits])
|
3044
|
+
end
|
3045
|
+
|
3046
|
+
def set_base(inherits)
|
3047
|
+
unless inherits.nil?
|
3048
|
+
rtc = inherits.resolved_type
|
3049
|
+
unless rtc.node.is_a?(IDL::AST::BitSet)
|
3050
|
+
raise "#{typename} #{scoped_lm_name} cannot inherit from non bitset #{rtc.node.typename} #{rtc.node.scoped_lm_name}"
|
3051
|
+
end
|
3052
|
+
inherits.node
|
3053
|
+
end
|
3054
|
+
end
|
3055
|
+
|
3056
|
+
def base
|
3057
|
+
@base
|
3058
|
+
end
|
3059
|
+
|
3060
|
+
# Override from Node base to handle anonymous bitfields
|
3061
|
+
def define(_type, _name, params = {})
|
3062
|
+
unless is_definable?(_type)
|
3063
|
+
raise "#{_type} is not definable in #{self.typename}."
|
3064
|
+
end
|
3065
|
+
|
3066
|
+
# All IDL definables have a name except a bitfield, that has an optional name and can
|
3067
|
+
# be anonymous
|
3068
|
+
node = search_self(_name) unless _name.nil?
|
3069
|
+
if node.nil?
|
3070
|
+
node = _type.new(_name, self, params)
|
3071
|
+
node.annotations.concat(params[:annotations])
|
3072
|
+
node.prefix = @prefix
|
3073
|
+
introduce(node) unless _name.nil? # If there is no name don't introduce it in our scope
|
3074
|
+
@children << node
|
3075
|
+
else
|
3076
|
+
if _type != node.class
|
3077
|
+
raise "#{_name} is already defined as a type of #{node.typename}"
|
3078
|
+
end
|
3079
|
+
|
3080
|
+
node = redefine(node, params)
|
3081
|
+
end
|
3082
|
+
node
|
3083
|
+
end
|
3084
|
+
|
3085
|
+
def marshal_dump
|
3086
|
+
super() << @idltype << @bitset_bits << @bitfields << @base
|
3087
|
+
end
|
3088
|
+
|
3089
|
+
def marshal_load(vars)
|
3090
|
+
@base = vars.pop
|
3091
|
+
@bitfields = vars.pop
|
3092
|
+
@bitset_bits = vars.pop
|
3093
|
+
@idltype = vars.pop
|
3094
|
+
super(vars)
|
3095
|
+
end
|
3096
|
+
|
3097
|
+
# Total number of bits in this bitset including the optional base
|
3098
|
+
def bitset_bits
|
3099
|
+
base.nil? ? @bitset_bits : @bitset_bits + base.bitset_bits
|
3100
|
+
end
|
3101
|
+
|
3102
|
+
# Underlying type which is large enough to contain the full bitset
|
3103
|
+
# including its base
|
3104
|
+
def underlying_type
|
3105
|
+
return IDL::Type::UTinyShort.new if bitset_bits.between?(1,8)
|
3106
|
+
return IDL::Type::UShort.new if bitset_bits.between?(9,16)
|
3107
|
+
return IDL::Type::ULong.new if bitset_bits.between?(17,32)
|
3108
|
+
return IDL::Type::ULongLong.new if bitset_bits.between?(33,64)
|
3109
|
+
end
|
3110
|
+
|
3111
|
+
def bitfields
|
3112
|
+
@bitfields
|
3113
|
+
end
|
3114
|
+
|
3115
|
+
def add_bitfield(n)
|
3116
|
+
@bitfields << n
|
3117
|
+
@bitset_bits += n.bits
|
3118
|
+
raise "Bitset size #{bitset_bits} must be between 1 and 64" unless bitset_bits.between?(1, 64)
|
3119
|
+
end
|
3120
|
+
|
3121
|
+
def instantiate(instantiation_context, _enclosure)
|
3122
|
+
super(instantiation_context, _enclosure, {})
|
3123
|
+
end
|
3124
|
+
end # BitSet
|
3125
|
+
|
3126
|
+
class BitField < Leaf
|
3127
|
+
attr_reader :idltype, :bitset, :bits
|
3128
|
+
|
2896
3129
|
def initialize(_name, _enclosure, params)
|
2897
3130
|
super(_name, _enclosure)
|
3131
|
+
@idltype = params[:idltype]
|
3132
|
+
@bitset = params[:bitset]
|
3133
|
+
@bits = params[:bits]
|
3134
|
+
|
3135
|
+
raise "Amount of bits for bitfield #{_name} must <= 64, not #{bits}" if bits > 64
|
3136
|
+
|
3137
|
+
# When no IDL type has been specified for the bitfield in IDL we need to determine
|
3138
|
+
# the underlying type based on the number of bits
|
3139
|
+
if @idltype.nil?
|
3140
|
+
@idltype = IDL::Type::Boolean.new if bits == 1
|
3141
|
+
@idltype = IDL::Type::TinyShort.new if bits.between?(2,8)
|
3142
|
+
@idltype = IDL::Type::Short.new if bits.between?(9,16)
|
3143
|
+
@idltype = IDL::Type::Long.new if bits.between?(17,32)
|
3144
|
+
@idltype = IDL::Type::LongLong.new if bits.between?(33,64)
|
3145
|
+
end
|
3146
|
+
@bitset.add_bitfield(self)
|
3147
|
+
end
|
3148
|
+
|
3149
|
+
def marshal_dump
|
3150
|
+
super() << @idltype << @bits << @bitset << @value
|
3151
|
+
end
|
3152
|
+
|
3153
|
+
def marshal_load(vars)
|
3154
|
+
@value = vars.pop
|
3155
|
+
@bitset = vars.pop
|
3156
|
+
@bits = vars.pop
|
3157
|
+
@idltype = vars.pop
|
3158
|
+
super(vars)
|
3159
|
+
end
|
3160
|
+
|
3161
|
+
def instantiate(instantiation_context, _enclosure)
|
3162
|
+
# find already instantiated BitSet parent
|
3163
|
+
_bitmask = _enclosure.resolve(@bitset.name)
|
3164
|
+
raise "Unable to resolve instantiated BitSet scope for bitfield #{@bitset.name}::#{name} instantiation" unless _bitset
|
3165
|
+
|
3166
|
+
super(instantiation_context, _enclosure, { bitset: _bitset, bits: @bits })
|
3167
|
+
end
|
3168
|
+
end # BitField
|
3169
|
+
|
3170
|
+
class Typedef < Leaf
|
3171
|
+
attr_reader :idltype
|
3172
|
+
|
3173
|
+
def initialize(_name, enclosure, params)
|
3174
|
+
super(_name, enclosure)
|
2898
3175
|
@idltype = params[:type]
|
2899
3176
|
end
|
2900
3177
|
|
data/lib/ridl/options.rb
CHANGED
@@ -67,7 +67,7 @@ module IDL
|
|
67
67
|
|
68
68
|
def load(rcpath)
|
69
69
|
IDL.log(3, "Loading #{RIDLRC} from #{rcpath}")
|
70
|
-
_cfg = JSON.parse(
|
70
|
+
_cfg = JSON.parse(File.read(rcpath))
|
71
71
|
IDL.log(4, "Read from #{rcpath}: [#{_cfg}]")
|
72
72
|
_rcdir = File.dirname(rcpath)
|
73
73
|
# handle automatic env var expansion in ridl be_paths
|