[pypy-commit] pypy hpy-ctypespace: move the typefef HPyInitFunc into cts; I removed the 'Ptr' from it to follow CPython convention (e.g., PyCFunction). In order to make it working, I had to move the HPy/_HPy_real distinction inside the cts itself
antocuni
pypy.commits at gmail.com
Fri Nov 22 11:26:38 EST 2019
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: hpy-ctypespace
Changeset: r98138:c00a74b4ddb9
Date: 2019-11-21 19:37 +0100
http://bitbucket.org/pypy/pypy/changeset/c00a74b4ddb9/
Log: move the typefef HPyInitFunc into cts; I removed the 'Ptr' from it
to follow CPython convention (e.g., PyCFunction). In order to make
it working, I had to move the HPy/_HPy_real distinction inside the
cts itself
diff --git a/pypy/module/hpy_universal/interp_hpy.py b/pypy/module/hpy_universal/interp_hpy.py
--- a/pypy/module/hpy_universal/interp_hpy.py
+++ b/pypy/module/hpy_universal/interp_hpy.py
@@ -100,7 +100,7 @@
def create_hpy_module(space, name, origin, lib, initfunc):
state = space.fromcache(State)
- initfunc = rffi.cast(llapi.HPyInitFuncPtr, initfunc)
+ initfunc = rffi.cast(llapi.HPyInitFunc, initfunc)
h_module = generic_cpy_call_dont_convert_result(space, initfunc, state.ctx)
return handles.consume(space, h_module)
diff --git a/pypy/module/hpy_universal/llapi.py b/pypy/module/hpy_universal/llapi.py
--- a/pypy/module/hpy_universal/llapi.py
+++ b/pypy/module/hpy_universal/llapi.py
@@ -43,13 +43,17 @@
cts.headers.append('stdint.h')
cts.parse_source("""
typedef intptr_t HPy_ssize_t;
-typedef struct { HPy_ssize_t _i; } HPy;
+
+// see below for more info about HPy vs _HPy_real
+typedef HPy_ssize_t HPy;
+typedef struct { HPy_ssize_t _i; } _HPy_real;
+
typedef struct _HPyContext_s {
int ctx_version;
- HPy h_None;
- HPy h_True;
- HPy h_False;
- HPy h_ValueError;
+ _HPy_real h_None;
+ _HPy_real h_True;
+ _HPy_real h_False;
+ _HPy_real h_ValueError;
void *ctx_Module_Create;
void *ctx_Dup;
void *ctx_Close;
@@ -64,6 +68,8 @@
void *ctx_CallRealFunctionFromTrampoline;
} _struct_HPyContext_s;
typedef struct _HPyContext_s *HPyContext;
+
+typedef HPy (*HPyInitFunc)(HPyContext ctx);
""")
HPy_ssize_t = cts.gettype('HPy_ssize_t')
@@ -75,11 +81,11 @@
# for practical reason, we use a primitive type to represent HPy almost
# everywhere in RPython. HOWEVER, the "real" HPy C type is a struct
-HPy = HPy_ssize_t
-_HPy_real = cts.gettype('HPy')
+HPy = cts.gettype('HPy')
+_HPy_real = cts.gettype('_HPy_real')
-HPyInitFuncPtr = lltype.Ptr(lltype.FuncType([HPyContext], HPy))
+HPyInitFunc = cts.gettype('HPyInitFunc')
_HPyCFunctionPtr = lltype.Ptr(lltype.FuncType([HPyContext, HPy, HPy], HPy))
_HPy_CPyCFunctionPtr = rffi.VOIDP # not used here
More information about the pypy-commit
mailing list