forked from microsoft/python-type-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcocoapy.pyi
More file actions
435 lines (353 loc) · 12.7 KB
/
cocoapy.pyi
File metadata and controls
435 lines (353 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
import platform
import struct
import sys
from ctypes import (
CFUNCTYPE,
POINTER,
ArgumentError,
Structure,
alignment,
byref,
c_bool,
c_buffer,
c_byte,
c_char,
c_char_p,
c_double,
c_float,
c_int,
c_int8,
c_int16,
c_int32,
c_int64,
c_long,
c_longdouble,
c_longlong,
c_short,
c_size_t,
c_ubyte,
c_uint,
c_uint8,
c_uint32,
c_ulong,
c_ulonglong,
c_ushort,
c_void_p,
c_wchar,
cast,
cdll,
py_object,
sizeof,
util,
)
# Based on Pyglet code
##############################################################################
# cocoatypes.py
__LP64__ = ...
__i386__ = ...
PyObjectEncoding: str = ...
def encoding_for_ctype(vartype): ...
NSIntegerEncoding = ...
NSUIntegerEncoding = ...
CGFloatEncoding = ...
CGImageEncoding: str = ...
NSZoneEncoding: str = ...
class NSPoint(Structure):
_fields_: list = ...
CGPoint = NSPoint
class NSSize(Structure):
_fields_: list = ...
CGSize = NSSize
class NSRect(Structure):
_fields_: list = ...
CGRect = NSRect
NSTimeInterval = ...
CFIndex = ...
UniChar = ...
unichar = ...
CGGlyph = ...
class CFRange(Structure):
_fields_: list = ...
class NSRange(Structure):
_fields_: list = ...
CFTypeID = ...
CFNumberType = ...
##############################################################################
# runtime.py
__LP64__ = ...
__i386__ = ...
objc = ...
class OBJC_METHOD_DESCRIPTION(Structure):
_fields_ = ...
def ensure_bytes(x): ...
def get_selector(name): ...
def get_class(name): ...
def get_object_class(obj): ...
def get_metaclass(name): ...
def get_superclass_of_object(obj): ...
def x86_should_use_stret(restype): ...
def should_use_fpret(restype): ...
def send_message(receiver, selName, *args, **kwargs): ...
class OBJC_SUPER(Structure):
_fields_: list = ...
OBJC_SUPER_PTR = ...
def send_super(receiver, selName, *args, **kwargs): ...
cfunctype_table: dict = ...
def parse_type_encoding(encoding): ...
def cfunctype_for_encoding(encoding): ...
def create_subclass(superclass, name): ...
def register_subclass(subclass): ...
def add_method(cls, selName, method, types): ...
def add_ivar(cls, name, vartype): ...
def set_instance_variable(obj, varname, value, vartype): ...
def get_instance_variable(obj, varname, vartype): ...
class ObjCMethod:
typecodes: dict = ...
cfunctype_table: dict = ...
def __init__(self, method): ...
def ctype_for_encoding(self, encoding): ...
def get_prototype(self): ...
def __repr__(self): ...
def get_callable(self): ...
def __call__(self, objc_id, *args): ...
class ObjCBoundMethod:
def __init__(self, method, objc_id): ...
def __repr__(self): ...
def __call__(self, *args): ...
class ObjCClass:
_registered_classes: dict = ...
def __new__(cls, class_name_or_ptr): ...
def __repr__(self): ...
def cache_instance_methods(self): ...
def cache_class_methods(self): ...
def get_instance_method(self, name): ...
def get_class_method(self, name): ...
def __getattr__(self, name): ...
class ObjCInstance:
_cached_objects: dict = ...
def __new__(cls, object_ptr): ...
def __repr__(self): ...
def __getattr__(self, name): ...
def convert_method_arguments(encoding, args): ...
class ObjCSubclass:
def __init__(self, superclass, name, register=True): ...
def register(self): ...
def add_ivar(self, varname, vartype): ...
def add_method(self, method, name, encoding): ...
def add_class_method(self, method, name, encoding): ...
def rawmethod(self, encoding): ...
def method(self, encoding): ...
def classmethod(self, encoding): ...
# XXX This causes segfaults in all backends (yikes!), and makes it so that
# pyglet can't even be loaded. We'll just have to live with leaks for now,
# which is probably alright since we only use the
# NSFontManager.sharedFontManager class currently.
# class DeallocationObserver_Implementation(object):
# DeallocationObserver = ObjCSubclass('NSObject', 'DeallocationObserver',
# register=False)
# DeallocationObserver.add_ivar('observed_object', c_void_p)
# DeallocationObserver.register()
#
# @DeallocationObserver.rawmethod('@@')
# def initWithObject_(self, cmd, anObject):
# self = send_super(self, 'init')
# self = self.value
# set_instance_variable(self, 'observed_object', anObject, c_void_p)
# return self
#
# @DeallocationObserver.rawmethod('v')
# def dealloc(self, cmd):
# anObject = get_instance_variable(self, 'observed_object', c_void_p)
# ObjCInstance._cached_objects.pop(anObject, None)
# send_super(self, 'dealloc')
#
# @DeallocationObserver.rawmethod('v')
# def finalize(self, cmd):
# anObject = get_instance_variable(self, 'observed_object', c_void_p)
# ObjCInstance._cached_objects.pop(anObject, None)
# send_super(self, 'finalize')
##############################################################################
# cocoalibs.py
cf = ...
kCFStringEncodingUTF8: int = ...
CFAllocatorRef = ...
CFStringEncoding = ...
def CFSTR(string): ...
def get_NSString(string): ...
def cfstring_to_string(cfstring): ...
# CFNumber.h
kCFNumberSInt8Type: int = ...
kCFNumberSInt16Type: int = ...
kCFNumberSInt32Type: int = ...
kCFNumberSInt64Type: int = ...
kCFNumberFloat32Type: int = ...
kCFNumberFloat64Type: int = ...
kCFNumberCharType: int = ...
kCFNumberShortType: int = ...
kCFNumberIntType: int = ...
kCFNumberLongType: int = ...
kCFNumberLongLongType: int = ...
kCFNumberFloatType: int = ...
kCFNumberDoubleType: int = ...
kCFNumberCFIndexType: int = ...
kCFNumberNSIntegerType: int = ...
kCFNumberCGFloatType: int = ...
kCFNumberMaxType: int = ...
def cfnumber_to_number(cfnumber): ...
# Dictionary of cftypes matched to the method converting them to python values.
known_cftypes: dict = ...
def cftype_to_value(cftype): ...
def cfset_to_set(cfset): ...
def cfarray_to_list(cfarray): ...
kCFRunLoopDefaultMode = ...
######################################################################
# APPLICATION KIT
# Even though we don't use this directly, it must be loaded so that
# we can find the NSApplication, NSWindow, and NSView classes.
appkit = ...
NSDefaultRunLoopMode = ...
NSEventTrackingRunLoopMode = ...
NSApplicationDidHideNotification = ...
NSApplicationDidUnhideNotification = ...
# /System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h
# NSAnyEventMask = 0xFFFFFFFFL # NSUIntegerMax
# Commented out b/c not Py3k compatible
NSKeyDown: int = ...
NSKeyUp: int = ...
NSFlagsChanged: int = ...
NSApplicationDefined: int = ...
NSAlphaShiftKeyMask = ...
NSShiftKeyMask = ...
NSControlKeyMask = ...
NSAlternateKeyMask = ...
NSCommandKeyMask = ...
NSNumericPadKeyMask = ...
NSHelpKeyMask = ...
NSFunctionKeyMask = ...
NSInsertFunctionKey: int = ...
NSDeleteFunctionKey: int = ...
NSHomeFunctionKey: int = ...
NSBeginFunctionKey: int = ...
NSEndFunctionKey: int = ...
NSPageUpFunctionKey: int = ...
NSPageDownFunctionKey: int = ...
# /System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h
NSBorderlessWindowMask: int = ...
NSTitledWindowMask = ...
NSClosableWindowMask = ...
NSMiniaturizableWindowMask = ...
NSResizableWindowMask = ...
# /System/Library/Frameworks/AppKit.framework/Headers/NSPanel.h
NSUtilityWindowMask = ...
# /System/Library/Frameworks/AppKit.framework/Headers/NSGraphics.h
NSBackingStoreRetained: int = ...
NSBackingStoreNonretained: int = ...
NSBackingStoreBuffered: int = ...
# /System/Library/Frameworks/AppKit.framework/Headers/NSTrackingArea.h
NSTrackingMouseEnteredAndExited: int = ...
NSTrackingMouseMoved: int = ...
NSTrackingCursorUpdate: int = ...
NSTrackingActiveInActiveApp: int = ...
# /System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h
NSOpenGLPFAAllRenderers: int = ... # choose from all available renderers
NSOpenGLPFADoubleBuffer: int = ... # choose a double buffered pixel format
NSOpenGLPFAStereo: int = ... # stereo buffering supported
NSOpenGLPFAAuxBuffers: int = ... # number of aux buffers
NSOpenGLPFAColorSize: int = ... # number of color buffer bits
NSOpenGLPFAAlphaSize: int = ... # number of alpha component bits
NSOpenGLPFADepthSize: int = ... # number of depth buffer bits
NSOpenGLPFAStencilSize: int = ... # number of stencil buffer bits
NSOpenGLPFAAccumSize: int = ... # number of accum buffer bits
NSOpenGLPFAMinimumPolicy: int = ... # never choose smaller buffers than requested
NSOpenGLPFAMaximumPolicy: int = ... # choose largest buffers of type requested
NSOpenGLPFAOffScreen: int = ... # choose an off-screen capable renderer
NSOpenGLPFAFullScreen: int = ... # choose a full-screen capable renderer
NSOpenGLPFASampleBuffers: int = ... # number of multi sample buffers
NSOpenGLPFASamples: int = ... # number of samples per multi sample buffer
NSOpenGLPFAAuxDepthStencil: int = ... # each aux buffer has its own depth stencil
NSOpenGLPFAColorFloat: int = ... # color buffers store floating point pixels
NSOpenGLPFAMultisample: int = ... # choose multisampling
NSOpenGLPFASupersample: int = ... # choose supersampling
NSOpenGLPFASampleAlpha: int = ... # request alpha filtering
NSOpenGLPFARendererID: int = ... # request renderer by ID
NSOpenGLPFASingleRenderer: int = ... # choose a single renderer for all screens
NSOpenGLPFANoRecovery: int = ... # disable all failure recovery systems
NSOpenGLPFAAccelerated: int = ... # choose a hardware accelerated renderer
NSOpenGLPFAClosestPolicy: int = ... # choose the closest color buffer to request
NSOpenGLPFARobust: int = ... # renderer does not need failure recovery
NSOpenGLPFABackingStore: int = ... # back buffer contents are valid after swap
NSOpenGLPFAMPSafe: int = ... # renderer is multi-processor safe
NSOpenGLPFAWindow: int = ... # can be used to render to an onscreen window
NSOpenGLPFAMultiScreen: int = ... # single window can span multiple screens
NSOpenGLPFACompliant: int = ... # renderer is opengl compliant
NSOpenGLPFAScreenMask: int = ... # bit mask of supported physical screens
NSOpenGLPFAPixelBuffer: int = ... # can be used to render to a pbuffer
# can be used to render offline to a pbuffer
NSOpenGLPFARemotePixelBuffer: int = ...
NSOpenGLPFAAllowOfflineRenderers: int = ... # allow use of offline renderers
# choose a hardware accelerated compute device
NSOpenGLPFAAcceleratedCompute: int = ...
# number of virtual screens in this format
NSOpenGLPFAVirtualScreenCount: int = ...
NSOpenGLCPSwapInterval: int = ...
# /System/Library/Frameworks/ApplicationServices.framework/Frameworks/...
# CoreGraphics.framework/Headers/CGImage.h
kCGImageAlphaNone: int = ...
kCGImageAlphaPremultipliedLast: int = ...
kCGImageAlphaPremultipliedFirst: int = ...
kCGImageAlphaLast: int = ...
kCGImageAlphaFirst: int = ...
kCGImageAlphaNoneSkipLast: int = ...
kCGImageAlphaNoneSkipFirst: int = ...
kCGImageAlphaOnly: int = ...
kCGBitmapAlphaInfoMask: int = ...
kCGBitmapFloatComponents = ...
kCGBitmapByteOrderMask: int = ...
kCGBitmapByteOrderDefault = ...
kCGBitmapByteOrder16Little = ...
kCGBitmapByteOrder32Little = ...
kCGBitmapByteOrder16Big = ...
kCGBitmapByteOrder32Big = ...
# NSApplication.h
NSApplicationPresentationDefault: int = ...
NSApplicationPresentationHideDock = ...
NSApplicationPresentationHideMenuBar = ...
NSApplicationPresentationDisableProcessSwitching = ...
NSApplicationPresentationDisableHideApplication = ...
# NSRunningApplication.h
NSApplicationActivationPolicyRegular: int = ...
NSApplicationActivationPolicyAccessory: int = ...
NSApplicationActivationPolicyProhibited: int = ...
######################################################################
# QUARTZ / COREGRAPHICS
quartz = ...
CGDirectDisplayID = ... # CGDirectDisplay.h
CGError = ... # CGError.h
CGBitmapInfo = ... # CGImage.h
# /System/Library/Frameworks/ApplicationServices.framework/Frameworks/...
# ImageIO.framework/Headers/CGImageProperties.h
kCGImagePropertyGIFDictionary = ...
kCGImagePropertyGIFDelayTime = ...
# /System/Library/Frameworks/ApplicationServices.framework/Frameworks/...
# CoreGraphics.framework/Headers/CGColorSpace.h
kCGRenderingIntentDefault: int = ...
######################################################################
# CORETEXT
ct = ...
# Types
CTFontOrientation = ... # CTFontDescriptor.h
CTFontSymbolicTraits = ... # CTFontTraits.h
# CoreText constants
kCTFontAttributeName = ...
kCTFontFamilyNameAttribute = ...
kCTFontSymbolicTrait = ...
kCTFontWeightTrait = ...
kCTFontTraitsAttribute = ...
# constants from CTFontTraits.h
kCTFontItalicTrait = ...
kCTFontBoldTrait = ...
######################################################################
# FOUNDATION
# foundation = cdll.LoadLibrary(util.find_library('Foundation'))
# foundation.NSMouseInRect.restype = c_bool
# foundation.NSMouseInRect.argtypes = [NSPoint, NSRect, c_bool]