rice 4.0.4 → 4.2.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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/CONTRIBUTORS.md +2 -0
  4. data/Rakefile +1 -1
  5. data/include/rice/rice.hpp +2851 -1955
  6. data/include/rice/stl.hpp +1654 -287
  7. data/lib/mkmf-rice.rb +5 -2
  8. data/lib/version.rb +1 -1
  9. data/rice/Arg.hpp +6 -6
  10. data/rice/Arg.ipp +8 -9
  11. data/rice/Constructor.hpp +2 -2
  12. data/rice/Data_Object.ipp +69 -15
  13. data/rice/Data_Object_defn.hpp +1 -15
  14. data/rice/Data_Type.ipp +56 -86
  15. data/rice/Data_Type_defn.hpp +14 -17
  16. data/rice/Director.hpp +0 -1
  17. data/rice/Enum.ipp +31 -22
  18. data/rice/Exception.ipp +2 -3
  19. data/rice/Exception_defn.hpp +5 -5
  20. data/rice/HandlerRegistration.hpp +15 -0
  21. data/rice/Return.hpp +5 -4
  22. data/rice/Return.ipp +8 -3
  23. data/rice/detail/ExceptionHandler.hpp +8 -0
  24. data/rice/detail/ExceptionHandler.ipp +28 -0
  25. data/rice/detail/{Exception_Handler_defn.hpp → ExceptionHandler_defn.hpp} +17 -21
  26. data/rice/detail/HandlerRegistry.hpp +51 -0
  27. data/rice/detail/HandlerRegistry.ipp +20 -0
  28. data/rice/detail/InstanceRegistry.hpp +34 -0
  29. data/rice/detail/InstanceRegistry.ipp +50 -0
  30. data/rice/detail/MethodInfo.ipp +1 -1
  31. data/rice/detail/NativeAttribute.hpp +26 -15
  32. data/rice/detail/NativeAttribute.ipp +76 -47
  33. data/rice/detail/NativeFunction.hpp +64 -14
  34. data/rice/detail/NativeFunction.ipp +138 -86
  35. data/rice/detail/NativeIterator.hpp +49 -0
  36. data/rice/detail/NativeIterator.ipp +102 -0
  37. data/rice/detail/NativeRegistry.hpp +31 -0
  38. data/rice/detail/{method_data.ipp → NativeRegistry.ipp} +20 -16
  39. data/rice/detail/Registries.hpp +26 -0
  40. data/rice/detail/Registries.ipp +23 -0
  41. data/rice/detail/RubyFunction.hpp +6 -11
  42. data/rice/detail/RubyFunction.ipp +10 -22
  43. data/rice/detail/Type.hpp +1 -1
  44. data/rice/detail/Type.ipp +2 -2
  45. data/rice/detail/TypeRegistry.hpp +8 -11
  46. data/rice/detail/TypeRegistry.ipp +3 -28
  47. data/rice/detail/Wrapper.hpp +0 -2
  48. data/rice/detail/Wrapper.ipp +74 -24
  49. data/rice/detail/cpp_protect.hpp +93 -0
  50. data/rice/detail/default_allocation_func.ipp +1 -1
  51. data/rice/detail/from_ruby.ipp +206 -2
  52. data/rice/detail/to_ruby.ipp +39 -5
  53. data/rice/detail/to_ruby_defn.hpp +1 -1
  54. data/rice/forward_declares.ipp +6 -0
  55. data/rice/global_function.hpp +0 -4
  56. data/rice/global_function.ipp +0 -6
  57. data/rice/rice.hpp +29 -24
  58. data/rice/stl.hpp +6 -1
  59. data/sample/callbacks/extconf.rb +0 -1
  60. data/sample/enum/extconf.rb +0 -1
  61. data/sample/inheritance/extconf.rb +0 -1
  62. data/sample/map/extconf.rb +0 -1
  63. data/test/embed_ruby.cpp +6 -15
  64. data/test/ext/t1/extconf.rb +0 -1
  65. data/test/ext/t2/extconf.rb +0 -1
  66. data/test/extconf.rb +0 -1
  67. data/test/test_Array.cpp +20 -24
  68. data/test/test_Attribute.cpp +6 -6
  69. data/test/test_Class.cpp +8 -47
  70. data/test/test_Constructor.cpp +0 -2
  71. data/test/test_Data_Object.cpp +25 -11
  72. data/test/test_Data_Type.cpp +124 -28
  73. data/test/test_Director.cpp +12 -13
  74. data/test/test_Enum.cpp +65 -26
  75. data/test/test_Inheritance.cpp +9 -9
  76. data/test/test_Iterator.cpp +134 -5
  77. data/test/test_Keep_Alive.cpp +7 -7
  78. data/test/test_Keep_Alive_No_Wrapper.cpp +80 -0
  79. data/test/test_Memory_Management.cpp +1 -1
  80. data/test/test_Module.cpp +25 -62
  81. data/test/test_Object.cpp +75 -3
  82. data/test/test_Ownership.cpp +12 -13
  83. data/test/test_Self.cpp +12 -13
  84. data/test/test_Stl_Map.cpp +696 -0
  85. data/test/test_Stl_Optional.cpp +3 -3
  86. data/test/test_Stl_Pair.cpp +38 -2
  87. data/test/test_Stl_Reference_Wrapper.cpp +102 -0
  88. data/test/test_Stl_SmartPointer.cpp +49 -9
  89. data/test/test_Stl_String.cpp +5 -2
  90. data/test/test_Stl_Unordered_Map.cpp +697 -0
  91. data/test/test_Stl_Variant.cpp +346 -0
  92. data/test/test_Stl_Vector.cpp +200 -41
  93. data/test/test_Struct.cpp +3 -3
  94. data/test/test_To_From_Ruby.cpp +8 -2
  95. data/test/test_Tracking.cpp +239 -0
  96. data/test/unittest.hpp +21 -4
  97. metadata +24 -13
  98. data/rice/detail/Exception_Handler.hpp +0 -8
  99. data/rice/detail/Exception_Handler.ipp +0 -28
  100. data/rice/detail/Iterator.hpp +0 -23
  101. data/rice/detail/Iterator.ipp +0 -47
  102. data/rice/detail/function_traits.hpp +0 -124
  103. data/rice/detail/method_data.hpp +0 -29
  104. data/rice/detail/rice_traits.hpp +0 -116
  105. data/rice/ruby_try_catch.hpp +0 -86
