From ba058ba3315561b8e459e682faf99d6f1d719933 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 7 Jun 2025 01:49:18 +0800 Subject: [PATCH] remove `py_assign` --- include/pocketpy/pocketpy.h | 13 ++++++------- src/public/stack_ops.c | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index 5589ccea..07410cef 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -29,9 +29,9 @@ typedef double py_f64; typedef void (*py_Dtor)(void*); #ifdef PK_IS_PUBLIC_INCLUDE - typedef struct py_TValue { - char _[16]; - } py_TValue; +typedef struct py_TValue { + char _[16]; +} py_TValue; #endif /// A string view type. It is helpful for passing strings which are not null-terminated. @@ -378,8 +378,6 @@ PK_API void py_setglobal(py_Name name, py_Ref val); /// Get variable in the `builtins` module. PK_API py_ItemRef py_getbuiltin(py_Name name); -/// Equivalent to `*dst = *src`. -PK_API void py_assign(py_Ref dst, py_Ref src); /// Get the last return value. PK_API py_GlobalRef py_retval(); @@ -455,8 +453,9 @@ PK_API void py_bindmagic(py_Type type, py_Name name, py_CFunction f); #define PY_CHECK_ARG_TYPE(i, type) \ if(!py_checktype(py_arg(i), type)) return false -#define py_offset(p, i) ((py_Ref)((char*)p + ((i) << 4))) -#define py_arg(i) py_offset(argv, i) +#define py_offset(p, i) ((p) + (i)) +#define py_arg(i) (&argv[i]) +#define py_assign(dst, src) *(dst) = *(src) /************* Python Equivalents *************/ diff --git a/src/public/stack_ops.c b/src/public/stack_ops.c index db34c0a6..abf8a5b3 100644 --- a/src/public/stack_ops.c +++ b/src/public/stack_ops.c @@ -68,8 +68,6 @@ py_GlobalRef py_inspect_currentmodule() { py_Frame* py_inspect_currentframe() { return pk_current_vm->top_frame; } -void py_assign(py_Ref dst, py_Ref src) { *dst = *src; } - /* Stack References */ py_Ref py_peek(int i) { assert(i <= 0);