r2corba 1.4.1

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 -0
  2. data/CHANGES +159 -0
  3. data/LICENSE +59 -0
  4. data/README +62 -0
  5. data/THANKS +52 -0
  6. data/bin/r2corba +8 -0
  7. data/bin/ridlc +11 -0
  8. data/bin/rins +7 -0
  9. data/ext/ext.mwc +6 -0
  10. data/ext/extload/extload.c +60 -0
  11. data/ext/libr2tao/any.cpp +1543 -0
  12. data/ext/libr2tao/exception.cpp +202 -0
  13. data/ext/libr2tao/exception.h +104 -0
  14. data/ext/libr2tao/longdouble.cpp +173 -0
  15. data/ext/libr2tao/longdouble.h +31 -0
  16. data/ext/libr2tao/object.cpp +1150 -0
  17. data/ext/libr2tao/object.h +38 -0
  18. data/ext/libr2tao/orb.cpp +1029 -0
  19. data/ext/libr2tao/orb.h +36 -0
  20. data/ext/libr2tao/r2tao_export.h +45 -0
  21. data/ext/libr2tao/r2tao_ext.h +38 -0
  22. data/ext/libr2tao/required.cpp +463 -0
  23. data/ext/libr2tao/required.h +187 -0
  24. data/ext/libr2tao/typecode.cpp +888 -0
  25. data/ext/libr2tao/typecode.h +45 -0
  26. data/ext/libr2tao/values.cpp +2938 -0
  27. data/ext/libr2tao/values.h +396 -0
  28. data/ext/librpoa/iortable.cpp +250 -0
  29. data/ext/librpoa/poa.cpp +1076 -0
  30. data/ext/librpoa/poa.h +24 -0
  31. data/ext/librpoa/rpoa_export.h +44 -0
  32. data/ext/librpoa/servant.cpp +1338 -0
  33. data/ext/librpoa/servant.h +116 -0
  34. data/ext/librpoa/srvreq_fix.cpp +283 -0
  35. data/ext/librpoa/srvreq_fix.h +149 -0
  36. data/ext/librpol/policies.cpp +763 -0
  37. data/ext/librpol/policies.h +15 -0
  38. data/ext/librpol/rpol_export.h +44 -0
  39. data/lib/corba/cbase/IORMap.rb +33 -0
  40. data/lib/corba/cbase/ORB.rb +231 -0
  41. data/lib/corba/cbase/Request.rb +134 -0
  42. data/lib/corba/cbase/Streams.rb +129 -0
  43. data/lib/corba/cbase/Stub.rb +19 -0
  44. data/lib/corba/cbase/Typecode.rb +441 -0
  45. data/lib/corba/cbase/Values.rb +129 -0
  46. data/lib/corba/cbase/exception.rb +66 -0
  47. data/lib/corba/cbase/poa.rb +23 -0
  48. data/lib/corba/cbase/policies.rb +78 -0
  49. data/lib/corba/cbase/post_require.rb +14 -0
  50. data/lib/corba/cbase/require.rb +28 -0
  51. data/lib/corba/cmds/base.rb +85 -0
  52. data/lib/corba/cmds/test.rb +30 -0
  53. data/lib/corba/common/Any.rb +91 -0
  54. data/lib/corba/common/IDL.rb +104 -0
  55. data/lib/corba/common/ORB.rb +368 -0
  56. data/lib/corba/common/Object.rb +208 -0
  57. data/lib/corba/common/Request.rb +20 -0
  58. data/lib/corba/common/Servant.rb +108 -0
  59. data/lib/corba/common/Struct.rb +22 -0
  60. data/lib/corba/common/Stub.rb +79 -0
  61. data/lib/corba/common/Typecode.rb +1121 -0
  62. data/lib/corba/common/Union.rb +56 -0
  63. data/lib/corba/common/Values.rb +92 -0
  64. data/lib/corba/common/const.rb +22 -0
  65. data/lib/corba/common/exception.rb +68 -0
  66. data/lib/corba/common/require.rb +27 -0
  67. data/lib/corba/common/version.rb +22 -0
  68. data/lib/corba/idl/IDL.rb +21 -0
  69. data/lib/corba/idl/IORTable.pidl +62 -0
  70. data/lib/corba/idl/TAO_Ext.pidl +46 -0
  71. data/lib/corba/idl/require.rb +20 -0
  72. data/lib/corba/jbase/Any.rb +273 -0
  73. data/lib/corba/jbase/IORMap.rb +36 -0
  74. data/lib/corba/jbase/ORB.rb +99 -0
  75. data/lib/corba/jbase/Object.rb +98 -0
  76. data/lib/corba/jbase/Request.rb +226 -0
  77. data/lib/corba/jbase/Servant.rb +247 -0
  78. data/lib/corba/jbase/ServerRequest.rb +128 -0
  79. data/lib/corba/jbase/Streams.rb +671 -0
  80. data/lib/corba/jbase/Stub.rb +38 -0
  81. data/lib/corba/jbase/Typecode.rb +520 -0
  82. data/lib/corba/jbase/Values.rb +173 -0
  83. data/lib/corba/jbase/exception.rb +106 -0
  84. data/lib/corba/jbase/poa.rb +229 -0
  85. data/lib/corba/jbase/policies.rb +300 -0
  86. data/lib/corba/jbase/post_require.rb +14 -0
  87. data/lib/corba/jbase/require.rb +86 -0
  88. data/lib/corba/naming.rb +14 -0
  89. data/lib/corba/naming_service.rb +15 -0
  90. data/lib/corba/poa.rb +15 -0
  91. data/lib/corba/policies.rb +18 -0
  92. data/lib/corba/require.rb +17 -0
  93. data/lib/corba/svcs/ins/cos_naming.rb +426 -0
  94. data/lib/corba/svcs/ins/ins.rb +526 -0
  95. data/lib/corba/svcs/ins/naming_service.rb +119 -0
  96. data/lib/corba.rb +16 -0
  97. data/lib/ridlbe/ruby/config.rb +336 -0
  98. data/lib/ridlbe/ruby/require.rb +16 -0
  99. data/lib/ridlbe/ruby/walker.rb +1582 -0
  100. data/mkrf_conf_srcgem.rb +186 -0
  101. data/rakelib/bin.rake +80 -0
  102. data/rakelib/bin.rb +146 -0
  103. data/rakelib/build.rake +87 -0
  104. data/rakelib/config.rake +52 -0
  105. data/rakelib/config.rb +450 -0
  106. data/rakelib/ext.rake +242 -0
  107. data/rakelib/ext.rb +308 -0
  108. data/rakelib/ext_r2tao.rb +232 -0
  109. data/rakelib/gem.rake +212 -0
  110. data/rakelib/gem.rb +146 -0
  111. data/rakelib/package.rake +26 -0
  112. data/rakelib/test.rake +23 -0
  113. data/test/BiDirectional/Test.idl +34 -0
  114. data/test/BiDirectional/client.rb +132 -0
  115. data/test/BiDirectional/run_test.rb +68 -0
  116. data/test/BiDirectional/server.rb +169 -0
  117. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
  118. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
  119. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
  120. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
  121. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
  122. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
  123. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
  124. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
  125. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
  126. data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
  127. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
  128. data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
  129. data/test/Collocation/Diamond.idl +39 -0
  130. data/test/Collocation/run_test.rb +52 -0
  131. data/test/Collocation/test.rb +195 -0
  132. data/test/Connect_Timeout/Test.idl +27 -0
  133. data/test/Connect_Timeout/client.rb +111 -0
  134. data/test/Connect_Timeout/run_test.rb +52 -0
  135. data/test/DII/Test.idl +27 -0
  136. data/test/DII/client.rb +115 -0
  137. data/test/DII/run_test.rb +69 -0
  138. data/test/DII/server.rb +95 -0
  139. data/test/DSI/Test.idl +27 -0
  140. data/test/DSI/client.rb +66 -0
  141. data/test/DSI/run_test.rb +69 -0
  142. data/test/DSI/server.rb +106 -0
  143. data/test/Exceptions/Test.idl +48 -0
  144. data/test/Exceptions/client.rb +118 -0
  145. data/test/Exceptions/run_test.rb +69 -0
  146. data/test/Exceptions/server.rb +131 -0
  147. data/test/Hello/Test.idl +27 -0
  148. data/test/Hello/client.rb +78 -0
  149. data/test/Hello/run_test.rb +71 -0
  150. data/test/Hello/server.rb +95 -0
  151. data/test/IDL_Test/Test.idl +113 -0
  152. data/test/IDL_Test/Test_inc.idl +17 -0
  153. data/test/IDL_Test/client.rb +102 -0
  154. data/test/IDL_Test/run_test.rb +69 -0
  155. data/test/IDL_Test/server.rb +99 -0
  156. data/test/IORMap/Test.idl +27 -0
  157. data/test/IORMap/client.rb +73 -0
  158. data/test/IORMap/run_test.rb +69 -0
  159. data/test/IORMap/server.rb +114 -0
  160. data/test/IORTable/Test.idl +27 -0
  161. data/test/IORTable/client.rb +75 -0
  162. data/test/IORTable/run_test.rb +69 -0
  163. data/test/IORTable/server.rb +130 -0
  164. data/test/Implicit_Conversion/Test.idl +31 -0
  165. data/test/Implicit_Conversion/client.rb +110 -0
  166. data/test/Implicit_Conversion/run_test.rb +69 -0
  167. data/test/Implicit_Conversion/server.rb +99 -0
  168. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
  169. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
  170. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
  171. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
  172. data/test/Multi_Threading/Simple/Test.idl +27 -0
  173. data/test/Multi_Threading/Simple/client.rb +88 -0
  174. data/test/Multi_Threading/Simple/run_test.rb +69 -0
  175. data/test/Multi_Threading/Simple/server.rb +118 -0
  176. data/test/Multi_Threading/Threads/Test.idl +31 -0
  177. data/test/Multi_Threading/Threads/client.rb +80 -0
  178. data/test/Multi_Threading/Threads/run_test.rb +76 -0
  179. data/test/Multi_Threading/Threads/server.rb +119 -0
  180. data/test/Multi_Threading/Threads/watchdog.rb +87 -0
  181. data/test/Multiple_Servant_Interfaces/Test.idl +34 -0
  182. data/test/Multiple_Servant_Interfaces/client.rb +70 -0
  183. data/test/Multiple_Servant_Interfaces/run_test.rb +69 -0
  184. data/test/Multiple_Servant_Interfaces/server.rb +102 -0
  185. data/test/Nil/Test.idl +27 -0
  186. data/test/Nil/run_test.rb +52 -0
  187. data/test/Nil/test.rb +78 -0
  188. data/test/OBV/AbstractInterface/client.rb +179 -0
  189. data/test/OBV/AbstractInterface/run_test.rb +69 -0
  190. data/test/OBV/AbstractInterface/server.rb +149 -0
  191. data/test/OBV/AbstractInterface/test.idl +53 -0
  192. data/test/OBV/Custom/OBV.idl +18 -0
  193. data/test/OBV/Custom/OBV_impl.rb +40 -0
  194. data/test/OBV/Custom/client.rb +86 -0
  195. data/test/OBV/Custom/run_test.rb +69 -0
  196. data/test/OBV/Custom/server.rb +100 -0
  197. data/test/OBV/Simple/OBV.idl +15 -0
  198. data/test/OBV/Simple/OBV_impl.rb +26 -0
  199. data/test/OBV/Simple/client.rb +86 -0
  200. data/test/OBV/Simple/run_test.rb +69 -0
  201. data/test/OBV/Simple/server.rb +100 -0
  202. data/test/OBV/Simple_Event/Event.idl +15 -0
  203. data/test/OBV/Simple_Event/Event_impl.rb +26 -0
  204. data/test/OBV/Simple_Event/client.rb +86 -0
  205. data/test/OBV/Simple_Event/run_test.rb +69 -0
  206. data/test/OBV/Simple_Event/server.rb +100 -0
  207. data/test/OBV/Supports/client.rb +116 -0
  208. data/test/OBV/Supports/run_test.rb +69 -0
  209. data/test/OBV/Supports/server.rb +103 -0
  210. data/test/OBV/Supports/supports.idl +33 -0
  211. data/test/OBV/Supports/supports_impl.rb +57 -0
  212. data/test/OBV/Tree/client.rb +116 -0
  213. data/test/OBV/Tree/run_test.rb +69 -0
  214. data/test/OBV/Tree/server.rb +117 -0
  215. data/test/OBV/Tree/test.idl +32 -0
  216. data/test/OBV/Truncatable/Extra.idl +27 -0
  217. data/test/OBV/Truncatable/Truncatable.idl +105 -0
  218. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
  219. data/test/OBV/Truncatable/client.rb +279 -0
  220. data/test/OBV/Truncatable/run_test.rb +69 -0
  221. data/test/OBV/Truncatable/server.rb +89 -0
  222. data/test/OBV/ValueBox/client.rb +497 -0
  223. data/test/OBV/ValueBox/run_test.rb +69 -0
  224. data/test/OBV/ValueBox/server.rb +271 -0
  225. data/test/OBV/ValueBox/valuebox.idl +101 -0
  226. data/test/OBV/ValueBox/vb_basic.idl +75 -0
  227. data/test/OBV/ValueBox/vb_struct.idl +68 -0
  228. data/test/OBV/ValueBox/vb_union.idl +21 -0
  229. data/test/Object/Test.idl +27 -0
  230. data/test/Object/client.rb +103 -0
  231. data/test/Object/run_test.rb +69 -0
  232. data/test/Object/server.rb +126 -0
  233. data/test/POA/Test.idl +27 -0
  234. data/test/POA/run_test.rb +52 -0
  235. data/test/POA/test.rb +112 -0
  236. data/test/Param_Test/Test.idl +182 -0
  237. data/test/Param_Test/client.rb +277 -0
  238. data/test/Param_Test/run_test.rb +69 -0
  239. data/test/Param_Test/server.rb +296 -0
  240. data/test/Performance/Simple/Test.idl +27 -0
  241. data/test/Performance/Simple/client.rb +90 -0
  242. data/test/Performance/Simple/run_test.rb +69 -0
  243. data/test/Performance/Simple/server.rb +95 -0
  244. data/test/Policies/Test.idl +27 -0
  245. data/test/Policies/run_test.rb +52 -0
  246. data/test/Policies/test.rb +144 -0
  247. data/test/Timeout/client.rb +207 -0
  248. data/test/Timeout/run_test.rb +69 -0
  249. data/test/Timeout/server.rb +109 -0
  250. data/test/Timeout/test.idl +19 -0
  251. data/test/lib/assert.rb +43 -0
  252. data/test/lib/test.rb +542 -0
  253. data/test/test_runner.rb +193 -0
  254. metadata +334 -0
