rice 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/COPYING +2 -2
  2. data/Doxyfile +1 -1
  3. data/Makefile.in +8 -3
  4. data/Rakefile +3 -3
  5. data/config.guess +30 -49
  6. data/config.sub +4 -22
  7. data/configure +319 -104
  8. data/configure.ac +6 -2
  9. data/doxygen.ac +2 -2
  10. data/extconf.rb +22 -0
  11. data/post-autoconf.rb +3 -3
  12. data/post-automake.rb +2 -2
  13. data/rice/Array.ipp +7 -6
  14. data/rice/Critical_Guard.hpp +6 -0
  15. data/rice/Critical_Guard.ipp +6 -0
  16. data/rice/Data_Object.hpp +1 -120
  17. data/rice/Data_Object.ipp +5 -1
  18. data/rice/Data_Object_defn.hpp +132 -0
  19. data/rice/Data_Type.ipp +18 -2
  20. data/rice/Enum.ipp +3 -3
  21. data/rice/Exception.hpp +1 -61
  22. data/rice/Exception_Base.hpp +2 -24
  23. data/rice/Exception_Base.ipp +2 -0
  24. data/rice/Exception_Base_defn.hpp +27 -0
  25. data/rice/Exception_defn.hpp +69 -0
  26. data/rice/Hash.hpp +5 -1
  27. data/rice/Hash.ipp +7 -7
  28. data/rice/Makefile.am +20 -3
  29. data/rice/Makefile.in +39 -4
  30. data/rice/Module.cpp +11 -3
  31. data/rice/Module_impl.hpp +20 -9
  32. data/rice/Module_impl.ipp +84 -87
  33. data/rice/Object.cpp +1 -1
  34. data/rice/VM.cpp +14 -1
  35. data/rice/VM.hpp +6 -1
  36. data/rice/config.hpp +24 -3
  37. data/rice/config.hpp.in +21 -0
  38. data/rice/detail/Auto_Function_Wrapper.hpp +97 -65
  39. data/rice/detail/Auto_Function_Wrapper.ipp +160 -128
  40. data/rice/detail/Auto_Member_Function_Wrapper.hpp +96 -64
  41. data/rice/detail/Auto_Member_Function_Wrapper.ipp +160 -128
  42. data/rice/detail/Exception_Handler.hpp +2 -112
  43. data/rice/detail/Exception_Handler.ipp +68 -0
  44. data/rice/detail/Exception_Handler_defn.hpp +96 -0
  45. data/rice/detail/Iterator.hpp +93 -0
  46. data/rice/detail/check_ruby_type.cpp +8 -2
  47. data/rice/detail/creation_funcs.ipp +2 -2
  48. data/rice/detail/define_method_and_auto_wrap.hpp +4 -2
  49. data/rice/detail/define_method_and_auto_wrap.ipp +14 -5
  50. data/rice/detail/env.hpp +4 -0
  51. data/rice/detail/method_data.cpp +362 -75
  52. data/rice/detail/method_data.cpp.rpp +301 -0
  53. data/rice/detail/method_data.hpp +6 -18
  54. data/rice/detail/mininode.cpp +1220 -0
  55. data/rice/detail/mininode.cpp.rpp +62 -0
  56. data/rice/detail/mininode.hpp +320 -0
  57. data/rice/detail/mininode.hpp.rpp +119 -0
  58. data/rice/detail/protect.cpp +4 -2
  59. data/rice/detail/ruby.hpp +44 -18
  60. data/rice/detail/ruby_version_code.hpp +6 -0
  61. data/rice/detail/ruby_version_code.hpp.in +6 -0
  62. data/rice/detail/rubysig.hpp +6 -0
  63. data/rice/detail/st.hpp +6 -2
  64. data/rice/detail/wrap_function.hpp +50 -48
  65. data/rice/detail/wrap_function.ipp +48 -48
  66. data/rice/generate_code.rb +43 -293
  67. data/rice/global_function.hpp +10 -4
  68. data/rice/global_function.ipp +1 -2
  69. data/rice/ruby_mark.hpp +13 -0
  70. data/rice/ruby_try_catch.hpp +1 -1
  71. data/rice/rubypp.rb +97 -0
  72. data/rice/to_from_ruby.ipp +3 -3
  73. data/ruby.ac +44 -8
  74. data/ruby/Makefile.in +2 -0
  75. data/ruby/lib/Makefile.in +2 -0
  76. data/ruby/lib/mkmf-rice.rb.in +4 -1
  77. data/ruby/lib/version.rb +3 -0
  78. data/sample/Makefile.am +2 -2
  79. data/sample/Makefile.in +4 -2
  80. data/test/Makefile.am +2 -1
  81. data/test/Makefile.in +7 -2
  82. data/test/test_Array.cpp +2 -2
  83. data/test/test_Class.cpp +4 -1
  84. data/test/test_Critical_Guard.cpp +4 -0
  85. data/test/test_Data_Object.cpp +43 -3
  86. data/test/test_Hash.cpp +3 -3
  87. data/test/test_String.cpp +8 -8
  88. data/test/test_VM.cpp +1 -1
  89. data/test/test_global_functions.cpp +45 -0
  90. data/test/test_rice.rb +5 -0
  91. metadata +115 -98
  92. data/rice/detail/Iterator_Definer.hpp +0 -98
