ridl 2.2.5 → 2.5.5

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
  SHA1:
3
- metadata.gz: 6b4f57fea70c3afc0799ca7d925b19f567476cf0
4
- data.tar.gz: 935963ed742a214a0dc67a2b72df6454e8716e10
3
+ metadata.gz: 487ad002804614ca82ead17a468922b304642d64
4
+ data.tar.gz: 419cd1417bbdd7498f589c245bf26ce50bb60b10
5
5
  SHA512:
6
- metadata.gz: 1484766696c20592f73ea92c88d6e8ba4dde89dc8c9220403fb6aa0ffe948c60e66cb29fe18f3f6241bd48d0cb8a196bf87ac4cc9b0eefb762c2a404eec8aed6
7
- data.tar.gz: 1818e868e7f680f256b1b74f36ef9ee572f9c4ca1c4e4dadcf05814f40a05a8baf0e6ba9610b3c038dfaea527633bbeceac6c912ba88f309495ff01bac963f68
6
+ metadata.gz: faf5353bc1a577cccf62034414744a012de908d8373bf38102edb5b6de39e970f223c140374278a2e7c86b6b00453351f9b123d20c4a93541a2c10cf35615e78
7
+ data.tar.gz: 6b3660bc7debee36367f8118c8114d49e6d05b7a9100902f567a59f8eb6d864adda462f838110b5fa5eec9b37143219933a023ddba2bc5617ca8e328a6b03d80
@@ -51,7 +51,7 @@ module IDL
51
51
  rescue LoadError => ex
52
52
  IDL.error "ERROR: Cannot load RIDL backend [:#{be_name}]"
53
53
  IDL.error ex.inspect
54
- IDL.error(ex.backtrace.join("\n")) if $VERBOSE
54
+ IDL.error(ex.backtrace.join("\n")) if IDL.verbose_level>0
55
55
  exit 1
56
56
  end
57
57
  end
@@ -62,8 +62,9 @@ module IDL
62
62
  @@backends[cfg.backend.name] = cfg.backend
63
63
  end
64
64
 
65
- def self.stop_processing
66
- raise ProcessStop, caller(1).first
65
+ # stop processing of current input and skip to next or exit RIDL
66
+ def self.stop_processing(msg='')
67
+ raise ProcessStop, msg, caller(1).first
67
68
  end
68
69
 
69
70
  def initialize(be_name, root, ttl, cpr, ver)
@@ -100,11 +101,9 @@ module IDL
100
101
  end
101
102
 
102
103
  def process_input(parser, params)
103
- # process input top-down; return true and stop processing when input handled
104
- unless _process_input(parser, params)
105
- return @base_backends.any? {|be| be.process_input(parser, params) }
106
- end
107
- true
104
+ # process input top-down
105
+ _process_input(parser, params)
106
+ @base_backends.each {|be| be.process_input(parser, params) }
108
107
  end
109
108
 
110
109
  @@null_be = nil
@@ -59,6 +59,9 @@ class Delegator
59
59
  begin
60
60
  @root, @includes = Marshal.load(f)
61
61
  @cur = @root
62
+ rescue Exception => ex
63
+ IDL.error("RIDL - failed to load ORB pidlc [#{ex}]\n You probably need to rebuild the bootstrap file (compile orb.idl to orb.pidlc).")
64
+ exit(1)
62
65
  ensure
63
66
  f.close
64
67
  end
@@ -68,6 +71,8 @@ class Delegator
68
71
  return if @root
69
72
  end
70
73
  @root = @cur = IDL::AST::Module.new(nil, nil, {}) # global root
74
+ @last = nil
75
+ @last_pos = nil
71
76
  end
72
77
  def post_parse
73
78
  if @preprocess
@@ -75,6 +80,16 @@ class Delegator
75
80
  end
76
81
  end
77
82
 
83
+ private
84
+
85
+ def set_last(node = nil)
86
+ @last = node
87
+ @last_pos = @scanner.position.dup if node
88
+ node
89
+ end
90
+
91
+ public
92
+
78
93
  def visit_nodes(walker)
79
94
  walker.visit_nodes(self)
80
95
  end
@@ -199,21 +214,23 @@ class Delegator
199
214
  @includes.has_key?(s)
