@@ -501,14 +501,12 @@ typedef struct {
501501 PyObject_HEAD Uint64 last_tick , fps_count , fps_tick ;
502502 float fps ;
503503 Uint64 timepassed , rawpassed ;
504- PyObject * rendered ;
505- } PyClockObject ;
504+ } pgClockObject ;
506505
507506// to be called by the other tick functions.
508507static PyObject *
509- clock_tick_base (PyObject * self , PyObject * arg , int use_accurate_delay )
508+ clock_tick_base (pgClockObject * self , PyObject * arg , int use_accurate_delay )
510509{
511- PyClockObject * _clock = (PyClockObject * )self ;
512510 float framerate = 0.0f ;
513511 Uint64 nowtime ;
514512
@@ -517,8 +515,8 @@ clock_tick_base(PyObject *self, PyObject *arg, int use_accurate_delay)
517515
518516 if (framerate ) {
519517 Sint64 delay , endtime = (Sint64 )((1.0f / framerate ) * 1000.0f );
520- _clock -> rawpassed = PG_GetTicks () - _clock -> last_tick ;
521- delay = endtime - _clock -> rawpassed ;
518+ self -> rawpassed = PG_GetTicks () - self -> last_tick ;
519+ delay = endtime - self -> rawpassed ;
522520
523521 /*just doublecheck that timer is initialized*/
524522 if (!SDL_WasInit (SDL_INIT_TIMER )) {
@@ -544,85 +542,80 @@ clock_tick_base(PyObject *self, PyObject *arg, int use_accurate_delay)
544542 }
545543
546544 nowtime = PG_GetTicks ();
547- _clock -> timepassed = nowtime - _clock -> last_tick ;
548- _clock -> fps_count += 1 ;
549- _clock -> last_tick = nowtime ;
545+ self -> timepassed = nowtime - self -> last_tick ;
546+ self -> fps_count += 1 ;
547+ self -> last_tick = nowtime ;
550548 if (!framerate )
551- _clock -> rawpassed = _clock -> timepassed ;
549+ self -> rawpassed = self -> timepassed ;
552550
553- if (!_clock -> fps_tick ) {
554- _clock -> fps_count = 0 ;
555- _clock -> fps_tick = nowtime ;
551+ if (!self -> fps_tick ) {
552+ self -> fps_count = 0 ;
553+ self -> fps_tick = nowtime ;
556554 }
557- else if (_clock -> fps_count >= 10 ) {
558- _clock -> fps =
559- _clock -> fps_count / ((nowtime - _clock -> fps_tick ) / 1000.0f );
560- _clock -> fps_count = 0 ;
561- _clock -> fps_tick = nowtime ;
562- Py_XDECREF (_clock -> rendered );
555+ else if (self -> fps_count >= 10 ) {
556+ self -> fps = self -> fps_count / ((nowtime - self -> fps_tick ) / 1000.0f );
557+ self -> fps_count = 0 ;
558+ self -> fps_tick = nowtime ;
563559 }
564- return PyLong_FromUnsignedLongLong (_clock -> timepassed );
560+ return PyLong_FromUnsignedLongLong (self -> timepassed );
565561}
566562
567563static PyObject *
568- clock_tick (PyObject * self , PyObject * arg )
564+ clock_tick (pgClockObject * self , PyObject * arg )
569565{
570566 return clock_tick_base (self , arg , 0 );
571567}
572568
573569static PyObject *
574- clock_tick_busy_loop (PyObject * self , PyObject * arg )
570+ clock_tick_busy_loop (pgClockObject * self , PyObject * arg )
575571{
576572 return clock_tick_base (self , arg , 1 );
577573}
578574
579575static PyObject *
580- clock_get_fps (PyObject * self , PyObject * _null )
576+ clock_get_fps (pgClockObject * self , PyObject * _null )
581577{
582- PyClockObject * _clock = (PyClockObject * )self ;
583- return PyFloat_FromDouble (_clock -> fps );
578+ return PyFloat_FromDouble (self -> fps );
584579}
585580
586581static PyObject *
587- clock_get_time (PyObject * self , PyObject * _null )
582+ clock_get_time (pgClockObject * self , PyObject * _null )
588583{
589- PyClockObject * _clock = (PyClockObject * )self ;
590- return PyLong_FromUnsignedLongLong (_clock -> timepassed );
584+ return PyLong_FromUnsignedLongLong (self -> timepassed );
591585}
592586
593587static PyObject *
594- clock_get_rawtime (PyObject * self , PyObject * _null )
588+ clock_get_rawtime (pgClockObject * self , PyObject * _null )
595589{
596- PyClockObject * _clock = (PyClockObject * )self ;
597- return PyLong_FromUnsignedLongLong (_clock -> rawpassed );
590+ return PyLong_FromUnsignedLongLong (self -> rawpassed );
598591}
599592
600593/* clock object internals */
601594
602595static struct PyMethodDef clock_methods [] = {
603- {"tick" , clock_tick , METH_VARARGS , DOC_TIME_CLOCK_TICK },
604- {"get_fps" , clock_get_fps , METH_NOARGS , DOC_TIME_CLOCK_GETFPS },
605- {"get_time" , clock_get_time , METH_NOARGS , DOC_TIME_CLOCK_GETTIME },
606- {"get_rawtime" , clock_get_rawtime , METH_NOARGS , DOC_TIME_CLOCK_GETRAWTIME },
607- {"tick_busy_loop" , clock_tick_busy_loop , METH_VARARGS ,
596+ {"tick" , (PyCFunction )clock_tick , METH_VARARGS , DOC_TIME_CLOCK_TICK },
597+ {"get_fps" , (PyCFunction )clock_get_fps , METH_NOARGS ,
598+ DOC_TIME_CLOCK_GETFPS },
599+ {"get_time" , (PyCFunction )clock_get_time , METH_NOARGS ,
600+ DOC_TIME_CLOCK_GETTIME },
601+ {"get_rawtime" , (PyCFunction )clock_get_rawtime , METH_NOARGS ,
602+ DOC_TIME_CLOCK_GETRAWTIME },
603+ {"tick_busy_loop" , (PyCFunction )clock_tick_busy_loop , METH_VARARGS ,
608604 DOC_TIME_CLOCK_TICKBUSYLOOP },
609605 {NULL , NULL , 0 , NULL }};
610606
611607static void
612608clock_dealloc (PyObject * self )
613609{
614- PyClockObject * _clock = (PyClockObject * )self ;
615- Py_XDECREF (_clock -> rendered );
616610 Py_TYPE (self )-> tp_free (self );
617611}
618612
619613PyObject *
620- clock_str (PyObject * self )
614+ clock_str (pgClockObject * self )
621615{
622616 char str [64 ];
623- PyClockObject * _clock = (PyClockObject * )self ;
624617
625- int ret = PyOS_snprintf (str , 64 , "<Clock(fps=%.2f)>" , _clock -> fps );
618+ int ret = PyOS_snprintf (str , 64 , "<Clock(fps=%.2f)>" , self -> fps );
626619 if (ret < 0 || ret >= 64 ) {
627620 return RAISE (PyExc_RuntimeError ,
628621 "Internal PyOS_snprintf call failed!" );
@@ -648,24 +641,23 @@ clock_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
648641 }
649642 }
650643
651- PyClockObject * self = (PyClockObject * )(type -> tp_alloc (type , 0 ));
644+ pgClockObject * self = (pgClockObject * )(type -> tp_alloc (type , 0 ));
652645 self -> fps_tick = 0 ;
653646 self -> timepassed = 0 ;
654647 self -> rawpassed = 0 ;
655648 self -> last_tick = PG_GetTicks ();
656649 self -> fps = 0.0f ;
657650 self -> fps_count = 0 ;
658- self -> rendered = NULL ;
659651
660652 return (PyObject * )self ;
661653}
662654
663655static PyTypeObject PyClock_Type = {
664656 PyVarObject_HEAD_INIT (NULL , 0 ).tp_name = "pygame.time.Clock" ,
665- .tp_basicsize = sizeof (PyClockObject ),
657+ .tp_basicsize = sizeof (pgClockObject ),
666658 .tp_dealloc = clock_dealloc ,
667- .tp_repr = clock_str ,
668- .tp_str = clock_str ,
659+ .tp_repr = ( reprfunc ) clock_str ,
660+ .tp_str = ( reprfunc ) clock_str ,
669661 .tp_doc = DOC_TIME_CLOCK ,
670662 .tp_methods = clock_methods ,
671663 .tp_new = clock_new ,
0 commit comments