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
ad037f74
Commit
ad037f74
authored
Aug 02, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up C comments in CyFunction/Generator utility code files to avoid writing them out
parent
aefd0a70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
61 deletions
+70
-61
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+34
-28
Cython/Utility/Generator.c
Cython/Utility/Generator.c
+36
-33
No files found.
Cython/Utility/CythonFunction.c
View file @
ad037f74
...
...
@@ -29,14 +29,15 @@ typedef struct {
PyObject
*
func_globals
;
PyObject
*
func_code
;
PyObject
*
func_closure
;
PyObject
*
func_classobj
;
/* No-args super() class cell */
// No-args super() class cell
PyObject
*
func_classobj
;
/
* Dynamic default args and annotations */
/
/ Dynamic default args and annotations
void
*
defaults
;
int
defaults_pyobjects
;
int
flags
;
/
* Defaults info */
/
/ Defaults info
PyObject
*
defaults_tuple
;
/* Const defaults tuple */
PyObject
*
defaults_kwdict
;
/* Const kwonly defaults dict */
PyObject
*
(
*
defaults_getter
)(
PyObject
*
);
...
...
@@ -97,8 +98,10 @@ static int
__Pyx_CyFunction_set_doc
(
__pyx_CyFunctionObject
*
op
,
PyObject
*
value
)
{
PyObject
*
tmp
=
op
->
func_doc
;
if
(
value
==
NULL
)
value
=
Py_None
;
/* Mark as deleted */
if
(
value
==
NULL
)
{
// Mark as deleted
value
=
Py_None
;
}
Py_INCREF
(
value
);
op
->
func_doc
=
value
;
Py_XDECREF
(
tmp
);
...
...
@@ -244,7 +247,7 @@ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
if
(
unlikely
(
!
res
))
return
-
1
;
/
* Cache result */
/
/ Cache result
op
->
defaults_tuple
=
PyTuple_GET_ITEM
(
res
,
0
);
Py_INCREF
(
op
->
defaults_tuple
);
op
->
defaults_kwdict
=
PyTuple_GET_ITEM
(
res
,
1
);
...
...
@@ -446,7 +449,7 @@ static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int f
Py_INCREF
(
op
->
func_globals
);
Py_XINCREF
(
code
);
op
->
func_code
=
code
;
/
* Dynamic Default args */
/
/ Dynamic Default args
op
->
defaults_pyobjects
=
0
;
op
->
defaults
=
NULL
;
op
->
defaults_tuple
=
NULL
;
...
...
@@ -555,8 +558,8 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
}
#if CYTHON_COMPILING_IN_PYPY
/
* originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c */
/
* PyPy does not have this function */
/
/ originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c
/
/ PyPy does not have this function
static
PyObject
*
__Pyx_CyFunction_Call
(
PyObject
*
func
,
PyObject
*
arg
,
PyObject
*
kw
)
{
PyCFunctionObject
*
f
=
(
PyCFunctionObject
*
)
func
;
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
...
...
@@ -633,12 +636,12 @@ static PyTypeObject __pyx_CyFunctionType_type = {
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
0
,
/*tp_as_buffer*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/*
tp_flags*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/*tp_flags*/
0
,
/*tp_doc*/
(
traverseproc
)
__Pyx_CyFunction_traverse
,
/*tp_traverse*/
(
inquiry
)
__Pyx_CyFunction_clear
,
/*tp_clear*/
0
,
/*tp_richcompare*/
offsetof
(
__pyx_CyFunctionObject
,
func_weakreflist
),
/*
tp_weaklistoffset
*/
offsetof
(
__pyx_CyFunctionObject
,
func_weakreflist
),
/*
tp_weaklistoffset
*/
0
,
/*tp_iter*/
0
,
/*tp_iternext*/
__pyx_CyFunction_methods
,
/*tp_methods*/
...
...
@@ -803,7 +806,7 @@ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
func
=
(
__pyx_FusedFunctionObject
*
)
self
;
if
(
func
->
self
||
func
->
func
.
flags
&
__Pyx_CYFUNCTION_STATICMETHOD
)
{
/
* Do not allow rebinding and don't do anything for static methods */
/
/ Do not allow rebinding and don't do anything for static methods
Py_INCREF
(
self
);
return
self
;
}
...
...
@@ -904,7 +907,7 @@ __pyx_err:
if
(
self
->
self
||
self
->
type
)
{
__pyx_FusedFunctionObject
*
unbound
=
(
__pyx_FusedFunctionObject
*
)
unbound_result_func
;
/
* Todo: move this to InitClassCell */
/
/ TODO: move this to InitClassCell
Py_CLEAR
(
unbound
->
func
.
func_classobj
);
Py_XINCREF
(
self
->
func
.
func_classobj
);
unbound
->
func
.
func_classobj
=
self
->
func
.
func_classobj
;
...
...
@@ -961,12 +964,12 @@ __pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
return
result
;
}
/
*
Note: the 'self' from method binding is passed in in the args tuple,
whereas PyCFunctionObject's m_self is passed in as the first
argument to the C function. For extension methods we need
to pass 'self' as 'm_self' and not as the first element of the
args tuple.
*/
/
/
Note: the 'self' from method binding is passed in in the args tuple,
//
whereas PyCFunctionObject's m_self is passed in as the first
//
argument to the C function. For extension methods we need
//
to pass 'self' as 'm_self' and not as the first element of the
//
args tuple.
static
PyObject
*
__pyx_FusedFunction_call
(
PyObject
*
func
,
PyObject
*
args
,
PyObject
*
kw
)
{
...
...
@@ -980,7 +983,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
int
is_classmethod
=
binding_func
->
func
.
flags
&
__Pyx_CYFUNCTION_CLASSMETHOD
;
if
(
binding_func
->
self
)
{
/
* Bound method call, put 'self' in the args tuple */
/
/ Bound method call, put 'self' in the args tuple
Py_ssize_t
i
;
new_args
=
PyTuple_New
(
argc
+
1
);
if
(
!
new_args
)
...
...
@@ -998,7 +1001,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
args
=
new_args
;
}
else
if
(
binding_func
->
type
)
{
/
* Unbound method call */
/
/ Unbound method call
if
(
argc
<
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Need at least one argument, 0 given."
);
return
NULL
;
...
...
@@ -1081,7 +1084,7 @@ static PyTypeObject __pyx_FusedFunctionType_type = {
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
0
,
/*tp_as_buffer*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/*
tp_flags*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/*tp_flags*/
0
,
/*tp_doc*/
(
traverseproc
)
__pyx_FusedFunction_traverse
,
/*tp_traverse*/
(
inquiry
)
__pyx_FusedFunction_clear
,
/*tp_clear*/
...
...
@@ -1091,8 +1094,8 @@ static PyTypeObject __pyx_FusedFunctionType_type = {
0
,
/*tp_iternext*/
0
,
/*tp_methods*/
__pyx_FusedFunction_members
,
/*tp_members*/
/
* __doc__ is None for the fused function type, but we need it to be */
/
* a descriptor for the instance's __doc__, so rebuild descriptors in our subclass */
/
/ __doc__ is None for the fused function type, but we need it to be
/
/ a descriptor for the instance's __doc__, so rebuild descriptors in our subclass
__pyx_CyFunction_getsets
,
/*tp_getset*/
&
__pyx_CyFunctionType_type
,
/*tp_base*/
0
,
/*tp_dict*/
...
...
@@ -1133,11 +1136,12 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
static
PyObject
*
__Pyx_Method_ClassMethod
(
PyObject
*
method
)
{
#if CYTHON_COMPILING_IN_PYPY
if
(
PyObject_TypeCheck
(
method
,
&
PyWrapperDescr_Type
))
{
/* cdef classes */
if
(
PyObject_TypeCheck
(
method
,
&
PyWrapperDescr_Type
))
{
// cdef classes
return
PyClassMethod_New
(
method
);
}
#else
/
* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
/
/ It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API
static
PyTypeObject
*
methoddescr_type
=
NULL
;
if
(
methoddescr_type
==
NULL
)
{
PyObject
*
meth
=
__Pyx_GetAttrString
((
PyObject
*
)
&
PyList_Type
,
"append"
);
...
...
@@ -1145,7 +1149,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
methoddescr_type
=
Py_TYPE
(
meth
);
Py_DECREF
(
meth
);
}
if
(
PyObject_TypeCheck
(
method
,
methoddescr_type
))
{
/* cdef classes */
if
(
PyObject_TypeCheck
(
method
,
methoddescr_type
))
{
// cdef classes
PyMethodDescrObject
*
descr
=
(
PyMethodDescrObject
*
)
method
;
#if PY_VERSION_HEX < 0x03020000
PyTypeObject
*
d_type
=
descr
->
d_type
;
...
...
@@ -1155,7 +1160,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
return
PyDescr_NewClassMethod
(
d_type
,
descr
->
d_method
);
}
#endif
else
if
(
PyMethod_Check
(
method
))
{
/* python classes */
else
if
(
PyMethod_Check
(
method
))
{
// python classes
return
PyClassMethod_New
(
PyMethod_GET_FUNCTION
(
method
));
}
else
if
(
PyCFunction_Check
(
method
))
{
...
...
Cython/Utility/Generator.c
View file @
ad037f74
...
...
@@ -10,7 +10,7 @@ static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_GeneratorObject
source_gen
=
PyObject_GetIter
(
source
);
if
(
unlikely
(
!
source_gen
))
return
NULL
;
/
* source_gen is now the iterator, make the first next() call */
/
/ source_gen is now the iterator, make the first next() call
retval
=
Py_TYPE
(
source_gen
)
->
tp_iternext
(
source_gen
);
if
(
likely
(
retval
))
{
gen
->
yieldfrom
=
source_gen
;
...
...
@@ -196,8 +196,8 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
#if CYTHON_COMPILING_IN_PYPY
// FIXME: what to do in PyPy?
#else
/
*
Generators always return to their most recent caller, not
* necessarily their creator. */
/
/
Generators always return to their most recent caller, not
// necessarily their creator.
if
(
self
->
exc_traceback
)
{
PyThreadState
*
tstate
=
PyThreadState_GET
();
PyTracebackObject
*
tb
=
(
PyTracebackObject
*
)
self
->
exc_traceback
;
...
...
@@ -224,9 +224,9 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
#if CYTHON_COMPILING_IN_PYPY
// FIXME: what to do in PyPy?
#else
/
*
Don't keep the reference to f_back any longer than necessary. It
*
may keep a chain of frames alive or it could create a reference
* cycle. */
/
/
Don't keep the reference to f_back any longer than necessary. It
//
may keep a chain of frames alive or it could create a reference
// cycle.
if
(
self
->
exc_traceback
)
{
PyTracebackObject
*
tb
=
(
PyTracebackObject
*
)
self
->
exc_traceback
;
PyFrameObject
*
f
=
tb
->
tb_frame
;
...
...
@@ -261,7 +261,7 @@ static PyObject *__Pyx_Generator_Next(PyObject *self) {
PyObject
*
ret
;
// FIXME: does this really need an INCREF() ?
//Py_INCREF(yf);
/
* YieldFrom code ensures that yf is an iterator */
/
/ YieldFrom code ensures that yf is an iterator
gen
->
is_running
=
1
;
ret
=
Py_TYPE
(
yf
)
->
tp_iternext
(
yf
);
gen
->
is_running
=
0
;
...
...
@@ -364,7 +364,8 @@ static PyObject *__Pyx_Generator_Close(PyObject *self) {
||
PyErr_GivenExceptionMatches
(
raised_exception
,
PyExc_GeneratorExit
)
||
PyErr_GivenExceptionMatches
(
raised_exception
,
PyExc_StopIteration
))
{
if
(
raised_exception
)
PyErr_Clear
();
/* ignore these errors */
// ignore these errors
if
(
raised_exception
)
PyErr_Clear
();
Py_INCREF
(
Py_None
);
return
Py_None
;
}
...
...
@@ -460,7 +461,7 @@ static void __Pyx_Generator_dealloc(PyObject *self) {
PyObject_ClearWeakRefs
(
self
);
if
(
gen
->
resume_label
>
0
)
{
/
* Generator is paused, so we need to close */
/
/ Generator is paused, so we need to close
PyObject_GC_Track
(
self
);
#if PY_VERSION_HEX >= 0x030400a1
if
(
PyObject_CallFinalizerFromDealloc
(
self
))
...
...
@@ -468,7 +469,10 @@ static void __Pyx_Generator_dealloc(PyObject *self) {
Py_TYPE
(
gen
)
->
tp_del
(
self
);
if
(
self
->
ob_refcnt
>
0
)
#endif
return
;
/* resurrected. :( */
{
// resurrected. :(
return
;
}
PyObject_GC_UnTrack
(
self
);
}
...
...
@@ -485,12 +489,12 @@ static void __Pyx_Generator_del(PyObject *self) {
return
;
#if PY_VERSION_HEX < 0x030400a1
/
* Temporarily resurrect the object. */
/
/ Temporarily resurrect the object.
assert
(
self
->
ob_refcnt
==
0
);
self
->
ob_refcnt
=
1
;
#endif
/
* Save the current exception, if any. */
/
/ Save the current exception, if any.
__Pyx_ErrFetch
(
&
error_type
,
&
error_value
,
&
error_traceback
);
res
=
__Pyx_Generator_Close
(
self
);
...
...
@@ -500,20 +504,20 @@ static void __Pyx_Generator_del(PyObject *self) {
else
Py_DECREF
(
res
);
/
* Restore the saved exception. */
/
/ Restore the saved exception.
__Pyx_ErrRestore
(
error_type
,
error_value
,
error_traceback
);
#if PY_VERSION_HEX < 0x030400a1
/* Undo the temporary resurrection; can't use DECREF here, it would
* cause a recursive call.
*/
// Undo the temporary resurrection; can't use DECREF here, it would
// cause a recursive call.
assert
(
self
->
ob_refcnt
>
0
);
if
(
--
self
->
ob_refcnt
==
0
)
return
;
/* this is the normal path out */
if
(
--
self
->
ob_refcnt
==
0
)
{
// this is the normal path out
return
;
}
/* close() resurrected it! Make it look like the original Py_DECREF
* never happened.
*/
// close() resurrected it! Make it look like the original Py_DECREF
// never happened.
{
Py_ssize_t
refcnt
=
self
->
ob_refcnt
;
_Py_NewReference
(
self
);
...
...
@@ -523,16 +527,15 @@ static void __Pyx_Generator_del(PyObject *self) {
assert
(
PyType_IS_GC
(
self
->
ob_type
)
&&
_Py_AS_GC
(
self
)
->
gc
.
gc_refs
!=
_PyGC_REFS_UNTRACKED
);
/
*
If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
/
/
If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
// we need to undo that.
_Py_DEC_REFTOTAL
;
#endif
/* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
* chain, so no more to do there.
* If COUNT_ALLOCS, the original decref bumped tp_frees, and
* _Py_NewReference bumped tp_allocs: both of those need to be
* undone.
*/
// If Py_TRACE_REFS, _Py_NewReference re-added self to the object
// chain, so no more to do there.
// If COUNT_ALLOCS, the original decref bumped tp_frees, and
// _Py_NewReference bumped tp_allocs: both of those need to be
// undone.
#ifdef COUNT_ALLOCS
--
Py_TYPE
(
self
)
->
tp_frees
;
--
Py_TYPE
(
self
)
->
tp_allocs
;
...
...
@@ -630,7 +633,7 @@ static PyTypeObject __pyx_GeneratorType_type = {
#else
0
,
/*reserved*/
#endif
0
,
/*tp_repr*/
0
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
...
...
@@ -640,12 +643,12 @@ static PyTypeObject __pyx_GeneratorType_type = {
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
0
,
/*tp_as_buffer*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_HAVE_FINALIZE
,
/*
tp_flags*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_HAVE_FINALIZE
,
/*tp_flags*/
0
,
/*tp_doc*/
(
traverseproc
)
__Pyx_Generator_traverse
,
/*tp_traverse*/
0
,
/*tp_clear*/
0
,
/*tp_richcompare*/
offsetof
(
__pyx_GeneratorObject
,
gi_weakreflist
),
/*
tp_weaklistoffset
*/
offsetof
(
__pyx_GeneratorObject
,
gi_weakreflist
),
/*
tp_weaklistoffset
*/
0
,
/*tp_iter*/
(
iternextfunc
)
__Pyx_Generator_Next
,
/*tp_iternext*/
__pyx_Generator_methods
,
/*tp_methods*/
...
...
@@ -706,7 +709,7 @@ static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
}
static
int
__pyx_Generator_init
(
void
)
{
/
* on Windows, C-API functions can't be used in slots statically */
/
/ on Windows, C-API functions can't be used in slots statically
__pyx_GeneratorType_type
.
tp_getattro
=
PyObject_GenericGetAttr
;
__pyx_GeneratorType_type
.
tp_iter
=
PyObject_SelfIter
;
...
...
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