Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
fc08e13d
Commit
fc08e13d
authored
Jan 10, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move set compatibility helpers into Builtins.c
parent
ddaffbe7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
46 deletions
+46
-46
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+1
-46
Cython/Utility/Builtins.c
Cython/Utility/Builtins.c
+45
-0
No files found.
Cython/Compiler/Builtin.py
View file @
fc08e13d
...
...
@@ -18,52 +18,7 @@ pyexec_utility_code = UtilityCode.load("PyExec", "Builtins.c")
pyexec_globals_utility_code
=
UtilityCode
.
load
(
"PyExecGlobals"
,
"Builtins.c"
)
globals_utility_code
=
UtilityCode
.
load
(
"Globals"
,
"Builtins.c"
)
py_set_utility_code
=
UtilityCode
(
proto
=
"""
#if PY_VERSION_HEX < 0x02050000
#ifndef PyAnySet_CheckExact
#define PyAnySet_CheckExact(ob)
\
\
((ob)->ob_type == &PySet_Type ||
\
\
(ob)->ob_type == &PyFrozenSet_Type)
#define PySet_New(iterable)
\
\
PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
#define Pyx_PyFrozenSet_New(iterable)
\
\
PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
#define PySet_Size(anyset)
\
\
PyObject_Size((anyset))
#define PySet_Contains(anyset, key)
\
\
PySequence_Contains((anyset), (key))
#define PySet_Pop(set)
\
\
PyObject_CallMethod(set, (char *)"pop", NULL)
static CYTHON_INLINE int PySet_Clear(PyObject *set) {
PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL);
if (!ret) return -1;
Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key);
if (!ret) return -1;
Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key);
if (!ret) return -1;
Py_DECREF(ret); return 0;
}
#endif /* PyAnySet_CheckExact (<= Py2.4) */
#endif /* < Py2.5 */
"""
,
)
py_set_utility_code
=
UtilityCode
.
load
(
"pyset_compat"
,
"Builtins.c"
)
builtin_utility_code
=
{
'set'
:
py_set_utility_code
,
...
...
Cython/Utility/Builtins.c
View file @
fc08e13d
...
...
@@ -369,3 +369,48 @@ static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d); /*proto*/
static
CYTHON_INLINE
PyObject
*
__Pyx_PyDict_ViewItems
(
PyObject
*
d
)
{
return
__Pyx_PyObject_CallMethod0
(
d
,
(
PY_MAJOR_VERSION
>=
3
)
?
PYIDENT
(
"items"
)
:
PYIDENT
(
"viewitems"
));
}
//////////////////// pyset_compat.proto ////////////////////
#if PY_VERSION_HEX < 0x02050000
#ifndef PyAnySet_CheckExact
#define PyAnySet_CheckExact(ob) \
((ob)->ob_type == &PySet_Type || \
(ob)->ob_type == &PyFrozenSet_Type)
#define PySet_New(iterable) \
PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
#define Pyx_PyFrozenSet_New(iterable) \
PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
#define PySet_Size(anyset) \
PyObject_Size((anyset))
#define PySet_Contains(anyset, key) \
PySequence_Contains((anyset), (key))
#define PySet_Pop(set) \
PyObject_CallMethod((set), (char*)"pop", NULL)
static
CYTHON_INLINE
int
PySet_Clear
(
PyObject
*
set
)
{
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"clear"
,
NULL
);
if
(
!
ret
)
return
-
1
;
Py_DECREF
(
ret
);
return
0
;
}
static
CYTHON_INLINE
int
PySet_Discard
(
PyObject
*
set
,
PyObject
*
key
)
{
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"discard"
,
(
char
*
)
"O"
,
key
);
if
(
!
ret
)
return
-
1
;
Py_DECREF
(
ret
);
return
0
;
}
static
CYTHON_INLINE
int
PySet_Add
(
PyObject
*
set
,
PyObject
*
key
)
{
PyObject
*
ret
=
PyObject_CallMethod
(
set
,
(
char
*
)
"add"
,
(
char
*
)
"O"
,
key
);
if
(
!
ret
)
return
-
1
;
Py_DECREF
(
ret
);
return
0
;
}
#endif
/* PyAnySet_CheckExact (<= Py2.4) */
#endif
/* < Py2.5 */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment