rice 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +2 -2
  3. data/Doxyfile +4 -16
  4. data/Makefile.am +2 -2
  5. data/Makefile.in +28 -17
  6. data/{README → README.md} +323 -328
  7. data/aclocal.m4 +104 -107
  8. data/ax_cxx_compile_stdcxx.m4 +951 -0
  9. data/configure +549 -238
  10. data/configure.ac +3 -3
  11. data/extconf.rb +11 -10
  12. data/rice/Array.hpp +16 -16
  13. data/rice/Array.ipp +11 -11
  14. data/rice/Class_defn.hpp +1 -0
  15. data/rice/Constructor.hpp +27 -371
  16. data/rice/Data_Object_defn.hpp +3 -3
  17. data/rice/Director.hpp +3 -3
  18. data/rice/Enum.ipp +1 -1
  19. data/rice/Exception.cpp +2 -7
  20. data/rice/Hash.hpp +8 -5
  21. data/rice/Hash.ipp +2 -2
  22. data/rice/Makefile.am +1 -4
  23. data/rice/Makefile.in +80 -35
  24. data/rice/Module_impl.ipp +1 -1
  25. data/rice/Object.cpp +1 -1
  26. data/rice/Object.ipp +15 -1
  27. data/rice/Object_defn.hpp +24 -1
  28. data/rice/String.cpp +2 -7
  29. data/rice/Struct.cpp +2 -2
  30. data/rice/Struct.hpp +1 -1
  31. data/rice/Struct.ipp +1 -1
  32. data/rice/config.hpp +2 -2
  33. data/rice/config.hpp.in +2 -2
  34. data/rice/detail/Arguments.hpp +1 -1
  35. data/rice/detail/Auto_Function_Wrapper.ipp +512 -1025
  36. data/rice/detail/Auto_Member_Function_Wrapper.ipp +272 -545
  37. data/rice/detail/Iterator.hpp +2 -2
  38. data/rice/detail/method_data.cpp +8 -2
  39. data/rice/detail/ruby.hpp +1 -4
  40. data/rice/detail/ruby_version_code.hpp +1 -1
  41. data/rice/detail/wrap_function.hpp +32 -307
  42. data/rice/protect.hpp +3 -57
  43. data/rice/to_from_ruby.ipp +128 -4
  44. data/ruby/Makefile.in +11 -8
  45. data/ruby/lib/Makefile.in +10 -7
  46. data/ruby/lib/version.rb +1 -1
  47. data/sample/Makefile.am +10 -4
  48. data/sample/Makefile.in +20 -11
  49. data/sample/callbacks/extconf.rb +3 -0
  50. data/sample/callbacks/sample_callbacks.cpp +38 -0
  51. data/sample/callbacks/test.rb +28 -0
  52. data/test/Makefile.am +1 -0
  53. data/test/Makefile.in +118 -49
  54. data/test/embed_ruby.cpp +21 -0
  55. data/test/embed_ruby.hpp +4 -0
  56. data/test/ext/Makefile.in +10 -7
  57. data/test/test_Address_Registration_Guard.cpp +2 -1
  58. data/test/test_Array.cpp +2 -1
  59. data/test/test_Builtin_Object.cpp +2 -1
  60. data/test/test_Class.cpp +7 -4
  61. data/test/test_Data_Object.cpp +2 -1
  62. data/test/test_Data_Type.cpp +2 -1
  63. data/test/test_Director.cpp +2 -1
  64. data/test/test_Enum.cpp +24 -3
  65. data/test/test_Exception.cpp +2 -1
  66. data/test/test_Hash.cpp +2 -1
  67. data/test/test_Identifier.cpp +2 -1
  68. data/test/test_Memory_Management.cpp +2 -1
  69. data/test/test_Module.cpp +2 -1
  70. data/test/test_Object.cpp +13 -1
  71. data/test/test_String.cpp +2 -1
  72. data/test/test_Struct.cpp +2 -1
  73. data/test/test_Symbol.cpp +2 -1
  74. data/test/test_To_From_Ruby.cpp +102 -1
  75. data/test/test_global_functions.cpp +2 -1
  76. data/test/test_rice.rb +4 -0
  77. data/test/unittest.cpp +35 -9
  78. metadata +72 -16
  79. data/check_stdcxx_11.ac +0 -142
  80. data/rice/detail/object_call.hpp +0 -69
  81. data/rice/detail/object_call.ipp +0 -131
  82. data/rice/detail/traits.hpp +0 -43
  83. data/rice/detail/wrap_function.ipp +0 -514