200
215
  end
201
216
 
202
- def enter_include(s)
203
- params = { :filename => s }
217
+ def enter_include(s, fullpath)
218
+ params = { :filename => s, :fullpath => fullpath }
204
219
  params[:defined] = true
205
220
  params[:preprocessed] = @preprocess
206
221
  @cur = @cur.define(IDL::AST::Include, "$INC:"+s, params)
207
222
  @includes[s] = @cur
223
+ set_last
208
224
  @cur
209
225
  end
210
226
 
211
227
  def leave_include()
228
+ set_last
212
229
  @cur = @cur.enclosure
213
230
  end
214
231
 
215
232
  def declare_include(s)
216
- params = { :filename => s }
233
+ params = { :filename => s, :fullpath => @includes[s].fullpath }
217
234
  params[:defined] = false
218
235
  params[:preprocessed] = @includes[s].is_preprocessed?
219
236
  @cur.define(IDL::AST::Include, "$INC:"+s, params)
@@ -259,18 +276,26 @@ class Delegator
259
276
  type.node.set_repo_id(tid.to_s)
260
277
  end
261
278
 
262
- def define_annotation(annid, annbody)
263
- IDL.log(3, "parsed Annotation #{annid}(#{annbody})")
264
- @annotation_stack << IDL::AST::Annotation.new(annid, annbody)
279
+ def define_annotation(annid, annpos, anncomment, annbody)
280
+ IDL.log(3, "parsed #{anncomment ? 'commented ' : ''}Annotation #{annid}(#{annbody}) @ #{annpos}")
281
+ if anncomment && @last && (@last_pos.line == annpos.line) && (@last_pos.name == annpos.name)
282
+ IDL.log(3, 'adding annotation to last node')
283
+ @last.annotations << IDL::AST::Annotation.new(annid, annbody)
284
+ else
285
+ IDL.log(3, 'appending annotation cached stack')
286
+ @annotation_stack << IDL::AST::Annotation.new(annid, annbody)
287
+ end
265
288
  end
266
289
 
267
290
  def define_module(name)
268
291
  @cur = @cur.define(IDL::AST::Module, name)
269
292
  @cur.annotations.concat(@annotation_stack) unless @annotation_stack.empty?
270
293
  @annotation_stack.clear
294
+ set_last
271
295
  @cur
272
296
  end
273
297
  def end_module(node)
298
+ set_last(@cur)
274
299
  @cur = @cur.enclosure # must equals to argument mod
275
300
  end
276
301
 
@@ -285,6 +310,7 @@ class Delegator
285
310
  @cur = @cur.define(IDL::AST::TemplateModule, names[0])
286
311
  @cur.annotations.concat(@annotation_stack) unless @annotation_stack.empty?
287
312
  @annotation_stack.clear
313
+ set_last
288
314
  @cur
289
315
  end
290
316
  alias :end_template_module :end_module
@@ -298,20 +324,23 @@ class Delegator
298
324
  params = { :type => type }
299
325
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
300
326
  @annotation_stack.clear
301
- @cur.define(IDL::AST::TemplateParam, name, params)
327
+ set_last(@cur.define(IDL::AST::TemplateParam, name, params))
328
+ @cur
302
329
  end
303
330
 
304
331
  def instantiate_template_module(name, parameters)
305
332
  tmp = @template_module_name
306
333
  @template_module_name = nil # reset
307
334
  template_type = parse_scopedname(*tmp)
308
- mod_inst = @cur.define(IDL::AST::Module, name)
309
- mod_inst.annotations.concat(@annotation_stack) unless @annotation_stack.empty?
310
- @annotation_stack.clear
311
335
  unless template_type.node.is_a?(IDL::AST::TemplateModule)
312
336
  raise RuntimeError, "invalid module template specification: #{template_type.node.typename} #{template_type.node.scoped_lm_name}"
313
337
  end
314
- template_type.node.instantiate(mod_inst, parameters)
338
+ params = { :template => template_type.node, :template_params => parameters }
339
+ mod_inst = @cur.define(IDL::AST::Module, name, params)
340
+ mod_inst.annotations.concat(@annotation_stack) unless @annotation_stack.empty?
341
+ @annotation_stack.clear
342
+ set_last(mod_inst.template.instantiate(mod_inst))
343
+ @cur
315
344
  end
