8000 Update HPy inlined files: 7c832a2 · oracle/graalpython@9452db7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9452db7

Browse files
committed
Update HPy inlined files: 7c832a2
1 parent 05bc6c1 commit 9452db7

27 files changed

+2065
-281
lines changed

graalpython/com.oracle.graal.python.cext/include/common/autogen_hpyfunc_declare.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define _HPyFunc_DECLARE_HPyFunc_INITPROC(SYM) static int SYM(HPyContext ctx, HPy self, HPy *args, HPy_ssize_t nargs, HPy kw)
3838
#define _HPyFunc_DECLARE_HPyFunc_GETTER(SYM) static HPy SYM(HPyContext ctx, HPy, void *)
3939
#define _HPyFunc_DECLARE_HPyFunc_SETTER(SYM) static int SYM(HPyContext ctx, HPy, HPy, void *)
40+
#define _HPyFunc_DECLARE_HPyFunc_OBJOBJPROC(SYM) static int SYM(HPyContext ctx, HPy, HPy)
4041
#define _HPyFunc_DECLARE_HPyFunc_DESTROYFUNC(SYM) static void SYM(void *)
4142

4243
typedef HPy (*HPyFunc_noargs)(HPyContext ctx, HPy self);
@@ -68,4 +69,5 @@ typedef int (*HPyFunc_descrsetfunc)(HPyContext ctx, HPy, HPy, HPy);
6869
typedef int (*HPyFunc_initproc)(HPyContext ctx, HPy self, HPy *args, HPy_ssize_t nargs, HPy kw);
6970
typedef HPy (*HPyFunc_getter)(HPyContext ctx, HPy, void *);
7071
typedef int (*HPyFunc_setter)(HPyContext ctx, HPy, HPy, void *);
72+
typedef int (*HPyFunc_objobjproc)(HPyContext ctx, HPy, HPy);
7173
typedef void (*HPyFunc_destroyfunc)(void *);

graalpython/com.oracle.graal.python.cext/include/common/autogen_hpyslot.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ typedef enum {
4242
HPy_nb_subtract = 36,
4343
HPy_nb_true_divide = 37,
4444
HPy_nb_xor = 38,
45+
HPy_sq_ass_item = 39,
46+
HPy_sq_concat = 40,
47+
HPy_sq_contains = 41,
48+
HPy_sq_inplace_concat = 42,
49+
HPy_sq_inplace_repeat = 43,
4550
HPy_sq_item = 44,
4651
HPy_sq_length = 45,
52+
HPy_sq_repeat = 46,
4753
HPy_tp_init = 60,
4854
HPy_tp_new = 65,
4955
HPy_tp_repr = 66,
@@ -85,8 +91,14 @@ typedef enum {
8591
#define _HPySlot_SIG__HPy_nb_subtract HPyFunc_BINARYFUNC
8692
#define _HPySlot_SIG__HPy_nb_true_divide HPyFunc_BINARYFUNC
8793
#define _HPySlot_SIG__HPy_nb_xor HPyFunc_BINARYFUNC
94+
#define _HPySlot_SIG__HPy_sq_ass_item HPyFunc_SSIZEOBJARGPROC
95+
#define _HPySlot_SIG__HPy_sq_concat HPyFunc_BINARYFUNC
96+
#define _HPySlot_SIG__HPy_sq_contains HPyFunc_OBJOBJPROC
97+
#define _HPySlot_SIG__HPy_sq_inplace_concat HPyFunc_BINARYFUNC
98+
#define _HPySlot_SIG__HPy_sq_inplace_repeat HPyFunc_SSIZEARGFUNC
8899
#define _HPySlot_SIG__HPy_sq_item HPyFunc_SSIZEARGFUNC
89100
#define _HPySlot_SIG__HPy_sq_length HPyFunc_LENFUNC
101+
#define _HPySlot_SIG__HPy_sq_repeat HPyFunc_SSIZEARGFUNC
90102
#define _HPySlot_SIG__HPy_tp_init HPyFunc_INITPROC
91103
#define _HPySlot_SIG__HPy_tp_new HPyFunc_KEYWORDS
92104
#define _HPySlot_SIG__HPy_tp_repr HPyFunc_REPRFUNC

graalpython/com.oracle.graal.python.cext/include/common/autogen_impl.h

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@ HPyAPI_STORAGE long _HPy_IMPL_NAME(Long_AsLong)(HPyContext ctx, HPy h)
4343
return PyLong_AsLong(_h2py(h));
4444
}
4545

46+
HPyAPI_STORAGE unsigned long _HPy_IMPL_NAME(Long_AsUnsignedLong)(HPyContext ctx, HPy h)
47+
{
48+
return PyLong_AsUnsignedLong(_h2py(h));
49+
}
50+
51+
HPyAPI_STORAGE unsigned long _HPy_IMPL_NAME(Long_AsUnsignedLongMask)(HPyContext ctx, HPy h)
52+
{
53+
return PyLong_AsUnsignedLongMask(_h2py(h));
54+
}
55+
56+
HPyAPI_STORAGE long long _HPy_IMPL_NAME(Long_AsLongLong)(HPyContext ctx, HPy h)
57+
{
58+
return PyLong_AsLongLong(_h2py(h));
59+
}
60+
61+
HPyAPI_STORAGE unsigned long long _HPy_IMPL_NAME(Long_AsUnsignedLongLong)(HPyContext ctx, HPy h)
62+
{
63+
return PyLong_AsUnsignedLongLong(_h2py(h));
64+
}
65+
66+
HPyAPI_STORAGE unsigned long long _HPy_IMPL_NAME(Long_AsUnsignedLongLongMask)(HPyContext ctx, HPy h)
67+
{
68+
return PyLong_AsUnsignedLongLongMask(_h2py(h));
69+
}
70+
71+
HPyAPI_STORAGE size_t _HPy_IMPL_NAME(Long_AsSize_t)(HPyContext ctx, HPy h)
72+
{
73+
return PyLong_AsSize_t(_h2py(h));
74+
}
75+
76+
HPyAPI_STORAGE HPy_ssize_t _HPy_IMPL_NAME(Long_AsSsize_t)(HPyContext ctx, HPy h)
77+
{
78+
return PyLong_AsSsize_t(_h2py(h));
79+
}
80+
4681
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Float_FromDouble)(HPyContext ctx, double v)
4782
{
4883
return _py2h(PyFloat_FromDouble(v));
@@ -238,11 +273,21 @@ HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetString)(HPyContext ctx, HPy h_type, co
238273
PyErr_SetString(_h2py(h_type), message);
239274
}
240275

