mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
f8872f8bc7
commit
d540af3043
@ -49,10 +49,6 @@ vm->bind(obj,
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
!!!
|
|
||||||
Other documents are working in progress.
|
|
||||||
!!!
|
|
||||||
|
|
||||||
### Bind a struct
|
### Bind a struct
|
||||||
|
|
||||||
Assume you have a struct `Point` declared as follows.
|
Assume you have a struct `Point` declared as follows.
|
||||||
@ -113,7 +109,7 @@ struct wrapped__Point{
|
|||||||
wrapped__Point& self = _py_cast<wrapped__Point>(vm, args[0]);
|
wrapped__Point& self = _py_cast<wrapped__Point>(vm, args[0]);
|
||||||
self.value.x = py_cast<int>(vm, args[1]);
|
self.value.x = py_cast<int>(vm, args[1]);
|
||||||
self.value.y = py_cast<int>(vm, args[2]);
|
self.value.y = py_cast<int>(vm, args[2]);
|
||||||
return vm->None
|
return vm->None;
|
||||||
});
|
});
|
||||||
|
|
||||||
// other custom methods
|
// other custom methods
|
||||||
@ -162,6 +158,6 @@ This specialized binding function has optimizations and result in better perform
|
|||||||
For example, `vm->bind__add__` is preferred over `vm->bind_method<1>(type, "__add__", ...)`.
|
For example, `vm->bind__add__` is preferred over `vm->bind_method<1>(type, "__add__", ...)`.
|
||||||
|
|
||||||
|
|
||||||
#### Further reading
|
### Further reading
|
||||||
|
|
||||||
See [linalg.h](https://github.com/blueloveTH/pocketpy/blob/main/src/linalg.h) for the complete implementation.
|
See [linalg.h](https://github.com/blueloveTH/pocketpy/blob/main/src/linalg.h) for a complete example used by `linalg` module.
|
Loading…
x
Reference in New Issue
Block a user