@@ -4625,9 +4625,7 @@ MODINIT_DEFINE(pg_math)
46254625MODINIT_DEFINE (math )
46264626#endif
46274627{
4628- PyObject * module , * apiobj ;
4629- static void * c_api [PYGAMEAPI_MATH_NUMSLOTS ];
4630-
4628+ PyObject * module ;
46314629 static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT ,
46324630 "math" ,
46334631 DOC_MATH ,
@@ -4638,14 +4636,6 @@ MODINIT_DEFINE(math)
46384636 NULL ,
46394637 NULL };
46404638
4641- /* initialize the extension types */
4642- if ((PyType_Ready (& pgVector2_Type ) < 0 ) ||
4643- (PyType_Ready (& pgVector3_Type ) < 0 ) ||
4644- (PyType_Ready (& pgVectorIter_Type ) < 0 ) ||
4645- (PyType_Ready (& pgVectorElementwiseProxy_Type ) < 0 )) {
4646- return NULL ;
4647- }
4648-
46494639 /* initialize the module */
46504640 module = PyModule_Create (& _module );
46514641
@@ -4654,29 +4644,10 @@ MODINIT_DEFINE(math)
46544644 }
46554645
46564646 /* add extension types to module */
4657- if ((PyModule_AddObjectRef (module , "Vector2" ,
4658- (PyObject * )& pgVector2_Type ) < 0 ) ||
4659- (PyModule_AddObjectRef (module , "Vector3" ,
4660- (PyObject * )& pgVector3_Type ) < 0 ) ||
4661- (PyModule_AddObjectRef (module , "VectorElementwiseProxy" ,
4662- (PyObject * )& pgVectorElementwiseProxy_Type ) <
4663- 0 ) ||
4664- (PyModule_AddObjectRef (module , "VectorIterator" ,
4665- (PyObject * )& pgVectorIter_Type ) < 0 )) {
4666- Py_DECREF (module );
4667- return NULL ;
4668- }
4669-
4670- /* export the C api */
4671- c_api [0 ] = & pgVector2_Type ;
4672- c_api [1 ] = & pgVector3_Type ;
4673- /*
4674- c_api[2] = pgVector_NEW;
4675- c_api[3] = pgVectorCompatible_Check;
4676- */
4677- apiobj = encapsulate_api (c_api , "math" );
4678- if (PyModule_AddObject (module , PYGAMEAPI_LOCAL_ENTRY , apiobj )) {
4679- Py_XDECREF (apiobj );
4647+ if ((PyModule_AddType (module , & pgVector2_Type ) < 0 ) ||
4648+ (PyModule_AddType (module , & pgVector3_Type ) < 0 ) ||
4649+ (PyModule_AddType (module , & pgVectorElementwiseProxy_Type ) < 0 ) ||
4650+ (PyModule_AddType (module , & pgVectorIter_Type ) < 0 )) {
46804651 Py_DECREF (module );
46814652 return NULL ;
46824653 }
0 commit comments