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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
f63ff29c
Commit
f63ff29c
authored
Apr 17, 2019
by
Stefan Behnel
Committed by
GitHub
Apr 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2826 from jdemeyer/cpython_declarations
Add various declarations for the CPython C API
parents
1a1087bd
007ac7ba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
6 deletions
+90
-6
Cython/Includes/cpython/descr.pxd
Cython/Includes/cpython/descr.pxd
+26
-0
Cython/Includes/cpython/dict.pxd
Cython/Includes/cpython/dict.pxd
+21
-0
Cython/Includes/cpython/module.pxd
Cython/Includes/cpython/module.pxd
+25
-6
Cython/Includes/cpython/object.pxd
Cython/Includes/cpython/object.pxd
+5
-0
Cython/Includes/cpython/pyport.pxd
Cython/Includes/cpython/pyport.pxd
+8
-0
Cython/Includes/cpython/type.pxd
Cython/Includes/cpython/type.pxd
+5
-0
No files found.
Cython/Includes/cpython/descr.pxd
0 → 100644
View file @
f63ff29c
from
.object
cimport
PyObject
,
PyTypeObject
cdef
extern
from
"Python.h"
:
ctypedef
object
(
*
wrapperfunc
)(
self
,
args
,
void
*
wrapped
)
ctypedef
object
(
*
wrapperfunc_kwds
)(
self
,
args
,
void
*
wrapped
,
kwds
)
struct
wrapperbase
:
char
*
name
int
offset
void
*
function
wrapperfunc
wrapper
char
*
doc
int
flags
PyObject
*
name_strobj
int
PyWrapperFlag_KEYWORDS
ctypedef
class
__builtin__
.
wrapper_descriptor
[
object
PyWrapperDescrObject
]:
cdef
type
d_type
cdef
d_name
cdef
wrapperbase
*
d_base
cdef
void
*
d_wrapped
PyDescr_NewWrapper
(
PyTypeObject
*
cls
,
wrapperbase
*
wrapper
,
void
*
wrapped
)
int
PyDescr_IsData
(
descr
)
Cython/Includes/cpython/dict.pxd
View file @
f63ff29c
from
.object
cimport
PyObject
from
.pyport
cimport
uint64_t
cdef
extern
from
"Python.h"
:
# On Python 2, PyDict_GetItemWithError is called _PyDict_GetItemWithError
"""
#if PY_MAJOR_VERSION <= 2
#define PyDict_GetItemWithError _PyDict_GetItemWithError
#endif
"""
############################################################################
# 7.4.1 Dictionary Objects
...
...
@@ -72,11 +79,25 @@ cdef extern from "Python.h":
# NULL if the key key is not present, but without setting an
# exception.
PyObject
*
PyDict_GetItemWithError
(
object
p
,
object
key
)
except
?
NULL
# Return value: Borrowed reference.
# Variant of PyDict_GetItem() that does not suppress exceptions. Return
# NULL with an exception set if an exception occurred. Return NULL
# without an exception set if the key wasn’t present.
PyObject
*
PyDict_GetItemString
(
object
p
,
const
char
*
key
)
# Return value: Borrowed reference.
# This is the same as PyDict_GetItem(), but key is specified as a
# char*, rather than a PyObject*.
PyObject
*
PyDict_SetDefault
(
object
p
,
object
key
,
object
default
)
except
NULL
# Return value: Borrowed reference.
# This is the same as the Python-level dict.setdefault(). If present, it
# returns the value corresponding to key from the dictionary p. If the key
# is not in the dict, it is inserted with value defaultobj and defaultobj
# is returned. This function evaluates the hash function of key only once,
# instead of evaluating it independently for the lookup and the insertion.
list
PyDict_Items
(
object
p
)
# Return value: New reference.
# Return a PyListObject containing all the items from the
...
...
Cython/Includes/cpython/module.pxd
View file @
f63ff29c
...
...
@@ -145,6 +145,12 @@ cdef extern from "Python.h":
bint
PyModule_CheckExact
(
object
p
)
# Return true if p is a module object, but not a subtype of PyModule_Type.
object
PyModule_NewObject
(
object
name
)
# Return a new module object with the __name__ attribute set to name.
# The module’s __name__, __doc__, __package__, and __loader__
# attributes are filled in (all but __name__ are set to None); the caller
# is responsible for providing a __file__ attribute.
object
PyModule_New
(
const
char
*
name
)
# Return value: New reference.
# Return a new module object with the __name__ attribute set to
...
...
@@ -160,15 +166,28 @@ cdef extern from "Python.h":
# use other PyModule_*() and PyObject_*() functions rather than
# directly manipulate a module's __dict__.
object
PyModule_GetNameObject
(
object
module
)
# Return module’s __name__ value. If the module does not provide one, or if
# it is not a string, SystemError is raised and NULL is returned.
char
*
PyModule_GetName
(
object
module
)
except
NULL
# Return module's __name__ value. If the module does not provide
# one, or if it is not a string, SystemError is raised and NULL is
# returned.
# Similar to PyModule_GetNameObject() but return the name encoded
# to 'utf-8'.
void
*
PyModule_GetState
(
object
module
)
# Return the “state” of the module, that is, a pointer to the block of
# memory allocated at module creation time, or NULL.
# See PyModuleDef.m_size.
object
PyModule_GetFilenameObject
(
object
module
)
# Return the name of the file from which module was loaded using module’s
# __file__ attribute. If this is not defined, or if it is not a unicode
# string, raise SystemError and return NULL; otherwise return a reference
# to a Unicode object.
char
*
PyModule_GetFilename
(
object
module
)
except
NULL
# Return the name of the file from which module was loaded using
# module's __file__ attribute. If this is not defined, or if it is
# not a string, raise SystemError and return NULL.
# Similar to PyModule_GetFilenameObject() but return the filename encoded
# to ‘utf-8’.
int
PyModule_AddObject
(
object
module
,
const
char
*
name
,
object
value
)
except
-
1
# Add an object to module as name. This is a convenience function
...
...
Cython/Includes/cpython/object.pxd
View file @
f63ff29c
...
...
@@ -45,6 +45,8 @@ cdef extern from "Python.h":
newfunc
tp_new
destructor
tp_dealloc
destructor
tp_del
destructor
tp_finalize
traverseproc
tp_traverse
inquiry
tp_clear
freefunc
tp_free
...
...
@@ -63,6 +65,8 @@ cdef extern from "Python.h":
descrgetfunc
tp_descr_get
descrsetfunc
tp_descr_set
unsigned
int
tp_version_tag
ctypedef
struct
PyObject
:
Py_ssize_t
ob_refcnt
PyTypeObject
*
ob_type
...
...
@@ -397,3 +401,4 @@ cdef extern from "Python.h":
long
Py_TPFLAGS_DEFAULT_EXTERNAL
long
Py_TPFLAGS_DEFAULT_CORE
long
Py_TPFLAGS_DEFAULT
long
Py_TPFLAGS_HAVE_FINALIZE
Cython/Includes/cpython/pyport.pxd
0 → 100644
View file @
f63ff29c
cdef
extern
from
"Python.h"
:
ctypedef
int
int32_t
ctypedef
int
int64_t
ctypedef
unsigned
int
uint32_t
ctypedef
unsigned
int
uint64_t
const
Py_ssize_t
PY_SSIZE_T_MIN
const
Py_ssize_t
PY_SSIZE_T_MAX
Cython/Includes/cpython/type.pxd
View file @
f63ff29c
...
...
@@ -23,6 +23,11 @@ cdef extern from "Python.h":
# of the standard type object. Return false in all other
# cases.
void
PyType_Modified
(
type
type
)
# Invalidate the internal lookup cache for the type and all of its
# subtypes. This function must be called after any manual modification
# of the attributes or base classes of the type.
bint
PyType_HasFeature
(
object
o
,
int
feature
)
# Return true if the type object o sets the feature feature. Type
# features are denoted by single bit flags.
...
...
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