diff --git a/pEpACIDgen/gen_backend/gen_pybind11.ysl2 b/pEpACIDgen/gen_backend/gen_pybind11.ysl2 index 1d60477..e367837 100644 --- a/pEpACIDgen/gen_backend/gen_pybind11.ysl2 +++ b/pEpACIDgen/gen_backend/gen_pybind11.ysl2 @@ -5,18 +5,19 @@ tstylesheet { document("py_module.pybind11", "text") { || namespace py = pybind11; + //py::options options; + //options.disable_function_signatures(); // INSERT COOL ASCII ART HERE - // METHOD - `` apply "method" + // ENUMS + `` apply "enum" // STRUCTS `` apply "struct" - - // ENUMS - `` apply "enum" + // METHODS + `` apply "method" || } } @@ -29,7 +30,6 @@ tstylesheet { > ) } - template "method" { const "signature_c" call "method_2_signature_c"; || @@ -51,11 +51,17 @@ tstylesheet { ``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); || } - // Creates the dereferences for given pointer type, to create // the simple pointer type of it. (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" { const "name", "@name"; 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" { const "name", "@name"; const "type", "@type"; @@ -153,10 +190,14 @@ tstylesheet { // int**** => int* // int => int function "decay" { + param "mode"; param "type"; choose { when "contains($type,'*')" { - > «substring-before($type,'*')»* + > «substring-before($type,'*')» + if "$mode != 'full'" { + > * + } } otherwise { > «$type» }