mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
ad082f0668
commit
8da3b7f110
@ -18,6 +18,7 @@ class void_p:
|
|||||||
def __sub__(self, i: int) -> 'void_p': ...
|
def __sub__(self, i: int) -> 'void_p': ...
|
||||||
def __eq__(self, other: 'void_p') -> bool: ...
|
def __eq__(self, other: 'void_p') -> bool: ...
|
||||||
def __ne__(self, other: 'void_p') -> bool: ...
|
def __ne__(self, other: 'void_p') -> bool: ...
|
||||||
|
def offset(self, i: int) -> 'void_p': ...
|
||||||
|
|
||||||
def read_char(self) -> int: ...
|
def read_char(self) -> int: ...
|
||||||
def read_uchar(self) -> int: ...
|
def read_uchar(self) -> int: ...
|
||||||
|
10
src/cffi.h
10
src/cffi.h
@ -79,16 +79,22 @@ struct VoidP{
|
|||||||
return VAR(self.base_offset);
|
return VAR(self.base_offset);
|
||||||
});
|
});
|
||||||
|
|
||||||
vm->bind_method<1>(type, "__add__", [](VM* vm, ArgsView args){
|
vm->bind_method<1>(type, "offset", [](VM* vm, ArgsView args){
|
||||||
VoidP& self = _CAST(VoidP&, args[0]);
|
VoidP& self = _CAST(VoidP&, args[0]);
|
||||||
i64 offset = CAST(i64, args[1]);
|
i64 offset = CAST(i64, args[1]);
|
||||||
return VAR_T(VoidP, (char*)self.ptr + offset * self.base_offset);
|
return VAR_T(VoidP, (char*)self.ptr + offset * self.base_offset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm->bind_method<1>(type, "__add__", [](VM* vm, ArgsView args){
|
||||||
|
VoidP& self = _CAST(VoidP&, args[0]);
|
||||||
|
i64 offset = CAST(i64, args[1]);
|
||||||
|
return VAR_T(VoidP, (char*)self.ptr + offset);
|
||||||
|
});
|
||||||
|
|
||||||
vm->bind_method<1>(type, "__sub__", [](VM* vm, ArgsView args){
|
vm->bind_method<1>(type, "__sub__", [](VM* vm, ArgsView args){
|
||||||
VoidP& self = _CAST(VoidP&, args[0]);
|
VoidP& self = _CAST(VoidP&, args[0]);
|
||||||
i64 offset = CAST(i64, args[1]);
|
i64 offset = CAST(i64, args[1]);
|
||||||
return VAR_T(VoidP, (char*)self.ptr - offset * self.base_offset);
|
return VAR_T(VoidP, (char*)self.ptr - offset);
|
||||||
});
|
});
|
||||||
|
|
||||||
#define BIND_SETGET(T, name) \
|
#define BIND_SETGET(T, name) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user