ridl 2.8.0 → 2.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be5b79c10b3a4bb8e2f0404004ec5201332bef859fc69c636c4750e8eb6f6b13
4
- data.tar.gz: 0a23918976bfb9b7db6595409d974fc80be2b5a686f8b40220fa689edd9cc791
3
+ metadata.gz: 880d87c66c5e6542fd7a61744fd2c10db2344e75849e73efbc45e26f8c33511a
4
+ data.tar.gz: 3d8b9e40f5d9220f5a677e4ebee507042f31246a0cbdc680166512985a1ba6ee
5
5
  SHA512:
6
- metadata.gz: a187e41cc1d3c1d77f79f2ed9e43dccc4b83bc89b98ed4e2771627b2b1b771ba26390624f9abf779e1e2c5c89d7776698045408ca3ceb8ca9f10ecf87c6d0db6
7
- data.tar.gz: b90d9a055d29d2de3dcee867df3ca57a26c8ddefd5b77fc3ff1a8a3ab7f645b395d8359c93b8a8a65122b006a76cd9f89815141239cd8e335cf21a78916b89b7
6
+ metadata.gz: a79c369f080a3e914de2df4899bd523c312814abd400726c9315043495bbfa4b3870f9ebc696019804487c86b5b1edc4791c1252dd616ac342da214849764304
7
+ data.tar.gz: a136ede546812cafba12a925d7c86415d5e453f2ad4d513f65be54751434c2bbd43fca0bbcea36bc898d522a2bd644da71dedd56029c26473ca77645a1827cfd
data/README.rdoc CHANGED
@@ -46,3 +46,7 @@ The RIDL Gem is a Ruby-only Gem without any dependencies.
46
46
  == Releasing new RIDL Ruby Gem
47
47
 
48
48
  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].