@@ -20,10 +20,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
20
20
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T>::
21
21
  Auto_Function_Wrapper(
22
22
  Func func,
23
- Exception_Handler const * handler)
23
+ Data_Object<Exception_Handler> handler)
24
24
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
25
25
  , func_(func)
26
- , handler_(handler ? handler : new Default_Exception_Handler)
26
+ , handler_(handler)
27
+ , handler_guard_(&handler_)
27
28
  {
28
29
  }
29
30
 
@@ -34,8 +35,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
34
35
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T> * wrapper = 0;
35
36
  try
36
37
  {
37
- void * data = detail::method_data();
38
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T> *)data;
38
+ Data_Object<Wrapped_Function> data(detail::method_data());
39
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T> *)data.get();
39
40
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12)); Arg13_T arg13(from_ruby<Arg13_T>(ruby_arg13)); Arg14_T arg14(from_ruby<Arg14_T>(ruby_arg14)); Arg15_T arg15(from_ruby<Arg15_T>(ruby_arg15));
40
41
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15));
41
42
  }
@@ -60,10 +61,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
60
61
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T>::
61
62
  Auto_Function_Wrapper(
62
63
  Func func,
63
- Exception_Handler const * handler)
64
+ Data_Object<Exception_Handler> handler)
64
65
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
65
66
  , func_(func)
66
- , handler_(handler ? handler : new Default_Exception_Handler)
67
+ , handler_(handler)
68
+ , handler_guard_(&handler_)
67
69
  {
68
70
  }
69
71
 
@@ -74,9 +76,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
74
76
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T> * wrapper = 0;
75
77
  try
76
78
  {
77
- void * data = detail::method_data();
79
+ Data_Object<Wrapped_Function> data(detail::method_data());
78
80
  wrapper =
79
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T> *)data;
81
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T, Arg15_T> *)data.get();
80
82
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12)); Arg13_T arg13(from_ruby<Arg13_T>(ruby_arg13)); Arg14_T arg14(from_ruby<Arg14_T>(ruby_arg14)); Arg15_T arg15(from_ruby<Arg15_T>(ruby_arg15));
81
83
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
82
84
  return Qnil;
@@ -103,10 +105,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
103
105
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T>::
104
106
  Auto_Function_Wrapper(
105
107
  Func func,
106
- Exception_Handler const * handler)
108
+ Data_Object<Exception_Handler> handler)
107
109
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
108
110
  , func_(func)
109
- , handler_(handler ? handler : new Default_Exception_Handler)
111
+ , handler_(handler)
112
+ , handler_guard_(&handler_)
110
113
  {
111
114
  }
112
115
 
@@ -117,8 +120,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
117
120
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T> * wrapper = 0;
118
121
  try
119
122
  {
120
- void * data = detail::method_data();
121
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T> *)data;
123
+ Data_Object<Wrapped_Function> data(detail::method_data());
124
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T> *)data.get();
122
125
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12)); Arg13_T arg13(from_ruby<Arg13_T>(ruby_arg13)); Arg14_T arg14(from_ruby<Arg14_T>(ruby_arg14));
123
126
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14));
124
127
  }
@@ -143,10 +146,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
143
146
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T>::
144
147
  Auto_Function_Wrapper(
145
148
  Func func,
146
- Exception_Handler const * handler)
149
+ Data_Object<Exception_Handler> handler)
147
150
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
148
151
  , func_(func)
149
- , handler_(handler ? handler : new Default_Exception_Handler)
152
+ , handler_(handler)
153
+ , handler_guard_(&handler_)
150
154
  {
151
155
  }
152
156
 
@@ -157,9 +161,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
157
161
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T> * wrapper = 0;
158
162
  try
