@@ -501,13 +501,12 @@ typedef struct {
501501 PyObject_HEAD Uint64 last_tick , fps_count , fps_tick ;
502502 float fps ;
503503 Uint64 timepassed , rawpassed ;
504- } PyClockObject ;
504+ } pgClockObject ;
505505
506506// to be called by the other tick functions.
507507static PyObject *
508- clock_tick_base (PyObject * self , PyObject * arg , int use_accurate_delay )
508+ clock_tick_base (pgClockObject * self , PyObject * arg , int use_accurate_delay )
509509{
510- PyClockObject * _clock = (PyClockObject * )self ;
511510 float framerate = 0.0f ;
512511 Uint64 nowtime ;
513512
@@ -516,8 +515,8 @@ clock_tick_base(PyObject *self, PyObject *arg, int use_accurate_delay)
516515
517516 if (framerate ) {
518517 Sint64 delay , endtime = (Sint64 )((1.0f / framerate ) * 1000.0f );
519- _clock -> rawpassed = PG_GetTicks () - _clock -> last_tick ;
520- delay = endtime - _clock -> rawpassed ;
518+ self -> rawpassed = PG_GetTicks () - self -> last_tick ;
519+ delay = endtime - self -> rawpassed ;
521520
522521 /*just doublecheck that timer is initialized*/
523522 if (!SDL_WasInit (SDL_INIT_TIMER )) {
@@ -543,66 +542,65 @@ clock_tick_base(PyObject *self, PyObject *arg, int use_accurate_delay)
543542 }
544543
545544 nowtime = PG_GetTicks ();
546- _clock -> timepassed = nowtime - _clock -> last_tick ;
547- _clock -> fps_count += 1 ;
548- _clock -> last_tick = nowtime ;
545+ self -> timepassed = nowtime - self -> last_tick ;
546+ self -> fps_count += 1 ;
547+ self -> last_tick = nowtime ;
549548 if (!framerate )
550- _clock -> rawpassed = _clock -> timepassed ;
549+ self -> rawpassed = self -> timepassed ;
551550
552- if (!_clock -> fps_tick ) {
553- _clock -> fps_count = 0 ;
554- _clock -> fps_tick = nowtime ;
551+ if (!self -> fps_tick ) {
552+ self -> fps_count = 0 ;
553+ self -> fps_tick = nowtime ;
555554 }
556- else if (_clock -> fps_count >= 10 ) {
557- _clock -> fps =
558- _clock -> fps_count / ((nowtime - _clock -> fps_tick ) / 1000.0f );
559- _clock -> fps_count = 0 ;
560- _clock -> fps_tick = nowtime ;
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 ;
561559 }
562- return PyLong_FromUnsignedLongLong (_clock -> timepassed );
560+ return PyLong_FromUnsignedLongLong (self -> timepassed );
563561}
564562
565563static PyObject *
566- clock_tick (PyObject * self , PyObject * arg )
564+ clock_tick (pgClockObject * self , PyObject * arg )
567565{
568566 return clock_tick_base (self , arg , 0 );
569567}
570568
571569static PyObject *
572- clock_tick_busy_loop (PyObject * self , PyObject * arg )
570+ clock_tick_busy_loop (pgClockObject * self , PyObject * arg )
573571{
574572 return clock_tick_base (self , arg , 1 );
575573}
576574
577575static PyObject *
578- clock_get_fps (PyObject * self , PyObject * _null )
576+ clock_get_fps (pgClockObject * self , PyObject * _null )
579577{
580- PyClockObject * _clock = (PyClockObject * )self ;
581- return PyFloat_FromDouble (_clock -> fps );
578+ return PyFloat_FromDouble (self -> fps );
582579}
583580
584581static PyObject *
585- clock_get_time (PyObject * self , PyObject * _null )
582+ clock_get_time (pgClockObject * self , PyObject * _null )
586583{
587- PyClockObject * _clock = (PyClockObject * )self ;
588- return PyLong_FromUnsignedLongLong (_clock -> timepassed );
584+ return PyLong_FromUnsignedLongLong (self -> timepassed );
589585}
590586
591587static PyObject *
592- clock_get_rawtime (PyObject * self , PyObject * _null )
588+ clock_get_rawtime (pgClockObject * self , PyObject * _null )
593589{
594- PyClockObject * _clock = (PyClockObject * )self ;
595- return PyLong_FromUnsignedLongLong (_clock -> rawpassed );
590+ return PyLong_FromUnsignedLongLong (self -> rawpassed );
596591}
597592
598593/* clock object internals */
599594
600595static struct PyMethodDef clock_methods [] = {
601- {"tick" , clock_tick , METH_VARARGS , DOC_TIME_CLOCK_TICK },
602- {"get_fps" , clock_get_fps , METH_NOARGS , DOC_TIME_CLOCK_GETFPS },
603- {"get_time" , clock_get_time , METH_NOARGS , DOC_TIME_CLOCK_GETTIME },
604- {"get_rawtime" , clock_get_rawtime , METH_NOARGS , DOC_TIME_CLOCK_GETRAWTIME },
605- {"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 ,
606604 DOC_TIME_CLOCK_TICKBUSYLOOP },
607605 {NULL , NULL , 0 , NULL }};
608606
@@ -613,12 +611,11 @@ clock_dealloc(PyObject *self)
613611}
614612
615613PyObject *
616- clock_str (PyObject * self )
614+ clock_str (pgClockObject * self )
617615{
618616 char str [64 ];
619- PyClockObject * _clock = (PyClockObject * )self ;
620617
621- int ret = PyOS_snprintf (str , 64 , "<Clock(fps=%.2f)>" , _clock -> fps );
618+ int ret = PyOS_snprintf (str , 64 , "<Clock(fps=%.2f)>" , self -> fps );
622619 if (ret < 0 || ret >= 64 ) {
623620 return RAISE (PyExc_RuntimeError ,
624621 "Internal PyOS_snprintf call failed!" );
@@ -644,7 +641,7 @@ clock_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
644641 }
645642 }
646643
647- PyClockObject * self = (PyClockObject * )(type -> tp_alloc (type , 0 ));
644+ pgClockObject * self = (pgClockObject * )(type -> tp_alloc (type , 0 ));
648645 self -> fps_tick = 0 ;
649646 self -> timepassed = 0 ;
650647 self -> rawpassed = 0 ;
@@ -657,10 +654,10 @@ clock_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
657654
658655static PyTypeObject PyClock_Type = {
659656 PyVarObject_HEAD_INIT (NULL , 0 ).tp_name = "pygame.time.Clock" ,
660- .tp_basicsize = sizeof (PyClockObject ),
657+ .tp_basicsize = sizeof (pgClockObject ),
661658 .tp_dealloc = clock_dealloc ,
662- .tp_repr = clock_str ,
663- .tp_str = clock_str ,
659+ .tp_repr = ( reprfunc ) clock_str ,
660+ .tp_str = ( reprfunc ) clock_str ,
664661 .tp_doc = DOC_TIME_CLOCK ,
665662 .tp_methods = clock_methods ,
666663 .tp_new = clock_new ,
0 commit comments