49
+
50
+ == Regenerating `lib/racc/parser.rb`
51
+
52
+ The file `lib/racc/parser.rb` can be regenerated using `racc -o parser.rb -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/backend.rb CHANGED
@@ -50,7 +50,7 @@ module IDL
50
50
  rescue LoadError => ex
51
51
  IDL.error "ERROR: Cannot load RIDL backend [:#{be_name}]"
52
52
  IDL.error ex.inspect
53
- IDL.error(ex.backtrace.join("\n")) if IDL.verbose_level>0
53
+ IDL.error(ex.backtrace.join("\n")) if IDL.verbose_level > 0
54
54
  exit 1
55
55
  end
56
56
  end
data/lib/ridl/delegate.rb CHANGED
@@ -25,7 +25,7 @@ class Delegator
25
25
  @@pragma_handlers = {}
26
26
 
27
27
  def self.add_pragma_handler(key, h = nil, &block)
28
- raise 'add_pragma_handler requires a callable object or a block' unless (h && h.respond_to?(:call)) || block_given?
28
+ raise 'add_pragma_handler requires a callable object or a block' unless h&.respond_to?(:call) || block_given?
29
29
  @@pragma_handlers[key] = block_given? ? block : h
30
30
  end
31
31
 
@@ -213,7 +213,7 @@ class Delegator
213
213
  params = { :filename => s, :fullpath => fullpath }
214
214
  params[:defined] = true
215
215
  params[:preprocessed] = @preprocess
216
- @cur = @cur.define(IDL::AST::Include, "$INC:"+s, params)
216
+ @cur = @cur.define(IDL::AST::Include, "$INC:" + s, params)
217
217
  @includes[s] = @cur
218
218
  set_last
219
219
  @cur
@@ -228,7 +228,7 @@ class Delegator
228
228
  params = { :filename => s, :fullpath => @includes[s].fullpath }
229
229
  params[:defined] = false
230
230
  params[:preprocessed] = @includes[s].is_preprocessed?
231
- @cur.define(IDL::AST::Include, "$INC:"+s, params)
231
+ @cur.define(IDL::AST::Include, "$INC:" + s, params)
232
232
  end
233
233
 
234
234
  def pragma_prefix(s)
@@ -258,7 +258,7 @@ class Delegator
258
258
  end
259
259
 
260
260
  def handle_pragma(pragma_string)
261
- unless @@pragma_handlers.values.any? {|h| h.call(self, @cur, pragma_string)}
261
+ unless @@pragma_handlers.values.reduce(false) {|rc, h| h.call(self, @cur, pragma_string) || rc }
262
262
  IDL.log(1, "RIDL - unrecognized pragma encountered: #{pragma_string}.")
263
263
  end
264
264
  end
@@ -299,8 +299,8 @@ class Delegator
299
299
  end
300
300
 
301
301
  def define_template_module(global, names)
302
- if global || names.size>1
303
- raise "no scoped identifier allowed for template module: #{(global ? '::' : '')+names.join('::')}"
302
+ if global || names.size > 1
303
+ raise "no scoped identifier allowed for template module: #{(global ? '::' : '') + names.join('::')}"
304
304
  end
305
305
  @cur = @cur.define(IDL::AST::TemplateModule, names[0])
306
306
  @cur.annotations.concat(@annotation_stack)
@@ -562,7 +562,7 @@ class Delegator
562
562
  root.introduce(first)
563
563
  case node
564
564
  when IDL::AST::Module, IDL::AST::TemplateModule,
565
- IDL::AST::Interface,IDL::AST::Home, IDL::AST::Component,
565
+ IDL::AST::Interface, IDL::AST::Home, IDL::AST::Component,
566
566
  IDL::AST::Porttype, IDL::AST::Connector,
567
567
  IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef,
568
568
  IDL::AST::Exception, IDL::AST::Enum,
@@ -86,7 +86,7 @@ module IDL
86
86
 
87
87
  if _operands.size != n
88
88
  raise format("%s must receive %d operand%s.",
89
- self.typename, n, if (n>1) then "s" else "" end)
89
+ self.typename, n, if (n > 1) then "s" else "" end)
90
90
  end
91
91
 
92
92
  unless _operands.any? { |o| o.is_template? }
@@ -184,7 +184,7 @@ module IDL
184
184
  superclass.checktype(*types)
185
185
 
186
186
  # it's expected that Double, LongDouble is a Float.
187
- s1,s2 = IDL::Type::Float, IDL::Type::Fixed
187
+ s1, s2 = IDL::Type::Float, IDL::Type::Fixed
188
188
  if (t1 === s1 && t2 === s2) or (t1 === s2 && t2 === s1)
189
189
  raise "#{self.name} about #{t1.typename} and #{t2.typename} is illegal."
190
190
  end
@@ -210,7 +210,7 @@ module IDL
210
210
  Applicable = Integer2::Applicable
211
211
  def calculate(op)
212
212
  if @idltype.is_unsigned?()
213
- (2**@idltype.bits-1)-op
213
+ (2**@idltype.bits - 1) - op
214
214
  else
215
215
  ~op
216
216
  end
@@ -218,13 +218,13 @@ module IDL
218
218
  end
219
219
 
220
220
  class Or < Boolean2
221
- def calculate(lop,rop); lop | rop; end
221
+ def calculate(lop, rop); lop | rop; end
222
222
  end
223
223
  class And < Boolean2
224
- def calculate(lop,rop); lop & rop; end
224
+ def calculate(lop, rop); lop & rop; end
225
225
  end
226
226
  class Xor < Boolean2
227
- def calculate(lop,rop); lop ^ rop; end
227
+ def calculate(lop, rop); lop ^ rop; end
228
228
  end
229
229
 
230
230
  class Shift < Integer2
@@ -236,32 +236,32 @@ module IDL
236
236
  end
237
237
  end
238
238
  class LShift < Shift
239
- def calculate(lop,rop)
239
+ def calculate(lop, rop)
240
240
  check_rop(rop)
241
241
  lop << rop
242
242
  end
243
243
  end
244
244
  class RShift < Shift
245
- def calculate(lop,rop)
245
+ def calculate(lop, rop)
246
246
  check_rop(rop)
247
247
  lop >> rop
248
248
  end
249
249
  end
250
250
 
251
251
  class Add < Float2
252
- def calculate(lop,rop); lop + rop; end
252
+ def calculate(lop, rop); lop + rop; end
253
253
  end
254
254
  class Minus < Float2
255
- def calculate(lop,rop); lop - rop; end
255
+ def calculate(lop, rop); lop - rop; end
256
256
  end
257
257
  class Mult < Float2
258
- def calculate(lop,rop); lop * rop; end
258
+ def calculate(lop, rop); lop * rop; end
259
259
  end
260
260
  class Div < Float2
261
- def calculate(lop,rop); lop / rop; end
261
+ def calculate(lop, rop); lop / rop; end
262
262
  end
263
263
  class Mod < Integer2
264
- def calculate(lop,rop); lop % rop; end
264
+ def calculate(lop, rop); lop % rop; end
265
265
  end
266
266
  end #of class Operation
267
267
  end #of class Expression
data/lib/ridl/genfile.rb CHANGED
@@ -67,7 +67,7 @@ module IDL
67
67
  class Content
68
68
  def initialize(sections = {})
69
69
  # copy content map transforming all keys to symbols
70
- @sections = sections.inject({}) {|m,(k,v)| m[k.to_sym] = v; m }
70
+ @sections = sections.inject({}) {|m, (k, v)| m[k.to_sym] = v; m }
71
71
  end
72
72
 
73
73
  def sections
@@ -96,7 +96,7 @@ module IDL
96
96
  @path = path
97
97
  @fullpath = File.expand_path(path)
98
98
  @name = File.basename(path)
99
- @ext = File.extname(path).sub(/^\./,'')
99
+ @ext = File.extname(path).sub(/^\./, '')
100
100
  else
101
101
  @path = @fullpath = @name = @ext = ''
102
102
  end
data/lib/ridl/node.rb CHANGED
@@ -19,7 +19,7 @@ module IDL::AST
19
19
  @id = id.to_sym
20
20
  # copy field map transforming all keys to symbols and
21
21
  # detecting nested annotation objects
22
- @fields = fields.inject({}) do |m,(k,v)|
22
+ @fields = fields.inject({}) do |m, (k, v)|
23
23
  m[k.to_sym] = case v
24
24
  when Array
25
25
  v.collect { |ve| Hash === ve ? Annotation.new(*ve.to_a.first) : ve }
@@ -159,8 +159,8 @@ module IDL::AST
159
159
  if id_arr.first == 'IDL'
160
160
  id_arr.shift
161
161
  id_str = id_arr.shift.to_s
162
- raise 'ID identifiers should not start or end with \'/\'' if id_str[0,1]=='/' or id_str[-1, 1]=='/'
163
- raise "ID identifiers should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(id_str[0,1])
162
+ raise 'ID identifiers should not start or end with \'/\'' if id_str[0, 1] == '/' or id_str[-1, 1] == '/'
163
+ raise "ID identifiers should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(id_str[0, 1])
164
164
  raise 'Invalid ID! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed for identifiers' unless REPO_ID_RE =~ id_str
165
165
  end
166
166
  @repo_id = id
@@ -184,8 +184,8 @@ module IDL::AST
184
184
 
185
185
  def prefix=(pfx)
186
186
  unless pfx.to_s.empty?
187
- raise 'ID prefix should not start or end with \'/\'' if pfx[0,1]=='/' or pfx[-1, 1]=='/'
188
- raise "ID prefix should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(pfx[0,1])
187
+ raise 'ID prefix should not start or end with \'/\'' if pfx[0, 1] == '/' or pfx[-1, 1] == '/'
188
+ raise "ID prefix should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(pfx[0, 1])
189
189
  raise 'Invalid ID prefix! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed' unless REPO_ID_RE =~ pfx
190
190
  end
191
191
  self.set_prefix(pfx)
@@ -199,7 +199,7 @@ module IDL::AST
199
199
  if @repo_id.nil?
200
200
  @repo_ver = "1.0" unless @repo_ver
201
201
  format("IDL:%s%s:%s",
202
- if @prefix.empty? then "" else @prefix+"/" end,
202
+ if @prefix.empty? then "" else @prefix + "/" end,
203
203
  self.scopes.collect{|s| s.name}.join("/"),
204
204
  @repo_ver)
205
205
  else
@@ -912,7 +912,7 @@ module IDL::AST
912
912
  # check if the matched name resulted in multiple different nodes or all the same
913
913
  r_one = results.shift
914
914
  unless results.all? {|r| r_one == r || (r_one.class == r.class && r_one.scoped_name == r.scoped_name) }
915
- s = results.inject([r_one]) {|l,r| l << r unless l.include?(r); l }.collect{ |n| n.scoped_name }.join(", ")
915
+ s = results.inject([r_one]) {|l, r| l << r unless l.include?(r); l }.collect{ |n| n.scoped_name }.join(", ")
916
916
  raise "\"#{_name}\" is ambiguous. " + s
917
917
  end
918
918
  end
@@ -1048,13 +1048,13 @@ module IDL::AST
1048
1048
  @resolved_bases
1049
1049
  end
1050
1050
 
1051
- def operations(include_bases=false,traversed=nil)
1051
+ def operations(include_bases=false, traversed=nil)
1052
1052
  ops = @children.find_all { |c| c.is_a?(IDL::AST::Operation) }
1053
1053
  ops.concat(base_operations(traversed || [])) if include_bases
1054
1054
  ops
1055
1055
  end
1056
1056
 
1057
- def attributes(include_bases=false,traversed=nil)
1057
+ def attributes(include_bases=false, traversed=nil)
1058
1058
  atts = @children.find_all { |c| c.is_a?(IDL::AST::Attribute) }
1059
1059
  atts.concat(base_attributes(traversed || [])) if include_bases
1060
1060
  atts
@@ -1316,8 +1316,8 @@ module IDL::AST
1316
1316
  end
1317
1317
 
1318
1318
  def set_component_and_key(comp, key)
1319
- unless comp && comp.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::TemplateParam)
1320
- unless comp && comp.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::Component)
1319
+ unless comp&.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::TemplateParam)
1320
+ unless comp&.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::Component)
1321
1321
  raise (comp ?
1322
1322
  "invalid managed component for #{typename} #{scoped_lm_name}: #{comp.typename}" :
1323
1323
  "missing managed component specification for #{typename} #{scoped_lm_name}")
@@ -1327,7 +1327,7 @@ module IDL::AST
1327
1327
  end
1328
1328
  @resolved_comp = comp.resolved_type.node
1329
1329
  end
1330
- unless key && key.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::TemplateParam)
1330
+ unless key&.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::TemplateParam)
1331
1331
  ## TODO : add check for Components::PrimaryKeyBase base type
1332
1332
  unless key.nil? || (key.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::Valuetype))
1333
1333
  raise "invalid primary key for #{typename} #{scoped_lm_name}: #{key.typename}"
@@ -1338,13 +1338,13 @@ module IDL::AST
1338
1338
  @primarykey = key.node if key
1339
1339
  end
1340
1340
 
1341
- def operations(include_bases=false,traversed=nil)
1341
+ def operations(include_bases=false, traversed=nil)
1342
1342
  ops = @children.find_all { |c| c.is_a?(IDL::AST::Operation) }
1343
1343
  ops.concat(base_operations(traversed || [])) if include_bases
1344
1344
  ops
1345
1345
  end
1346
1346
 
1347
- def attributes(include_bases=false,traversed=nil)
1347
+ def attributes(include_bases=false, traversed=nil)
1348
1348
  atts = @children.find_all { |c| c.is_a?(IDL::AST::Attribute) }
1349
1349
  atts.concat(base_attributes(traversed || [])) if include_bases
1350
1350
  atts
@@ -1393,7 +1393,7 @@ module IDL::AST
1393
1393
  @base = parent.node
1394
1394
  end
1395
1395
 
1396
- def ports(include_bases=false,traversed=nil)
1396
+ def ports(include_bases=false, traversed=nil)
1397
1397
  ports = @children.inject([]) do |lst, c|
1398
1398
  lst.concat(c.ports) if IDL::AST::Port === c
1399
1399
  lst
@@ -1402,7 +1402,7 @@ module IDL::AST
1402
1402
  ports
1403
1403
  end
1404
1404
 
1405
- def attributes(include_bases=false,traversed=nil)
1405
+ def attributes(include_bases=false, traversed=nil)
1406
1406
  atts = @children.inject([]) do |lst, c|
1407
1407
  if IDL::AST::Port === c
1408
1408
  lst.concat(c.attributes)
@@ -1472,7 +1472,7 @@ module IDL::AST
1472
1472
  @base = parent.node
1473
1473
  end
1474
1474
 
1475
- def ports(include_bases=false,traversed=nil)
1475
+ def ports(include_bases=false, traversed=nil)
1476
1476
  ports = @children.inject([]) do |lst, c|
1477
1477
  lst.concat(c.ports) if IDL::AST::Port === c
1478
1478
  lst
@@ -1481,11 +1481,11 @@ module IDL::AST
1481
1481
  ports
1482
1482
  end
1483
1483
 
1484
- def operations(include_bases=false,traversed=nil)
1484
+ def operations(include_bases=false, traversed=nil)
1485
1485
  include_bases ? base_operations(traversed || []) : []
1486
1486
  end
1487
1487
 
1488
- def attributes(include_bases=false,traversed=nil)
1488
+ def attributes(include_bases=false, traversed=nil)
1489
1489
  atts = @children.inject([]) do |lst, c|
1490
1490
  if IDL::AST::Port === c
1491
1491
  lst.concat(c.attributes)
@@ -1556,7 +1556,7 @@ module IDL::AST
1556
1556
  raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1557
1557
  end
1558
1558
  else
1559
- unless @idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Eventtype) || @idltype.is_node?(IDL::AST::TemplateParam))
1559
+ unless @idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Eventtype) || @idltype.is_node?(IDL::AST::TemplateParam))
1560
1560
  raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1561
1561
  end
1562
1562
  end
@@ -1794,7 +1794,7 @@ module IDL::AST
1794
1794
  raise "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1795
1795
  end
1796
1796
  if (not rtc.node.is_abstract?) and @bases.size > 0
1797
- raise "concrete basevalue #{tc.node.typename} #{tc.node.scoped_lm_name} MUST "+
1797
+ raise "concrete basevalue #{tc.node.typename} #{tc.node.scoped_lm_name} MUST " +
1798
1798
  "be first and only non-abstract in inheritance list for #{typename} #{scoped_lm_name}"
1799
1799
  end
1800
1800
  @resolved_bases << rtc.node
@@ -1946,7 +1946,7 @@ module IDL::AST
1946
1946
  @is_recursive = false
1947
1947
  @has_incomplete_type = false
1948
1948
  super(_name, _enclosure)
1949
- @idltype = params[:type]
1949
+ @idltype = params[:type]
1950
1950
  @visibility = (params[:visibility] == :public ? :public : :private)
1951
1951
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
1952
1952
  raise "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
@@ -2112,7 +2112,7 @@ module IDL::AST
2112
2112
  attr_reader :idltype, :expression, :value
2113
2113
  def initialize(_name, _enclosure, params)
2114
2114
  super(_name, _enclosure)
2115
- @idltype = params[:type]
2115
+ @idltype = params[:type]
2116
2116
  @expression = params[:expression]
2117
2117
  @value = nil
2118
2118
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
@@ -2158,7 +2158,7 @@ module IDL::AST
2158
2158
  attr_reader :idltype
2159
2159
  def initialize(_name, _enclosure, params)
2160
2160
  super(_name, _enclosure)
2161
- @idltype = params[:type]
2161
+ @idltype = params[:type]
2162
2162
  @attribute = params[:attribute]
2163
2163
  unless ATTRIBUTE_MAP.has_key?(@attribute)
2164
2164
  raise "invalid attribute for parameter: #{params[:attribute]}"
@@ -2210,7 +2210,7 @@ module IDL::AST
2210
2210
 
2211
2211
  def initialize(_name, _enclosure, params)
2212
2212
  super(_name, _enclosure)
2213
- @idltype = params[:type]
2213
+ @idltype = params[:type]
2214
2214
  @oneway = (params[:oneway] == true)
2215
2215
  @in = []
2216
2216
  @out = []
@@ -2322,7 +2322,7 @@ module IDL::AST
2322
2322
  attr_reader :get_raises, :set_raises
2323
2323
  def initialize(_name, _enclosure, params)
2324
2324
  super(_name, _enclosure)
2325
- @idltype = params[:type]
2325
+ @idltype = params[:type]
2326
2326
  @get_raises = []
2327
2327
  @set_raises = []
2328
2328
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
@@ -2726,7 +2726,7 @@ module IDL::AST
2726
2726
  attr_reader :idltype, :enum, :value
2727
2727
  def initialize(_name, _enclosure, params)
2728
2728
  super(_name, _enclosure)
2729
- @idltype = IDL::Type::ULong.new
2729
+ @idltype = IDL::Type::ULong.new
2730
2730
  @enum = params[:enum]
2731
2731
  @value = params[:value]
2732
2732
  @enum.add_enumerator(self)
@@ -2776,4 +2776,3 @@ module IDL::AST
2776
2776
  end
2777
2777
  end # Typedef
2778
2778
  end
2779
-
data/lib/ridl/options.rb CHANGED
@@ -124,7 +124,7 @@ module IDL
124
124
  when Array
125
125
  v.collect {|e| _dup_elem(e) }
126
126
  when Hash
127
- v.inject({}) {|h, (k,e)| h[k] = _dup_elem(e); h }
127
+ v.inject({}) {|h, (k, e)| h[k] = _dup_elem(e); h }
128
128
  when OpenStruct
129
129
  v.class.new(_dup_elem(v.__send__(:table)))
130
130
  else
@@ -134,7 +134,7 @@ module IDL
134
134
  key = to_key(spec)
135
135
  @params[key] = { :option_name => key }
136
136
  when Hash
137
- spec.each do |k,v|
137
+ spec.each do |k, v|
138
138
  @params[to_key(k)] = (if Hash === v
139
139
  {
140
140
  :option_name => to_key(v[:option_name] || k),