159
163
  {
160
- void * data = detail::method_data();
164
+ Data_Object<Wrapped_Function> data(detail::method_data());
161
165
  wrapper =
162
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T> *)data;
166
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T, Arg14_T> *)data.get();
163
167
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12)); Arg13_T arg13(from_ruby<Arg13_T>(ruby_arg13)); Arg14_T arg14(from_ruby<Arg14_T>(ruby_arg14));
164
168
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
165
169
  return Qnil;
@@ -186,10 +190,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
186
190
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T>::
187
191
  Auto_Function_Wrapper(
188
192
  Func func,
189
- Exception_Handler const * handler)
193
+ Data_Object<Exception_Handler> handler)
190
194
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
191
195
  , func_(func)
192
- , handler_(handler ? handler : new Default_Exception_Handler)
196
+ , handler_(handler)
197
+ , handler_guard_(&handler_)
193
198
  {
194
199
  }
195
200
 
@@ -200,8 +205,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
200
205
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T> * wrapper = 0;
201
206
  try
202
207
  {
203
- void * data = detail::method_data();
204
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T> *)data;
208
+ Data_Object<Wrapped_Function> data(detail::method_data());
209
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T> *)data.get();
205
210
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12)); Arg13_T arg13(from_ruby<Arg13_T>(ruby_arg13));
206
211
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13));
207
212
  }
@@ -226,10 +231,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
226
231
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T>::
227
232
  Auto_Function_Wrapper(
228
233
  Func func,
229
- Exception_Handler const * handler)
234
+ Data_Object<Exception_Handler> handler)
230
235
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
231
236
  , func_(func)
232
- , handler_(handler ? handler : new Default_Exception_Handler)
237
+ , handler_(handler)
238
+ , handler_guard_(&handler_)
233
239
  {
234
240
  }
235
241
 
@@ -240,9 +246,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
240
246
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T> * wrapper = 0;
241
247
  try
242
248
  {
243
- void * data = detail::method_data();
249
+ Data_Object<Wrapped_Function> data(detail::method_data());
244
250
  wrapper =
245
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T> *)data;
251
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T, Arg13_T> *)data.get();
246
252
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12)); Arg13_T arg13(from_ruby<Arg13_T>(ruby_arg13));
247
253
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
248
254
  return Qnil;
@@ -269,10 +275,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
269
275
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T>::
270
276
  Auto_Function_Wrapper(
271
277
  Func func,
272
- Exception_Handler const * handler)
278
+ Data_Object<Exception_Handler> handler)
273
279
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
274
280
  , func_(func)
275
- , handler_(handler ? handler : new Default_Exception_Handler)
281
+ , handler_(handler)
282
+ , handler_guard_(&handler_)
276
283
  {
277
284
  }
278
285
 
@@ -283,8 +290,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
283
290
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T> * wrapper = 0;
284
291
  try
285
292
  {
286
- void * data = detail::method_data();
287
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T> *)data;
293
+ Data_Object<Wrapped_Function> data(detail::method_data());
294
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T> *)data.get();
288
295
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12));
289
296
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12));
290
297
  }
@@ -309,10 +316,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
309
316
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T>::
310
317
  Auto_Function_Wrapper(
311
318
  Func func,
312
- Exception_Handler const * handler)
319
+ Data_Object<Exception_Handler> handler)
313
320
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
314
321
  , func_(func)
315
- , handler_(handler ? handler : new Default_Exception_Handler)
322
+ , handler_(handler)
323
+ , handler_guard_(&handler_)
316
324
  {
317
325
  }
318
326
 
@@ -323,9 +331,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
323
331
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T> * wrapper = 0;
324
332
  try
325
333
  {
326
- void * data = detail::method_data();
334
+ Data_Object<Wrapped_Function> data(detail::method_data());
327
335
  wrapper =
328
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T> *)data;
336
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T, Arg12_T> *)data.get();
329
337
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11)); Arg12_T arg12(from_ruby<Arg12_T>(ruby_arg12));
330
338
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
331
339
  return Qnil;
@@ -352,10 +360,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
352
360
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T>::
353
361
  Auto_Function_Wrapper(
354
362
  Func func,
355
- Exception_Handler const * handler)
363
+ Data_Object<Exception_Handler> handler)
356
364
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
357
365
  , func_(func)
358
- , handler_(handler ? handler : new Default_Exception_Handler)
366
+ , handler_(handler)
367
+ , handler_guard_(&handler_)
359
368
  {
360
369
  }
361
370
 
@@ -366,8 +375,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
366
375
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T> * wrapper = 0;
367
376
  try