316
345
 
317
346
  def declare_template_reference(name, type, tpl_params)
@@ -320,7 +349,8 @@ class Delegator
320
349
  params[:tpl_params] = tpl_params || []
321
350
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
322
351
  @annotation_stack.clear
323
- @cur.define(IDL::AST::TemplateModuleReference, name, params)
352
+ set_last(@cur.define(IDL::AST::TemplateModuleReference, name, params))
353
+ @cur
324
354
  end
325
355
 
326
356
  def declare_interface(name, attrib=nil)
@@ -332,6 +362,8 @@ class Delegator
332
362
  raise RuntimeError,
333
363
  "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
334
364
  @cur.define(IDL::AST::Interface, name, params)
365
+ set_last
366
+ @cur
335
367
  end
336
368
 
337
369
  def define_interface(name, attrib, inherits = [])
@@ -343,9 +375,11 @@ class Delegator
343
375
  params[:inherits] = inherits
344
376
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
345
377
  @annotation_stack.clear
378
+ set_last
346
379
  @cur = @cur.define(IDL::AST::Interface, name, params)
347
380
  end
348
381
  def end_interface(node)
382
+ set_last(@cur)
349
383
  @cur = @cur.enclosure # must equals to argument mod
350
384
  end
351
385
 
@@ -357,10 +391,12 @@ class Delegator
357
391
  params[:supports] = supports || []
358
392
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
359
393
  @annotation_stack.clear
394
+ set_last
360
395
  @cur = @cur.define(IDL::AST::Home, name, params)
361
396
  end
362
397
 
363
398
  def end_home(node)
399
+ set_last(@cur)
364
400
  @cur = @cur.enclosure
365
401
  end
366
402
 
@@ -369,6 +405,7 @@ class Delegator
369
405
  params[:forward] = true
370
406
  raise RuntimeError,
371
407
  "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
408
+ set_last
372
409
  @cur.define(IDL::AST::Component, name, params)
373
410
  end
374
411
 
@@ -378,10 +415,12 @@ class Delegator
378
415
  params[:supports] = supports || []
379
416
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
380
417
  @annotation_stack.clear
418
+ set_last
381
419
  @cur = @cur.define(IDL::AST::Component, name, params)
382
420
  end
383
421
 
384
422
  def end_component(node)
423
+ set_last(@cur)
385
424
  @cur = @cur.enclosure
386
425
  end
387
426
 
@@ -390,10 +429,12 @@ class Delegator
390
429
  params[:base] = base
391
430
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
392
431
  @annotation_stack.clear
432
+ set_last
393
433
  @cur = @cur.define(IDL::AST::Connector, name, params)
394
434
  end
395
435
 
396
436
  def end_connector(node)
437
+ set_last(@cur)
397
438
  @cur = @cur.enclosure
398
439
  end
399
440
 
@@ -401,10 +442,12 @@ class Delegator
401
442
  params = {}
402
443
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
403
444
  @annotation_stack.clear
445
+ set_last
404
446
  @cur = @cur.define(IDL::AST::Porttype, name, params)
405
447
  end
406
448
 
407
449
  def end_porttype(node)
450
+ set_last(@cur)
408
451
  @cur = @cur.enclosure
409
452
  end
410
453
 
@@ -415,7 +458,8 @@ class Delegator
415
458
  params[:multiple] = multiple
416
459
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
417
460
  @annotation_stack.clear
418
- @cur.define(IDL::AST::Port, name, params)
461
+ set_last(@cur.define(IDL::AST::Port, name, params))
462
+ @cur
419
463
  end
420
464
 
421
465
  def declare_eventtype(name, attrib=nil)
@@ -424,6 +468,7 @@ class Delegator
424
468
  params[:forward] = true
425
469
  raise RuntimeError,
426
470
  "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
471
+ set_last
427
472
  @cur.define(IDL::AST::Eventtype, name, params)
428
473
  @cur
429
474
  end
@@ -436,6 +481,7 @@ class Delegator
436
481
  params[:inherits] = inherits
437
482
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
438
483
  @annotation_stack.clear
484
+ set_last
439
485
  @cur = @cur.define(IDL::AST::Eventtype, name, params)
