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,1076 @@
1
+ /*--------------------------------------------------------------------
2
+ # poa.cpp - R2TAO CORBA PortableServer 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 "poa.h"
15
+ #include "tao/DynamicInterface/Server_Request.h"
16
+ #include "tao/DynamicInterface/Dynamic_Implementation.h"
17
+ #include "tao/AnyTypeCode/Any.h"
18
+ #include "tao/AnyTypeCode/NVList.h"
19
+ #include "tao/ORB.h"
20
+ #include "tao/Exception.h"
21
+ #include "tao/TSS_Resources.h"
22
+ #include "tao/PortableServer/POA_Current_Impl.h"
23
+ #include "typecode.h"
24
+ #include "object.h"
25
+ #include "exception.h"
26
+ #include "orb.h"
27
+ #include "servant.h"
28
+
29
+ #define RUBY_INVOKE_FUNC RUBY_ALLOC_FUNC
30
+
31
+ R2TAO_POA_EXPORT VALUE r2tao_nsPOA = 0;
32
+ static VALUE r2tao_nsPOAManager;
33
+ static VALUE r2tao_nsPortableServer;
34
+ static VALUE r2tao_cObjectId;
35
+ static VALUE r2tao_nsPolicy;
36
+
37
+ static VALUE r2tao_x_POA_AdapterAlreadyExists;
38
+ static VALUE r2tao_x_POA_AdapterInactive;
39
+ static VALUE r2tao_x_POA_AdapterNonExistent;
40
+ static VALUE r2tao_x_POA_InvalidPolicy;
41
+ static VALUE r2tao_x_POA_NoServant;
42
+ static VALUE r2tao_x_POA_ObjectAlreadyActive;
43
+ static VALUE r2tao_x_POA_ObjectNotActive;
44
+ static VALUE r2tao_x_POA_ServantAlreadyActive;
45
+ static VALUE r2tao_x_POA_ServantNotActive;
46
+ static VALUE r2tao_x_POA_WrongAdapter;
47
+ static VALUE r2tao_x_POA_WrongPolicy;
48
+
49
+ static VALUE r2tao_x_POAManager_AdapterInactive;
50
+
51
+ static ID new_ID;
52
+
53
+ static R2TAO_RBFuncall FN_narrow ("_narrow");
54
+
55
+ static VALUE r2tao_PS_string_to_ObjectId(VALUE self, VALUE string);
56
+ static VALUE r2tao_PS_ObjectId_to_string(VALUE self, VALUE oid);
57
+
58
+ static VALUE r2tao_POA_destroy(VALUE self, VALUE etherealize, VALUE wait_for_completion);
59
+ static VALUE r2tao_POA_the_name(VALUE self);
60
+ static VALUE r2tao_POA_the_POAManager(VALUE self);
61
+ static VALUE r2tao_POA_the_parent(VALUE self);
62
+ static VALUE r2tao_POA_the_children(VALUE self);
63
+ static VALUE r2tao_POA_activate_object(VALUE self, VALUE servant);
64
+ static VALUE r2tao_POA_activate_object_with_id(VALUE self, VALUE id, VALUE servant);
65
+ static VALUE r2tao_POA_deactivate_object(VALUE self, VALUE oid);
66
+ static VALUE r2tao_POA_create_reference(VALUE self, VALUE repoid);
67
+ static VALUE r2tao_POA_create_reference_with_id(VALUE self, VALUE oid, VALUE repoid);
68
+ static VALUE r2tao_POA_servant_to_id(VALUE self, VALUE servant);
69
+ static VALUE r2tao_POA_servant_to_reference(VALUE self, VALUE servant);
70
+ static VALUE r2tao_POA_reference_to_servant(VALUE self, VALUE obj);
71
+ static VALUE r2tao_POA_reference_to_id(VALUE self, VALUE obj);
72
+ static VALUE r2tao_POA_id_to_servant(VALUE self, VALUE oid);
73
+ static VALUE r2tao_POA_id_to_reference(VALUE self, VALUE oid);
74
+ static VALUE r2tao_POA_create_POA(VALUE self, VALUE name, VALUE poaman, VALUE policies);
75
+ static VALUE r2tao_POA_find_POA(VALUE self, VALUE name, VALUE activate);
76
+ static VALUE r2tao_POA_id(VALUE self);
77
+
78
+ static PortableServer::POAManager_ptr r2tao_POAManager_r2t(VALUE obj);
79
+
80
+ static VALUE r2tao_POAManager_activate(VALUE self);
81
+ static VALUE r2tao_POAManager_hold_requests(VALUE self, VALUE wait_for_completion);
82
+ static VALUE r2tao_POAManager_discard_requests(VALUE self, VALUE wait_for_completion);
83
+ static VALUE r2tao_POAManager_deactivate(VALUE self, VALUE etherealize, VALUE wait_for_completion);
84
+ static VALUE r2tao_POAManager_get_state(VALUE self);
85
+ static VALUE r2tao_POAManager_get_id(VALUE self);
86
+ static VALUE r2tao_POAManager_get_orb(VALUE self);
87
+
88
+ static PortableServer::ObjectId* r2tao_ObjectId_r2t(VALUE oid);
89
+
90
+ void r2tao_init_Servant(); // in servant.cpp
91
+ void r2tao_init_IORTable(); // in iortable.cpp
92
+
93
+ #if defined(WIN32) && defined(_DEBUG)
94
+ extern "C" R2TAO_POA_EXPORT void Init_librpoad()
95
+ #else
96
+ extern "C" R2TAO_POA_EXPORT void Init_librpoa()
97
+ #endif
98
+ {
99
+ VALUE klass;
100
+
101
+ if (r2tao_nsCORBA == 0)
102
+ {
103
+ rb_raise(rb_eRuntimeError, "CORBA base not initialized.");
104
+ return;
105
+ }
106
+
107
+ if (r2tao_nsPOA) return;
108
+
109
+ r2tao_nsPortableServer = klass = rb_eval_string("::R2CORBA::PortableServer");
110
+ rb_define_singleton_method(klass, "string_to_ObjectId", RUBY_METHOD_FUNC(r2tao_PS_string_to_ObjectId), 1);
111
+ rb_define_singleton_method(klass, "ObjectId_to_string", RUBY_METHOD_FUNC(r2tao_PS_ObjectId_to_string), 1);
112
+
113
+ r2tao_nsPOA = klass = rb_eval_string("::R2CORBA::PortableServer::POA");
114
+
115
+ r2tao_x_POA_AdapterAlreadyExists = rb_const_get (r2tao_nsPOA, rb_intern ("AdapterAlreadyExists"));
116
+ r2tao_x_POA_AdapterInactive = rb_const_get (r2tao_nsPOA, rb_intern ("AdapterInactive"));
117
+ r2tao_x_POA_AdapterNonExistent = rb_const_get (r2tao_nsPOA, rb_intern ("AdapterNonExistent"));
118
+ r2tao_x_POA_InvalidPolicy = rb_const_get (r2tao_nsPOA, rb_intern ("InvalidPolicy"));
119
+ r2tao_x_POA_NoServant = rb_const_get (r2tao_nsPOA, rb_intern ("NoServant"));
120
+ r2tao_x_POA_ObjectAlreadyActive = rb_const_get (r2tao_nsPOA, rb_intern ("ObjectAlreadyActive"));
121
+ r2tao_x_POA_ObjectNotActive = rb_const_get (r2tao_nsPOA, rb_intern ("ObjectNotActive"));
122
+ r2tao_x_POA_ServantAlreadyActive = rb_const_get (r2tao_nsPOA, rb_intern ("ServantAlreadyActive"));
123
+ r2tao_x_POA_ServantNotActive = rb_const_get (r2tao_nsPOA, rb_intern ("ServantNotActive"));
124
+ r2tao_x_POA_WrongAdapter = rb_const_get (r2tao_nsPOA, rb_intern ("WrongAdapter"));
125
+ r2tao_x_POA_WrongPolicy = rb_const_get (r2tao_nsPOA, rb_intern ("WrongPolicy"));
126
+
127
+ rb_define_method(klass, "destroy", RUBY_METHOD_FUNC(r2tao_POA_destroy), 2);
128
+ rb_define_method(klass, "the_name", RUBY_METHOD_FUNC(r2tao_POA_the_name), 0);
129
+ rb_define_method(klass, "the_POAManager", RUBY_METHOD_FUNC(r2tao_POA_the_POAManager), 0);
130
+ rb_define_method(klass, "the_parent", RUBY_METHOD_FUNC(r2tao_POA_the_parent), 0);
131
+ rb_define_method(klass, "the_children", RUBY_METHOD_FUNC(r2tao_POA_the_children), 0);
132
+ rb_define_method(klass, "activate_object", RUBY_METHOD_FUNC(r2tao_POA_activate_object), 1);
133
+ rb_define_method(klass, "activate_object_with_id", RUBY_METHOD_FUNC(r2tao_POA_activate_object_with_id), 2);
134
+ rb_define_method(klass, "deactivate_object", RUBY_METHOD_FUNC(r2tao_POA_deactivate_object), 1);
135
+ rb_define_method(klass, "create_reference", RUBY_METHOD_FUNC(r2tao_POA_create_reference), 1);
136
+ rb_define_method(klass, "create_reference_with_id", RUBY_METHOD_FUNC(r2tao_POA_create_reference_with_id), 2);
137
+ rb_define_method(klass, "servant_to_id", RUBY_METHOD_FUNC(r2tao_POA_servant_to_id), 1);
138
+ rb_define_method(klass, "servant_to_reference", RUBY_METHOD_FUNC(r2tao_POA_servant_to_reference), 1);
139
+ rb_define_method(klass, "reference_to_servant", RUBY_METHOD_FUNC(r2tao_POA_reference_to_servant), 1);
140
+ rb_define_method(klass, "reference_to_id", RUBY_METHOD_FUNC(r2tao_POA_reference_to_id), 1);
141
+ rb_define_method(klass, "id_to_servant", RUBY_METHOD_FUNC(r2tao_POA_id_to_servant), 1);
142
+ rb_define_method(klass, "id_to_reference", RUBY_METHOD_FUNC(r2tao_POA_id_to_reference), 1);
143
+ rb_define_method(klass, "create_POA", RUBY_METHOD_FUNC(r2tao_POA_create_POA), 3);
144
+ rb_define_method(klass, "find_POA", RUBY_METHOD_FUNC(r2tao_POA_find_POA), 2);
145
+ rb_define_method(klass, "id", RUBY_METHOD_FUNC(r2tao_POA_id), 0);
146
+
147
+ r2tao_nsPOAManager = klass = rb_eval_string("::R2CORBA::PortableServer::POAManager");
148
+
149
+ r2tao_x_POAManager_AdapterInactive = rb_const_get (r2tao_nsPOAManager, rb_intern ("AdapterInactive"));
150
+
151
+ rb_define_method(klass, "activate", RUBY_METHOD_FUNC(r2tao_POAManager_activate), 0);
152
+ rb_define_method(klass, "hold_requests", RUBY_METHOD_FUNC(r2tao_POAManager_hold_requests), 1);
153
+ rb_define_method(klass, "discard_requests", RUBY_METHOD_FUNC(r2tao_POAManager_discard_requests), 1);
154
+ rb_define_method(klass, "deactivate", RUBY_METHOD_FUNC(r2tao_POAManager_deactivate), 2);
155
+ rb_define_method(klass, "get_state", RUBY_METHOD_FUNC(r2tao_POAManager_get_state), 0);
156
+ rb_define_method(klass, "get_id", RUBY_METHOD_FUNC(r2tao_POAManager_get_id), 0);
157
+ rb_define_method(klass, "_get_orb", RUBY_METHOD_FUNC(r2tao_POAManager_get_orb), 0);
158
+
159
+ new_ID = rb_intern ("new");
160
+
161
+ r2tao_cObjectId = rb_eval_string("::R2CORBA::PortableServer::ObjectId");
162
+ r2tao_nsPolicy = rb_eval_string ("R2CORBA::CORBA::Policy");
163
+
164
+ r2tao_init_Servant(); // in servant.cpp
165
+ r2tao_init_IORTable(); // in iortable.cpp
166
+ }
167
+
168
+ class R2TAO_POA_BlockedRegionCallerBase
169
+ {
170
+ public:
171
+ R2TAO_POA_BlockedRegionCallerBase ()
172
+ : exception_ (false),
173
+ corba_ex_ (0) {}
174
+ virtual ~R2TAO_POA_BlockedRegionCallerBase ();
175
+
176
+ VALUE call ();
177
+
178
+ static VALUE blocking_func_exec (void *arg);
179
+
180
+ protected:
181
+ VALUE execute ();
182
+
183
+ virtual VALUE do_exec () = 0;
184
+
185
+ bool exception_;
186
+ CORBA::Exception* corba_ex_;
187
+ };
188
+
189
+ R2TAO_POA_BlockedRegionCallerBase::~R2TAO_POA_BlockedRegionCallerBase()
190
+ {
191
+ if (this->exception_)
192
+ {
193
+ if (corba_ex_)
194
+ {
195
+ ACE_Auto_Basic_Ptr<CORBA::Exception> e_ptr(corba_ex_);
196
+ corba_ex_->_raise ();
197
+ }
198
+ else
199
+ {
200
+ throw ::CORBA::UNKNOWN ();
201
+ }
202
+ }
203
+ }
204
+
205
+ VALUE R2TAO_POA_BlockedRegionCallerBase::call ()
206
+ {
207
+ return r2tao_blocking_call (R2TAO_POA_BlockedRegionCallerBase::blocking_func_exec, this);
208
+ }
209
+
210
+ VALUE R2TAO_POA_BlockedRegionCallerBase::blocking_func_exec (void *arg)
211
+ {
212
+ R2TAO_POA_BlockedRegionCallerBase* call_obj =
213
+ reinterpret_cast<R2TAO_POA_BlockedRegionCallerBase*> (arg);
214
+
215
+ return call_obj->execute ();
216
+ }
217
+
218
+ VALUE R2TAO_POA_BlockedRegionCallerBase::execute ()
219
+ {
220
+ try {
221
+ return this->do_exec ();
222
+ }
223
+ catch (const CORBA::Exception& ex) {
224
+ this->exception_ = true;
225
+ this->corba_ex_ = ex._tao_duplicate ();
226
+ return Qfalse;
227
+ }
228
+ catch(...) {
229
+ this->exception_ = true;
230
+ return Qfalse;
231
+ }
232
+ }
233
+
234
+ //-------------------------------------------------------------------
235
+ // ObjectId functions
236
+ //
237
+ //===================================================================
238
+
239
+ VALUE r2tao_ObjectId_t2r(const PortableServer::ObjectId& oid)
240
+ {
241
+ return rb_funcall (r2tao_cObjectId,
242
+ new_ID,
243
+ 1,
244
+ rb_str_new ((char*)oid.get_buffer (), (long)oid.length ()));
245
+ }
246
+
247
+ static PortableServer::ObjectId* r2tao_ObjectId_r2t(VALUE oid)
248
+ {
249
+ VALUE oidstr =
250
+ rb_type (oid) == T_STRING ? oid : rb_str_to_str (oid);
251
+ CORBA::ULong buflen = static_cast<CORBA::ULong> (RSTRING_LEN (oidstr));
252
+ CORBA::Octet* buf =
253
+ PortableServer::ObjectId::allocbuf (buflen);
254
+ ACE_OS::memcpy (buf, RSTRING_PTR (oidstr), static_cast<size_t> (buflen));
255
+ return new PortableServer::ObjectId (buflen, buflen, buf, true);
256
+ }
257
+
258
+ //-------------------------------------------------------------------
259
+ // Ruby PortableServer class methods
260
+ //
261
+ //===================================================================
262
+
263
+ VALUE r2tao_PS_string_to_ObjectId(VALUE /*self*/, VALUE string)
264
+ {
265
+ string = rb_check_convert_type(string, T_STRING, "String", "to_s");
266
+ R2TAO_TRY
267
+ {
268
+ PortableServer::ObjectId_var oid =
269
+ PortableServer::string_to_ObjectId (RSTRING_PTR (string));
270
+ return r2tao_ObjectId_t2r (oid);
271
+ }
272
+ R2TAO_CATCH;
273
+ return Qnil;
274
+ }
275
+
276
+ VALUE r2tao_PS_ObjectId_to_string(VALUE /*self*/, VALUE oid)
277
+ {
278
+ R2TAO_TRY
279
+ {
280
+ PortableServer::ObjectId_var _oid = r2tao_ObjectId_r2t(oid);
281
+ CORBA::String_var str = PortableServer::ObjectId_to_string (_oid);
282
+ return rb_str_new2 (str.in ());
283
+ }
284
+ R2TAO_CATCH;
285
+ return Qnil;
286
+ }
287
+
288
+ //-------------------------------------------------------------------
289
+ // Ruby POA functions
290
+ //
291
+ //===================================================================
292
+
293
+ class R2TAO_POA_BlockedRegionCaller : public R2TAO_POA_BlockedRegionCallerBase
294
+ {
295
+ public:
296
+ R2TAO_POA_BlockedRegionCaller (PortableServer::POA_ptr _poa)
297
+ : poa_ (PortableServer::POA::_duplicate (_poa))
298
+ {}
299
+ virtual ~R2TAO_POA_BlockedRegionCaller () {}
300
+
301
+ protected:
302
+ //virtual VALUE do_exec () = 0;
303
+
304
+ PortableServer::POA_var poa_;
305
+ };
306
+
307
+ R2TAO_POA_EXPORT PortableServer::POA_ptr r2tao_POA_r2t(VALUE obj)
308
+ {
309
+ CORBA::Object_ptr _obj = r2corba_Object_r2t (obj);
310
+ R2TAO_TRY
311
+ {
312
+ return PortableServer::POA::_narrow (_obj);
313
+ }
314
+ R2TAO_CATCH;
315
+ return PortableServer::POA::_nil();
316
+ }
317
+
318
+ class R2TAO_POA_BlockedDestroy : public R2TAO_POA_BlockedRegionCaller
319
+ {
320
+ public:
321
+ R2TAO_POA_BlockedDestroy (PortableServer::POA_ptr _poa, bool _etherealize, bool _wait_for_completion)
322
+ : R2TAO_POA_BlockedRegionCaller (_poa),
323
+ etherealize_ (_etherealize),
324
+ wait_for_completion_ (_wait_for_completion)
325
+ {}
326
+ virtual ~R2TAO_POA_BlockedDestroy () {}
327
+
328
+ protected:
329
+ virtual VALUE do_exec ();
330
+
331
+ bool etherealize_;
332
+ bool wait_for_completion_;
333
+ };
334
+
335
+ VALUE R2TAO_POA_BlockedDestroy::do_exec ()
336
+ {
337
+ this->poa_->destroy (this->etherealize_, this->wait_for_completion_);
338
+ return Qnil;
339
+ }
340
+
341
+ VALUE r2tao_POA_destroy(VALUE self, VALUE etherealize, VALUE wait_for_completion)
342
+ {
343
+ R2TAO_TRY
344
+ {
345
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
346
+ R2TAO_POA_BlockedDestroy blocked_destroy (_poa.in (), etherealize == Qtrue, wait_for_completion == Qtrue);
347
+ blocked_destroy.call ();
348
+ }
349
+ R2TAO_CATCH;
350
+ return Qnil;
351
+ }
352
+ VALUE r2tao_POA_the_name(VALUE self)
353
+ {
354
+ VALUE rpoaname = Qnil;
355
+ R2TAO_TRY
356
+ {
357
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
358
+ CORBA::String_var _poaname = _poa->the_name ();
359
+ rpoaname = rb_str_new2 (_poaname.in ());
360
+ }
361
+ R2TAO_CATCH;
362
+ return rpoaname;
363
+ }
364
+ VALUE r2tao_POA_the_POAManager(VALUE self)
365
+ {
366
+ VALUE rpoa_man = Qnil;
367
+ R2TAO_TRY
368
+ {
369
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
370
+ PortableServer::POAManager_var _poa_manager = _poa->the_POAManager ();
371
+
372
+ CORBA::Object_ptr obj =
373
+ dynamic_cast<CORBA::Object_ptr> (_poa_manager.in ());
374
+ rpoa_man = r2corba_Object_t2r (obj);
375
+ rpoa_man = FN_narrow.invoke (r2tao_nsPOAManager, 1, &rpoa_man);
376
+ }
377
+ R2TAO_CATCH;
378
+ return rpoa_man;
379
+ }
380
+ VALUE r2tao_POA_the_parent(VALUE self)
381
+ {
382
+ VALUE rpoa_parent = Qnil;
383
+ R2TAO_TRY
384
+ {
385
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
386
+ PortableServer::POA_var _poa_parent = _poa->the_parent ();
387
+
388
+ rpoa_parent =
389
+ r2corba_Object_t2r(dynamic_cast<CORBA::Object_ptr> (_poa_parent.in ()));
390
+ rpoa_parent = FN_narrow.invoke (r2tao_nsPOA, 1, &rpoa_parent);
391
+ }
392
+ R2TAO_CATCH;
393
+ return rpoa_parent;
394
+ }
395
+ VALUE r2tao_POA_the_children(VALUE self)
396
+ {
397
+ VALUE rpoa_list = Qnil;
398
+ R2TAO_TRY
399
+ {
400
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
401
+ PortableServer::POAList_var _poa_list = _poa->the_children ();
402
+
403
+ rpoa_list = rb_ary_new2 (ULONG2NUM (_poa_list->length ()));
404
+ for (CORBA::ULong l=0; l<_poa_list->length () ;++l)
405
+ {
406
+ PortableServer::POA_ptr _poa_child = _poa_list[l];
407
+ VALUE rpoa_child =
408
+ r2corba_Object_t2r(dynamic_cast<CORBA::Object_ptr> (_poa_child));
409
+ rb_ary_push (rpoa_list, FN_narrow.invoke (r2tao_nsPOA, 1, &rpoa_child));
410
+ }
411
+ }
412
+ R2TAO_CATCH;
413
+ return rpoa_list;
414
+ }
415
+
416
+ class R2TAO_POA_BlockedActivateObject : public R2TAO_POA_BlockedRegionCaller
417
+ {
418
+ public:
419
+ R2TAO_POA_BlockedActivateObject (PortableServer::POA_ptr _poa, DSI_Servant* _svnt)
420
+ : R2TAO_POA_BlockedRegionCaller (_poa),
421
+ servant_ (_svnt),
422
+ with_id_ (false)
423
+ {}
424
+ R2TAO_POA_BlockedActivateObject (PortableServer::POA_ptr _poa, DSI_Servant* _svnt, PortableServer::ObjectId* oid)
425
+ : R2TAO_POA_BlockedRegionCaller (_poa),
426
+ servant_ (_svnt),
427
+ oid_ (oid),
428
+ with_id_ (true)
429
+ {}
430
+ virtual ~R2TAO_POA_BlockedActivateObject () {}
431
+
432
+ const PortableServer::ObjectId& oid () const { return this->oid_.in (); }
433
+
434
+ protected:
435
+ virtual VALUE do_exec ();
436
+
437
+ DSI_Servant* servant_;
438
+ PortableServer::ObjectId_var oid_;
439
+ bool with_id_;
440
+ };
441
+
442
+ VALUE R2TAO_POA_BlockedActivateObject::do_exec ()
443
+ {
444
+ if (this->with_id_)
445
+ this->poa_->activate_object_with_id (this->oid_.in (), this->servant_);
446
+ else
447
+ this->oid_ = this->poa_->activate_object (this->servant_);
448
+ return Qnil;
449
+ }
450
+
451
+ VALUE r2tao_POA_activate_object(VALUE self, VALUE servant)
452
+ {
453
+ r2tao_check_type(servant, r2tao_cServant);
454
+
455
+ R2TAO_TRY
456
+ {
457
+ try
458
+ {
459
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
460
+
461
+ DSI_Servant* _servant;
462
+ if (DATA_PTR (servant) == 0)
463
+ {
464
+ _servant = new DSI_Servant (servant);
465
+ }
466
+ else
467
+ {
468
+ _servant = static_cast<DSI_Servant*> (DATA_PTR (servant));
469
+ }
470
+ R2TAO_POA_BlockedActivateObject blocked_actobj (_poa.in (), _servant);
471
+ blocked_actobj.call ();
472
+
473
+ _servant->activate_servant (); // activate Ruby servant
474
+
475
+ return r2tao_ObjectId_t2r (blocked_actobj.oid ());
476
+ }
477
+ catch (const PortableServer::POA::WrongPolicy& ex)
478
+ {
479
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
480
+ }
481
+ catch (const PortableServer::POA::ServantAlreadyActive& ex)
482
+ {
483
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ServantAlreadyActive));
484
+ }
485
+ }
486
+ R2TAO_CATCH;
487
+ return Qnil;
488
+ }
489
+
490
+ VALUE r2tao_POA_activate_object_with_id(VALUE self, VALUE oid, VALUE servant)
491
+ {
492
+ R2TAO_TRY
493
+ {
494
+ try
495
+ {
496
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
497
+
498
+ DSI_Servant* _servant;
499
+ if (DATA_PTR (servant) == 0)
500
+ {
501
+ _servant = new DSI_Servant (servant);
502
+ }
503
+ else
504
+ {
505
+ _servant = static_cast<DSI_Servant*> (DATA_PTR (servant));
506
+ }
507
+ R2TAO_POA_BlockedActivateObject blocked_actobj (_poa.in (), _servant, r2tao_ObjectId_r2t(oid));
508
+ blocked_actobj.call ();
509
+
510
+ _servant->activate_servant (); // activate Ruby servant
511
+ }
512
+ catch (const PortableServer::POA::WrongPolicy& ex)
513
+ {
514
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
515
+ }
516
+ catch (const PortableServer::POA::ServantAlreadyActive& ex)
517
+ {
518
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ServantAlreadyActive));
519
+ }
520
+ catch (const PortableServer::POA::ObjectAlreadyActive& ex)
521
+ {
522
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ObjectAlreadyActive));
523
+ }
524
+ }
525
+ R2TAO_CATCH;
526
+ return Qnil;
527
+ }
528
+
529
+ class R2TAO_POA_BlockedDeactivateObject : public R2TAO_POA_BlockedRegionCaller
530
+ {
531
+ public:
532
+ R2TAO_POA_BlockedDeactivateObject (PortableServer::POA_ptr _poa, PortableServer::ObjectId* oid)
533
+ : R2TAO_POA_BlockedRegionCaller (_poa),
534
+ oid_ (oid)
535
+ {}
536
+ virtual ~R2TAO_POA_BlockedDeactivateObject () {}
537
+
538
+ protected:
539
+ virtual VALUE do_exec ();
540
+
541
+ PortableServer::ObjectId_var oid_;
542
+ };
543
+
544
+ VALUE R2TAO_POA_BlockedDeactivateObject::do_exec ()
545
+ {
546
+ this->poa_->deactivate_object (this->oid_.in ());
547
+ return Qnil;
548
+ }
549
+
550
+ VALUE r2tao_POA_deactivate_object(VALUE self, VALUE oid)
551
+ {
552
+ R2TAO_TRY
553
+ {
554
+ try
555
+ {
556
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
557
+
558
+ R2TAO_POA_BlockedDeactivateObject blocked_deactobj (_poa.in (), r2tao_ObjectId_r2t(oid));
559
+ blocked_deactobj.call ();
560
+ }
561
+ catch (const PortableServer::POA::WrongPolicy& ex)
562
+ {
563
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
564
+ }
565
+ catch (const PortableServer::POA::ObjectNotActive& ex)
566
+ {
567
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ObjectNotActive));
568
+ }
569
+ }
570
+ R2TAO_CATCH;
571
+ return Qnil;
572
+ }
573
+
574
+ VALUE r2tao_POA_create_reference(VALUE self, VALUE repoid)
575
+ {
576
+ Check_Type(repoid, T_STRING);
577
+ R2TAO_TRY
578
+ {
579
+ try
580
+ {
581
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
582
+
583
+ CORBA::Object_var obj = _poa->create_reference (RSTRING_PTR (repoid));
584
+ return r2corba_Object_t2r(obj.in ());
585
+ }
586
+ catch (const PortableServer::POA::WrongPolicy& ex)
587
+ {
588
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
589
+ }
590
+ }
591
+ R2TAO_CATCH;
592
+ return Qnil;
593
+ }
594
+ VALUE r2tao_POA_create_reference_with_id(VALUE self, VALUE oid, VALUE repoid)
595
+ {
596
+ Check_Type(repoid, T_STRING);
597
+ R2TAO_TRY
598
+ {
599
+ try
600
+ {
601
+ PortableServer::ObjectId_var _oid = r2tao_ObjectId_r2t(oid);
602
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
603
+
604
+ CORBA::Object_var obj = _poa->create_reference_with_id (_oid.in (), RSTRING_PTR (repoid));
605
+ return r2corba_Object_t2r(obj.in ());
606
+ }
607
+ catch (const PortableServer::POA::WrongPolicy& ex)
608
+ {
609
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
610
+ }
611
+ }
612
+ R2TAO_CATCH;
613
+ return Qnil;
614
+ }
615
+ VALUE r2tao_POA_servant_to_id(VALUE self, VALUE servant)
616
+ {
617
+ r2tao_check_type(servant, r2tao_cServant);
618
+
619
+ R2TAO_TRY
620
+ {
621
+ try
622
+ {
623
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
624
+
625
+ DSI_Servant* _servant = static_cast<DSI_Servant*> (DATA_PTR (servant));
626
+ PortableServer::ObjectId_var _oid = _poa->servant_to_id (_servant);
627
+ return r2tao_ObjectId_t2r (_oid.in ());
628
+ }
629
+ catch (const PortableServer::POA::WrongPolicy& ex)
630
+ {
631
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
632
+ }
633
+ catch (const PortableServer::POA::ServantNotActive& ex)
634
+ {
635
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ServantNotActive));
636
+ }
637
+ }
638
+ R2TAO_CATCH;
639
+ return Qnil;
640
+ }
641
+ VALUE r2tao_POA_servant_to_reference(VALUE self, VALUE servant)
642
+ {
643
+ r2tao_check_type(servant, r2tao_cServant);
644
+
645
+ R2TAO_TRY
646
+ {
647
+ try
648
+ {
649
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
650
+
651
+ DSI_Servant* _servant = static_cast<DSI_Servant*> (DATA_PTR (servant));
652
+ CORBA::Object_var _obj = _poa->servant_to_reference (_servant);
653
+ return r2corba_Object_t2r(_obj.in ());
654
+ }
655
+ catch (const PortableServer::POA::WrongPolicy& ex)
656
+ {
657
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
658
+ }
659
+ catch (const PortableServer::POA::ServantNotActive& ex)
660
+ {
661
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ServantNotActive));
662
+ }
663
+ }
664
+ R2TAO_CATCH;
665
+ return Qnil;
666
+ }
667
+ VALUE r2tao_POA_reference_to_servant(VALUE self, VALUE obj)
668
+ {
669
+ R2TAO_TRY
670
+ {
671
+ try
672
+ {
673
+ CORBA::Object_ptr _obj = r2corba_Object_r2t (obj);
674
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
675
+
676
+ PortableServer::Servant _srv = _poa->reference_to_servant (_obj);
677
+ DSI_Servant* _servant = dynamic_cast<DSI_Servant*> (_srv);
678
+ return _servant->rbServant ();
679
+ }
680
+ catch (const PortableServer::POA::WrongPolicy& ex)
681
+ {
682
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
683
+ }
684
+ catch (const PortableServer::POA::ObjectNotActive& ex)
685
+ {
686
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ObjectNotActive));
687
+ }
688
+ catch (const PortableServer::POA::WrongAdapter& ex)
689
+ {
690
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongAdapter));
691
+ }
692
+ }
693
+ R2TAO_CATCH;
694
+ return Qnil;
695
+ }
696
+ VALUE r2tao_POA_reference_to_id(VALUE self, VALUE obj)
697
+ {
698
+ R2TAO_TRY
699
+ {
700
+ try
701
+ {
702
+ CORBA::Object_ptr _obj = r2corba_Object_r2t (obj);
703
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
704
+
705
+ PortableServer::ObjectId_var _oid = _poa->reference_to_id (_obj);
706
+ return r2tao_ObjectId_t2r (_oid.in ());
707
+ }
708
+ catch (const PortableServer::POA::WrongPolicy& ex)
709
+ {
710
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
711
+ }
712
+ catch (const PortableServer::POA::WrongAdapter& ex)
713
+ {
714
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongAdapter));
715
+ }
716
+ }
717
+ R2TAO_CATCH;
718
+ return Qnil;
719
+ }
720
+ VALUE r2tao_POA_id_to_servant(VALUE self, VALUE oid)
721
+ {
722
+ R2TAO_TRY
723
+ {
724
+ try
725
+ {
726
+ PortableServer::ObjectId_var _oid = r2tao_ObjectId_r2t(oid);
727
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
728
+
729
+ PortableServer::Servant _srv = _poa->id_to_servant (_oid.in ());
730
+ DSI_Servant* _servant = dynamic_cast<DSI_Servant*> (_srv);
731
+ return _servant->rbServant ();
732
+ }
733
+ catch (const PortableServer::POA::WrongPolicy& ex)
734
+ {
735
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
736
+ }
737
+ catch (const PortableServer::POA::ObjectNotActive& ex)
738
+ {
739
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ObjectNotActive));
740
+ }
741
+ }
742
+ R2TAO_CATCH;
743
+ return Qnil;
744
+ }
745
+ VALUE r2tao_POA_id_to_reference(VALUE self, VALUE oid)
746
+ {
747
+ R2TAO_TRY
748
+ {
749
+ try
750
+ {
751
+ PortableServer::ObjectId_var _oid = r2tao_ObjectId_r2t(oid);
752
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
753
+
754
+ CORBA::Object_var _obj = _poa->id_to_reference (_oid.in ());
755
+ return r2corba_Object_t2r(_obj.in ());
756
+ }
757
+ catch (const PortableServer::POA::WrongPolicy& ex)
758
+ {
759
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_WrongPolicy));
760
+ }
761
+ catch (const PortableServer::POA::ObjectNotActive& ex)
762
+ {
763
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_ObjectNotActive));
764
+ }
765
+ }
766
+ R2TAO_CATCH;
767
+ return Qnil;
768
+ }
769
+
770
+ VALUE r2tao_POA_create_POA(VALUE self, VALUE name, VALUE poaman, VALUE policies)
771
+ {
772
+ VALUE poaret = Qnil;
773
+ CORBA::ULong alen = 0;
774
+
775
+ name = rb_check_convert_type(name, T_STRING, "String", "to_s");
776
+ r2tao_check_type (poaman, r2tao_nsPOAManager);
777
+ if (policies != Qnil)
778
+ {
779
+ VALUE rPolicyList_tc = rb_eval_string ("CORBA::PolicyList._tc");
780
+ rb_funcall (rPolicyList_tc, rb_intern ("validate"), 1, policies);
781
+ alen = static_cast<unsigned long> (RARRAY_LEN (policies));
782
+ }
783
+
784
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
785
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (poaman);
786
+ R2TAO_TRY
787
+ {
788
+ try
789
+ {
790
+ CORBA::PolicyList pollist(alen);
791
+ pollist.length (alen);
792
+ for (CORBA::ULong l=0; l<alen ;++l)
793
+ {
794
+ VALUE pol = rb_ary_entry (policies, l);
795
+ CORBA::Object_ptr obj = r2corba_Object_r2t(pol);
796
+ pollist[l] = CORBA::Policy::_duplicate (dynamic_cast<CORBA::Policy_ptr> (obj));
797
+ }
798
+
799
+ PortableServer::POA_var _newpoa =
800
+ _poa->create_POA (RSTRING_PTR (name), _poa_man.in (), pollist);
801
+
802
+ poaret = r2corba_Object_t2r (dynamic_cast<CORBA::Object_ptr> (_newpoa.in ()));
803
+ poaret = FN_narrow.invoke (r2tao_nsPOA, 1, &poaret);
804
+ }
805
+ catch (const PortableServer::POA::InvalidPolicy& ex)
806
+ {
807
+ VALUE index = INT2NUM (ex.index);
808
+ rb_exc_raise (rb_class_new_instance (1, &index, r2tao_x_POA_InvalidPolicy));
809
+ }
810
+ catch (const PortableServer::POA::AdapterAlreadyExists& ex)
811
+ {
812
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_AdapterAlreadyExists));
813
+ }
814
+ }
815
+ R2TAO_CATCH;
816
+
817
+ return poaret;
818
+ }
819
+
820
+ VALUE r2tao_POA_find_POA(VALUE self, VALUE name, VALUE activate)
821
+ {
822
+ VALUE poaret = Qnil;
823
+
824
+ name = rb_check_convert_type(name, T_STRING, "String", "to_s");
825
+
826
+ R2TAO_TRY
827
+ {
828
+ try
829
+ {
830
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
831
+ PortableServer::POA_var _newpoa =
832
+ _poa->find_POA (RSTRING_PTR (name), activate == Qtrue);
833
+
834
+ poaret = r2corba_Object_t2r (dynamic_cast<CORBA::Object_ptr> (_newpoa.in ()));
835
+ poaret = FN_narrow.invoke (r2tao_nsPOA, 1, &poaret);
836
+ }
837
+ catch (const PortableServer::POA::AdapterNonExistent& ex)
838
+ {
839
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POA_AdapterNonExistent));
840
+ }
841
+ }
842
+ R2TAO_CATCH;
843
+
844
+ return poaret;
845
+ }
846
+
847
+ VALUE r2tao_POA_id(VALUE self)
848
+ {
849
+ VALUE rid = Qnil;
850
+ R2TAO_TRY
851
+ {
852
+ PortableServer::POA_var _poa = r2tao_POA_r2t (self);
853
+ CORBA::OctetSeq_var _id = _poa->id ();
854
+ rid = rb_funcall (rb_eval_string ("CORBA::OctetSeq"),
855
+ new_ID,
856
+ 1,
857
+ rb_str_new ((char*)_id->get_buffer (), (long)_id->length ()));
858
+ }
859
+ R2TAO_CATCH;
860
+ return rid;
861
+ }
862
+
863
+ //-------------------------------------------------------------------
864
+ // Ruby POAManager functions
865
+ //
866
+ //===================================================================
867
+
868
+ PortableServer::POAManager_ptr r2tao_POAManager_r2t(VALUE obj)
869
+ {
870
+ CORBA::Object_ptr _obj = r2corba_Object_r2t (obj);
871
+ return PortableServer::POAManager::_narrow (_obj);
872
+ }
873
+
874
+ class R2TAO_POAMan_BlockedRegionCaller : public R2TAO_POA_BlockedRegionCallerBase
875
+ {
876
+ public:
877
+ R2TAO_POAMan_BlockedRegionCaller (PortableServer::POAManager_ptr _poaman)
878
+ : poaman_ (PortableServer::POAManager::_duplicate (_poaman))
879
+ {}
880
+ virtual ~R2TAO_POAMan_BlockedRegionCaller () {}
881
+
882
+ protected:
883
+ //virtual VALUE do_exec () = 0;
884
+
885
+ PortableServer::POAManager_var poaman_;
886
+ };
887
+
888
+ class R2TAO_POAMan_BlockedActivate : public R2TAO_POAMan_BlockedRegionCaller
889
+ {
890
+ public:
891
+ R2TAO_POAMan_BlockedActivate (PortableServer::POAManager_ptr _poaman)
892
+ : R2TAO_POAMan_BlockedRegionCaller (_poaman)
893
+ {}
894
+ virtual ~R2TAO_POAMan_BlockedActivate () {}
895
+
896
+ protected:
897
+ virtual VALUE do_exec ();
898
+ };
899
+
900
+ VALUE R2TAO_POAMan_BlockedActivate::do_exec ()
901
+ {
902
+ this->poaman_->activate ();
903
+ return Qnil;
904
+ }
905
+
906
+ VALUE r2tao_POAManager_activate(VALUE self)
907
+ {
908
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
909
+ R2TAO_TRY
910
+ {
911
+ try
912
+ {
913
+ R2TAO_POAMan_BlockedActivate blocked_activate (_poa_man.in ());
914
+ blocked_activate.call ();
915
+ }
916
+ catch (const PortableServer::POAManager::AdapterInactive& ex)
917
+ {
918
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POAManager_AdapterInactive));
919
+ }
920
+ }
921
+ R2TAO_CATCH;
922
+ return Qnil;
923
+ }
924
+
925
+ class R2TAO_POAMan_BlockedHoldReq : public R2TAO_POAMan_BlockedRegionCaller
926
+ {
927
+ public:
928
+ R2TAO_POAMan_BlockedHoldReq (PortableServer::POAManager_ptr _poaman, bool _wait_for_completion)
929
+ : R2TAO_POAMan_BlockedRegionCaller (_poaman),
930
+ wait_for_completion_ (_wait_for_completion)
931
+ {}
932
+ virtual ~R2TAO_POAMan_BlockedHoldReq () {}
933
+
934
+ protected:
935
+ virtual VALUE do_exec ();
936
+
937
+ bool wait_for_completion_;
938
+ };
939
+
940
+ VALUE R2TAO_POAMan_BlockedHoldReq::do_exec ()
941
+ {
942
+ this->poaman_->hold_requests (this->wait_for_completion_);
943
+ return Qnil;
944
+ }
945
+
946
+ VALUE r2tao_POAManager_hold_requests(VALUE self, VALUE wait_for_completion)
947
+ {
948
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
949
+ R2TAO_TRY
950
+ {
951
+ try
952
+ {
953
+ R2TAO_POAMan_BlockedHoldReq blocked_holdreq (_poa_man.in (), wait_for_completion == Qtrue);
954
+ blocked_holdreq.call ();
955
+ }
956
+ catch (const PortableServer::POAManager::AdapterInactive& ex)
957
+ {
958
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POAManager_AdapterInactive));
959
+ }
960
+ }
961
+ R2TAO_CATCH;
962
+ return Qnil;
963
+ }
964
+
965
+ class R2TAO_POAMan_BlockedDiscardReq : public R2TAO_POAMan_BlockedRegionCaller
966
+ {
967
+ public:
968
+ R2TAO_POAMan_BlockedDiscardReq (PortableServer::POAManager_ptr _poaman, bool _wait_for_completion)
969
+ : R2TAO_POAMan_BlockedRegionCaller (_poaman),
970
+ wait_for_completion_ (_wait_for_completion)
971
+ {}
972
+ virtual ~R2TAO_POAMan_BlockedDiscardReq () {}
973
+
974
+ protected:
975
+ virtual VALUE do_exec ();
976
+
977
+ bool wait_for_completion_;
978
+ };
979
+
980
+ VALUE R2TAO_POAMan_BlockedDiscardReq::do_exec ()
981
+ {
982
+ this->poaman_->discard_requests (this->wait_for_completion_);
983
+ return Qnil;
984
+ }
985
+
986
+ VALUE r2tao_POAManager_discard_requests(VALUE self, VALUE wait_for_completion)
987
+ {
988
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
989
+ R2TAO_TRY
990
+ {
991
+ try
992
+ {
993
+ R2TAO_POAMan_BlockedDiscardReq blocked_discardreq (_poa_man.in (), wait_for_completion == Qtrue);
994
+ blocked_discardreq.call ();
995
+ }
996
+ catch (const PortableServer::POAManager::AdapterInactive& ex)
997
+ {
998
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POAManager_AdapterInactive));
999
+ }
1000
+ }
1001
+ R2TAO_CATCH;
1002
+ return Qnil;
1003
+ }
1004
+
1005
+ class R2TAO_POAMan_BlockedDeactivate : public R2TAO_POAMan_BlockedRegionCaller
1006
+ {
1007
+ public:
1008
+ R2TAO_POAMan_BlockedDeactivate (PortableServer::POAManager_ptr _poaman, bool _etherealize, bool _wait_for_completion)
1009
+ : R2TAO_POAMan_BlockedRegionCaller (_poaman),
1010
+ etherealize_ (_etherealize),
1011
+ wait_for_completion_ (_wait_for_completion)
1012
+ {}
1013
+ virtual ~R2TAO_POAMan_BlockedDeactivate () {}
1014
+
1015
+ protected:
1016
+ virtual VALUE do_exec ();
1017
+
1018
+ bool etherealize_;
1019
+ bool wait_for_completion_;
1020
+ };
1021
+
1022
+ VALUE R2TAO_POAMan_BlockedDeactivate::do_exec ()
1023
+ {
1024
+ this->poaman_->deactivate (this->etherealize_, this->wait_for_completion_);
1025
+ return Qnil;
1026
+ }
1027
+
1028
+ VALUE r2tao_POAManager_deactivate(VALUE self, VALUE etherealize, VALUE wait_for_completion)
1029
+ {
1030
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
1031
+ R2TAO_TRY
1032
+ {
1033
+ try
1034
+ {
1035
+ R2TAO_POAMan_BlockedDeactivate blocked_deactivate (_poa_man.in (), etherealize == Qtrue, wait_for_completion == Qtrue);
1036
+ blocked_deactivate.call ();
1037
+ }
1038
+ catch (const PortableServer::POAManager::AdapterInactive& ex)
1039
+ {
1040
+ rb_exc_raise (rb_class_new_instance (0, 0, r2tao_x_POAManager_AdapterInactive));
1041
+ }
1042
+ }
1043
+ R2TAO_CATCH;
1044
+ return Qnil;
1045
+ }
1046
+ VALUE r2tao_POAManager_get_state(VALUE self)
1047
+ {
1048
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
1049
+ R2TAO_TRY
1050
+ {
1051
+ return ULONG2NUM (static_cast<unsigned long> (_poa_man->get_state ()));
1052
+ }
1053
+ R2TAO_CATCH;
1054
+ return Qnil;
1055
+ }
1056
+ VALUE r2tao_POAManager_get_id(VALUE self)
1057
+ {
1058
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
1059
+ R2TAO_TRY
1060
+ {
1061
+ return rb_str_new2 (_poa_man->get_id ());
1062
+ }
1063
+ R2TAO_CATCH;
1064
+ return Qnil;
1065
+ }
1066
+ VALUE r2tao_POAManager_get_orb(VALUE self)
1067
+ {
1068
+ PortableServer::POAManager_var _poa_man = r2tao_POAManager_r2t (self);
1069
+ R2TAO_TRY
1070
+ {
1071
+ CORBA::ORB_var _orb = _poa_man->_get_orb ();
1072
+ return r2corba_ORB_t2r(_orb.in ());
1073
+ }
1074
+ R2TAO_CATCH;
1075
+ return Qnil;
1076
+ }