Skip to content

Commit a4ba548

Browse files
authored
Merge pull request #286 from ruby-rice/dev
Dev
2 parents 8b51ac1 + ff32504 commit a4ba548

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

FindRuby.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ set(_Ruby_POSSIBLE_LIB_NAMES
378378
)
379379

380380
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}")
382382
set(_Ruby_POSSIBLE_VERSION_SUFFIXES "${_Ruby_VERSION_NODOT};${_Ruby_VERSION_NODOT_ZERO_PATCH}")
383383
# Under MSYS CMAKE_SIZEOF_VOID_P is unset so add prefixes for 32 and 64 architectures
384384
set(_Ruby_POSSIBLE_ARCH_PREFIXES "lib;libx64-;x64-")

test/test_Attribute.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ namespace
5353
bool globalBool = true;
5454
const DataStruct* globalStruct = new DataStruct();
5555

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+
5671
} // namespace
5772

5873
TESTCASE(attributes)
@@ -102,6 +117,25 @@ TESTCASE(attributes)
102117
ASSERT_EQUAL("Set a string", detail::From_Ruby<std::string>().convert(result.value()));
103118
}
104119

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+
105139
TESTCASE(const_attribute)
106140
{
107141
Class c = define_class<DataStruct>("DataStruct")

0 commit comments

Comments
 (0)