440
486
  @cur
441
487
  end
@@ -446,6 +492,7 @@ class Delegator
446
492
  params[:forward] = true
447
493
  raise RuntimeError,
448
494
  "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
495
+ set_last
449
496
  @cur.define(IDL::AST::Valuetype, name, params)
450
497
  @cur
451
498
  end
@@ -458,12 +505,14 @@ class Delegator
458
505
  params[:inherits] = inherits
459
506
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
460
507
  @annotation_stack.clear
508
+ set_last
461
509
  @cur = @cur.define(IDL::AST::Valuetype, name, params)
462
510
  @cur
463
511
  end
464
512
 
465
513
  def end_valuetype(node)
466
514
  node.defined = true
515
+ set_last(@cur)
467
516
  ret = IDL::Type::ScopedName.new(@cur)
468
517
  @cur = @cur.enclosure # must equals to argument mod
469
518
  ret
@@ -476,7 +525,7 @@ class Delegator
476
525
  params[:visibility] = (public_ ? :public : :private)
477
526
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
478
527
  @annotation_stack.clear
479
- @cur.define(IDL::AST::StateMember, name, params)
528
+ set_last(@cur.define(IDL::AST::StateMember, name, params))
480
529
  @cur
481
530
  end
482
531
 
@@ -484,7 +533,7 @@ class Delegator
484
533
  params = { :type => type }
485
534
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
486
535
  @annotation_stack.clear
487
- @cur.define(IDL::AST::Valuebox, name, params)
536
+ set_last(@cur.define(IDL::AST::Valuebox, name, params))
488
537
  @cur
489
538
  end
490
539
 
@@ -494,7 +543,7 @@ class Delegator
494
543
  params[:raises] = raises_
495
544
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
496
545
  @annotation_stack.clear
497
- @cur.define(IDL::AST::Initializer, name, params)
546
+ set_last(@cur.define(IDL::AST::Initializer, name, params))
498
547
  @cur
499
548
  end
500
549
 
@@ -504,7 +553,7 @@ class Delegator
504
553
  params[:raises] = raises_
505
554
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
506
555
  @annotation_stack.clear
507
- @cur.define(IDL::AST::Finder, name, params)
556
+ set_last(@cur.define(IDL::AST::Finder, name, params))
508
557
  @cur
509
558
  end
510
559
 
@@ -597,7 +646,7 @@ class Delegator
597
646
  params = { :type => _type, :expression => _expression }
598
647
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
599
648
  @annotation_stack.clear
600
- node = @cur.define(IDL::AST::Const, _name, params)
649
+ set_last(@cur.define(IDL::AST::Const, _name, params))
601
650
  @cur
602
651
  end
603
652
 
@@ -607,6 +656,7 @@ class Delegator
607
656
  params[:type] = _type
608
657
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
609
658
  @annotation_stack.clear
659
+ set_last
610
660
  @cur = @cur.define(IDL::AST::Operation, _name, params)
611
661
  end
612
662
  def declare_op_parameter(_attribute, _type, _name)
@@ -615,7 +665,8 @@ class Delegator
615
665
  params[:type] = _type
616
666
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
617
667
  @annotation_stack.clear
618
- @cur.define(IDL::AST::Parameter, _name, params)
668
+ set_last(@cur.define(IDL::AST::Parameter, _name, params))
669
+ @cur
619
670
  end
620
671
  def declare_op_footer(_raises, _context)
621
672
  @cur.raises = _raises || []
@@ -623,6 +674,7 @@ class Delegator
623
674
  if not @cur.context.nil?
624
675
  raise RuntimeError, "context phrase's not supported"
625
676
  end
677
+ set_last(@cur)
626
678
  @cur = @cur.enclosure
627
679
  end
628
680
 
@@ -632,13 +684,14 @@ class Delegator
632
684
  params[:readonly] = _readonly
633
685
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
634
686
  @annotation_stack.clear
635
- @cur.define(IDL::AST::Attribute, _name, params)
687
+ set_last(@cur.define(IDL::AST::Attribute, _name, params))
636
688
  end
637
689
 
638
690
  def declare_struct(_name)
639
691
  params = { :forward => true }
640
692
  raise RuntimeError,
641
693
  "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