276+
HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetObject)(HPyContext ctx, HPy h_type, HPy h_value)
277+
{
278+
PyErr_SetObject(_h2py(h_type), _h2py(h_value));
279+
}
280+
241281
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Err_NoMemory)(HPyContext ctx)
242282
{
243283
return _py2h(PyErr_NoMemory());
244284
}
245285

286+
HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_Clear)(HPyContext ctx)
287+
{
288+
PyErr_Clear();
289+
}
290+
246291
HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(IsTrue)(HPyContext ctx, HPy h)
247292
{
248293
return PyObject_IsTrue(_h2py(h));
@@ -348,6 +393,16 @@ HPyAPI_STORAGE char *_HPy_IMPL_NAME(Bytes_AS_STRING)(HPyContext ctx, HPy h)
348393
return PyBytes_AS_STRING(_h2py(h));
349394
}
350395

396+
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Bytes_FromString)(HPyContext ctx, const char *v)
397+
{
398+
return _py2h(PyBytes_FromString(v));
399+
}
400+
401+
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Bytes_FromStringAndSize)(HPyContext ctx, const char *v, HPy_ssize_t len)
402+
{
403+
return _py2h(PyBytes_FromStringAndSize(v, len));
404+
}
405+
351406
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_FromString)(HPyContext ctx, const char *utf8)
352407
{
353408
return _py2h(PyUnicode_FromString(utf8));
@@ -393,13 +448,3 @@ HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dict_New)(HPyContext ctx)
393448
return _py2h(PyDict_New());
394449
}
395450

396-
HPyAPI_STORAGE int _HPy_IMPL_NAME(Dict_SetItem)(HPyContext ctx, HPy h_dict, HPy h_key, HPy h_val)
397-
{
398-
return PyDict_SetItem(_h2py(h_dict), _h2py(h_key), _h2py(h_val));
399-
}
400-
401-
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dict_GetItem)(HPyContext ctx, HPy h_dict, HPy h_key)
402-
{
403-
return _py2h(PyDict_GetItem(_h2py(h_dict), _h2py(h_key)));
404-
}
405-

graalpython/com.oracle.graal.python.cext/include/common/hpyfunc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ typedef enum {
3434
HPyFunc_INITPROC,
3535
HPyFunc_GETTER,
3636
HPyFunc_SETTER,
37+
HPyFunc_OBJOBJPROC,
3738

3839
} HPyFunc_Signature;
3940

