File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ set(_Ruby_POSSIBLE_LIB_NAMES
378
378
)
379
379
380
380
if (WIN32 OR MSYS )
381
- set (_Ruby_POSSIBLE_RUNTIMES "ucrt;msvcrt;vcruntime140;vcruntime140_1;msvcr ${MSVC_TOOLSET_VERSION} " )
381
+ set (_Ruby_POSSIBLE_RUNTIMES "ucrt;msvcrt;vcruntime140;vcruntime140_1;vcruntime ${MSVC_TOOLSET_VERSION} " )
382
382
set (_Ruby_POSSIBLE_VERSION_SUFFIXES "${_Ruby_VERSION_NODOT} ;${_Ruby_VERSION_NODOT_ZERO_PATCH} " )
383
383
# Under MSYS CMAKE_SIZEOF_VOID_P is unset so add prefixes for 32 and 64 architectures
384
384
set (_Ruby_POSSIBLE_ARCH_PREFIXES "lib;libx64-;x64-" )
Original file line number Diff line number Diff line change @@ -53,6 +53,21 @@ namespace
53
53
bool globalBool = true ;
54
54
const DataStruct* globalStruct = new DataStruct();
55
55
56
+ class VecStruct
57
+ {
58
+ public:
59
+ std::vector<double > vector;
60
+
61
+ VecStruct (std::vector<double > aVector) : vector(aVector)
62
+ {
63
+ }
64
+
65
+ size_t vecSize ()
66
+ {
67
+ return this ->vector .size ();
68
+ }
69
+ };
70
+
56
71
} // namespace
57
72
58
73
TESTCASE (attributes)
@@ -102,6 +117,25 @@ TESTCASE(attributes)
102
117
ASSERT_EQUAL (" Set a string" , detail::From_Ruby<std::string>().convert (result.value ()));
103
118
}
104
119
120
+ TESTCASE (vector)
121
+ {
122
+ // See https ://github.com/ruby-rice/rice/issues/283
123
+ Module m = define_module (" Testing" );
124
+
125
+ define_class<VecStruct>(" VecStruct" )
126
+ .define_constructor (Constructor<VecStruct, std::vector<double >>())
127
+ .define_attr (" vector" , &VecStruct::vector, Rice::AttrAccess::Read)
128
+ .define_method (" vector_size" , &VecStruct::vecSize);
129
+
130
+ std::string code = R"( struct = VecStruct.new([1, 2])
131
+ # Access the attribute
132
+ array = struct.vector.to_a
133
+ struct.vector_size)" ;
134
+
135
+ Object result = m.module_eval (code);
136
+ ASSERT_EQUAL (2 , detail::From_Ruby<size_t >().convert (result));
137
+ }
138
+
105
139
TESTCASE (const_attribute)
106
140
{
107
141
Class c = define_class<DataStruct>(" DataStruct" )
You can’t perform that action at this time.
0 commit comments