|
@@ -5,7 +5,6 @@
|
|
|
#include "pocketpy/common/utils.h"
|
|
#include "pocketpy/common/utils.h"
|
|
|
#include "pocketpy/common/sstream.h"
|
|
#include "pocketpy/common/sstream.h"
|
|
|
#include "pocketpy/interpreter/vm.h"
|
|
#include "pocketpy/interpreter/vm.h"
|
|
|
-#include "pocketpy/interpreter/array2d.h"
|
|
|
|
|
#include <stdint.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
@@ -28,7 +27,6 @@ typedef enum {
|
|
|
PKL_VEC2, PKL_VEC3,
|
|
PKL_VEC2, PKL_VEC3,
|
|
|
PKL_VEC2I, PKL_VEC3I,
|
|
PKL_VEC2I, PKL_VEC3I,
|
|
|
PKL_TYPE,
|
|
PKL_TYPE,
|
|
|
- PKL_ARRAY2D,
|
|
|
|
|
PKL_IMPORT_PATH,
|
|
PKL_IMPORT_PATH,
|
|
|
PKL_GETATTR,
|
|
PKL_GETATTR,
|
|
|
PKL_TVALUE,
|
|
PKL_TVALUE,
|
|
@@ -396,22 +394,6 @@ static bool pkl__write_object(PickleObject* buf, py_TValue* obj) {
|
|
|
pkl__emit_cstr(buf, name->data);
|
|
pkl__emit_cstr(buf, name->data);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
- case tp_array2d: {
|
|
|
|
|
- if(pkl__try_memo(buf, obj->_obj)) return true;
|
|
|
|
|
- c11_array2d* arr = py_touserdata(obj);
|
|
|
|
|
- for(int i = 0; i < arr->header.numel; i++) {
|
|
|
|
|
- if(arr->data[i].is_ptr)
|
|
|
|
|
- return TypeError(
|
|
|
|
|
- "'array2d' object is not picklable because it contains heap-allocated objects");
|
|
|
|
|
- buf->used_types[arr->data[i].type] = true;
|
|
|
|
|
- }
|
|
|
|
|
- pkl__emit_op(buf, PKL_ARRAY2D);
|
|
|
|
|
- pkl__emit_int(buf, arr->header.n_cols);
|
|
|
|
|
- pkl__emit_int(buf, arr->header.n_rows);
|
|
|
|
|
- PickleObject__write_bytes(buf, arr->data, arr->header.numel * sizeof(py_TValue));
|
|
|
|
|
- pkl__store_memo(buf, obj->_obj);
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
default: {
|
|
default: {
|
|
|
if(!obj->is_ptr) {
|
|
if(!obj->is_ptr) {
|
|
|
pkl__emit_op(buf, PKL_TVALUE);
|
|
pkl__emit_op(buf, PKL_TVALUE);
|
|
@@ -732,18 +714,6 @@ bool py_pickle_loads_body(const unsigned char* p, int memo_length, c11_smallmap_
|
|
|
py_push(py_tpobject(type));
|
|
py_push(py_tpobject(type));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- case PKL_ARRAY2D: {
|
|
|
|
|
- int n_cols = pkl__read_int(&p);
|
|
|
|
|
- int n_rows = pkl__read_int(&p);
|
|
|
|
|
- c11_array2d* arr = c11_newarray2d(py_pushtmp(), n_cols, n_rows);
|
|
|
|
|
- int total_size = arr->header.numel * sizeof(py_TValue);
|
|
|
|
|
- memcpy(arr->data, p, total_size);
|
|
|
|
|
- for(int i = 0; i < arr->header.numel; i++) {
|
|
|
|
|
- arr->data[i].type = pkl__fix_type(arr->data[i].type, type_mapping);
|
|
|
|
|
- }
|
|
|
|
|
- p += total_size;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
case PKL_IMPORT_PATH: {
|
|
case PKL_IMPORT_PATH: {
|
|
|
const char* path = pkl__read_cstr(&p);
|
|
const char* path = pkl__read_cstr(&p);
|
|
|
int res = py_import(path);
|
|
int res = py_import(path);
|