graalpython/com.oracle.graal.python.cext/include/common/hpytype.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ typedef struct {
4545

4646
/* All types are dynamically allocated */
4747
#define _Py_TPFLAGS_HEAPTYPE (1UL << 9)
48+
#define _Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18)
4849

4950
/* Set if the type allows subclassing */
5051
#define HPy_TPFLAGS_BASETYPE (1UL << 10)
5152

52-
#define HPy_TPFLAGS_DEFAULT _Py_TPFLAGS_HEAPTYPE
53+
#define HPy_TPFLAGS_DEFAULT (_Py_TPFLAGS_HEAPTYPE | _Py_TPFLAGS_HAVE_VERSION_TAG)
5354

5455
#define HPy_CAST(ctx, return_type, h) ((return_type *) _HPy_Cast(ctx, h))
5556

graalpython/com.oracle.graal.python.cext/include/common/runtime/argparse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "hpy.h"
55

66
HPyAPI_RUNTIME_FUNC(int)
7-
HPyArg_Parse(HPyContext ctx, HPy *args, HPy_ssize_t nargs, const char *fmt, ...);
7+
HPyArg_Parse(HPyContext ctx, HPyTracker *ht, HPy *args, HPy_ssize_t nargs, const char *fmt, ...);
88

99
HPyAPI_RUNTIME_FUNC(int)
10-
HPyArg_ParseKeywords(HPyContext ctx, HPy *args, HPy_ssize_t nargs, HPy kw,
10+
HPyArg_ParseKeywords(HPyContext ctx, HPyTracker *ht, HPy *args, HPy_ssize_t nargs, HPy kw,
1111
const char *fmt, const char *keywords[], ...);
1212

1313

graalpython/com.oracle.graal.python.cext/include/common/runtime/ctx_tracker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ _HPy_HIDDEN int
1010
ctx_Tracker_Add(HPyContext ctx, HPyTracker ht, HPy h);
1111

1212
_HPy_HIDDEN void
13-
ctx_Tracker_RemoveAll(HPyContext ctx, HPyTracker ht);
13+
ctx_Tracker_ForgetAll(HPyContext ctx, HPyTracker ht);
1414

1515
_HPy_HIDDEN void
16-
ctx_Tracker_Free(HPyContext ctx, HPyTracker ht);
16+
ctx_Tracker_Close(HPyContext ctx, HPyTracker ht);
1717

1818
#endif /* HPY_COMMON_RUNTIME_CTX_TRACKER_H */
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
// automatically generated by setup.py:get_scm_config()
3-
#define HPY_VERSION "0.1.dev618+g2f53dbf"
4-
#define HPY_GIT_REVISION "2f53dbf"
3+
#define HPY_VERSION "0.1.dev875+g7c832a2"
4+
#define HPY_GIT_REVISION "7c832a2"

graalpython/com.oracle.graal.python.cext/include/cpython/autogen_hpyfunc_trampolines.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@
128128
{ \
129129
return (IMPL(_HPyGetContext(), _py2h(arg0), _py2h(arg1), arg2)); \
130130
}
131+
#define _HPyFunc_TRAMPOLINE_HPyFunc_OBJOBJPROC(SYM, IMPL) \
132+
static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \
133+
{ \
134+
return (IMPL(_HPyGetContext(), _py2h(arg0), _py2h(arg1))); \
135+
}

graalpython/com.oracle.graal.python.cext/include/cpython/hpy.h

Lines changed: 139 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,79 @@ typedef Py_hash_t HPy_hash_t;
4343
#define _h2py(x) (x._o)
4444
#define _py2h(o) ((HPy){o})
4545

46+
// this should maybe autogenerated from public_api.h
4647
typedef struct _HPyContext_s {
48+
/* Constants */
4749
HPy h_None;
4850
HPy h_True;
4951
HPy h_False;
50-
HPy h_ValueError;
52+
/* Exceptions */
53+
HPy h_BaseException;
54+
HPy h_Exception;
55+
HPy h_StopAsyncIteration;
56+
HPy h_StopIteration;
57+
HPy h_GeneratorExit;
58+
HPy h_ArithmeticError;
59+
HPy h_LookupError;
60+
HPy h_AssertionError;
61+
HPy h_AttributeError;
62+
HPy h_BufferError;
63+
HPy h_EOFError;
64+
HPy h_FloatingPointError;
65+
HPy h_OSError;
66+
HPy h_ImportError;
67+
HPy h_ModuleNotFoundError;
68+
HPy h_IndexError;
69+
HPy h_KeyError;
70+
HPy h_KeyboardInterrupt;
71+
HPy h_MemoryError;
72+
HPy h_NameError;
73+
HPy h_OverflowError;
74+
HPy h_RuntimeError;
75+
HPy h_RecursionError;
76+
HPy h_NotImplementedError;
77+
HPy h_SyntaxError;
78+
HPy h_IndentationError;
79+
HPy h_TabError;
80+
HPy h_ReferenceError;
81+
HPy h_SystemError;
82+
HPy h_SystemExit;
5183
HPy h_TypeError;
84+
HPy h_UnboundLocalError;
85+
HPy h_UnicodeError;
86+
HPy h_UnicodeEncodeError;
87+
HPy h_UnicodeDecodeError;
88+
HPy h_UnicodeTranslateError;
89+
HPy h_ValueError;
90+
HPy h_ZeroDivisionError;
91+
HPy h_BlockingIOError;
92+
HPy h_BrokenPipeError;
93+
HPy h_ChildProcessError;
94+
HPy h_ConnectionError;
95+
HPy h_ConnectionAbortedError;
96+
HPy h_ConnectionRefusedError;
97+
HPy h_ConnectionResetError;
98+
HPy h_FileExistsError;
99+
HPy h_FileNotFoundError;
100+
HPy h_InterruptedError;
101+
HPy h_IsADirectoryError;
102+
HPy h_NotADirectoryError;
103+
HPy h_PermissionError;
104+
HPy h_ProcessLookupError;
105+
HPy h_TimeoutError;
106+
/* Warnings */
107+
HPy h_Warning;
108+
HPy h_UserWarning;
109+
HPy h_DeprecationWarning;
110+
HPy h_PendingDeprecationWarning;
111+
HPy h_SyntaxWarning;
112+
HPy h_RuntimeWarning;
113+
HPy h_FutureWarning;
114+
HPy h_ImportWarning;
115+
HPy h_UnicodeWarning;
116+
HPy h_BytesWarning;
117+
HPy h_ResourceWarning;
118+
/* Types */
52119
HPy h_BaseObjectType;
53120
HPy h_TypeType;
54121
HPy h_LongType;
@@ -76,11 +143,77 @@ _HPyGetContext(void) {
76143
if (HPy_IsNull(ctx->h_None)) {
77144
// XXX: we need to find a better way to check whether the ctx is
78145
// initialized or not
146+
/* Constants */
79147
ctx->h_None = _py2h(Py_None);
80148
ctx->h_True = _py2h(Py_True);
81149
ctx->h_False = _py2h(Py_False);
82-
ctx->h_ValueError = _py2h(PyExc_ValueError);
150+
/* Exceptions */
151+
ctx->h_BaseException = _py2h(PyExc_BaseException);
152+
ctx->h_Exception = _py2h(PyExc_Exception);
153+
ctx->h_StopAsyncIteration = _py2h(PyExc_StopAsyncIteration);
154+
ctx->h_StopIteration = _py2h(PyExc_StopIteration);
155+
ctx->h_GeneratorExit = _py2h(PyExc_GeneratorExit);
156+
ctx->h_ArithmeticError = _py2h(PyExc_ArithmeticError);
157+
ctx->h_LookupError = _py2h(PyExc_LookupError);
158+
ctx->h_AssertionError = _py2h(PyExc_AssertionError);
159+
ctx->h_AttributeError = _py2h(PyExc_AttributeError);
160+
ctx->h_BufferError = _py2h(PyExc_BufferError);
161+
ctx->h_EOFError = _py2h(PyExc_EOFError);
162+
ctx->h_FloatingPointError = _py2h(PyExc_FloatingPointError);
163+
ctx->h_OSError = _py2h(PyExc_OSError);
164+
ctx->h_ImportError = _py2h(PyExc_ImportError);
165+
ctx->h_ModuleNotFoundError = _py2h(PyExc_ModuleNotFoundError);
166+
ctx->h_IndexError = _py2h(PyExc_IndexError);
167+
ctx->h_KeyError = _py2h(PyExc_KeyError);
168+
ctx->h_KeyboardInterrupt = _py2h(PyExc_KeyboardInterrupt);
169+
ctx->h_MemoryError = _py2h(PyExc_MemoryError);
170+
ctx->h_NameError = _py2h(PyExc_NameError);
171+
ctx->h_OverflowError = _py2h(PyExc_OverflowError);
172+
ctx->h_RuntimeError = _py2h(PyExc_RuntimeError);
173+
ctx->h_RecursionError = _py2h(PyExc_RecursionError);
174+
ctx->h_NotImplementedError = _py2h(PyExc_NotImplementedError);
175+
ctx->h_SyntaxError = _py2h(PyExc_SyntaxError);
176+
ctx->h_IndentationError = _py2h(PyExc_IndentationError);
177+
ctx->h_TabError = _py2h(PyExc_TabError);
178+
ctx->h_ReferenceError = _py2h(PyExc_ReferenceError);
179+
ctx->h_SystemError = _py2h(PyExc_SystemError);
180+
ctx->h_SystemExit = _py2h(PyExc_SystemExit);
83181
ctx->h_TypeError = _py2h(PyExc_TypeError);
182+
ctx->h_UnboundLocalError = _py2h(PyExc_UnboundLocalError);
183+
ctx->h_UnicodeError = _py2h(PyExc_UnicodeError);
184+
ctx->h_UnicodeEncodeError = _py2h(PyExc_UnicodeEncodeError);
185+
ctx->h_UnicodeDecodeError = _py2h(PyExc_UnicodeDecodeError);
186+
ctx->h_UnicodeTranslateError = _py2h(PyExc_UnicodeTranslateError);
187+
ctx->h_ValueError = _py2h(PyExc_ValueError);
188+
ctx->h_ZeroDivisionError = _py2h(PyExc_ZeroDivisionError);
189+
ctx->h_BlockingIOError = _py2h(PyExc_BlockingIOError);
190+
ctx->h_BrokenPipeError = _py2h(PyExc_BrokenPipeError);
191+
ctx->h_ChildProcessError = _py2h(PyExc_ChildProcessError);
192+
ctx->h_ConnectionError = _py2h(PyExc_ConnectionError);
193+
ctx->h_ConnectionAbortedError = _py2h(PyExc_ConnectionAbortedError);
194+
ctx->h_ConnectionRefusedError = _py2h(PyExc_ConnectionRefusedError);
195+
ctx->h_ConnectionResetError = _py2h(PyExc_ConnectionResetError);
196+
ctx->h_FileExistsError = _py2h(PyExc_FileExistsError);
197+
ctx->h_FileNotFoundError = _py2h(PyExc_FileNotFoundError);
198+
ctx->h_InterruptedError = _py2h(PyExc_InterruptedError);
199+
ctx->h_IsADirectoryError = _py2h(PyExc_IsADirectoryError);
200+
ctx->h_NotADirectoryError = _py2h(PyExc_NotADirectoryError);
201+
ctx->h_PermissionError = _py2h(PyExc_PermissionError);
202+
ctx->h_ProcessLookupError = _py2h(PyExc_ProcessLookupError);
203+
ctx->h_TimeoutError = _py2h(PyExc_TimeoutError);
204+
/* Warnings */
205+
ctx->h_Warning = _py2h(PyExc_Warning);
206+
ctx->h_UserWarning = _py2h(PyExc_UserWarning);
207+
ctx->h_DeprecationWarning = _py2h(PyExc_DeprecationWarning);
208+
ctx->h_PendingDeprecationWarning = _py2h(PyExc_PendingDeprecationWarning);
209+
ctx->h_SyntaxWarning = _py2h(PyExc_SyntaxWarning);
210+
ctx->h_RuntimeWarning = _py2h(PyExc_RuntimeWarning);
211+
ctx->h_FutureWarning = _py2h(PyExc_FutureWarning);
212+
ctx->h_ImportWarning = _py2h(PyExc_ImportWarning);
213+
ctx->h_UnicodeWarning = _py2h(PyExc_UnicodeWarning);
214+
ctx->h_BytesWarning = _py2h(PyExc_BytesWarning);
215+
ctx->h_ResourceWarning = _py2h(PyExc_ResourceWarning);
216+
/* Types */
84217
ctx->h_BaseObjectType = _py2h((PyObject *)&PyBaseObject_Type);
85218
ctx->h_TypeType = _py2h((PyObject *)&PyType_Type);
86219
ctx->h_LongType = _py2h((PyObject *)&PyLong_Type);
@@ -251,15 +384,15 @@ HPyTracker_Add(HPyContext ctx, HPyTracker ht, HPy h)
251384
}
252385

253386
HPyAPI_FUNC(void)
254-
HPyTracker_RemoveAll(HPyContext ctx, HPyTracker ht)
387+
HPyTracker_ForgetAll(HPyContext ctx, HPyTracker ht)
255388
{
256-
ctx_Tracker_RemoveAll(ctx, ht);
389+
ctx_Tracker_ForgetAll(ctx, ht);
257390
}
258391

259392
HPyAPI_FUNC(void)
260-
HPyTracker_Free(HPyContext ctx, HPyTracker ht)
393+
HPyTracker_Close(HPyContext ctx, HPyTracker ht)
261394
{
262-
ctx_Tracker_Free(ctx, ht);
395+
ctx_Tracker_Close(ctx, ht);
263396
}
264397

265398
#endif /* !HPy_CPYTHON_H */

0 commit comments

Comments
 (0)
0