@@ -22,6 +22,11 @@ namespace Rice::detail
22
22
  {
23
23
  }
24
24
 
25
+ bool is_convertible(VALUE value)
26
+ {
27
+ return rb_type(value) == RUBY_T_FIXNUM;
28
+ }
29
+
25
30
  short convert(VALUE value)
26
31
  {
27
32
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -48,6 +53,11 @@ namespace Rice::detail
48
53
  {
49
54
  }
50
55
 
56
+ bool is_convertible(VALUE value)
57
+ {
58
+ return rb_type(value) == RUBY_T_FIXNUM;
59
+ }
60
+
51
61
  short& convert(VALUE value)
52
62
  {
53
63
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -70,6 +80,11 @@ namespace Rice::detail
70
80
  class From_Ruby<short*>
71
81
  {
72
82
  public:
83
+ bool is_convertible(VALUE value)
84
+ {
85
+ return rb_type(value) == RUBY_T_FIXNUM;
86
+ }
87
+
73
88
  short* convert(VALUE value)
74
89
  {
75
90
  if (value == Qnil)
@@ -98,6 +113,11 @@ namespace Rice::detail
98
113
  {
99
114
  }
100
115
 
116
+ bool is_convertible(VALUE value)
117
+ {
118
+ return rb_type(value) == RUBY_T_FIXNUM;
119
+ }
120
+
101
121
  int convert(VALUE value)
102
122
  {
103
123
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -124,6 +144,11 @@ namespace Rice::detail
124
144
  {
125
145
  }
126
146
 
147
+ bool is_convertible(VALUE value)
148
+ {
149
+ return rb_type(value) == RUBY_T_FIXNUM;
150
+ }
151
+
127
152
  int& convert(VALUE value)
128
153
  {
129
154
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -146,6 +171,11 @@ namespace Rice::detail
146
171
  class From_Ruby<int*>
147
172
  {
148
173
  public:
174
+ bool is_convertible(VALUE value)
175
+ {
176
+ return rb_type(value) == RUBY_T_FIXNUM;
177
+ }
178
+
149
179
  int* convert(VALUE value)
150
180
  {
151
181
  if (value == Qnil)
@@ -174,6 +204,11 @@ namespace Rice::detail
174
204
  {
175
205
  }
176
206
 
207
+ bool is_convertible(VALUE value)
208
+ {
209
+ return rb_type(value) == RUBY_T_FIXNUM;
210
+ }
211
+
177
212
  long convert(VALUE value)
178
213
  {
179
214
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -200,6 +235,11 @@ namespace Rice::detail
200
235
  {
201
236
  }
202
237
 
238
+ bool is_convertible(VALUE value)
239
+ {
240
+ return rb_type(value) == RUBY_T_FIXNUM;
241
+ }
242
+
203
243
  long& convert(VALUE value)
204
244
  {
205
245
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -222,6 +262,11 @@ namespace Rice::detail
222
262
  class From_Ruby<long*>
223
263
  {
224
264
  public:
265
+ bool is_convertible(VALUE value)
266
+ {
267
+ return rb_type(value) == RUBY_T_FIXNUM;
268
+ }
269
+
225
270
  long* convert(VALUE value)
226
271
  {
227
272
  if (value == Qnil)
@@ -250,6 +295,11 @@ namespace Rice::detail
250
295
  {
251
296
  }
252
297
 
298
+ bool is_convertible(VALUE value)
299
+ {
300
+ return rb_type(value) == RUBY_T_FIXNUM;
301
+ }
302
+
253
303
  long long convert(VALUE value)
254
304
  {
255
305
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -276,6 +326,11 @@ namespace Rice::detail
276
326
  {
277
327
  }
278
328
 
329
+ bool is_convertible(VALUE value)
330
+ {
331
+ return rb_type(value) == RUBY_T_FIXNUM;
332
+ }
333
+
279
334
  long long& convert(VALUE value)
280
335
  {
281
336
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -298,6 +353,11 @@ namespace Rice::detail
298
353
  class From_Ruby<long long*>
299
354
  {
300
355
  public:
356
+ bool is_convertible(VALUE value)
357
+ {
358
+ return rb_type(value) == RUBY_T_FIXNUM;
359
+ }
360
+
301
361
  long long* convert(VALUE value)
302
362
  {
303
363
  if (value == Qnil)
@@ -326,6 +386,11 @@ namespace Rice::detail
326
386
  {
327
387
  }
328
388
 
389
+ bool is_convertible(VALUE value)
390
+ {
391
+ return rb_type(value) == RUBY_T_FIXNUM;
392
+ }
393
+
329
394
  unsigned short convert(VALUE value)
330
395
  {
331
396
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -352,6 +417,11 @@ namespace Rice::detail
352
417
  {
353
418
  }
354
419
 
420
+ bool is_convertible(VALUE value)
421
+ {
422
+ return rb_type(value) == RUBY_T_FIXNUM;
423
+ }
424
+
355
425
  unsigned short& convert(VALUE value)
356
426
  {
357
427
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -374,6 +444,11 @@ namespace Rice::detail
374
444
  class From_Ruby<unsigned short*>
375
445
  {
376
446
  public:
447
+ bool is_convertible(VALUE value)
448
+ {
449
+ return rb_type(value) == RUBY_T_FIXNUM;
450
+ }
451
+
377
452
  unsigned short* convert(VALUE value)
378
453
  {
379
454
  if (value == Qnil)
@@ -402,6 +477,11 @@ namespace Rice::detail
402
477
  {
403
478
  }
404
479
 
480
+ bool is_convertible(VALUE value)
481
+ {
482
+ return rb_type(value) == RUBY_T_FIXNUM;
483
+ }
484
+
405
485
  unsigned int convert(VALUE value)
406
486
  {
407
487
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -428,6 +508,11 @@ namespace Rice::detail
428
508
  {
429
509
  }
430
510
 
511
+ bool is_convertible(VALUE value)
512
+ {
513
+ return rb_type(value) == RUBY_T_FIXNUM;
514
+ }
515
+
431
516
  unsigned int& convert(VALUE value)
432
517
  {
433
518
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -450,6 +535,11 @@ namespace Rice::detail
450
535
  class From_Ruby<unsigned int*>
451
536
  {
452
537
  public:
538
+ bool is_convertible(VALUE value)
539
+ {
540
+ return rb_type(value) == RUBY_T_FIXNUM;
541
+ }
542
+
453
543
  unsigned int* convert(VALUE value)
454
544
  {
455
545
  if (value == Qnil)
@@ -478,9 +568,14 @@ namespace Rice::detail
478
568
  {
479
569
  }
480
570
 
571
+ bool is_convertible(VALUE value)
572
+ {
573
+ return rb_type(value) == RUBY_T_FIXNUM;
574
+ }
575
+
481
576
  unsigned long convert(VALUE value)
482
577
  {
483
- if (this->arg_ && this->arg_->getIsValue())
578
+ if (this->arg_ && this->arg_->isValue())
484
579
  {
485
580
  return (unsigned long)value;
486
581
  }
@@ -508,6 +603,11 @@ namespace Rice::detail
508
603
  {
509
604
  }
510
605
 
606
+ bool is_convertible(VALUE value)
607
+ {
608
+ return rb_type(value) == RUBY_T_FIXNUM;
609
+ }
610
+
511
611
  unsigned long& convert(VALUE value)
512
612
  {
513
613
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -530,6 +630,11 @@ namespace Rice::detail
530
630
  class From_Ruby<unsigned long*>
531
631
  {
532
632
  public:
633
+ bool is_convertible(VALUE value)
634
+ {
635
+ return rb_type(value) == RUBY_T_FIXNUM;
636
+ }
637
+
533
638
  unsigned long* convert(VALUE value)
534
639
  {
535
640
  if (value == Qnil)
@@ -558,9 +663,14 @@ namespace Rice::detail
558
663
  {
559
664
  }
560
665
 
666
+ bool is_convertible(VALUE value)
667
+ {
668
+ return rb_type(value) == RUBY_T_FIXNUM;
669
+ }
670
+
561
671
  unsigned long long convert(VALUE value)
562
672
  {
563
- if (this->arg_ && this->arg_->getIsValue())
673
+ if (this->arg_ && this->arg_->isValue())
564
674
  {
565
675
  return value;
566
676
  }
@@ -588,6 +698,11 @@ namespace Rice::detail
588
698
  {
589
699
  }
590
700
 
701
+ bool is_convertible(VALUE value)
702
+ {
703
+ return rb_type(value) == RUBY_T_FIXNUM;
704
+ }
705
+
591
706
  unsigned long long& convert(VALUE value)
592
707
  {
593
708
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -610,6 +725,11 @@ namespace Rice::detail
610
725
  class From_Ruby<unsigned long long*>
611
726
  {
612
727
  public:
728
+ bool is_convertible(VALUE value)
729
+ {
730
+ return rb_type(value) == RUBY_T_FIXNUM;
731
+ }
732
+
613
733
  unsigned long long* convert(VALUE value)
614
734
  {
615
735
  if (value == Qnil)
@@ -638,6 +758,14 @@ namespace Rice::detail
638
758
  {
639
759
  }
640
760
 
761
+ bool is_convertible(VALUE value)
762
+ {
763
+ ruby_value_type ruby_type = (ruby_value_type)rb_type(value);
764
+ return ruby_type == RUBY_T_TRUE ||
765
+ ruby_type == RUBY_T_FALSE ||
766
+ ruby_type == RUBY_T_NIL;
767
+ }
768
+
641
769
  bool convert(VALUE value)
642
770
  {
643
771
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -664,6 +792,14 @@ namespace Rice::detail
664
792
  {
665
793
  }
666
794
 
795
+ bool is_convertible(VALUE value)
796
+ {
797
+ ruby_value_type ruby_type = (ruby_value_type)rb_type(value);
798
+ return ruby_type == RUBY_T_TRUE ||
799
+ ruby_type == RUBY_T_FALSE ||
800
+ ruby_type == RUBY_T_NIL;
801
+ }
802
+
667
803
  bool& convert(VALUE value)
668
804
  {
669
805
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -686,6 +822,14 @@ namespace Rice::detail
686
822
  class From_Ruby<bool*>
687
823
  {
688
824
  public:
825
+ bool is_convertible(VALUE value)
826
+ {
827
+ ruby_value_type ruby_type = (ruby_value_type)rb_type(value);
828
+ return ruby_type == RUBY_T_TRUE ||
829
+ ruby_type == RUBY_T_FALSE ||
830
+ ruby_type == RUBY_T_NIL;
831
+ }
832
+
689
833
  bool* convert(VALUE value)
690
834
  {
691
835
  if (value == Qnil)
@@ -744,6 +888,11 @@ namespace Rice::detail
744
888
  {
745
889
  }
746
890
 
891
+ bool is_convertible(VALUE value)
892
+ {
893
+ return rb_type(value) == RUBY_T_STRING;
894
+ }
895
+
747
896
  char convert(VALUE value)
748
897
  {
749
898
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -770,6 +919,11 @@ namespace Rice::detail
770
919
  {
771
920
  }
772
921
 
922
+ bool is_convertible(VALUE value)
923
+ {
924
+ return rb_type(value) == RUBY_T_STRING;
925
+ }
926
+
773
927
  char& convert(VALUE value)
774
928
  {
775
929
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -792,6 +946,11 @@ namespace Rice::detail
792
946
  class From_Ruby<char*>
793
947
  {
794
948
  public:
949
+ bool is_convertible(VALUE value)
950
+ {
951
+ return rb_type(value) == RUBY_T_STRING;
952
+ }
953
+
795
954
  char* convert(VALUE value)
796
955
  {
797
956
  if (value == Qnil)
@@ -811,6 +970,11 @@ namespace Rice::detail
811
970
  class From_Ruby<char const*>
812
971
  {
813
972
  public:
973
+ bool is_convertible(VALUE value)
974
+ {
975
+ return rb_type(value) == RUBY_T_STRING;
976
+ }
977
+
814
978
  char const* convert(VALUE value)
815
979
  {
816
980
  if (value == Qnil)
@@ -836,6 +1000,11 @@ namespace Rice::detail
836
1000
  {
837
1001
  }
838
1002
 
1003
+ bool is_convertible(VALUE value)
1004
+ {
1005
+ return rb_type(value) == RUBY_T_STRING;
1006
+ }
1007
+
839
1008
  unsigned char convert(VALUE value)
840
1009
  {
841
1010
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -863,6 +1032,11 @@ namespace Rice::detail
863
1032
  {
864
1033
  }
865
1034
 
1035
+ bool is_convertible(VALUE value)
1036
+ {
1037
+ return rb_type(value) == RUBY_T_STRING;
1038
+ }
1039
+
866
1040
  signed char convert(VALUE value)
867
1041
  {
868
1042
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -890,6 +1064,11 @@ namespace Rice::detail
890
1064
  {
891
1065
  }
892
1066
 
1067
+ bool is_convertible(VALUE value)
1068
+ {
1069
+ return rb_type(value) == RUBY_T_FLOAT;
1070
+ }
1071
+
893
1072
  double convert(VALUE value)
894
1073
  {
895
1074
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -916,6 +1095,11 @@ namespace Rice::detail
916
1095
  {
917
1096
  }
918
1097
 
1098
+ bool is_convertible(VALUE value)
1099
+ {
1100
+ return rb_type(value) == RUBY_T_FLOAT;
1101
+ }
1102
+
919
1103
  double& convert(VALUE value)
920
1104
  {
921
1105
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -938,6 +1122,11 @@ namespace Rice::detail
938
1122
  class From_Ruby<double*>
939
1123
  {
940
1124
  public:
1125
+ bool is_convertible(VALUE value)
1126
+ {
1127
+ return rb_type(value) == RUBY_T_FLOAT;
1128
+ }
1129
+
941
1130
  double* convert(VALUE value)
942
1131
  {
943
1132
  if (value == Qnil)
@@ -966,6 +1155,11 @@ namespace Rice::detail
966
1155
  {
967
1156
  }
968
1157
 
1158
+ bool is_convertible(VALUE value)
1159
+ {
1160
+ return rb_type(value) == RUBY_T_FLOAT;
1161
+ }
1162
+
969
1163
  float convert(VALUE value)
970
1164
  {
971
1165
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -992,6 +1186,11 @@ namespace Rice::detail
992
1186
  {
993
1187
  }
994
1188
 
1189
+ bool is_convertible(VALUE value)
1190
+ {
1191
+ return rb_type(value) == RUBY_T_FLOAT;
1192
+ }
1193
+
995
1194
  float& convert(VALUE value)
996
1195
  {
997
1196
  if (value == Qnil && this->arg_ && this->arg_->hasDefaultValue())
@@ -1014,6 +1213,11 @@ namespace Rice::detail
1014
1213
  class From_Ruby<float*>
1015
1214
  {
1016
1215
  public:
1216
+ bool is_convertible(VALUE value)
1217
+ {
1218
+ return rb_type(value) == RUBY_T_FLOAT;
1219
+ }
1220
+
1017
1221
  float* convert(VALUE value)
1018
1222
  {
1019
1223
  if (value == Qnil)
@@ -189,7 +189,7 @@ namespace Rice
189
189
 
190
190
  VALUE convert(unsigned long const& x)
191
191
  {
192
- if (this->returnInfo_ && this->returnInfo_->getIsValue())
192
+ if (this->returnInfo_ && this->returnInfo_->isValue())
193
193
  {
194
194
  return x;
195
195
  }
@@ -215,7 +215,7 @@ namespace Rice
215
215
 
216
216
  VALUE convert(unsigned long const& x)
217
217
  {
218
- if (this->returnInfo_ && this->returnInfo_->getIsValue())
218
+ if (this->returnInfo_ && this->returnInfo_->isValue())
219
219
  {
220
220
  return x;
221
221
  }
@@ -241,7 +241,7 @@ namespace Rice
241
241
 
242
242
  VALUE convert(unsigned long long const& x)
243
243
  {
244
- if (this->returnInfo_ && this->returnInfo_->getIsValue())
244
+ if (this->returnInfo_ && this->returnInfo_->isValue())
245
245
  {
246
246
  return x;
247
247
  }
@@ -267,7 +267,7 @@ namespace Rice
267
267
 
268
268
  VALUE convert(unsigned long long const& x)
269
269
  {
270
- if (this->returnInfo_ && this->returnInfo_->getIsValue())
270
+ if (this->returnInfo_ && this->returnInfo_->isValue())
271
271
  {
272
272
  return x;
273
273
  }
@@ -407,7 +407,41 @@ namespace Rice
407
407
  public:
408
408
  VALUE convert(char const* x)
409
409
  {
410
- return protect(rb_str_new2, x);
410
+ if (strlen(x) > 0 && x[0] == ':')
411
+ {
412
+ size_t symbolLength = strlen(x) - 1;
413
+ char* symbol = new char[symbolLength];
414
+ strncpy(symbol, x + 1, symbolLength);
415
+ ID id = protect(rb_intern2, symbol, (long)symbolLength);
416
+ delete[] symbol;
417
+ return protect(rb_id2sym, id);
418
+ }
419
+ else
420
+ {
421
+ return protect(rb_str_new2, x);
422
+ }
423
+ }
424
+ };
425
+
426
+ template<int N>
427
+ class To_Ruby<char[N]>
428
+ {
429
+ public:
430
+ VALUE convert(char const x[])
431
+ {
432
+ if (N > 0 && x[0] == ':')
433
+ {
434
+ // N count includes a NULL character at the end of the string
435
+ constexpr size_t symbolLength = N - 1;
436
+ char symbol[symbolLength];
437
+ strncpy(symbol, x + 1, symbolLength);
438
+ ID id = protect(rb_intern, symbol);
439
+ return protect(rb_id2sym, id);
440
+ }
441
+ else
442
+ {
443
+ return protect(rb_str_new2, x);
444
+ }
411
445
  }
412
446
  };
413
447
  }
@@ -1,7 +1,7 @@
1
1
  #ifndef Rice__detail__to_ruby_defn__hpp_
2
2
  #define Rice__detail__to_ruby_defn__hpp_
3
3
 
4
- #include "rice_traits.hpp"
4
+ #include "../traits/rice_traits.hpp"
5
5
 
6
6
  namespace Rice
7
7
  {
@@ -78,5 +78,11 @@ namespace Rice
78
78
  {
79
79
  return CLASS_OF(value());
80
80
  }
81
+
82
+ inline Object Module::module_eval(String const& s)
83
+ {
84
+ const VALUE argv[] = { s.value() };
85
+ return detail::protect(rb_mod_module_eval, 1, &argv[0], this->value());
86
+ }
81
87
  }
82
88
  #endif // Rice__Forward_Declares__ipp_
@@ -5,10 +5,6 @@
5
5
 
6
6
  namespace Rice
7
7
  {
8
- template<typename Function_T>
9
- [[deprecated("Please call define_global_function with Arg parameters")]]
10
- void define_global_function(char const * name, Function_T&& func, MethodInfo* arguments);
11
-
12
8
  //! Define an global function
13
9
  /*! The method's implementation can be any function or static member
14
10
  * function. A wrapper will be generated which will convert the arguments
@@ -1,11 +1,5 @@
1
1
  #include "cpp_api/Module.hpp"
2
2
 
3
- template<typename Function_T>
4
- void Rice::define_global_function(char const * name, Function_T&& func, MethodInfo* methodInfo)
5
- {
6
- Module(rb_mKernel).define_module_function(name, std::forward<Function_T>(func), methodInfo);
7
- }
8
-
9
3
  template<typename Function_T, typename...Arg_Ts>
10
4
  void Rice::define_global_function(char const * name, Function_T&& func, Arg_Ts const& ...args)
11
5
  {
data/rice/rice.hpp CHANGED
@@ -1,56 +1,61 @@
1
1
  #ifndef Rice__hpp_
2
2
  #define Rice__hpp_
3
3
 
4
+ // Traits
4
5
  #include "detail/ruby.hpp"
5
- #include "detail/rice_traits.hpp"
6
- #include "detail/function_traits.hpp"
6
+ #include "traits/rice_traits.hpp"
7
+ #include "traits/function_traits.hpp"
8
+ #include "traits/method_traits.hpp"
9
+ #include "traits/attribute_traits.hpp"
10
+
11
+ // Code for C++ to call Ruby
12
+ #include "Exception_defn.hpp"
13
+ #include "detail/Jump_Tag.hpp"
14
+ #include "detail/RubyFunction.hpp"
15
+
16
+ // Code for Ruby to call C++
17
+ #include "detail/ExceptionHandler.hpp"
7
18
  #include "detail/Type.hpp"
8
19
  #include "detail/TypeRegistry.hpp"
20
+ #include "detail/InstanceRegistry.hpp"
21
+ #include "detail/HandlerRegistry.hpp"
22
+ #include "detail/NativeRegistry.hpp"
23
+ #include "detail/Registries.hpp"
24
+ #include "detail/cpp_protect.hpp"
9
25
  #include "detail/Wrapper.hpp"
10
- #include "detail/default_allocation_func.hpp"
11
- #include "detail/Jump_Tag.hpp"
12
- #include "Exception_defn.hpp"
13
- #include "detail/RubyFunction.hpp"
14
26
  #include "Return.hpp"
15
27
  #include "Arg.hpp"
28
+ #include "detail/MethodInfo.hpp"
16
29
  #include "detail/from_ruby.hpp"
17
30
  #include "detail/to_ruby.hpp"
18
- #include "detail/MethodInfo.hpp"
19
- #include "detail/Exception_Handler.hpp"
20
- #include "detail/Iterator.hpp"
31
+ #include "Identifier.hpp"
21
32
  #include "Exception.ipp"
22
- #include "detail/method_data.hpp"
23
- #include "ruby_try_catch.hpp"
24
33
  #include "detail/NativeAttribute.hpp"
25
34
  #include "detail/NativeFunction.hpp"
35
+ #include "detail/NativeIterator.hpp"
36
+ #include "HandlerRegistration.hpp"
26
37
 
27
- #include "ruby_mark.hpp"
28
-
29
- #include "Identifier.hpp"
30
-
38
+ // C++ classes for using the Ruby API
31
39
  #include "cpp_api/Object.hpp"
32
40
  #include "cpp_api/Builtin_Object.hpp"
33
41
  #include "cpp_api/String.hpp"
34
42
  #include "cpp_api/Array.hpp"
35
43
  #include "cpp_api/Hash.hpp"
36
44
  #include "cpp_api/Symbol.hpp"
37
-
38
- #include "Address_Registration_Guard.hpp"
39
45
  #include "cpp_api/Module.hpp"
40
- #include "global_function.hpp"
41
-
42
46
  #include "cpp_api/Class.hpp"
43
47
  #include "cpp_api/Struct.hpp"
48
+ #include "Address_Registration_Guard.hpp"
49
+ #include "global_function.hpp"
44
50
 
51
+ // Code involed in creating custom DataTypes (ie, Ruby classes that wrap C++ classes)
52
+ #include "ruby_mark.hpp"
53
+ #include "detail/default_allocation_func.hpp"
45
54
  #include "Director.hpp"
46
55
  #include "Data_Type.hpp"
56
+ #include "detail/default_allocation_func.ipp"
47
57
  #include "Constructor.hpp"
48
58
  #include "Data_Object.hpp"
49
- #include "detail/Iterator.ipp"
50
-
51
- // Dependent on Data_Object due to the way method metadata is stored in the Ruby class
52
- #include "detail/default_allocation_func.ipp"
53
-
54
59
  #include "Enum.hpp"
55
60
 
56
61
  // Dependent on Module, Class, Array and String
data/rice/stl.hpp CHANGED
@@ -4,8 +4,13 @@
4
4
  #include "stl/string.hpp"
5
5
  #include "stl/complex.hpp"
6
6
  #include "stl/optional.hpp"
7
- #include "stl/pair.hpp"
7
+ #include "stl/reference_wrapper.hpp"
8
8
  #include "stl/smart_ptr.hpp"
9
+ #include "stl/monostate.hpp"
10
+ #include "stl/variant.hpp"
11
+ #include "stl/pair.hpp"
12
+ #include "stl/map.hpp"
13
+ #include "stl/unordered_map.hpp"
9
14
  #include "stl/vector.hpp"
10
15
 
11
16
  #endif // Rice__stl__hpp_
@@ -1,5 +1,4 @@
1
1
  require 'bundler/setup'
2
- require 'rice'
3
2
  require 'mkmf-rice'
4
3
 
5
4
  create_makefile('sample_callbacks')
@@ -1,5 +1,4 @@
1
1
  require 'bundler/setup'
2
- require 'rice'
3
2
  require 'mkmf-rice'
4
3
 
5
4
  create_makefile('sample_enum')