Commit 5bfd8c82 authored by Xavier Thompson's avatar Xavier Thompson

Disable non-cypclass no-op templated overloads of cypclass refcounting macros

parent 277f0c23
...@@ -652,24 +652,12 @@ def init_builtin_structs(): ...@@ -652,24 +652,12 @@ def init_builtin_structs():
name, "struct", scope, 1, None, cname = cname) name, "struct", scope, 1, None, cname = cname)
def inject_cypclass_refcount_macros(): def inject_cypclass_refcount_macros():
template_placeholder_type = PyrexTypes.TemplatePlaceholderType("T") 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", template_placeholder_type, None)],
nogil = 1,
templates = [template_placeholder_type]
)
reference_to_template_type = PyrexTypes.CReferenceType(template_placeholder_type) reference_to_cy_object_type = PyrexTypes.CReferenceType(PyrexTypes.cy_object_type)
decref_type = PyrexTypes.CFuncType( decref_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [PyrexTypes.CFuncTypeArg("obj", reference_to_cy_object_type, None)], nogil = 1)
PyrexTypes.c_void_type, [PyrexTypes.CFuncTypeArg("obj", reference_to_template_type, None)],
nogil = 1,
templates = [template_placeholder_type]
)
getref_type = PyrexTypes.CFuncType( getref_type = PyrexTypes.CFuncType(PyrexTypes.c_int_type, [PyrexTypes.CFuncTypeArg("obj", PyrexTypes.cy_object_type, None)], nogil = 1)
PyrexTypes.c_int_type, [PyrexTypes.CFuncTypeArg("obj", PyrexTypes.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)]: 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) builtin_scope.declare_builtin_cfunction(macro, macro_type, macro)
......
...@@ -357,26 +357,13 @@ ...@@ -357,26 +357,13 @@
}; };
/* template <typename T>
* Let Cy_INCREF, Cy_DECREF and Cy_XDECREF accept any argument type
* but only do the work when the argument is actually a CyObject
*/
template <typename T, typename std::enable_if<!std::is_convertible<T, CyObject*>::value, int>::type = 0>
static inline void Cy_DECREF(T) {}
template <typename T, typename std::enable_if<!std::is_convertible<T, CyObject*>::value, int>::type = 0>
static inline void Cy_XDECREF(T) {}
template <typename T, typename std::enable_if<!std::is_convertible<T, CyObject*>::value, int>::type = 0>
static inline void Cy_INCREF(T) {}
template <typename T, typename std::enable_if<std::is_convertible<T, CyObject*>::value, int>::type = 0>
static inline void Cy_DECREF(T &ob) { static inline void Cy_DECREF(T &ob) {
if(ob->CyObject_DECREF()) if(ob->CyObject_DECREF())
ob = NULL; ob = NULL;
} }
template <typename T, typename std::enable_if<std::is_convertible<T, CyObject*>::value, int>::type = 0> template <typename T>
static inline void Cy_XDECREF(T &ob) { static inline void Cy_XDECREF(T &ob) {
if (ob != NULL) { if (ob != NULL) {
if(ob->CyObject_DECREF()) if(ob->CyObject_DECREF())
...@@ -384,7 +371,7 @@ ...@@ -384,7 +371,7 @@
} }
} }
template <typename T, typename std::enable_if<std::is_convertible<T, CyObject*>::value, int>::type = 0> template <typename T>
static inline void Cy_INCREF(T ob) { static inline void Cy_INCREF(T ob) {
if (ob != NULL) if (ob != NULL)
ob->CyObject_INCREF(); ob->CyObject_INCREF();
......
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