mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
doc fix
This commit is contained in:
parent
79608fb9c9
commit
84c4bf590c
@ -112,26 +112,13 @@ struct Point{
|
||||
}
|
||||
```
|
||||
|
||||
You can write a wrapper class `wrapped__Point`. Add `PY_CLASS` macro into your wrapper class and implement a static function `_register`.
|
||||
|
||||
You can write a wrapper class `wrapped__Point`. Add implement a static function `_register`.
|
||||
Inside the `_register` function, do bind methods and properties.
|
||||
|
||||
```cpp
|
||||
PY_CLASS(T, mod, name)
|
||||
|
||||
// T is the struct type in cpp
|
||||
// mod is the module name in python
|
||||
// name is the class name in python
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```cpp
|
||||
struct wrapped__Point{
|
||||
// special macro for wrapper class
|
||||
PY_CLASS(wrapped__Point, builtins, Point)
|
||||
// ^T ^module ^name
|
||||
|
||||
// wrapped value
|
||||
Point value;
|
||||
|
||||
@ -187,8 +174,6 @@ If your custom type stores `PyObject*` in its fields, you need to handle gc for
|
||||
|
||||
```cpp
|
||||
struct Container{
|
||||
PY_CLASS(Container, builtins, Container)
|
||||
|
||||
PyObject* a;
|
||||
std::vector<PyObject*> b;
|
||||
// ...
|
||||
@ -199,8 +184,6 @@ Add a magic method `_gc_mark() const` to your custom type.
|
||||
|
||||
```cpp
|
||||
struct Container{
|
||||
PY_CLASS(Container, builtins, Container)
|
||||
|
||||
PyObject* a;
|
||||
std::vector<PyObject*> b;
|
||||
// ...
|
||||
|
@ -140,7 +140,6 @@ PyObject* list_t = vm->_t(vm->tp_list);
|
||||
Access extended python types
|
||||
|
||||
```cpp
|
||||
// VoidP was defined by `PY_CLASS` macro
|
||||
Type voidp_t = vm->_tp_user<VoidP>();
|
||||
```
|
||||
|
||||
|
@ -63,8 +63,6 @@ POINTER_VAR(const bool*, "bool_p")
|
||||
|
||||
|
||||
struct C99Struct{
|
||||
PY_CLASS(C99Struct, c, struct)
|
||||
|
||||
static constexpr int INLINE_SIZE = 24;
|
||||
|
||||
char _inlined[INLINE_SIZE];
|
||||
|
Loading…
x
Reference in New Issue
Block a user