368
377
  {
369
- void * data = detail::method_data();
370
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T> *)data;
378
+ Data_Object<Wrapped_Function> data(detail::method_data());
379
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T> *)data.get();
371
380
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11));
372
381
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11));
373
382
  }
@@ -392,10 +401,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
392
401
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T>::
393
402
  Auto_Function_Wrapper(
394
403
  Func func,
395
- Exception_Handler const * handler)
404
+ Data_Object<Exception_Handler> handler)
396
405
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
397
406
  , func_(func)
398
- , handler_(handler ? handler : new Default_Exception_Handler)
407
+ , handler_(handler)
408
+ , handler_guard_(&handler_)
399
409
  {
400
410
  }
401
411
 
@@ -406,9 +416,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
406
416
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T> * wrapper = 0;
407
417
  try
408
418
  {
409
- void * data = detail::method_data();
419
+ Data_Object<Wrapped_Function> data(detail::method_data());
410
420
  wrapper =
411
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T> *)data;
421
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T, Arg11_T> *)data.get();
412
422
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10)); Arg11_T arg11(from_ruby<Arg11_T>(ruby_arg11));
413
423
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
414
424
  return Qnil;
@@ -435,10 +445,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
435
445
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T>::
436
446
  Auto_Function_Wrapper(
437
447
  Func func,
438
- Exception_Handler const * handler)
448
+ Data_Object<Exception_Handler> handler)
439
449
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
440
450
  , func_(func)
441
- , handler_(handler ? handler : new Default_Exception_Handler)
451
+ , handler_(handler)
452
+ , handler_guard_(&handler_)
442
453
  {
443
454
  }
444
455
 
@@ -449,8 +460,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
449
460
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T> * wrapper = 0;
450
461
  try
451
462
  {
452
- void * data = detail::method_data();
453
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T> *)data;
463
+ Data_Object<Wrapped_Function> data(detail::method_data());
464
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T> *)data.get();
454
465
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10));
455
466
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10));
456
467
  }
@@ -475,10 +486,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
475
486
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T>::
476
487
  Auto_Function_Wrapper(
477
488
  Func func,
478
- Exception_Handler const * handler)
489
+ Data_Object<Exception_Handler> handler)
479
490
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
480
491
  , func_(func)
481
- , handler_(handler ? handler : new Default_Exception_Handler)
492
+ , handler_(handler)
493
+ , handler_guard_(&handler_)
482
494
  {
483
495
  }
484
496
 
@@ -489,9 +501,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
489
501
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T> * wrapper = 0;
490
502
  try
491
503
  {
492
- void * data = detail::method_data();
504
+ Data_Object<Wrapped_Function> data(detail::method_data());
493
505
  wrapper =
494
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T> *)data;
506
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T, Arg10_T> *)data.get();
495
507
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9)); Arg10_T arg10(from_ruby<Arg10_T>(ruby_arg10));
496
508
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
497
509
  return Qnil;
@@ -518,10 +530,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
518
530
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T>::
519
531
  Auto_Function_Wrapper(
520
532
  Func func,
521
- Exception_Handler const * handler)
533
+ Data_Object<Exception_Handler> handler)
522
534
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
523
535
  , func_(func)
524
- , handler_(handler ? handler : new Default_Exception_Handler)
536
+ , handler_(handler)
537
+ , handler_guard_(&handler_)
525
538
  {
526
539
  }
527
540
 
@@ -532,8 +545,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
532
545
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T> * wrapper = 0;
533
546
  try
534
547
  {
535
- void * data = detail::method_data();
536
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T> *)data;
548
+ Data_Object<Wrapped_Function> data(detail::method_data());
549
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T> *)data.get();
537
550
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9));
538
551
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9));
539
552
  }
@@ -558,10 +571,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
558
571
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T>::
559
572
  Auto_Function_Wrapper(
560
573
  Func func,
561
- Exception_Handler const * handler)
574
+ Data_Object<Exception_Handler> handler)
562
575
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
563
576
  , func_(func)
564
- , handler_(handler ? handler : new Default_Exception_Handler)
577
+ , handler_(handler)
578
+ , handler_guard_(&handler_)
565
579
  {
566
580
  }
567
581
 
@@ -572,9 +586,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
572
586
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T> * wrapper = 0;
573
587
  try
574
588
  {
575
- void * data = detail::method_data();
589
+ Data_Object<Wrapped_Function> data(detail::method_data());
576
590
  wrapper =
577
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T> *)data;
591
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T, Arg9_T> *)data.get();
578
592
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8)); Arg9_T arg9(from_ruby<Arg9_T>(ruby_arg9));
579
593
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
580
594
  return Qnil;