@@ -0,0 +1,1150 @@
1
+ /*--------------------------------------------------------------------
2
+ # object.cpp - R2TAO CORBA Object support
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
+ #include "required.h"
15
+ #include "tao/DynamicInterface/Request.h"
16
+ #include "tao/DynamicInterface/DII_CORBA_methods.h"
17
+ #include "tao/DynamicInterface/Unknown_User_Exception.h"
18
+ #include "ace/Truncate.h"
19
+ #include "typecode.h"
20
+ #include "object.h"
21
+ #include "exception.h"
22
+ #include "orb.h"
23
+
24
+ R2TAO_EXPORT VALUE r2corba_cObject = 0;
25
+ R2TAO_EXPORT VALUE r2tao_cObject = 0;
26
+ static VALUE r2tao_cStub;
27
+ static VALUE r2tao_cRequest;
28
+ static VALUE r2corba_nsRequest;
29
+
30
+ VALUE r2tao_Object_orb(VALUE self);
31
+ VALUE r2tao_Object_object_id(VALUE self);
32
+
33
+ static int r2tao_IN_ARG;
34
+ static int r2tao_INOUT_ARG;
35
+ static int r2tao_OUT_ARG;
36
+
37
+ static VALUE ID_arg_list;
38
+ static VALUE ID_result_type;
39
+ static VALUE ID_exc_list;
40
+
41
+ static ID wrap_native_ID;
42
+ static ID objref_ID;
43
+
44
+ VALUE rCORBA_Object_is_a(VALUE self, VALUE type_id);
45
+ VALUE rCORBA_Object_get_interface(VALUE self);
46
+ VALUE rCORBA_Object_get_component(VALUE self);
47
+ VALUE rCORBA_Object_is_nil(VALUE self);
48
+ //VALUE rCORBA_Object_free_ref(VALUE self);
49
+ VALUE rCORBA_Object_duplicate(VALUE self);
50
+ VALUE rCORBA_Object_release(VALUE self);
51
+ VALUE rCORBA_Object_non_existent(VALUE self);
52
+ VALUE rCORBA_Object_is_equivalent(VALUE self, VALUE other);
53
+ VALUE rCORBA_Object_hash(VALUE self, VALUE max);
54
+ VALUE rCORBA_Object_get_policy(VALUE self, VALUE policy_type);
55
+ VALUE rCORBA_Object_repository_id(VALUE self);
56
+ VALUE rCORBA_Object_release(VALUE self);
57
+
58
+ VALUE ri_CORBA_Object_equal(VALUE self, VALUE that);
59
+ VALUE ri_CORBA_Object_hash(VALUE self);
60
+
61
+ VALUE rCORBA_Object_request(VALUE self, VALUE op);
62
+
63
+ VALUE rCORBA_Stub_invoke(int _argc, VALUE *_argv, VALUE self);
64
+
65
+ VALUE rCORBA_Request_target(VALUE self);
66
+ VALUE rCORBA_Request_operation(VALUE self);
67
+ VALUE rCORBA_Request_arguments(VALUE self, VALUE arg_list);
68
+ VALUE rCORBA_Request_return_value(VALUE self, VALUE result_type);
69
+ VALUE rCORBA_Request_invoke(int _argc, VALUE *_argv, VALUE self);
70
+ VALUE rCORBA_Request_send_oneway(VALUE self, VALUE arg_list);
71
+ VALUE rCORBA_Request_send_deferred(int _argc, VALUE *_argv, VALUE self);
72
+ VALUE rCORBA_Request_get_response(VALUE self);
73
+ VALUE rCORBA_Request_poll_response(VALUE self);
74
+
75
+ static void _object_free(void *ptr);
76
+
77
+ void
78
+ r2tao_Init_Object()
79
+ {
80
+ VALUE klass;
81
+ //VALUE nsCORBA_PortableStub;
82
+
83
+ if (r2tao_cObject) return;
84
+
85
+ ID_arg_list = rb_eval_string (":arg_list");
86
+ ID_result_type = rb_eval_string (":result_type");
87
+ ID_exc_list = rb_eval_string (":exc_list");
88
+
89
+ wrap_native_ID = rb_intern ("_wrap_native");
90
+ objref_ID = rb_intern ("objref_");
91
+
92
+ // CORBA::Object
93
+ r2corba_cObject = rb_eval_string ("::R2CORBA::CORBA::Object");
94
+ // CORBA::Native::Object
95
+ klass = r2tao_cObject =
96
+ rb_define_class_under(r2tao_nsCORBA_Native, "Object", rb_cObject);
97
+
98
+ rb_define_method(klass, "_is_a", RUBY_METHOD_FUNC(rCORBA_Object_is_a), 1);
99
+ rb_define_method(klass, "_get_interface", RUBY_METHOD_FUNC(rCORBA_Object_get_interface), 0);
100
+ rb_define_method(klass, "_get_component", RUBY_METHOD_FUNC(rCORBA_Object_get_component), 0);
101
+ rb_define_method(klass, "_repository_id", RUBY_METHOD_FUNC(rCORBA_Object_repository_id), 0);
102
+ rb_define_method(klass, "_is_nil", RUBY_METHOD_FUNC(rCORBA_Object_is_nil), 0);
103
+ //rb_define_method(klass, "_free_ref", RUBY_METHOD_FUNC(rCORBA_Object_free_ref), 0);
104
+ rb_define_method(klass, "_duplicate", RUBY_METHOD_FUNC(rCORBA_Object_duplicate), 0);
105
+ rb_define_method(klass, "_release", RUBY_METHOD_FUNC(rCORBA_Object_release), 0);
106
+ rb_define_method(klass, "_non_existent", RUBY_METHOD_FUNC(rCORBA_Object_non_existent), 0);
107
+ rb_define_method(klass, "_is_equivalent", RUBY_METHOD_FUNC(rCORBA_Object_is_equivalent), 1);
108
+ rb_define_method(klass, "_hash", RUBY_METHOD_FUNC(rCORBA_Object_hash), 1);
109
+ rb_define_method(klass, "_get_policy", RUBY_METHOD_FUNC(rCORBA_Object_get_policy), 1);
110
+ rb_define_method(klass, "_get_orb", RUBY_METHOD_FUNC(r2tao_Object_orb), 0);
111
+ rb_define_method(klass, "_orb", RUBY_METHOD_FUNC(r2tao_Object_orb), 0);
112
+ rb_define_method(klass, "_request", RUBY_METHOD_FUNC(rCORBA_Object_request), 1);
113
+
114
+ rb_define_method(klass, "==", RUBY_METHOD_FUNC(ri_CORBA_Object_equal), 1);
115
+ rb_define_method(klass, "eql?", RUBY_METHOD_FUNC(ri_CORBA_Object_equal), 1);
116
+ rb_define_method(klass, "hash", RUBY_METHOD_FUNC(ri_CORBA_Object_hash), 0);
117
+
118
+ // CORBA::Stub
119
+
120
+ klass = r2tao_cStub = rb_define_module_under (r2tao_nsCORBA, "Stub");
121
+ // R2TAO::CORBA::Stub._invoke(opname, arg_list, result_type = nil)
122
+ // . arg_list = Array of Array-s containing name, argtype, tc [, value] for each arg
123
+ // . result_type = typecode; if result_type == nil => oneway call
124
+ // -> returns [ <return value>, <out arg1>, ..., <out argn> ] or nil (oneway) or throws exception
125
+ rb_define_protected_method(klass, "_invoke", RUBY_METHOD_FUNC(rCORBA_Stub_invoke), -1);
126
+
127
+ r2tao_IN_ARG = NUM2INT (rb_eval_string ("R2CORBA::CORBA::ARG_IN"));
128
+ r2tao_INOUT_ARG = NUM2INT (rb_eval_string ("R2CORBA::CORBA::ARG_INOUT"));
129
+ r2tao_OUT_ARG = NUM2INT (rb_eval_string ("R2CORBA::CORBA::ARG_OUT"));
130
+
131
+ // R2CORBA::CORBA::Request
132
+ r2corba_nsRequest = rb_eval_string ("R2CORBA::CORBA::Request");
133
+ // create anonymous class for wrapping CORBA::Request
134
+ klass = r2tao_cRequest = rb_class_new (rb_cObject);
135
+ rb_global_variable (&r2tao_cRequest); // pin it down so GC doesn't get it
136
+ // include the standard module
137
+ rb_include_module (r2tao_cRequest, r2corba_nsRequest);
138
+ // add native methods
139
+ rb_define_method(klass, "target", RUBY_METHOD_FUNC(rCORBA_Request_target), 0);
140
+ rb_define_method(klass, "operation", RUBY_METHOD_FUNC(rCORBA_Request_operation), 0);
141
+
142
+ // R2TAO::CORBA::Request.invoke({:arg_list=>[], :result_type=>, :exc_list=>[]})
143
+ // . arg_list = Array of Array-s containing name, argtype, tc [, value] for each arg
144
+ // . result_type = typecode; if result_type == nil => oneway call
145
+ // -> returns [ <return value>, <out arg1>, ..., <out argn> ] or nil (oneway) or throws exception
146
+ rb_define_protected_method(klass, "_invoke", RUBY_METHOD_FUNC(rCORBA_Request_invoke), -1);
147
+ rb_define_protected_method(klass, "_send_oneway", RUBY_METHOD_FUNC(rCORBA_Request_send_oneway), 1);
148
+ rb_define_protected_method(klass, "_send_deferred", RUBY_METHOD_FUNC(rCORBA_Request_send_deferred), -1);
149
+ rb_define_protected_method(klass, "_get_response", RUBY_METHOD_FUNC(rCORBA_Request_get_response), 0);
150
+ rb_define_protected_method(klass, "_poll_response", RUBY_METHOD_FUNC(rCORBA_Request_poll_response), 0);
151
+ rb_define_protected_method(klass, "_get_arguments", RUBY_METHOD_FUNC(rCORBA_Request_arguments), 1);
152
+ rb_define_protected_method(klass, "_return_value", RUBY_METHOD_FUNC(rCORBA_Request_return_value), 1);
153
+ }
154
+
155
+ //-------------------------------------------------------------------
156
+ // Ruby <-> TAO object conversions
157
+ //
158
+ //===================================================================
159
+
160
+ VALUE
161
+ r2tao_t2r(VALUE klass, CORBA::Object_ptr obj)
162
+ {
163
+ VALUE ret;
164
+ CORBA::Object_ptr o;
165
+
166
+ o = CORBA::Object::_duplicate (obj);
167
+ ret = Data_Wrap_Struct(klass, 0, _object_free, o);
168
+
169
+ return ret;
170
+ }
171
+
172
+ R2TAO_EXPORT VALUE
173
+ r2tao_Object_t2r(CORBA::Object_ptr obj)
174
+ {
175
+ return r2tao_t2r (r2tao_cObject, obj);
176
+ }
177
+
178
+ R2TAO_EXPORT CORBA::Object_ptr
179
+ r2tao_Object_r2t(VALUE obj)
180
+ {
181
+ CORBA::Object_ptr ret;
182
+
183
+ r2tao_check_type (obj, r2tao_cObject);
184
+ Data_Get_Struct(obj, CORBA::Object, ret);
185
+ return ret;
186
+ }
187
+
188
+ R2TAO_EXPORT VALUE
189
+ r2corba_Object_t2r(CORBA::Object_ptr obj)
190
+ {
191
+ VALUE r2tao_obj = r2tao_Object_t2r(obj);
192
+ return rb_funcall (r2corba_cObject, wrap_native_ID, 1, r2tao_obj);
193
+ }
194
+
195
+ R2TAO_EXPORT CORBA::Object_ptr
196
+ r2corba_Object_r2t(VALUE obj)
197
+ {
198
+ r2tao_check_type (obj, r2corba_cObject);
199
+ return r2tao_Object_r2t (rb_funcall (obj, objref_ID, 0));
200
+ }
201
+
202
+ static void
203
+ _object_free(void *ptr)
204
+ {
205
+ CORBA::release (static_cast<CORBA::Object_ptr> (ptr));
206
+ }
207
+
208
+
209
+ static void
210
+ _request_free(void *ptr)
211
+ {
212
+ CORBA::release (static_cast<CORBA::Request_ptr> (ptr));
213
+ }
214
+
215
+ VALUE
216
+ r2tao_Request_t2r(CORBA::Request_ptr req)
217
+ {
218
+ VALUE ret;
219
+ CORBA::Request_ptr o;
220
+
221
+ o = CORBA::Request::_duplicate (req);
222
+ ret = Data_Wrap_Struct(r2tao_cRequest, 0, _request_free, o);
223
+
224
+ return ret;
225
+ }
226
+
227
+ CORBA::Request_ptr
228
+ r2tao_Request_r2t(VALUE obj)
229
+ {
230
+ CORBA::Request_ptr ret;
231
+
232
+ r2tao_check_type(obj, r2tao_cRequest);
233
+ Data_Get_Struct(obj, CORBA::Request, ret);
234
+ return ret;
235
+ }
236
+
237
+ //-------------------------------------------------------------------
238
+ // CORBA::Object methods
239
+ //
240
+ //===================================================================
241
+
242
+ VALUE
243
+ r2tao_Object_orb(VALUE self)
244
+ {
245
+ CORBA::ORB_var orb_ = r2tao_Object_r2t(self)->_get_orb ();
246
+ return r2tao_ORB_t2r(orb_.in ());
247
+ }
248
+
249
+ VALUE
250
+ rCORBA_Object_get_interface(VALUE /*self*/)
251
+ {
252
+ X_CORBA(NO_IMPLEMENT);
253
+ return Qnil;
254
+ }
255
+
256
+ VALUE
257
+ rCORBA_Object_get_component(VALUE self)
258
+ {
259
+ VALUE ret = Qnil;
260
+
261
+ CORBA::Object_ptr obj = r2tao_Object_r2t (self);
262
+
263
+ R2TAO_TRY
264
+ {
265
+ CORBA::Object_var comp = obj->_get_component ();
266
+ ret = r2tao_Object_t2r (comp.in ());
267
+ }
268
+ R2TAO_CATCH;
269
+
270
+ return ret;
271
+ }
272
+
273
+ VALUE
274
+ rCORBA_Object_repository_id(VALUE self)
275
+ {
276
+ VALUE ret = Qnil;
277
+
278
+ CORBA::Object_ptr obj = r2tao_Object_r2t (self);
279
+
280
+ R2TAO_TRY
281
+ {
282
+ ret = rb_str_new2 (obj->_repository_id ());
283
+ }
284
+ R2TAO_CATCH;
285
+
286
+ return ret;
287
+ }
288
+
289
+ VALUE
290
+ rCORBA_Object_is_nil(VALUE self)
291
+ {
292
+ VALUE ret = Qnil;
293
+
294
+ CORBA::Object_ptr obj = r2tao_Object_r2t (self);
295
+
296
+ R2TAO_TRY
297
+ {
298
+ ret = CORBA::is_nil (obj) ? Qtrue: Qfalse;
299
+ }
300
+ R2TAO_CATCH;
301
+
302
+ return ret;
303
+ }
304
+
305
+ /*
306
+ VALUE
307
+ rCORBA_Object_free_ref(VALUE self)
308
+ {
309
+ CORBA::Object_ptr obj = r2tao_Object_r2t (self);
310
+
311
+ R2TAO_TRY
312
+ {
313
+ if (!CORBA::is_nil (obj))
314
+ {
315
+ _object_free (DATA_PTR (self));
316
+ DATA_PTR (self) = CORBA::Object::_nil ();
317
+ }
318
+ }
319
+ R2TAO_CATCH;
320
+
321
+ return self;
322
+ }
323
+ */
324
+
325
+ VALUE
326
+ rCORBA_Object_duplicate(VALUE self)
327
+ {
328
+ VALUE ret = Qnil;
329
+
330
+ R2TAO_TRY
331
+ {
332
+ ret = r2tao_Object_t2r (r2tao_Object_r2t (self));
333
+ }
334
+ R2TAO_CATCH;
335
+
336
+ return ret;
337
+ }
338
+
339
+ VALUE
340
+ rCORBA_Object_release(VALUE self)
341
+ {
342
+ CORBA::Object_ptr obj = r2tao_Object_r2t (self);
343
+
344
+ R2TAO_TRY
345
+ {
346
+ if (!CORBA::is_nil (obj))
347
+ {
348
+ _object_free (DATA_PTR (self));
349
+ DATA_PTR (self) = CORBA::Object::_nil ();
350
+ }
351
+ }
352
+ R2TAO_CATCH;
353
+
354
+ return self;
355
+ }
356
+
357
+ VALUE
358
+ rCORBA_Object_non_existent(VALUE self)
359
+ {
360
+ VALUE ret = Qnil;
361
+
362
+ R2TAO_TRY
363
+ {
364
+ ret = r2tao_Object_r2t (self)->_non_existent () ? Qtrue: Qfalse;
365
+ }
366
+ R2TAO_CATCH;
367
+
368
+ return ret;
369
+ }
370
+
371
+ VALUE
372
+ rCORBA_Object_is_equivalent(VALUE self, VALUE _other)
373
+ {
374
+ CORBA::Object_ptr other, obj;
375
+ VALUE ret = Qnil;
376
+
377
+ obj = r2tao_Object_r2t (self);
378
+ other = r2tao_Object_r2t (_other);
379
+
380
+ R2TAO_TRY
381
+ {
382
+ ret = obj->_is_equivalent (other)? Qtrue: Qfalse;
383
+ }
384
+ R2TAO_CATCH;
385
+
386
+ return ret;
387
+ }
388
+
389
+ VALUE
390
+ rCORBA_Object_hash(VALUE self, VALUE _max)
391
+ {
392
+ CORBA::ULong ret=0, max;
393
+ CORBA::Object_ptr obj = r2tao_Object_r2t (self);
394
+
395
+ max = NUM2ULONG(_max);
396
+ R2TAO_TRY
397
+ {
398
+ ret = obj->_hash(max);
399
+ }
400
+ R2TAO_CATCH;
401
+
402
+ return ULONG2NUM(ret);
403
+ }
404
+
405
+ VALUE
406
+ rCORBA_Object_get_policy(VALUE /*self*/, VALUE /*policy_type*/)
407
+ {
408
+ /* Implemented in policy extension */
409
+ X_CORBA(NO_IMPLEMENT);
410
+ return Qnil;
411
+ }
412
+
413
+ VALUE
414
+ ri_CORBA_Object_equal(VALUE self, VALUE that)
415
+ {
416
+ CORBA::Object_ptr obj1, obj2;
417
+
418
+ r2tao_check_type(that, r2tao_cObject);
419
+
420
+ Data_Get_Struct(self, CORBA::Object, obj1);
421
+ Data_Get_Struct(self, CORBA::Object, obj2);
422
+ return (obj1 == obj2) ? Qtrue : Qfalse;
423
+ }
424
+
425
+ VALUE
426
+ ri_CORBA_Object_hash(VALUE self)
427
+ {
428
+ return ULONG2NUM (ACE_Utils::truncate_cast<unsigned long> ((intptr_t)r2tao_Object_r2t (self)));
429
+ }
430
+
431
+ VALUE
432
+ rCORBA_Object_is_a(VALUE self, VALUE type_id)
433
+ {
434
+ CORBA::Object_ptr obj;
435
+ VALUE ret = Qnil;
436
+
437
+ obj = r2tao_Object_r2t (self);
438
+ Check_Type(type_id, T_STRING);
439
+
440
+ R2TAO_TRY
441
+ {
442
+ int f = obj->_is_a (RSTRING_PTR (type_id));
443
+ //::printf ("rCORBA_Object_is_a: %s -> %d\n", RSTRING_PTR (type_id), f);
444
+ ret = f ? Qtrue: Qfalse;
445
+ }
446
+ R2TAO_CATCH;
447
+
448
+ return ret;
449
+ }
450
+
451
+ VALUE
452
+ rCORBA_Object_request(VALUE self, VALUE op_name)
453
+ {
454
+ CORBA::Object_ptr obj;
455
+ CORBA::Request_var req;
456
+
457
+ obj = r2tao_Object_r2t (self);
458
+ Check_Type(op_name, T_STRING);
459
+
460
+ R2TAO_TRY
461
+ {
462
+ req = obj->_request (RSTRING_PTR (op_name));
463
+ }
464
+ R2TAO_CATCH;
465
+
466
+ return r2tao_Request_t2r (req.in ());
467
+ }
468
+
469
+ //-------------------------------------------------------------------
470
+ // Request invocation helper methods
471
+ //
472
+ //===================================================================
473
+
474
+ static VALUE _r2tao_set_request_arguments(CORBA::Request_ptr _req, VALUE arg_list)
475
+ {
476
+ if (TAO_debug_level > 9)
477
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - set_request_arguments: entry\n"));
478
+
479
+ long ret_val = 0;
480
+
481
+ // clear all current args
482
+ CORBA::ULong arg_num = _req->arguments ()->count ();
483
+ while (arg_num > 0)
484
+ _req->arguments ()->remove (--arg_num);
485
+
486
+ if (!NIL_P (arg_list))
487
+ {
488
+ long arg_len = RARRAY_LEN (arg_list);
489
+ for (long a=0; a<arg_len ;++a)
490
+ {
491
+ VALUE argspec = rb_ary_entry (arg_list, a);
492
+ VALUE argname = rb_ary_entry (argspec, 0);
493
+ int _arg_type = NUM2INT (rb_ary_entry (argspec, 1));
494
+ CORBA::TypeCode_ptr _arg_tc = r2corba_TypeCode_r2t (rb_ary_entry (argspec, 2));
495
+
496
+ if (_arg_type != r2tao_OUT_ARG)
497
+ {
498
+ VALUE arg_val = rb_ary_entry (argspec, 3);
499
+
500
+ char *_arg_name = NIL_P (argname) ? 0 : RSTRING_PTR (argname);
501
+ CORBA::Any& _arg = (_arg_type == r2tao_IN_ARG) ?
502
+ (_arg_name ? _req->add_in_arg (_arg_name) : _req->add_in_arg ()) :
503
+ (_arg_name ? _req->add_inout_arg (_arg_name) : _req->add_inout_arg ());
504
+
505
+ if (_arg_type == r2tao_INOUT_ARG)
506
+ ++ret_val;
507
+
508
+ if (TAO_debug_level > 9)
509
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - set_request_arguments: IN_ARG/INOUT_ARG - arg_name=%s\n",
510
+ _arg_name));
511
+
512
+ // assign value to Any
513
+ r2tao_Ruby2Any(_arg, _arg_tc, arg_val);
514
+ }
515
+ else
516
+ {
517
+ ++ret_val;
518
+ char *_arg_name = NIL_P (argname) ? 0 : RSTRING_PTR (argname);
519
+ CORBA::Any& _arg = _arg_name ?
520
+ _req->add_out_arg (_arg_name) : _req->add_out_arg ();
521
+
522
+ if (TAO_debug_level > 9)
523
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - set_request_arguments: OUT_ARG - arg_name=%s\n",
524
+ _arg_name));
525
+
526
+ // assign type info to Any
527
+ r2tao_Ruby2Any(_arg, _arg_tc, Qnil);
528
+ }
529
+ }
530
+ }
531
+ return LONG2NUM (ret_val);
532
+ }
533
+
534
+ static VALUE _r2tao_set_request_exceptions(CORBA::Request_ptr _req, VALUE exc_list)
535
+ {
536
+ if (TAO_debug_level > 9)
537
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - set_request_exceptions: entry\n"));
538
+
539
+ long exc_len = 0;
540
+ // clear all current excepts
541
+ CORBA::ULong x_num = _req->exceptions ()->count ();
542
+ while (x_num > 0)
543
+ _req->exceptions ()->remove (--x_num);
544
+
545
+ if (!NIL_P (exc_list))
546
+ {
547
+ exc_len = RARRAY_LEN (exc_list);
548
+ for (long x=0; x<exc_len ;++x)
549
+ {
550
+ VALUE exctc = rb_ary_entry (exc_list, x);
551
+ CORBA::TypeCode_ptr _xtc = r2corba_TypeCode_r2t (exctc);
552
+ _req->exceptions ()->add (_xtc);
553
+ }
554
+ }
555
+ return LONG2NUM (exc_len);
556
+ }
557
+
558
+ class R2TAO_Request_BlockedRegionCaller
559
+ {
560
+ public:
561
+ R2TAO_Request_BlockedRegionCaller (CORBA::Request_ptr req)
562
+ : req_ (req),
563
+ exception_ (false),
564
+ corba_ex_ (0) {}
565
+ virtual ~R2TAO_Request_BlockedRegionCaller ();
566
+
567
+ VALUE call ();
568
+
569
+ static VALUE blocking_func_exec (void *arg);
570
+
571
+ protected:
572
+ VALUE execute ();
573
+
574
+ virtual VALUE do_exec () = 0;
575
+
576
+ CORBA::Request_ptr req_;
577
+ bool exception_;
578
+ CORBA::Exception* corba_ex_;
579
+ };
580
+
581
+ R2TAO_Request_BlockedRegionCaller::~R2TAO_Request_BlockedRegionCaller()
582
+ {
583
+ if (this->exception_)
584
+ {
585
+ if (corba_ex_)
586
+ {
587
+ ACE_Auto_Basic_Ptr<CORBA::Exception> e_ptr(corba_ex_);
588
+ corba_ex_->_raise ();
589
+ }
590
+ else
591
+ {
592
+ throw ::CORBA::UNKNOWN ();
593
+ }
594
+ }
595
+ }
596
+
597
+ VALUE R2TAO_Request_BlockedRegionCaller::call ()
598
+ {
599
+ return r2tao_blocking_call (R2TAO_Request_BlockedRegionCaller::blocking_func_exec, this);
600
+ }
601
+
602
+ VALUE R2TAO_Request_BlockedRegionCaller::blocking_func_exec (void *arg)
603
+ {
604
+ R2TAO_Request_BlockedRegionCaller* call_obj =
605
+ reinterpret_cast<R2TAO_Request_BlockedRegionCaller*> (arg);
606
+
607
+ return call_obj->execute ();
608
+ }
609
+
610
+ VALUE R2TAO_Request_BlockedRegionCaller::execute ()
611
+ {
612
+ try {
613
+ return this->do_exec ();
614
+ }
615
+ catch (const CORBA::Exception& ex) {
616
+ this->exception_ = true;
617
+ this->corba_ex_ = ex._tao_duplicate ();
618
+ return Qfalse;
619
+ }
620
+ catch(...) {
621
+ this->exception_ = true;
622
+ return Qfalse;
623
+ }
624
+ }
625
+
626
+ class R2TAO_Request_BlockedInvoke : public R2TAO_Request_BlockedRegionCaller
627
+ {
628
+ public:
629
+ R2TAO_Request_BlockedInvoke (CORBA::Request_ptr req)
630
+ : R2TAO_Request_BlockedRegionCaller (req) {}
631
+ virtual ~R2TAO_Request_BlockedInvoke () {}
632
+
633
+ protected:
634
+ virtual VALUE do_exec ();
635
+ };
636
+
637
+ VALUE R2TAO_Request_BlockedInvoke::do_exec ()
638
+ {
639
+ this->req_->invoke ();
640
+ return Qnil;
641
+ }
642
+
643
+ class R2TAO_Request_BlockedSendOneway : public R2TAO_Request_BlockedRegionCaller
644
+ {
645
+ public:
646
+ R2TAO_Request_BlockedSendOneway (CORBA::Request_ptr req)
647
+ : R2TAO_Request_BlockedRegionCaller (req) {}
648
+ virtual ~R2TAO_Request_BlockedSendOneway () {}
649
+
650
+ protected:
651
+ virtual VALUE do_exec ();
652
+ };
653
+
654
+ VALUE R2TAO_Request_BlockedSendOneway::do_exec ()
655
+ {
656
+ this->req_->send_oneway ();
657
+ return Qnil;
658
+ }
659
+
660
+ class R2TAO_Request_BlockedSendDeferred : public R2TAO_Request_BlockedRegionCaller
661
+ {
662
+ public:
663
+ R2TAO_Request_BlockedSendDeferred (CORBA::Request_ptr req)
664
+ : R2TAO_Request_BlockedRegionCaller (req) {}
665
+ virtual ~R2TAO_Request_BlockedSendDeferred () {}
666
+
667
+ protected:
668
+ virtual VALUE do_exec ();
669
+ };
670
+
671
+ VALUE R2TAO_Request_BlockedSendDeferred::do_exec ()
672
+ {
673
+ this->req_->send_deferred ();
674
+ return Qnil;
675
+ }
676
+
677
+ class R2TAO_Request_BlockedGetResponse : public R2TAO_Request_BlockedRegionCaller
678
+ {
679
+ public:
680
+ R2TAO_Request_BlockedGetResponse (CORBA::Request_ptr req)
681
+ : R2TAO_Request_BlockedRegionCaller (req) {}
682
+ virtual ~R2TAO_Request_BlockedGetResponse () {}
683
+
684
+ protected:
685
+ virtual VALUE do_exec ();
686
+ };
687
+
688
+ VALUE R2TAO_Request_BlockedGetResponse::do_exec ()
689
+ {
690
+ this->req_->get_response ();
691
+ return Qnil;
692
+ }
693
+
694
+ class R2TAO_Request_BlockedPollResponse : public R2TAO_Request_BlockedRegionCaller
695
+ {
696
+ public:
697
+ R2TAO_Request_BlockedPollResponse (CORBA::Request_ptr req)
698
+ : R2TAO_Request_BlockedRegionCaller (req) {}
699
+ virtual ~R2TAO_Request_BlockedPollResponse () {}
700
+
701
+ protected:
702
+ virtual VALUE do_exec ();
703
+ };
704
+
705
+ VALUE R2TAO_Request_BlockedPollResponse::do_exec ()
706
+ {
707
+ return this->req_->poll_response () ? Qtrue : Qfalse;
708
+ }
709
+
710
+ static VALUE _r2tao_invoke_request(CORBA::Request_ptr _req,
711
+ VALUE arg_list,
712
+ VALUE ret_rtc,
713
+ VALUE exc_list,
714
+ bool& _raise)
715
+ {
716
+ if (TAO_debug_level > 5)
717
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): entry\n", _req->operation ()));
718
+
719
+ if (!NIL_P (arg_list))
720
+ _r2tao_set_request_arguments(_req, arg_list);
721
+ if (!NIL_P (exc_list))
722
+ _r2tao_set_request_exceptions(_req, exc_list);
723
+
724
+ if (TAO_debug_level > 9)
725
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): set return type\n", _req->operation ()));
726
+
727
+ CORBA::TypeCode_ptr _ret_tc = CORBA::TypeCode::_nil ();
728
+ if (!NIL_P(ret_rtc))
729
+ {
730
+ _ret_tc = r2corba_TypeCode_r2t (ret_rtc);
731
+ // assign type info to Any
732
+ r2tao_Ruby2Any(_req->return_value(), _ret_tc, Qnil);
733
+ }
734
+
735
+ CORBA::ULong ret_num = 0;
736
+
737
+ // invoke twoway if resulttype specified (could be void!)
738
+ if (!CORBA::is_nil(_ret_tc) && _ret_tc->kind () != CORBA::tk_null)
739
+ {
740
+ if (_ret_tc->kind () != CORBA::tk_void)
741
+ ++ret_num;
742
+
743
+ CORBA::ULong arg_num = _req->arguments ()->count ();
744
+ for (CORBA::ULong a=0; a<arg_num ;++a)
745
+ {
746
+ CORBA::NamedValue_ptr _arg = _req->arguments ()->item (a);
747
+ if (ACE_BIT_DISABLED (_arg->flags (), CORBA::ARG_IN))
748
+ ++ret_num;
749
+ }
750
+
751
+ if (TAO_debug_level > 6)
752
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): invoke remote twoway\n", _req->operation ()));
753
+
754
+ // invoke request
755
+ try
756
+ {
757
+ {
758
+ R2TAO_Request_BlockedInvoke blocked_exec (_req);
759
+
760
+ blocked_exec.call ();
761
+ }
762
+ }
763
+ catch (CORBA::UnknownUserException& user_ex)
764
+ {
765
+ if (TAO_debug_level > 6)
766
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): user exception from remote twoway\n", _req->operation ()));
767
+
768
+ CORBA::Any& _excany = user_ex.exception ();
769
+
770
+ CORBA::ULong exc_len = _req->exceptions ()->count ();
771
+ for (CORBA::ULong x=0; x<exc_len ;++x)
772
+ {
773
+ CORBA::TypeCode_var _xtc = _req->exceptions ()->item (x);
774
+ if (ACE_OS::strcmp (_xtc->id (),
775
+ _excany._tao_get_typecode ()->id ()) == 0)
776
+ {
777
+ VALUE x_rtc = r2corba_TypeCode_t2r (_xtc.in ());
778
+ VALUE rexc = r2tao_Any2Ruby (_excany,
779
+ _xtc.in (),
780
+ x_rtc, x_rtc);
781
+ _raise = true;
782
+ return rexc;
783
+ }
784
+ }
785
+
786
+ // rethrow if we were not able to identify the exception
787
+ // will be caught and handled in outer exception handler
788
+ throw;
789
+ }
790
+
791
+ if (TAO_debug_level > 6)
792
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): handle remote twoway results\n", _req->operation ()));
793
+
794
+ // handle result and OUT arguments
795
+ VALUE result = (ret_num>1 ? rb_ary_new () : Qnil);
796
+
797
+ if (_ret_tc->kind () != CORBA::tk_void)
798
+ {
799
+ if (TAO_debug_level > 9)
800
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): handle remote twoway return value\n", _req->operation ()));
801
+
802
+ CORBA::Any& retval = _req->return_value ();
803
+ // return value
804
+ if (ret_num>1)
805
+ rb_ary_push (result, r2tao_Any2Ruby (retval, _ret_tc, Qnil, Qnil));
806
+ else
807
+ result = r2tao_Any2Ruby (retval, _ret_tc, Qnil, Qnil);
808
+
809
+ --ret_num; // return value handled
810
+ }
811
+
812
+ // (in)out args
813
+ if (ret_num > 0)
814
+ {
815
+ if (TAO_debug_level > 9)
816
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): handle remote twoway (in)out args\n", _req->operation ()));
817
+
818
+ for (CORBA::ULong a=0; a<arg_num ;++a)
819
+ {
820
+ VALUE rargspec = rb_ary_entry (arg_list, a);
821
+ VALUE rargtc = rb_ary_entry (rargspec, 2);
822
+ CORBA::TypeCode_ptr atc = r2corba_TypeCode_r2t (rargtc);
823
+
824
+ CORBA::NamedValue_ptr _arg = _req->arguments ()->item (a);
825
+ if (ACE_BIT_DISABLED (_arg->flags (), CORBA::ARG_IN))
826
+ {
827
+ if (!NIL_P (result))
828
+ rb_ary_push (result, r2tao_Any2Ruby (*_arg->value (), atc, rargtc, rargtc));
829
+ else
830
+ result = r2tao_Any2Ruby (*_arg->value (), atc, rargtc, rargtc);
831
+ }
832
+ }
833
+ }
834
+
835
+ return result;
836
+ }
837
+ else // invoke oneway
838
+ {
839
+ if (TAO_debug_level > 6)
840
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - invoke_request(%C): invoke remote oneway\n", _req->operation ()));
841
+
842
+ // oneway
843
+ _req->send_oneway ();
844
+
845
+ return Qtrue;
846
+ }
847
+ }
848
+
849
+ //-------------------------------------------------------------------
850
+ // CORBA::Stub methods
851
+ //
852
+ //===================================================================
853
+
854
+ VALUE rCORBA_Stub_invoke(int _argc, VALUE *_argv, VALUE self)
855
+ {
856
+ if (TAO_debug_level > 9)
857
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Stub::_invoke: entry\n"));
858
+
859
+ // since rb_exc_raise () does not return and does *not* honour
860
+ // C++ exception rules we invoke from an inner function and
861
+ // only raise the user exception when returned so all stack
862
+ // unwinding has been correctly handled.
863
+ VALUE ret=Qnil;
864
+ bool _raise = false;
865
+ CORBA::Object_ptr obj;
866
+ VALUE opname = Qnil;
867
+ VALUE arg_list = Qnil;
868
+ VALUE result_type = Qnil;
869
+ VALUE exc_list = Qnil;
870
+ VALUE v1=Qnil;
871
+
872
+ // extract and check arguments
873
+ rb_scan_args(_argc, _argv, "20", &opname, &v1);
874
+ Check_Type (v1, T_HASH);
875
+
876
+ arg_list = rb_hash_aref (v1, ID_arg_list);
877
+ result_type = rb_hash_aref (v1, ID_result_type);
878
+ exc_list = rb_hash_aref (v1, ID_exc_list);
879
+
880
+ Check_Type(opname, T_STRING);
881
+ if (!NIL_P (arg_list))
882
+ Check_Type (arg_list, T_ARRAY);
883
+ if (!NIL_P (result_type))
884
+ r2tao_check_type(result_type, r2corba_cTypeCode);
885
+ if (!NIL_P (exc_list))
886
+ Check_Type (exc_list, T_ARRAY);
887
+
888
+ obj = r2corba_Object_r2t (self);
889
+
890
+ R2TAO_TRY
891
+ {
892
+ CORBA::Request_var _req = obj->_request (RSTRING_PTR (opname));
893
+
894
+ ret = _r2tao_invoke_request(_req.in (), arg_list, result_type, exc_list, _raise);
895
+ }
896
+ R2TAO_CATCH;
897
+ if (_raise) rb_exc_raise (ret);
898
+ return ret;
899
+ }
900
+
901
+ //-------------------------------------------------------------------
902
+ // CORBA::Request methods
903
+ //
904
+ //===================================================================
905
+
906
+ VALUE rCORBA_Request_invoke(int _argc, VALUE *_argv, VALUE self)
907
+ {
908
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
909
+
910
+ if (TAO_debug_level > 5)
911
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Request::_invoke(%@): entry\n", _req->operation ()));
912
+
913
+ // since rb_exc_raise () does not return and does *not* honour
914
+ // C++ exception rules we invoke from an inner function and
915
+ // only raise the user exception when returned so all stack
916
+ // unwinding has been correctly handled.
917
+ VALUE ret=Qnil;
918
+ bool _raise = false;
919
+ VALUE arg_list = Qnil;
920
+ VALUE result_type = Qnil;
921
+ VALUE exc_list = Qnil;
922
+ VALUE v1=Qnil;
923
+
924
+ // extract and check arguments
925
+ rb_scan_args(_argc, _argv, "10", &v1);
926
+ if (!NIL_P (v1))
927
+ {
928
+ Check_Type (v1, T_HASH);
929
+ arg_list = rb_hash_aref (v1, ID_arg_list);
930
+ result_type = rb_hash_aref (v1, ID_result_type);
931
+ exc_list = rb_hash_aref (v1, ID_exc_list);
932
+ }
933
+
934
+ if (!NIL_P (arg_list))
935
+ Check_Type (arg_list, T_ARRAY);
936
+ if (!NIL_P (result_type))
937
+ r2tao_check_type(result_type, r2corba_cTypeCode);
938
+ if (!NIL_P (exc_list))
939
+ Check_Type (exc_list, T_ARRAY);
940
+
941
+ R2TAO_TRY
942
+ {
943
+ ret = _r2tao_invoke_request(_req, arg_list, result_type, exc_list, _raise);
944
+ }
945
+ R2TAO_CATCH;
946
+
947
+ if (_raise) rb_exc_raise (ret);
948
+ return ret;
949
+ }
950
+
951
+ VALUE rCORBA_Request_send_oneway(VALUE self, VALUE arg_list)
952
+ {
953
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
954
+
955
+ if (TAO_debug_level > 5)
956
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Request::_send_oneway(%@): entry\n", _req->operation ()));
957
+
958
+ if (!NIL_P (arg_list))
959
+ {
960
+ Check_Type (arg_list, T_ARRAY);
961
+ }
962
+
963
+
964
+ R2TAO_TRY
965
+ {
966
+ if (!NIL_P (arg_list))
967
+ _r2tao_set_request_arguments(_req, arg_list);
968
+
969
+ {
970
+ R2TAO_Request_BlockedSendOneway blocked_exec (_req);
971
+
972
+ blocked_exec.call ();
973
+ }
974
+ }
975
+ R2TAO_CATCH;
976
+
977
+ return Qtrue;
978
+ }
979
+
980
+ VALUE rCORBA_Request_send_deferred(int _argc, VALUE *_argv, VALUE self)
981
+ {
982
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
983
+
984
+ if (TAO_debug_level > 5)
985
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Request::_send_deferred(%@): entry\n", _req->operation ()));
986
+
987
+ VALUE arg_list = Qnil;
988
+ VALUE result_type = Qnil;
989
+ VALUE exc_list = Qnil;
990
+ VALUE v1=Qnil;
991
+
992
+ // extract and check arguments
993
+ rb_scan_args(_argc, _argv, "10", &v1);
994
+ if (!NIL_P (v1))
995
+ {
996
+ Check_Type (v1, T_HASH);
997
+ arg_list = rb_hash_aref (v1, ID_arg_list);
998
+ result_type = rb_hash_aref (v1, ID_result_type);
999
+ exc_list = rb_hash_aref (v1, ID_exc_list);
1000
+ }
1001
+
1002
+ if (!NIL_P (arg_list))
1003
+ Check_Type (arg_list, T_ARRAY);
1004
+ if (!NIL_P (result_type))
1005
+ r2tao_check_type(result_type, r2corba_cTypeCode);
1006
+ if (!NIL_P (exc_list))
1007
+ Check_Type (exc_list, T_ARRAY);
1008
+
1009
+ R2TAO_TRY
1010
+ {
1011
+ if (!NIL_P (arg_list))
1012
+ _r2tao_set_request_arguments(_req, arg_list);
1013
+ if (!NIL_P (exc_list))
1014
+ _r2tao_set_request_exceptions(_req, exc_list);
1015
+
1016
+ if (TAO_debug_level > 9)
1017
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Request::_send_deferred(%C): set return type\n", _req->operation ()));
1018
+
1019
+ CORBA::TypeCode_ptr _ret_tc = CORBA::TypeCode::_nil ();
1020
+ if (!NIL_P(result_type))
1021
+ {
1022
+ _ret_tc = r2corba_TypeCode_r2t (result_type);
1023
+ // assign type info to Any
1024
+ r2tao_Ruby2Any(_req->return_value(), _ret_tc, Qnil);
1025
+ }
1026
+
1027
+ {
1028
+ R2TAO_Request_BlockedSendDeferred blocked_exec (_req);
1029
+
1030
+ blocked_exec.call ();
1031
+ }
1032
+ }
1033
+ R2TAO_CATCH;
1034
+
1035
+ return Qtrue;
1036
+ }
1037
+
1038
+ VALUE rCORBA_Request_get_response(VALUE self)
1039
+ {
1040
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
1041
+
1042
+ R2TAO_TRY
1043
+ {
1044
+ {
1045
+ R2TAO_Request_BlockedGetResponse blocked_exec (_req);
1046
+
1047
+ blocked_exec.call ();
1048
+ }
1049
+ }
1050
+ R2TAO_CATCH;
1051
+
1052
+ return Qtrue;
1053
+ }
1054
+
1055
+ VALUE rCORBA_Request_poll_response(VALUE self)
1056
+ {
1057
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
1058
+
1059
+ VALUE ret=Qnil;
1060
+ R2TAO_TRY
1061
+ {
1062
+ {
1063
+ R2TAO_Request_BlockedPollResponse blocked_exec (_req);
1064
+
1065
+ ret = blocked_exec.call ();
1066
+ }
1067
+ }
1068
+ R2TAO_CATCH;
1069
+
1070
+ return ret;
1071
+ }
1072
+
1073
+ VALUE rCORBA_Request_target(VALUE self)
1074
+ {
1075
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
1076
+ R2TAO_TRY
1077
+ {
1078
+ CORBA::Object_var obj = _req->target ();
1079
+ return r2tao_Object_t2r (obj.in ());
1080
+ }
1081
+ R2TAO_CATCH;
1082
+ return Qnil;
1083
+ }
1084
+
1085
+ VALUE rCORBA_Request_operation(VALUE self)
1086
+ {
1087
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
1088
+ R2TAO_TRY
1089
+ {
1090
+ return rb_str_new2 (_req->operation ());
1091
+ }
1092
+ R2TAO_CATCH;
1093
+ return Qnil;
1094
+ }
1095
+
1096
+ VALUE rCORBA_Request_arguments(VALUE self, VALUE arg_list)
1097
+ {
1098
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
1099
+ if (arg_list != Qnil)
1100
+ Check_Type (arg_list, T_ARRAY);
1101
+ CORBA::ULong rarg_len = (CORBA::ULong )RARRAY_LEN (arg_list);
1102
+ R2TAO_TRY
1103
+ {
1104
+ CORBA::ULong arg_len = _req->arguments ()->count ();
1105
+ if (arg_len != rarg_len)
1106
+ {
1107
+ throw CORBA::BAD_PARAM();
1108
+ }
1109
+ VALUE rargs_new = rb_ary_new ();
1110
+ for (CORBA::ULong a=0; a<arg_len ;++a)
1111
+ {
1112
+ VALUE rargspec = rb_ary_entry (arg_list, a);
1113
+ VALUE rargname = rb_ary_entry (rargspec, 0);
1114
+ VALUE rargtc = rb_ary_entry (rargspec, 2);
1115
+ CORBA::TypeCode_ptr atc = r2corba_TypeCode_r2t (rargtc);
1116
+
1117
+ VALUE rarg_new = rb_ary_new ();
1118
+ CORBA::NamedValue_ptr arg = _req->arguments ()->item (a);
1119
+
1120
+ rb_ary_push (rarg_new, rargname);
1121
+ if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_IN))
1122
+ rb_ary_push (rarg_new, ULONG2NUM (r2tao_IN_ARG));
1123
+ else if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_OUT))
1124
+ rb_ary_push (rarg_new, ULONG2NUM (r2tao_OUT_ARG));
1125
+ else if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_INOUT))
1126
+ rb_ary_push (rarg_new, ULONG2NUM (r2tao_INOUT_ARG));
1127
+ rb_ary_push (rarg_new, rargtc);
1128
+ VALUE arg_val = r2tao_Any2Ruby (*arg->value (), atc, rargtc, rargtc);
1129
+ rb_ary_push (rarg_new, arg_val);
1130
+ rb_ary_push (rargs_new, rarg_new);
1131
+ }
1132
+ return rargs_new;
1133
+ }
1134
+ R2TAO_CATCH;
1135
+ return Qnil;
1136
+ }
1137
+
1138
+ VALUE rCORBA_Request_return_value(VALUE self, VALUE result_type)
1139
+ {
1140
+ CORBA::Request_ptr _req = r2tao_Request_r2t(self);
1141
+ CORBA::TypeCode_ptr _ret_tc = r2corba_TypeCode_r2t (result_type);
1142
+ R2TAO_TRY
1143
+ {
1144
+ CORBA::Any& _ret_val = _req->return_value ();
1145
+ return r2tao_Any2Ruby (_ret_val, _ret_tc, result_type, result_type);
1146
+ }
1147
+ R2TAO_CATCH;
1148
+
1149
+ return Qnil;
1150
+ }