diff --git a/prebuild b/prebuild deleted file mode 100755 index 9082cf95..00000000 Binary files a/prebuild and /dev/null differ diff --git a/src/pocketpy.h b/src/pocketpy.h index 65cf3b38..f97e6295 100644 --- a/src/pocketpy.h +++ b/src/pocketpy.h @@ -677,6 +677,21 @@ inline void init_builtins(VM* _vm) { return VAR(Str(self.str())); }); + _vm->bind_method<0>("bytes", "to_char_array", [](VM* vm, ArgsView args) { + const Bytes& self = _CAST(Bytes&, args[0]); + void* buffer = malloc(self.size()); + memcpy(buffer, self.data(), self.size()); + return VAR_T(VoidP, buffer); + }); + + _vm->bind_func<2>("bytes", "from_char_array", [](VM* vm, ArgsView args) { + const VoidP& data = _CAST(VoidP&, args[0]); + int size = CAST(int, args[1]); + std::vector buffer(size); + memcpy(buffer.data(), data.ptr, size); + return VAR(Bytes(std::move(buffer))); + }); + _vm->bind_method<1>("bytes", "__eq__", [](VM* vm, ArgsView args) { const Bytes& self = _CAST(Bytes&, args[0]); if(!is_type(args[1], vm->tp_bytes)) return VAR(false);