rice 4.7.1 → 4.8.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/CMakeLists.txt +14 -22
- data/CMakePresets.json +203 -75
- data/FindRuby.cmake +358 -123
- data/bin/rice-doc.rb +56 -141
- data/include/rice/api.hpp +248 -0
- data/include/rice/rice.hpp +2237 -1657
- data/include/rice/stl.hpp +346 -443
- data/lib/rice/doc/config.rb +70 -0
- data/lib/rice/doc/cpp_reference.rb +1 -4
- data/lib/rice/doc/mkdocs.rb +58 -20
- data/lib/rice/doc/rice.rb +20 -0
- data/lib/rice/doc.rb +1 -0
- data/lib/rice/make_rice_headers.rb +7 -0
- data/lib/rice/native_registry.rb +2 -2
- data/lib/rice/rbs.rb +2 -2
- data/lib/rice/version.rb +1 -1
- data/lib/rubygems_plugin.rb +12 -9
- data/rice/Arg.hpp +12 -6
- data/rice/Arg.ipp +14 -7
- data/rice/Buffer.ipp +44 -40
- data/rice/Callback.hpp +1 -1
- data/rice/Callback.ipp +2 -7
- data/rice/Constructor.hpp +1 -1
- data/rice/Constructor.ipp +11 -11
- data/rice/Data_Object.ipp +15 -15
- data/rice/Data_Type.hpp +9 -10
- data/rice/Data_Type.ipp +22 -25
- data/rice/Director.hpp +1 -0
- data/rice/Enum.ipp +58 -39
- data/rice/Exception.hpp +4 -4
- data/rice/Exception.ipp +7 -7
- data/rice/NoGVL.hpp +13 -0
- data/rice/Reference.hpp +56 -0
- data/rice/Reference.ipp +96 -0
- data/rice/Return.hpp +4 -1
- data/rice/Return.ipp +0 -6
- data/rice/cpp_api/Array.hpp +41 -4
- data/rice/cpp_api/Array.ipp +105 -9
- data/rice/cpp_api/Class.hpp +2 -2
- data/rice/cpp_api/Class.ipp +4 -4
- data/rice/cpp_api/Hash.ipp +7 -4
- data/rice/cpp_api/Module.hpp +4 -4
- data/rice/cpp_api/Module.ipp +12 -10
- data/rice/cpp_api/Object.hpp +4 -4
- data/rice/cpp_api/Object.ipp +15 -12
- data/rice/cpp_api/String.hpp +2 -2
- data/rice/cpp_api/String.ipp +11 -8
- data/rice/cpp_api/Symbol.ipp +7 -7
- data/rice/cpp_api/shared_methods.hpp +5 -9
- data/rice/detail/InstanceRegistry.hpp +0 -2
- data/rice/detail/Native.hpp +31 -21
- data/rice/detail/Native.ipp +282 -130
- data/rice/detail/NativeAttributeGet.hpp +5 -7
- data/rice/detail/NativeAttributeGet.ipp +26 -26
- data/rice/detail/NativeAttributeSet.hpp +2 -4
- data/rice/detail/NativeAttributeSet.ipp +20 -16
- data/rice/detail/NativeCallback.hpp +77 -0
- data/rice/detail/NativeCallback.ipp +280 -0
- data/rice/detail/NativeFunction.hpp +11 -21
- data/rice/detail/NativeFunction.ipp +58 -119
- data/rice/detail/NativeInvoker.hpp +4 -4
- data/rice/detail/NativeInvoker.ipp +7 -7
- data/rice/detail/NativeIterator.hpp +2 -4
- data/rice/detail/NativeIterator.ipp +18 -14
- data/rice/detail/NativeMethod.hpp +10 -20
- data/rice/detail/NativeMethod.ipp +54 -114
- data/rice/detail/NativeProc.hpp +5 -7
- data/rice/detail/NativeProc.ipp +39 -28
- data/rice/detail/NativeRegistry.hpp +0 -1
- data/rice/detail/Parameter.hpp +15 -8
- data/rice/detail/Parameter.ipp +102 -43
- data/rice/detail/Proc.ipp +14 -28
- data/rice/detail/RubyType.ipp +2 -53
- data/rice/detail/Type.hpp +23 -7
- data/rice/detail/Type.ipp +73 -93
- data/rice/detail/TypeRegistry.ipp +5 -4
- data/rice/detail/Wrapper.hpp +1 -1
- data/rice/detail/Wrapper.ipp +18 -10
- data/rice/detail/from_ruby.hpp +8 -6
- data/rice/detail/from_ruby.ipp +306 -173
- data/rice/detail/ruby.hpp +23 -0
- data/rice/libc/file.hpp +4 -4
- data/rice/rice.hpp +6 -8
- data/rice/rice_api/Native.ipp +5 -1
- data/rice/rice_api/Parameter.ipp +1 -1
- data/rice/ruby_mark.hpp +2 -1
- data/rice/stl/complex.ipp +12 -8
- data/rice/stl/map.ipp +27 -22
- data/rice/stl/monostate.ipp +16 -12
- data/rice/stl/multimap.hpp +0 -2
- data/rice/stl/multimap.ipp +27 -22
- data/rice/stl/optional.ipp +27 -11
- data/rice/stl/pair.ipp +5 -5
- data/rice/stl/reference_wrapper.ipp +5 -4
- data/rice/stl/set.ipp +16 -16
- data/rice/stl/shared_ptr.hpp +0 -16
- data/rice/stl/shared_ptr.ipp +34 -190
- data/rice/stl/string.ipp +18 -18
- data/rice/stl/string_view.ipp +1 -1
- data/rice/stl/tuple.ipp +15 -36
- data/rice/stl/unique_ptr.ipp +18 -8
- data/rice/stl/unordered_map.ipp +20 -15
- data/rice/stl/variant.ipp +37 -21
- data/rice/stl/vector.ipp +41 -36
- data/rice/traits/function_traits.hpp +19 -19
- data/rice/traits/method_traits.hpp +4 -4
- data/rice/traits/rice_traits.hpp +162 -39
- data/rice.gemspec +1 -3
- data/test/test_Array.cpp +261 -3
- data/test/test_Attribute.cpp +6 -3
- data/test/test_Buffer.cpp +6 -42
- data/test/test_Callback.cpp +77 -23
- data/test/test_Data_Object.cpp +1 -1
- data/test/test_Data_Type.cpp +21 -22
- data/test/test_Director.cpp +2 -4
- data/test/test_Enum.cpp +34 -5
- data/test/test_File.cpp +9 -5
- data/test/test_From_Ruby.cpp +4 -3
- data/test/test_GVL.cpp +3 -3
- data/test/test_Hash.cpp +1 -1
- data/test/test_Iterator.cpp +54 -22
- data/test/test_Keep_Alive.cpp +1 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +1 -1
- data/test/test_Module.cpp +5 -5
- data/test/test_Overloads.cpp +345 -48
- data/test/test_Proc.cpp +54 -0
- data/test/test_Reference.cpp +181 -0
- data/test/test_Self.cpp +2 -2
- data/test/test_Stl_Set.cpp +6 -6
- data/test/test_Stl_SharedPtr.cpp +54 -30
- data/test/test_Stl_String_View.cpp +4 -2
- data/test/test_Stl_Tuple.cpp +1 -1
- data/test/test_Stl_Variant.cpp +6 -14
- data/test/test_Stl_Vector.cpp +61 -30
- data/test/test_String.cpp +4 -2
- data/test/test_Struct.cpp +1 -1
- data/test/test_Symbol.cpp +1 -1
- data/test/test_To_Ruby.cpp +1 -0
- data/test/test_Type.cpp +36 -35
- data/test/test_global_functions.cpp +1 -1
- data/test/unittest.cpp +1 -1
- data/test/unittest.hpp +5 -5
- metadata +10 -10
- data/rice/Function.hpp +0 -17
- data/rice/Function.ipp +0 -13
- data/rice/detail/MethodInfo.hpp +0 -48
- data/rice/detail/MethodInfo.ipp +0 -99
- data/rice/detail/NativeCallbackFFI.hpp +0 -55
- data/rice/detail/NativeCallbackFFI.ipp +0 -152
- data/rice/detail/NativeCallbackSimple.hpp +0 -30
- data/rice/detail/NativeCallbackSimple.ipp +0 -29
data/include/rice/stl.hpp
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
// This file is part of [rice](https://github.com/ruby-rice/rice).
|
|
2
|
+
//
|
|
3
|
+
// Copyright (C) 2025 Jason Roelofs <jasongroelofs@gmail.com>
|
|
4
|
+
// Paul Brannan <curlypaul924@gmail.com>,
|
|
5
|
+
// Charlie Savage
|
|
6
|
+
//
|
|
7
|
+
// Redistribution and use in source and binary forms, with or without
|
|
8
|
+
// modification, are permitted provided that the following conditions
|
|
9
|
+
// are met:
|
|
10
|
+
//
|
|
11
|
+
// 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
// notice, this list of conditions and the following disclaimer.
|
|
13
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
// documentation and/or other materials provided with the distribution.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
18
|
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
19
|
+
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
20
|
+
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
21
|
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
22
|
+
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
+
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
1
28
|
#ifndef Rice__stl__hpp_
|
|
2
29
|
#define Rice__stl__hpp_
|
|
3
30
|
|
|
@@ -162,7 +189,7 @@ namespace Rice::detail
|
|
|
162
189
|
public:
|
|
163
190
|
To_Ruby() = default;
|
|
164
191
|
|
|
165
|
-
explicit To_Ruby(
|
|
192
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
166
193
|
{
|
|
167
194
|
}
|
|
168
195
|
|
|
@@ -172,7 +199,7 @@ namespace Rice::detail
|
|
|
172
199
|
}
|
|
173
200
|
|
|
174
201
|
private:
|
|
175
|
-
|
|
202
|
+
Arg* arg_ = nullptr;
|
|
176
203
|
};
|
|
177
204
|
|
|
178
205
|
template<>
|
|
@@ -181,7 +208,7 @@ namespace Rice::detail
|
|
|
181
208
|
public:
|
|
182
209
|
To_Ruby() = default;
|
|
183
210
|
|
|
184
|
-
explicit To_Ruby(
|
|
211
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
185
212
|
{
|
|
186
213
|
}
|
|
187
214
|
|
|
@@ -191,7 +218,7 @@ namespace Rice::detail
|
|
|
191
218
|
}
|
|
192
219
|
|
|
193
220
|
private:
|
|
194
|
-
|
|
221
|
+
Arg* arg_ = nullptr;
|
|
195
222
|
};
|
|
196
223
|
|
|
197
224
|
template<int N>
|
|
@@ -200,7 +227,7 @@ namespace Rice::detail
|
|
|
200
227
|
public:
|
|
201
228
|
To_Ruby() = default;
|
|
202
229
|
|
|
203
|
-
explicit To_Ruby(
|
|
230
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
204
231
|
{
|
|
205
232
|
}
|
|
206
233
|
|
|
@@ -211,7 +238,7 @@ namespace Rice::detail
|
|
|
211
238
|
return dataObject.value();
|
|
212
239
|
}
|
|
213
240
|
private:
|
|
214
|
-
|
|
241
|
+
Arg* arg_ = nullptr;
|
|
215
242
|
};
|
|
216
243
|
|
|
217
244
|
template<>
|
|
@@ -220,14 +247,14 @@ namespace Rice::detail
|
|
|
220
247
|
public:
|
|
221
248
|
To_Ruby() = default;
|
|
222
249
|
|
|
223
|
-
explicit To_Ruby(
|
|
250
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
224
251
|
{
|
|
225
252
|
}
|
|
226
253
|
|
|
227
254
|
VALUE convert(const std::string* value)
|
|
228
255
|
{
|
|
229
|
-
bool isOwner = this->
|
|
230
|
-
bool isBuffer = this->
|
|
256
|
+
bool isOwner = this->arg_ && this->arg_->isOwner();
|
|
257
|
+
bool isBuffer = dynamic_cast<ReturnBuffer*>(this->arg_) ? true : false;
|
|
231
258
|
|
|
232
259
|
if (isBuffer)
|
|
233
260
|
{
|
|
@@ -241,7 +268,7 @@ namespace Rice::detail
|
|
|
241
268
|
}
|
|
242
269
|
|
|
243
270
|
private:
|
|
244
|
-
|
|
271
|
+
Arg* arg_ = nullptr;
|
|
245
272
|
};
|
|
246
273
|
|
|
247
274
|
template<>
|
|
@@ -250,7 +277,7 @@ namespace Rice::detail
|
|
|
250
277
|
public:
|
|
251
278
|
To_Ruby() = default;
|
|
252
279
|
|
|
253
|
-
explicit To_Ruby(
|
|
280
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
254
281
|
{
|
|
255
282
|
}
|
|
256
283
|
|
|
@@ -260,7 +287,7 @@ namespace Rice::detail
|
|
|
260
287
|
}
|
|
261
288
|
|
|
262
289
|
private:
|
|
263
|
-
|
|
290
|
+
Arg* arg_ = nullptr;
|
|
264
291
|
};
|
|
265
292
|
|
|
266
293
|
/*template<>
|
|
@@ -269,7 +296,7 @@ namespace Rice::detail
|
|
|
269
296
|
public:
|
|
270
297
|
To_Ruby() = default;
|
|
271
298
|
|
|
272
|
-
explicit To_Ruby(
|
|
299
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
273
300
|
{
|
|
274
301
|
}
|
|
275
302
|
|
|
@@ -281,7 +308,7 @@ namespace Rice::detail
|
|
|
281
308
|
}
|
|
282
309
|
|
|
283
310
|
private:
|
|
284
|
-
|
|
311
|
+
Arg* arg_ = nullptr;
|
|
285
312
|
};*/
|
|
286
313
|
|
|
287
314
|
template<>
|
|
@@ -294,7 +321,7 @@ namespace Rice::detail
|
|
|
294
321
|
{
|
|
295
322
|
}
|
|
296
323
|
|
|
297
|
-
|
|
324
|
+
double is_convertible(VALUE value)
|
|
298
325
|
{
|
|
299
326
|
switch (rb_type(value))
|
|
300
327
|
{
|
|
@@ -326,7 +353,7 @@ namespace Rice::detail
|
|
|
326
353
|
{
|
|
327
354
|
}
|
|
328
355
|
|
|
329
|
-
|
|
356
|
+
double is_convertible(VALUE value)
|
|
330
357
|
{
|
|
331
358
|
switch (rb_type(value))
|
|
332
359
|
{
|
|
@@ -360,7 +387,7 @@ namespace Rice::detail
|
|
|
360
387
|
{
|
|
361
388
|
}
|
|
362
389
|
|
|
363
|
-
|
|
390
|
+
double is_convertible(VALUE value)
|
|
364
391
|
{
|
|
365
392
|
switch (rb_type(value))
|
|
366
393
|
{
|
|
@@ -394,7 +421,7 @@ namespace Rice::detail
|
|
|
394
421
|
{
|
|
395
422
|
}
|
|
396
423
|
|
|
397
|
-
|
|
424
|
+
double is_convertible(VALUE value)
|
|
398
425
|
{
|
|
399
426
|
switch (rb_type(value))
|
|
400
427
|
{
|
|
@@ -489,7 +516,7 @@ namespace Rice::detail
|
|
|
489
516
|
{
|
|
490
517
|
}
|
|
491
518
|
|
|
492
|
-
|
|
519
|
+
double is_convertible(VALUE value)
|
|
493
520
|
{
|
|
494
521
|
switch (rb_type(value))
|
|
495
522
|
{
|
|
@@ -540,7 +567,7 @@ namespace Rice::detail
|
|
|
540
567
|
public:
|
|
541
568
|
To_Ruby() = default;
|
|
542
569
|
|
|
543
|
-
explicit To_Ruby(
|
|
570
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
544
571
|
{
|
|
545
572
|
}
|
|
546
573
|
|
|
@@ -553,7 +580,7 @@ namespace Rice::detail
|
|
|
553
580
|
}
|
|
554
581
|
|
|
555
582
|
private:
|
|
556
|
-
|
|
583
|
+
Arg* arg_ = nullptr;
|
|
557
584
|
};
|
|
558
585
|
|
|
559
586
|
template<typename T>
|
|
@@ -562,7 +589,7 @@ namespace Rice::detail
|
|
|
562
589
|
public:
|
|
563
590
|
To_Ruby() = default;
|
|
564
591
|
|
|
565
|
-
explicit To_Ruby(
|
|
592
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
566
593
|
{
|
|
567
594
|
}
|
|
568
595
|
|
|
@@ -575,7 +602,7 @@ namespace Rice::detail
|
|
|
575
602
|
}
|
|
576
603
|
|
|
577
604
|
private:
|
|
578
|
-
|
|
605
|
+
Arg* arg_ = nullptr;
|
|
579
606
|
};
|
|
580
607
|
|
|
581
608
|
template<typename T>
|
|
@@ -584,11 +611,11 @@ namespace Rice::detail
|
|
|
584
611
|
public:
|
|
585
612
|
From_Ruby() = default;
|
|
586
613
|
|
|
587
|
-
explicit From_Ruby(Arg* arg)
|
|
614
|
+
explicit From_Ruby(Arg* arg) :arg_(arg)
|
|
588
615
|
{
|
|
589
616
|
}
|
|
590
617
|
|
|
591
|
-
|
|
618
|
+
double is_convertible(VALUE value)
|
|
592
619
|
{
|
|
593
620
|
switch (rb_type(value))
|
|
594
621
|
{
|
|
@@ -607,6 +634,9 @@ namespace Rice::detail
|
|
|
607
634
|
|
|
608
635
|
return std::complex<T>(From_Ruby<T>().convert(real), From_Ruby<T>().convert(imaginary));
|
|
609
636
|
}
|
|
637
|
+
|
|
638
|
+
private:
|
|
639
|
+
Arg* arg_ = nullptr;
|
|
610
640
|
};
|
|
611
641
|
|
|
612
642
|
template<typename T>
|
|
@@ -615,11 +645,11 @@ namespace Rice::detail
|
|
|
615
645
|
public:
|
|
616
646
|
From_Ruby() = default;
|
|
617
647
|
|
|
618
|
-
explicit From_Ruby(Arg* arg)
|
|
648
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
619
649
|
{
|
|
620
650
|
}
|
|
621
651
|
|
|
622
|
-
|
|
652
|
+
double is_convertible(VALUE value)
|
|
623
653
|
{
|
|
624
654
|
switch (rb_type(value))
|
|
625
655
|
{
|
|
@@ -641,6 +671,7 @@ namespace Rice::detail
|
|
|
641
671
|
}
|
|
642
672
|
|
|
643
673
|
private:
|
|
674
|
+
Arg* arg_ = nullptr;
|
|
644
675
|
std::complex<T> converted_;
|
|
645
676
|
};
|
|
646
677
|
}
|
|
@@ -715,17 +746,17 @@ namespace Rice::detail
|
|
|
715
746
|
public:
|
|
716
747
|
To_Ruby() = default;
|
|
717
748
|
|
|
718
|
-
explicit To_Ruby(
|
|
749
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
719
750
|
{
|
|
720
751
|
}
|
|
721
752
|
|
|
722
|
-
VALUE convert(const std::nullopt_t&
|
|
753
|
+
VALUE convert(const std::nullopt_t&)
|
|
723
754
|
{
|
|
724
755
|
return Qnil;
|
|
725
756
|
}
|
|
726
757
|
|
|
727
758
|
private:
|
|
728
|
-
|
|
759
|
+
Arg* arg_ = nullptr;
|
|
729
760
|
};
|
|
730
761
|
|
|
731
762
|
template<typename T>
|
|
@@ -734,7 +765,7 @@ namespace Rice::detail
|
|
|
734
765
|
public:
|
|
735
766
|
To_Ruby() = default;
|
|
736
767
|
|
|
737
|
-
explicit To_Ruby(
|
|
768
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
738
769
|
{
|
|
739
770
|
}
|
|
740
771
|
|
|
@@ -750,8 +781,20 @@ namespace Rice::detail
|
|
|
750
781
|
}
|
|
751
782
|
}
|
|
752
783
|
|
|
784
|
+
VALUE convert(const std::optional<T>& data)
|
|
785
|
+
{
|
|
786
|
+
if (data.has_value())
|
|
787
|
+
{
|
|
788
|
+
return To_Ruby<T>().convert(data.value());
|
|
789
|
+
}
|
|
790
|
+
else
|
|
791
|
+
{
|
|
792
|
+
return Qnil;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
753
796
|
private:
|
|
754
|
-
|
|
797
|
+
Arg* arg_ = nullptr;
|
|
755
798
|
};
|
|
756
799
|
|
|
757
800
|
template<typename T>
|
|
@@ -760,7 +803,7 @@ namespace Rice::detail
|
|
|
760
803
|
public:
|
|
761
804
|
To_Ruby() = default;
|
|
762
805
|
|
|
763
|
-
explicit To_Ruby(
|
|
806
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
764
807
|
{
|
|
765
808
|
}
|
|
766
809
|
|
|
@@ -777,7 +820,7 @@ namespace Rice::detail
|
|
|
777
820
|
}
|
|
778
821
|
|
|
779
822
|
private:
|
|
780
|
-
|
|
823
|
+
Arg* arg_ = nullptr;
|
|
781
824
|
};
|
|
782
825
|
|
|
783
826
|
template<typename T>
|
|
@@ -786,11 +829,11 @@ namespace Rice::detail
|
|
|
786
829
|
public:
|
|
787
830
|
From_Ruby() = default;
|
|
788
831
|
|
|
789
|
-
explicit From_Ruby(Arg* arg)
|
|
832
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
790
833
|
{
|
|
791
834
|
}
|
|
792
835
|
|
|
793
|
-
|
|
836
|
+
double is_convertible(VALUE value)
|
|
794
837
|
{
|
|
795
838
|
switch (rb_type(value))
|
|
796
839
|
{
|
|
@@ -813,6 +856,9 @@ namespace Rice::detail
|
|
|
813
856
|
return From_Ruby<T>().convert(value);
|
|
814
857
|
}
|
|
815
858
|
}
|
|
859
|
+
|
|
860
|
+
private:
|
|
861
|
+
Arg* arg_ = nullptr;
|
|
816
862
|
};
|
|
817
863
|
|
|
818
864
|
template<typename T>
|
|
@@ -821,11 +867,11 @@ namespace Rice::detail
|
|
|
821
867
|
public:
|
|
822
868
|
From_Ruby() = default;
|
|
823
869
|
|
|
824
|
-
explicit From_Ruby(Arg* arg)
|
|
870
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
825
871
|
{
|
|
826
872
|
}
|
|
827
873
|
|
|
828
|
-
|
|
874
|
+
double is_convertible(VALUE value)
|
|
829
875
|
{
|
|
830
876
|
switch (rb_type(value))
|
|
831
877
|
{
|
|
@@ -850,6 +896,7 @@ namespace Rice::detail
|
|
|
850
896
|
return this->converted_;
|
|
851
897
|
}
|
|
852
898
|
private:
|
|
899
|
+
Arg* arg_ = nullptr;
|
|
853
900
|
std::optional<T> converted_;
|
|
854
901
|
};
|
|
855
902
|
}
|
|
@@ -884,7 +931,7 @@ namespace Rice::detail
|
|
|
884
931
|
public:
|
|
885
932
|
To_Ruby() = default;
|
|
886
933
|
|
|
887
|
-
explicit To_Ruby(
|
|
934
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
888
935
|
{
|
|
889
936
|
}
|
|
890
937
|
|
|
@@ -894,7 +941,7 @@ namespace Rice::detail
|
|
|
894
941
|
}
|
|
895
942
|
|
|
896
943
|
private:
|
|
897
|
-
|
|
944
|
+
Arg* arg_ = nullptr;
|
|
898
945
|
};
|
|
899
946
|
|
|
900
947
|
template<typename T>
|
|
@@ -903,11 +950,11 @@ namespace Rice::detail
|
|
|
903
950
|
public:
|
|
904
951
|
From_Ruby() = default;
|
|
905
952
|
|
|
906
|
-
explicit From_Ruby(Arg* arg)
|
|
953
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
907
954
|
{
|
|
908
955
|
}
|
|
909
956
|
|
|
910
|
-
|
|
957
|
+
double is_convertible(VALUE value)
|
|
911
958
|
{
|
|
912
959
|
return this->converter_.is_convertible(value);
|
|
913
960
|
}
|
|
@@ -918,6 +965,7 @@ namespace Rice::detail
|
|
|
918
965
|
}
|
|
919
966
|
|
|
920
967
|
private:
|
|
968
|
+
Arg* arg_ = nullptr;
|
|
921
969
|
From_Ruby<T&> converter_;
|
|
922
970
|
};
|
|
923
971
|
}
|
|
@@ -997,11 +1045,11 @@ namespace Rice
|
|
|
997
1045
|
}
|
|
998
1046
|
else
|
|
999
1047
|
{
|
|
1000
|
-
klass_.define_method("to_s", [](const T&
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1048
|
+
klass_.define_method("to_s", [](const T&)
|
|
1049
|
+
{
|
|
1050
|
+
return "[Not printable]";
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1005
1053
|
}
|
|
1006
1054
|
|
|
1007
1055
|
private:
|
|
@@ -1175,20 +1223,25 @@ namespace Rice
|
|
|
1175
1223
|
{
|
|
1176
1224
|
if constexpr (detail::is_comparable_v<Mapped_T>)
|
|
1177
1225
|
{
|
|
1178
|
-
klass_.define_method("
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1226
|
+
klass_.define_method("==", [](T& map, T& other)->bool
|
|
1227
|
+
{
|
|
1228
|
+
return map == other;
|
|
1229
|
+
})
|
|
1230
|
+
.define_method("value?", [](T& map, Mapped_T& value) -> bool
|
|
1231
|
+
{
|
|
1232
|
+
auto it = std::find_if(map.begin(), map.end(),
|
|
1233
|
+
[&value](auto& pair)
|
|
1234
|
+
{
|
|
1235
|
+
return pair.second == value;
|
|
1236
|
+
});
|
|
1185
1237
|
|
|
1186
|
-
|
|
1238
|
+
return it != map.end();
|
|
1187
1239
|
});
|
|
1240
|
+
rb_define_alias(klass_, "eql?", "==");
|
|
1188
1241
|
}
|
|
1189
1242
|
else
|
|
1190
1243
|
{
|
|
1191
|
-
klass_.define_method("value?", [](T
|
|
1244
|
+
klass_.define_method("value?", [](T&, Mapped_T&) -> bool
|
|
1192
1245
|
{
|
|
1193
1246
|
return false;
|
|
1194
1247
|
});
|
|
@@ -1273,10 +1326,10 @@ namespace Rice
|
|
|
1273
1326
|
}
|
|
1274
1327
|
else
|
|
1275
1328
|
{
|
|
1276
|
-
klass_.define_method("to_s", [](const T&
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1329
|
+
klass_.define_method("to_s", [](const T&)
|
|
1330
|
+
{
|
|
1331
|
+
return "[Not printable]";
|
|
1332
|
+
});
|
|
1280
1333
|
}
|
|
1281
1334
|
}
|
|
1282
1335
|
|
|
@@ -1367,7 +1420,7 @@ namespace Rice
|
|
|
1367
1420
|
{
|
|
1368
1421
|
}
|
|
1369
1422
|
|
|
1370
|
-
|
|
1423
|
+
double is_convertible(VALUE value)
|
|
1371
1424
|
{
|
|
1372
1425
|
switch (rb_type(value))
|
|
1373
1426
|
{
|
|
@@ -1375,7 +1428,7 @@ namespace Rice
|
|
|
1375
1428
|
return Data_Type<std::map<T, U>>::is_descendant(value) ? Convertible::Exact : Convertible::None;
|
|
1376
1429
|
break;
|
|
1377
1430
|
case RUBY_T_HASH:
|
|
1378
|
-
return Convertible::
|
|
1431
|
+
return Convertible::Exact;
|
|
1379
1432
|
break;
|
|
1380
1433
|
default:
|
|
1381
1434
|
return Convertible::None;
|
|
@@ -1401,7 +1454,7 @@ namespace Rice
|
|
|
1401
1454
|
}
|
|
1402
1455
|
default:
|
|
1403
1456
|
{
|
|
1404
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
1457
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
1405
1458
|
detail::protect(rb_obj_classname, value), "std::map");
|
|
1406
1459
|
}
|
|
1407
1460
|
}
|
|
@@ -1421,7 +1474,7 @@ namespace Rice
|
|
|
1421
1474
|
{
|
|
1422
1475
|
}
|
|
1423
1476
|
|
|
1424
|
-
|
|
1477
|
+
double is_convertible(VALUE value)
|
|
1425
1478
|
{
|
|
1426
1479
|
switch (rb_type(value))
|
|
1427
1480
|
{
|
|
@@ -1429,7 +1482,7 @@ namespace Rice
|
|
|
1429
1482
|
return Data_Type<std::map<T, U>>::is_descendant(value) ? Convertible::Exact : Convertible::None;
|
|
1430
1483
|
break;
|
|
1431
1484
|
case RUBY_T_HASH:
|
|
1432
|
-
return Convertible::
|
|
1485
|
+
return Convertible::Exact;
|
|
1433
1486
|
break;
|
|
1434
1487
|
default:
|
|
1435
1488
|
return Convertible::None;
|
|
@@ -1456,7 +1509,7 @@ namespace Rice
|
|
|
1456
1509
|
}
|
|
1457
1510
|
default:
|
|
1458
1511
|
{
|
|
1459
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
1512
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
1460
1513
|
detail::protect(rb_obj_classname, value), "std::map");
|
|
1461
1514
|
}
|
|
1462
1515
|
}
|
|
@@ -1477,7 +1530,7 @@ namespace Rice
|
|
|
1477
1530
|
{
|
|
1478
1531
|
}
|
|
1479
1532
|
|
|
1480
|
-
|
|
1533
|
+
double is_convertible(VALUE value)
|
|
1481
1534
|
{
|
|
1482
1535
|
switch (rb_type(value))
|
|
1483
1536
|
{
|
|
@@ -1488,7 +1541,7 @@ namespace Rice
|
|
|
1488
1541
|
return Convertible::Exact;
|
|
1489
1542
|
break;
|
|
1490
1543
|
case RUBY_T_HASH:
|
|
1491
|
-
return Convertible::
|
|
1544
|
+
return Convertible::Exact;
|
|
1492
1545
|
break;
|
|
1493
1546
|
default:
|
|
1494
1547
|
return Convertible::None;
|
|
@@ -1515,7 +1568,7 @@ namespace Rice
|
|
|
1515
1568
|
}
|
|
1516
1569
|
default:
|
|
1517
1570
|
{
|
|
1518
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
1571
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
1519
1572
|
detail::protect(rb_obj_classname, value), "std::map");
|
|
1520
1573
|
}
|
|
1521
1574
|
}
|
|
@@ -1556,18 +1609,18 @@ namespace Rice::detail
|
|
|
1556
1609
|
public:
|
|
1557
1610
|
To_Ruby() = default;
|
|
1558
1611
|
|
|
1559
|
-
explicit To_Ruby(
|
|
1612
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
1560
1613
|
{
|
|
1561
1614
|
}
|
|
1562
1615
|
|
|
1563
|
-
VALUE convert(const std::monostate&
|
|
1616
|
+
VALUE convert(const std::monostate&)
|
|
1564
1617
|
{
|
|
1565
1618
|
return Qnil;
|
|
1566
1619
|
}
|
|
1567
1620
|
|
|
1568
1621
|
|
|
1569
1622
|
private:
|
|
1570
|
-
|
|
1623
|
+
Arg* arg_ = nullptr;
|
|
1571
1624
|
};
|
|
1572
1625
|
|
|
1573
1626
|
template<>
|
|
@@ -1576,17 +1629,17 @@ namespace Rice::detail
|
|
|
1576
1629
|
public:
|
|
1577
1630
|
To_Ruby() = default;
|
|
1578
1631
|
|
|
1579
|
-
explicit To_Ruby(
|
|
1632
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
1580
1633
|
{
|
|
1581
1634
|
}
|
|
1582
1635
|
|
|
1583
|
-
VALUE convert(const std::monostate&
|
|
1636
|
+
VALUE convert(const std::monostate&)
|
|
1584
1637
|
{
|
|
1585
1638
|
return Qnil;
|
|
1586
1639
|
}
|
|
1587
1640
|
|
|
1588
1641
|
private:
|
|
1589
|
-
|
|
1642
|
+
Arg* arg_ = nullptr;
|
|
1590
1643
|
};
|
|
1591
1644
|
|
|
1592
1645
|
template<>
|
|
@@ -1595,13 +1648,13 @@ namespace Rice::detail
|
|
|
1595
1648
|
public:
|
|
1596
1649
|
From_Ruby() = default;
|
|
1597
1650
|
|
|
1598
|
-
explicit From_Ruby(Arg* arg)
|
|
1651
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1599
1652
|
{
|
|
1600
1653
|
}
|
|
1601
1654
|
|
|
1602
|
-
|
|
1655
|
+
double is_convertible(VALUE value)
|
|
1603
1656
|
{
|
|
1604
|
-
return value == Qnil ?
|
|
1657
|
+
return value == Qnil ? 1.0 : 0.0;
|
|
1605
1658
|
}
|
|
1606
1659
|
|
|
1607
1660
|
std::monostate convert(VALUE value)
|
|
@@ -1615,6 +1668,9 @@ namespace Rice::detail
|
|
|
1615
1668
|
throw std::runtime_error("Can only convert nil values to std::monostate");
|
|
1616
1669
|
}
|
|
1617
1670
|
}
|
|
1671
|
+
|
|
1672
|
+
private:
|
|
1673
|
+
Arg* arg_ = nullptr;
|
|
1618
1674
|
};
|
|
1619
1675
|
|
|
1620
1676
|
template<>
|
|
@@ -1623,13 +1679,13 @@ namespace Rice::detail
|
|
|
1623
1679
|
public:
|
|
1624
1680
|
From_Ruby() = default;
|
|
1625
1681
|
|
|
1626
|
-
explicit From_Ruby(Arg* arg)
|
|
1682
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
1627
1683
|
{
|
|
1628
1684
|
}
|
|
1629
1685
|
|
|
1630
|
-
|
|
1686
|
+
double is_convertible(VALUE value)
|
|
1631
1687
|
{
|
|
1632
|
-
return value == Qnil ?
|
|
1688
|
+
return value == Qnil ? 1.0 : 0.0;
|
|
1633
1689
|
}
|
|
1634
1690
|
|
|
1635
1691
|
std::monostate& convert(VALUE value)
|
|
@@ -1645,6 +1701,7 @@ namespace Rice::detail
|
|
|
1645
1701
|
}
|
|
1646
1702
|
|
|
1647
1703
|
private:
|
|
1704
|
+
Arg* arg_ = nullptr;
|
|
1648
1705
|
std::monostate converted_ = std::monostate();
|
|
1649
1706
|
};
|
|
1650
1707
|
}
|
|
@@ -1652,8 +1709,6 @@ namespace Rice::detail
|
|
|
1652
1709
|
|
|
1653
1710
|
// ========= multimap.hpp =========
|
|
1654
1711
|
|
|
1655
|
-
#include <map>
|
|
1656
|
-
|
|
1657
1712
|
namespace Rice
|
|
1658
1713
|
{
|
|
1659
1714
|
template<typename K, typename T>
|
|
@@ -1770,20 +1825,25 @@ namespace Rice
|
|
|
1770
1825
|
{
|
|
1771
1826
|
if constexpr (detail::is_comparable_v<Mapped_T>)
|
|
1772
1827
|
{
|
|
1773
|
-
klass_.define_method("
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1828
|
+
klass_.define_method("==", [](T& multimap, T& other)->bool
|
|
1829
|
+
{
|
|
1830
|
+
return multimap == other;
|
|
1831
|
+
})
|
|
1832
|
+
.define_method("value?", [](T& multimap, Mapped_T& value) -> bool
|
|
1833
|
+
{
|
|
1834
|
+
auto it = std::find_if(multimap.begin(), multimap.end(),
|
|
1835
|
+
[&value](auto& pair)
|
|
1836
|
+
{
|
|
1837
|
+
return pair.second == value;
|
|
1838
|
+
});
|
|
1780
1839
|
|
|
1781
|
-
|
|
1840
|
+
return it != multimap.end();
|
|
1782
1841
|
});
|
|
1842
|
+
rb_define_alias(klass_, "eql?", "==");
|
|
1783
1843
|
}
|
|
1784
1844
|
else
|
|
1785
1845
|
{
|
|
1786
|
-
klass_.define_method("value?", [](T
|
|
1846
|
+
klass_.define_method("value?", [](T&, Mapped_T&) -> bool
|
|
1787
1847
|
{
|
|
1788
1848
|
return false;
|
|
1789
1849
|
});
|
|
@@ -1852,10 +1912,10 @@ namespace Rice
|
|
|
1852
1912
|
}
|
|
1853
1913
|
else
|
|
1854
1914
|
{
|
|
1855
|
-
klass_.define_method("to_s", [](const T&
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1915
|
+
klass_.define_method("to_s", [](const T&)
|
|
1916
|
+
{
|
|
1917
|
+
return "[Not printable]";
|
|
1918
|
+
});
|
|
1859
1919
|
}
|
|
1860
1920
|
}
|
|
1861
1921
|
|
|
@@ -1943,7 +2003,7 @@ namespace Rice
|
|
|
1943
2003
|
{
|
|
1944
2004
|
}
|
|
1945
2005
|
|
|
1946
|
-
|
|
2006
|
+
double is_convertible(VALUE value)
|
|
1947
2007
|
{
|
|
1948
2008
|
switch (rb_type(value))
|
|
1949
2009
|
{
|
|
@@ -1951,7 +2011,7 @@ namespace Rice
|
|
|
1951
2011
|
return Data_Type<std::multimap<T, U>>::is_descendant(value) ? Convertible::Exact : Convertible::None;
|
|
1952
2012
|
break;
|
|
1953
2013
|
case RUBY_T_HASH:
|
|
1954
|
-
return Convertible::
|
|
2014
|
+
return Convertible::Exact;
|
|
1955
2015
|
break;
|
|
1956
2016
|
default:
|
|
1957
2017
|
return Convertible::None;
|
|
@@ -1977,7 +2037,7 @@ namespace Rice
|
|
|
1977
2037
|
}
|
|
1978
2038
|
default:
|
|
1979
2039
|
{
|
|
1980
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2040
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
1981
2041
|
detail::protect(rb_obj_classname, value), "std::multimap");
|
|
1982
2042
|
}
|
|
1983
2043
|
}
|
|
@@ -1997,7 +2057,7 @@ namespace Rice
|
|
|
1997
2057
|
{
|
|
1998
2058
|
}
|
|
1999
2059
|
|
|
2000
|
-
|
|
2060
|
+
double is_convertible(VALUE value)
|
|
2001
2061
|
{
|
|
2002
2062
|
switch (rb_type(value))
|
|
2003
2063
|
{
|
|
@@ -2005,7 +2065,7 @@ namespace Rice
|
|
|
2005
2065
|
return Data_Type<std::multimap<T, U>>::is_descendant(value) ? Convertible::Exact : Convertible::None;
|
|
2006
2066
|
break;
|
|
2007
2067
|
case RUBY_T_HASH:
|
|
2008
|
-
return Convertible::
|
|
2068
|
+
return Convertible::Exact;
|
|
2009
2069
|
break;
|
|
2010
2070
|
default:
|
|
2011
2071
|
return Convertible::None;
|
|
@@ -2032,7 +2092,7 @@ namespace Rice
|
|
|
2032
2092
|
}
|
|
2033
2093
|
default:
|
|
2034
2094
|
{
|
|
2035
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2095
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2036
2096
|
detail::protect(rb_obj_classname, value), "std::multimap");
|
|
2037
2097
|
}
|
|
2038
2098
|
}
|
|
@@ -2053,7 +2113,7 @@ namespace Rice
|
|
|
2053
2113
|
{
|
|
2054
2114
|
}
|
|
2055
2115
|
|
|
2056
|
-
|
|
2116
|
+
double is_convertible(VALUE value)
|
|
2057
2117
|
{
|
|
2058
2118
|
switch (rb_type(value))
|
|
2059
2119
|
{
|
|
@@ -2064,7 +2124,7 @@ namespace Rice
|
|
|
2064
2124
|
return Convertible::Exact;
|
|
2065
2125
|
break;
|
|
2066
2126
|
case RUBY_T_HASH:
|
|
2067
|
-
return Convertible::
|
|
2127
|
+
return Convertible::Exact;
|
|
2068
2128
|
break;
|
|
2069
2129
|
default:
|
|
2070
2130
|
return Convertible::None;
|
|
@@ -2091,7 +2151,7 @@ namespace Rice
|
|
|
2091
2151
|
}
|
|
2092
2152
|
default:
|
|
2093
2153
|
{
|
|
2094
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2154
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2095
2155
|
detail::protect(rb_obj_classname, value), "std::multimap");
|
|
2096
2156
|
}
|
|
2097
2157
|
}
|
|
@@ -2333,10 +2393,10 @@ namespace Rice
|
|
|
2333
2393
|
}
|
|
2334
2394
|
else
|
|
2335
2395
|
{
|
|
2336
|
-
klass_.define_method("to_s", [](const T&
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2396
|
+
klass_.define_method("to_s", [](const T&)
|
|
2397
|
+
{
|
|
2398
|
+
return "[Not printable]";
|
|
2399
|
+
});
|
|
2340
2400
|
}
|
|
2341
2401
|
}
|
|
2342
2402
|
|
|
@@ -2423,7 +2483,7 @@ namespace Rice
|
|
|
2423
2483
|
{
|
|
2424
2484
|
}
|
|
2425
2485
|
|
|
2426
|
-
|
|
2486
|
+
double is_convertible(VALUE value)
|
|
2427
2487
|
{
|
|
2428
2488
|
switch (rb_type(value))
|
|
2429
2489
|
{
|
|
@@ -2435,7 +2495,7 @@ namespace Rice
|
|
|
2435
2495
|
Object object(value);
|
|
2436
2496
|
if (object.class_name().str() == setName)
|
|
2437
2497
|
{
|
|
2438
|
-
return Convertible::
|
|
2498
|
+
return Convertible::Exact;
|
|
2439
2499
|
}
|
|
2440
2500
|
}
|
|
2441
2501
|
default:
|
|
@@ -2459,12 +2519,12 @@ namespace Rice
|
|
|
2459
2519
|
{
|
|
2460
2520
|
return toSet<T>(value);
|
|
2461
2521
|
}
|
|
2462
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2522
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2463
2523
|
detail::protect(rb_obj_classname, value), "std::set");
|
|
2464
2524
|
}
|
|
2465
2525
|
default:
|
|
2466
2526
|
{
|
|
2467
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2527
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2468
2528
|
detail::protect(rb_obj_classname, value), "std::set");
|
|
2469
2529
|
}
|
|
2470
2530
|
}
|
|
@@ -2487,7 +2547,7 @@ namespace Rice
|
|
|
2487
2547
|
{
|
|
2488
2548
|
}
|
|
2489
2549
|
|
|
2490
|
-
|
|
2550
|
+
double is_convertible(VALUE value)
|
|
2491
2551
|
{
|
|
2492
2552
|
switch (rb_type(value))
|
|
2493
2553
|
{
|
|
@@ -2499,7 +2559,7 @@ namespace Rice
|
|
|
2499
2559
|
Object object(value);
|
|
2500
2560
|
if (object.class_name().str() == setName)
|
|
2501
2561
|
{
|
|
2502
|
-
return Convertible::
|
|
2562
|
+
return Convertible::Exact;
|
|
2503
2563
|
}
|
|
2504
2564
|
}
|
|
2505
2565
|
default:
|
|
@@ -2528,12 +2588,12 @@ namespace Rice
|
|
|
2528
2588
|
return this->converted_;
|
|
2529
2589
|
}
|
|
2530
2590
|
}
|
|
2531
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2591
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2532
2592
|
detail::protect(rb_obj_classname, value), "std::set");
|
|
2533
2593
|
}
|
|
2534
2594
|
default:
|
|
2535
2595
|
{
|
|
2536
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2596
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2537
2597
|
detail::protect(rb_obj_classname, value), "std::set");
|
|
2538
2598
|
}
|
|
2539
2599
|
}
|
|
@@ -2556,7 +2616,7 @@ namespace Rice
|
|
|
2556
2616
|
{
|
|
2557
2617
|
}
|
|
2558
2618
|
|
|
2559
|
-
|
|
2619
|
+
double is_convertible(VALUE value)
|
|
2560
2620
|
{
|
|
2561
2621
|
switch (rb_type(value))
|
|
2562
2622
|
{
|
|
@@ -2571,7 +2631,7 @@ namespace Rice
|
|
|
2571
2631
|
Object object(value);
|
|
2572
2632
|
if (object.class_name().str() == setName)
|
|
2573
2633
|
{
|
|
2574
|
-
return Convertible::
|
|
2634
|
+
return Convertible::Exact;
|
|
2575
2635
|
}
|
|
2576
2636
|
}
|
|
2577
2637
|
default:
|
|
@@ -2600,12 +2660,12 @@ namespace Rice
|
|
|
2600
2660
|
return &this->converted_;
|
|
2601
2661
|
}
|
|
2602
2662
|
}
|
|
2603
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2663
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2604
2664
|
detail::protect(rb_obj_classname, value), "std::set");
|
|
2605
2665
|
}
|
|
2606
2666
|
default:
|
|
2607
2667
|
{
|
|
2608
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
2668
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
2609
2669
|
detail::protect(rb_obj_classname, value), "std::set");
|
|
2610
2670
|
}
|
|
2611
2671
|
}
|
|
@@ -2621,22 +2681,6 @@ namespace Rice
|
|
|
2621
2681
|
|
|
2622
2682
|
// ========= shared_ptr.hpp =========
|
|
2623
2683
|
|
|
2624
|
-
namespace Rice::detail
|
|
2625
|
-
{
|
|
2626
|
-
template<typename T>
|
|
2627
|
-
class Wrapper<std::shared_ptr<T>> : public WrapperBase
|
|
2628
|
-
{
|
|
2629
|
-
public:
|
|
2630
|
-
Wrapper(const std::shared_ptr<T>& data);
|
|
2631
|
-
~Wrapper();
|
|
2632
|
-
void* get() override;
|
|
2633
|
-
std::shared_ptr<T>& data();
|
|
2634
|
-
|
|
2635
|
-
private:
|
|
2636
|
-
std::shared_ptr<T> data_;
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
|
|
2640
2684
|
namespace Rice
|
|
2641
2685
|
{
|
|
2642
2686
|
template<typename T>
|
|
@@ -2669,38 +2713,22 @@ namespace Rice
|
|
|
2669
2713
|
}
|
|
2670
2714
|
|
|
2671
2715
|
Identifier id(klassName);
|
|
2672
|
-
Data_Type_T result = define_class_under<
|
|
2673
|
-
define_constructor(Constructor<SharedPtr_T, typename SharedPtr_T::element_type*>(), Arg("value").takeOwnership());
|
|
2716
|
+
Data_Type_T result = define_class_under<SharedPtr_T>(rb_mStd, id);
|
|
2674
2717
|
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
template<typename T>
|
|
2683
|
-
inline Wrapper<std::shared_ptr<T>>::Wrapper(const std::shared_ptr<T>& data)
|
|
2684
|
-
: data_(data)
|
|
2685
|
-
{
|
|
2686
|
-
}
|
|
2687
|
-
|
|
2688
|
-
template<typename T>
|
|
2689
|
-
inline Wrapper<std::shared_ptr<T>>::~Wrapper()
|
|
2690
|
-
{
|
|
2691
|
-
Registries::instance.instances.remove(this->get());
|
|
2692
|
-
}
|
|
2718
|
+
// std::shared_ptr<void> cannot be constructed from void* because void is incomplete
|
|
2719
|
+
// and the deleter cannot be determined. So skip the constructor for void.
|
|
2720
|
+
// std::shared_ptr<T[]> (array types) also skip constructor - arrays need special handling.
|
|
2721
|
+
if constexpr (!std::is_void_v<T> && !std::is_array_v<T>)
|
|
2722
|
+
{
|
|
2723
|
+
result.define_constructor(Constructor<SharedPtr_T, typename SharedPtr_T::element_type*>(), Arg("value").takeOwnership());
|
|
2724
|
+
}
|
|
2693
2725
|
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
}
|
|
2726
|
+
result.
|
|
2727
|
+
define_method("get", &SharedPtr_T::get).
|
|
2728
|
+
define_method("use_count", &SharedPtr_T::use_count).
|
|
2729
|
+
define_method("empty?", &SharedPtr_T::operator bool);
|
|
2699
2730
|
|
|
2700
|
-
|
|
2701
|
-
inline std::shared_ptr<T>& Wrapper<std::shared_ptr<T>>::data()
|
|
2702
|
-
{
|
|
2703
|
-
return data_;
|
|
2731
|
+
return result;
|
|
2704
2732
|
}
|
|
2705
2733
|
}
|
|
2706
2734
|
|
|
@@ -2714,186 +2742,46 @@ namespace Rice::detail
|
|
|
2714
2742
|
{
|
|
2715
2743
|
if constexpr (std::is_fundamental_v<T>)
|
|
2716
2744
|
{
|
|
2717
|
-
|
|
2718
|
-
|
|
2745
|
+
Type<Pointer<T>>::verify();
|
|
2746
|
+
Type<Buffer<T>>::verify();
|
|
2719
2747
|
}
|
|
2720
2748
|
else
|
|
2721
2749
|
{
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
static VALUE rubyKlass()
|
|
2727
|
-
{
|
|
2728
|
-
if (Data_Type<std::shared_ptr<T>>::is_defined())
|
|
2729
|
-
{
|
|
2730
|
-
std::pair<VALUE, rb_data_type_t*> pair = Registries::instance.types.getType<std::shared_ptr<T>>();
|
|
2731
|
-
return pair.first;
|
|
2732
|
-
}
|
|
2733
|
-
else
|
|
2734
|
-
{
|
|
2735
|
-
TypeMapper<T> typeMapper;
|
|
2736
|
-
return typeMapper.rubyKlass();
|
|
2750
|
+
if (!Type<intrinsic_type<T>>::verify())
|
|
2751
|
+
{
|
|
2752
|
+
return false;
|
|
2753
|
+
}
|
|
2737
2754
|
}
|
|
2738
|
-
}
|
|
2739
|
-
};
|
|
2740
|
-
|
|
2741
|
-
template <typename T>
|
|
2742
|
-
class To_Ruby<std::shared_ptr<T>>
|
|
2743
|
-
{
|
|
2744
|
-
public:
|
|
2745
|
-
To_Ruby() = default;
|
|
2746
2755
|
|
|
2747
|
-
|
|
2748
|
-
{
|
|
2749
|
-
}
|
|
2750
|
-
|
|
2751
|
-
VALUE convert(std::shared_ptr<T>& data)
|
|
2752
|
-
{
|
|
2753
|
-
if constexpr (std::is_fundamental_v<T>)
|
|
2754
|
-
{
|
|
2755
|
-
return detail::wrap<std::shared_ptr<T>>(Data_Type<Pointer<T>>::klass(), Data_Type<Pointer<T>>::ruby_data_type(), data, true);
|
|
2756
|
-
}
|
|
2757
|
-
else
|
|
2758
|
-
{
|
|
2759
|
-
return detail::wrap<std::shared_ptr<T>>(Data_Type<T>::klass(), Data_Type<T>::ruby_data_type(), data, true);
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2756
|
+
define_shared_ptr<T>();
|
|
2762
2757
|
|
|
2763
|
-
|
|
2764
|
-
{
|
|
2765
|
-
if constexpr (std::is_fundamental_v<T>)
|
|
2766
|
-
{
|
|
2767
|
-
return detail::wrap<std::shared_ptr<T>>(Data_Type<Pointer<T>>::klass(), Data_Type<Pointer<T>>::ruby_data_type(), data, true);
|
|
2768
|
-
}
|
|
2769
|
-
else
|
|
2770
|
-
{
|
|
2771
|
-
return detail::wrap<std::shared_ptr<T>>(Data_Type<T>::klass(), Data_Type<T>::ruby_data_type(), data, true);
|
|
2772
|
-
}
|
|
2758
|
+
return true;
|
|
2773
2759
|
}
|
|
2774
2760
|
};
|
|
2775
2761
|
|
|
2776
|
-
|
|
2777
|
-
|
|
2762
|
+
// Specialization for array types std::shared_ptr<T[]>
|
|
2763
|
+
template<typename T>
|
|
2764
|
+
struct Type<std::shared_ptr<T[]>>
|
|
2778
2765
|
{
|
|
2779
|
-
|
|
2780
|
-
From_Ruby() = default;
|
|
2781
|
-
|
|
2782
|
-
explicit From_Ruby(Arg * arg) : arg_(arg)
|
|
2783
|
-
{
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
|
-
Convertible is_convertible(VALUE value)
|
|
2787
|
-
{
|
|
2788
|
-
switch (rb_type(value))
|
|
2789
|
-
{
|
|
2790
|
-
case RUBY_T_DATA:
|
|
2791
|
-
return Convertible::Exact;
|
|
2792
|
-
break;
|
|
2793
|
-
default:
|
|
2794
|
-
return Convertible::None;
|
|
2795
|
-
}
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
|
-
std::shared_ptr<T> convert(VALUE value)
|
|
2766
|
+
static bool verify()
|
|
2799
2767
|
{
|
|
2800
|
-
|
|
2801
|
-
WrapperBase* wrapperBase = detail::getWrapper(value);
|
|
2802
|
-
|
|
2803
|
-
// Was this shared_ptr created by the user from Ruby? If so it will
|
|
2804
|
-
// be wrapped as a pointer, std::shared_ptr<T>*. In the case just
|
|
2805
|
-
// return the shared pointer
|
|
2806
|
-
if (dynamic_cast<Wrapper<std::shared_ptr<T>*>*>(wrapperBase))
|
|
2807
|
-
{
|
|
2808
|
-
// Use unwrap to validate the underlying wrapper is the correct type
|
|
2809
|
-
std::shared_ptr<T>* ptr = unwrap<std::shared_ptr<T>>(value, Data_Type<std::shared_ptr<T>>::ruby_data_type(), false);
|
|
2810
|
-
return *ptr;
|
|
2811
|
-
}
|
|
2812
|
-
else if (std::is_fundamental_v<T>)
|
|
2768
|
+
if constexpr (std::is_fundamental_v<T>)
|
|
2813
2769
|
{
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
return wrapper->data();
|
|
2770
|
+
Type<Pointer<T>>::verify();
|
|
2771
|
+
Type<Buffer<T>>::verify();
|
|
2817
2772
|
}
|
|
2818
2773
|
else
|
|
2819
2774
|
{
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
}
|
|
2825
|
-
private:
|
|
2826
|
-
Arg* arg_ = nullptr;
|
|
2827
|
-
};
|
|
2828
|
-
|
|
2829
|
-
template <typename T>
|
|
2830
|
-
class To_Ruby<std::shared_ptr<T>&>
|
|
2831
|
-
{
|
|
2832
|
-
public:
|
|
2833
|
-
To_Ruby() = default;
|
|
2834
|
-
|
|
2835
|
-
explicit To_Ruby(Arg* arg)
|
|
2836
|
-
{
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
VALUE convert(std::shared_ptr<T>& data)
|
|
2840
|
-
{
|
|
2841
|
-
return detail::wrap(Data_Type<T>::klass(), Data_Type<T>::ruby_data_type(), data, true);
|
|
2842
|
-
}
|
|
2843
|
-
};
|
|
2844
|
-
|
|
2845
|
-
template <typename T>
|
|
2846
|
-
class From_Ruby<std::shared_ptr<T>&>
|
|
2847
|
-
{
|
|
2848
|
-
public:
|
|
2849
|
-
From_Ruby() = default;
|
|
2850
|
-
|
|
2851
|
-
explicit From_Ruby(Arg * arg) : arg_(arg)
|
|
2852
|
-
{
|
|
2853
|
-
}
|
|
2854
|
-
|
|
2855
|
-
Convertible is_convertible(VALUE value)
|
|
2856
|
-
{
|
|
2857
|
-
switch (rb_type(value))
|
|
2858
|
-
{
|
|
2859
|
-
case RUBY_T_DATA:
|
|
2860
|
-
return Convertible::Exact;
|
|
2861
|
-
break;
|
|
2862
|
-
default:
|
|
2863
|
-
return Convertible::None;
|
|
2775
|
+
if (!Type<intrinsic_type<T>>::verify())
|
|
2776
|
+
{
|
|
2777
|
+
return false;
|
|
2778
|
+
}
|
|
2864
2779
|
}
|
|
2865
|
-
}
|
|
2866
2780
|
|
|
2867
|
-
|
|
2868
|
-
{
|
|
2869
|
-
// Get the wrapper
|
|
2870
|
-
WrapperBase* wrapperBase = detail::getWrapper(value);
|
|
2781
|
+
define_shared_ptr<T[]>();
|
|
2871
2782
|
|
|
2872
|
-
|
|
2873
|
-
// be wrapped as a pointer, std::shared_ptr<T>*. In the case just
|
|
2874
|
-
// return the shared pointer
|
|
2875
|
-
if (dynamic_cast<Wrapper<std::shared_ptr<T>*>*>(wrapperBase))
|
|
2876
|
-
{
|
|
2877
|
-
// Use unwrap to validate the underlying wrapper is the correct type
|
|
2878
|
-
std::shared_ptr<T>* ptr = unwrap<std::shared_ptr<T>>(value, Data_Type<std::shared_ptr<T>>::ruby_data_type(), false);
|
|
2879
|
-
return *ptr;
|
|
2880
|
-
}
|
|
2881
|
-
else if (std::is_fundamental_v<T>)
|
|
2882
|
-
{
|
|
2883
|
-
// Get the wrapper again to validate T's type
|
|
2884
|
-
Wrapper<std::shared_ptr<T>>* wrapper = getWrapper<Wrapper<std::shared_ptr<T>>>(value, Data_Type<Pointer<T>>::ruby_data_type());
|
|
2885
|
-
return wrapper->data();
|
|
2886
|
-
}
|
|
2887
|
-
else
|
|
2888
|
-
{
|
|
2889
|
-
// Get the wrapper again to validate T's type
|
|
2890
|
-
Wrapper<std::shared_ptr<T>>* wrapper = getWrapper<Wrapper<std::shared_ptr<T>>>(value, Data_Type<T>::ruby_data_type());
|
|
2891
|
-
return wrapper->data();
|
|
2892
|
-
}
|
|
2783
|
+
return true;
|
|
2893
2784
|
}
|
|
2894
|
-
|
|
2895
|
-
private:
|
|
2896
|
-
Arg* arg_ = nullptr;
|
|
2897
2785
|
};
|
|
2898
2786
|
}
|
|
2899
2787
|
|
|
@@ -2912,7 +2800,7 @@ namespace Rice::detail
|
|
|
2912
2800
|
using Tuple_T = std::tuple<Types...>;
|
|
2913
2801
|
|
|
2914
2802
|
template<std::size_t... I>
|
|
2915
|
-
constexpr static bool verifyTypes(std::index_sequence<I...>&
|
|
2803
|
+
constexpr static bool verifyTypes(std::index_sequence<I...>&)
|
|
2916
2804
|
{
|
|
2917
2805
|
return (Type<std::tuple_element_t<I, Tuple_T>>::verify() && ...);
|
|
2918
2806
|
}
|
|
@@ -2936,7 +2824,7 @@ namespace Rice::detail
|
|
|
2936
2824
|
public:
|
|
2937
2825
|
To_Ruby() = default;
|
|
2938
2826
|
|
|
2939
|
-
explicit To_Ruby(
|
|
2827
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
2940
2828
|
{
|
|
2941
2829
|
}
|
|
2942
2830
|
|
|
@@ -2953,7 +2841,7 @@ namespace Rice::detail
|
|
|
2953
2841
|
}
|
|
2954
2842
|
|
|
2955
2843
|
private:
|
|
2956
|
-
|
|
2844
|
+
Arg* arg_ = nullptr;
|
|
2957
2845
|
};
|
|
2958
2846
|
|
|
2959
2847
|
template<typename...Types>
|
|
@@ -2962,7 +2850,7 @@ namespace Rice::detail
|
|
|
2962
2850
|
public:
|
|
2963
2851
|
To_Ruby() = default;
|
|
2964
2852
|
|
|
2965
|
-
explicit To_Ruby(
|
|
2853
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
2966
2854
|
{
|
|
2967
2855
|
}
|
|
2968
2856
|
|
|
@@ -2970,7 +2858,7 @@ namespace Rice::detail
|
|
|
2970
2858
|
{
|
|
2971
2859
|
Array result;
|
|
2972
2860
|
|
|
2973
|
-
bool isOwner = (this->
|
|
2861
|
+
bool isOwner = (this->arg_ && this->arg_->isOwner());
|
|
2974
2862
|
|
|
2975
2863
|
for_each_tuple(data, [&](auto& element)
|
|
2976
2864
|
{
|
|
@@ -2981,7 +2869,7 @@ namespace Rice::detail
|
|
|
2981
2869
|
}
|
|
2982
2870
|
|
|
2983
2871
|
private:
|
|
2984
|
-
|
|
2872
|
+
Arg* arg_ = nullptr;
|
|
2985
2873
|
};
|
|
2986
2874
|
|
|
2987
2875
|
template<typename...Types>
|
|
@@ -2990,35 +2878,28 @@ namespace Rice::detail
|
|
|
2990
2878
|
public:
|
|
2991
2879
|
using Tuple_T = std::tuple<Types...>;
|
|
2992
2880
|
|
|
2993
|
-
template<std::size_t... I>
|
|
2994
|
-
constexpr static bool verifyTypes(Array& array, std::index_sequence<I...>& indices)
|
|
2995
|
-
{
|
|
2996
|
-
return (Type<std::tuple_element_t<I, Tuple_T>>::verify() && ...);
|
|
2997
|
-
}
|
|
2998
|
-
|
|
2999
2881
|
From_Ruby() = default;
|
|
3000
2882
|
|
|
3001
|
-
explicit From_Ruby(Arg* arg)
|
|
2883
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
3002
2884
|
{
|
|
3003
2885
|
}
|
|
3004
2886
|
|
|
3005
|
-
|
|
2887
|
+
double is_convertible(VALUE value)
|
|
3006
2888
|
{
|
|
3007
|
-
Convertible result = Convertible::None;
|
|
3008
|
-
|
|
3009
2889
|
// The ruby value must be an array of the correct size
|
|
3010
2890
|
if (rb_type(value) != RUBY_T_ARRAY || Array(value).size() != std::tuple_size_v<Tuple_T>)
|
|
3011
2891
|
{
|
|
3012
|
-
return
|
|
2892
|
+
return Convertible::None;
|
|
3013
2893
|
}
|
|
3014
|
-
|
|
3015
|
-
// Now check that each tuple type is convertible
|
|
2894
|
+
|
|
2895
|
+
// Now check that each tuple type is convertible - use minimum score
|
|
2896
|
+
double result = Convertible::Exact;
|
|
3016
2897
|
Array array(value);
|
|
3017
2898
|
int i = 0;
|
|
3018
2899
|
for_each_tuple(this->fromRubys_,
|
|
3019
2900
|
[&](auto& fromRuby)
|
|
3020
2901
|
{
|
|
3021
|
-
result = result
|
|
2902
|
+
result = (std::min)(result, fromRuby.is_convertible(array[i].value()));
|
|
3022
2903
|
i++;
|
|
3023
2904
|
});
|
|
3024
2905
|
|
|
@@ -3026,7 +2907,7 @@ namespace Rice::detail
|
|
|
3026
2907
|
}
|
|
3027
2908
|
|
|
3028
2909
|
template <std::size_t... I>
|
|
3029
|
-
std::tuple<Types...> convertInternal(Array array, std::index_sequence<I...>&
|
|
2910
|
+
std::tuple<Types...> convertInternal(Array array, std::index_sequence<I...>&)
|
|
3030
2911
|
{
|
|
3031
2912
|
return std::forward_as_tuple(std::get<I>(this->fromRubys_).convert(array[I].value())...);
|
|
3032
2913
|
}
|
|
@@ -3039,25 +2920,11 @@ namespace Rice::detail
|
|
|
3039
2920
|
}
|
|
3040
2921
|
|
|
3041
2922
|
private:
|
|
2923
|
+
Arg* arg_ = nullptr;
|
|
3042
2924
|
// Possible converters we could use for this variant
|
|
3043
2925
|
using From_Ruby_Ts = std::tuple<From_Ruby<Types>...>;
|
|
3044
2926
|
From_Ruby_Ts fromRubys_;
|
|
3045
2927
|
};
|
|
3046
|
-
|
|
3047
|
-
/* template<typename...Types>
|
|
3048
|
-
class From_Ruby<std::tuple<Types...>&> : public From_Ruby<std::tuple<Types...>>
|
|
3049
|
-
{
|
|
3050
|
-
public:
|
|
3051
|
-
std::tuple<Types...>& convert(VALUE value)
|
|
3052
|
-
{
|
|
3053
|
-
int index = this->figureIndex(value);
|
|
3054
|
-
this->converted_ = this->convertInternal(value, index);
|
|
3055
|
-
return this->converted_;
|
|
3056
|
-
}
|
|
3057
|
-
|
|
3058
|
-
private:
|
|
3059
|
-
std::tuple<Types...> converted_;
|
|
3060
|
-
};*/
|
|
3061
2928
|
}
|
|
3062
2929
|
|
|
3063
2930
|
|
|
@@ -3146,7 +3013,7 @@ namespace Rice::detail
|
|
|
3146
3013
|
using Tuple_T = std::tuple<Types...>;
|
|
3147
3014
|
|
|
3148
3015
|
template<std::size_t... I>
|
|
3149
|
-
constexpr static bool verifyTypes(std::index_sequence<I...>&
|
|
3016
|
+
constexpr static bool verifyTypes(std::index_sequence<I...>&)
|
|
3150
3017
|
{
|
|
3151
3018
|
return (Type<std::tuple_element_t<I, Tuple_T>>::verify() && ...);
|
|
3152
3019
|
}
|
|
@@ -3170,18 +3037,23 @@ namespace Rice::detail
|
|
|
3170
3037
|
public:
|
|
3171
3038
|
To_Ruby() = default;
|
|
3172
3039
|
|
|
3173
|
-
explicit To_Ruby(
|
|
3040
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
3174
3041
|
{
|
|
3175
3042
|
}
|
|
3176
3043
|
|
|
3177
3044
|
template<typename U, typename V>
|
|
3178
3045
|
VALUE convertElement(U& data, bool takeOwnership)
|
|
3179
3046
|
{
|
|
3180
|
-
|
|
3047
|
+
Arg arg("arg1");
|
|
3048
|
+
if (takeOwnership)
|
|
3049
|
+
{
|
|
3050
|
+
arg.takeOwnership();
|
|
3051
|
+
}
|
|
3052
|
+
return To_Ruby<V>(&arg).convert(std::forward<V>(std::get<V>(data)));
|
|
3181
3053
|
}
|
|
3182
3054
|
|
|
3183
3055
|
template<typename U, std::size_t... I>
|
|
3184
|
-
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&
|
|
3056
|
+
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&)
|
|
3185
3057
|
{
|
|
3186
3058
|
// Create a tuple of the variant types so we can look over the tuple's types
|
|
3187
3059
|
using Tuple_T = std::tuple<Types...>;
|
|
@@ -3239,7 +3111,7 @@ namespace Rice::detail
|
|
|
3239
3111
|
}
|
|
3240
3112
|
|
|
3241
3113
|
private:
|
|
3242
|
-
|
|
3114
|
+
Arg* arg_ = nullptr;
|
|
3243
3115
|
};
|
|
3244
3116
|
|
|
3245
3117
|
template<typename...Types>
|
|
@@ -3248,25 +3120,31 @@ namespace Rice::detail
|
|
|
3248
3120
|
public:
|
|
3249
3121
|
To_Ruby() = default;
|
|
3250
3122
|
|
|
3251
|
-
explicit To_Ruby(
|
|
3123
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
3252
3124
|
{
|
|
3253
3125
|
}
|
|
3254
3126
|
|
|
3255
3127
|
template<typename U, typename V>
|
|
3256
3128
|
VALUE convertElement(U& data, bool takeOwnership)
|
|
3257
3129
|
{
|
|
3130
|
+
Arg arg("arg1");
|
|
3131
|
+
if (takeOwnership)
|
|
3132
|
+
{
|
|
3133
|
+
arg.takeOwnership();
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3258
3136
|
if constexpr (std::is_const_v<U>)
|
|
3259
3137
|
{
|
|
3260
|
-
return To_Ruby<V>().convert(std::get<V>(data));
|
|
3138
|
+
return To_Ruby<V>(&arg).convert(std::get<V>(data));
|
|
3261
3139
|
}
|
|
3262
3140
|
else
|
|
3263
3141
|
{
|
|
3264
|
-
return To_Ruby<V>().convert(std::forward<V>(std::get<V>(data)));
|
|
3142
|
+
return To_Ruby<V>(&arg).convert(std::forward<V>(std::get<V>(data)));
|
|
3265
3143
|
}
|
|
3266
3144
|
}
|
|
3267
3145
|
|
|
3268
3146
|
template<typename U, std::size_t... I>
|
|
3269
|
-
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&
|
|
3147
|
+
VALUE convertIterator(U& data, bool takeOwnership, std::index_sequence<I...>&)
|
|
3270
3148
|
{
|
|
3271
3149
|
// Create a tuple of the variant types so we can look over the tuple's types
|
|
3272
3150
|
using Tuple_T = std::tuple<Types...>;
|
|
@@ -3292,13 +3170,13 @@ namespace Rice::detail
|
|
|
3292
3170
|
template<typename U>
|
|
3293
3171
|
VALUE convert(U& data)
|
|
3294
3172
|
{
|
|
3295
|
-
bool isOwner = (this->
|
|
3173
|
+
bool isOwner = (this->arg_ && this->arg_->isOwner());
|
|
3296
3174
|
auto indices = std::make_index_sequence<std::variant_size_v<std::variant<Types...>>>{};
|
|
3297
3175
|
return convertIterator(data, isOwner, indices);
|
|
3298
3176
|
}
|
|
3299
3177
|
|
|
3300
3178
|
private:
|
|
3301
|
-
|
|
3179
|
+
Arg* arg_ = nullptr;
|
|
3302
3180
|
};
|
|
3303
3181
|
|
|
3304
3182
|
template<typename...Types>
|
|
@@ -3307,18 +3185,18 @@ namespace Rice::detail
|
|
|
3307
3185
|
public:
|
|
3308
3186
|
From_Ruby() = default;
|
|
3309
3187
|
|
|
3310
|
-
explicit From_Ruby(Arg* arg)
|
|
3188
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
3311
3189
|
{
|
|
3312
3190
|
}
|
|
3313
3191
|
|
|
3314
|
-
|
|
3192
|
+
double is_convertible(VALUE value)
|
|
3315
3193
|
{
|
|
3316
|
-
|
|
3194
|
+
double result = Convertible::None;
|
|
3317
3195
|
|
|
3318
3196
|
for_each_tuple(this->fromRubys_,
|
|
3319
3197
|
[&](auto& fromRuby)
|
|
3320
3198
|
{
|
|
3321
|
-
result = result
|
|
3199
|
+
result = (std::max)(result, fromRuby.is_convertible(value));
|
|
3322
3200
|
});
|
|
3323
3201
|
|
|
3324
3202
|
return result;
|
|
@@ -3330,17 +3208,17 @@ namespace Rice::detail
|
|
|
3330
3208
|
{
|
|
3331
3209
|
int i = 0;
|
|
3332
3210
|
int index = -1;
|
|
3333
|
-
|
|
3211
|
+
double foundScore = Convertible::None;
|
|
3334
3212
|
|
|
3335
3213
|
for_each_tuple(this->fromRubys_,
|
|
3336
3214
|
[&](auto& fromRuby)
|
|
3337
3215
|
{
|
|
3338
|
-
|
|
3216
|
+
double score = fromRuby.is_convertible(value);
|
|
3339
3217
|
|
|
3340
|
-
if (
|
|
3218
|
+
if (score > foundScore)
|
|
3341
3219
|
{
|
|
3342
3220
|
index = i;
|
|
3343
|
-
|
|
3221
|
+
foundScore = score;
|
|
3344
3222
|
}
|
|
3345
3223
|
i++;
|
|
3346
3224
|
});
|
|
@@ -3378,7 +3256,10 @@ namespace Rice::detail
|
|
|
3378
3256
|
return convertInternal<I + 1>(value, index);
|
|
3379
3257
|
}
|
|
3380
3258
|
}
|
|
3381
|
-
|
|
3259
|
+
else
|
|
3260
|
+
{
|
|
3261
|
+
rb_raise(rb_eArgError, "Could not find converter for variant");
|
|
3262
|
+
}
|
|
3382
3263
|
}
|
|
3383
3264
|
|
|
3384
3265
|
std::variant<Types...> convert(VALUE value)
|
|
@@ -3388,6 +3269,7 @@ namespace Rice::detail
|
|
|
3388
3269
|
}
|
|
3389
3270
|
|
|
3390
3271
|
private:
|
|
3272
|
+
Arg* arg_ = nullptr;
|
|
3391
3273
|
// Possible converters we could use for this variant
|
|
3392
3274
|
using From_Ruby_Ts = std::tuple<From_Ruby<Types>...>;
|
|
3393
3275
|
From_Ruby_Ts fromRubys_;
|
|
@@ -3399,7 +3281,7 @@ namespace Rice::detail
|
|
|
3399
3281
|
public:
|
|
3400
3282
|
From_Ruby() = default;
|
|
3401
3283
|
|
|
3402
|
-
explicit From_Ruby(Arg* arg)
|
|
3284
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
3403
3285
|
{
|
|
3404
3286
|
}
|
|
3405
3287
|
|
|
@@ -3411,6 +3293,7 @@ namespace Rice::detail
|
|
|
3411
3293
|
}
|
|
3412
3294
|
|
|
3413
3295
|
private:
|
|
3296
|
+
Arg* arg_ = nullptr;
|
|
3414
3297
|
std::variant<Types...> converted_;
|
|
3415
3298
|
};
|
|
3416
3299
|
}
|
|
@@ -3470,7 +3353,7 @@ namespace Rice::detail
|
|
|
3470
3353
|
public:
|
|
3471
3354
|
To_Ruby() = default;
|
|
3472
3355
|
|
|
3473
|
-
explicit To_Ruby(
|
|
3356
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
3474
3357
|
{
|
|
3475
3358
|
}
|
|
3476
3359
|
|
|
@@ -3487,7 +3370,7 @@ namespace Rice::detail
|
|
|
3487
3370
|
}
|
|
3488
3371
|
|
|
3489
3372
|
private:
|
|
3490
|
-
|
|
3373
|
+
Arg* arg_ = nullptr;
|
|
3491
3374
|
};
|
|
3492
3375
|
|
|
3493
3376
|
template <typename T>
|
|
@@ -3496,7 +3379,7 @@ namespace Rice::detail
|
|
|
3496
3379
|
public:
|
|
3497
3380
|
To_Ruby() = default;
|
|
3498
3381
|
|
|
3499
|
-
explicit To_Ruby(
|
|
3382
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
3500
3383
|
{
|
|
3501
3384
|
}
|
|
3502
3385
|
|
|
@@ -3507,7 +3390,7 @@ namespace Rice::detail
|
|
|
3507
3390
|
}
|
|
3508
3391
|
|
|
3509
3392
|
private:
|
|
3510
|
-
|
|
3393
|
+
Arg* arg_ = nullptr;
|
|
3511
3394
|
};
|
|
3512
3395
|
|
|
3513
3396
|
template <typename T>
|
|
@@ -3522,14 +3405,16 @@ namespace Rice::detail
|
|
|
3522
3405
|
|
|
3523
3406
|
From_Ruby() = default;
|
|
3524
3407
|
|
|
3525
|
-
explicit From_Ruby(Arg* arg)
|
|
3408
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
3526
3409
|
{
|
|
3527
3410
|
}
|
|
3528
3411
|
|
|
3529
|
-
|
|
3412
|
+
double is_convertible(VALUE value)
|
|
3530
3413
|
{
|
|
3531
3414
|
if (!is_same_smart_ptr(value))
|
|
3415
|
+
{
|
|
3532
3416
|
return Convertible::None;
|
|
3417
|
+
}
|
|
3533
3418
|
|
|
3534
3419
|
switch (rb_type(value))
|
|
3535
3420
|
{
|
|
@@ -3551,6 +3436,9 @@ namespace Rice::detail
|
|
|
3551
3436
|
}
|
|
3552
3437
|
return std::move(wrapper->data());
|
|
3553
3438
|
}
|
|
3439
|
+
|
|
3440
|
+
private:
|
|
3441
|
+
Arg* arg_ = nullptr;
|
|
3554
3442
|
};
|
|
3555
3443
|
|
|
3556
3444
|
template <typename T>
|
|
@@ -3565,14 +3453,16 @@ namespace Rice::detail
|
|
|
3565
3453
|
|
|
3566
3454
|
From_Ruby() = default;
|
|
3567
3455
|
|
|
3568
|
-
explicit From_Ruby(Arg* arg)
|
|
3456
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
3569
3457
|
{
|
|
3570
3458
|
}
|
|
3571
3459
|
|
|
3572
|
-
|
|
3460
|
+
double is_convertible(VALUE value)
|
|
3573
3461
|
{
|
|
3574
3462
|
if (!is_same_smart_ptr(value))
|
|
3463
|
+
{
|
|
3575
3464
|
return Convertible::None;
|
|
3465
|
+
}
|
|
3576
3466
|
|
|
3577
3467
|
switch (rb_type(value))
|
|
3578
3468
|
{
|
|
@@ -3594,6 +3484,9 @@ namespace Rice::detail
|
|
|
3594
3484
|
}
|
|
3595
3485
|
return wrapper->data();
|
|
3596
3486
|
}
|
|
3487
|
+
|
|
3488
|
+
private:
|
|
3489
|
+
Arg* arg_ = nullptr;
|
|
3597
3490
|
};
|
|
3598
3491
|
|
|
3599
3492
|
template<typename T>
|
|
@@ -3740,7 +3633,11 @@ namespace Rice
|
|
|
3740
3633
|
{
|
|
3741
3634
|
if constexpr (detail::is_comparable_v<Mapped_T>)
|
|
3742
3635
|
{
|
|
3743
|
-
klass_.define_method("
|
|
3636
|
+
klass_.define_method("==", [](T& unordered_map, T& other)->bool
|
|
3637
|
+
{
|
|
3638
|
+
return unordered_map == other;
|
|
3639
|
+
})
|
|
3640
|
+
.define_method("value?", [](T& unordered_map, Mapped_T& value) -> bool
|
|
3744
3641
|
{
|
|
3745
3642
|
auto it = std::find_if(unordered_map.begin(), unordered_map.end(),
|
|
3746
3643
|
[&value](auto& pair)
|
|
@@ -3750,10 +3647,11 @@ namespace Rice
|
|
|
3750
3647
|
|
|
3751
3648
|
return it != unordered_map.end();
|
|
3752
3649
|
});
|
|
3650
|
+
rb_define_alias(klass_, "eql?", "==");
|
|
3753
3651
|
}
|
|
3754
3652
|
else
|
|
3755
3653
|
{
|
|
3756
|
-
klass_.define_method("value?", [](T
|
|
3654
|
+
klass_.define_method("value?", [](T&, Mapped_T&) -> bool
|
|
3757
3655
|
{
|
|
3758
3656
|
return false;
|
|
3759
3657
|
});
|
|
@@ -3838,10 +3736,10 @@ namespace Rice
|
|
|
3838
3736
|
}
|
|
3839
3737
|
else
|
|
3840
3738
|
{
|
|
3841
|
-
klass_.define_method("to_s", [](const T&
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3739
|
+
klass_.define_method("to_s", [](const T&)
|
|
3740
|
+
{
|
|
3741
|
+
return "[Not printable]";
|
|
3742
|
+
});
|
|
3845
3743
|
}
|
|
3846
3744
|
}
|
|
3847
3745
|
|
|
@@ -3932,7 +3830,7 @@ namespace Rice
|
|
|
3932
3830
|
{
|
|
3933
3831
|
}
|
|
3934
3832
|
|
|
3935
|
-
|
|
3833
|
+
double is_convertible(VALUE value)
|
|
3936
3834
|
{
|
|
3937
3835
|
switch (rb_type(value))
|
|
3938
3836
|
{
|
|
@@ -3940,7 +3838,7 @@ namespace Rice
|
|
|
3940
3838
|
return Data_Type<std::unordered_map<T, U>>::is_descendant(value) ? Convertible::Exact : Convertible::None;
|
|
3941
3839
|
break;
|
|
3942
3840
|
case RUBY_T_HASH:
|
|
3943
|
-
return Convertible::
|
|
3841
|
+
return Convertible::Exact;
|
|
3944
3842
|
break;
|
|
3945
3843
|
default:
|
|
3946
3844
|
return Convertible::None;
|
|
@@ -3966,7 +3864,7 @@ namespace Rice
|
|
|
3966
3864
|
}
|
|
3967
3865
|
default:
|
|
3968
3866
|
{
|
|
3969
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
3867
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
3970
3868
|
detail::protect(rb_obj_classname, value), "std::unordered_map");
|
|
3971
3869
|
}
|
|
3972
3870
|
}
|
|
@@ -3986,7 +3884,7 @@ namespace Rice
|
|
|
3986
3884
|
{
|
|
3987
3885
|
}
|
|
3988
3886
|
|
|
3989
|
-
|
|
3887
|
+
double is_convertible(VALUE value)
|
|
3990
3888
|
{
|
|
3991
3889
|
switch (rb_type(value))
|
|
3992
3890
|
{
|
|
@@ -3994,7 +3892,7 @@ namespace Rice
|
|
|
3994
3892
|
return Data_Type<std::unordered_map<T, U>>::is_descendant(value) ? Convertible::Exact : Convertible::None;
|
|
3995
3893
|
break;
|
|
3996
3894
|
case RUBY_T_HASH:
|
|
3997
|
-
return Convertible::
|
|
3895
|
+
return Convertible::Exact;
|
|
3998
3896
|
break;
|
|
3999
3897
|
default:
|
|
4000
3898
|
return Convertible::None;
|
|
@@ -4021,7 +3919,7 @@ namespace Rice
|
|
|
4021
3919
|
}
|
|
4022
3920
|
default:
|
|
4023
3921
|
{
|
|
4024
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
3922
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
4025
3923
|
detail::protect(rb_obj_classname, value), "std::unordered_map");
|
|
4026
3924
|
}
|
|
4027
3925
|
}
|
|
@@ -4042,7 +3940,7 @@ namespace Rice
|
|
|
4042
3940
|
{
|
|
4043
3941
|
}
|
|
4044
3942
|
|
|
4045
|
-
|
|
3943
|
+
double is_convertible(VALUE value)
|
|
4046
3944
|
{
|
|
4047
3945
|
switch (rb_type(value))
|
|
4048
3946
|
{
|
|
@@ -4053,7 +3951,7 @@ namespace Rice
|
|
|
4053
3951
|
return Convertible::Exact;
|
|
4054
3952
|
break;
|
|
4055
3953
|
case RUBY_T_HASH:
|
|
4056
|
-
return Convertible::
|
|
3954
|
+
return Convertible::Exact;
|
|
4057
3955
|
break;
|
|
4058
3956
|
default:
|
|
4059
3957
|
return Convertible::None;
|
|
@@ -4080,7 +3978,7 @@ namespace Rice
|
|
|
4080
3978
|
}
|
|
4081
3979
|
default:
|
|
4082
3980
|
{
|
|
4083
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
3981
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
4084
3982
|
detail::protect(rb_obj_classname, value), "std::unordered_map");
|
|
4085
3983
|
}
|
|
4086
3984
|
}
|
|
@@ -4144,7 +4042,7 @@ namespace Rice
|
|
|
4144
4042
|
Difference_T normalizeIndex(Size_T size, Difference_T index, bool enforceBounds = false)
|
|
4145
4043
|
{
|
|
4146
4044
|
// Negative indices mean count from the right
|
|
4147
|
-
if (index < 0 && (-index <= size))
|
|
4045
|
+
if (index < 0 && ((Size_T)(-index) <= size))
|
|
4148
4046
|
{
|
|
4149
4047
|
index = size + index;
|
|
4150
4048
|
}
|
|
@@ -4188,7 +4086,7 @@ namespace Rice
|
|
|
4188
4086
|
}
|
|
4189
4087
|
|
|
4190
4088
|
// Wrap the vector
|
|
4191
|
-
detail::wrapConstructed<T>(self, Data_Type<T>::ruby_data_type(), data
|
|
4089
|
+
detail::wrapConstructed<T>(self, Data_Type<T>::ruby_data_type(), data);
|
|
4192
4090
|
});
|
|
4193
4091
|
}
|
|
4194
4092
|
|
|
@@ -4204,10 +4102,10 @@ namespace Rice
|
|
|
4204
4102
|
}
|
|
4205
4103
|
else
|
|
4206
4104
|
{
|
|
4207
|
-
klass_.define_method("resize", [](const T
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4105
|
+
klass_.define_method("resize", [](const T&, Size_T)
|
|
4106
|
+
{
|
|
4107
|
+
// Do nothing
|
|
4108
|
+
});
|
|
4211
4109
|
}
|
|
4212
4110
|
}
|
|
4213
4111
|
|
|
@@ -4264,7 +4162,7 @@ namespace Rice
|
|
|
4264
4162
|
return vector[index];
|
|
4265
4163
|
}
|
|
4266
4164
|
})
|
|
4267
|
-
.template define_method<Value_T*(T::*)()>("data", &T::data,
|
|
4165
|
+
.template define_method<Value_T*(T::*)()>("data", &T::data, ReturnBuffer());
|
|
4268
4166
|
}
|
|
4269
4167
|
else
|
|
4270
4168
|
{
|
|
@@ -4345,7 +4243,11 @@ namespace Rice
|
|
|
4345
4243
|
{
|
|
4346
4244
|
if constexpr (detail::is_comparable_v<T>)
|
|
4347
4245
|
{
|
|
4348
|
-
klass_.define_method("
|
|
4246
|
+
klass_.define_method("==", [](T& vector, T& other)->bool
|
|
4247
|
+
{
|
|
4248
|
+
return vector == other;
|
|
4249
|
+
})
|
|
4250
|
+
.define_method("delete", [](T& vector, Parameter_T element) -> std::optional<Value_T>
|
|
4349
4251
|
{
|
|
4350
4252
|
auto iter = std::find(vector.begin(), vector.end(), element);
|
|
4351
4253
|
if (iter == vector.end())
|
|
@@ -4379,21 +4281,22 @@ namespace Rice
|
|
|
4379
4281
|
return iter - vector.begin();
|
|
4380
4282
|
}
|
|
4381
4283
|
});
|
|
4284
|
+
rb_define_alias(klass_, "eql?", "==");
|
|
4382
4285
|
}
|
|
4383
4286
|
else
|
|
4384
4287
|
{
|
|
4385
|
-
klass_.define_method("delete", [](T
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
.define_method("include?", [](const T
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
.define_method("index", [](const T
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4288
|
+
klass_.define_method("delete", [](T&, Parameter_T) -> std::optional<Value_T>
|
|
4289
|
+
{
|
|
4290
|
+
return std::nullopt;
|
|
4291
|
+
})
|
|
4292
|
+
.define_method("include?", [](const T&, Parameter_T)
|
|
4293
|
+
{
|
|
4294
|
+
return false;
|
|
4295
|
+
})
|
|
4296
|
+
.define_method("index", [](const T&, Parameter_T) -> std::optional<Difference_T>
|
|
4297
|
+
{
|
|
4298
|
+
return std::nullopt;
|
|
4299
|
+
});
|
|
4397
4300
|
}
|
|
4398
4301
|
}
|
|
4399
4302
|
|
|
@@ -4418,7 +4321,7 @@ namespace Rice
|
|
|
4418
4321
|
})
|
|
4419
4322
|
.define_method("insert", [this](T& vector, Difference_T index, Parameter_T element) -> T&
|
|
4420
4323
|
{
|
|
4421
|
-
|
|
4324
|
+
size_t normalized = normalizeIndex(vector.size(), index, true);
|
|
4422
4325
|
// For a Ruby array a positive index means insert the element before the index. But
|
|
4423
4326
|
// a negative index means insert the element *after* the index. std::vector
|
|
4424
4327
|
// inserts *before* the index. So add 1 if this is a negative index.
|
|
@@ -4517,10 +4420,10 @@ namespace Rice
|
|
|
4517
4420
|
}
|
|
4518
4421
|
else
|
|
4519
4422
|
{
|
|
4520
|
-
klass_.define_method("to_s", [](const T&
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4423
|
+
klass_.define_method("to_s", [](const T&)
|
|
4424
|
+
{
|
|
4425
|
+
return "[Not printable]";
|
|
4426
|
+
});
|
|
4524
4427
|
}
|
|
4525
4428
|
}
|
|
4526
4429
|
|
|
@@ -4582,7 +4485,7 @@ namespace Rice
|
|
|
4582
4485
|
{
|
|
4583
4486
|
}
|
|
4584
4487
|
|
|
4585
|
-
|
|
4488
|
+
double is_convertible(VALUE value)
|
|
4586
4489
|
{
|
|
4587
4490
|
switch (rb_type(value))
|
|
4588
4491
|
{
|
|
@@ -4592,7 +4495,7 @@ namespace Rice
|
|
|
4592
4495
|
case RUBY_T_ARRAY:
|
|
4593
4496
|
if constexpr (std::is_default_constructible_v<T>)
|
|
4594
4497
|
{
|
|
4595
|
-
return Convertible::
|
|
4498
|
+
return Convertible::Exact;
|
|
4596
4499
|
}
|
|
4597
4500
|
default:
|
|
4598
4501
|
return Convertible::None;
|
|
@@ -4618,7 +4521,7 @@ namespace Rice
|
|
|
4618
4521
|
}
|
|
4619
4522
|
default:
|
|
4620
4523
|
{
|
|
4621
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
4524
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
4622
4525
|
detail::protect(rb_obj_classname, value), "std::vector");
|
|
4623
4526
|
}
|
|
4624
4527
|
}
|
|
@@ -4638,7 +4541,7 @@ namespace Rice
|
|
|
4638
4541
|
{
|
|
4639
4542
|
}
|
|
4640
4543
|
|
|
4641
|
-
|
|
4544
|
+
double is_convertible(VALUE value)
|
|
4642
4545
|
{
|
|
4643
4546
|
switch (rb_type(value))
|
|
4644
4547
|
{
|
|
@@ -4648,7 +4551,7 @@ namespace Rice
|
|
|
4648
4551
|
case RUBY_T_ARRAY:
|
|
4649
4552
|
if constexpr (std::is_default_constructible_v<T>)
|
|
4650
4553
|
{
|
|
4651
|
-
return Convertible::
|
|
4554
|
+
return Convertible::Exact;
|
|
4652
4555
|
}
|
|
4653
4556
|
default:
|
|
4654
4557
|
return Convertible::None;
|
|
@@ -4675,7 +4578,7 @@ namespace Rice
|
|
|
4675
4578
|
}
|
|
4676
4579
|
default:
|
|
4677
4580
|
{
|
|
4678
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
4581
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
4679
4582
|
detail::protect(rb_obj_classname, value), "std::vector");
|
|
4680
4583
|
}
|
|
4681
4584
|
}
|
|
@@ -4696,7 +4599,7 @@ namespace Rice
|
|
|
4696
4599
|
{
|
|
4697
4600
|
}
|
|
4698
4601
|
|
|
4699
|
-
|
|
4602
|
+
double is_convertible(VALUE value)
|
|
4700
4603
|
{
|
|
4701
4604
|
switch (rb_type(value))
|
|
4702
4605
|
{
|
|
@@ -4709,7 +4612,7 @@ namespace Rice
|
|
|
4709
4612
|
case RUBY_T_ARRAY:
|
|
4710
4613
|
if constexpr (std::is_default_constructible_v<T>)
|
|
4711
4614
|
{
|
|
4712
|
-
return Convertible::
|
|
4615
|
+
return Convertible::Exact;
|
|
4713
4616
|
}
|
|
4714
4617
|
default:
|
|
4715
4618
|
return Convertible::None;
|
|
@@ -4736,7 +4639,7 @@ namespace Rice
|
|
|
4736
4639
|
}
|
|
4737
4640
|
default:
|
|
4738
4641
|
{
|
|
4739
|
-
throw Exception(rb_eTypeError, "wrong argument type %s (expected %
|
|
4642
|
+
throw Exception(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
4740
4643
|
detail::protect(rb_obj_classname, value), "std::vector");
|
|
4741
4644
|
}
|
|
4742
4645
|
}
|
|
@@ -4757,7 +4660,7 @@ namespace Rice
|
|
|
4757
4660
|
public:
|
|
4758
4661
|
To_Ruby() = default;
|
|
4759
4662
|
|
|
4760
|
-
explicit To_Ruby(
|
|
4663
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
4761
4664
|
{
|
|
4762
4665
|
}
|
|
4763
4666
|
|
|
@@ -4767,7 +4670,7 @@ namespace Rice
|
|
|
4767
4670
|
}
|
|
4768
4671
|
|
|
4769
4672
|
private:
|
|
4770
|
-
|
|
4673
|
+
Arg* arg_ = nullptr;
|
|
4771
4674
|
};
|
|
4772
4675
|
}
|
|
4773
4676
|
}
|