rice 4.11.1 → 4.11.2
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 +7 -1
- data/include/rice/rice.hpp +182 -2
- data/lib/rice/version.rb +1 -1
- data/rice/Data_Type.ipp +0 -2
- data/rice/detail/RubyType.ipp +11 -0
- data/rice/detail/TypeRegistry.ipp +6 -0
- data/rice/detail/Types.ipp +29 -0
- data/rice/detail/from_ruby.ipp +80 -0
- data/rice/detail/to_ruby.ipp +56 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bbea336b28656bc1123b687fe1649c58c5c497cc01efafeabe7efdac71577d46
|
|
4
|
+
data.tar.gz: 4910c437a1e878c3c0dc534828ee89b499cf14a3d3ab4011ead2944f6063cca4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f8f3dc946883c516c3e3e79ea11866503cd059d95765586789490c31fbd0881ed6d5fb905fd9f60120df3f2d4980a2a50bb8005d245e17feb94f85d217bbf3a
|
|
7
|
+
data.tar.gz: 2b69b75163ca48b82f5b11041094885d64b5c18abe0b7306912e96a94f5f986afeb968127fc7b6b3d513ee6297160adc7bd0008d1cbdfc669d0660e3aa7e8d2c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.11.2 (2026-02-21)
|
|
4
|
+
|
|
5
|
+
### Enhancements
|
|
6
|
+
|
|
7
|
+
* Add support for `long double`
|
|
8
|
+
* Improve support for references to incomplete types
|
|
9
|
+
|
|
3
10
|
## 4.11.1 (2026-02-18)
|
|
4
11
|
|
|
5
12
|
### Enhancements
|
|
6
13
|
|
|
7
14
|
* Be more lenient on wrapp Qnil values in the C++ API
|
|
8
15
|
|
|
9
|
-
|
|
10
16
|
## 4.11.0 (2026-02-17)
|
|
11
17
|
|
|
12
18
|
This release focuses on improving memory management.
|
data/include/rice/rice.hpp
CHANGED
|
@@ -3797,6 +3797,17 @@ namespace Rice::detail
|
|
|
3797
3797
|
static inline std::string name = "Float";
|
|
3798
3798
|
};
|
|
3799
3799
|
|
|
3800
|
+
template<>
|
|
3801
|
+
class RubyType<long double>
|
|
3802
|
+
{
|
|
3803
|
+
public:
|
|
3804
|
+
using FromRuby_T = double(*)(VALUE);
|
|
3805
|
+
|
|
3806
|
+
static inline FromRuby_T fromRuby = rb_num2dbl;
|
|
3807
|
+
static inline std::string packTemplate = "d*";
|
|
3808
|
+
static inline std::string name = "Float";
|
|
3809
|
+
};
|
|
3810
|
+
|
|
3800
3811
|
template<>
|
|
3801
3812
|
class RubyType<void>
|
|
3802
3813
|
{
|
|
@@ -6073,6 +6084,35 @@ namespace Rice::detail
|
|
|
6073
6084
|
}
|
|
6074
6085
|
};
|
|
6075
6086
|
|
|
6087
|
+
template<>
|
|
6088
|
+
struct Type<long double>
|
|
6089
|
+
{
|
|
6090
|
+
static bool verify()
|
|
6091
|
+
{
|
|
6092
|
+
return true;
|
|
6093
|
+
}
|
|
6094
|
+
|
|
6095
|
+
static VALUE rubyKlass()
|
|
6096
|
+
{
|
|
6097
|
+
return rb_cFloat;
|
|
6098
|
+
}
|
|
6099
|
+
};
|
|
6100
|
+
|
|
6101
|
+
template<int N>
|
|
6102
|
+
struct Type<long double[N]>
|
|
6103
|
+
{
|
|
6104
|
+
static bool verify()
|
|
6105
|
+
{
|
|
6106
|
+
define_buffer<long double>();
|
|
6107
|
+
return true;
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6110
|
+
static VALUE rubyKlass()
|
|
6111
|
+
{
|
|
6112
|
+
return rb_cString;
|
|
6113
|
+
}
|
|
6114
|
+
};
|
|
6115
|
+
|
|
6076
6116
|
template<>
|
|
6077
6117
|
struct Type<void>
|
|
6078
6118
|
{
|
|
@@ -6601,6 +6641,62 @@ namespace Rice
|
|
|
6601
6641
|
Arg* arg_ = nullptr;
|
|
6602
6642
|
};
|
|
6603
6643
|
|
|
6644
|
+
// =========== long double ============
|
|
6645
|
+
template<>
|
|
6646
|
+
class To_Ruby<long double>
|
|
6647
|
+
{
|
|
6648
|
+
public:
|
|
6649
|
+
To_Ruby() = default;
|
|
6650
|
+
|
|
6651
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
6652
|
+
{}
|
|
6653
|
+
|
|
6654
|
+
VALUE convert(const long double& native)
|
|
6655
|
+
{
|
|
6656
|
+
return protect(rb_float_new, native);
|
|
6657
|
+
}
|
|
6658
|
+
|
|
6659
|
+
private:
|
|
6660
|
+
Arg* arg_ = nullptr;
|
|
6661
|
+
};
|
|
6662
|
+
|
|
6663
|
+
template<>
|
|
6664
|
+
class To_Ruby<long double&>
|
|
6665
|
+
{
|
|
6666
|
+
public:
|
|
6667
|
+
To_Ruby() = default;
|
|
6668
|
+
|
|
6669
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
6670
|
+
{}
|
|
6671
|
+
|
|
6672
|
+
VALUE convert(const long double& native)
|
|
6673
|
+
{
|
|
6674
|
+
return protect(rb_float_new, native);
|
|
6675
|
+
}
|
|
6676
|
+
|
|
6677
|
+
private:
|
|
6678
|
+
Arg* arg_ = nullptr;
|
|
6679
|
+
};
|
|
6680
|
+
|
|
6681
|
+
template<int N>
|
|
6682
|
+
class To_Ruby<long double[N]>
|
|
6683
|
+
{
|
|
6684
|
+
public:
|
|
6685
|
+
To_Ruby() = default;
|
|
6686
|
+
|
|
6687
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
6688
|
+
{}
|
|
6689
|
+
|
|
6690
|
+
VALUE convert(long double data[N])
|
|
6691
|
+
{
|
|
6692
|
+
Buffer<long double> buffer(data, N);
|
|
6693
|
+
Data_Object<Buffer<long double>> dataObject(std::move(buffer));
|
|
6694
|
+
return dataObject.value();
|
|
6695
|
+
}
|
|
6696
|
+
private:
|
|
6697
|
+
Arg* arg_ = nullptr;
|
|
6698
|
+
};
|
|
6699
|
+
|
|
6604
6700
|
// =========== float ============
|
|
6605
6701
|
template<>
|
|
6606
6702
|
class To_Ruby<float>
|
|
@@ -7879,6 +7975,86 @@ namespace Rice::detail
|
|
|
7879
7975
|
Reference<double> reference_;
|
|
7880
7976
|
};
|
|
7881
7977
|
|
|
7978
|
+
// =========== long double ============
|
|
7979
|
+
template<>
|
|
7980
|
+
class From_Ruby<long double>
|
|
7981
|
+
{
|
|
7982
|
+
public:
|
|
7983
|
+
From_Ruby() = default;
|
|
7984
|
+
|
|
7985
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
7986
|
+
{}
|
|
7987
|
+
|
|
7988
|
+
long double is_convertible(VALUE value)
|
|
7989
|
+
{
|
|
7990
|
+
return FromRubyFundamental<long double>::is_convertible(value);
|
|
7991
|
+
}
|
|
7992
|
+
|
|
7993
|
+
long double convert(VALUE value)
|
|
7994
|
+
{
|
|
7995
|
+
return FromRubyFundamental<long double>::convert(value);
|
|
7996
|
+
}
|
|
7997
|
+
|
|
7998
|
+
private:
|
|
7999
|
+
Arg* arg_ = nullptr;
|
|
8000
|
+
};
|
|
8001
|
+
|
|
8002
|
+
template<>
|
|
8003
|
+
class From_Ruby<long double&>
|
|
8004
|
+
{
|
|
8005
|
+
public:
|
|
8006
|
+
using Reference_T = Reference<long double>;
|
|
8007
|
+
|
|
8008
|
+
From_Ruby() = default;
|
|
8009
|
+
|
|
8010
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
8011
|
+
{}
|
|
8012
|
+
|
|
8013
|
+
long double is_convertible(VALUE value)
|
|
8014
|
+
{
|
|
8015
|
+
switch (rb_type(value))
|
|
8016
|
+
{
|
|
8017
|
+
case RUBY_T_DATA:
|
|
8018
|
+
{
|
|
8019
|
+
if (Data_Type<Reference_T>::is_descendant(value))
|
|
8020
|
+
{
|
|
8021
|
+
return Convertible::Exact;
|
|
8022
|
+
}
|
|
8023
|
+
[[fallthrough]];
|
|
8024
|
+
}
|
|
8025
|
+
default:
|
|
8026
|
+
{
|
|
8027
|
+
return FromRubyFundamental<long double>::is_convertible(value);
|
|
8028
|
+
}
|
|
8029
|
+
}
|
|
8030
|
+
}
|
|
8031
|
+
|
|
8032
|
+
long double& convert(VALUE value)
|
|
8033
|
+
{
|
|
8034
|
+
switch (rb_type(value))
|
|
8035
|
+
{
|
|
8036
|
+
case RUBY_T_DATA:
|
|
8037
|
+
{
|
|
8038
|
+
if (Data_Type<Reference_T>::is_descendant(value))
|
|
8039
|
+
{
|
|
8040
|
+
Reference_T* reference = unwrap<Reference_T>(value, Data_Type<Reference_T>::ruby_data_type(), false);
|
|
8041
|
+
return reference->get();
|
|
8042
|
+
}
|
|
8043
|
+
[[fallthrough]];
|
|
8044
|
+
}
|
|
8045
|
+
default:
|
|
8046
|
+
{
|
|
8047
|
+
this->reference_ = Reference<long double>(value);
|
|
8048
|
+
return this->reference_.get();
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8051
|
+
}
|
|
8052
|
+
|
|
8053
|
+
private:
|
|
8054
|
+
Arg* arg_ = nullptr;
|
|
8055
|
+
Reference<long double> reference_;
|
|
8056
|
+
};
|
|
8057
|
+
|
|
7882
8058
|
// =========== float ============
|
|
7883
8059
|
template<>
|
|
7884
8060
|
class From_Ruby<float>
|
|
@@ -8973,6 +9149,12 @@ namespace Rice::detail
|
|
|
8973
9149
|
{
|
|
8974
9150
|
return std::type_index(typeid(T));
|
|
8975
9151
|
}
|
|
9152
|
+
else if constexpr (std::is_reference_v<T>)
|
|
9153
|
+
{
|
|
9154
|
+
// For incomplete reference types, strip the reference and use pointer.
|
|
9155
|
+
// Can't form T* when T is a reference type (pointer-to-reference is illegal).
|
|
9156
|
+
return std::type_index(typeid(std::remove_reference_t<T>*));
|
|
9157
|
+
}
|
|
8976
9158
|
else
|
|
8977
9159
|
{
|
|
8978
9160
|
return std::type_index(typeid(T*));
|
|
@@ -14845,8 +15027,6 @@ namespace Rice
|
|
|
14845
15027
|
template <typename Attribute_T, typename Access_T, typename...Arg_Ts>
|
|
14846
15028
|
inline Data_Type<T>& Data_Type<T>::define_attr_internal(VALUE klass, std::string name, Attribute_T attribute, Access_T, const Arg_Ts&...args)
|
|
14847
15029
|
{
|
|
14848
|
-
using Attr_T = typename detail::attribute_traits<Attribute_T>::attr_type;
|
|
14849
|
-
|
|
14850
15030
|
// Define attribute getter
|
|
14851
15031
|
if constexpr (std::is_same_v<Access_T, AttrAccess::ReadWriteType> || std::is_same_v<Access_T, AttrAccess::ReadType>)
|
|
14852
15032
|
{
|
data/lib/rice/version.rb
CHANGED
data/rice/Data_Type.ipp
CHANGED
|
@@ -376,8 +376,6 @@ namespace Rice
|
|
|
376
376
|
template <typename Attribute_T, typename Access_T, typename...Arg_Ts>
|
|
377
377
|
inline Data_Type<T>& Data_Type<T>::define_attr_internal(VALUE klass, std::string name, Attribute_T attribute, Access_T, const Arg_Ts&...args)
|
|
378
378
|
{
|
|
379
|
-
using Attr_T = typename detail::attribute_traits<Attribute_T>::attr_type;
|
|
380
|
-
|
|
381
379
|
// Define attribute getter
|
|
382
380
|
if constexpr (std::is_same_v<Access_T, AttrAccess::ReadWriteType> || std::is_same_v<Access_T, AttrAccess::ReadType>)
|
|
383
381
|
{
|
data/rice/detail/RubyType.ipp
CHANGED
|
@@ -154,6 +154,17 @@ namespace Rice::detail
|
|
|
154
154
|
static inline std::string name = "Float";
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
+
template<>
|
|
158
|
+
class RubyType<long double>
|
|
159
|
+
{
|
|
160
|
+
public:
|
|
161
|
+
using FromRuby_T = double(*)(VALUE);
|
|
162
|
+
|
|
163
|
+
static inline FromRuby_T fromRuby = rb_num2dbl;
|
|
164
|
+
static inline std::string packTemplate = "d*";
|
|
165
|
+
static inline std::string name = "Float";
|
|
166
|
+
};
|
|
167
|
+
|
|
157
168
|
template<>
|
|
158
169
|
class RubyType<void>
|
|
159
170
|
{
|
|
@@ -13,6 +13,12 @@ namespace Rice::detail
|
|
|
13
13
|
{
|
|
14
14
|
return std::type_index(typeid(T));
|
|
15
15
|
}
|
|
16
|
+
else if constexpr (std::is_reference_v<T>)
|
|
17
|
+
{
|
|
18
|
+
// For incomplete reference types, strip the reference and use pointer.
|
|
19
|
+
// Can't form T* when T is a reference type (pointer-to-reference is illegal).
|
|
20
|
+
return std::type_index(typeid(std::remove_reference_t<T>*));
|
|
21
|
+
}
|
|
16
22
|
else
|
|
17
23
|
{
|
|
18
24
|
return std::type_index(typeid(T*));
|
data/rice/detail/Types.ipp
CHANGED
|
@@ -404,6 +404,35 @@ namespace Rice::detail
|
|
|
404
404
|
}
|
|
405
405
|
};
|
|
406
406
|
|
|
407
|
+
template<>
|
|
408
|
+
struct Type<long double>
|
|
409
|
+
{
|
|
410
|
+
static bool verify()
|
|
411
|
+
{
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
static VALUE rubyKlass()
|
|
416
|
+
{
|
|
417
|
+
return rb_cFloat;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
template<int N>
|
|
422
|
+
struct Type<long double[N]>
|
|
423
|
+
{
|
|
424
|
+
static bool verify()
|
|
425
|
+
{
|
|
426
|
+
define_buffer<long double>();
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
static VALUE rubyKlass()
|
|
431
|
+
{
|
|
432
|
+
return rb_cString;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
407
436
|
template<>
|
|
408
437
|
struct Type<void>
|
|
409
438
|
{
|
data/rice/detail/from_ruby.ipp
CHANGED
|
@@ -729,6 +729,86 @@ namespace Rice::detail
|
|
|
729
729
|
Reference<double> reference_;
|
|
730
730
|
};
|
|
731
731
|
|
|
732
|
+
// =========== long double ============
|
|
733
|
+
template<>
|
|
734
|
+
class From_Ruby<long double>
|
|
735
|
+
{
|
|
736
|
+
public:
|
|
737
|
+
From_Ruby() = default;
|
|
738
|
+
|
|
739
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
740
|
+
{}
|
|
741
|
+
|
|
742
|
+
long double is_convertible(VALUE value)
|
|
743
|
+
{
|
|
744
|
+
return FromRubyFundamental<long double>::is_convertible(value);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
long double convert(VALUE value)
|
|
748
|
+
{
|
|
749
|
+
return FromRubyFundamental<long double>::convert(value);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
private:
|
|
753
|
+
Arg* arg_ = nullptr;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
template<>
|
|
757
|
+
class From_Ruby<long double&>
|
|
758
|
+
{
|
|
759
|
+
public:
|
|
760
|
+
using Reference_T = Reference<long double>;
|
|
761
|
+
|
|
762
|
+
From_Ruby() = default;
|
|
763
|
+
|
|
764
|
+
explicit From_Ruby(Arg* arg) : arg_(arg)
|
|
765
|
+
{}
|
|
766
|
+
|
|
767
|
+
long double is_convertible(VALUE value)
|
|
768
|
+
{
|
|
769
|
+
switch (rb_type(value))
|
|
770
|
+
{
|
|
771
|
+
case RUBY_T_DATA:
|
|
772
|
+
{
|
|
773
|
+
if (Data_Type<Reference_T>::is_descendant(value))
|
|
774
|
+
{
|
|
775
|
+
return Convertible::Exact;
|
|
776
|
+
}
|
|
777
|
+
[[fallthrough]];
|
|
778
|
+
}
|
|
779
|
+
default:
|
|
780
|
+
{
|
|
781
|
+
return FromRubyFundamental<long double>::is_convertible(value);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
long double& convert(VALUE value)
|
|
787
|
+
{
|
|
788
|
+
switch (rb_type(value))
|
|
789
|
+
{
|
|
790
|
+
case RUBY_T_DATA:
|
|
791
|
+
{
|
|
792
|
+
if (Data_Type<Reference_T>::is_descendant(value))
|
|
793
|
+
{
|
|
794
|
+
Reference_T* reference = unwrap<Reference_T>(value, Data_Type<Reference_T>::ruby_data_type(), false);
|
|
795
|
+
return reference->get();
|
|
796
|
+
}
|
|
797
|
+
[[fallthrough]];
|
|
798
|
+
}
|
|
799
|
+
default:
|
|
800
|
+
{
|
|
801
|
+
this->reference_ = Reference<long double>(value);
|
|
802
|
+
return this->reference_.get();
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
private:
|
|
808
|
+
Arg* arg_ = nullptr;
|
|
809
|
+
Reference<long double> reference_;
|
|
810
|
+
};
|
|
811
|
+
|
|
732
812
|
// =========== float ============
|
|
733
813
|
template<>
|
|
734
814
|
class From_Ruby<float>
|
data/rice/detail/to_ruby.ipp
CHANGED
|
@@ -501,6 +501,62 @@ namespace Rice
|
|
|
501
501
|
Arg* arg_ = nullptr;
|
|
502
502
|
};
|
|
503
503
|
|
|
504
|
+
// =========== long double ============
|
|
505
|
+
template<>
|
|
506
|
+
class To_Ruby<long double>
|
|
507
|
+
{
|
|
508
|
+
public:
|
|
509
|
+
To_Ruby() = default;
|
|
510
|
+
|
|
511
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
512
|
+
{}
|
|
513
|
+
|
|
514
|
+
VALUE convert(const long double& native)
|
|
515
|
+
{
|
|
516
|
+
return protect(rb_float_new, native);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
private:
|
|
520
|
+
Arg* arg_ = nullptr;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
template<>
|
|
524
|
+
class To_Ruby<long double&>
|
|
525
|
+
{
|
|
526
|
+
public:
|
|
527
|
+
To_Ruby() = default;
|
|
528
|
+
|
|
529
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
530
|
+
{}
|
|
531
|
+
|
|
532
|
+
VALUE convert(const long double& native)
|
|
533
|
+
{
|
|
534
|
+
return protect(rb_float_new, native);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
private:
|
|
538
|
+
Arg* arg_ = nullptr;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
template<int N>
|
|
542
|
+
class To_Ruby<long double[N]>
|
|
543
|
+
{
|
|
544
|
+
public:
|
|
545
|
+
To_Ruby() = default;
|
|
546
|
+
|
|
547
|
+
explicit To_Ruby(Arg* arg) : arg_(arg)
|
|
548
|
+
{}
|
|
549
|
+
|
|
550
|
+
VALUE convert(long double data[N])
|
|
551
|
+
{
|
|
552
|
+
Buffer<long double> buffer(data, N);
|
|
553
|
+
Data_Object<Buffer<long double>> dataObject(std::move(buffer));
|
|
554
|
+
return dataObject.value();
|
|
555
|
+
}
|
|
556
|
+
private:
|
|
557
|
+
Arg* arg_ = nullptr;
|
|
558
|
+
};
|
|
559
|
+
|
|
504
560
|
// =========== float ============
|
|
505
561
|
template<>
|
|
506
562
|
class To_Ruby<float>
|