@@ -601,10 +615,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
601
615
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T>::
602
616
  Auto_Function_Wrapper(
603
617
  Func func,
604
- Exception_Handler const * handler)
618
+ Data_Object<Exception_Handler> handler)
605
619
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
606
620
  , func_(func)
607
- , handler_(handler ? handler : new Default_Exception_Handler)
621
+ , handler_(handler)
622
+ , handler_guard_(&handler_)
608
623
  {
609
624
  }
610
625
 
@@ -615,8 +630,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
615
630
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T> * wrapper = 0;
616
631
  try
617
632
  {
618
- void * data = detail::method_data();
619
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T> *)data;
633
+ Data_Object<Wrapped_Function> data(detail::method_data());
634
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T> *)data.get();
620
635
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8));
621
636
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8));
622
637
  }
@@ -641,10 +656,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
641
656
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T>::
642
657
  Auto_Function_Wrapper(
643
658
  Func func,
644
- Exception_Handler const * handler)
659
+ Data_Object<Exception_Handler> handler)
645
660
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
646
661
  , func_(func)
647
- , handler_(handler ? handler : new Default_Exception_Handler)
662
+ , handler_(handler)
663
+ , handler_guard_(&handler_)
648
664
  {
649
665
  }
650
666
 
@@ -655,9 +671,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
655
671
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T> * wrapper = 0;
656
672
  try
657
673
  {
658
- void * data = detail::method_data();
674
+ Data_Object<Wrapped_Function> data(detail::method_data());
659
675
  wrapper =
660
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T> *)data;
676
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T, Arg8_T> *)data.get();
661
677
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7)); Arg8_T arg8(from_ruby<Arg8_T>(ruby_arg8));
662
678
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
663
679
  return Qnil;
@@ -684,10 +700,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
684
700
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T>::
685
701
  Auto_Function_Wrapper(
686
702
  Func func,
687
- Exception_Handler const * handler)
703
+ Data_Object<Exception_Handler> handler)
688
704
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
689
705
  , func_(func)
690
- , handler_(handler ? handler : new Default_Exception_Handler)
706
+ , handler_(handler)
707
+ , handler_guard_(&handler_)
691
708
  {
692
709
  }
693
710
 
@@ -698,8 +715,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
698
715
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T> * wrapper = 0;
699
716
  try
700
717
  {
701
- void * data = detail::method_data();
702
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T> *)data;
718
+ Data_Object<Wrapped_Function> data(detail::method_data());
719
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T> *)data.get();
703
720
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7));
704
721
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7));
705
722
  }
@@ -724,10 +741,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
724
741
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T>::
725
742
  Auto_Function_Wrapper(
726
743
  Func func,
727
- Exception_Handler const * handler)
744
+ Data_Object<Exception_Handler> handler)
728
745
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
729
746
  , func_(func)
730
- , handler_(handler ? handler : new Default_Exception_Handler)
747
+ , handler_(handler)
748
+ , handler_guard_(&handler_)
731
749
  {
732
750
  }
733
751
 
@@ -738,9 +756,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
738
756
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T> * wrapper = 0;
739
757
  try
740
758
  {
741
- void * data = detail::method_data();
759
+ Data_Object<Wrapped_Function> data(detail::method_data());
742
760
  wrapper =
743
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T> *)data;
761
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T, Arg7_T> *)data.get();
744
762
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6)); Arg7_T arg7(from_ruby<Arg7_T>(ruby_arg7));
745
763
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
746
764
  return Qnil;
@@ -767,10 +785,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
767
785
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T>::
768
786
  Auto_Function_Wrapper(
769
787
  Func func,
770
- Exception_Handler const * handler)
788
+ Data_Object<Exception_Handler> handler)
771
789
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
772
790
  , func_(func)
773
- , handler_(handler ? handler : new Default_Exception_Handler)
791
+ , handler_(handler)
792
+ , handler_guard_(&handler_)
774
793
  {
775
794
  }
776
795
 
@@ -781,8 +800,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
781
800
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T> * wrapper = 0;
782
801
  try
783
802
  {
784
- void * data = detail::method_data();
785
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T> *)data;
803
+ Data_Object<Wrapped_Function> data(detail::method_data());
804
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T> *)data.get();
786
805
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6));
787
806
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6));
788
807
  }
@@ -807,10 +826,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
807
826
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T>::
808
827
  Auto_Function_Wrapper(
809
828
  Func func,
810
- Exception_Handler const * handler)
829
+ Data_Object<Exception_Handler> handler)
811
830
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
812
831
  , func_(func)
