Skip to content

Commit bdacc49

Browse files
committed
[GR-31206] Update HPy import.
PullRequest: graalpython/1802
2 parents 8876d8f + cce889c commit bdacc49

File tree

78 files changed

+4032
-1120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4032
-1120
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "678366cf6c0b054e751248aec4d939526f029a21" }
1+
{ "overlay": "3c6f644a6a6c7d27bae5b0d82445818549a83175" }

graalpython/com.oracle.graal.python.cext/hpy/hpy.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#define UNWRAP(_h) ((_h)._i)
4949
#define WRAP(_ptr) ((HPy){(_ptr)})
5050

51-
5251
typedef HPyDef* HPyDefPtr;
5352

5453
POLYGLOT_DECLARE_TYPE(HPy);
@@ -91,6 +90,10 @@ void* graal_hpy_calloc(size_t count, size_t eltsize) {
9190
return calloc(count, eltsize);
9291
}
9392

93+
void graal_hpy_free(void *ptr) {
94+
free(ptr);
95+
}
96+
9497
void* graal_hpy_from_HPy_array(void *arr, uint64_t len) {
9598
return polyglot_from_HPy_array(arr, len);
9699
}
@@ -571,3 +574,9 @@ int graal_hpy_bulk_free(void* ptrArray[], int64_t len) {
571574
}
572575
return 0;
573576
}
577+
578+
POLYGLOT_DECLARE_TYPE(HPy_buffer);
579+
HPy_buffer *graal_hpy_allocate_buffer() {
580+
return polyglot_from_HPy_buffer((HPy_buffer *) malloc(sizeof(HPy_buffer)));
581+
}
582+

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
#define _HPyFunc_DECLARE_HPyFunc_GETTER(SYM) static HPy SYM(HPyContext ctx, HPy, void *)
6464
#define _HPyFunc_DECLARE_HPyFunc_SETTER(SYM) static int SYM(HPyContext ctx, HPy, HPy, void *)
6565
#define _HPyFunc_DECLARE_HPyFunc_OBJOBJPROC(SYM) static int SYM(HPyContext ctx, HPy, HPy)
66+
#define _HPyFunc_DECLARE_HPyFunc_GETBUFFERPROC(SYM) static int SYM(HPyContext, HPy, HPy_buffer *, int)
67+
#define _HPyFunc_DECLARE_HPyFunc_RELEASEBUFFERPROC(SYM) static void SYM(HPyContext, HPy, HPy_buffer *)
6668
#define _HPyFunc_DECLARE_HPyFunc_DESTROYFUNC(SYM) static void SYM(void *)
6769