@@ -18,6 +18,37 @@ Rice::Object to_ruby<Rice::Object>(Rice::Object const & x)
18
18
  return x;
19
19
  }
20
20
 
21
+ // ---------------------------------------------------------------------
22
+ namespace Rice
23
+ {
24
+ namespace detail
25
+ {
26
+ inline short num2short(VALUE x)
27
+ {
28
+ return NUM2SHORT(x);
29
+ }
30
+
31
+ inline VALUE short2num(short x)
32
+ {
33
+ return INT2NUM(x);
34
+ }
35
+ }
36
+ }
37
+
38
+ template<>
39
+ inline
40
+ short from_ruby<short>(Rice::Object x)
41
+ {
42
+ return Rice::detail::num2short(x);
43
+ }
44
+
45
+ template<>
46
+ inline
47
+ Rice::Object to_ruby<short>(short const & x)
48
+ {
49
+ return Rice::protect(Rice::detail::short2num, x);
50
+ }
51
+
21
52
  // ---------------------------------------------------------------------
22
53
  namespace Rice
23
54
  {
@@ -70,7 +101,7 @@ template<>
70
101
  inline
71
102
  long from_ruby<long>(Rice::Object x)
72
103
  {
73
- return Rice::protect(Rice::detail::num2long, x);
104
+ return (long)Rice::protect(Rice::detail::num2long, x);
74
105
  }
75
106
 
76
107
  template<>
@@ -80,6 +111,68 @@ Rice::Object to_ruby<long>(long const & x)
80
111
  return Rice::protect(Rice::detail::long2num, x);
81
112
  }
82
113
 
114
+ // ---------------------------------------------------------------------
115
+ namespace Rice
116
+ {
117
+ namespace detail
118
+ {
119
+ inline long long num2longlong(VALUE x)
120
+ {
121
+ return NUM2LL(x);
122
+ }
123
+
124
+ inline VALUE longlong2num(long long x)
125
+ {
126
+ return LL2NUM(x);
127
+ }
128
+ }
129
+ }
130
+
131
+ template<>
132
+ inline
133
+ long long from_ruby<long long>(Rice::Object x)
134
+ {
135
+ return Rice::protect(Rice::detail::num2longlong, x);
136
+ }
137
+
138
+ template<>
139
+ inline
140
+ Rice::Object to_ruby<long long>(long long const & x)
141
+ {
142
+ return Rice::protect(Rice::detail::longlong2num, x);
143
+ }
144
+
145
+ // ---------------------------------------------------------------------
146
+ namespace Rice
147
+ {
148
+ namespace detail
149
+ {
150
+ inline unsigned short num2ushort(VALUE x)
151
+ {
152
+ return NUM2USHORT(x);
153
+ }
154
+
155
+ inline VALUE ushort2num(unsigned short x)
156
+ {
157
+ return UINT2NUM(x);
158
+ }
159
+ }
160
+ }
161
+
162
+ template<>
163
+ inline
164
+ unsigned short from_ruby<unsigned short>(Rice::Object x)
165
+ {
166
+ return Rice::detail::num2ushort(x);
167
+ }
168
+
169
+ template<>
170
+ inline
171
+ Rice::Object to_ruby<unsigned short>(unsigned short const & x)
172
+ {
173
+ return Rice::protect(Rice::detail::ushort2num, x);
174
+ }
175
+
83
176
  // ---------------------------------------------------------------------
