Commit 48aeaa3a authored by Xavier Thompson's avatar Xavier Thompson

Make cypclass builtin macros accept const arguments

parent ac886ee9
......@@ -652,21 +652,45 @@ def init_builtin_structs():
name, "struct", scope, 1, None, cname = cname)
def inject_cypclass_refcount_macros():
incref_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [PyrexTypes.CFuncTypeArg("obj", PyrexTypes.cy_object_type, None)], nogil = 1)
incref_type = PyrexTypes.CFuncType(
PyrexTypes.c_void_type,
[
PyrexTypes.CFuncTypeArg("obj", PyrexTypes.const_cy_object_type, None)
],
nogil = 1)
reference_to_cy_object_type = PyrexTypes.CReferenceType(PyrexTypes.cy_object_type)
decref_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [PyrexTypes.CFuncTypeArg("obj", reference_to_cy_object_type, None)], nogil = 1)
decref_type = PyrexTypes.CFuncType(
PyrexTypes.c_void_type,
[
PyrexTypes.CFuncTypeArg("obj", PyrexTypes.CReferenceType(PyrexTypes.const_cy_object_type), None)
],
nogil = 1)
getref_type = PyrexTypes.CFuncType(PyrexTypes.c_int_type, [PyrexTypes.CFuncTypeArg("obj", PyrexTypes.cy_object_type, None)], nogil = 1)
getref_type = PyrexTypes.CFuncType(
PyrexTypes.c_int_type,
[
PyrexTypes.CFuncTypeArg("obj", PyrexTypes.const_cy_object_type, None)
],
nogil = 1)
for macro, macro_type in [("Cy_INCREF", incref_type), ("Cy_DECREF", decref_type), ("Cy_XDECREF", decref_type), ("Cy_GETREF", getref_type)]:
builtin_scope.declare_builtin_cfunction(macro, macro_type, macro)
def inject_cypclass_lock_macros():
blocking_macro_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [PyrexTypes.CFuncTypeArg("obj", PyrexTypes.cy_object_type, None)], nogil = 1)
blocking_macro_type = PyrexTypes.CFuncType(
PyrexTypes.c_void_type,
[
PyrexTypes.CFuncTypeArg("obj", PyrexTypes.const_cy_object_type, None)
],
nogil = 1)
for macro in ("Cy_RLOCK", "Cy_WLOCK", "Cy_UNWLOCK", "Cy_UNRLOCK"):
builtin_scope.declare_builtin_cfunction(macro, blocking_macro_type, macro)
nonblocking_macro_type = PyrexTypes.CFuncType(PyrexTypes.c_int_type, [PyrexTypes.CFuncTypeArg("obj", PyrexTypes.cy_object_type, None)], nogil = 1)
nonblocking_macro_type = PyrexTypes.CFuncType(PyrexTypes.c_int_type,
[
PyrexTypes.CFuncTypeArg("obj", PyrexTypes.const_cy_object_type, None)
],
nogil = 1)
for macro in ("Cy_TRYRLOCK", "Cy_TRYWLOCK"):
builtin_scope.declare_builtin_cfunction(macro, nonblocking_macro_type, macro)
......
......@@ -399,11 +399,11 @@
ob->CyObject_INCREF();
}
static inline int _Cy_GETREF(CyObject *ob) {
static inline int _Cy_GETREF(const CyObject *ob) {
return ob->CyObject_GETREF();
}
static inline void _Cy_RLOCK(CyObject *ob, const char *context) {
static inline void _Cy_RLOCK(const CyObject *ob, const char *context) {
if (ob != NULL) {
ob->CyObject_RLOCK(context);
}
......@@ -412,7 +412,7 @@
}
}
static inline void _Cy_WLOCK(CyObject *ob, const char *context) {
static inline void _Cy_WLOCK(const CyObject *ob, const char *context) {
if (ob != NULL) {
ob->CyObject_WLOCK(context);
}
......@@ -421,7 +421,7 @@
}
}
static inline void _Cy_UNRLOCK(CyObject *ob) {
static inline void _Cy_UNRLOCK(const CyObject *ob) {
if (ob != NULL) {
ob->CyObject_UNRLOCK();
}
......@@ -430,7 +430,7 @@
}
}
static inline void _Cy_UNWLOCK(CyObject *ob) {
static inline void _Cy_UNWLOCK(const CyObject *ob) {
if (ob != NULL) {
ob->CyObject_UNWLOCK();
}
......@@ -439,11 +439,11 @@
}
}
static inline int _Cy_TRYRLOCK(CyObject *ob) {
static inline int _Cy_TRYRLOCK(const CyObject *ob) {
return ob->CyObject_TRYRLOCK();
}
static inline int _Cy_TRYWLOCK(CyObject *ob) {
static inline int _Cy_TRYWLOCK(const CyObject *ob) {
return ob->CyObject_TRYWLOCK();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment