1717objc .objc_getClass .restype = void_p
1818objc .sel_registerName .restype = void_p
1919objc .objc_msgSend .restype = void_p
20- objc .objc_msgSend .argtypes = [void_p , void_p ]
2120
2221msg = objc .objc_msgSend
2322
@@ -80,11 +79,25 @@ def C(classname):
8079
8180def _NSApp ():
8281 """Return the global NSApplication instance (NSApp)"""
82+ objc .objc_msgSend .argtypes = [void_p , void_p ]
8383 return msg (C ("NSApplication" ), n ("sharedApplication" ))
8484
8585
8686def _wake (NSApp ):
8787 """Wake the Application"""
88+ objc .objc_msgSend .argtypes = [
89+ void_p ,
90+ void_p ,
91+ void_p ,
92+ void_p ,
93+ void_p ,
94+ void_p ,
95+ void_p ,
96+ void_p ,
97+ void_p ,
98+ void_p ,
99+ void_p ,
100+ ]
88101 event = msg (
89102 C ("NSEvent" ),
90103 n (
@@ -101,6 +114,7 @@ def _wake(NSApp):
101114 0 , # data1
102115 0 , # data2
103116 )
117+ objc .objc_msgSend .argtypes = [void_p , void_p , void_p , void_p ]
104118 msg (NSApp , n ("postEvent:atStart:" ), void_p (event ), True )
105119
106120
@@ -113,7 +127,9 @@ def stop(timer=None, loop=None):
113127 NSApp = _NSApp ()
114128 # if NSApp is not running, stop CFRunLoop directly,
115129 # otherwise stop and wake NSApp
130+ objc .objc_msgSend .argtypes = [void_p , void_p ]
116131 if msg (NSApp , n ("isRunning" )):
132+ objc .objc_msgSend .argtypes = [void_p , void_p , void_p ]
117133 msg (NSApp , n ("stop:" ), NSApp )
118134 _wake (NSApp )
119135 else :
@@ -148,6 +164,7 @@ def mainloop(duration=1):
148164 _triggered .clear ()
149165 NSApp = _NSApp ()
150166 _stop_after (duration )
167+ objc .objc_msgSend .argtypes = [void_p , void_p ]
151168 msg (NSApp , n ("run" ))
152169 if not _triggered .is_set ():
153170 # app closed without firing callback,
0 commit comments