this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Upgrade Python language bindings to `v1.4.1` (#2459)

* Update pocketpy

* fix `py_pix`

* ...

* Update pocketpy

* update pocketpy to 1.4.1

* Update pocketpy

authored by

BLUELOVETH and committed by
GitHub
0602c496 fd02c6f8

+13 -32
-1
cmake/pocketpy.cmake
··· 10 10 if(BUILD_WITH_PYTHON) 11 11 12 12 add_subdirectory(${THIRDPARTY_DIR}/pocketpy) 13 - target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) 14 13 include_directories(${THIRDPARTY_DIR}/pocketpy/include) 15 14 16 15 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+13 -31
src/api/python.c
··· 15 15 pkpy_CName MENU; 16 16 } N; 17 17 18 - // duplicate a pkpy_CString to a null-terminated c string 19 - static char* cstrdup(pkpy_CString cs){ 20 - char* s = (char*)malloc(cs.size + 1); 21 - memcpy(s, cs.data, cs.size); 22 - s[cs.size] = '\0'; 23 - return s; 24 - } 25 - 26 18 static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ 27 19 pkpy_setglobal(vm, pkpy_name(name)); 28 20 } ··· 105 97 return 0; 106 98 } 107 99 108 - char* message_s = cstrdup(message); 109 - tic_api_trace(tic, message_s, (u8) color); 110 - free(message_s); 100 + tic_api_trace(tic, message, (u8) color); 111 101 return 0; 112 102 } 113 103 ··· 344 334 else 345 335 { 346 336 u8 chromakey = (u8) chromakey_raw; 347 - char* text_s = cstrdup(text); 348 - s32 size = tic_api_font(tic, text_s, x, y, &chromakey, 1, width, height, fixed, scale, alt); 349 - free(text_s); 337 + s32 size = tic_api_font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt); 350 338 pkpy_push_int(vm, size); 351 339 } 352 340 ··· 364 352 return 0; 365 353 366 354 if (key_id >= tic_keys_count) { 367 - pkpy_error(vm, "tic80-panic!", pkpy_string("unknown keyboard code\n")); 355 + pkpy_error(vm, "RuntimeError", pkpy_string("unknown keyboard code\n")); 368 356 return 0; 369 357 } 370 358 ··· 388 376 return 0; 389 377 390 378 if (key_id >= tic_keys_count) { 391 - pkpy_error(vm, "tic80-panic!", pkpy_string("unknown keyboard code\n")); 379 + pkpy_error(vm, "RuntimeError", pkpy_string("unknown keyboard code\n")); 392 380 return 0; 393 381 } 394 382 ··· 598 586 return 0; 599 587 600 588 if (track > MUSIC_TRACKS - 1 ) 601 - pkpy_error(vm, "tic80-panic!", pkpy_string("invalid music track index\n")); 589 + pkpy_error(vm, "RuntimeError", pkpy_string("invalid music track index\n")); 602 590 603 591 //stop the music first I guess 604 592 tic_api_music(tic, -1, 0, 0, false, false, -1, -1); ··· 715 703 return 0; 716 704 717 705 if (index >= TIC_PERSISTENT_SIZE) { 718 - pkpy_error(vm, "tic80-panic!", pkpy_string("invalid persistent tic index\n")); 706 + pkpy_error(vm, "RuntimeError", pkpy_string("invalid persistent tic index\n")); 719 707 return 0; 720 708 } 721 709 ··· 825 813 return 0; 826 814 } 827 815 828 - char* text_s = cstrdup(text); 829 - s32 size = tic_api_print(tic, text_s, x, y, color, fixed, scale, alt); 830 - free(text_s); 831 - 816 + s32 size = tic_api_print(tic, text, x, y, color, fixed, scale, alt); 832 817 pkpy_push_int(vm, size); 833 818 return 1; 834 819 } ··· 883 868 int sfx_id; 884 869 885 870 bool parse_note = false; 886 - char* string_note = NULL; 871 + const char* string_note = NULL; 887 872 int int_note; 888 873 889 874 int duration; ··· 895 880 896 881 if (pkpy_is_string(vm, 1)) { 897 882 parse_note = true; 898 - pkpy_CString tmp; 899 - pkpy_to_string(vm, 1, &tmp); 900 - if(tmp.size) string_note = cstrdup(tmp); 883 + pkpy_to_string(vm, 1, &string_note); 901 884 } else { 902 885 pkpy_to_int(vm, 1, &int_note); 903 886 } ··· 913 896 914 897 if (parse_note) { 915 898 if(!tic_tool_parse_note(string_note, &note, &octave)) { 916 - pkpy_error(vm, "tic80-panic!", pkpy_string("invalid note, should like C#4\n")); 899 + pkpy_error(vm, "RuntimeError", pkpy_string("invalid note, should like C#4\n")); 917 900 goto cleanup; //error in future; 918 901 } 919 902 ··· 923 906 } 924 907 925 908 if (channel < 0 || channel >= TIC_SOUND_CHANNELS) { 926 - pkpy_error(vm, "tic80-panic!", pkpy_string("unknown channel\n")); 909 + pkpy_error(vm, "RuntimeError", pkpy_string("unknown channel\n")); 927 910 goto cleanup; 928 911 } 929 912 930 913 if (sfx_id >= SFX_COUNT) { 931 - pkpy_error(vm, "tic80-panic!", pkpy_string("unknown sfx index\n")); 914 + pkpy_error(vm, "RuntimeError", pkpy_string("unknown sfx index\n")); 932 915 goto cleanup; 933 916 } 934 917 ··· 937 920 tic_api_sfx(tic, sfx_id, note, octave, duration, channel, volume & 0xf, volume & 0xf, speed); 938 921 939 922 cleanup : 940 - if (string_note != NULL) free(string_note); 941 923 return 0; 942 924 } 943 925 ··· 1000 982 return 0; 1001 983 1002 984 if (bank < 0 || bank >= TIC_BANKS) { 1003 - pkpy_error(vm, "tic80-panic!", pkpy_string("sync() error, invalid bank\n")); 985 + pkpy_error(vm, "RuntimeError", pkpy_string("sync() error, invalid bank\n")); 1004 986 return 0; 1005 987 } 1006 988