File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
com.oracle.graal.python.cext/src Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ POLYGLOT_DECLARE_TYPE(PyBytesObject);
74
74
POLYGLOT_DECLARE_STRUCT (_longobject );
75
75
POLYGLOT_DECLARE_TYPE (PyCapsule );
76
76
POLYGLOT_DECLARE_TYPE (PyMemoryViewObject );
77
+ POLYGLOT_DECLARE_TYPE (PySetObject );
77
78
78
79
79
80
extern void * to_java (PyObject * obj );
Original file line number Diff line number Diff line change 40
40
41
41
PyTypeObject PySet_Type = PY_TRUFFLE_TYPE ("set" , & PyType_Type , Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC );
42
42
PyTypeObject PyFrozenSet_Type = PY_TRUFFLE_TYPE ("frozenset" , & PyType_Type , Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC );
43
+
44
+ PyObject * PySet_New (PyObject * iterable ) {
45
+ void * result = polyglot_invoke (PY_TRUFFLE_CEXT , "PySet_New" , to_java (iterable ));
46
+ if (result == ERROR_MARKER ) {
47
+ return NULL ;
48
+ }
49
+ return to_sulong (result );
50
+ }
51
+
52
+ PyObject * PyFrozenSet_New (PyObject * iterable ) {
53
+ void * result = polyglot_invoke (PY_TRUFFLE_CEXT , "PyFrozenSet_New" , to_java (iterable ));
54
+ if (result == ERROR_MARKER ) {
55
+ return NULL ;
56
+ }
57
+ return to_sulong (result );
58
+ }
Original file line number Diff line number Diff line change @@ -152,6 +152,25 @@ def PyDict_DelItem(dictObj, key):
152
152
return 0
153
153
154
154
155
+ ##################### SET, FROZENSET
156
+
157
+
158
+ @may_raise
159
+ def PySet_New (iterable ):
160
+ if iterable :
161
+ return set (iterable )
162
+ else :
163
+ return set ()
164
+
165
+
166
+ @may_raise
167
+ def PyFrozenSet_New (iterable ):
168
+ if iterable :
169
+ return frozenset (iterable )
170
+ else :
171
+ return frozenset ()
172
+
173
+
155
174
##################### MAPPINGPROXY
156
175
157
176
You can’t perform that action at this time.
0 commit comments