84
177
  namespace Rice
85
178
  {
@@ -132,7 +225,7 @@ template<>
132
225
  inline
133
226
  unsigned long from_ruby<unsigned long>(Rice::Object x)
134
227
  {
135
- return Rice::protect(Rice::detail::num2ulong, x);
228
+ return (unsigned long)Rice::protect(Rice::detail::num2ulong, x);
136
229
  }
137
230
 
138
231
  template<>
@@ -142,6 +235,37 @@ Rice::Object to_ruby<unsigned long>(unsigned long const & x)
142
235
  return Rice::protect(Rice::detail::ulong2num, x);
143
236
  }
144
237
 
238
+ // ---------------------------------------------------------------------
239
+ namespace Rice
240
+ {
241
+ namespace detail
242
+ {
243
+ inline unsigned long long num2ulonglong(VALUE x)
244
+ {
245
+ return NUM2ULL(x);
246
+ }
247
+
248
+ inline VALUE ulonglong2num(unsigned long long x)
249
+ {
250
+ return ULL2NUM(x);
251
+ }
252
+ }
253
+ }
254
+
255
+ template<>
256
+ inline
257
+ unsigned long long from_ruby<unsigned long long>(Rice::Object x)
258
+ {
259
+ return Rice::protect(Rice::detail::num2ulonglong, x);
260
+ }
261
+
262
+ template<>
263
+ inline
264
+ Rice::Object to_ruby<unsigned long long>(unsigned long long const & x)
265
+ {
266
+ return Rice::protect(Rice::detail::ulonglong2num, x);
267
+ }
268
+
145
269
  // ---------------------------------------------------------------------
146
270
  template<>
147
271
  inline
@@ -261,7 +385,7 @@ template<>
261
385
  inline
262
386
  char const * from_ruby<char const *>(Rice::Object x)
263
387
  {
264
- return Rice::String(x).str().data();
388
+ return Rice::String(x).c_str();
265
389
  }
266
390
 
267
391
  template<>
@@ -283,7 +407,7 @@ template<>
283
407
  inline
284
408
  Rice::Object to_ruby<std::string>(std::string const & x)
285
409
  {
286
- return Rice::protect(rb_str_new, x.data(), x.size());
410
+ return Rice::protect(rb_str_new, x.data(), (long)x.size());
287
411
  }
288
412
 
289
413
  template<>
@@ -1,7 +1,7 @@
1
- # Makefile.in generated by automake 1.15 from Makefile.am.
1
+ # Makefile.in generated by automake 1.16.3 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
- # Copyright (C) 1994-2014 Free Software Foundation, Inc.
4
+ # Copyright (C) 1994-2020 Free Software Foundation, Inc.
5
5
 
6
6
  # This Makefile.in is free software; the Free Software Foundation
7
7
  # gives unlimited permission to copy and/or distribute it,
@@ -89,7 +89,7 @@ build_triplet = @build@
89
89
  host_triplet = @host@
90
90
  subdir = ruby
91
91
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
92
- am__aclocal_m4_deps = $(top_srcdir)/check_stdcxx_11.ac \
92
+ am__aclocal_m4_deps = $(top_srcdir)/ax_cxx_compile_stdcxx.m4 \
93
93
  $(top_srcdir)/ruby.ac $(top_srcdir)/doxygen.ac \
94
94
  $(top_srcdir)/configure.ac
95
95
  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -133,7 +133,7 @@ am__recursive_targets = \
133
133
  $(RECURSIVE_CLEAN_TARGETS) \
134
134
  $(am__extra_recursive_targets)
135
135
  AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
136
- distdir
136
+ distdir distdir-am
137
137
  am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
138
138
  # Read a list of newline-separated strings from the standard input,
