From 32c6f9bbd00b44280ffccfde57bf46eaaccd0b53 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Sep 2024 17:07:06 +1000 Subject: [PATCH] Cleanup: use PyModule_AddObjectRef where appropriate --- intern/cycles/blender/python.cpp | 36 ++++------ intern/mantaflow/intern/MANTA_main.cpp | 3 +- .../freestyle/intern/python/BPy_BBox.cpp | 3 +- .../intern/python/BPy_BinaryPredicate0D.cpp | 3 +- .../intern/python/BPy_BinaryPredicate1D.cpp | 19 ++---- .../intern/python/BPy_ContextFunctions.cpp | 3 +- .../intern/python/BPy_FrsMaterial.cpp | 3 +- .../freestyle/intern/python/BPy_FrsNoise.cpp | 3 +- .../freestyle/intern/python/BPy_Id.cpp | 3 +- .../intern/python/BPy_IntegrationType.cpp | 9 +-- .../intern/python/BPy_Interface0D.cpp | 21 ++---- .../intern/python/BPy_Interface1D.cpp | 24 +++---- .../freestyle/intern/python/BPy_Iterator.cpp | 35 ++++------ .../intern/python/BPy_MediumType.cpp | 3 +- .../freestyle/intern/python/BPy_Nature.cpp | 3 +- .../freestyle/intern/python/BPy_Operators.cpp | 3 +- .../freestyle/intern/python/BPy_SShape.cpp | 3 +- .../intern/python/BPy_StrokeAttribute.cpp | 3 +- .../intern/python/BPy_StrokeShader.cpp | 65 +++++++------------ .../intern/python/BPy_UnaryFunction0D.cpp | 3 +- .../intern/python/BPy_UnaryFunction1D.cpp | 3 +- .../intern/python/BPy_UnaryPredicate0D.cpp | 9 +-- .../intern/python/BPy_UnaryPredicate1D.cpp | 34 ++++------ .../freestyle/intern/python/BPy_ViewMap.cpp | 3 +- .../freestyle/intern/python/BPy_ViewShape.cpp | 3 +- .../BPy_UnaryFunction0DDouble.cpp | 33 ++++------ .../BPy_UnaryFunction0DEdgeNature.cpp | 6 +- .../BPy_UnaryFunction0DFloat.cpp | 21 ++---- .../UnaryFunction0D/BPy_UnaryFunction0DId.cpp | 6 +- .../BPy_UnaryFunction0DMaterial.cpp | 7 +- .../BPy_UnaryFunction0DUnsigned.cpp | 7 +- .../BPy_UnaryFunction0DVec2f.cpp | 10 ++- .../BPy_UnaryFunction0DVec3f.cpp | 7 +- .../BPy_UnaryFunction0DVectorViewShape.cpp | 6 +- .../BPy_UnaryFunction0DViewShape.cpp | 9 +-- .../BPy_UnaryFunction1DDouble.cpp | 49 +++++--------- .../BPy_UnaryFunction1DEdgeNature.cpp | 6 +- .../BPy_UnaryFunction1DFloat.cpp | 3 +- .../BPy_UnaryFunction1DUnsigned.cpp | 7 +- .../BPy_UnaryFunction1DVec2f.cpp | 9 +-- .../BPy_UnaryFunction1DVec3f.cpp | 6 +- .../BPy_UnaryFunction1DVectorViewShape.cpp | 12 ++-- .../BPy_UnaryFunction1DVoid.cpp | 12 ++-- source/blender/python/generic/bgl.cc | 3 +- .../blender/python/generic/py_capi_utils.cc | 3 +- 45 files changed, 184 insertions(+), 338 deletions(-) diff --git a/intern/cycles/blender/python.cpp b/intern/cycles/blender/python.cpp index bab6abd3130..034074c371d 100644 --- a/intern/cycles/blender/python.cpp +++ b/intern/cycles/blender/python.cpp @@ -1005,8 +1005,7 @@ void *CCL_python_module_init() * might use to get version in runtime. */ int curversion = OSL_LIBRARY_VERSION_CODE; - PyModule_AddObject(mod, "with_osl", Py_True); - Py_INCREF(Py_True); + PyModule_AddObjectRef(mod, "with_osl", Py_True); PyModule_AddObject( mod, "osl_version", @@ -1017,52 +1016,41 @@ void *CCL_python_module_init() PyUnicode_FromFormat( "%2d, %2d, %2d", curversion / 10000, (curversion / 100) % 100, curversion % 100)); #else - PyModule_AddObject(mod, "with_osl", Py_False); - Py_INCREF(Py_False); + PyModule_AddObjectRef(mod, "with_osl", Py_False); PyModule_AddStringConstant(mod, "osl_version", "unknown"); PyModule_AddStringConstant(mod, "osl_version_string", "unknown"); #endif if (ccl::guiding_supported()) { - PyModule_AddObject(mod, "with_path_guiding", Py_True); - Py_INCREF(Py_True); + PyModule_AddObjectRef(mod, "with_path_guiding", Py_True); } else { - PyModule_AddObject(mod, "with_path_guiding", Py_False); - Py_INCREF(Py_False); + PyModule_AddObjectRef(mod, "with_path_guiding", Py_False); } #ifdef WITH_EMBREE - PyModule_AddObject(mod, "with_embree", Py_True); - Py_INCREF(Py_True); + PyModule_AddObjectRef(mod, "with_embree", Py_True); #else /* WITH_EMBREE */ - PyModule_AddObject(mod, "with_embree", Py_False); - Py_INCREF(Py_False); + PyModule_AddObjectRef(mod, "with_embree", Py_False); #endif /* WITH_EMBREE */ #ifdef WITH_EMBREE_GPU - PyModule_AddObject(mod, "with_embree_gpu", Py_True); - Py_INCREF(Py_True); + PyModule_AddObjectRef(mod, "with_embree_gpu", Py_True); #else /* WITH_EMBREE_GPU */ - PyModule_AddObject(mod, "with_embree_gpu", Py_False); - Py_INCREF(Py_False); + PyModule_AddObjectRef(mod, "with_embree_gpu", Py_False); #endif /* WITH_EMBREE_GPU */ if (ccl::openimagedenoise_supported()) { - PyModule_AddObject(mod, "with_openimagedenoise", Py_True); - Py_INCREF(Py_True); + PyModule_AddObjectRef(mod, "with_openimagedenoise", Py_True); } else { - PyModule_AddObject(mod, "with_openimagedenoise", Py_False); - Py_INCREF(Py_False); + PyModule_AddObjectRef(mod, "with_openimagedenoise", Py_False); } #ifdef WITH_CYCLES_DEBUG - PyModule_AddObject(mod, "with_debug", Py_True); - Py_INCREF(Py_True); + PyModule_AddObjectRef(mod, "with_debug", Py_True); #else /* WITH_CYCLES_DEBUG */ - PyModule_AddObject(mod, "with_debug", Py_False); - Py_INCREF(Py_False); + PyModule_AddObjectRef(mod, "with_debug", Py_False); #endif /* WITH_CYCLES_DEBUG */ return (void *)mod; diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index 66e27310d3e..6f70d9ef5c9 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -605,8 +605,7 @@ static PyObject *manta_python_main_module_create(const char *filename) * NOTE: this won't map to a real file when executing text-blocks and buttons. */ PyModule_AddObject(mod_main, "__file__", PyUnicode_InternFromString(filename)); } - PyModule_AddObject(mod_main, "__builtins__", builtins); - Py_INCREF(builtins); /* AddObject steals a reference */ + PyModule_AddObjectRef(mod_main, "__builtins__", builtins); return mod_main; } diff --git a/source/blender/freestyle/intern/python/BPy_BBox.cpp b/source/blender/freestyle/intern/python/BPy_BBox.cpp index 343264af27d..783bcee51ed 100644 --- a/source/blender/freestyle/intern/python/BPy_BBox.cpp +++ b/source/blender/freestyle/intern/python/BPy_BBox.cpp @@ -27,8 +27,7 @@ int BBox_Init(PyObject *module) if (PyType_Ready(&BBox_Type) < 0) { return -1; } - Py_INCREF(&BBox_Type); - PyModule_AddObject(module, "BBox", (PyObject *)&BBox_Type); + PyModule_AddObjectRef(module, "BBox", (PyObject *)&BBox_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp index 08d6a9e0a96..60d83b7fd61 100644 --- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp @@ -29,8 +29,7 @@ int BinaryPredicate0D_Init(PyObject *module) if (PyType_Ready(&BinaryPredicate0D_Type) < 0) { return -1; } - Py_INCREF(&BinaryPredicate0D_Type); - PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type); + PyModule_AddObjectRef(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp index 146060a0c3f..2faded49976 100644 --- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp @@ -35,38 +35,33 @@ int BinaryPredicate1D_Init(PyObject *module) if (PyType_Ready(&BinaryPredicate1D_Type) < 0) { return -1; } - Py_INCREF(&BinaryPredicate1D_Type); - PyModule_AddObject(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type); + PyModule_AddObjectRef(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type); if (PyType_Ready(&FalseBP1D_Type) < 0) { return -1; } - Py_INCREF(&FalseBP1D_Type); - PyModule_AddObject(module, "FalseBP1D", (PyObject *)&FalseBP1D_Type); + PyModule_AddObjectRef(module, "FalseBP1D", (PyObject *)&FalseBP1D_Type); if (PyType_Ready(&Length2DBP1D_Type) < 0) { return -1; } - Py_INCREF(&Length2DBP1D_Type); - PyModule_AddObject(module, "Length2DBP1D", (PyObject *)&Length2DBP1D_Type); + PyModule_AddObjectRef(module, "Length2DBP1D", (PyObject *)&Length2DBP1D_Type); if (PyType_Ready(&SameShapeIdBP1D_Type) < 0) { return -1; } - Py_INCREF(&SameShapeIdBP1D_Type); - PyModule_AddObject(module, "SameShapeIdBP1D", (PyObject *)&SameShapeIdBP1D_Type); + PyModule_AddObjectRef(module, "SameShapeIdBP1D", (PyObject *)&SameShapeIdBP1D_Type); if (PyType_Ready(&TrueBP1D_Type) < 0) { return -1; } - Py_INCREF(&TrueBP1D_Type); - PyModule_AddObject(module, "TrueBP1D", (PyObject *)&TrueBP1D_Type); + PyModule_AddObjectRef(module, "TrueBP1D", (PyObject *)&TrueBP1D_Type); if (PyType_Ready(&ViewMapGradientNormBP1D_Type) < 0) { return -1; } - Py_INCREF(&ViewMapGradientNormBP1D_Type); - PyModule_AddObject(module, "ViewMapGradientNormBP1D", (PyObject *)&ViewMapGradientNormBP1D_Type); + PyModule_AddObjectRef( + module, "ViewMapGradientNormBP1D", (PyObject *)&ViewMapGradientNormBP1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp index e8828e77a42..c628b14dce7 100644 --- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp +++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp @@ -330,8 +330,7 @@ int ContextFunctions_Init(PyObject *module) if (m == nullptr) { return -1; } - Py_INCREF(m); - PyModule_AddObject(module, "ContextFunctions", m); + PyModule_AddObjectRef(module, "ContextFunctions", m); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp index 5b70a3c0c4c..747b0dc9077 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -31,8 +31,7 @@ int FrsMaterial_Init(PyObject *module) if (PyType_Ready(&FrsMaterial_Type) < 0) { return -1; } - Py_INCREF(&FrsMaterial_Type); - PyModule_AddObject(module, "Material", (PyObject *)&FrsMaterial_Type); + PyModule_AddObjectRef(module, "Material", (PyObject *)&FrsMaterial_Type); FrsMaterial_mathutils_register_callback(); diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp index 24bf920c4f4..fe3a42c0297 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp @@ -33,8 +33,7 @@ int FrsNoise_Init(PyObject *module) if (PyType_Ready(&FrsNoise_Type) < 0) { return -1; } - Py_INCREF(&FrsNoise_Type); - PyModule_AddObject(module, "Noise", (PyObject *)&FrsNoise_Type); + PyModule_AddObjectRef(module, "Noise", (PyObject *)&FrsNoise_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_Id.cpp b/source/blender/freestyle/intern/python/BPy_Id.cpp index ca77172733d..f2dcb7ae325 100644 --- a/source/blender/freestyle/intern/python/BPy_Id.cpp +++ b/source/blender/freestyle/intern/python/BPy_Id.cpp @@ -29,8 +29,7 @@ int Id_Init(PyObject *module) return -1; } - Py_INCREF(&Id_Type); - PyModule_AddObject(module, "Id", (PyObject *)&Id_Type); + PyModule_AddObjectRef(module, "Id", (PyObject *)&Id_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp index 0a46e304655..a9bedfdab4c 100644 --- a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp +++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp @@ -208,8 +208,7 @@ int IntegrationType_Init(PyObject *module) if (PyType_Ready(&IntegrationType_Type) < 0) { return -1; } - Py_INCREF(&IntegrationType_Type); - PyModule_AddObject(module, "IntegrationType", (PyObject *)&IntegrationType_Type); + PyModule_AddObjectRef(module, "IntegrationType", (PyObject *)&IntegrationType_Type); #define ADD_TYPE_CONST(id) \ PyLong_subtype_add_to_dict( \ @@ -227,15 +226,13 @@ int IntegrationType_Init(PyObject *module) if (m == nullptr) { return -1; } - Py_INCREF(m); - PyModule_AddObject(module, "Integrator", m); + PyModule_AddObjectRef(module, "Integrator", m); // from Integrator import * d = PyModule_GetDict(m); for (PyMethodDef *p = module_functions; p->ml_name; p++) { f = PyDict_GetItemString(d, p->ml_name); - Py_INCREF(f); - PyModule_AddObject(module, p->ml_name, f); + PyModule_AddObjectRef(module, p->ml_name, f); } return 0; diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp index 84241f1a9e1..f301ad01468 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp @@ -36,44 +36,37 @@ int Interface0D_Init(PyObject *module) if (PyType_Ready(&Interface0D_Type) < 0) { return -1; } - Py_INCREF(&Interface0D_Type); - PyModule_AddObject(module, "Interface0D", (PyObject *)&Interface0D_Type); + PyModule_AddObjectRef(module, "Interface0D", (PyObject *)&Interface0D_Type); if (PyType_Ready(&CurvePoint_Type) < 0) { return -1; } - Py_INCREF(&CurvePoint_Type); - PyModule_AddObject(module, "CurvePoint", (PyObject *)&CurvePoint_Type); + PyModule_AddObjectRef(module, "CurvePoint", (PyObject *)&CurvePoint_Type); if (PyType_Ready(&SVertex_Type) < 0) { return -1; } - Py_INCREF(&SVertex_Type); - PyModule_AddObject(module, "SVertex", (PyObject *)&SVertex_Type); + PyModule_AddObjectRef(module, "SVertex", (PyObject *)&SVertex_Type); if (PyType_Ready(&ViewVertex_Type) < 0) { return -1; } - Py_INCREF(&ViewVertex_Type); - PyModule_AddObject(module, "ViewVertex", (PyObject *)&ViewVertex_Type); + PyModule_AddObjectRef(module, "ViewVertex", (PyObject *)&ViewVertex_Type); if (PyType_Ready(&StrokeVertex_Type) < 0) { return -1; } - Py_INCREF(&StrokeVertex_Type); - PyModule_AddObject(module, "StrokeVertex", (PyObject *)&StrokeVertex_Type); + PyModule_AddObjectRef(module, "StrokeVertex", (PyObject *)&StrokeVertex_Type); if (PyType_Ready(&NonTVertex_Type) < 0) { return -1; } - Py_INCREF(&NonTVertex_Type); - PyModule_AddObject(module, "NonTVertex", (PyObject *)&NonTVertex_Type); + PyModule_AddObjectRef(module, "NonTVertex", (PyObject *)&NonTVertex_Type); if (PyType_Ready(&TVertex_Type) < 0) { return -1; } - Py_INCREF(&TVertex_Type); - PyModule_AddObject(module, "TVertex", (PyObject *)&TVertex_Type); + PyModule_AddObjectRef(module, "TVertex", (PyObject *)&TVertex_Type); SVertex_mathutils_register_callback(); StrokeVertex_mathutils_register_callback(); diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp index 58ec72b764d..3f6d31efb8a 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp @@ -37,44 +37,37 @@ int Interface1D_Init(PyObject *module) if (PyType_Ready(&Interface1D_Type) < 0) { return -1; } - Py_INCREF(&Interface1D_Type); - PyModule_AddObject(module, "Interface1D", (PyObject *)&Interface1D_Type); + PyModule_AddObjectRef(module, "Interface1D", (PyObject *)&Interface1D_Type); if (PyType_Ready(&FrsCurve_Type) < 0) { return -1; } - Py_INCREF(&FrsCurve_Type); - PyModule_AddObject(module, "Curve", (PyObject *)&FrsCurve_Type); + PyModule_AddObjectRef(module, "Curve", (PyObject *)&FrsCurve_Type); if (PyType_Ready(&Chain_Type) < 0) { return -1; } - Py_INCREF(&Chain_Type); - PyModule_AddObject(module, "Chain", (PyObject *)&Chain_Type); + PyModule_AddObjectRef(module, "Chain", (PyObject *)&Chain_Type); if (PyType_Ready(&FEdge_Type) < 0) { return -1; } - Py_INCREF(&FEdge_Type); - PyModule_AddObject(module, "FEdge", (PyObject *)&FEdge_Type); + PyModule_AddObjectRef(module, "FEdge", (PyObject *)&FEdge_Type); if (PyType_Ready(&FEdgeSharp_Type) < 0) { return -1; } - Py_INCREF(&FEdgeSharp_Type); - PyModule_AddObject(module, "FEdgeSharp", (PyObject *)&FEdgeSharp_Type); + PyModule_AddObjectRef(module, "FEdgeSharp", (PyObject *)&FEdgeSharp_Type); if (PyType_Ready(&FEdgeSmooth_Type) < 0) { return -1; } - Py_INCREF(&FEdgeSmooth_Type); - PyModule_AddObject(module, "FEdgeSmooth", (PyObject *)&FEdgeSmooth_Type); + PyModule_AddObjectRef(module, "FEdgeSmooth", (PyObject *)&FEdgeSmooth_Type); if (PyType_Ready(&Stroke_Type) < 0) { return -1; } - Py_INCREF(&Stroke_Type); - PyModule_AddObject(module, "Stroke", (PyObject *)&Stroke_Type); + PyModule_AddObjectRef(module, "Stroke", (PyObject *)&Stroke_Type); #define ADD_TYPE_CONST(id) \ PyLong_subtype_add_to_dict(Stroke_Type.tp_dict, &MediumType_Type, STRINGIFY(id), Stroke::id) @@ -86,8 +79,7 @@ int Interface1D_Init(PyObject *module) if (PyType_Ready(&ViewEdge_Type) < 0) { return -1; } - Py_INCREF(&ViewEdge_Type); - PyModule_AddObject(module, "ViewEdge", (PyObject *)&ViewEdge_Type); + PyModule_AddObjectRef(module, "ViewEdge", (PyObject *)&ViewEdge_Type); FEdgeSharp_mathutils_register_callback(); FEdgeSmooth_mathutils_register_callback(); diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp index 80f83662c6a..430e9451333 100644 --- a/source/blender/freestyle/intern/python/BPy_Iterator.cpp +++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp @@ -38,69 +38,60 @@ int Iterator_Init(PyObject *module) if (PyType_Ready(&Iterator_Type) < 0) { return -1; } - Py_INCREF(&Iterator_Type); - PyModule_AddObject(module, "Iterator", (PyObject *)&Iterator_Type); + PyModule_AddObjectRef(module, "Iterator", (PyObject *)&Iterator_Type); if (PyType_Ready(&AdjacencyIterator_Type) < 0) { return -1; } - Py_INCREF(&AdjacencyIterator_Type); - PyModule_AddObject(module, "AdjacencyIterator", (PyObject *)&AdjacencyIterator_Type); + PyModule_AddObjectRef(module, "AdjacencyIterator", (PyObject *)&AdjacencyIterator_Type); if (PyType_Ready(&Interface0DIterator_Type) < 0) { return -1; } - Py_INCREF(&Interface0DIterator_Type); - PyModule_AddObject(module, "Interface0DIterator", (PyObject *)&Interface0DIterator_Type); + PyModule_AddObjectRef(module, "Interface0DIterator", (PyObject *)&Interface0DIterator_Type); if (PyType_Ready(&CurvePointIterator_Type) < 0) { return -1; } - Py_INCREF(&CurvePointIterator_Type); - PyModule_AddObject(module, "CurvePointIterator", (PyObject *)&CurvePointIterator_Type); + PyModule_AddObjectRef(module, "CurvePointIterator", (PyObject *)&CurvePointIterator_Type); if (PyType_Ready(&StrokeVertexIterator_Type) < 0) { return -1; } - Py_INCREF(&StrokeVertexIterator_Type); - PyModule_AddObject(module, "StrokeVertexIterator", (PyObject *)&StrokeVertexIterator_Type); + PyModule_AddObjectRef(module, "StrokeVertexIterator", (PyObject *)&StrokeVertexIterator_Type); if (PyType_Ready(&SVertexIterator_Type) < 0) { return -1; } - Py_INCREF(&SVertexIterator_Type); - PyModule_AddObject(module, "SVertexIterator", (PyObject *)&SVertexIterator_Type); + PyModule_AddObjectRef(module, "SVertexIterator", (PyObject *)&SVertexIterator_Type); if (PyType_Ready(&orientedViewEdgeIterator_Type) < 0) { return -1; } - Py_INCREF(&orientedViewEdgeIterator_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "orientedViewEdgeIterator", (PyObject *)&orientedViewEdgeIterator_Type); if (PyType_Ready(&ViewEdgeIterator_Type) < 0) { return -1; } - Py_INCREF(&ViewEdgeIterator_Type); - PyModule_AddObject(module, "ViewEdgeIterator", (PyObject *)&ViewEdgeIterator_Type); + PyModule_AddObjectRef(module, "ViewEdgeIterator", (PyObject *)&ViewEdgeIterator_Type); if (PyType_Ready(&ChainingIterator_Type) < 0) { return -1; } - Py_INCREF(&ChainingIterator_Type); - PyModule_AddObject(module, "ChainingIterator", (PyObject *)&ChainingIterator_Type); + PyModule_AddObjectRef(module, "ChainingIterator", (PyObject *)&ChainingIterator_Type); if (PyType_Ready(&ChainPredicateIterator_Type) < 0) { return -1; } - Py_INCREF(&ChainPredicateIterator_Type); - PyModule_AddObject(module, "ChainPredicateIterator", (PyObject *)&ChainPredicateIterator_Type); + PyModule_AddObjectRef( + module, "ChainPredicateIterator", (PyObject *)&ChainPredicateIterator_Type); if (PyType_Ready(&ChainSilhouetteIterator_Type) < 0) { return -1; } - Py_INCREF(&ChainSilhouetteIterator_Type); - PyModule_AddObject(module, "ChainSilhouetteIterator", (PyObject *)&ChainSilhouetteIterator_Type); + PyModule_AddObjectRef( + module, "ChainSilhouetteIterator", (PyObject *)&ChainSilhouetteIterator_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.cpp b/source/blender/freestyle/intern/python/BPy_MediumType.cpp index 680979b2567..672bdfa1893 100644 --- a/source/blender/freestyle/intern/python/BPy_MediumType.cpp +++ b/source/blender/freestyle/intern/python/BPy_MediumType.cpp @@ -86,8 +86,7 @@ int MediumType_Init(PyObject *module) if (PyType_Ready(&MediumType_Type) < 0) { return -1; } - Py_INCREF(&MediumType_Type); - PyModule_AddObject(module, "MediumType", (PyObject *)&MediumType_Type); + PyModule_AddObjectRef(module, "MediumType", (PyObject *)&MediumType_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_Nature.cpp b/source/blender/freestyle/intern/python/BPy_Nature.cpp index 5e4e566c550..d9849f550bd 100644 --- a/source/blender/freestyle/intern/python/BPy_Nature.cpp +++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp @@ -149,8 +149,7 @@ int Nature_Init(PyObject *module) if (PyType_Ready(&Nature_Type) < 0) { return -1; } - Py_INCREF(&Nature_Type); - PyModule_AddObject(module, "Nature", (PyObject *)&Nature_Type); + PyModule_AddObjectRef(module, "Nature", (PyObject *)&Nature_Type); #define ADD_TYPE_CONST(id) \ PyLong_subtype_add_to_dict(Nature_Type.tp_dict, &Nature_Type, STRINGIFY(id), Nature::id) diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp index 6981298092a..7bca91cd75a 100644 --- a/source/blender/freestyle/intern/python/BPy_Operators.cpp +++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp @@ -40,8 +40,7 @@ int Operators_Init(PyObject *module) if (PyType_Ready(&Operators_Type) < 0) { return -1; } - Py_INCREF(&Operators_Type); - PyModule_AddObject(module, "Operators", (PyObject *)&Operators_Type); + PyModule_AddObjectRef(module, "Operators", (PyObject *)&Operators_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp index 447ab8656c5..a369081ffd7 100644 --- a/source/blender/freestyle/intern/python/BPy_SShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp @@ -34,8 +34,7 @@ int SShape_Init(PyObject *module) if (PyType_Ready(&SShape_Type) < 0) { return -1; } - Py_INCREF(&SShape_Type); - PyModule_AddObject(module, "SShape", (PyObject *)&SShape_Type); + PyModule_AddObjectRef(module, "SShape", (PyObject *)&SShape_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp index 8eb2ee2df18..2d2cff43b61 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -28,8 +28,7 @@ int StrokeAttribute_Init(PyObject *module) if (PyType_Ready(&StrokeAttribute_Type) < 0) { return -1; } - Py_INCREF(&StrokeAttribute_Type); - PyModule_AddObject(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type); + PyModule_AddObjectRef(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type); StrokeAttribute_mathutils_register_callback(); return 0; diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp index f6489b7d99f..41420234591 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp @@ -48,119 +48,104 @@ int StrokeShader_Init(PyObject *module) if (PyType_Ready(&StrokeShader_Type) < 0) { return -1; } - Py_INCREF(&StrokeShader_Type); - PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type); + PyModule_AddObjectRef(module, "StrokeShader", (PyObject *)&StrokeShader_Type); if (PyType_Ready(&BackboneStretcherShader_Type) < 0) { return -1; } - Py_INCREF(&BackboneStretcherShader_Type); - PyModule_AddObject(module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type); + PyModule_AddObjectRef( + module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type); if (PyType_Ready(&BezierCurveShader_Type) < 0) { return -1; } - Py_INCREF(&BezierCurveShader_Type); - PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type); + PyModule_AddObjectRef(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type); if (PyType_Ready(&BlenderTextureShader_Type) < 0) { return -1; } - Py_INCREF(&BlenderTextureShader_Type); - PyModule_AddObject(module, "BlenderTextureShader", (PyObject *)&BlenderTextureShader_Type); + PyModule_AddObjectRef(module, "BlenderTextureShader", (PyObject *)&BlenderTextureShader_Type); if (PyType_Ready(&CalligraphicShader_Type) < 0) { return -1; } - Py_INCREF(&CalligraphicShader_Type); - PyModule_AddObject(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type); + PyModule_AddObjectRef(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type); if (PyType_Ready(&ColorNoiseShader_Type) < 0) { return -1; } - Py_INCREF(&ColorNoiseShader_Type); - PyModule_AddObject(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type); + PyModule_AddObjectRef(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type); if (PyType_Ready(&ConstantColorShader_Type) < 0) { return -1; } - Py_INCREF(&ConstantColorShader_Type); - PyModule_AddObject(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type); + PyModule_AddObjectRef(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type); if (PyType_Ready(&ConstantThicknessShader_Type) < 0) { return -1; } - Py_INCREF(&ConstantThicknessShader_Type); - PyModule_AddObject(module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type); + PyModule_AddObjectRef( + module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type); if (PyType_Ready(&ConstrainedIncreasingThicknessShader_Type) < 0) { return -1; } - Py_INCREF(&ConstrainedIncreasingThicknessShader_Type); - PyModule_AddObject(module, - "ConstrainedIncreasingThicknessShader", - (PyObject *)&ConstrainedIncreasingThicknessShader_Type); + PyModule_AddObjectRef(module, + "ConstrainedIncreasingThicknessShader", + (PyObject *)&ConstrainedIncreasingThicknessShader_Type); if (PyType_Ready(&GuidingLinesShader_Type) < 0) { return -1; } - Py_INCREF(&GuidingLinesShader_Type); - PyModule_AddObject(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type); + PyModule_AddObjectRef(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type); if (PyType_Ready(&IncreasingColorShader_Type) < 0) { return -1; } - Py_INCREF(&IncreasingColorShader_Type); - PyModule_AddObject(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type); + PyModule_AddObjectRef(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type); if (PyType_Ready(&IncreasingThicknessShader_Type) < 0) { return -1; } - Py_INCREF(&IncreasingThicknessShader_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "IncreasingThicknessShader", (PyObject *)&IncreasingThicknessShader_Type); if (PyType_Ready(&PolygonalizationShader_Type) < 0) { return -1; } - Py_INCREF(&PolygonalizationShader_Type); - PyModule_AddObject(module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type); + PyModule_AddObjectRef( + module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type); if (PyType_Ready(&SamplingShader_Type) < 0) { return -1; } - Py_INCREF(&SamplingShader_Type); - PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type); + PyModule_AddObjectRef(module, "SamplingShader", (PyObject *)&SamplingShader_Type); if (PyType_Ready(&SmoothingShader_Type) < 0) { return -1; } - Py_INCREF(&SmoothingShader_Type); - PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type); + PyModule_AddObjectRef(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type); if (PyType_Ready(&SpatialNoiseShader_Type) < 0) { return -1; } - Py_INCREF(&SpatialNoiseShader_Type); - PyModule_AddObject(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type); + PyModule_AddObjectRef(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type); if (PyType_Ready(&StrokeTextureStepShader_Type) < 0) { return -1; } - Py_INCREF(&StrokeTextureStepShader_Type); - PyModule_AddObject(module, "StrokeTextureStepShader", (PyObject *)&StrokeTextureStepShader_Type); + PyModule_AddObjectRef( + module, "StrokeTextureStepShader", (PyObject *)&StrokeTextureStepShader_Type); if (PyType_Ready(&ThicknessNoiseShader_Type) < 0) { return -1; } - Py_INCREF(&ThicknessNoiseShader_Type); - PyModule_AddObject(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type); + PyModule_AddObjectRef(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type); if (PyType_Ready(&TipRemoverShader_Type) < 0) { return -1; } - Py_INCREF(&TipRemoverShader_Type); - PyModule_AddObject(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type); + PyModule_AddObjectRef(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp index 03454f883d4..4d632682de7 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp @@ -37,8 +37,7 @@ int UnaryFunction0D_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0D_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0D_Type); - PyModule_AddObject(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type); + PyModule_AddObjectRef(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type); UnaryFunction0DDouble_Init(module); UnaryFunction0DEdgeNature_Init(module); diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp index ea68f8dc037..e4873d114b4 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp @@ -35,8 +35,7 @@ int UnaryFunction1D_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1D_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1D_Type); - PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type); + PyModule_AddObjectRef(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type); UnaryFunction1DDouble_Init(module); UnaryFunction1DEdgeNature_Init(module); diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp index b935c1aa7a7..51f20b7fbb1 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp @@ -31,20 +31,17 @@ int UnaryPredicate0D_Init(PyObject *module) if (PyType_Ready(&UnaryPredicate0D_Type) < 0) { return -1; } - Py_INCREF(&UnaryPredicate0D_Type); - PyModule_AddObject(module, "UnaryPredicate0D", (PyObject *)&UnaryPredicate0D_Type); + PyModule_AddObjectRef(module, "UnaryPredicate0D", (PyObject *)&UnaryPredicate0D_Type); if (PyType_Ready(&FalseUP0D_Type) < 0) { return -1; } - Py_INCREF(&FalseUP0D_Type); - PyModule_AddObject(module, "FalseUP0D", (PyObject *)&FalseUP0D_Type); + PyModule_AddObjectRef(module, "FalseUP0D", (PyObject *)&FalseUP0D_Type); if (PyType_Ready(&TrueUP0D_Type) < 0) { return -1; } - Py_INCREF(&TrueUP0D_Type); - PyModule_AddObject(module, "TrueUP0D", (PyObject *)&TrueUP0D_Type); + PyModule_AddObjectRef(module, "TrueUP0D", (PyObject *)&TrueUP0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp index d3298457cd1..1cec17f14e9 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp @@ -40,70 +40,60 @@ int UnaryPredicate1D_Init(PyObject *module) if (PyType_Ready(&UnaryPredicate1D_Type) < 0) { return -1; } - Py_INCREF(&UnaryPredicate1D_Type); - PyModule_AddObject(module, "UnaryPredicate1D", (PyObject *)&UnaryPredicate1D_Type); + PyModule_AddObjectRef(module, "UnaryPredicate1D", (PyObject *)&UnaryPredicate1D_Type); if (PyType_Ready(&ContourUP1D_Type) < 0) { return -1; } - Py_INCREF(&ContourUP1D_Type); - PyModule_AddObject(module, "ContourUP1D", (PyObject *)&ContourUP1D_Type); + PyModule_AddObjectRef(module, "ContourUP1D", (PyObject *)&ContourUP1D_Type); if (PyType_Ready(&DensityLowerThanUP1D_Type) < 0) { return -1; } - Py_INCREF(&DensityLowerThanUP1D_Type); - PyModule_AddObject(module, "DensityLowerThanUP1D", (PyObject *)&DensityLowerThanUP1D_Type); + PyModule_AddObjectRef(module, "DensityLowerThanUP1D", (PyObject *)&DensityLowerThanUP1D_Type); if (PyType_Ready(&EqualToChainingTimeStampUP1D_Type) < 0) { return -1; } - Py_INCREF(&EqualToChainingTimeStampUP1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "EqualToChainingTimeStampUP1D", (PyObject *)&EqualToChainingTimeStampUP1D_Type); if (PyType_Ready(&EqualToTimeStampUP1D_Type) < 0) { return -1; } - Py_INCREF(&EqualToTimeStampUP1D_Type); - PyModule_AddObject(module, "EqualToTimeStampUP1D", (PyObject *)&EqualToTimeStampUP1D_Type); + PyModule_AddObjectRef(module, "EqualToTimeStampUP1D", (PyObject *)&EqualToTimeStampUP1D_Type); if (PyType_Ready(&ExternalContourUP1D_Type) < 0) { return -1; } - Py_INCREF(&ExternalContourUP1D_Type); - PyModule_AddObject(module, "ExternalContourUP1D", (PyObject *)&ExternalContourUP1D_Type); + PyModule_AddObjectRef(module, "ExternalContourUP1D", (PyObject *)&ExternalContourUP1D_Type); if (PyType_Ready(&FalseUP1D_Type) < 0) { return -1; } - Py_INCREF(&FalseUP1D_Type); - PyModule_AddObject(module, "FalseUP1D", (PyObject *)&FalseUP1D_Type); + PyModule_AddObjectRef(module, "FalseUP1D", (PyObject *)&FalseUP1D_Type); if (PyType_Ready(&QuantitativeInvisibilityUP1D_Type) < 0) { return -1; } - Py_INCREF(&QuantitativeInvisibilityUP1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "QuantitativeInvisibilityUP1D", (PyObject *)&QuantitativeInvisibilityUP1D_Type); if (PyType_Ready(&ShapeUP1D_Type) < 0) { return -1; } - Py_INCREF(&ShapeUP1D_Type); - PyModule_AddObject(module, "ShapeUP1D", (PyObject *)&ShapeUP1D_Type); + PyModule_AddObjectRef(module, "ShapeUP1D", (PyObject *)&ShapeUP1D_Type); if (PyType_Ready(&TrueUP1D_Type) < 0) { return -1; } - Py_INCREF(&TrueUP1D_Type); - PyModule_AddObject(module, "TrueUP1D", (PyObject *)&TrueUP1D_Type); + PyModule_AddObjectRef(module, "TrueUP1D", (PyObject *)&TrueUP1D_Type); if (PyType_Ready(&WithinImageBoundaryUP1D_Type) < 0) { return -1; } - Py_INCREF(&WithinImageBoundaryUP1D_Type); - PyModule_AddObject(module, "WithinImageBoundaryUP1D", (PyObject *)&WithinImageBoundaryUP1D_Type); + PyModule_AddObjectRef( + module, "WithinImageBoundaryUP1D", (PyObject *)&WithinImageBoundaryUP1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp index f31f9aec7b8..779c1c79b7e 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp @@ -31,8 +31,7 @@ int ViewMap_Init(PyObject *module) if (PyType_Ready(&ViewMap_Type) < 0) { return -1; } - Py_INCREF(&ViewMap_Type); - PyModule_AddObject(module, "ViewMap", (PyObject *)&ViewMap_Type); + PyModule_AddObjectRef(module, "ViewMap", (PyObject *)&ViewMap_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp index 82eb7aa8851..5af10e87acd 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -34,8 +34,7 @@ int ViewShape_Init(PyObject *module) if (PyType_Ready(&ViewShape_Type) < 0) { return -1; } - Py_INCREF(&ViewShape_Type); - PyModule_AddObject(module, "ViewShape", (PyObject *)&ViewShape_Type); + PyModule_AddObjectRef(module, "ViewShape", (PyObject *)&ViewShape_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp index 9ad901fba58..2bd73784fef 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp @@ -41,68 +41,57 @@ int UnaryFunction0DDouble_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DDouble_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DDouble_Type); - PyModule_AddObject(module, "UnaryFunction0DDouble", (PyObject *)&UnaryFunction0DDouble_Type); + PyModule_AddObjectRef(module, "UnaryFunction0DDouble", (PyObject *)&UnaryFunction0DDouble_Type); if (PyType_Ready(&DensityF0D_Type) < 0) { return -1; } - Py_INCREF(&DensityF0D_Type); - PyModule_AddObject(module, "DensityF0D", (PyObject *)&DensityF0D_Type); + PyModule_AddObjectRef(module, "DensityF0D", (PyObject *)&DensityF0D_Type); if (PyType_Ready(&LocalAverageDepthF0D_Type) < 0) { return -1; } - Py_INCREF(&LocalAverageDepthF0D_Type); - PyModule_AddObject(module, "LocalAverageDepthF0D", (PyObject *)&LocalAverageDepthF0D_Type); + PyModule_AddObjectRef(module, "LocalAverageDepthF0D", (PyObject *)&LocalAverageDepthF0D_Type); if (PyType_Ready(&Curvature2DAngleF0D_Type) < 0) { return -1; } - Py_INCREF(&Curvature2DAngleF0D_Type); - PyModule_AddObject(module, "Curvature2DAngleF0D", (PyObject *)&Curvature2DAngleF0D_Type); + PyModule_AddObjectRef(module, "Curvature2DAngleF0D", (PyObject *)&Curvature2DAngleF0D_Type); if (PyType_Ready(&GetProjectedXF0D_Type) < 0) { return -1; } - Py_INCREF(&GetProjectedXF0D_Type); - PyModule_AddObject(module, "GetProjectedXF0D", (PyObject *)&GetProjectedXF0D_Type); + PyModule_AddObjectRef(module, "GetProjectedXF0D", (PyObject *)&GetProjectedXF0D_Type); if (PyType_Ready(&GetProjectedYF0D_Type) < 0) { return -1; } - Py_INCREF(&GetProjectedYF0D_Type); - PyModule_AddObject(module, "GetProjectedYF0D", (PyObject *)&GetProjectedYF0D_Type); + PyModule_AddObjectRef(module, "GetProjectedYF0D", (PyObject *)&GetProjectedYF0D_Type); if (PyType_Ready(&GetProjectedZF0D_Type) < 0) { return -1; } - Py_INCREF(&GetProjectedZF0D_Type); - PyModule_AddObject(module, "GetProjectedZF0D", (PyObject *)&GetProjectedZF0D_Type); + PyModule_AddObjectRef(module, "GetProjectedZF0D", (PyObject *)&GetProjectedZF0D_Type); if (PyType_Ready(&GetXF0D_Type) < 0) { return -1; } - Py_INCREF(&GetXF0D_Type); - PyModule_AddObject(module, "GetXF0D", (PyObject *)&GetXF0D_Type); + PyModule_AddObjectRef(module, "GetXF0D", (PyObject *)&GetXF0D_Type); if (PyType_Ready(&GetYF0D_Type) < 0) { return -1; } - Py_INCREF(&GetYF0D_Type); - PyModule_AddObject(module, "GetYF0D", (PyObject *)&GetYF0D_Type); + PyModule_AddObjectRef(module, "GetYF0D", (PyObject *)&GetYF0D_Type); if (PyType_Ready(&GetZF0D_Type) < 0) { return -1; } - Py_INCREF(&GetZF0D_Type); - PyModule_AddObject(module, "GetZF0D", (PyObject *)&GetZF0D_Type); + PyModule_AddObjectRef(module, "GetZF0D", (PyObject *)&GetZF0D_Type); if (PyType_Ready(&ZDiscontinuityF0D_Type) < 0) { return -1; } - Py_INCREF(&ZDiscontinuityF0D_Type); - PyModule_AddObject(module, "ZDiscontinuityF0D", (PyObject *)&ZDiscontinuityF0D_Type); + PyModule_AddObjectRef(module, "ZDiscontinuityF0D", (PyObject *)&ZDiscontinuityF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp index 484bc04a86e..a8c0ab9b2d0 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp @@ -32,15 +32,13 @@ int UnaryFunction0DEdgeNature_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DEdgeNature_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DEdgeNature_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "UnaryFunction0DEdgeNature", (PyObject *)&UnaryFunction0DEdgeNature_Type); if (PyType_Ready(&CurveNatureF0D_Type) < 0) { return -1; } - Py_INCREF(&CurveNatureF0D_Type); - PyModule_AddObject(module, "CurveNatureF0D", (PyObject *)&CurveNatureF0D_Type); + PyModule_AddObjectRef(module, "CurveNatureF0D", (PyObject *)&CurveNatureF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp index 737cfc3590e..7bc3b339fa9 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp @@ -37,47 +37,40 @@ int UnaryFunction0DFloat_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DFloat_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DFloat_Type); - PyModule_AddObject(module, "UnaryFunction0DFloat", (PyObject *)&UnaryFunction0DFloat_Type); + PyModule_AddObjectRef(module, "UnaryFunction0DFloat", (PyObject *)&UnaryFunction0DFloat_Type); if (PyType_Ready(&GetCurvilinearAbscissaF0D_Type) < 0) { return -1; } - Py_INCREF(&GetCurvilinearAbscissaF0D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "GetCurvilinearAbscissaF0D", (PyObject *)&GetCurvilinearAbscissaF0D_Type); if (PyType_Ready(&GetParameterF0D_Type) < 0) { return -1; } - Py_INCREF(&GetParameterF0D_Type); - PyModule_AddObject(module, "GetParameterF0D", (PyObject *)&GetParameterF0D_Type); + PyModule_AddObjectRef(module, "GetParameterF0D", (PyObject *)&GetParameterF0D_Type); if (PyType_Ready(&GetViewMapGradientNormF0D_Type) < 0) { return -1; } - Py_INCREF(&GetViewMapGradientNormF0D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "GetViewMapGradientNormF0D", (PyObject *)&GetViewMapGradientNormF0D_Type); if (PyType_Ready(&ReadCompleteViewMapPixelF0D_Type) < 0) { return -1; } - Py_INCREF(&ReadCompleteViewMapPixelF0D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "ReadCompleteViewMapPixelF0D", (PyObject *)&ReadCompleteViewMapPixelF0D_Type); if (PyType_Ready(&ReadMapPixelF0D_Type) < 0) { return -1; } - Py_INCREF(&ReadMapPixelF0D_Type); - PyModule_AddObject(module, "ReadMapPixelF0D", (PyObject *)&ReadMapPixelF0D_Type); + PyModule_AddObjectRef(module, "ReadMapPixelF0D", (PyObject *)&ReadMapPixelF0D_Type); if (PyType_Ready(&ReadSteerableViewMapPixelF0D_Type) < 0) { return -1; } - Py_INCREF(&ReadSteerableViewMapPixelF0D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "ReadSteerableViewMapPixelF0D", (PyObject *)&ReadSteerableViewMapPixelF0D_Type); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp index fb8eddc71b5..cfbcb4c57f6 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp @@ -32,14 +32,12 @@ int UnaryFunction0DId_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DId_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DId_Type); - PyModule_AddObject(module, "UnaryFunction0DId", (PyObject *)&UnaryFunction0DId_Type); + PyModule_AddObjectRef(module, "UnaryFunction0DId", (PyObject *)&UnaryFunction0DId_Type); if (PyType_Ready(&ShapeIdF0D_Type) < 0) { return -1; } - Py_INCREF(&ShapeIdF0D_Type); - PyModule_AddObject(module, "ShapeIdF0D", (PyObject *)&ShapeIdF0D_Type); + PyModule_AddObjectRef(module, "ShapeIdF0D", (PyObject *)&ShapeIdF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp index 31c657561c6..95cee2701b9 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -32,14 +32,13 @@ int UnaryFunction0DMaterial_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DMaterial_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DMaterial_Type); - PyModule_AddObject(module, "UnaryFunction0DMaterial", (PyObject *)&UnaryFunction0DMaterial_Type); + PyModule_AddObjectRef( + module, "UnaryFunction0DMaterial", (PyObject *)&UnaryFunction0DMaterial_Type); if (PyType_Ready(&MaterialF0D_Type) < 0) { return -1; } - Py_INCREF(&MaterialF0D_Type); - PyModule_AddObject(module, "MaterialF0D", (PyObject *)&MaterialF0D_Type); + PyModule_AddObjectRef(module, "MaterialF0D", (PyObject *)&MaterialF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp index 1cb4d2a73b4..6948b10b613 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -34,14 +34,13 @@ int UnaryFunction0DUnsigned_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DUnsigned_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DUnsigned_Type); - PyModule_AddObject(module, "UnaryFunction0DUnsigned", (PyObject *)&UnaryFunction0DUnsigned_Type); + PyModule_AddObjectRef( + module, "UnaryFunction0DUnsigned", (PyObject *)&UnaryFunction0DUnsigned_Type); if (PyType_Ready(&QuantitativeInvisibilityF0D_Type) < 0) { return -1; } - Py_INCREF(&QuantitativeInvisibilityF0D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "QuantitativeInvisibilityF0D", (PyObject *)&QuantitativeInvisibilityF0D_Type); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp index 610dee92bd3..ab15ac6b443 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp @@ -33,20 +33,18 @@ int UnaryFunction0DVec2f_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DVec2f_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DVec2f_Type); - PyModule_AddObject(module, "UnaryFunction0DVec2f", (PyObject *)&UnaryFunction0DVec2f_Type); + PyModule_AddObjectRef(module, "UnaryFunction0DVec2f", (PyObject *)&UnaryFunction0DVec2f_Type); if (PyType_Ready(&Normal2DF0D_Type) < 0) { return -1; } - Py_INCREF(&Normal2DF0D_Type); - PyModule_AddObject(module, "Normal2DF0D", (PyObject *)&Normal2DF0D_Type); + PyModule_AddObjectRef(module, "Normal2DF0D", (PyObject *)&Normal2DF0D_Type); if (PyType_Ready(&VertexOrientation2DF0D_Type) < 0) { return -1; } - Py_INCREF(&VertexOrientation2DF0D_Type); - PyModule_AddObject(module, "VertexOrientation2DF0D", (PyObject *)&VertexOrientation2DF0D_Type); + PyModule_AddObjectRef( + module, "VertexOrientation2DF0D", (PyObject *)&VertexOrientation2DF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp index ac578ad82b2..c516a5355d5 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp @@ -32,14 +32,13 @@ int UnaryFunction0DVec3f_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DVec3f_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DVec3f_Type); - PyModule_AddObject(module, "UnaryFunction0DVec3f", (PyObject *)&UnaryFunction0DVec3f_Type); + PyModule_AddObjectRef(module, "UnaryFunction0DVec3f", (PyObject *)&UnaryFunction0DVec3f_Type); if (PyType_Ready(&VertexOrientation3DF0D_Type) < 0) { return -1; } - Py_INCREF(&VertexOrientation3DF0D_Type); - PyModule_AddObject(module, "VertexOrientation3DF0D", (PyObject *)&VertexOrientation3DF0D_Type); + PyModule_AddObjectRef( + module, "VertexOrientation3DF0D", (PyObject *)&VertexOrientation3DF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp index c59de0174b0..3c357a05d66 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp @@ -34,15 +34,13 @@ int UnaryFunction0DVectorViewShape_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DVectorViewShape_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DVectorViewShape_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type); if (PyType_Ready(&GetOccludersF0D_Type) < 0) { return -1; } - Py_INCREF(&GetOccludersF0D_Type); - PyModule_AddObject(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type); + PyModule_AddObjectRef(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp index 03ff4faf396..04317013534 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp @@ -33,21 +33,18 @@ int UnaryFunction0DViewShape_Init(PyObject *module) if (PyType_Ready(&UnaryFunction0DViewShape_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction0DViewShape_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "UnaryFunction0DViewShape", (PyObject *)&UnaryFunction0DViewShape_Type); if (PyType_Ready(&GetOccludeeF0D_Type) < 0) { return -1; } - Py_INCREF(&GetOccludeeF0D_Type); - PyModule_AddObject(module, "GetOccludeeF0D", (PyObject *)&GetOccludeeF0D_Type); + PyModule_AddObjectRef(module, "GetOccludeeF0D", (PyObject *)&GetOccludeeF0D_Type); if (PyType_Ready(&GetShapeF0D_Type) < 0) { return -1; } - Py_INCREF(&GetShapeF0D_Type); - PyModule_AddObject(module, "GetShapeF0D", (PyObject *)&GetShapeF0D_Type); + PyModule_AddObjectRef(module, "GetShapeF0D", (PyObject *)&GetShapeF0D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp index 5d16a81c169..e87b1c79128 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp @@ -46,97 +46,82 @@ int UnaryFunction1DDouble_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DDouble_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DDouble_Type); - PyModule_AddObject(module, "UnaryFunction1DDouble", (PyObject *)&UnaryFunction1DDouble_Type); + PyModule_AddObjectRef(module, "UnaryFunction1DDouble", (PyObject *)&UnaryFunction1DDouble_Type); if (PyType_Ready(&DensityF1D_Type) < 0) { return -1; } - Py_INCREF(&DensityF1D_Type); - PyModule_AddObject(module, "DensityF1D", (PyObject *)&DensityF1D_Type); + PyModule_AddObjectRef(module, "DensityF1D", (PyObject *)&DensityF1D_Type); if (PyType_Ready(&Curvature2DAngleF1D_Type) < 0) { return -1; } - Py_INCREF(&Curvature2DAngleF1D_Type); - PyModule_AddObject(module, "Curvature2DAngleF1D", (PyObject *)&Curvature2DAngleF1D_Type); + PyModule_AddObjectRef(module, "Curvature2DAngleF1D", (PyObject *)&Curvature2DAngleF1D_Type); if (PyType_Ready(&GetCompleteViewMapDensityF1D_Type) < 0) { return -1; } - Py_INCREF(&GetCompleteViewMapDensityF1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "GetCompleteViewMapDensityF1D", (PyObject *)&GetCompleteViewMapDensityF1D_Type); if (PyType_Ready(&GetDirectionalViewMapDensityF1D_Type) < 0) { return -1; } - Py_INCREF(&GetDirectionalViewMapDensityF1D_Type); - PyModule_AddObject(module, - "GetDirectionalViewMapDensityF1D", - (PyObject *)&GetDirectionalViewMapDensityF1D_Type); + PyModule_AddObjectRef(module, + "GetDirectionalViewMapDensityF1D", + (PyObject *)&GetDirectionalViewMapDensityF1D_Type); if (PyType_Ready(&GetProjectedXF1D_Type) < 0) { return -1; } - Py_INCREF(&GetProjectedXF1D_Type); - PyModule_AddObject(module, "GetProjectedXF1D", (PyObject *)&GetProjectedXF1D_Type); + PyModule_AddObjectRef(module, "GetProjectedXF1D", (PyObject *)&GetProjectedXF1D_Type); if (PyType_Ready(&GetProjectedYF1D_Type) < 0) { return -1; } - Py_INCREF(&GetProjectedYF1D_Type); - PyModule_AddObject(module, "GetProjectedYF1D", (PyObject *)&GetProjectedYF1D_Type); + PyModule_AddObjectRef(module, "GetProjectedYF1D", (PyObject *)&GetProjectedYF1D_Type); if (PyType_Ready(&GetProjectedZF1D_Type) < 0) { return -1; } - Py_INCREF(&GetProjectedZF1D_Type); - PyModule_AddObject(module, "GetProjectedZF1D", (PyObject *)&GetProjectedZF1D_Type); + PyModule_AddObjectRef(module, "GetProjectedZF1D", (PyObject *)&GetProjectedZF1D_Type); if (PyType_Ready(&GetSteerableViewMapDensityF1D_Type) < 0) { return -1; } - Py_INCREF(&GetSteerableViewMapDensityF1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "GetSteerableViewMapDensityF1D", (PyObject *)&GetSteerableViewMapDensityF1D_Type); if (PyType_Ready(&GetViewMapGradientNormF1D_Type) < 0) { return -1; } - Py_INCREF(&GetViewMapGradientNormF1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "GetViewMapGradientNormF1D", (PyObject *)&GetViewMapGradientNormF1D_Type); if (PyType_Ready(&GetXF1D_Type) < 0) { return -1; } - Py_INCREF(&GetXF1D_Type); - PyModule_AddObject(module, "GetXF1D", (PyObject *)&GetXF1D_Type); + PyModule_AddObjectRef(module, "GetXF1D", (PyObject *)&GetXF1D_Type); if (PyType_Ready(&GetYF1D_Type) < 0) { return -1; } - Py_INCREF(&GetYF1D_Type); - PyModule_AddObject(module, "GetYF1D", (PyObject *)&GetYF1D_Type); + PyModule_AddObjectRef(module, "GetYF1D", (PyObject *)&GetYF1D_Type); if (PyType_Ready(&GetZF1D_Type) < 0) { return -1; } - Py_INCREF(&GetZF1D_Type); - PyModule_AddObject(module, "GetZF1D", (PyObject *)&GetZF1D_Type); + PyModule_AddObjectRef(module, "GetZF1D", (PyObject *)&GetZF1D_Type); if (PyType_Ready(&LocalAverageDepthF1D_Type) < 0) { return -1; } - Py_INCREF(&LocalAverageDepthF1D_Type); - PyModule_AddObject(module, "LocalAverageDepthF1D", (PyObject *)&LocalAverageDepthF1D_Type); + PyModule_AddObjectRef(module, "LocalAverageDepthF1D", (PyObject *)&LocalAverageDepthF1D_Type); if (PyType_Ready(&ZDiscontinuityF1D_Type) < 0) { return -1; } - Py_INCREF(&ZDiscontinuityF1D_Type); - PyModule_AddObject(module, "ZDiscontinuityF1D", (PyObject *)&ZDiscontinuityF1D_Type); + PyModule_AddObjectRef(module, "ZDiscontinuityF1D", (PyObject *)&ZDiscontinuityF1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp index 416f56c45e0..e123328edd7 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp @@ -33,15 +33,13 @@ int UnaryFunction1DEdgeNature_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DEdgeNature_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DEdgeNature_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "UnaryFunction1DEdgeNature", (PyObject *)&UnaryFunction1DEdgeNature_Type); if (PyType_Ready(&CurveNatureF1D_Type) < 0) { return -1; } - Py_INCREF(&CurveNatureF1D_Type); - PyModule_AddObject(module, "CurveNatureF1D", (PyObject *)&CurveNatureF1D_Type); + PyModule_AddObjectRef(module, "CurveNatureF1D", (PyObject *)&CurveNatureF1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp index e0f22d4a3a9..da48c5be737 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp @@ -31,8 +31,7 @@ int UnaryFunction1DFloat_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DFloat_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DFloat_Type); - PyModule_AddObject(module, "UnaryFunction1DFloat", (PyObject *)&UnaryFunction1DFloat_Type); + PyModule_AddObjectRef(module, "UnaryFunction1DFloat", (PyObject *)&UnaryFunction1DFloat_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp index 53c9db65792..e5125cb6e85 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp @@ -35,14 +35,13 @@ int UnaryFunction1DUnsigned_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DUnsigned_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DUnsigned_Type); - PyModule_AddObject(module, "UnaryFunction1DUnsigned", (PyObject *)&UnaryFunction1DUnsigned_Type); + PyModule_AddObjectRef( + module, "UnaryFunction1DUnsigned", (PyObject *)&UnaryFunction1DUnsigned_Type); if (PyType_Ready(&QuantitativeInvisibilityF1D_Type) < 0) { return -1; } - Py_INCREF(&QuantitativeInvisibilityF1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "QuantitativeInvisibilityF1D", (PyObject *)&QuantitativeInvisibilityF1D_Type); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp index 679f73fe32b..ba67ccf64d6 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp @@ -34,20 +34,17 @@ int UnaryFunction1DVec2f_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DVec2f_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DVec2f_Type); - PyModule_AddObject(module, "UnaryFunction1DVec2f", (PyObject *)&UnaryFunction1DVec2f_Type); + PyModule_AddObjectRef(module, "UnaryFunction1DVec2f", (PyObject *)&UnaryFunction1DVec2f_Type); if (PyType_Ready(&Normal2DF1D_Type) < 0) { return -1; } - Py_INCREF(&Normal2DF1D_Type); - PyModule_AddObject(module, "Normal2DF1D", (PyObject *)&Normal2DF1D_Type); + PyModule_AddObjectRef(module, "Normal2DF1D", (PyObject *)&Normal2DF1D_Type); if (PyType_Ready(&Orientation2DF1D_Type) < 0) { return -1; } - Py_INCREF(&Orientation2DF1D_Type); - PyModule_AddObject(module, "Orientation2DF1D", (PyObject *)&Orientation2DF1D_Type); + PyModule_AddObjectRef(module, "Orientation2DF1D", (PyObject *)&Orientation2DF1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp index f90fbabf3d1..7926afe0ea0 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp @@ -33,14 +33,12 @@ int UnaryFunction1DVec3f_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DVec3f_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DVec3f_Type); - PyModule_AddObject(module, "UnaryFunction1DVec3f", (PyObject *)&UnaryFunction1DVec3f_Type); + PyModule_AddObjectRef(module, "UnaryFunction1DVec3f", (PyObject *)&UnaryFunction1DVec3f_Type); if (PyType_Ready(&Orientation3DF1D_Type) < 0) { return -1; } - Py_INCREF(&Orientation3DF1D_Type); - PyModule_AddObject(module, "Orientation3DF1D", (PyObject *)&Orientation3DF1D_Type); + PyModule_AddObjectRef(module, "Orientation3DF1D", (PyObject *)&Orientation3DF1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp index 54adc1ff29d..66135e58809 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp @@ -37,27 +37,23 @@ int UnaryFunction1DVectorViewShape_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DVectorViewShape_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DVectorViewShape_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "UnaryFunction1DVectorViewShape", (PyObject *)&UnaryFunction1DVectorViewShape_Type); if (PyType_Ready(&GetOccludeeF1D_Type) < 0) { return -1; } - Py_INCREF(&GetOccludeeF1D_Type); - PyModule_AddObject(module, "GetOccludeeF1D", (PyObject *)&GetOccludeeF1D_Type); + PyModule_AddObjectRef(module, "GetOccludeeF1D", (PyObject *)&GetOccludeeF1D_Type); if (PyType_Ready(&GetOccludersF1D_Type) < 0) { return -1; } - Py_INCREF(&GetOccludersF1D_Type); - PyModule_AddObject(module, "GetOccludersF1D", (PyObject *)&GetOccludersF1D_Type); + PyModule_AddObjectRef(module, "GetOccludersF1D", (PyObject *)&GetOccludersF1D_Type); if (PyType_Ready(&GetShapeF1D_Type) < 0) { return -1; } - Py_INCREF(&GetShapeF1D_Type); - PyModule_AddObject(module, "GetShapeF1D", (PyObject *)&GetShapeF1D_Type); + PyModule_AddObjectRef(module, "GetShapeF1D", (PyObject *)&GetShapeF1D_Type); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp index de60aeaef70..49efb7aa31b 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp @@ -35,27 +35,23 @@ int UnaryFunction1DVoid_Init(PyObject *module) if (PyType_Ready(&UnaryFunction1DVoid_Type) < 0) { return -1; } - Py_INCREF(&UnaryFunction1DVoid_Type); - PyModule_AddObject(module, "UnaryFunction1DVoid", (PyObject *)&UnaryFunction1DVoid_Type); + PyModule_AddObjectRef(module, "UnaryFunction1DVoid", (PyObject *)&UnaryFunction1DVoid_Type); if (PyType_Ready(&ChainingTimeStampF1D_Type) < 0) { return -1; } - Py_INCREF(&ChainingTimeStampF1D_Type); - PyModule_AddObject(module, "ChainingTimeStampF1D", (PyObject *)&ChainingTimeStampF1D_Type); + PyModule_AddObjectRef(module, "ChainingTimeStampF1D", (PyObject *)&ChainingTimeStampF1D_Type); if (PyType_Ready(&IncrementChainingTimeStampF1D_Type) < 0) { return -1; } - Py_INCREF(&IncrementChainingTimeStampF1D_Type); - PyModule_AddObject( + PyModule_AddObjectRef( module, "IncrementChainingTimeStampF1D", (PyObject *)&IncrementChainingTimeStampF1D_Type); if (PyType_Ready(&TimeStampF1D_Type) < 0) { return -1; } - Py_INCREF(&TimeStampF1D_Type); - PyModule_AddObject(module, "TimeStampF1D", (PyObject *)&TimeStampF1D_Type); + PyModule_AddObjectRef(module, "TimeStampF1D", (PyObject *)&TimeStampF1D_Type); return 0; } diff --git a/source/blender/python/generic/bgl.cc b/source/blender/python/generic/bgl.cc index dc5fedf6e5a..77ee1bd86f6 100644 --- a/source/blender/python/generic/bgl.cc +++ b/source/blender/python/generic/bgl.cc @@ -2679,8 +2679,7 @@ PyObject *BPyInit_bgl() UNUSED_VARS(LOG); #endif - PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType); - Py_INCREF((PyObject *)&BGL_bufferType); + PyModule_AddObjectRef(submodule, "Buffer", (PyObject *)&BGL_bufferType); init_bgl_version_1_0_methods(submodule, dict); init_bgl_version_1_1_methods(submodule, dict); diff --git a/source/blender/python/generic/py_capi_utils.cc b/source/blender/python/generic/py_capi_utils.cc index b0d40ebd4b1..0f17dcf24ce 100644 --- a/source/blender/python/generic/py_capi_utils.cc +++ b/source/blender/python/generic/py_capi_utils.cc @@ -1124,9 +1124,8 @@ PyObject *PyC_DefaultNameSpace(const char *filename) * In this case an identifier is typically used that is surrounded by angle-brackets. * It's mainly helpful for the UI and messages to show *something*. */ PyModule_AddObject(mod_main, "__file__", PyC_UnicodeFromBytes(filename)); + PyModule_AddObjectRef(mod_main, "__builtins__", builtins); - PyModule_AddObject(mod_main, "__builtins__", builtins); - Py_INCREF(builtins); /* AddObject steals a reference */ return PyModule_GetDict(mod_main); }