This commit is contained in:
blueloveTH 2024-07-01 20:06:52 +08:00
parent 7692899366
commit a9d6242a43
2 changed files with 8 additions and 0 deletions

View File

@ -105,6 +105,7 @@ bool py_tobool(const py_Ref);
py_Type py_totype(const py_Ref);
const char* py_tostr(const py_Ref);
const char* py_tostrn(const py_Ref, int* size);
const unsigned char* py_tobytes(const py_Ref, int* size);
void* py_touserdata(const py_Ref);

View File

@ -51,6 +51,13 @@ const char* py_tostrn(const py_Ref self, int* size){
return py_Str__data(ud);
}
const unsigned char* py_tobytes(const py_Ref self, int* size){
assert(self->type == tp_bytes);
int* ud = PyObject__value(self->_obj);
*size = *ud;
return (unsigned char*)(ud + 1);
}
void* py_touserdata(const py_Ref self){
assert(self && self->is_ptr);
return PyObject__value(self->_obj);