|
|
@ -195,8 +195,28 @@ tstylesheet { |
|
|
|
const "array_type", "substring-before($type, '[')"; |
|
|
|
const "array_len", "substring-before(substring-after($type, '['),']')"; |
|
|
|
|
|
|
|
|
|
|
|
choose { |
|
|
|
// If is array type |
|
|
|
when "string-length($array_len) > 0" { |
|
|
|
choose { |
|
|
|
when "$array_type = 'char '" { |
|
|
|
|| |
|
|
|
.def_property("«$name»", |
|
|
|
[](::«$structname» &obj) -> py::bytes { |
|
|
|
// cout << "«$structname»::«$name»: getter called" << endl; |
|
|
|
return py::bytes(obj.«$name», «$array_len»); |
|
|
|
}, |
|
|
|
[](::«$structname» &obj, py::bytes val) -> void { |
|
|
|
// cout << "«$structname»::«$name»: setter called" << endl; |
|
|
|
std::string strval{val}; |
|
|
|
for(int i = 0; i < «$array_len»; ++i) { |
|
|
|
obj.«$name»[i] = strval[i]; |
|
|
|
} |
|
|
|
}, |
|
|
|
py::return_value_policy::copy) |
|
|
|
|| |
|
|
|
} otherwise { |
|
|
|
|| |
|
|
|
.def_property("«$name»", |
|
|
|
[](::«$structname» &obj) -> py::list { |
|
|
@ -208,7 +228,7 @@ tstylesheet { |
|
|
|
return l; |
|
|
|
}, |
|
|
|
[](::«$structname» &obj, py::list val) -> void { |
|
|
|
// cout << "«$structname»::«$name»: getter called" << endl; |
|
|
|
// cout << "«$structname»::«$name»: setter called" << endl; |
|
|
|
if(val.size() <= 0) { |
|
|
|
// empty array given, doing nothing (static c array cant be cleared) |
|
|
|
} else { |
|
|
@ -232,6 +252,9 @@ tstylesheet { |
|
|
|
py::return_value_policy::copy) |
|
|
|
|
|
|
|
|| |
|
|
|
} |
|
|
|
} |
|
|
|
// not array type |
|
|
|
} otherwise { |
|
|
|
|| |
|
|
|
.def_property("«@name»", |
|
|
|