813
- , handler_(handler ? handler : new Default_Exception_Handler)
832
+ , handler_(handler)
833
+ , handler_guard_(&handler_)
814
834
  {
815
835
  }
816
836
 
@@ -821,9 +841,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
821
841
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T> * wrapper = 0;
822
842
  try
823
843
  {
824
- void * data = detail::method_data();
844
+ Data_Object<Wrapped_Function> data(detail::method_data());
825
845
  wrapper =
826
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T> *)data;
846
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T, Arg6_T> *)data.get();
827
847
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5)); Arg6_T arg6(from_ruby<Arg6_T>(ruby_arg6));
828
848
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
829
849
  return Qnil;
@@ -850,10 +870,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
850
870
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T>::
851
871
  Auto_Function_Wrapper(
852
872
  Func func,
853
- Exception_Handler const * handler)
873
+ Data_Object<Exception_Handler> handler)
854
874
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
855
875
  , func_(func)
856
- , handler_(handler ? handler : new Default_Exception_Handler)
876
+ , handler_(handler)
877
+ , handler_guard_(&handler_)
857
878
  {
858
879
  }
859
880
 
@@ -864,8 +885,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
864
885
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T> * wrapper = 0;
865
886
  try
866
887
  {
867
- void * data = detail::method_data();
868
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T> *)data;
888
+ Data_Object<Wrapped_Function> data(detail::method_data());
889
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T> *)data.get();
869
890
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5));
870
891
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5));
871
892
  }
@@ -890,10 +911,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
890
911
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T>::
891
912
  Auto_Function_Wrapper(
892
913
  Func func,
893
- Exception_Handler const * handler)
914
+ Data_Object<Exception_Handler> handler)
894
915
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
895
916
  , func_(func)
896
- , handler_(handler ? handler : new Default_Exception_Handler)
917
+ , handler_(handler)
918
+ , handler_guard_(&handler_)
897
919
  {
898
920
  }
899
921
 
@@ -904,9 +926,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
904
926
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T> * wrapper = 0;
905
927
  try
906
928
  {
907
- void * data = detail::method_data();
929
+ Data_Object<Wrapped_Function> data(detail::method_data());
908
930
  wrapper =
909
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T> *)data;
931
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T, Arg5_T> *)data.get();
910
932
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4)); Arg5_T arg5(from_ruby<Arg5_T>(ruby_arg5));
911
933
  wrapper->func_(arg0, arg1, arg2, arg3, arg4, arg5);
912
934
  return Qnil;
@@ -933,10 +955,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
933
955
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T>::
934
956
  Auto_Function_Wrapper(
935
957
  Func func,
936
- Exception_Handler const * handler)
958
+ Data_Object<Exception_Handler> handler)
937
959
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
938
960
  , func_(func)
939
- , handler_(handler ? handler : new Default_Exception_Handler)
961
+ , handler_(handler)
962
+ , handler_guard_(&handler_)
940
963
  {
941
964
  }
942
965
 
@@ -947,8 +970,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
947
970
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T> * wrapper = 0;
948
971
  try
949
972
  {
950
- void * data = detail::method_data();
951
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T> *)data;
973
+ Data_Object<Wrapped_Function> data(detail::method_data());
974
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T> *)data.get();
952
975
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4));
953
976
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3, arg4));
954
977
  }
@@ -973,10 +996,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
973
996
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T>::
974
997
  Auto_Function_Wrapper(
975
998
  Func func,
976
- Exception_Handler const * handler)
999
+ Data_Object<Exception_Handler> handler)
977
1000
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
978
1001
  , func_(func)
979
- , handler_(handler ? handler : new Default_Exception_Handler)
1002
+ , handler_(handler)
1003
+ , handler_guard_(&handler_)
980
1004
  {
981
1005
  }
982
1006
 
@@ -987,9 +1011,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3, VALUE r
987
1011
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T> * wrapper = 0;
988
1012
  try
989
1013
  {
990
- void * data = detail::method_data();
1014
+ Data_Object<Wrapped_Function> data(detail::method_data());
991
1015
  wrapper =
992
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T> *)data;
1016
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T, Arg4_T> *)data.get();
993
1017
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3)); Arg4_T arg4(from_ruby<Arg4_T>(ruby_arg4));
994
1018
  wrapper->func_(arg0, arg1, arg2, arg3, arg4);
995
1019
  return Qnil;
@@ -1016,10 +1040,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
1016
1040
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T>::
1017
1041
  Auto_Function_Wrapper(
1018
1042
  Func func,
1019
- Exception_Handler const * handler)
1043
+ Data_Object<Exception_Handler> handler)
1020
1044
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1021
1045
  , func_(func)