139
139
  # and print each of them once, without duplicates. Input order is
@@ -223,7 +223,7 @@ ECHO_C = @ECHO_C@
223
223
  ECHO_N = @ECHO_N@
224
224
  ECHO_T = @ECHO_T@
225
225
  EXEEXT = @EXEEXT@
226
- HAVE_CXX11 = @HAVE_CXX11@
226
+ HAVE_CXX14 = @HAVE_CXX14@
227
227
  INSTALL = @INSTALL@
228
228
  INSTALL_DATA = @INSTALL_DATA@
229
229
  INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -335,8 +335,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
335
335
  *config.status*) \
336
336
  cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
337
337
  *) \
338
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
339
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
338
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
339
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
340
340
  esac;
341
341
 
342
342
  $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -447,7 +447,10 @@ cscopelist-am: $(am__tagged_files)
447
447
  distclean-tags:
448
448
  -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
449
449
 
450
- distdir: $(DISTFILES)
450
+ distdir: $(BUILT_SOURCES)
451
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
452
+
453
+ distdir-am: $(DISTFILES)
451
454
  @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
452
455
  topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
453
456
  list='$(DISTFILES)'; \
@@ -1,7 +1,7 @@
1
- # Makefile.in generated by automake 1.15 from Makefile.am.
1
+ # Makefile.in generated by automake 1.16.3 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
- # Copyright (C) 1994-2014 Free Software Foundation, Inc.
4
+ # Copyright (C) 1994-2020 Free Software Foundation, Inc.
5
5
 
6
6
  # This Makefile.in is free software; the Free Software Foundation
7
7
  # gives unlimited permission to copy and/or distribute it,
@@ -90,7 +90,7 @@ build_triplet = @build@
90
90
  host_triplet = @host@
91
91
  subdir = ruby/lib
92
92
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
93
- am__aclocal_m4_deps = $(top_srcdir)/check_stdcxx_11.ac \
93
+ am__aclocal_m4_deps = $(top_srcdir)/ax_cxx_compile_stdcxx.m4 \
94
94
  $(top_srcdir)/ruby.ac $(top_srcdir)/doxygen.ac \
95
95
  $(top_srcdir)/configure.ac
96
96
  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -193,7 +193,7 @@ ECHO_C = @ECHO_C@
193
193
  ECHO_N = @ECHO_N@
194
194
  ECHO_T = @ECHO_T@
195
195
  EXEEXT = @EXEEXT@
196
- HAVE_CXX11 = @HAVE_CXX11@
196
+ HAVE_CXX14 = @HAVE_CXX14@
197
197
  INSTALL = @INSTALL@
198
198
  INSTALL_DATA = @INSTALL_DATA@
199
199
  INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -306,8 +306,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
306
306
  *config.status*) \
307
307
  cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
308
308
  *) \
309
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
310
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
309
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
310
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
311
311
  esac;
312
312
 
313
313
  $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -348,7 +348,10 @@ ctags CTAGS:
348
348
  cscope cscopelist:
349
349
 
350
350
 
351
- distdir: $(DISTFILES)
351
+ distdir: $(BUILT_SOURCES)
352
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
353
+
354
+ distdir-am: $(DISTFILES)
352
355
  @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
353
356
  topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
354
357
  list='$(DISTFILES)'; \
@@ -1,3 +1,3 @@
1
1
  module Rice
2
- VERSION = "2.1.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -10,7 +10,10 @@ EXTRA_DIST = \
10
10
  map/test.rb \
11
11
  inheritance/extconf.rb \
12
12
  inheritance/animals.cpp \
13
- inheritance/test.rb
13
+ inheritance/test.rb \
14
+ callbacks/extconf.rb \
15
+ callbacks/sample_callbacks.cpp \
16
+ callbacks/test.rb
14
17
 
15
18
  enum/Makefile: enum/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
16
19
  @RUBY@ $(RUBY_EXTCONF_OPTIONS) -C enum extconf.rb $(EXTCONF_OPTIONS)
@@ -21,7 +24,10 @@ map/Makefile: map/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
21
24
  inheritance/Makefile: inheritance/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
22
25
  @RUBY@ $(RUBY_EXTCONF_OPTIONS) -C inheritance extconf.rb $(EXTCONF_OPTIONS)
23
26
 
24
- all: enum/Makefile map/Makefile inheritance/Makefile all_extensions
27
+ callbacks/Makefile: callbacks/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
28
+ @RUBY@ $(RUBY_EXTCONF_OPTIONS) -C callbacks extconf.rb $(EXTCONF_OPTIONS)
29
+
30
+ all: enum/Makefile map/Makefile inheritance/Makefile callbacks/Makefile all_extensions
25
31
 
26
32
  all_extensions: $(addsuffix /Makefile,$(RICE_SAMPLES))
27
33
  @for sample in $(RICE_SAMPLES); \
@@ -29,7 +35,7 @@ all_extensions: $(addsuffix /Makefile,$(RICE_SAMPLES))
29
35
  ${MAKE} -C $${sample} all; \
30
36
  done
31
37
 
32
- clean: enum/Makefile map/Makefile inheritance/Makefile clean_extensions
38
+ clean: enum/Makefile map/Makefile inheritance/Makefile callbacks/Makefile clean_extensions
33
39
 
34
40
  clean_extensions:
35
41
  @for sample in $(RICE_SAMPLES); \
@@ -37,7 +43,7 @@ clean_extensions:
37
43
  ${MAKE} -C $${sample} clean; \
38
44
  done
39
45
 
40
- distclean: enum/Makefile map/Makefile inheritance/Makefile distclean_extensions
46
+ distclean: enum/Makefile map/Makefile inheritance/Makefile callbacks/Makefile distclean_extensions
41
47
 
42
48
  distclean_extensions:
43
49
  @for sample in $(RICE_SAMPLES);
@@ -1,7 +1,7 @@
1
- # Makefile.in generated by automake 1.15 from Makefile.am.
1
+ # Makefile.in generated by automake 1.16.3 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
- # Copyright (C) 1994-2014 Free Software Foundation, Inc.
4
+ # Copyright (C) 1994-2020 Free Software Foundation, Inc.
5
5
 
6
6
  # This Makefile.in is free software; the Free Software Foundation
7
7
  # gives unlimited permission to copy and/or distribute it,
@@ -89,7 +89,7 @@ build_triplet = @build@
89
89
  host_triplet = @host@
90
90
  subdir = sample
91
91
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
92
- am__aclocal_m4_deps = $(top_srcdir)/check_stdcxx_11.ac \
92
+ am__aclocal_m4_deps = $(top_srcdir)/ax_cxx_compile_stdcxx.m4 \
93
93
  $(top_srcdir)/ruby.ac $(top_srcdir)/doxygen.ac \
94
94
  $(top_srcdir)/configure.ac
95
95
  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -163,7 +163,7 @@ ECHO_C = @ECHO_C@
163
163
  ECHO_N = @ECHO_N@
164
164
  ECHO_T = @ECHO_T@
165
165
  EXEEXT = @EXEEXT@
166
- HAVE_CXX11 = @HAVE_CXX11@
166
+ HAVE_CXX14 = @HAVE_CXX14@
167
167
  INSTALL = @INSTALL@
168
168
  INSTALL_DATA = @INSTALL_DATA@
169
169
  INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -265,7 +265,10 @@ EXTRA_DIST = \
265
265
  map/test.rb \
266
266
  inheritance/extconf.rb \
267
267
  inheritance/animals.cpp \
268
- inheritance/test.rb
268
+ inheritance/test.rb \
269
+ callbacks/extconf.rb \
270
+ callbacks/sample_callbacks.cpp \
271
+ callbacks/test.rb
269
272
 
