Skip to content

Commit c541b91

Browse files
author
Dilawar Singh
committed
One more test passed.
1 parent 5cc3d3b commit c541b91

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

pybind11/helper.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,24 @@ py::object getValueFinfo(const ObjId& oid, const string& fname, const Finfo* f)
338338
auto rttType = f->rttiType();
339339
py::object r = py::none();
340340

341+
// cout << "Getting " << fname << "(" << rttType << ")"
342+
// << " from " << oid.path() << endl;
343+
341344
if (rttType == "double" or rttType == "float")
342345
r = pybind11::float_(getField<double>(oid, fname));
343346
else if (rttType == "vector<double>") {
344-
r = py::cast(getField<vector<double>>(oid, fname));
345-
// r = getFieldNumpy<double>(oid, fname);
347+
// r = py::cast(getField<vector<double>>(oid, fname));
348+
r = getFieldNumpy<double>(oid, fname);
346349
} else if (rttType == "string")
347350
r = pybind11::str(getField<string>(oid, fname));
348-
// else if (rttType == "char")
349-
// r = pybind11::int_(getField<char>(oid, fname));
350-
else if (rttType == "int" or rttType == "unsigned int" or rttType == "unsigned long" or rttType == "unsigned int")
351+
else if (rttType == "char")
352+
r = pybind11::int_(getField<char>(oid, fname));
353+
else if (rttType == "int")
351354
r = pybind11::int_(getField<int>(oid, fname));
355+
else if (rttType == "unsigned int")
356+
r = pybind11::int_(getField<unsigned int>(oid, fname));
357+
else if (rttType == "unsigned long")
358+
r = pybind11::int_(getField<unsigned long>(oid, fname));
352359
else if (rttType == "bool")
353360
r = pybind11::bool_(getField<bool>(oid, fname));
354361
else if (rttType == "Id")
@@ -382,7 +389,7 @@ py::list getElementFinfo(const ObjId& objid, const string& fname,
382389
}
383390

384391
py::cpp_function getFieldertyDestFinfo(const ObjId& oid, const string& fname,
385-
const Finfo* finfo)
392+
const Finfo* finfo)
386393
{
387394
const auto rttType = finfo->rttiType();
388395

@@ -396,21 +403,22 @@ py::cpp_function getFieldertyDestFinfo(const ObjId& oid, const string& fname,
396403
return func;
397404
}
398405
if (rttType == "vector<Id>") {
399-
std::function<bool(const vector<Id>&)> func = [oid, fname](const vector<Id>& ids) {
406+
std::function<bool(const vector<Id>&)> func = [oid, fname](
407+
const vector<Id>& ids) {
400408
return SetGet1<vector<Id>>::set(oid, fname, ids);
401409
};
402410
return func;
403411
}
404412
if (rttType == "vector<ObjId>") {
405-
std::function<bool(const vector<ObjId>&)> func = [oid, fname](const vector<ObjId>& ids) {
413+
std::function<bool(const vector<ObjId>&)> func = [oid, fname](
414+
const vector<ObjId>& ids) {
406415
return SetGet1<vector<ObjId>>::set(oid, fname, ids);
407416
};
408417
return func;
409418
}
410419

411-
throw runtime_error("NotImplemented " + fname + " for rttType " + rttType
412-
+ " for oid " + oid.path());
413-
420+
throw runtime_error("NotImplemented " + fname + " for rttType " + rttType +
421+
" for oid " + oid.path());
414422
}
415423

416424
py::object getFieldGeneric(const ObjId& oid, const string& fname)

pybind11/pymoose.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,15 @@ PYBIND11_MODULE(_cmoose, m)
140140
.def("__setattr__", &setField<bool>)
141141
.def("__setattr__", &setField<double>)
142142
.def("__setattr__", &setField<int>)
143+
.def("__setattr__", &setField<size_t>)
143144
.def("__setattr__", &setField<unsigned long>)
144145
.def("__setattr__", &setField<unsigned int>)
145-
.def("__setattr__", &setField<unsigned int>)
146146
.def("__setattr__", &setField<vector<double>>)
147147
.def("__setattr__", &setField<std::string>)
148148
.def("__setattr__", &setField<ObjId>)
149+
.def("__setattr__", &setField<vector<ObjId>>)
149150
.def("__setattr__", &setField<Id>)
151+
.def("__setattr__", &setField<vector<Id>>)
150152

151153
//---------------------------------------------------------------------
152154
// Connect

0 commit comments

Comments
 (0)