694
+ set_last
642
695
  @cur.define(IDL::AST::Struct, _name, params)
643
696
  @cur
644
697
  end
@@ -646,6 +699,7 @@ class Delegator
646
699
  params = { :forward => false }
647
700
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
648
701
  @annotation_stack.clear
702
+ set_last
649
703
  @cur = @cur.define(IDL::AST::Struct, _name, params)
650
704
  end
651
705
  def declare_member(_type, _name)
@@ -653,10 +707,12 @@ class Delegator
653
707
  params[:type] = _type
654
708
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
655
709
  @annotation_stack.clear
656
- @cur.define(IDL::AST::Member, _name, params)
710
+ set_last(@cur.define(IDL::AST::Member, _name, params))
711
+ @cur
657
712
  end
658
713
  def end_struct(node)
659
714
  node.defined = true
715
+ set_last(@cur)
660
716
  ret = IDL::Type::ScopedName.new(@cur)
661
717
  @cur = @cur.enclosure
662
718
  ret
@@ -665,9 +721,11 @@ class Delegator
665
721
  params = { :forward => false }
666
722
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
667
723
  @annotation_stack.clear
724
+ set_last
668
725
  @cur = @cur.define(IDL::AST::Exception, _name, params)
669
726
  end
670
727
  def end_exception(node)
728
+ set_last(@cur)
671
729
  ret = IDL::Type::ScopedName.new(@cur)
672
730
  @cur = @cur.enclosure
673
731
  ret
@@ -677,6 +735,7 @@ class Delegator
677
735
  params = { :forward => true }
678
736
  raise RuntimeError,
679
737
  "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty?
738
+ set_last
680
739
  @cur.define(IDL::AST::Union, _name, params)
681
740
  @cur
682
741
  end
@@ -684,10 +743,13 @@ class Delegator
684
743
  params = { :forward => false }
685
744
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
686
745
  @annotation_stack.clear
746
+ set_last
687
747
  @cur = @cur.define(IDL::AST::Union, _name, params)
688
748
  end
689
749
  def define_union_switchtype(union_node, switchtype)
690
750
  union_node.set_switchtype(switchtype)
751
+ union_node.annotations.concat(@annotation_stack) unless @annotation_stack.empty?
752
+ @annotation_stack.clear
691
753
  union_node
692
754
  end
693
755
  def define_case(_labels, _type, _name)
@@ -696,11 +758,13 @@ class Delegator
696
758
  params[:labels] = _labels
697
759
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
698
760
  @annotation_stack.clear
699
- @cur.define(IDL::AST::UnionMember, _name, params)
761
+ set_last(@cur.define(IDL::AST::UnionMember, _name, params))
762
+ @cur
700
763
  end
701
764
  def end_union(node)
702
765
  node.validate_labels
703
766
  node.defined = true
767
+ set_last(@cur)
704
768
  ret = IDL::Type::ScopedName.new(@cur)
705
769
  @cur = @cur.enclosure
706
770
  ret
@@ -710,6 +774,7 @@ class Delegator
710
774
  params = {}
711
775
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
712
776
  @annotation_stack.clear
777
+ set_last
713
778
  @cur = @cur.define(IDL::AST::Enum, _name, params)
714
779
  end
715
780
  def declare_enumerator(_name)
@@ -720,10 +785,11 @@ class Delegator
720
785
  }
721
786
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
722
787
  @annotation_stack.clear
723
- @cur.enclosure.define(IDL::AST::Enumerator, _name, params)
788
+ set_last(@cur.enclosure.define(IDL::AST::Enumerator, _name, params))
724
789
  @cur
725
790
  end
726
791
  def end_enum(node)
792
+ set_last(@cur)
727
793
  ret = IDL::Type::ScopedName.new(@cur)
728
794
  @cur = @cur.enclosure
729
795
  ret
@@ -734,7 +800,8 @@ class Delegator
734
800
  params[:type] = _type
735
801
  params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty?
736
802
  @annotation_stack.clear
737
- @cur.define(IDL::AST::Typedef, _name, params)
803
+ set_last(@cur.define(IDL::AST::Typedef, _name, params))
804
+ @cur
738
805
  end
739
806
  end # Delegator
740
807
  end # IDL