r2corba 1.4.1-x86-mingw32 → 1.5.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +7 -7
  2. data/CHANGES +173 -159
  3. data/LICENSE +59 -59
  4. data/README +62 -62
  5. data/THANKS +54 -52
  6. data/bin/r2corba +1 -1
  7. data/bin/ridlc +1 -1
  8. data/bin/rins +1 -1
  9. data/lib/corba.rb +16 -16
  10. data/lib/corba/cbase/IORMap.rb +33 -33
  11. data/lib/corba/cbase/ORB.rb +237 -231
  12. data/lib/corba/cbase/Request.rb +133 -133
  13. data/lib/corba/cbase/Streams.rb +129 -129
  14. data/lib/corba/cbase/Stub.rb +19 -19
  15. data/lib/corba/cbase/Typecode.rb +441 -441
  16. data/lib/corba/cbase/Values.rb +129 -129
  17. data/lib/corba/cbase/exception.rb +66 -66
  18. data/lib/corba/cbase/poa.rb +23 -23
  19. data/lib/corba/cbase/policies.rb +77 -77
  20. data/lib/corba/cbase/post_require.rb +13 -13
  21. data/lib/corba/cbase/require.rb +28 -28
  22. data/lib/corba/cmds/base.rb +85 -85
  23. data/lib/corba/cmds/test.rb +30 -30
  24. data/lib/corba/common/Any.rb +91 -91
  25. data/lib/corba/common/IDL.rb +104 -104
  26. data/lib/corba/common/ORB.rb +368 -368
  27. data/lib/corba/common/Object.rb +208 -208
  28. data/lib/corba/common/Request.rb +19 -19
  29. data/lib/corba/common/Servant.rb +108 -108
  30. data/lib/corba/common/Struct.rb +21 -21
  31. data/lib/corba/common/Stub.rb +79 -79
  32. data/lib/corba/common/Typecode.rb +1121 -1121
  33. data/lib/corba/common/Union.rb +55 -55
  34. data/lib/corba/common/Values.rb +91 -91
  35. data/lib/corba/common/const.rb +22 -22
  36. data/lib/corba/common/exception.rb +68 -68
  37. data/lib/corba/common/require.rb +27 -27
  38. data/lib/corba/common/version.rb +22 -22
  39. data/lib/corba/idl/IDL.rb +21 -21
  40. data/lib/corba/idl/IORTable.pidl +62 -62
  41. data/lib/corba/idl/TAO_Ext.pidl +46 -46
  42. data/lib/corba/idl/require.rb +20 -20
  43. data/lib/corba/jbase/Any.rb +273 -273
  44. data/lib/corba/jbase/IORMap.rb +35 -35
  45. data/lib/corba/jbase/ORB.rb +112 -99
  46. data/lib/corba/jbase/Object.rb +99 -98
  47. data/lib/corba/jbase/Request.rb +225 -225
  48. data/lib/corba/jbase/Servant.rb +247 -246
  49. data/lib/corba/jbase/ServerRequest.rb +127 -127
  50. data/lib/corba/jbase/Streams.rb +670 -670
  51. data/lib/corba/jbase/Stub.rb +38 -38
  52. data/lib/corba/jbase/Typecode.rb +520 -520
  53. data/lib/corba/jbase/Values.rb +173 -173
  54. data/lib/corba/jbase/exception.rb +106 -106
  55. data/lib/corba/jbase/poa.rb +228 -228
  56. data/lib/corba/jbase/policies.rb +299 -299
  57. data/lib/corba/jbase/post_require.rb +14 -14
  58. data/lib/corba/jbase/require.rb +89 -86
  59. data/lib/corba/naming.rb +14 -14
  60. data/lib/corba/naming_service.rb +15 -15
  61. data/lib/corba/poa.rb +15 -15
  62. data/lib/corba/policies.rb +18 -18
  63. data/lib/corba/require.rb +17 -17
  64. data/lib/corba/svcs/ins/cos_naming.rb +426 -426
  65. data/lib/corba/svcs/ins/ins.rb +526 -526
  66. data/lib/corba/svcs/ins/naming_service.rb +119 -119
  67. data/lib/ridlbe/ruby/config.rb +336 -336
  68. data/lib/ridlbe/ruby/orb.pidlc +0 -0
  69. data/lib/ridlbe/ruby/require.rb +16 -16
  70. data/lib/ridlbe/ruby/walker.rb +1582 -1582
  71. data/mkrf_conf_bingem.rb +151 -101
  72. data/rakelib/bin.rake +80 -80
  73. data/rakelib/bin.rb +145 -145
  74. data/rakelib/build.rake +87 -87
  75. data/rakelib/config.rake +51 -51
  76. data/rakelib/config.rb +543 -449
  77. data/rakelib/ext.rake +242 -242
  78. data/rakelib/ext.rb +316 -308
  79. data/rakelib/ext_r2tao.rb +235 -232
  80. data/rakelib/gem.rake +235 -211
  81. data/rakelib/gem.rb +145 -145
  82. data/rakelib/package.rake +26 -26
  83. data/rakelib/test.rake +23 -23
  84. data/test/BiDirectional/Test.idl +34 -34
  85. data/test/BiDirectional/client.rb +131 -131
  86. data/test/BiDirectional/run_test.rb +68 -68
  87. data/test/BiDirectional/server.ior +1 -1
  88. data/test/BiDirectional/server.rb +169 -169
  89. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -27
  90. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -121
  91. data/test/CORBA_Services/Naming/BindingIterator/ins.ior +1 -1
  92. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -82
  93. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -109
  94. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -27
  95. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -85
  96. data/test/CORBA_Services/Naming/Corbaname/ins.ior +1 -1
  97. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -88
  98. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -135
  99. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -27
  100. data/test/CORBA_Services/Naming/Simple/client.rb +84 -84
  101. data/test/CORBA_Services/Naming/Simple/ins.ior +1 -1
  102. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -82
  103. data/test/CORBA_Services/Naming/Simple/server.rb +109 -109
  104. data/test/Collocation/Diamond.idl +39 -39
  105. data/test/Collocation/run_test.rb +52 -52
  106. data/test/Collocation/test.rb +195 -195
  107. data/test/Connect_Timeout/Test.idl +27 -27
  108. data/test/Connect_Timeout/client.rb +111 -111
  109. data/test/Connect_Timeout/run_test.rb +52 -52
  110. data/test/DII/Test.idl +27 -27
  111. data/test/DII/client.rb +115 -115
  112. data/test/DII/run_test.rb +69 -69
  113. data/test/DII/server.ior +1 -1
  114. data/test/DII/server.rb +95 -95
  115. data/test/DSI/Test.idl +27 -27
  116. data/test/DSI/client.rb +66 -66
  117. data/test/DSI/run_test.rb +69 -69
  118. data/test/DSI/server.ior +1 -1
  119. data/test/DSI/server.rb +106 -106
  120. data/test/Exceptions/Test.idl +48 -48
  121. data/test/Exceptions/client.rb +117 -117
  122. data/test/Exceptions/run_test.rb +69 -69
  123. data/test/Exceptions/server.ior +1 -1
  124. data/test/Exceptions/server.rb +131 -131
  125. data/test/Hello/Test.idl +27 -27
  126. data/test/Hello/client.rb +78 -78
  127. data/test/Hello/run_test.rb +71 -71
  128. data/test/Hello/server.rb +95 -95
  129. data/test/IDL_Test/Test.idl +113 -113
  130. data/test/IDL_Test/Test_inc.idl +17 -17
  131. data/test/IDL_Test/client.rb +102 -102
  132. data/test/IDL_Test/run_test.rb +69 -69
  133. data/test/IDL_Test/server.ior +1 -1
  134. data/test/IDL_Test/server.rb +99 -99
  135. data/test/IORMap/Test.idl +27 -27
  136. data/test/IORMap/client.rb +73 -73
  137. data/test/IORMap/run_test.rb +69 -69
  138. data/test/IORMap/server.ior +1 -1
  139. data/test/IORMap/server.rb +114 -114
  140. data/test/IORTable/Test.idl +27 -27
  141. data/test/IORTable/client.rb +75 -75
  142. data/test/IORTable/run_test.rb +69 -69
  143. data/test/IORTable/server.ior +1 -1
  144. data/test/IORTable/server.rb +130 -130
  145. data/test/Implicit_Conversion/Test.idl +31 -31
  146. data/test/Implicit_Conversion/client.rb +110 -110
  147. data/test/Implicit_Conversion/run_test.rb +69 -69
  148. data/test/Implicit_Conversion/server.ior +1 -1
  149. data/test/Implicit_Conversion/server.rb +99 -99
  150. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -27
  151. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -82
  152. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -71
  153. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -108
  154. data/test/Multi_Threading/Multiple_ORB/server0.ior +1 -1
  155. data/test/Multi_Threading/Multiple_ORB/server1.ior +1 -1
  156. data/test/Multi_Threading/Simple/Test.idl +27 -27
  157. data/test/Multi_Threading/Simple/client.rb +93 -88
  158. data/test/Multi_Threading/Simple/run_test.rb +69 -69
  159. data/test/Multi_Threading/Simple/server.ior +1 -1
  160. data/test/Multi_Threading/Simple/server.rb +117 -117
  161. data/test/Multi_Threading/Threads/Test.idl +31 -31
  162. data/test/Multi_Threading/Threads/client.rb +80 -80
  163. data/test/Multi_Threading/Threads/run_test.rb +76 -76
  164. data/test/Multi_Threading/Threads/server.ior +1 -1
  165. data/test/Multi_Threading/Threads/server.rb +119 -119
  166. data/test/Multi_Threading/Threads/watchdog.ior +1 -1
  167. data/test/Multi_Threading/Threads/watchdog.rb +87 -87
  168. data/test/Multiple_Servant_Interfaces/Test.idl +34 -34
  169. data/test/Multiple_Servant_Interfaces/client.rb +70 -70
  170. data/test/Multiple_Servant_Interfaces/run_test.rb +69 -69
  171. data/test/Multiple_Servant_Interfaces/server.ior +1 -1
  172. data/test/Multiple_Servant_Interfaces/server.rb +102 -102
  173. data/test/Nil/Test.idl +27 -27
  174. data/test/Nil/run_test.rb +52 -52
  175. data/test/Nil/test.rb +78 -78
  176. data/test/OBV/AbstractInterface/client.rb +179 -179
  177. data/test/OBV/AbstractInterface/run_test.rb +69 -69
  178. data/test/OBV/AbstractInterface/server.ior +1 -1
  179. data/test/OBV/AbstractInterface/server.rb +149 -149
  180. data/test/OBV/AbstractInterface/test.idl +53 -53
  181. data/test/OBV/Custom/OBV.idl +18 -18
  182. data/test/OBV/Custom/OBV_impl.rb +40 -40
  183. data/test/OBV/Custom/client.rb +86 -86
  184. data/test/OBV/Custom/run_test.rb +69 -69
  185. data/test/OBV/Custom/server.ior +1 -1
  186. data/test/OBV/Custom/server.rb +100 -100
  187. data/test/OBV/Simple/OBV.idl +15 -15
  188. data/test/OBV/Simple/OBV_impl.rb +26 -26
  189. data/test/OBV/Simple/client.rb +86 -86
  190. data/test/OBV/Simple/run_test.rb +69 -69
  191. data/test/OBV/Simple/server.ior +1 -1
  192. data/test/OBV/Simple/server.rb +100 -100
  193. data/test/OBV/Simple_Event/Event.idl +15 -15
  194. data/test/OBV/Simple_Event/Event_impl.rb +26 -26
  195. data/test/OBV/Simple_Event/client.rb +86 -86
  196. data/test/OBV/Simple_Event/run_test.rb +69 -69
  197. data/test/OBV/Simple_Event/server.ior +1 -1
  198. data/test/OBV/Simple_Event/server.rb +100 -100
  199. data/test/OBV/Supports/client.rb +116 -116
  200. data/test/OBV/Supports/run_test.rb +69 -69
  201. data/test/OBV/Supports/server.ior +1 -1
  202. data/test/OBV/Supports/server.rb +103 -103
  203. data/test/OBV/Supports/supports.idl +33 -33
  204. data/test/OBV/Supports/supports_impl.rb +57 -57
  205. data/test/OBV/Tree/client.rb +116 -116
  206. data/test/OBV/Tree/run_test.rb +69 -69
  207. data/test/OBV/Tree/server.ior +1 -1
  208. data/test/OBV/Tree/server.rb +117 -117
  209. data/test/OBV/Tree/test.idl +32 -32
  210. data/test/OBV/Truncatable/Extra.idl +27 -27
  211. data/test/OBV/Truncatable/Truncatable.idl +105 -105
  212. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -86
  213. data/test/OBV/Truncatable/client.rb +279 -279
  214. data/test/OBV/Truncatable/run_test.rb +69 -69
  215. data/test/OBV/Truncatable/server.ior +1 -1
  216. data/test/OBV/Truncatable/server.rb +89 -89
  217. data/test/OBV/ValueBox/client.rb +497 -497
  218. data/test/OBV/ValueBox/run_test.rb +69 -69
  219. data/test/OBV/ValueBox/server.ior +1 -1
  220. data/test/OBV/ValueBox/server.rb +271 -271
  221. data/test/OBV/ValueBox/valuebox.idl +101 -101
  222. data/test/OBV/ValueBox/vb_basic.idl +75 -75
  223. data/test/OBV/ValueBox/vb_struct.idl +68 -68
  224. data/test/OBV/ValueBox/vb_union.idl +21 -21
  225. data/test/Object/Test.idl +27 -27
  226. data/test/Object/client.rb +112 -103
  227. data/test/Object/run_test.rb +69 -69
  228. data/test/Object/server.ior +1 -1
  229. data/test/Object/server.rb +126 -126
  230. data/test/POA/Test.idl +27 -27
  231. data/test/POA/run_test.rb +52 -52
  232. data/test/POA/test.rb +111 -111
  233. data/test/Param_Test/Test.idl +182 -182
  234. data/test/Param_Test/client.rb +277 -277
  235. data/test/Param_Test/run_test.rb +69 -69
  236. data/test/Param_Test/server.ior +1 -1
  237. data/test/Param_Test/server.rb +296 -296
  238. data/test/Performance/Simple/Test.idl +27 -27
  239. data/test/Performance/Simple/client.rb +90 -90
  240. data/test/Performance/Simple/run_test.rb +69 -69
  241. data/test/Performance/Simple/server.ior +1 -1
  242. data/test/Performance/Simple/server.rb +95 -95
  243. data/test/Policies/Test.idl +27 -27
  244. data/test/Policies/run_test.rb +52 -52
  245. data/test/Policies/test.rb +144 -144
  246. data/test/Timeout/client.rb +207 -207
  247. data/test/Timeout/run_test.rb +69 -69
  248. data/test/Timeout/server.ior +1 -1
  249. data/test/Timeout/server.rb +109 -109
  250. data/test/Timeout/test.idl +19 -19
  251. data/test/lib/assert.rb +43 -43
  252. data/test/lib/test.rb +542 -542
  253. data/test/test_runner.rb +193 -193
  254. metadata +141 -137