6870
typedef HPy (*HPyFunc_noargs)(HPyContext ctx, HPy self);
@@ -95,4 +97,6 @@ typedef int (*HPyFunc_initproc)(HPyContext ctx, HPy self, HPy *args, HPy_ssize_t
9597
typedef HPy (*HPyFunc_getter)(HPyContext ctx, HPy, void *);
9698
typedef int (*HPyFunc_setter)(HPyContext ctx, HPy, HPy, void *);
9799
typedef int (*HPyFunc_objobjproc)(HPyContext ctx, HPy, HPy);
100+
typedef int (*HPyFunc_getbufferproc)(HPyContext, HPy, HPy_buffer *, int);
101+
typedef void (*HPyFunc_releasebufferproc)(HPyContext, HPy, HPy_buffer *);
98102
typedef void (*HPyFunc_destroyfunc)(void *);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
*/
3535

3636
typedef enum {
37+
HPy_bf_getbuffer = 1,
38+
HPy_bf_releasebuffer = 2,
3739
HPy_nb_absolute = 6,
3840
HPy_nb_add = 7,
3941
HPy_nb_and = 8,
@@ -84,6 +86,8 @@ typedef enum {
8486
HPy_tp_destroy = 1000,
8587
} HPySlot_Slot;
8688

89+
#define _HPySlot_SIG__HPy_bf_getbuffer HPyFunc_GETBUFFERPROC
90+
#define _HPySlot_SIG__HPy_bf_releasebuffer HPyFunc_RELEASEBUFFERPROC
8791
#define _HPySlot_SIG__HPy_nb_absolute HPyFunc_UNARYFUNC
8892
#define _HPySlot_SIG__HPy_nb_add HPyFunc_BINARYFUNC
8993
#define _HPySlot_SIG__HPy_nb_and HPyFunc_BINARYFUNC

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ HPyAPI_STORAGE double _HPy_IMPL_NAME(Float_AsDouble)(HPyContext ctx, HPy h)
113113
return PyFloat_AsDouble(_h2py(h));
114114
}
115115

116+
HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Bool_FromLong)(HPyContext ctx, long v)
117+
{
118+
return _py2h(PyBool_FromLong(v));
119+
}
120+
116121
HPyAPI_STORAGE HPy_ssize_t _HPy_IMPL_NAME_NOPREFIX(Length)(HPyContext ctx, HPy h)
117122
{
118123
return PyObject_Length(_h2py(h));
@@ -363,6 +368,11 @@ HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(SetItem)(HPyContext ctx, HPy obj, HPy
363368
return PyObject_SetItem(_h2py(obj), _h2py(key), _h2py(value));
364369
}
365370

371+
HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Type)(HPyContext ctx, HPy obj)
372+
{
373+
return _py2h(PyObject_Type(_h2py(obj)));
374+
}
375+
366376
HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Repr)(HPyContext ctx, HPy obj)
367377
{
368378
return _py2h(PyObject_Repr(_h2py(obj)));

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ typedef struct PyMethodDef cpy_PyMethodDef;
3838
typedef PyType_Slot cpy_PyTypeSlot;
3939
typedef PyGetSetDef cpy_PyGetSetDef;
4040
typedef PyMemberDef cpy_PyMemberDef;
41+
typedef struct bufferinfo cpy_Py_buffer;
4142

4243

4344
#endif /* HPY_UNIVERSAL_CPY_TYPES_H */

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ typedef enum {
3333

3434
HPyFunc_DESTROYFUNC,
3535

36+
HPyFunc_GETBUFFERPROC,
37+
HPyFunc_RELEASEBUFFERPROC,
3638
HPyFunc_UNARYFUNC,
3739
HPyFunc_BINARYFUNC,
3840
HPyFunc_TERNARYFUNC,
@@ -94,6 +96,19 @@ typedef enum {
9496
enum { SYM##_sig = SIG }; \
9597
_HPyFunc_TRAMPOLINE_##SIG(SYM, IMPL)
9698

99+
typedef struct {
100+
void *buf;
101+
HPy obj; /* owned reference */
102+
HPy_ssize_t len;
103+
HPy_ssize_t itemsize;
104+
int readonly;
105+
int ndim;
106+
char *format;
107+
HPy_ssize_t *shape;
108+
HPy_ssize_t *strides;
109+
HPy_ssize_t *suboffsets;
110+
void *internal;
111+
} HPy_buffer;
97112

98113
#include "autogen_hpyfunc_declare.h"
99114

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ typedef struct {
5353
unsigned int flags;
5454
void *legacy_slots; // PyType_Slot *
5555
HPyDef **defines; /* points to an array of 'HPyDef *' */
56+
const char* doc; /* UTF-8 doc string or NULL */
5657
} HPyType_Spec;
5758

5859
typedef enum {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
#include "hpy.h"
3030

3131
_HPy_HIDDEN void ctx_Dump(HPyContext ctx, HPy h);
32+
_HPy_HIDDEN int ctx_TypeCheck(HPyContext ctx, HPy h_obj, HPy h_type);
3233

3334
#endif /* HPY_COMMON_RUNTIME_CTX_OBJECT_H */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
*/
2424

2525
// automatically generated by setup.py:get_scm_config()
26-
#define HPY_VERSION "0.1.dev965+g6d3b941"
27-
#define HPY_GIT_REVISION "6d3b941"
26+
#define HPY_VERSION "0.0.2.dev144+ng1d5d4c5"
27+
#define HPY_GIT_REVISION "1d5d4c5"

0 commit comments

Comments
 (0)