mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
3c6e4b4e76
commit
b3e77cdb51
@ -113,6 +113,12 @@ static PyObject* convert_cjson_to_python_object(const cJSON * const item, VM* vm
|
|||||||
|
|
||||||
void add_module_cjson(VM* vm){
|
void add_module_cjson(VM* vm){
|
||||||
PyObject* mod = vm->new_module("cjson");
|
PyObject* mod = vm->new_module("cjson");
|
||||||
|
|
||||||
|
PK_LOCAL_STATIC cJSON_Hooks hooks;
|
||||||
|
hooks.malloc_fn = pool64_alloc;
|
||||||
|
hooks.free_fn = pool64_dealloc;
|
||||||
|
cJSON_InitHooks(&hooks);
|
||||||
|
|
||||||
vm->bind_func<1>(mod, "loads", [](VM* vm, ArgsView args){
|
vm->bind_func<1>(mod, "loads", [](VM* vm, ArgsView args){
|
||||||
const Str& string = CAST(Str&, args[0]);
|
const Str& string = CAST(Str&, args[0]);
|
||||||
cJSON *json = cJSON_ParseWithLength(string.data, string.size);
|
cJSON *json = cJSON_ParseWithLength(string.data, string.size);
|
||||||
|
@ -7,11 +7,9 @@ if not os.path.exists("build"):
|
|||||||
|
|
||||||
os.chdir("build")
|
os.chdir("build")
|
||||||
|
|
||||||
code = os.system(r"""
|
code = os.system("cmake .. -DPK_USE_CJSON=ON -DPK_USE_BOX2D=ON")
|
||||||
cmake .. -DPK_USE_CJSON=ON -DPK_USE_BOX2D=ON
|
assert code == 0
|
||||||
cmake --build . --config Release
|
code = os.system("cmake --build . --config Release")
|
||||||
""")
|
|
||||||
|
|
||||||
assert code == 0
|
assert code == 0
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user