Browse Source

gen_pybind11: methods add py_arg, add docstrings.

master
heck 4 years ago
parent
commit
5aea5d8074
  1. 57
      pEpACIDgen/gen_backend/gen_pybind11.ysl2

57
pEpACIDgen/gen_backend/gen_pybind11.ysl2

@ -5,18 +5,19 @@ tstylesheet {
document("py_module.pybind11", "text") { document("py_module.pybind11", "text") {
|| ||
namespace py = pybind11; namespace py = pybind11;
//py::options options;
//options.disable_function_signatures();
// INSERT COOL ASCII ART HERE // INSERT COOL ASCII ART HERE
// METHOD
`` apply "method"
// ENUMS
`` apply "enum"
// STRUCTS // STRUCTS
`` apply "struct" `` apply "struct"
// METHODS
// ENUMS `` apply "method"
`` apply "enum"
|| ||
} }
} }
@ -29,7 +30,6 @@ tstylesheet {
> ) > )
} }
template "method" { template "method" {
const "signature_c" call "method_2_signature_c"; const "signature_c" call "method_2_signature_c";
|| ||
@ -51,11 +51,17 @@ tstylesheet {
``apply "use", mode="return_args_as_tuple" ``apply "use", mode="return_args_as_tuple"
); );
}, },
`apply "use", 0, mode="create_args_py"`
R"mydelimiter(
«$signature_c»
``apply "use" mode="docstring"
``apply "return" mode="docstring"
)mydelimiter",
py::return_value_policy::copy); py::return_value_policy::copy);
|| ||
} }
// Creates the dereferences for given pointer type, to create // Creates the dereferences for given pointer type, to create
// the simple pointer type of it. (char*) // the simple pointer type of it. (char*)
// char*** => ** // char*** => **
@ -106,6 +112,16 @@ tstylesheet {
} }
} }
template "return" mode="docstring" {
const "type", "@type";
choose {
when "$type != 'PEP_SESSION'" {
| :return: («$type»... args)
| :rtype: tuple
}
}
}
template "use" mode="create_args_c" { template "use" mode="create_args_c" {
const "name", "@name"; const "name", "@name";
const "type", "@type"; const "type", "@type";
@ -122,6 +138,27 @@ tstylesheet {
} }
} }
template "use" mode="docstring" {
const "name", "@name";
const "type", "@type";
choose {
when "$type != 'PEP_SESSION'" {
| :param «$name»: «$type»
| :type «$name»: «$type»
}
}
}
template "use" mode="create_args_py" {
const "name", "@name";
const "type", "@type";
choose {
when "$type != 'PEP_SESSION'" {
| py::arg("«$name»"),
}
}
}
template "use", mode="return_args_as_tuple" { template "use", mode="return_args_as_tuple" {
const "name", "@name"; const "name", "@name";
const "type", "@type"; const "type", "@type";
@ -153,10 +190,14 @@ tstylesheet {
// int**** => int* // int**** => int*
// int => int // int => int
function "decay" { function "decay" {
param "mode";
param "type"; param "type";
choose { choose {
when "contains($type,'*')" { when "contains($type,'*')" {
> «substring-before($type,'*')»* > «substring-before($type,'*')»
if "$mode != 'full'" {
> *
}
} otherwise { } otherwise {
> «$type» > «$type»
} }

Loading…
Cancel
Save