|
|
@ -15,27 +15,84 @@ tstylesheet { |
|
|
|
|
|
|
|
template "method" { |
|
|
|
|| |
|
|
|
m.def("«@name»",`apply "signature"` &«@name», ""); |
|
|
|
|
|
|
|
m.def("«@name»", |
|
|
|
[](`apply "use", mode="lambda_sig"`) -> `apply return` { |
|
|
|
return ::«@name»( |
|
|
|
``apply "use", mode="arg_list" |
|
|
|
); |
|
|
|
}, |
|
|
|
pybind11::return_value_policy::copy); |
|
|
|
|| |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
template "return" { |
|
|
|
> «@type» |
|
|
|
} |
|
|
|
|
|
|
|
template "use", mode="arg_list" { |
|
|
|
const "name", "@name"; |
|
|
|
const "type", "@type"; |
|
|
|
choose { |
|
|
|
when "$type = 'const char *'" { |
|
|
|
|> strdup(«$name»)`if "position()!=last()" > ,` |
|
|
|
} otherwise { |
|
|
|
|> «$name»`if "position()!=last()" > ,` |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template "use", mode="lambda_sig" { |
|
|
|
const "name", "@name"; |
|
|
|
const "type", "@type"; |
|
|
|
> «$type» «$name»`if "position()!=last()"> , ` |
|
|
|
} |
|
|
|
|
|
|
|
template "signature" { |
|
|
|
> «@string» |
|
|
|
} |
|
|
|
const "string", "@string"; |
|
|
|
> «$string» |
|
|
|
} |
|
|
|
|
|
|
|
template "struct" { |
|
|
|
|| |
|
|
|
pybind11::class_<«@name»>(m, "«@name»") |
|
|
|
``apply "field" |
|
|
|
; |
|
|
|
|
|
|
|
|| |
|
|
|
| pybind11::class_<«@name»>(m, "«@name»") |
|
|
|
apply "field" { |
|
|
|
with "structname", "@name" |
|
|
|
} |
|
|
|
| ; |
|
|
|
| |
|
|
|
| |
|
|
|
} |
|
|
|
|
|
|
|
template "field" { |
|
|
|
param "structname"; |
|
|
|
|| |
|
|
|
.def_readwrite("«@name»", &::«../@name»::«@name») |
|
|
|
.def_property("«@name»", |
|
|
|
[](::«$structname» &obj) -> «@type» { |
|
|
|
//cout << "«$structname»::«@name»: getter called" << endl; |
|
|
|
return obj.«@name»; |
|
|
|
}, |
|
|
|
|| |
|
|
|
choose { |
|
|
|
when "@type = 'const char *'" { |
|
|
|
|| |
|
|
|
[](::«$structname» &obj, «@type» cstr) -> void { |
|
|
|
//cout << "«$structname»::«@name»: setter called" << cstr << endl; |
|
|
|
obj.«@name» = strdup(cstr); |
|
|
|
}, |
|
|
|
pybind11::return_value_policy::copy) |
|
|
|
|| |
|
|
|
} otherwise { |
|
|
|
|| |
|
|
|
[](::«$structname» &obj, «@type» val) -> void { |
|
|
|
//cout << "«$structname»::«@name»: setter called" << endl; |
|
|
|
obj.«@name» = val; |
|
|
|
}, |
|
|
|
pybind11::return_value_policy::copy) |
|
|
|
|
|
|
|
|| |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template "enum" { |
|
|
|