mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 06:30:17 +00:00
fix struct gen
This commit is contained in:
parent
63334872f6
commit
9d2cb89b24
@ -142,7 +142,8 @@ static bool gpio_config__get_label(int argc, py_Ref argv) {
|
||||
return true;
|
||||
}
|
||||
static py_Type register__gpio_config(py_GlobalRef mod) {
|
||||
py_Type type = py_newtype("gpio_config", tp_object, mod, NULL);
|
||||
py_Type type = py_newtype("gpio_config", tp_stdc_Memory, mod, NULL);
|
||||
py_newint(py_emplacedict(py_tpobject(type), py_name("size")), sizeof(gpio_config_t));
|
||||
py_bindmethod(type, "__new__", gpio_config__new__);
|
||||
py_bindmethod(type, "__init__", gpio_config__init__);
|
||||
py_bindproperty(type, "direction", gpio_config__get_direction, gpio_config__set_direction);
|
||||
@ -228,7 +229,8 @@ static bool periphery_version__get_commit_id(int argc, py_Ref argv) {
|
||||
return true;
|
||||
}
|
||||
static py_Type register__periphery_version(py_GlobalRef mod) {
|
||||
py_Type type = py_newtype("periphery_version", tp_object, mod, NULL);
|
||||
py_Type type = py_newtype("periphery_version", tp_stdc_Memory, mod, NULL);
|
||||
py_newint(py_emplacedict(py_tpobject(type), py_name("size")), sizeof(periphery_version_t));
|
||||
py_bindmethod(type, "__new__", periphery_version__new__);
|
||||
py_bindmethod(type, "__init__", periphery_version__init__);
|
||||
py_bindproperty(type, "major", periphery_version__get_major, periphery_version__set_major);
|
||||
|
||||
@ -71,7 +71,8 @@ def gen_struct(w: Writer, pyi_w: Writer, struct: Struct):
|
||||
|
||||
w.write(f'static py_Type register__{identifier}(py_GlobalRef mod) {{')
|
||||
w.indent()
|
||||
w.write(f'py_Type type = py_newtype("{identifier}", tp_object, mod, NULL);')
|
||||
w.write(f'py_Type type = py_newtype("{identifier}", tp_stdc_Memory, mod, NULL);')
|
||||
w.write(f'py_newint(py_emplacedict(py_tpobject(type), py_name("size")), sizeof({name}));')
|
||||
|
||||
w.write(f'py_bindmethod(type, "__new__", {identifier}__new__);')
|
||||
w.write(f'py_bindmethod(type, "__init__", {identifier}__init__);')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user