From b7feda8525301a98aea9a98f8a60202381632ba4 Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Wed, 22 Mar 2023 08:19:02 +0100 Subject: [PATCH] Align signature of HPyFunc_VARARGS to HPyFunc_KEYWORDS --- hpy/debug/src/_debugmod.c | 2 +- .../include/hpy/autogen_hpyfunc_declare.h | 4 +-- .../include/hpy/cpython/hpyfunc_trampolines.h | 2 +- hpy/devel/include/hpy/runtime/argparse.h | 2 +- hpy/devel/src/runtime/argparse.c | 4 +-- hpy/tools/autogen/public_api.h | 2 +- microbench/src/hpy_simple.c | 6 ++-- proof-of-concept/pof.c | 4 +-- proof-of-concept/pofcpp.cpp | 2 +- test/debug/test_builder_invalid.py | 32 +++++++++---------- test/debug/test_charptr.py | 6 ++-- test/debug/test_handles_invalid.py | 2 +- test/debug/test_misc.py | 8 ++--- test/test_00_basic.py | 4 +-- test/test_argparse.py | 10 +++--- test/test_capsule.py | 12 +++---- test/test_contextvar.py | 4 +-- test/test_eval.py | 4 +-- test/test_hpybytes.py | 8 ++--- test/test_hpyerr.py | 10 +++--- test/test_hpyslice.py | 2 +- test/test_hpytype.py | 4 +-- test/test_hpyunicode.py | 4 +-- test/test_number.py | 12 +++---- test/test_object.py | 6 ++-- test/test_tracker.py | 4 +-- test/trace/test_trace.py | 4 +-- 27 files changed, 82 insertions(+), 82 deletions(-) diff --git a/hpy/debug/src/_debugmod.c b/hpy/debug/src/_debugmod.c index 81008f403..468b4bb3c 100644 --- a/hpy/debug/src/_debugmod.c +++ b/hpy/debug/src/_debugmod.c @@ -82,7 +82,7 @@ static UHPy get_open_handles_impl(HPyContext *uctx, UHPy u_self, UHPy u_gen) HPyDef_METH(get_closed_handles, "get_closed_handles", HPyFunc_VARARGS, .doc="Return a list of all the closed handle in the cache") -static UHPy get_closed_handles_impl(HPyContext *uctx, UHPy u_self, HPy *args, HPy_ssize_t nargs) +static UHPy get_closed_handles_impl(HPyContext *uctx, UHPy u_self, const HPy *args, size_t nargs) { HPyContext *dctx = hpy_debug_get_ctx(uctx); if (dctx == NULL) diff --git a/hpy/devel/include/hpy/autogen_hpyfunc_declare.h b/hpy/devel/include/hpy/autogen_hpyfunc_declare.h index 5ea31c9be..334a36f8d 100644 --- a/hpy/devel/include/hpy/autogen_hpyfunc_declare.h +++ b/hpy/devel/include/hpy/autogen_hpyfunc_declare.h @@ -12,7 +12,7 @@ #define _HPyFunc_DECLARE_HPyFunc_NOARGS(SYM) static HPy SYM(HPyContext *ctx, HPy self) #define _HPyFunc_DECLARE_HPyFunc_O(SYM) static HPy SYM(HPyContext *ctx, HPy self, HPy arg) -#define _HPyFunc_DECLARE_HPyFunc_VARARGS(SYM) static HPy SYM(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) +#define _HPyFunc_DECLARE_HPyFunc_VARARGS(SYM) static HPy SYM(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) #define _HPyFunc_DECLARE_HPyFunc_KEYWORDS(SYM) static HPy SYM(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames) #define _HPyFunc_DECLARE_HPyFunc_UNARYFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy) #define _HPyFunc_DECLARE_HPyFunc_BINARYFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy) @@ -50,7 +50,7 @@ typedef HPy (*HPyFunc_noargs)(HPyContext *ctx, HPy self); typedef HPy (*HPyFunc_o)(HPyContext *ctx, HPy self, HPy arg); -typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs); +typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs); typedef HPy (*HPyFunc_keywords)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames); typedef HPy (*HPyFunc_unaryfunc)(HPyContext *ctx, HPy); typedef HPy (*HPyFunc_binaryfunc)(HPyContext *ctx, HPy, HPy); diff --git a/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h b/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h index c65f020fd..0e8898360 100644 --- a/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h +++ b/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h @@ -1,7 +1,7 @@ #ifndef HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H #define HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H -typedef HPy (*_HPyCFunction_VARARGS)(HPyContext*, HPy, const HPy *, HPy_ssize_t); +typedef HPy (*_HPyCFunction_VARARGS)(HPyContext*, HPy, const HPy *, size_t); #define _HPyFunc_TRAMPOLINE_HPyFunc_VARARGS(SYM, IMPL) \ static PyObject* \ SYM(PyObject *self, PyObject *const *args, Py_ssize_t nargs) \ diff --git a/hpy/devel/include/hpy/runtime/argparse.h b/hpy/devel/include/hpy/runtime/argparse.h index 040e39401..5d43db163 100644 --- a/hpy/devel/include/hpy/runtime/argparse.h +++ b/hpy/devel/include/hpy/runtime/argparse.h @@ -8,7 +8,7 @@ extern "C" { HPyAPI_HELPER int HPyArg_Parse(HPyContext *ctx, HPyTracker *ht, const HPy *args, - HPy_ssize_t nargs, const char *fmt, ...); + size_t nargs, const char *fmt, ...); HPyAPI_HELPER int HPyArg_ParseKeywords(HPyContext *ctx, HPyTracker *ht, const HPy *args, diff --git a/hpy/devel/src/runtime/argparse.c b/hpy/devel/src/runtime/argparse.c index 2d58fb754..9f2b97212 100644 --- a/hpy/devel/src/runtime/argparse.c +++ b/hpy/devel/src/runtime/argparse.c @@ -463,14 +463,14 @@ parse_item(HPyContext *ctx, HPyTracker *ht, HPy current_arg, int current_arg_tmp * future format string codes (e.g. for character strings). */ HPyAPI_HELPER int -HPyArg_Parse(HPyContext *ctx, HPyTracker *ht, const HPy *args, HPy_ssize_t nargs, const char *fmt, ...) +HPyArg_Parse(HPyContext *ctx, HPyTracker *ht, const HPy *args, size_t nargs, const char *fmt, ...) { const char *fmt1 = fmt; const char *err_fmt = NULL; const char *fmt_end = NULL; int optional = 0; - HPy_ssize_t i = 0; + size_t i = 0; HPy current_arg; fmt_end = parse_err_fmt(fmt, &err_fmt); diff --git a/hpy/tools/autogen/public_api.h b/hpy/tools/autogen/public_api.h index 61fea9b14..0879e3289 100644 --- a/hpy/tools/autogen/public_api.h +++ b/hpy/tools/autogen/public_api.h @@ -1066,7 +1066,7 @@ int HPy_SetCallFunction(HPyContext *ctx, HPy h, HPyCallFunction *func); */ typedef HPy (*HPyFunc_noargs)(HPyContext *ctx, HPy self); typedef HPy (*HPyFunc_o)(HPyContext *ctx, HPy self, HPy arg); -typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs); +typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs); typedef HPy (*HPyFunc_keywords)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames); diff --git a/microbench/src/hpy_simple.c b/microbench/src/hpy_simple.c index d252b3b2a..a5dddadd6 100644 --- a/microbench/src/hpy_simple.c +++ b/microbench/src/hpy_simple.c @@ -15,13 +15,13 @@ static HPy onearg_impl(HPyContext *ctx, HPy self, HPy arg) } HPyDef_METH(varargs, "varargs", HPyFunc_VARARGS) -static HPy varargs_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) +static HPy varargs_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { return HPy_Dup(ctx, ctx->h_None); } HPyDef_METH(call_with_tuple, "call_with_tuple", HPyFunc_VARARGS) -static HPy call_with_tuple_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) +static HPy call_with_tuple_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy f, f_args; if (nargs != 2) { @@ -34,7 +34,7 @@ static HPy call_with_tuple_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_ } HPyDef_METH(call_with_tuple_and_dict, "call_with_tuple_and_dict", HPyFunc_VARARGS) -static HPy call_with_tuple_and_dict_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) +static HPy call_with_tuple_and_dict_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy f, f_args, f_kw; if (nargs != 3) { diff --git a/proof-of-concept/pof.c b/proof-of-concept/pof.c index 932c70b7a..672a9a019 100644 --- a/proof-of-concept/pof.c +++ b/proof-of-concept/pof.c @@ -14,7 +14,7 @@ static HPy double_obj_impl(HPyContext *ctx, HPy self, HPy obj) } HPyDef_METH(add_ints, "add_ints", HPyFunc_VARARGS) -static HPy add_ints_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) +static HPy add_ints_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { long a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b)) @@ -106,4 +106,4 @@ static HPyModuleDef moduledef = { .defines = module_defines }; -HPy_MODINIT(pof, moduledef) \ No newline at end of file +HPy_MODINIT(pof, moduledef) diff --git a/proof-of-concept/pofcpp.cpp b/proof-of-concept/pofcpp.cpp index 23bb0bc06..6214c5f87 100644 --- a/proof-of-concept/pofcpp.cpp +++ b/proof-of-concept/pofcpp.cpp @@ -14,7 +14,7 @@ static HPy double_obj_impl(HPyContext *ctx, HPy self, HPy obj) } HPyDef_METH(add_ints, "add_ints", HPyFunc_VARARGS) -static HPy add_ints_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) +static HPy add_ints_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { long a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b)) diff --git a/test/debug/test_builder_invalid.py b/test/debug/test_builder_invalid.py index 6695ba694..ebe708c0e 100644 --- a/test/debug/test_builder_invalid.py +++ b/test/debug/test_builder_invalid.py @@ -11,11 +11,11 @@ def test_correct_usage(compiler, hpy_debug_capture): # Basic sanity check that valid code does not trigger any error reports mod = compiler.make_module(""" HPyDef_METH(build, "build", HPyFunc_VARARGS) - static HPy build_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy build_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyTupleBuilder tbuilder = HPyTupleBuilder_New(ctx, nargs); HPyListBuilder lbuilder = HPyListBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) { + for (size_t i=0; i < nargs; i++) { HPyTupleBuilder_Set(ctx, tbuilder, i, args[i]); HPyListBuilder_Set(ctx, lbuilder, i, args[i]); } @@ -28,11 +28,11 @@ def test_correct_usage(compiler, hpy_debug_capture): } HPyDef_METH(cancel, "cancel", HPyFunc_VARARGS) - static HPy cancel_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy cancel_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyTupleBuilder tbuilder = HPyTupleBuilder_New(ctx, nargs); HPyListBuilder lbuilder = HPyListBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) { + for (size_t i=0; i < nargs; i++) { HPyTupleBuilder_Set(ctx, tbuilder, i, args[i]); HPyListBuilder_Set(ctx, lbuilder, i, args[i]); } @@ -52,20 +52,20 @@ def test_correct_usage(compiler, hpy_debug_capture): def test_build_twice(compiler, hpy_debug_capture): mod = compiler.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) + for (size_t i=0; i < nargs; i++) HPyTupleBuilder_Set(ctx, builder, i, args[i]); HPy h_result = HPyTupleBuilder_Build(ctx, builder); HPy_Close(ctx, h_result); return HPyTupleBuilder_Build(ctx, builder); } HPyDef_METH(g, "g", HPyFunc_VARARGS) - static HPy g_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy g_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyListBuilder builder = HPyListBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) + for (size_t i=0; i < nargs; i++) HPyListBuilder_Set(ctx, builder, i, args[i]); HPy h_result = HPyListBuilder_Build(ctx, builder); HPy_Close(ctx, h_result); @@ -86,19 +86,19 @@ def test_build_twice(compiler, hpy_debug_capture): def test_build_after_cancel(compiler, hpy_debug_capture): mod = compiler.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) + for (size_t i=0; i < nargs; i++) HPyTupleBuilder_Set(ctx, builder, i, args[i]); HPyTupleBuilder_Cancel(ctx, builder); return HPyTupleBuilder_Build(ctx, builder); } HPyDef_METH(g, "g", HPyFunc_VARARGS) - static HPy g_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy g_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyListBuilder builder = HPyListBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) + for (size_t i=0; i < nargs; i++) HPyListBuilder_Set(ctx, builder, i, args[i]); HPyListBuilder_Cancel(ctx, builder); return HPyListBuilder_Build(ctx, builder); @@ -118,10 +118,10 @@ def test_build_after_cancel(compiler, hpy_debug_capture): def test_build_cancel_after_build(compiler, hpy_debug_capture): mod = compiler.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) + for (size_t i=0; i < nargs; i++) HPyTupleBuilder_Set(ctx, builder, i, args[i]); HPy h_result = HPyTupleBuilder_Build(ctx, builder); HPyTupleBuilder_Cancel(ctx, builder); @@ -129,10 +129,10 @@ def test_build_cancel_after_build(compiler, hpy_debug_capture): return HPy_Dup(ctx, ctx->h_None); } HPyDef_METH(g, "g", HPyFunc_VARARGS) - static HPy g_impl(HPyContext *ctx, HPy h_self, HPy *args, HPy_ssize_t nargs) + static HPy g_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) { HPyListBuilder builder = HPyListBuilder_New(ctx, nargs); - for (int i=0; i < nargs; i++) + for (size_t i=0; i < nargs; i++) HPyListBuilder_Set(ctx, builder, i, args[i]); HPy h_result = HPyListBuilder_Build(ctx, builder); HPyListBuilder_Cancel(ctx, builder); diff --git a/test/debug/test_charptr.py b/test/debug/test_charptr.py index a7df01495..cf59cd5e9 100644 --- a/test/debug/test_charptr.py +++ b/test/debug/test_charptr.py @@ -19,7 +19,7 @@ def test_charptr_use_after_implicit_arg_handle_close(compiler, python_subprocess const char *keep; HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t n) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t n) { if (n != 2) { HPyErr_SetString(ctx, ctx->h_ValueError, "expected exactly two arguments"); @@ -74,7 +74,7 @@ def test_charptr_use_after_implicit_arg_handle_close(compiler, python_subprocess def test_charptr_use_after_handle_close(compiler, python_subprocess): mod = compiler.compile_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t n) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t n) { if (n != 2) { HPyErr_SetString(ctx, ctx->h_ValueError, "expected exactly two arguments"); @@ -127,7 +127,7 @@ def test_charptr_use_after_handle_close(compiler, python_subprocess): def test_charptr_write_ptr(compiler, python_subprocess): mod = compiler.compile_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t n) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t n) { if (n != 2) { HPyErr_SetString(ctx, ctx->h_ValueError, "expected exactly two arguments"); diff --git a/test/debug/test_handles_invalid.py b/test/debug/test_handles_invalid.py index 9dbf2cd1b..32aec8e41 100644 --- a/test/debug/test_handles_invalid.py +++ b/test/debug/test_handles_invalid.py @@ -75,7 +75,7 @@ def test_cant_use_closed_handle(compiler, hpy_debug_capture): } HPyDef_METH(f_varargs, "f_varargs", HPyFunc_VARARGS, .doc="returns arg w/o dupping it") - static HPy f_varargs_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_varargs_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { // should be: return HPy_Dup(ctx, args[0]); return args[0]; diff --git a/test/debug/test_misc.py b/test/debug/test_misc.py index f6ac7e8cb..0c6e0a4ca 100644 --- a/test/debug/test_misc.py +++ b/test/debug/test_misc.py @@ -42,7 +42,7 @@ def test_use_invalid_as_struct(compiler, python_subprocess): def test_typecheck(compiler, python_subprocess): mod = compiler.compile_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { if (nargs != 2) { HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); @@ -68,7 +68,7 @@ def test_type_getname(compiler, python_subprocess): #define MODE_READ_ONLY 0 #define MODE_USE_AFTER_FREE 1 HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy type; int mode; @@ -123,7 +123,7 @@ def test_type_getname(compiler, python_subprocess): def test_type_issubtype(compiler, python_subprocess): mod = compiler.compile_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { if (nargs != 2) { HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); @@ -147,7 +147,7 @@ def test_type_issubtype(compiler, python_subprocess): def test_unicode_substring(compiler, python_subprocess): mod = compiler.compile_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy_ssize_t start, end; if (nargs != 3) { diff --git a/test/test_00_basic.py b/test/test_00_basic.py index d553715fc..a17f10e3a 100644 --- a/test/test_00_basic.py +++ b/test/test_00_basic.py @@ -220,7 +220,7 @@ def test_exception(self): def test_varargs(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { long a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b)) @@ -316,7 +316,7 @@ def test_extern_def(self): return HPy_Dup(ctx, arg); } HPyDef_METH(h, "h", HPyFunc_VARARGS) - static HPy h_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy h_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { long a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b)) diff --git a/test/test_argparse.py b/test/test_argparse.py index 70143ffe2..51aa35c71 100644 --- a/test/test_argparse.py +++ b/test/test_argparse.py @@ -31,7 +31,7 @@ def make_parse_item(self, fmt, type, hpy_converter): HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) {{ {type} a; if (!HPyArg_Parse(ctx, NULL, args, nargs, "{fmt}", &a)) @@ -300,7 +300,7 @@ def make_two_arg_add(self, fmt="OO"): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) {{ HPy a; HPy b = HPy_NULL; @@ -325,7 +325,7 @@ def test_many_int_arguments(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { long a, b, c, d, e; if (!HPyArg_Parse(ctx, NULL, args, nargs, "lllll", @@ -343,7 +343,7 @@ def test_many_handle_arguments(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) @@ -359,7 +359,7 @@ def test_supplying_hpy_tracker(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b, result; HPyTracker ht; diff --git a/test/test_capsule.py b/test/test_capsule.py index cee5c693a..74c7134b3 100644 --- a/test/test_capsule.py +++ b/test/test_capsule.py @@ -59,7 +59,7 @@ def DEFINE_Capsule_New(self, destructor="NULL"): #define CAPSULE_NAME _capsule_name HPyDef_METH(Capsule_New, "capsule_new", HPyFunc_VARARGS) - static HPy Capsule_New_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy Capsule_New_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy res; int value; @@ -189,7 +189,7 @@ def test_capsule_getter_and_setter(self): @DEFINE_Payload_Free HPyDef_METH(Capsule_SetPointer, "capsule_setpointer", HPyFunc_VARARGS) - static HPy Capsule_SetPointer_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy Capsule_SetPointer_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy capsule; int value; @@ -236,7 +236,7 @@ def test_capsule_getter_and_setter(self): } HPyDef_METH(Capsule_SetContext, "capsule_setcontext", HPyFunc_VARARGS) - static HPy Capsule_SetContext_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy Capsule_SetContext_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy capsule; int value; @@ -264,7 +264,7 @@ def test_capsule_getter_and_setter(self): } HPyDef_METH(Capsule_SetName, "capsule_setname", HPyFunc_VARARGS) - static HPy Capsule_SetName_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy Capsule_SetName_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy capsule; const char *name; @@ -296,7 +296,7 @@ def test_capsule_getter_and_setter(self): static HPyCapsule_Destructor invalid_dtor = { NULL, NULL }; HPyDef_METH(Capsule_SetDestructor, "capsule_set_destructor", HPyFunc_VARARGS) - static HPy Capsule_SetDestructor_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy Capsule_SetDestructor_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy capsule; HPy null_dtor; @@ -392,7 +392,7 @@ def test_capsule_isvalid(self): @DEFINE_Payload_Free HPyDef_METH(Capsule_isvalid, "capsule_isvalid", HPyFunc_VARARGS) - static HPy Capsule_isvalid_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy Capsule_isvalid_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy capsule; const char *name; diff --git a/test/test_contextvar.py b/test/test_contextvar.py index b9bc82f35..dec376a25 100644 --- a/test/test_contextvar.py +++ b/test/test_contextvar.py @@ -20,7 +20,7 @@ def test_basics(self): } HPyDef_METH(set_ctxv, "set_ctxv", HPyFunc_VARARGS) - static HPy set_ctxv_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy set_ctxv_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy obj, val; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &obj, &val)) @@ -28,7 +28,7 @@ def test_basics(self): return HPyContextVar_Set(ctx, obj, val); } HPyDef_METH(get_ctxv, "get_ctxv", HPyFunc_VARARGS) - static HPy get_ctxv_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy get_ctxv_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy obj, def=HPy_NULL, val; if (!HPyArg_Parse(ctx, NULL, args, nargs, "O|O", &obj, &def)) diff --git a/test/test_eval.py b/test/test_eval.py index 1bf75c2ad..ffb89df8e 100644 --- a/test/test_eval.py +++ b/test/test_eval.py @@ -6,7 +6,7 @@ def test_compile(self): import pytest mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { const char *source, *filename; HPy_SourceKind src_kind; @@ -63,7 +63,7 @@ def test_eval_code(self): import pytest mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { if (nargs != 3) { HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 3 args"); diff --git a/test/test_hpybytes.py b/test/test_hpybytes.py index 0e7cb1d4f..c713bcb97 100644 --- a/test/test_hpybytes.py +++ b/test/test_hpybytes.py @@ -89,8 +89,8 @@ def test_FromStringAndSize(self): import pytest mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, - HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, + size_t nargs) { HPy src; long len; @@ -103,8 +103,8 @@ def test_FromStringAndSize(self): } HPyDef_METH(f_null, "f_null", HPyFunc_VARARGS) - static HPy f_null_impl(HPyContext *ctx, HPy self, HPy *args, - HPy_ssize_t nargs) + static HPy f_null_impl(HPyContext *ctx, HPy self, const HPy *args, + size_t nargs) { long len; if (!HPyArg_Parse(ctx, NULL, args, nargs, "l", &len)) { diff --git a/test/test_hpyerr.py b/test/test_hpyerr.py index faaa2477c..6adc8d51d 100644 --- a/test/test_hpyerr.py +++ b/test/test_hpyerr.py @@ -154,7 +154,7 @@ def test_HPyErr_SetFromErrnoWithFilenameObjects(self): HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) {{ HPy type, file1, file2; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &type, &file1, &file2)) @@ -337,7 +337,7 @@ def test_h_unicode_exceptions(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy h_key, h_args, h_kw; HPy h_dict, h_err, h_err_value; @@ -478,7 +478,7 @@ def check_warning(arg, category, message, file): def test_errorval_returned_by_api_functions_hpy(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy a = HPy_NULL; HPy b = HPy_NULL; @@ -523,7 +523,7 @@ def test_HPyErr_NewException(self): import pytest mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { // MSVC doesn't allow "static HPy h_FooErr = HPy_NULL" // so we do an initialization dance instead. @@ -603,7 +603,7 @@ def test_exception_matches(self): import pytest mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPyTracker ht; HPy fun, fun_args; diff --git a/test/test_hpyslice.py b/test/test_hpyslice.py index 31f647390..8f8126828 100644 --- a/test/test_hpyslice.py +++ b/test/test_hpyslice.py @@ -59,7 +59,7 @@ def test_unpack(self): def test_adjust_indices(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy_ssize_t length, start, stop, step; diff --git a/test/test_hpytype.py b/test/test_hpytype.py index 81a14d499..aa14006b4 100644 --- a/test/test_hpytype.py +++ b/test/test_hpytype.py @@ -1422,7 +1422,7 @@ def test_metaclass(self): HPyDef_METH(create_type, "create_type", HPyFunc_VARARGS) static HPy create_type_impl(HPyContext *ctx, HPy module, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy metaclass; if (!HPyArg_Parse(ctx, NULL, args, nargs, "sO", @@ -1556,7 +1556,7 @@ def test_issubtype(self): } HPyDef_METH(issubtype, "issubtype", HPyFunc_VARARGS) - static HPy issubtype_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy issubtype_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { if (nargs != 2) { HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); diff --git a/test/test_hpyunicode.py b/test/test_hpyunicode.py index 6b4e056c0..481d3029c 100644 --- a/test/test_hpyunicode.py +++ b/test/test_hpyunicode.py @@ -863,7 +863,7 @@ def test_FromEncodedObject(self): } HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy h_obj; const char *encoding, *errors; @@ -921,7 +921,7 @@ def test_Substring(self): import string mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy_ssize_t start, end; if (nargs != 3) { diff --git a/test/test_number.py b/test/test_number.py index a23459ce0..2b92924fb 100644 --- a/test/test_number.py +++ b/test/test_number.py @@ -89,7 +89,7 @@ def test_binary(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) @@ -106,7 +106,7 @@ def test_power(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b, c; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &a, &b, &c)) @@ -128,7 +128,7 @@ def __matmul__(self, other): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) @@ -158,7 +158,7 @@ def test_inplace_binary(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) @@ -178,7 +178,7 @@ def test_inplace_power(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b, c; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &a, &b, &c)) @@ -207,7 +207,7 @@ def __imatmul__(self, other): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { HPy a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) diff --git a/test/test_object.py b/test/test_object.py index 8bf3d3079..46e82e9e8 100644 --- a/test/test_object.py +++ b/test/test_object.py @@ -695,7 +695,7 @@ def test_length(self): def test_contains(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { int result = HPy_Contains(ctx, args[0], args[1]); if (result == -1) { @@ -774,7 +774,7 @@ def test_type(self): def test_typecheck(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy a, b; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) @@ -794,7 +794,7 @@ class MyStr(str): def test_is(self): mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { HPy obj, other; if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &obj, &other)) diff --git a/test/test_tracker.py b/test/test_tracker.py index c860fea23..5df8371bd 100644 --- a/test/test_tracker.py +++ b/test/test_tracker.py @@ -14,7 +14,7 @@ def hpytracker_module(self, ops, size=0): return self.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) static HPy f_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) {{ HPyTracker ht; HPy result = HPy_NULL; @@ -64,7 +64,7 @@ def test_squares_example(self): mod = self.make_module(""" HPyDef_METH(squares, "squares", HPyFunc_VARARGS) static HPy squares_impl(HPyContext *ctx, HPy self, - HPy *args, HPy_ssize_t nargs) + const HPy *args, size_t nargs) { long i, n; long n_err = -1; // simulate an error at the given index diff --git a/test/trace/test_trace.py b/test/trace/test_trace.py index 5f7b34e79..275d314df 100644 --- a/test/trace/test_trace.py +++ b/test/trace/test_trace.py @@ -23,7 +23,7 @@ def test_get_call_counts(compiler): import pytest mod = compiler.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { if (nargs != 2) { HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly two args"); @@ -81,7 +81,7 @@ def test_trace_funcs(compiler): import pytest mod = compiler.make_module(""" HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs) + static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) { if (nargs != 2) { HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly two args");