1022
- , handler_(handler ? handler : new Default_Exception_Handler)
1046
+ , handler_(handler)
1047
+ , handler_guard_(&handler_)
1023
1048
  {
1024
1049
  }
1025
1050
 
@@ -1030,8 +1055,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3)
1030
1055
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T> * wrapper = 0;
1031
1056
  try
1032
1057
  {
1033
- void * data = detail::method_data();
1034
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T> *)data;
1058
+ Data_Object<Wrapped_Function> data(detail::method_data());
1059
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T, Arg3_T> *)data.get();
1035
1060
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3));
1036
1061
  return to_ruby(wrapper->func_(arg0, arg1, arg2, arg3));
1037
1062
  }
@@ -1056,10 +1081,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T, typ
1056
1081
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T>::
1057
1082
  Auto_Function_Wrapper(
1058
1083
  Func func,
1059
- Exception_Handler const * handler)
1084
+ Data_Object<Exception_Handler> handler)
1060
1085
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1061
1086
  , func_(func)
1062
- , handler_(handler ? handler : new Default_Exception_Handler)
1087
+ , handler_(handler)
1088
+ , handler_guard_(&handler_)
1063
1089
  {
1064
1090
  }
1065
1091
 
@@ -1070,9 +1096,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2, VALUE ruby_arg3)
1070
1096
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T> * wrapper = 0;
1071
1097
  try
1072
1098
  {
1073
- void * data = detail::method_data();
1099
+ Data_Object<Wrapped_Function> data(detail::method_data());
1074
1100
  wrapper =
1075
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T> *)data;
1101
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T, Arg3_T> *)data.get();
1076
1102
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2)); Arg3_T arg3(from_ruby<Arg3_T>(ruby_arg3));
1077
1103
  wrapper->func_(arg0, arg1, arg2, arg3);
1078
1104
  return Qnil;
@@ -1099,10 +1125,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T, type
1099
1125
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T>::
1100
1126
  Auto_Function_Wrapper(
1101
1127
  Func func,
1102
- Exception_Handler const * handler)
1128
+ Data_Object<Exception_Handler> handler)
1103
1129
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1104
1130
  , func_(func)
1105
- , handler_(handler ? handler : new Default_Exception_Handler)
1131
+ , handler_(handler)
1132
+ , handler_guard_(&handler_)
1106
1133
  {
1107
1134
  }
1108
1135
 
@@ -1113,8 +1140,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2)
1113
1140
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T> * wrapper = 0;
1114
1141
  try
1115
1142
  {
1116
- void * data = detail::method_data();
1117
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T> *)data;
1143
+ Data_Object<Wrapped_Function> data(detail::method_data());
1144
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T, Arg2_T> *)data.get();
1118
1145
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2));
1119
1146
  return to_ruby(wrapper->func_(arg0, arg1, arg2));
1120
1147
  }
@@ -1139,10 +1166,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T, typename Arg2_T>
1139
1166
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T>::
1140
1167
  Auto_Function_Wrapper(
1141
1168
  Func func,
1142
- Exception_Handler const * handler)
1169
+ Data_Object<Exception_Handler> handler)
1143
1170
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1144
1171
  , func_(func)
1145
- , handler_(handler ? handler : new Default_Exception_Handler)
1172
+ , handler_(handler)
1173
+ , handler_guard_(&handler_)
1146
1174
  {
1147
1175
  }
1148
1176
 
@@ -1153,9 +1181,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1, VALUE ruby_arg2)
1153
1181
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T> * wrapper = 0;
1154
1182
  try
1155
1183
  {
1156
- void * data = detail::method_data();
1184
+ Data_Object<Wrapped_Function> data(detail::method_data());
1157
1185
  wrapper =
1158
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T> *)data;
1186
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T, Arg2_T> *)data.get();
1159
1187
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1)); Arg2_T arg2(from_ruby<Arg2_T>(ruby_arg2));
1160
1188
  wrapper->func_(arg0, arg1, arg2);
1161
1189
  return Qnil;
@@ -1182,10 +1210,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T, typename Arg1_T>
1182
1210
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T>::
1183
1211
  Auto_Function_Wrapper(
1184
1212
  Func func,
1185
- Exception_Handler const * handler)
1213
+ Data_Object<Exception_Handler> handler)
1186
1214
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1187
1215
  , func_(func)