270
273
  all: all-am
271
274
 
@@ -287,8 +290,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
287
290
  *config.status*) \
288
291
  cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289
292
  *) \
290
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
293
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
294
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
292
295
  esac;
293
296
 
294
297
  $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -306,7 +309,10 @@ ctags CTAGS:
306
309
  cscope cscopelist:
307
310
 
308
311
 
309
- distdir: $(DISTFILES)
312
+ distdir: $(BUILT_SOURCES)
313
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
314
+
315
+ distdir-am: $(DISTFILES)
310
316
  @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
311
317
  topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
312
318
  list='$(DISTFILES)'; \
@@ -457,7 +463,10 @@ map/Makefile: map/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
457
463
  inheritance/Makefile: inheritance/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
458
464
  @RUBY@ $(RUBY_EXTCONF_OPTIONS) -C inheritance extconf.rb $(EXTCONF_OPTIONS)
459
465
 
460
- all: enum/Makefile map/Makefile inheritance/Makefile all_extensions
466
+ callbacks/Makefile: callbacks/extconf.rb ../config.status ../ruby/lib/mkmf-rice.rb
467
+ @RUBY@ $(RUBY_EXTCONF_OPTIONS) -C callbacks extconf.rb $(EXTCONF_OPTIONS)
468
+
469
+ all: enum/Makefile map/Makefile inheritance/Makefile callbacks/Makefile all_extensions
461
470
 
462
471
  all_extensions: $(addsuffix /Makefile,$(RICE_SAMPLES))
463
472
  @for sample in $(RICE_SAMPLES); \
@@ -465,7 +474,7 @@ all_extensions: $(addsuffix /Makefile,$(RICE_SAMPLES))
465
474
  ${MAKE} -C $${sample} all; \
466
475
  done
467
476
 
468
- clean: enum/Makefile map/Makefile inheritance/Makefile clean_extensions
477
+ clean: enum/Makefile map/Makefile inheritance/Makefile callbacks/Makefile clean_extensions
469
478
 
470
479
  clean_extensions:
471
480
  @for sample in $(RICE_SAMPLES); \
@@ -473,7 +482,7 @@ clean_extensions:
473
482
  ${MAKE} -C $${sample} clean; \
474
483
  done
475
484
 
476
- distclean: enum/Makefile map/Makefile inheritance/Makefile distclean_extensions
485
+ distclean: enum/Makefile map/Makefile inheritance/Makefile callbacks/Makefile distclean_extensions
477
486
 
478
487
  distclean_extensions:
479
488
  @for sample in $(RICE_SAMPLES);
@@ -0,0 +1,3 @@
1
+ require 'mkmf-rice'
2
+ create_makefile('sample_callbacks')
3
+
@@ -0,0 +1,38 @@
1
+ #include "rice/Data_Type.hpp"
2
+ #include "rice/Constructor.hpp"
3
+ #include "rice/String.hpp"
4
+
5
+ using namespace Rice;
6
+
7
+ namespace
8
+ {
9
+
10
+ class CallbackHolder {
11
+ public:
12
+
13
+ void registerCallback(Rice::Object cb) {
14
+ callback = cb;
15
+ }
16
+
17
+ Rice::Object fireCallback(Rice::String param) {
18
+ return callback.call("call", param);
19
+ }
20
+
21
+ Rice::Object callback;
22
+ };
23
+
24
+ } // namespace
25
+
26
+ extern "C"
27
+ void Init_sample_callbacks()
28
+ {
29
+ RUBY_TRY
30
+ {
31
+ define_class<CallbackHolder>("CallbackHolder")
32
+ .define_constructor(Constructor<CallbackHolder>())
33
+ .define_method("register_callback", &CallbackHolder::registerCallback)
34
+ .define_method("fire_callback", &CallbackHolder::fireCallback);
35
+ }
36
+ RUBY_CATCH
37
+ }
38
+