@@ -1,119 +1,119 @@
1
- #--------------------------------------------------------------------
2
- # naming_service.rb - Implementation of Naming Service
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 R2CORBA LICENSE which is
8
- # included with this program.
9
- #
10
- # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
- #--------------------------------------------------------------------
13
-
14
- require 'corba'
15
- require 'corba/svcs/ins/cos_naming'
16
-
17
- module R2CORBA
18
- module INS
19
- class Service
20
- # default options
21
- OPTIONS = {
22
- :iorfile => 'ins.ior',
23
- :debug => 0,
24
- :threads => 5,
25
- :orbprop => {},
26
- :port => 0
27
- }
28
-
29
- def initialize(options = {})
30
- @options = OPTIONS.merge(options)
31
- raise RuntimeError, 'nr. of threads must >= 1' if @options[:threads] < 1
32
- end
33
-
34
- def setup
35
- # process options
36
- #
37
- if defined?(JRUBY_VERSION)
38
- @options[:orbprop]['jacorb.poa.thread_pool_min'] = @options[:threads]
39
- @options[:orbprop]['jacorb.poa.thread_pool_max'] = @options[:threads]*4
40
- if @options[:debug] > 0
41
- @options[:orbprop]['jacorb.log.default.verbosity'] = case
42
- when @options[:debug] < 2
43
- 1
44
- when (2...4) === @options[:debug]
45
- 2
46
- when (5...7) === @options[:debug]
47
- 3
48
- when @options[:debug] > 7
49
- 4
50
- end
51
- end
52
- if @options[:port] > 0
53
- @options[:orbprop]['OAPort'] = @options[:port]
54
- end
55
- else
56
- if @options[:debug] > 0
57
- @options[:orbprop]['-ORBDebugLevel'] = @options[:debug]
58
- end
59
- if @options[:port] > 0
60
- @options[:orbprop]['-ORBListenEndpoints'] = "iiop://:#{@options[:port]}"
61
- end
62
- end
63
-
64
- # initialize ORB and POA.
65
- #
66
- @orb = CORBA.ORB_init('INS_ORB', @options[:orbprop])
67
-
68
- obj = @orb.resolve_initial_references('RootPOA')
69
-
70
- root_poa = PortableServer::POA._narrow(obj)
71
-
72
- poa_man = root_poa.the_POAManager
73
-
74
- poa_man.activate
75
-
76
- # create and activate root Naming context
77
- #
78
- @naming_srv = INS::NamingContext.new(@orb)
79
-
80
- naming_obj = @naming_srv._this()
81
-
82
- naming_ior = @orb.object_to_string(naming_obj)
83
-
84
- # simplify Corbaloc urls (corbaloc:iiop:[host][:port]/NamingService)
85
- #
86
- @orb.ior_map.map_ior('NamingService', naming_ior)
87
-
88
- # save INS IOR to file
89
- #
90
- open(@options[:iorfile], 'w') { |io|
91
- io.write naming_ior
92
- }
93
- end
94
-
95
- def run
96
- STDERR.puts "INS - starting service run" if @options[:verbose]
97
- if (defined?(JRUBY_VERSION) or !R2CORBA::TAO::RUBY_THREAD_SUPPORT)
98
- STDERR.puts "INS - running ORB" if @options[:verbose]
99
- @orb.run
100
- else
101
- STDERR.puts "INS - starting #{@options[:threads]} ORB threads" if @options[:verbose]
102
- @threads = []
103
- @options[:threads].times do
104
- @threads << Thread.new(@orb) { |orb| orb.run }
105
- end
106
- STDERR.puts "INS - joining ORB threads" if @options[:verbose]
107
- @threads.each { |t| t.join }
108
- end
109
- STDERR.puts "INS - service run ended" if @options[:verbose]
110
- end
111
-
112
- def shutdown
113
- STDERR.puts "INS - shutting down ORB" if @options[:verbose]
114
- @orb.shutdown if @orb
115
- STDERR.puts "INS - shutdown finished" if @options[:verbose]
116
- end
117
- end
118
- end
119
- end
1
+ #--------------------------------------------------------------------
2
+ # naming_service.rb - Implementation of Naming Service
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 R2CORBA LICENSE which is
8
+ # included with this program.
9
+ #
10
+ # Copyright (c) Remedy IT Expertise BV
11
+ # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
+ #--------------------------------------------------------------------
13
+
14
+ require 'corba'
15
+ require 'corba/svcs/ins/cos_naming'
16
+
17
+ module R2CORBA
18
+ module INS
19
+ class Service
20
+ # default options
21
+ OPTIONS = {
22
+ :iorfile => 'ins.ior',
23
+ :debug => 0,
24
+ :threads => 5,
25
+ :orbprop => {},
26
+ :port => 0
27
+ }
28
+
29
+ def initialize(options = {})
30
+ @options = OPTIONS.merge(options)
31
+ raise RuntimeError, 'nr. of threads must >= 1' if @options[:threads] < 1
32
+ end
33
+
34
+ def setup
35
+ # process options
36
+ #
37
+ if defined?(JRUBY_VERSION)
38
+ @options[:orbprop]['jacorb.poa.thread_pool_min'] = @options[:threads]
39
+ @options[:orbprop]['jacorb.poa.thread_pool_max'] = @options[:threads]*4
40
+ if @options[:debug] > 0
41
+ @options[:orbprop]['jacorb.log.default.verbosity'] = case
42
+ when @options[:debug] < 2
43
+ 1
44
+ when (2...4) === @options[:debug]
45
+ 2
46
+ when (5...7) === @options[:debug]
47
+ 3
48
+ when @options[:debug] > 7
49
+ 4
50
+ end
51
+ end
52
+ if @options[:port] > 0
53
+ @options[:orbprop]['OAPort'] = @options[:port]
54
+ end
55
+ else
56
+ if @options[:debug] > 0
57
+ @options[:orbprop]['-ORBDebugLevel'] = @options[:debug]
58
+ end
59
+ if @options[:port] > 0
60
+ @options[:orbprop]['-ORBListenEndpoints'] = "iiop://:#{@options[:port]}"
61
+ end
62
+ end
63
+
64
+ # initialize ORB and POA.
65
+ #
66
+ @orb = CORBA.ORB_init('INS_ORB', @options[:orbprop])
67
+
68
+ obj = @orb.resolve_initial_references('RootPOA')
69
+
70
+ root_poa = PortableServer::POA._narrow(obj)
71
+
72
+ poa_man = root_poa.the_POAManager
73
+
74
+ poa_man.activate
75
+
76
+ # create and activate root Naming context
77
+ #
78
+ @naming_srv = INS::NamingContext.new(@orb)
79
+
80
+ naming_obj = @naming_srv._this()
81
+
82
+ naming_ior = @orb.object_to_string(naming_obj)
83
+
84
+ # simplify Corbaloc urls (corbaloc:iiop:[host][:port]/NamingService)
85
+ #
86
+ @orb.ior_map.map_ior('NamingService', naming_ior)
87
+
88
+ # save INS IOR to file
89
+ #
90
+ open(@options[:iorfile], 'w') { |io|
91
+ io.write naming_ior
92
+ }
93
+ end
94
+
95
+ def run
96
+ STDERR.puts "INS - starting service run" if @options[:verbose]
97
+ if (defined?(JRUBY_VERSION) or !R2CORBA::TAO::RUBY_THREAD_SUPPORT)
98
+ STDERR.puts "INS - running ORB" if @options[:verbose]
99
+ @orb.run
100
+ else
101
+ STDERR.puts "INS - starting #{@options[:threads]} ORB threads" if @options[:verbose]
102
+ @threads = []
103
+ @options[:threads].times do
104
+ @threads << Thread.new(@orb) { |orb| orb.run }
105
+ end
106
+ STDERR.puts "INS - joining ORB threads" if @options[:verbose]
107
+ @threads.each { |t| t.join }
108
+ end
109
+ STDERR.puts "INS - service run ended" if @options[:verbose]
110
+ end
111
+
112
+ def shutdown
113
+ STDERR.puts "INS - shutting down ORB" if @options[:verbose]
114
+ @orb.shutdown if @orb
115
+ STDERR.puts "INS - shutdown finished" if @options[:verbose]
116
+ end
117
+ end
118
+ end
119
+ end
@@ -1,336 +1,336 @@
1
- #--------------------------------------------------------------------
2
- # config.rb - IDL language mapping configuration for Ruby
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 R2CORBA LICENSE which is
8
- # included with this program.
9
- #
10
- # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
- #--------------------------------------------------------------------
13
-
14
- module IDL
15
-
16
- class StrOStream
17
- def initialize()
18
- @str = ""
19
- end
20
- def clear
21
- @str = ""
22
- end
23
- def to_s
24
- @str
25
- end
26
- def <<(s)
27
- @str << s
28
- end
29
- end # class StrOStream
30
-
31
- class RIDL
32
- private
33
- def RIDL.merge_params(params)
34
- opts = IDL::OPTIONS.dup
35
- params.each do |k,v|
36
- case opts[k]
37
- when Array
38
- opts[k] = opts[k] + (Array === v ? v : [v])
39
- when Hash
40
- opts[k] = opts[k].merge(v) if Hash === v
41
- else
42
- opts[k] = v
43
- end
44
- end
45
- opts
46
- end
47
- def RIDL.parse0(src, params)
48
- params = merge_params(params)
49
- IDL.verbose_level = params[:verbose]
50
- parser = ::IDL::Parser.new(params)
51
- parser.parse(src)
52
- s = ::IDL::StrOStream.new
53
- s.clear
54
- IDL::Ruby.process_input(parser,params,s)
55
- s
56
- end
57
- def RIDL.parse(src, params)
58
- s = parse0(src, params)
59
- s.to_s
60
- end
61
- public
62
- def RIDL.eval(src, params={})
63
- params[:idl_eval] = true
64
- params[:expand_includes] = true
65
- params[:client_stubs] = true if params[:client_stubs].nil?
66
- params[:stubs_only] ||= false
67
- s = parse0(src, params)
68
- Kernel.eval(s.to_s, ::TOPLEVEL_BINDING)
69
- s = nil
70
- end
71
- def RIDL.fparse(fname, params = {})
72
- params[:client_stubs] = true if params[:client_stubs].nil?
73
- params[:stubs_only] ||= false
74
- f = File.open(fname, "r")
75
- self.parse(f, params)
76
- ensure
77
- f.close
78
- end
79
- def RIDL.feval(fname, params = {})
80
- File.open(fname, "r") { |io| self.eval(io, params) }
81
- end
82
- end # module RIDL
83
-
84
- module Ruby
85
- COPYRIGHT = 'Copyright (c) 2007-2013 Remedy IT Expertise BV, The Netherlands'.freeze
86
- TITLE = 'RIDL Ruby backend'.freeze
87
- VERSION = {
88
- :major => 1,
89
- :minor => 9,
90
- :release => 2
91
- }
92
-
93
- ## Configure Ruby backend
94
- #
95
- Backend.configure('ruby', File.dirname(__FILE__), TITLE, COPYRIGHT, VERSION) do |becfg|
96
-
97
- # setup backend option handling
98
- #
99
- becfg.on_setup do |optlist, ridl_params|
100
- # defaults
101
- ridl_params[:stub_pfx] = 'C'
102
- ridl_params[:srv_pfx] = 'S'
103
- ridl_params[:stubs_only] = false
104
- ridl_params[:client_stubs] = true
105
- ridl_params[:expand_includes] = false
106
- ridl_params[:libinit] = true
107
- ridl_params[:class_interfaces] = []
108
-
109
- # ruby specific option switches
110
-
111
- unless IDL.preprocessing? # same switch defined for IDL preprocessing mode
112
- optlist.for_switch "--output=FILE", :type => String,
113
- :description => ['Specifies filename to generate output in.',
114
- 'Default: File.basename(idlfile, \'.idl\')+<postfix>+<ext>'] do |swcfg|
115
- swcfg.on_exec do |arg, params|
116
- params[:output] = arg
117
- end
118
-
119
- end
120
- end
121
-
122
- optlist.for_switch '-o PATH', :type => String,
123
- :description => ["Specifies output directory.",
124
- "Default: ./"] do |swcfg|
125
- swcfg.on_exec do |arg, params|
126
- params[:outputdir] = arg
127
- end
128
- end
129
- optlist.for_switch '--stubs-only',
130
- :description => ["Only generate client stubs, no servant code.",
131
- "Default: off"] do |swcfg|
132
- swcfg.on_exec do |arg, params|
133
- params[:client_stubs] = true
134
- params[:stubs_only] = true
135
- end
136
- end
137
- optlist.for_switch '--no-stubs',
138
- :description => ["Do not generate client stubs, only servant code.",
139
- "Default: off"] do |swcfg|
140
- swcfg.on_exec do |arg, params|
141
- params[:client_stubs] = false
142
- params[:stubs_only] = false
143
- end
144
- end
145
- optlist.for_switch '--stub-pfx=POSTFIX', :type => String,
146
- :description => ['Specifies postfix for generated client stub source filename.',
147
- 'Filenames are formed like: <idl basename><postfix>.<language extension>',
148
- "Default: #{ridl_params[:stub_pfx]}"] do |swcfg|
149
- swcfg.on_exec do |arg, params|
150
- params[:stub_pfx] = arg
151
- end
152
- end
153
- optlist.for_switch '--skel-pfx=POSTFIX', :type => String,
154
- :description => ['Specifies postfix for generated servant skeleton source filename.',
155
- 'Filenames are formed like: <idl basename><postfix>.<language extension>',
156
- "Default: #{ridl_params[:srv_pfx]}"] do |swcfg|
157
- swcfg.on_exec do |arg, params|
158
- params[:srv_pfx] = arg
159
- end
160
- end
161
-
162
- optlist.for_switch '--skel-directory=PATH', :type => String,
163
- :description => ["Specifies output directory for servant files.",
164
- "Default: outputdir or ./"] do |swcfg|
165
- swcfg.on_exec do |arg, params|
166
- params[:skel_outputdir] = arg
167
- end
168
- end
169
- optlist.for_switch '--expand-includes',
170
- :description => ["Generate code for included IDL inline.",
171
- "Default: off"] do |swcfg|
172
- swcfg.on_exec do |arg, params|
173
- params[:expand_includes] = true
174
- end
175
- end
176
- optlist.for_switch '--no-libinit',
177
- :description => ["Do not generate library initialization code as preamble.",
178
- "Default: on"] do |swcfg|
179
- swcfg.on_exec do |arg, params|
180
- params[:libinit] = false
181
- end
182
- end
183
- optlist.for_switch '--interface-as-class=INTF', :type => String,
184
- :description => ["Generate a Ruby class for interface INTF instead of a module in client stubs.",
185
- "Default: module"] do |swcfg|
186
- swcfg.on_exec do |arg, params|
187
- params[:class_interfaces] << arg
188
- end
189
- end
190
- end
191
-
192
- # process input / generate code
193
- # arguments:
194
- # in parser - parser object with full AST from parsed source
195
- # in options - initialized option hash
196
- #
197
- becfg.on_process_input do |parser, options|
198
- IDL::Ruby.process_input(parser,options)
199
- end # becfg.on_process_input
200
-
201
- end # Backend.configure
202
-
203
- def self.process_input(parser, options, outstream = nil)
204
- # has a user defined output filename been set
205
- fixed_output = !options[:output].nil?
206
-
207
- # determine output file path for client stub code
208
- unless fixed_output || options[:idlfile].nil?
209
- options[:output] = options[:outputdir]+'/'+File.basename(options[:idlfile], '.idl')+options[:stub_pfx]+'.rb'
210
- end
211
- # generate client stubs if requested
212
- if options[:client_stubs]
213
- # open output file
214
- co = outstream || (if options[:output].nil?
215
- GenFile.new(nil, :output_file => $stdout)
216
- else
217
- GenFile.new(options[:output])
218
- end)
219
- begin
220
- # process StubWriter
221
- parser.visit_nodes(::IDL::RubyStubWriter.new(co, options))
222
- rescue => ex
223
- IDL.log(0, ex)
224
- IDL.log(0, ex.backtrace.join("\n")) unless ex.is_a? IDL::ParseError
225
- exit 1
226
- end
227
- end
228
-
229
- # determin output file path for servant code and open file
230
- unless options[:stubs_only]
231
- so = outstream || (unless fixed_output || options[:idlfile].nil?
232
- options[:srv_output] = if fixed_output
233
- options[:output]
234
- else
235
- options[:outputdir]+'/'+File.basename(options[:idlfile], '.idl')+options[:srv_pfx]+'.rb'
236
- end
237
- if fixed_output && options[:client_stubs]
238
- co
239
- else
240
- GenFile.new(options[:srv_output])
241
- end
242
- else
243
- GenFile.new(nil, :output_file => $stdout)
244
- end)
245
- begin
246
- # process ServantWriter
247
- parser.visit_nodes(::IDL::RubyServantWriter.new(so, options))
248
- rescue => ex
249
- IDL.log(0, ex)
250
- IDL.log(0, ex.backtrace.join("\n")) unless ex.is_a? IDL::ParseError
251
- exit 1
252
- end
253
- end
254
- end
255
-
256
- module LeafMixin
257
-
258
- RESERVED_RUBY_CONST = [
259
- 'Array', 'Bignum', 'Binding', 'Class', 'Continuation', 'Dir', 'Exception',
260
- 'FalseClass', 'File', 'Fixnum', 'Float', 'Hash', 'Integer', 'IO', 'MatchData',
261
- 'Method', 'Module', 'NilClass', 'Numeric', 'Object', 'Proc', 'Process', 'Range',
262
- 'Regexp', 'String', 'Struct', 'Symbol', 'Thread', 'ThreadGroup', 'Time', 'TrueClass',
263
- 'UnboundMethod', 'Comparable', 'Enumerable', 'Errno', 'FileTest', 'GC', 'Kernel',
264
- 'Marshal', 'Math', 'ObjectSpace', 'Signal'
265
- ]
266
-
267
- RESERVED_RUBY_MEMBER = [
268
- "untaint", "id", "instance_variable_get", "inspect", "taint", "public_methods", "__send__", "to_a", "display", "instance_eval",
269
- "extend", "clone", "protected_methods", "hash", "freeze", "type", "instance_variable_set", "methods", "instance_variables", "to_s", "method", "dup",
270
- "private_methods", "object_id", "send", "__id__", "singleton_methods",
271
- "proc", "readline", "global_variables", "singleton_method_removed", "callcc", "syscall", "fail", "untrace_var", "load", "srand", "puts", "catch", "chomp",
272
- "initialize_copy", "format", "scan", "print", "abort", "fork", "gsub", "trap", "test", "select", "initialize", "method_missing", "lambda", "readlines",
273
- "local_variables", "singleton_method_undefined", "system", "open", "caller", "eval", "set_trace_func", "require", "rand", "singleton_method_added",
274
- "throw", "gets", "binding", "raise", "warn", "getc", "exec", "trace_var", "irb_binding", "at_exit", "split", "putc", "loop", "chop", "sprintf", "p",
275
- "remove_instance_variable", "exit", "printf", "sleep", "sub", "autoload"
276
- ]
277
-
278
- def self.included(klass)
279
- klass.extend ClassMethods
280
- end
281
-
282
- def rubyname
283
- lm_name
284
- end
285
-
286
- def scoped_rubyname
287
- scoped_lm_name
288
- end
289
-
290
- module ClassMethods
291
- def mk_name(nm, is_scoped)
292
- ret = nm.dup
293
- case self::NAMETYPE
294
- when :class
295
- ret = ret[0,1].upcase + ret[1,ret.size].to_s
296
- ret = 'R_'+ret if !is_scoped && IDL::Ruby::LeafMixin::RESERVED_RUBY_CONST.include?(ret)
297
- when :member
298
- ret = ret[0,1].downcase + ret[1,ret.size].to_s
299
- ret = 'r_'+ret if IDL::Ruby::LeafMixin::RESERVED_RUBY_MEMBER.include?(ret)
300
- else
301
- raise RuntimeError,
302
- "invalid nametype for #{self.class}: #{self::NAMETYPE}"
303
- end
304
- ret
305
- end
306
- end
307
- end # module LeafMixin
308
-
309
- IDL::AST::Leaf.class_eval do
310
- include LeafMixin
311
- end
312
-
313
- module ScannerMixin
314
-
315
- RUBYKW = [
316
- '__FILE__', 'and', 'def', 'end', 'in', 'or', 'self', 'unless',
317
- '__LINE__', 'begin', 'defined?', 'ensure', 'module', 'redo', 'super', 'until',
318
- 'BEGIN', 'break', 'do', 'false', 'next', 'rescue', 'then', 'when',
319
- 'END', 'case', 'else', 'for', 'nil', 'retry', 'true', 'while',
320
- 'alias', 'class', 'elsif', 'if', 'not', 'return', 'undef', 'yield',
321
- ].collect! { |w| w.to_sym }
322
-
323
- def chk_identifier(ident)
324
- # prefix Ruby keywords with 'r_'
325
- RUBYKW.include?(ident.to_sym) ? 'r_'+ident : ident
326
- end
327
-
328
- end # module ScannerMixin
329
-
330
- IDL::Scanner.class_eval do
331
- include ScannerMixin
332
- end
333
-
334
- end # module Ruby
335
-
336
- end # module IDL
1
+ #--------------------------------------------------------------------
2
+ # config.rb - IDL language mapping configuration for Ruby
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 R2CORBA LICENSE which is
8
+ # included with this program.
9
+ #
10
+ # Copyright (c) Remedy IT Expertise BV
11
+ # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
+ #--------------------------------------------------------------------
13
+
14
+ module IDL
15
+
16
+ class StrOStream
17
+ def initialize()
18
+ @str = ""
19
+ end
20
+ def clear
21
+ @str = ""
22
+ end
23
+ def to_s
24
+ @str
25
+ end
26
+ def <<(s)
27
+ @str << s
28
+ end
29
+ end # class StrOStream
30
+
31
+ class RIDL
32
+ private
33
+ def RIDL.merge_params(params)
34
+ opts = IDL::OPTIONS.dup
35
+ params.each do |k,v|
36
+ case opts[k]
37
+ when Array
38
+ opts[k] = opts[k] + (Array === v ? v : [v])
39
+ when Hash
40
+ opts[k] = opts[k].merge(v) if Hash === v
41
+ else
42
+ opts[k] = v
43
+ end
44
+ end
45
+ opts
46
+ end
47
+ def RIDL.parse0(src, params)
48
+ params = merge_params(params)
49
+ IDL.verbose_level = params[:verbose]
50
+ parser = ::IDL::Parser.new(params)
51
+ parser.parse(src)
52
+ s = ::IDL::StrOStream.new
53
+ s.clear
54
+ IDL::Ruby.process_input(parser,params,s)
55
+ s
56
+ end
57
+ def RIDL.parse(src, params)
58
+ s = parse0(src, params)
59
+ s.to_s
60
+ end
61
+ public
62
+ def RIDL.eval(src, params={})
63
+ params[:idl_eval] = true
64
+ params[:expand_includes] = true
65
+ params[:client_stubs] = true if params[:client_stubs].nil?
66
+ params[:stubs_only] ||= false
67
+ s = parse0(src, params)
68
+ Kernel.eval(s.to_s, ::TOPLEVEL_BINDING)
69
+ s = nil
70
+ end
71
+ def RIDL.fparse(fname, params = {})
72
+ params[:client_stubs] = true if params[:client_stubs].nil?
73
+ params[:stubs_only] ||= false
74
+ f = File.open(fname, "r")
75
+ self.parse(f, params)
76
+ ensure
77
+ f.close
78
+ end
79
+ def RIDL.feval(fname, params = {})
80
+ File.open(fname, "r") { |io| self.eval(io, params) }
81
+ end
82
+ end # module RIDL
83
+
84
+ module Ruby
85
+ COPYRIGHT = "Copyright (c) 2007-#{Time.now.year} Remedy IT Expertise BV, The Netherlands".freeze
86
+ TITLE = 'RIDL Ruby backend'.freeze
87
+ VERSION = {
88
+ :major => 2,
89
+ :minor => 0,
90
+ :release => 1
91
+ }
92
+
93
+ ## Configure Ruby backend
94
+ #
95
+ Backend.configure('ruby', File.dirname(__FILE__), TITLE, COPYRIGHT, VERSION) do |becfg|
96
+
97
+ # setup backend option handling
98
+ #
99
+ becfg.on_setup do |optlist, ridl_params|
100
+ # defaults
101
+ ridl_params[:stub_pfx] = 'C'
102
+ ridl_params[:srv_pfx] = 'S'
103
+ ridl_params[:stubs_only] = false
104
+ ridl_params[:client_stubs] = true
105
+ ridl_params[:expand_includes] = false
106
+ ridl_params[:libinit] = true
107
+ ridl_params[:class_interfaces] = []
108
+
109
+ # ruby specific option switches
110
+
111
+ unless ridl_params[:preprocess] # same switch defined for IDL preprocessing mode
112
+ optlist.for_switch "--output=FILE", :type => String,
113
+ :description => ['Specifies filename to generate output in.',
114
+ 'Default: File.basename(idlfile, \'.idl\')+<postfix>+<ext>'] do |swcfg|
115
+ swcfg.on_exec do |arg, params|
116
+ params[:output] = arg
117
+ end
118
+
119
+ end
120
+ end
121
+
122
+ optlist.for_switch '-o PATH', :type => String,
123
+ :description => ["Specifies output directory.",
124
+ "Default: ./"] do |swcfg|
125
+ swcfg.on_exec do |arg, params|
126
+ params[:outputdir] = arg
127
+ end
128
+ end
129
+ optlist.for_switch '--stubs-only',
130
+ :description => ["Only generate client stubs, no servant code.",
131
+ "Default: off"] do |swcfg|
132
+ swcfg.on_exec do |arg, params|
133
+ params[:client_stubs] = true
134
+ params[:stubs_only] = true
135
+ end
136
+ end
137
+ optlist.for_switch '--no-stubs',
138
+ :description => ["Do not generate client stubs, only servant code.",
139
+ "Default: off"] do |swcfg|
140
+ swcfg.on_exec do |arg, params|
141
+ params[:client_stubs] = false
142
+ params[:stubs_only] = false
143
+ end
144
+ end
145
+ optlist.for_switch '--stub-pfx=POSTFIX', :type => String,
146
+ :description => ['Specifies postfix for generated client stub source filename.',
147
+ 'Filenames are formed like: <idl basename><postfix>.<language extension>',
148
+ "Default: #{ridl_params[:stub_pfx]}"] do |swcfg|
149
+ swcfg.on_exec do |arg, params|
150
+ params[:stub_pfx] = arg
151
+ end
152
+ end
153
+ optlist.for_switch '--skel-pfx=POSTFIX', :type => String,
154
+ :description => ['Specifies postfix for generated servant skeleton source filename.',
155
+ 'Filenames are formed like: <idl basename><postfix>.<language extension>',
156
+ "Default: #{ridl_params[:srv_pfx]}"] do |swcfg|
157
+ swcfg.on_exec do |arg, params|
158
+ params[:srv_pfx] = arg
159
+ end
160
+ end
161
+
162
+ optlist.for_switch '--skel-directory=PATH', :type => String,
163
+ :description => ["Specifies output directory for servant files.",
164
+ "Default: outputdir or ./"] do |swcfg|
165
+ swcfg.on_exec do |arg, params|
166
+ params[:skel_outputdir] = arg
167
+ end
168
+ end
169
+ optlist.for_switch '--expand-includes',
170
+ :description => ["Generate code for included IDL inline.",
171
+ "Default: off"] do |swcfg|
172
+ swcfg.on_exec do |arg, params|
173
+ params[:expand_includes] = true
174
+ end
175
+ end
176
+ optlist.for_switch '--no-libinit',
177
+ :description => ["Do not generate library initialization code as preamble.",
178
+ "Default: on"] do |swcfg|
179
+ swcfg.on_exec do |arg, params|
180
+ params[:libinit] = false
181
+ end
182
+ end
183
+ optlist.for_switch '--interface-as-class=INTF', :type => String,
184
+ :description => ["Generate a Ruby class for interface INTF instead of a module in client stubs.",
185
+ "Default: module"] do |swcfg|
186
+ swcfg.on_exec do |arg, params|
187
+ params[:class_interfaces] << arg
188
+ end
189
+ end
190
+ end
191
+
192
+ # process input / generate code
193
+ # arguments:
194
+ # in parser - parser object with full AST from parsed source
195
+ # in options - initialized option hash
196
+ #
197
+ becfg.on_process_input do |parser, options|
198
+ IDL::Ruby.process_input(parser,options)
199
+ end # becfg.on_process_input
200
+
201
+ end # Backend.configure
202
+
203
+ def self.process_input(parser, options, outstream = nil)
204
+ # has a user defined output filename been set
205
+ fixed_output = !options[:output].nil?
206
+
207
+ # determine output file path for client stub code
208
+ unless fixed_output || options[:idlfile].nil?
209
+ options[:output] = options[:outputdir]+'/'+File.basename(options[:idlfile], '.idl')+options[:stub_pfx]+'.rb'
210
+ end
211
+ # generate client stubs if requested
212
+ if options[:client_stubs]
213
+ # open output file
214
+ co = outstream || (if options[:output].nil?
215
+ GenFile.new(nil, :output_file => $stdout)
216
+ else
217
+ GenFile.new(options[:output])
218
+ end)
219
+ begin
220
+ # process StubWriter
221
+ parser.visit_nodes(::IDL::RubyStubWriter.new(co, options))
222
+ rescue => ex
223
+ IDL.log(0, ex)
224
+ IDL.log(0, ex.backtrace.join("\n")) unless ex.is_a? IDL::ParseError
225
+ exit 1
226
+ end
227
+ end
228
+
229
+ # determin output file path for servant code and open file
230
+ unless options[:stubs_only]
231
+ so = outstream || (unless fixed_output || options[:idlfile].nil?
232
+ options[:srv_output] = if fixed_output
233
+ options[:output]
234
+ else
235
+ options[:outputdir]+'/'+File.basename(options[:idlfile], '.idl')+options[:srv_pfx]+'.rb'
236
+ end
237
+ if fixed_output && options[:client_stubs]
238
+ co
239
+ else
240
+ GenFile.new(options[:srv_output])
241
+ end
242
+ else
243
+ GenFile.new(nil, :output_file => $stdout)
244
+ end)
245
+ begin
246
+ # process ServantWriter
247
+ parser.visit_nodes(::IDL::RubyServantWriter.new(so, options))
248
+ rescue => ex
249
+ IDL.log(0, ex)
250
+ IDL.log(0, ex.backtrace.join("\n")) unless ex.is_a? IDL::ParseError
251
+ exit 1
252
+ end
253
+ end
254
+ end
255
+
256
+ module LeafMixin
257
+
258
+ RESERVED_RUBY_CONST = [
259
+ 'Array', 'Bignum', 'Binding', 'Class', 'Continuation', 'Dir', 'Exception',
260
+ 'FalseClass', 'File', 'Fixnum', 'Float', 'Hash', 'Integer', 'IO', 'MatchData',
261
+ 'Method', 'Module', 'NilClass', 'Numeric', 'Object', 'Proc', 'Process', 'Range',
262
+ 'Regexp', 'String', 'Struct', 'Symbol', 'Thread', 'ThreadGroup', 'Time', 'TrueClass',
263
+ 'UnboundMethod', 'Comparable', 'Enumerable', 'Errno', 'FileTest', 'GC', 'Kernel',
264
+ 'Marshal', 'Math', 'ObjectSpace', 'Signal'
265
+ ]
266
+
267
+ RESERVED_RUBY_MEMBER = [
268
+ "untaint", "id", "instance_variable_get", "inspect", "taint", "public_methods", "__send__", "to_a", "display", "instance_eval",
269
+ "extend", "clone", "protected_methods", "hash", "freeze", "type", "instance_variable_set", "methods", "instance_variables", "to_s", "method", "dup",
270
+ "private_methods", "object_id", "send", "__id__", "singleton_methods",
271
+ "proc", "readline", "global_variables", "singleton_method_removed", "callcc", "syscall", "fail", "untrace_var", "load", "srand", "puts", "catch", "chomp",
272
+ "initialize_copy", "format", "scan", "print", "abort", "fork", "gsub", "trap", "test", "select", "initialize", "method_missing", "lambda", "readlines",
273
+ "local_variables", "singleton_method_undefined", "system", "open", "caller", "eval", "set_trace_func", "require", "rand", "singleton_method_added",
274
+ "throw", "gets", "binding", "raise", "warn", "getc", "exec", "trace_var", "irb_binding", "at_exit", "split", "putc", "loop", "chop", "sprintf", "p",
275
+ "remove_instance_variable", "exit", "printf", "sleep", "sub", "autoload"
276
+ ]
277
+
278
+ def self.included(klass)
279
+ klass.extend ClassMethods
280
+ end
281
+
282
+ def rubyname
283
+ lm_name
284
+ end
285
+
286
+ def scoped_rubyname
287
+ scoped_lm_name
288
+ end
289
+
290
+ module ClassMethods
291
+ def mk_name(nm, is_scoped)
292
+ ret = nm.dup
293
+ case self::NAMETYPE
294
+ when :class
295
+ ret = ret[0,1].upcase + ret[1,ret.size].to_s
296
+ ret = 'R_'+ret if !is_scoped && IDL::Ruby::LeafMixin::RESERVED_RUBY_CONST.include?(ret)
297
+ when :member
298
+ ret = ret[0,1].downcase + ret[1,ret.size].to_s
299
+ ret = 'r_'+ret if IDL::Ruby::LeafMixin::RESERVED_RUBY_MEMBER.include?(ret)
300
+ else
301
+ raise RuntimeError,
302
+ "invalid nametype for #{self.class}: #{self::NAMETYPE}"
303
+ end
304
+ ret
305
+ end
306
+ end
307
+ end # module LeafMixin
308
+
309
+ IDL::AST::Leaf.class_eval do
310
+ include LeafMixin
311
+ end
312
+
313
+ module ScannerMixin
314
+
315
+ RUBYKW = [
316
+ '__FILE__', 'and', 'def', 'end', 'in', 'or', 'self', 'unless',
317
+ '__LINE__', 'begin', 'defined?', 'ensure', 'module', 'redo', 'super', 'until',
318
+ 'BEGIN', 'break', 'do', 'false', 'next', 'rescue', 'then', 'when',
319
+ 'END', 'case', 'else', 'for', 'nil', 'retry', 'true', 'while',
320
+ 'alias', 'class', 'elsif', 'if', 'not', 'return', 'undef', 'yield',
321
+ ].collect! { |w| w.to_sym }
322
+
323
+ def chk_identifier(ident)
324
+ # prefix Ruby keywords with 'r_'
325
+ RUBYKW.include?(ident.to_sym) ? 'r_'+ident : ident
326
+ end
327
+
328
+ end # module ScannerMixin
329
+
330
+ IDL::Scanner.class_eval do
331
+ include ScannerMixin
332
+ end
333
+
334
+ end # module Ruby
335
+
336
+ end # module IDL