From 120d1dfb27ec8b6f58475f5a549d2cc8190d723d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 1 Feb 2024 12:48:46 +0800 Subject: [PATCH] some fix --- include/pocketpy/common.h | 16 +--------------- include/pocketpy/error.h | 2 +- include/pocketpy/pocketpy_c.h | 2 +- include/pocketpy/vm.h | 2 +- src/error.cpp | 3 +-- src/pocketpy_c.cpp | 4 ---- src/str.cpp | 5 ++++- src2/pocketpy_c.c | 5 ----- 8 files changed, 9 insertions(+), 30 deletions(-) diff --git a/include/pocketpy/common.h b/include/pocketpy/common.h index 478ca27e..33c4dac0 100644 --- a/include/pocketpy/common.h +++ b/include/pocketpy/common.h @@ -18,7 +18,7 @@ #include #include -#define PK_VERSION "1.4.0" +#define PK_VERSION "1.4.1" #include "config.h" #include "export.h" @@ -115,13 +115,6 @@ union BitsCvtImpl<4>{ BitsCvtImpl(NumberTraits<4>::float_t val): _float(val) {} BitsCvtImpl(NumberTraits<4>::int_t val): _int(val) {} - - // void print(){ - // std::string s = std::bitset<32>(_int).to_string(); - // std::cout << s.substr(0, 1) << '|'; - // std::cout << s.substr(1, 8) << '|'; - // std::cout << s.substr(9) << std::endl; - // } }; template<> @@ -146,13 +139,6 @@ union BitsCvtImpl<8>{ BitsCvtImpl(NumberTraits<8>::float_t val): _float(val) {} BitsCvtImpl(NumberTraits<8>::int_t val): _int(val) {} - - // void print(){ - // std::string s = std::bitset<64>(_int).to_string(); - // std::cout << s.substr(0, 1) << '|'; - // std::cout << s.substr(1, 11) << '|'; - // std::cout << s.substr(12) << std::endl; - // } }; using BitsCvt = BitsCvtImpl; diff --git a/include/pocketpy/error.h b/include/pocketpy/error.h index a56e4804..a2dbceba 100644 --- a/include/pocketpy/error.h +++ b/include/pocketpy/error.h @@ -29,7 +29,7 @@ struct SourceData { Str filename; CompileMode mode; - std::string source; // assume '\0' terminated + Str source; std::vector line_starts; SourceData(const Str& source, const Str& filename, CompileMode mode); diff --git a/include/pocketpy/pocketpy_c.h b/include/pocketpy/pocketpy_c.h index b58812c3..ba3d8dc2 100644 --- a/include/pocketpy/pocketpy_c.h +++ b/include/pocketpy/pocketpy_c.h @@ -87,7 +87,7 @@ PK_EXPORT bool pkpy_vectorcall(pkpy_vm*, int argc); /* Special APIs */ PK_EXPORT void pkpy_free(void* p); -PK_EXPORT pkpy_CString pkpy_string(const char* s); +#define pkpy_string(__s) (__s) PK_EXPORT pkpy_CName pkpy_name(const char* s); PK_EXPORT pkpy_CString pkpy_name_to_string(pkpy_CName name); PK_EXPORT void pkpy_set_output_handler(pkpy_vm*, pkpy_COutputHandler handler); diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index fe80e561..7fb97bf5 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -582,7 +582,7 @@ inline const char* _py_cast(VM* vm, PyObject* obj){ } inline PyObject* py_var(VM* vm, std::string val){ - return VAR(Str(std::move(val))); + return VAR(Str(val)); } inline PyObject* py_var(VM* vm, std::string_view val){ diff --git a/src/error.cpp b/src/error.cpp index 0bb5dc10..d280d894 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -12,8 +12,7 @@ namespace pkpy{ if(source[index] != '\r') ss << source[index]; index++; } - this->source = ss.str().str(); - + this->source = ss.str(); line_starts.push_back(this->source.c_str()); } diff --git a/src/pocketpy_c.cpp b/src/pocketpy_c.cpp index eef94764..d0a442fc 100644 --- a/src/pocketpy_c.cpp +++ b/src/pocketpy_c.cpp @@ -546,10 +546,6 @@ void pkpy_free(void* p){ free(p); } -pkpy_CString pkpy_string(const char* value){ - return value; -} - pkpy_CName pkpy_name(const char* name){ return StrName(name).index; } diff --git a/src/str.cpp b/src/str.cpp index d328487c..bddd5bd3 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -60,6 +60,7 @@ int utf8len(unsigned char c, bool suppress){ for(int i=0; i