17
17
objc .objc_getClass .restype = void_p
18
18
objc .sel_registerName .restype = void_p
19
19
objc .objc_msgSend .restype = void_p
20
- objc .objc_msgSend .argtypes = [void_p , void_p ]
21
20
22
21
msg = objc .objc_msgSend
23
22
@@ -80,11 +79,25 @@ def C(classname):
80
79
81
80
def _NSApp ():
82
81
"""Return the global NSApplication instance (NSApp)"""
82
+ objc .objc_msgSend .argtypes = [void_p , void_p ]
83
83
return msg (C ("NSApplication" ), n ("sharedApplication" ))
84
84
85
85
86
86
def _wake (NSApp ):
87
87
"""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
+ ]
88
101
event = msg (
89
102
C ("NSEvent" ),
90
103
n (
@@ -101,6 +114,7 @@ def _wake(NSApp):
101
114
0 , # data1
102
115
0 , # data2
103
116
)
117
+ objc .objc_msgSend .argtypes = [void_p , void_p , void_p , void_p ]
104
118
msg (NSApp , n ("postEvent:atStart:" ), void_p (event ), True )
105
119
106
120
@@ -113,7 +127,9 @@ def stop(timer=None, loop=None):
113
127
NSApp = _NSApp ()
114
128
# if NSApp is not running, stop CFRunLoop directly,
115
129
# otherwise stop and wake NSApp
130
+ objc .objc_msgSend .argtypes = [void_p , void_p ]
116
131
if msg (NSApp , n ("isRunning" )):
132
+ objc .objc_msgSend .argtypes = [void_p , void_p , void_p ]
117
133
msg (NSApp , n ("stop:" ), NSApp )
118
134
_wake (NSApp )
119
135
else :
@@ -148,6 +164,7 @@ def mainloop(duration=1):
148
164
_triggered .clear ()
149
165
NSApp = _NSApp ()
150
166
_stop_after (duration )
167
+ objc .objc_msgSend .argtypes = [void_p , void_p ]
151
168
msg (NSApp , n ("run" ))
152
169
if not _triggered .is_set ():
153
170
# app closed without firing callback,
0 commit comments