Skip to content

Commit

Permalink
Change ctx to *ctx in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgestar committed Mar 5, 2021
1 parent 678d11b commit ea65933
Show file tree
Hide file tree
Showing 20 changed files with 165 additions and 165 deletions.
4 changes: 2 additions & 2 deletions test/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DefaultExtensionTemplate(object):
};
HPy_MODINIT(%(name)s)
static HPy init_%(name)s_impl(HPyContext ctx)
static HPy init_%(name)s_impl(HPyContext *ctx)
{
HPy m = HPy_NULL;
m = HPyModule_Create(ctx, &moduledef);
Expand Down Expand Up @@ -317,7 +317,7 @@ def make_leak_module(self):
# for convenience
return self.make_module("""
HPyDef_METH(leak, "leak", leak_impl, HPyFunc_O)
static HPy leak_impl(HPyContext ctx, HPy self, HPy arg)
static HPy leak_impl(HPyContext *ctx, HPy self, HPy arg)
{
HPy_Dup(ctx, arg); // leak!
return HPy_Dup(ctx, ctx->h_None);
Expand Down
50 changes: 25 additions & 25 deletions test/test_00_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_different_name(self):
def test_noop_function(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS, .doc="hello world")
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
return HPy_Dup(ctx, ctx->h_None);
}
Expand All @@ -51,7 +51,7 @@ def test_noop_function(self):
def test_self_is_module(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
return HPy_Dup(ctx, self);
}
Expand All @@ -63,7 +63,7 @@ def test_self_is_module(self):
def test_identity_function(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_Dup(ctx, arg);
}
Expand All @@ -76,7 +76,7 @@ def test_identity_function(self):
def test_float_asdouble(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
double a = HPyFloat_AsDouble(ctx, arg);
return HPyFloat_FromDouble(ctx, a * 2.);
Expand All @@ -90,12 +90,12 @@ def test_wrong_number_of_arguments(self):
import pytest
mod = self.make_module("""
HPyDef_METH(f_noargs, "f_noargs", f_noargs_impl, HPyFunc_NOARGS)
static HPy f_noargs_impl(HPyContext ctx, HPy self)
static HPy f_noargs_impl(HPyContext *ctx, HPy self)
{
return HPy_Dup(ctx, ctx->h_None);
}
HPyDef_METH(f_o, "f_o", f_o_impl, HPyFunc_O)
static HPy f_o_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_o_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_Dup(ctx, ctx->h_None);
}
Expand All @@ -113,7 +113,7 @@ def test_wrong_number_of_arguments(self):
def test_close(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
HPy one = HPyLong_FromLong(ctx, 1);
if (HPy_IsNull(one))
Expand All @@ -130,7 +130,7 @@ def test_close(self):
def test_bool(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
int cond = HPyLong_AsLong(ctx, arg) > 5;
return HPy_Dup(ctx, cond ? ctx->h_True : ctx->h_False);
Expand All @@ -145,7 +145,7 @@ def test_exception(self):
import pytest
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
long x = HPyLong_AsLong(ctx, arg);
if (x < 5) {
Expand All @@ -167,7 +167,7 @@ def test_exception(self):
def test_varargs(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS)
static HPy f_impl(HPyContext ctx, HPy self, HPy *args, HPy_ssize_t nargs)
static HPy f_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs)
{
long a, b;
if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b))
Expand All @@ -182,7 +182,7 @@ def test_varargs(self):
def test_builtin_handles(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
long i = HPyLong_AsLong(ctx, arg);
HPy h;
Expand Down Expand Up @@ -236,25 +236,25 @@ def test_extern_def(self):
"""
extra = """
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
return HPyLong_FromLong(ctx, 12345);
}
HPyDef_METH(g, "g", g_impl, HPyFunc_O)
static HPy g_impl(HPyContext ctx, HPy self, HPy arg)
static HPy g_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_Dup(ctx, arg);
}
HPyDef_METH(h, "h", h_impl, HPyFunc_VARARGS)
static HPy h_impl(HPyContext ctx, HPy self, HPy *args, HPy_ssize_t nargs)
static HPy h_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs)
{
long a, b;
if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b))
return HPy_NULL;
return HPyLong_FromLong(ctx, 10*a + b);
}
HPyDef_METH(i, "i", i_impl, HPyFunc_KEYWORDS)
static HPy i_impl(HPyContext ctx, HPy self, HPy *args, HPy_ssize_t nargs,
static HPy i_impl(HPyContext *ctx, HPy self, HPy *args, HPy_ssize_t nargs,
HPy kw)
{
long a, b;
Expand All @@ -276,7 +276,7 @@ def test_extern_def(self):
def test_Float_FromDouble(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
return HPyFloat_FromDouble(ctx, 123.45);
}
Expand Down Expand Up @@ -304,22 +304,22 @@ def test_unsupported_signature(self):
def test_repr_str_ascii_bytes(self):
mod = self.make_module("""
HPyDef_METH(f1, "f1", f1_impl, HPyFunc_O)
static HPy f1_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f1_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_Repr(ctx, arg);
}
HPyDef_METH(f2, "f2", f2_impl, HPyFunc_O)
static HPy f2_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f2_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_Str(ctx, arg);
}
HPyDef_METH(f3, "f3", f3_impl, HPyFunc_O)
static HPy f3_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f3_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_ASCII(ctx, arg);
}
HPyDef_METH(f4, "f4", f4_impl, HPyFunc_O)
static HPy f4_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f4_impl(HPyContext *ctx, HPy self, HPy arg)
{
return HPy_Bytes(ctx, arg);
}
Expand All @@ -337,7 +337,7 @@ def test_repr_str_ascii_bytes(self):
def test_is_true(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
int cond = HPy_IsTrue(ctx, arg);
return HPy_Dup(ctx, cond ? ctx->h_True : ctx->h_False);
Expand All @@ -351,7 +351,7 @@ def test_is_true(self):
def test_richcompare(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
HPy arg2 = HPyLong_FromLong(ctx, 100);
HPy result = HPy_RichCompare(ctx, arg, arg2, HPy_GT);
Expand All @@ -367,7 +367,7 @@ def test_richcompare(self):
def test_richcomparebool(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
HPy arg2 = HPyLong_FromLong(ctx, 100);
int result = HPy_RichCompareBool(ctx, arg, arg2, HPy_GE);
Expand All @@ -383,7 +383,7 @@ def test_richcomparebool(self):
def test_hash(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
HPy_hash_t hash = HPy_Hash(ctx, arg);
return HPyLong_FromSsize_t(ctx, hash);
Expand All @@ -397,7 +397,7 @@ def test_hash(self):
def test_ctx_name(self, hpy_abi):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
return HPyUnicode_FromString(ctx, ctx->name);
}
Expand Down
22 changes: 11 additions & 11 deletions test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class TestParseItem(HPyTest):
def make_parse_item(self, fmt, type, hpy_converter):
mod = self.make_module("""
__attribute__((unused)) static inline
HPy char_to_hpybytes(HPyContext ctx, char a) {{
HPy char_to_hpybytes(HPyContext *ctx, char a) {{
return HPyBytes_FromStringAndSize(ctx, &a, 1);
}}
HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs)
{{
{type} a;
Expand Down Expand Up @@ -267,7 +267,7 @@ class TestArgParse(HPyTest):
def make_two_arg_add(self, fmt="OO"):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs)
{{
HPy a;
Expand All @@ -292,7 +292,7 @@ def make_two_arg_add(self, fmt="OO"):
def test_many_int_arguments(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs)
{
long a, b, c, d, e;
Expand All @@ -310,7 +310,7 @@ def test_many_int_arguments(self):
def test_many_handle_arguments(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs)
{
HPy a, b;
Expand All @@ -326,7 +326,7 @@ def test_many_handle_arguments(self):
def test_supplying_hpy_tracker(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs)
{
HPy a, b, result;
Expand Down Expand Up @@ -401,7 +401,7 @@ class TestArgParseKeywords(HPyTest):
def make_two_arg_add(self, fmt="O+O+"):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_KEYWORDS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs, HPy kw)
{{
HPy a, b, result;
Expand All @@ -427,7 +427,7 @@ def test_handle_two_arguments(self):
def test_handle_reordered_arguments(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_KEYWORDS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs, HPy kw)
{
HPy a, b, result;
Expand All @@ -448,7 +448,7 @@ def test_handle_reordered_arguments(self):
def test_handle_optional_arguments(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_KEYWORDS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs, HPy kw)
{
HPy a;
Expand Down Expand Up @@ -507,7 +507,7 @@ def test_blank_keyword_argument_exception(self):
import pytest
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_KEYWORDS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs, HPy kw)
{
long a, b, c;
Expand All @@ -528,7 +528,7 @@ def test_positional_only_argument(self):
import pytest
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_KEYWORDS)
static HPy f_impl(HPyContext ctx, HPy self,
static HPy f_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs, HPy kw)
{
HPy a;
Expand Down
4 changes: 2 additions & 2 deletions test/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_hpy_calltupledict(self):
import pytest
mod = self.make_module("""
HPyDef_METH(call, "call", call_impl, HPyFunc_KEYWORDS)
static HPy call_impl(HPyContext ctx, HPy self,
static HPy call_impl(HPyContext *ctx, HPy self,
HPy *args, HPy_ssize_t nargs, HPy kw)
{
Expand Down Expand Up @@ -91,7 +91,7 @@ def g():
def test_hpycallable_check(self):
mod = self.make_module("""
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
if (HPyCallable_Check(ctx, arg))
return HPy_Dup(ctx, ctx->h_True);
Expand Down
12 changes: 6 additions & 6 deletions test/test_cpy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_frompyobject(self):
mod = self.make_module("""
#include <Python.h>
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
PyObject *o = PyList_New(0);
Py_ssize_t initial_refcount = o->ob_refcnt;
Expand All @@ -42,7 +42,7 @@ def test_aspyobject(self):
mod = self.make_module("""
#include <Python.h>
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
PyObject *o = HPy_AsPyObject(ctx, arg);
long val = PyLong_AsLong(o);
Expand All @@ -58,7 +58,7 @@ def test_aspyobject_custom_class(self):
mod = self.make_module("""
#include <Python.h>
HPyDef_METH(f, "f", f_impl, HPyFunc_O)
static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
static HPy f_impl(HPyContext *ctx, HPy self, HPy arg)
{
PyObject *o = HPy_AsPyObject(ctx, arg);
PyObject *o_res = PyObject_CallMethod(o, "foo", "");
Expand All @@ -80,7 +80,7 @@ def test_hpy_close(self):
mod = self.make_module("""
#include <Python.h>
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
PyObject *o = PyList_New(0);
Expand All @@ -104,7 +104,7 @@ def test_hpy_dup(self):
mod = self.make_module("""
#include <Python.h>
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
PyObject *o = PyList_New(0);
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_many_handles(self):
#define NUM_HANDLES 10000
HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS)
static HPy f_impl(HPyContext ctx, HPy self)
static HPy f_impl(HPyContext *ctx, HPy self)
{
PyObject *o = PyList_New(0);
Expand Down
Loading

0 comments on commit ea65933

Please sign in to comment.