MCPcopy Create free account
hub / github.com/lief-project/LIEF / Parameter>

Method Parameter>

api/python/src/DWARF/pyParameter.cpp:11–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace LIEF::dwarf::py {
10template<>
11void create<dw::Parameter>(nb::module_& m) {
12 nb::class_<dw::Parameter> param(m, "Parameter",
13 R"doc(
14 This class represents a DWARF parameter which can be either:
15 - A regular function parameter (see: :class:`.parameters.Formal`)
16 - A template type parameter (see: :class:`.parameters.TemplateType`)
17 - A template value parameter (see: :class:`.parameters.TemplateValue`)
18 )doc"_doc
19 );
20
21 param
22 .def_prop_ro("name", &dw::Parameter::name,
23 R"doc(
24 Name of the parameter
25 )doc"_doc
26 )
27
28 .def_prop_ro("type", &dw::Parameter::type,
29 R"doc(
30 Type of this parameter
31 )doc"_doc
32 )
33 ;
34
35 nb::module_ m_params = m.def_submodule("parameters");
36 /* Formal */ {
37 nb::class_<dw::parameters::Formal, dw::Parameter>(m_params, "Formal",
38 R"doc(
39 This class represents a regular function parameter.
40
41 For instance, given this prototype:
42
43 .. code-block:: cpp
44
45 int main(int argc, const char** argv);
46
47 The function ``main`` has two :class:`.Formal` parameters:
48
49 1. ``argc`` (:attr:`lief.dwarf.Parameter.name`) typed as ``int``
50 (:class:`~lief.dwarf.types.Base` from :attr:`lief.dwarf.Parameter.type`)
51 2. ``argv`` (:attr:`lief.dwarf.Parameter.name`) typed as ``const char**``
52 (:class:`~lief.dwarf.types.Const`)
53 )doc"_doc
54 )
55 /* NOT NEEDED but dirty workaround to void stubgen generating this
56 * kind of error:
57 * lief/dwarf/parameters.pyi:1: error: Name "lief" is not defined [name-defined]
58 *
59 * CAN BE REMOVED if one of these classes are API enhanced
60 */
61 .def_prop_ro("type", &dw::parameters::Formal::type)
62 ;
63 }
64
65 /* TemplateValue */ {
66 nb::class_<dw::parameters::TemplateValue, dw::Parameter>(m_params, "TemplateValue",
67 R"doc(
68 This class represents a template **value** parameter.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected