add PK_ENABLE_CUSTOM_SNAME

This commit is contained in:
blueloveTH 2025-06-05 22:18:50 +08:00
parent 8fe2e4457f
commit c0d5f1e575
5 changed files with 21 additions and 2 deletions

View File

@ -53,6 +53,11 @@ if(PK_ENABLE_WATCHDOG)
add_definitions(-DPK_ENABLE_WATCHDOG=1)
endif()
if(PK_ENABLE_CUSTOM_SNAME)
add_definitions(-DPK_ENABLE_CUSTOM_SNAME=1)
endif()
if(PK_BUILD_MODULE_LZ4)
add_subdirectory(3rd/lz4)
add_definitions(-DPK_BUILD_MODULE_LZ4)

View File

@ -9,6 +9,7 @@ endif()
option(PK_ENABLE_OS "" OFF)
option(PK_ENABLE_DETERMINISM "" OFF)
option(PK_ENABLE_WATCHDOG "" OFF)
option(PK_ENABLE_CUSTOM_SNAME "" OFF)
# modules
option(PK_BUILD_MODULE_LZ4 "" OFF)

View File

@ -7,4 +7,9 @@ void pk_names_finalize();
#define MAGIC_METHOD(x) extern py_Name x;
#include "pocketpy/xmacros/magics.h"
#undef MAGIC_METHOD
#undef MAGIC_METHOD
py_Name py_namev(c11_sv name);
c11_sv py_name2sv(py_Name index);
py_Name py_name(const char* name);
const char* py_name2str(py_Name index);

View File

@ -20,6 +20,10 @@
#define PK_ENABLE_WATCHDOG 0
#endif
#ifndef PK_ENABLE_CUSTOM_SNAME // can be overridden by cmake
#define PK_ENABLE_CUSTOM_SNAME 0
#endif
// GC min threshold
#ifndef PK_GC_MIN_THRESHOLD // can be overridden by cmake
#define PK_GC_MIN_THRESHOLD 32768

View File

@ -1,3 +1,5 @@
#if PK_ENABLE_CUSTOM_SNAME == 0
#include "pocketpy/common/name.h"
#include "pocketpy/common/str.h"
#include "pocketpy/pocketpy.h"
@ -94,4 +96,6 @@ py_Name py_name(const char* name) {
const char* py_name2str(py_Name index) {
NameBucket* p = (NameBucket*)index;
return p->data;
}
}
#endif