1188
- , handler_(handler ? handler : new Default_Exception_Handler)
1216
+ , handler_(handler)
1217
+ , handler_guard_(&handler_)
1189
1218
  {
1190
1219
  }
1191
1220
 
@@ -1196,8 +1225,8 @@ call(VALUE ruby_arg0, VALUE ruby_arg1)
1196
1225
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T> * wrapper = 0;
1197
1226
  try
1198
1227
  {
1199
- void * data = detail::method_data();
1200
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T> *)data;
1228
+ Data_Object<Wrapped_Function> data(detail::method_data());
1229
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T, Arg1_T> *)data.get();
1201
1230
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1));
1202
1231
  return to_ruby(wrapper->func_(arg0, arg1));
1203
1232
  }
@@ -1222,10 +1251,11 @@ template<typename Func_T, typename Arg0_T, typename Arg1_T>
1222
1251
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T>::
1223
1252
  Auto_Function_Wrapper(
1224
1253
  Func func,
1225
- Exception_Handler const * handler)
1254
+ Data_Object<Exception_Handler> handler)
1226
1255
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1227
1256
  , func_(func)
1228
- , handler_(handler ? handler : new Default_Exception_Handler)
1257
+ , handler_(handler)
1258
+ , handler_guard_(&handler_)
1229
1259
  {
1230
1260
  }
1231
1261
 
@@ -1236,9 +1266,9 @@ call(VALUE ruby_arg0, VALUE ruby_arg1)
1236
1266
  Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T> * wrapper = 0;
1237
1267
  try
1238
1268
  {
1239
- void * data = detail::method_data();
1269
+ Data_Object<Wrapped_Function> data(detail::method_data());
1240
1270
  wrapper =
1241
- (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T> *)data;
1271
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T, Arg1_T> *)data.get();
1242
1272
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0)); Arg1_T arg1(from_ruby<Arg1_T>(ruby_arg1));
1243
1273
  wrapper->func_(arg0, arg1);
1244
1274
  return Qnil;
@@ -1265,10 +1295,11 @@ template<typename Func_T, typename Ret_T, typename Arg0_T>
1265
1295
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T>::
1266
1296
  Auto_Function_Wrapper(
1267
1297
  Func func,
1268
- Exception_Handler const * handler)
1298
+ Data_Object<Exception_Handler> handler)
1269
1299
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1270
1300
  , func_(func)
1271
- , handler_(handler ? handler : new Default_Exception_Handler)
1301
+ , handler_(handler)
1302
+ , handler_guard_(&handler_)
1272
1303
  {
1273
1304
  }
1274
1305
 
@@ -1279,8 +1310,8 @@ call(VALUE ruby_arg0)
1279
1310
  Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T> * wrapper = 0;
1280
1311
  try
1281
1312
  {
1282
- void * data = detail::method_data();
1283
- wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T> *)data;
1313
+ Data_Object<Wrapped_Function> data(detail::method_data());
1314
+ wrapper = (Auto_Function_Wrapper<Func_T, Ret_T, Arg0_T> *)data.get();
1284
1315
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0));
1285
1316
  return to_ruby(wrapper->func_(arg0));
1286
1317
  }
@@ -1305,10 +1336,11 @@ template<typename Func_T, typename Arg0_T>
1305
1336
  Auto_Function_Wrapper<Func_T, void, Arg0_T>::
1306
1337
  Auto_Function_Wrapper(
1307
1338
  Func func,
1308
- Exception_Handler const * handler)
1339
+ Data_Object<Exception_Handler> handler)
1309
1340
  : Wrapped_Function(RUBY_METHOD_FUNC(call), Num_Args)
1310
1341
  , func_(func)
1311
- , handler_(handler ? handler : new Default_Exception_Handler)
1342
+ , handler_(handler)
1343
+ , handler_guard_(&handler_)
1312
1344
  {
1313
1345
  }
1314
1346
 
@@ -1319,9 +1351,9 @@ call(VALUE ruby_arg0)
1319
1351
  Auto_Function_Wrapper<Func_T, void, Arg0_T> * wrapper = 0;
1320
1352
  try
1321
1353
  {
1322
- void * data = detail::method_data();
1354
+ Data_Object<Wrapped_Function> data(detail::method_data());
1323
1355
  wrapper =
1324
- (Auto_Function_Wrapper<Func_T, void, Arg0_T> *)data;
1356
+ (Auto_Function_Wrapper<Func_T, void, Arg0_T> *)data.get();
1325
1357
  Arg0_T arg0(from_ruby<Arg0_T>(ruby_arg0));
1326
1358
  wrapper->func_(arg0);
1327
1359
  return Qnil;