ridl 2.5.6 → 2.7.0

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
- SHA1:
3
- metadata.gz: 314694ac1e00cdc3cbc8d6afdc18e1e7e3884670
4
- data.tar.gz: 9899c45caa2b63b1ac39c444e9e4a6c3adce1bfa
2
+ SHA256:
3
+ metadata.gz: 18e62df6c0bae092d3d8f3da6ab5cf8fad2fadfe5e839c72d59660868c187f1a
4
+ data.tar.gz: 5a51e665b994e566b6579e7f76dab959947b1294ddacc7bd566febef1dbe1766
5
5
  SHA512:
6
- metadata.gz: 0d0dbd35ff3af48b46bc0fc8f3a0c34c136ce65a8a62e3a2314563af00ed73efa96938d16a7fa12526a6817b9dbb125781b7d36cdc5a166a483a79a3a2156bbf
7
- data.tar.gz: 51ac6bf5289b2e18e87bc3f0389c43a980f0d3188f2c97c0cbccc315cb0f6bdecd72cc103bd2599d219a1ee5e6b1f4fe083d9dfda10719d434db0bbb228bb0da
6
+ metadata.gz: d6cce4394f7a366135dd636f935ea90348cba4c2bd20aa95d9f712a88c45cfaacdc82381039e329c1be1bb3d34f9fe70269a1891296ea63179ad8cea0c39ee77
7
+ data.tar.gz: b2eda0b126d08ed4cdb66bfbd7795b8f7660b45e24776fb655267885f07a444cd47e8fea42fc3893f464ec63fa3ef5e08b722549f9f90425d9708b702382699c
data/LICENSE CHANGED
@@ -1,49 +1,21 @@
1
- RIDL LICENSE
2
-
3
- RIDL (Licensed Product) is protected by copyright, and is distributed
4
- under the following terms.
5
-
6
- RIDL (Ruby IDL compiler) is an open source tool, developed by Remedy IT and
7
- written in Ruby. It is designed to provide a flexible parser/compiler
8
- frontend for OMG standard IDL.
9
- RIDL provides a generic parser component for OMG IDL and a flexible framework
10
- for plugging in (code) generation backends.
11
-
12
- Since RIDL is open source and free of licensing fees, you are free to use,
13
- modify, and distribute the source code, as long as you include this
14
- copyright statement.
15
-
16
- In particular, you can use RIDL to build proprietary software and are
17
- under no obligation to redistribute any of your source code that is built
18
- using RIDL. Note, however, that you may not do anything to the RIDL
19
- code, such as copyrighting it yourself or claiming authorship of the RIDL
20
- code, that will prevent RIDL from being distributed freely using an open
21
- source development model.
22
-
23
- Warranty
24
-
25
- LICENSED PRODUCT IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
26
- THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
- PURPOSE, NON-INFRINGEMENT, OR ARISING FROM A COURSE OF DEALING, USAGE OR
28
- TRADE PRACTICE.
29
-
30
- Support
31
-
32
- LICENSED PRODUCT IS PROVIDED WITH NO SUPPORT AND WITHOUT ANY OBLIGATION ON
33
- THE PART OF REMEDY IT OR ANY OF ITS SUBSIDIARIES OR AFFILIATES TO ASSIST IN
34
- ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
35
-
36
- Remedy IT provides support to users who have agreed on the terms of a support
37
- contract.
38
-
39
- Liability
40
-
41
- REMEDY IT OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY
42
- WITH RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS
43
- BY LICENSED PRODUCT OR ANY PART THEREOF.
44
-
45
- IN NO EVENT WILL REMEDY IT OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE
46
- FOR ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
47
- DAMAGES, EVEN IF REMEDY IT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
48
-
49
- RIDL is Copyright Remedy IT. Nijkerk, The Netherlands, 2006-2015.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Remedy IT Expertise BV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,42 +1,47 @@
1
- = RIDL Compiler
1
+ {<img src="https://badge.fury.io/rb/ridl.svg" alt="Gem Version" />}[https://badge.fury.io/rb/ridl]
2
+ {<img src="https://dev.azure.com/remedyit/axcioma/_apis/build/status/ridl?branchName=master" alt="Azure pipeline" />}[https://dev.azure.com/remedyit/axcioma/_build?definitionId=7&_a=summary]
2
3
 
3
- home :: https://osportal.remedy.nl/projects/ridl
4
+ = RIDL Compiler
4
5
 
5
6
  == Description
6
-
7
- RIDL is a Ruby library implementing an OMG \IDL parser/compiler
8
- frontend with support for pluggable (and stackable) backends.
9
7
 
10
- == Synopsis
8
+ {RIDL}[https://www.remedy.nl/opensource/ridl.html] is a Ruby library implementing an Object Management Group (OMG) {IDL}[https://www.omg.org/spec/IDL] parser/compiler frontend with support for pluggable (and stackable) backends created by {Remedy IT}[https://www.remedy.nl].
11
9
 
12
- RIDL provides a framework for implementing compiler/generators for
13
- OMG standard \IDL interface definitions.
14
- The framework includes:
10
+ == Synopsis
15
11
 
16
- * a RACC based parser supplemented with a custom scanner/tokenizer
17
- * a complete AST class hierarchy for representing parsed \IDL specifications
12
+ RIDL provides a framework for implementing compiler/generators for OMG standard IDL definitions. The framework includes:
13
+ * a {RACC}[https://github.com/ruby/racc] based parser supplemented with a custom scanner/tokenizer
14
+ * a complete AST class hierarchy for representing parsed IDL specifications
18
15
  * a complete Type class hierarchy
19
- * \IDL constants expression support
20
- * a builtin \IDL preprocessor expression parser/evaluator
16
+ * IDL constants expression support
17
+ * a builtin IDL preprocessor expression parser/evaluator
21
18
  * a flexible framework for pluggable (and stackable) backends
22
- * basic support for backend code <b>re</b>generation
19
+ * basic support for backend code re-generation
20
+ * compliant with the {OMG IDL 3.5}[https://www.omg.org/spec/IDL/3.5] standard.
21
+
22
+ Remedy IT has developed multiple backends for RIDL. These include:
23
+ * {R2CORBA}[https://www.remedy.nl/opensource/r2corba.html] generating Ruby code
24
+ * {TAOX11}[https://www.taox11.org] generating C++11 code
25
+ * {AXCIOMA}[https://www.axcioma.org] generating C++11 code
23
26
 
24
- RIDL is compliant with the latest OMG \IDL standard.
27
+ When you want to know more about how Remedy IT can assist you with developing your own backend for RIDL contact {sales@remedy.nl}[mailto:sales@remedy.nl].
25
28
 
26
29
  == Bugs
27
30
 
28
- If you find a bug, please report it at the RIDL project's
29
- {issues tracker}[https://osportal.remedy.nl/projects/ridl/issues].
31
+ If you find a bug, please report it as {RIDL issue}[https://github.com/RemedyIT/ridl/issues].
30
32
 
31
- == License
33
+ == Warranty
32
34
 
33
- RIDL is Copyright (c) 2007-2015 Remedy IT Expertise BV, The Netherlands.
35
+ This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.
34
36
 
35
- It is free software, and may be redistributed under the terms specified in
36
- the LICENSE file.
37
+ == Installing RIDL
37
38
 
38
- == Warranty
39
+ RIDL is distributed as a Ruby Gem. You can download and install RIDL as a Ruby Gem from the common {Rubygems.org}[https://www.rubygems.org/gems/ridl] repository by executing the following command:
40
+
41
+ $ gem install ridl
42
+
43
+ The RIDL Gem is a Ruby-only Gem without any dependencies.
44
+
45
+ == Releasing new RIDL Ruby Gem
39
46
 
40
- This software is provided "as is" and without any express or implied
41
- warranties, including, without limitation, the implied warranties of
42
- merchantibility and fitness for a particular purpose.
47
+ 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].
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
 
14
13
  module IDL
@@ -97,28 +96,25 @@ module IDL
97
96
  # base settings
98
97
  @base_backends.reverse.each {|be| be.setup_be(optlist, idl_options) }
99
98
  # initialize this backend
100
- _setup_be(optlist, idl_options)
99
+ _setup_be(optlist, idl_options) if self.respond_to?(:_setup_be, true)
101
100
  end
102
101
 
103
102
  def process_input(parser, params)
104
- # process input top-down
105
- _process_input(parser, params)
106
- @base_backends.each {|be| be.process_input(parser, params) }
103
+ # process input bottom-up
104
+ @base_backends.reverse.each {|be| be.process_input(parser, params) }
105
+ _process_input(parser, params) if self.respond_to?(:_process_input, true)
107
106
  end
108
107
 
109
108
  @@null_be = nil
110
109
 
111
110
  def self.null_be
112
- @@null_be ||= self.configure('null', '.', 'RIDL Null backend', 'Copyright (c) 2013 Remedy IT Expertise BV, The Netherlands', 1) do |becfg|
111
+ @@null_be ||= self.configure('null', '.', 'RIDL Null backend', "Copyright (c) 2013-#{Time.now.year} Remedy IT Expertise BV, The Netherlands", 1) do |becfg|
113
112
  becfg.on_setup do |optlist, params|
114
113
  # noop
115
114
  IDL.log(0, "Setup called for #{becfg.backend.title}")
116
115
  end
117
- becfg.on_process_input do |parser, params|
118
- # noop
119
- end
120
116
  end
121
117
  end
122
118
 
123
119
  end
124
- end
120
+ end
@@ -8,14 +8,13 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  require 'ridl/node'
14
13
  require 'ridl/expression'
15
14
 
16
15
  module IDL
17
16
 
18
- ORB_PIDL = 'orb.pidlc'
17
+ ORB_PIDL = 'orb.pidlc'.freeze
19
18
 
20
19
  class Delegator
21
20
 
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  require 'ridl/node'
14
13
 
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  require 'tempfile'
14
13
  require 'fileutils'
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  module IDL::AST
14
13
 
@@ -488,8 +487,12 @@ module IDL::AST
488
487
  return _next
489
488
  when IDL::AST::Interface
490
489
  node.annotations.concat(params[:annotations])
491
- return node if params[:forward]
492
- if node.is_defined?
490
+ # in case of a forward declaration in the same module ignore it since a previous declaration already exists
491
+ if params[:forward]
492
+ return node if node.enclosure == self
493
+ # forward declaration in different scope (other module section in same file or other file)
494
+ elsif node.is_defined?
495
+ # multiple full declarations are illegal
493
496
  raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
494
497
  end
495
498
  if (node.is_abstract? != params[:abstract]) || (node.is_local? != params[:local]) || (node.is_pseudo? != params[:pseudo])
@@ -503,9 +506,15 @@ module IDL::AST
503
506
  _intf.instance_variable_set(:@repo_id, node.instance_variable_get(:@repo_id))
504
507
 
505
508
  @children << _intf
506
- # replace forward node registration
507
- node.enclosure.undo_introduction(node)
508
- introduce(_intf)
509
+
510
+ # in case of a full declaration undo the preceding forward introduction and
511
+ # replace by full node
512
+ # (no need to introduce forward declaration since there is a preceding introduction)
513
+ unless params[:forward]
514
+ # replace forward node registration
515
+ node.enclosure.undo_introduction(node)
516
+ introduce(_intf)
517
+ end
509
518
 
510
519
  return _intf
511
520
  when IDL::AST::Valuetype
@@ -671,6 +680,14 @@ module IDL::AST
671
680
  @concrete = _param
672
681
  end
673
682
 
683
+ def concrete_matches?(idl_type)
684
+ if @concrete
685
+ concrete_type = (@concrete.is_a?(IDL::Type) ? @concrete : @concrete.idltype).resolved_type
686
+ return concrete_type.matches?(idl_type.resolved_type)
687
+ end
688
+ false
689
+ end
690
+
674
691
  def self.concrete_param(_context, _node)
675
692
  if _node.is_template?
676
693
  _cnode = if _node.is_a?(IDL::AST::TemplateParam)
@@ -746,8 +763,7 @@ module IDL::AST
746
763
  # check basetype
747
764
  unless _tptype.basetype.is_a?(IDL::Type::ScopedName) &&
748
765
  _tptype.basetype.is_node?(IDL::AST::TemplateParam) &&
749
- _tptype.basetype.node.concrete &&
750
- _tptype.basetype.node.concrete.idltype.resolved_type == _cp.resolved_type.basetype.resolved_type
766
+ _tptype.basetype.node.concrete_matches?(_cp.resolved_type.basetype)
751
767
  raise RuntimeError, "invalid sequence type as instantiation parameter for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
752
768
  end
753
769
  end
@@ -2792,6 +2808,7 @@ module IDL::AST
2792
2808
  def instantiate(_context, _enclosure)
2793
2809
  super(_context, _enclosure, {})
2794
2810
  end
2811
+
2795
2812
  end # Enum
2796
2813
 
2797
2814
  class Enumerator < Leaf
@@ -2817,7 +2834,10 @@ module IDL::AST
2817
2834
  end
2818
2835
 
2819
2836
  def instantiate(_context, _enclosure)
2820
- super(_context, _enclosure, { :enum => @enum, :value => @value })
2837
+ # find already instantiated Enum parent
2838
+ _enum = _enclosure.resolve(@enum.name)
2839
+ raise RuntimeError, "Unable to resolve instantiated Enum scope for enumerator #{@enum.name}::#{name} instantiation" unless _enum
2840
+ super(_context, _enclosure, { :enum => _enum, :value => @value })
2821
2841
  end
2822
2842
  end # Enumerator
2823
2843
 
@@ -0,0 +1,176 @@
1
+ #--------------------------------------------------------------------
2
+ # options.rb - Ruby IDL compiler options class
3
+ #
4
+ # Author: Martin Corino
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the RIDL LICENSE which is
8
+ # included with this program.
9
+ #
10
+ # Copyright (c) Remedy IT Expertise BV
11
+ #--------------------------------------------------------------------
12
+
13
+ require 'ostruct'
14
+ require 'json'
15
+
16
+ module IDL
17
+
18
+ RIDLRC = '.ridlrc'
19
+ RIDLRC_GLOBAL = File.expand_path(File.join(ENV['HOME'] || ENV['HOMEPATH'] || '~', RIDLRC))
20
+
21
+ class Options < OpenStruct
22
+
23
+ def initialize(hash=nil, marked=nil)
24
+ super(hash)
25
+ @marked = marked
26
+ end
27
+
28
+ def merge!(from, *keys)
29
+ _merge(@table, from, *keys)
30
+ self
31
+ end
32
+
33
+ def merge(from, *keys)
34
+ self.dup.merge!(from, *keys)
35
+ end
36
+
37
+ def copy!(from, *keys)
38
+ keys.flatten.each {|k| self[k] = from[k] }
39
+ self
40
+ end
41
+
42
+ def copy(from, *keys)
43
+ self.dup.copy!(from, *keys)
44
+ end
45
+
46
+ def delete(k)
47
+ modifiable.delete(k)
48
+ end
49
+
50
+ def has_key?(k)
51
+ @table.has_key?(k)
52
+ end
53
+
54
+ def keys
55
+ @table.keys
56
+ end
57
+
58
+ def dup
59
+ self.class.new(_dup_elem(@table), @marked)
60
+ end
61
+
62
+ def mark
63
+ @marked = _dup_elem(@table)
64
+ end
65
+
66
+ def restore
67
+ self.class.new(_dup_elem(@marked || @table), @marked)
68
+ end
69
+
70
+
71
+ def load(rcpath)
72
+ IDL.log(3, "Loading #{RIDLRC} from #{rcpath}")
73
+ _cfg = JSON.parse(IO.read(rcpath))
74
+ IDL.log(4, "Read from #{rcpath}: [#{_cfg}]")
75
+ _rcdir = File.dirname(rcpath)
76
+ # handle automatic env var expansion in ridl be_paths
77
+ _cfg['be_path'] = (_cfg['be_path'] || []).collect do |p|
78
+ IDL.log(5, "Examining RIDL be path [#{p}]")
79
+ # for paths coming from rc files environment vars are immediately expanded and
80
+ p.gsub!(/\$([^\s\/]+)/) { |m| ENV[$1] }
81
+ IDL.log(6, "Expanded RIDL be path [#{p}]")
82
+ # resulting relative paths converted to absolute paths
83
+ _fp = File.expand_path(p, _rcdir)
84
+ if File.directory?(_fp) # relative to rc location?
85
+ p = _fp
86
+ end # or relative to working dir
87
+ IDL.fatal("Cannot access RIDL backend search path #{p} configured in #{rcpath}") unless File.directory?(p)
88
+ IDL.log(4, "Adding RIDL backend search path : #{p}")
89
+ p
90
+ end
91
+ merge!(_cfg)
92
+ end
93
+
94
+ protected
95
+
96
+ def _merge(to, from, *keys)
97
+ keys = keys.flatten.collect {|k| k.to_sym}
98
+ keys = from.keys if keys.empty?
99
+ keys.each do |k|
100
+ if from.has_key?(k)
101
+ v = from[k]
102
+ k = k.to_sym
103
+ if to.has_key?(k)
104
+ case to[k]
105
+ when Array
106
+ to[k].concat v
107
+ when Hash
108
+ to[k].merge!(Hash === v ? v : v.to_h)
109
+ when OpenStruct
110
+ _merge(to[k].__send__(:table), v)
111
+ else
112
+ to[k] = v
113
+ end
114
+ else
115
+ to[k] = v
116
+ end
117
+ end
118
+ end
119
+ to
120
+ end
121
+
122
+ def _dup_elem(v)
123
+ case v
124
+ when Array
125
+ v.collect {|e| _dup_elem(e) }
126
+ when Hash
127
+ v.inject({}) {|h, (k,e)| h[k] = _dup_elem(e); h }
128
+ when OpenStruct
129
+ v.class.new(_dup_elem(v.__send__(:table)))
130
+ else
131
+ v
132
+ end
133
+ end
134
+
135
+ public
136
+
137
+ def self.load_config(opt)
138
+ # first collect config from known (standard and configured) locations
139
+ _rc_paths = [ RIDLRC_GLOBAL ]
140
+ _loaded_rc_paths = []
141
+ (ENV['RIDLRC'] || '').split(/:|;/).each do |p|
142
+ _rc_paths << p unless _rc_paths.include?(p)
143
+ end
144
+ _rc_paths.collect {|path| File.expand_path(path) }.each do |rcp|
145
+ IDL.log(3, "Testing rc path #{rcp}")
146
+ if File.readable?(rcp) && !_loaded_rc_paths.include?(rcp)
147
+ opt.load(rcp)
148
+ _loaded_rc_paths << rcp
149
+ else
150
+ IDL.log(3, "Ignoring #{File.readable?(rcp) ? 'already loaded' : 'inaccessible'} rc path #{rcp}")
151
+ end
152
+ end
153
+ # now scan working path for any rc files
154
+ _cwd = File.expand_path(Dir.getwd)
155
+ IDL.log(3, "scanning working path #{_cwd} for rc files")
156
+ # first collect any rc files found
157
+ _rc_paths = []
158
+ begin
159
+ _rcp = File.join(_cwd, RIDLRC)
160
+ if File.readable?(_rcp) && !_loaded_rc_paths.include?(_rcp)
161
+ _rc_paths << _rcp unless _rc_paths.include?(_rcp)
162
+ else
163
+ IDL.log(3, "Ignoring #{File.readable?(_rcp) ? 'already loaded' : 'inaccessible'} rc path #{_rcp}")
164
+ end
165
+ break if /\A(.:(\\|\/)|\.|\/)\Z/ =~ _cwd
166
+ _cwd = File.dirname(_cwd)
167
+ end while true
168
+ # now load them in reverse order
169
+ _rc_paths.reverse.each do |_rcp|
170
+ opt.load(_rcp)
171
+ _loaded_rc_paths << _rcp
172
+ end
173
+ end
174
+ end
175
+
176
+ end