forked from Noitidart/ostypes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathostypes_mac.jsm
1739 lines (1646 loc) · 66.6 KB
/
ostypes_mac.jsm
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var EXPORTED_SYMBOLS = ['ostypes'];
// no need to define core or import cutils as all the globals of the worker who importScripts'ed it are availble here
if (ctypes.voidptr_t.size == 4 /* 32-bit */) {
var is64bit = false;
} else if (ctypes.voidptr_t.size == 8 /* 64-bit */) {
var is64bit = true;
} else {
throw new Error('huh??? not 32 or 64 bit?!?!');
}
var macTypes = function() {
// ABIs
this.CALLBACK_ABI = ctypes.default_abi;
this.ABI = ctypes.default_abi;
////// C TYPES
// SIMPLE TYPES
this.bool = ctypes.bool;
this.char = ctypes.char;
this.float = ctypes.float;
this.int = ctypes.int;
this.int16_t = ctypes.int16_t;
this.int32_t = ctypes.int32_t;
this.int64_t = ctypes.int64_t;
this.intptr_t = ctypes.intptr_t;
this.long = ctypes.long;
this.off_t = ctypes.off_t;
this.pid_t = ctypes.int32_t;
this.short = ctypes.short;
this.size_t = ctypes.size_t;
this.ssize_t = ctypes.ssize_t;
this.uint16_t = ctypes.uint16_t;
this.uint32_t = ctypes.uint32_t;
this.uintptr_t = ctypes.uintptr_t;
this.uint64_t = ctypes.uint64_t;
this.unsigned_char = ctypes.unsigned_char;
this.unsigned_long = ctypes.unsigned_long;
this.unsigned_long_long = ctypes.unsigned_long_long;
this.void = ctypes.void_t;
// ADV C TYPES
this.time_t = this.long; // https://github.com/j4cbo/chiral/blob/3c66a8bb64e541c0f63b04b78ec2d0ffdf5b473c/chiral/os/kqueue.py#L34 AND also based on this github search https://github.com/search?utf8=%E2%9C%93&q=time_t+ctypes&type=Code&ref=searchresults AND based on this answer here: http://stackoverflow.com/a/471287/1828637
// GUESS C TYPES
this.FILE = ctypes.void_t; // not really a guess, i just dont have a need to fill it
// C SIMPLE STRUCTS
var flockHollowStruct = new cutils.HollowStructure('flock', OS.Constants.libc.OSFILE_SIZEOF_FLOCK);
flockHollowStruct.add_field_at(OS.Constants.libc.OSFILE_OFFSETOF_FLOCK_L_WHENCE, 'l_whence', this.short);
flockHollowStruct.add_field_at(OS.Constants.libc.OSFILE_OFFSETOF_FLOCK_L_TYPE, 'l_type', this.short);
flockHollowStruct.add_field_at(OS.Constants.libc.OSFILE_OFFSETOF_FLOCK_L_START, 'l_start', this.off_t);
flockHollowStruct.add_field_at(OS.Constants.libc.OSFILE_OFFSETOF_FLOCK_L_PID, 'l_pid', this.pid_t);
flockHollowStruct.add_field_at(OS.Constants.libc.OSFILE_OFFSETOF_FLOCK_L_LEN, 'l_len', this.off_t);
this.flock = flockHollowStruct.getType().implementation;
////// CoreFoundation TYPES
// SIMPLE TYPES // based on ctypes.BLAH
this.Boolean = ctypes.unsigned_char;
this.CFIndex = ctypes.long;
this.CFOptionFlags = ctypes.unsigned_long;
this.CFTimeInterval = ctypes.double;
this.CFTypeRef = ctypes.voidptr_t;
this.CGDirectDisplayID = ctypes.uint32_t;
this.CGError = ctypes.int32_t;
this.CGEventField = ctypes.uint32_t;
this.CGEventMask = ctypes.uint64_t;
this.CGEventTapLocation = ctypes.uint32_t;
this.CGEventTapOptions = ctypes.uint32_t;
this.CGEventTapPlacement = ctypes.uint32_t;
this.CGEventType = ctypes.uint32_t;
this.CGFloat = is64bit ? ctypes.double : ctypes.float; // ctypes.float is 32bit deosntw ork as of May 10th 2015 see this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1163406 this would cause crash on CGDisplayGetBounds http://stackoverflow.com/questions/28216681/how-can-i-get-screenshot-from-all-displays-on-mac#comment48414568_28247749
this.CGSConnection = ctypes.int;
this.CGSTransitionOption = ctypes.int; // type is enum so i guess int - https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L162
this.CGSTransitionType = ctypes.int; // type is enum so i guess int - https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L148
this.CGSWindow = ctypes.int;
this.CGSWindowOrderingMode = ctypes.int; // type is enum so i guess int - https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L66
this.CGSWorkspace = ctypes.int;
this.CGSValue = ctypes.int;
this.CGWindowID = ctypes.uint32_t;
this.CGWindowLevel = ctypes.int32_t;
this.CGWindowLevelKey = ctypes.int32_t;
this.CGWindowListOption = ctypes.uint32_t;
this.ConstStr255Param = ctypes.unsigned_char.ptr;
this.ConstStringPtr = ctypes.unsigned_char.ptr;
this.EventTime = ctypes.double;
this.ItemCount = ctypes.unsigned_long;
this.UInt8 = ctypes.uint8_t; // osxtypes says ctypes.unsigned_char
this.SInt16 = ctypes.short;
this.SInt32 = ctypes.long;
this.UInt16 = ctypes.unsigned_short;
this.UInt32 = ctypes.uint32_t; // i was using ctypes.unsigned long but it is NOT 32bit. which caused problem on 64bit mac with RegisterEventHotKey i would keep getting invalid args error of -50
this.UInt64 = ctypes.unsigned_long_long;
this.UniChar = ctypes.jschar;
this.VOID = ctypes.void_t;
// ADVANCED TYPES // as per how it was defined in WinNT.h // defined by "simple types"
this.AlertType = this.SInt16;
this.CFAbsoluteTime = this.CFTimeInterval;
this.DialogItemIndex = this.SInt16;
this.EventKind = this.UInt16;
this.EventMask = this.UInt16;
this.EventTimeout = this.EventTime;
this.FourCharCode = this.UInt32;
this.FSEventStreamCreateFlags = this.UInt32;
this.FSEventStreamEventFlags = this.UInt32;
this.FSEventStreamEventId = this.UInt64;
this.EventModifiers = this.UInt16;
this.OptionBits = this.UInt32;
this.OSErr = this.SInt16;
this.OSStatus = this.SInt32;
// SUPER ADVANCED TYPES // defined by "advanced types"
this.LSRolesMask = this.OptionBits;
this.OSType = this.FourCharCode;
// SUPER DUPER ADVANCED TYPES // defined by "super advanced types"
// GUESS TYPES - i know these are something else but setting them to voidptr_t or something just works and all the extra work isnt needed
// STRUCTURES
// consts for structures
var struct_const = {
};
// SIMPLE STRUCTS // based on any of the types above
this.__CFAllocator = ctypes.StructType('__CFAllocator');
this.__CFArray = ctypes.StructType('__CFArray');
this.__CFDictionary = ctypes.StructType('__CFDictionary');
this.__CFError = ctypes.StructType('__CFError');
this.__CFMachPort = ctypes.StructType('__CFMachPort');
this.__CFRunLoop = ctypes.StructType('__CFRunLoop');
this.__CFRunLoopSource = ctypes.StructType('__CFRunLoopSource');
this.__CFRunLoopTimer = ctypes.StructType('__CFRunLoopTimer');
this.__CFString = ctypes.StructType('__CFString');
this.__CFURL = ctypes.StructType('__CFURL');
this.__CGEvent = ctypes.StructType('__CGEvent');
this.__CGEventTapProxy = ctypes.StructType('__CGEventTapProxy');
this.__FSEventStream = ctypes.StructType("__FSEventStream");
this.CGImage = ctypes.StructType('CGImage');
this.CGContext = ctypes.StructType('CGContext');
this.CGPoint = ctypes.StructType('CGPoint', [
{ x: this.CGFloat },
{ y: this.CGFloat }
]);
this.CGSize = ctypes.StructType('CGSize', [
{ width: this.CGFloat },
{ height: this.CGFloat }
]);
this.EventHotKeyID = ctypes.StructType('EventHotKeyID', [
{ signature: this.OSType },
{ id: this.UInt32 }
]);
this.EventTypeSpec = ctypes.StructType('EventTypeSpec', [
{ eventClass: this.OSType },
{ eventKind: this.UInt32 }
]);
this.FSRef = ctypes.StructType('FSRef', [
{ hidden: this.UInt8.array(80) }
]);
this.OpaqueDialogPtr = ctypes.StructType('OpaqueDialogPtr');
this.OpaqueEventHandlerCallRef = ctypes.StructType('OpaqueEventHandlerCallRef');
this.OpaqueEventHandlerRef = ctypes.StructType('OpaqueEventHandlerRef');
this.OpaqueEventHotKeyRef = ctypes.StructType('OpaqueEventHotKeyRef');
this.OpaqueEventRef = ctypes.StructType('OpaqueEventRef');
this.OpaqueEventTargetRef = ctypes.StructType('OpaqueEventTargetRef');
this.OpaqueRgnHandle = ctypes.StructType('OpaqueRgnHandle');
this.Point = ctypes.StructType('Point', [
{ v: this.short },
{ h: this.short }
]);
this.ProcessSerialNumber = ctypes.StructType('ProcessSerialNumber', [
{ highLongOfPSN: this.UInt32 },
{ lowLongOfPSN: this.UInt32 }
]);
this.timespec = ctypes.StructType('timespec', [ // http://www.opensource.apple.com/source/text_cmds/text_cmds-69/sort/timespec.h
{ tv_sec: this.time_t },
{ tv_nsec: this.long }
]);
// ADVANCED STRUCTS // based on "simple structs" to be defined first
this.CFAllocatorRef = this.__CFAllocator.ptr;
this.CFArrayRef = this.__CFArray.ptr;
this.CFDictionaryRef = this.__CFDictionary.ptr;
this.CFErrorRef = this.__CFError.ptr;
this.CFMachPortRef = this.__CFMachPort.ptr;
this.CFRunLoopRef = this.__CFRunLoop.ptr;
this.CFRunLoopSourceRef = this.__CFRunLoopSource.ptr;
this.CFRunLoopTimerRef = this.__CFRunLoopTimer.ptr
this.CFStringRef = this.__CFString.ptr;
this.CFURLRef = this.__CFURL.ptr;
this.CGImageRef = this.CGImage.ptr;
this.CGContextRef = this.CGContext.ptr;
this.CGEventRef = this.__CGEvent.ptr;
this.CGEventTapProxy = this.__CGEventTapProxy.ptr;
this.CGRect = ctypes.StructType('CGRect', [
{ origin: this.CGPoint },
{ size: this.CGSize }
]);
this.ConstFSEventStreamRef = this.__FSEventStream.ptr;
this.DialogPtr = this.OpaqueDialogPtr.ptr;
this.EventHandlerCallRef = this.OpaqueEventHandlerCallRef.ptr;
this.EventHandlerRef = this.OpaqueEventHandlerRef.ptr;
this.EventHotKeyRef = this.OpaqueEventHotKeyRef.ptr;
this.EventRecord = ctypes.StructType('EventRecord', [
{ what: this.EventKind },
{ message: this.unsigned_long },
{ when: this.UInt32 },
{ where: this.Point },
{ modifiers: this.EventModifiers }
]);
this.EventRef = this.OpaqueEventRef.ptr;
this.EventTargetRef = this.OpaqueEventTargetRef.ptr;
this.FSEventStreamRef = this.__FSEventStream.ptr;
this.RgnHandle = this.OpaqueRgnHandle.ptr;
// FURTHER ADVANCED STRUCTS
this.DialogRef = this.DialogPtr;
// FURTHER ADV STRUCTS
// FUNCTION TYPES
this.CFAllocatorCopyDescriptionCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.CFStringRef, [this.void.ptr]).ptr; // https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFAllocatorRef/index.html#//apple_ref/doc/c_ref/CFAllocatorCopyDescriptionCallBack
this.CFAllocatorRetainCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.void.ptr, [this.void.ptr]).ptr; // https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFAllocatorRef/index.html#//apple_ref/doc/c_ref/CFAllocatorRetainCallBack // typedef const void *(*CFAllocatorRetainCallBack) ( const void *info );
this.CFAllocatorReleaseCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.void, [this.void.ptr]).ptr; // https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFAllocatorRef/index.html#//apple_ref/doc/c_ref/CFAllocatorReleaseCallBack // typedef void (*CFAllocatorReleaseCallBack) ( const void *info );
this.CFArrayCopyDescriptionCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.CFStringRef, [this.void.ptr]).ptr;
this.CFArrayEqualCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.Boolean, [this.void.ptr, this.void.ptr]).ptr;
this.CFArrayReleaseCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.void, [this.CFAllocatorRef, this.void.ptr]).ptr;
this.CFArrayRetainCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.void.ptr, [this.CFAllocatorRef, this.void.ptr]).ptr;
this.CFRunLoopTimerCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.void, [this.CFRunLoopTimerRef, this.void.ptr]).ptr; // https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopTimerRef/index.html#//apple_ref/doc/c_ref/CFRunLoopTimerCallBack
this.EventHandlerProcPtr = ctypes.FunctionType(this.CALLBACK_ABI, this.OSStatus, [this.EventHandlerCallRef, this.EventRef, this.void.ptr]).ptr;
this.FSEventStreamCallback = ctypes.FunctionType(this.CALLBACK_ABI, this.void, [this.ConstFSEventStreamRef, this.void.ptr, this.size_t, this.void.ptr, this.FSEventStreamEventFlags.ptr, this.FSEventStreamEventId.ptr]).ptr;
this.ModalFilterProcPtr = ctypes.FunctionType(this.CALLBACK_ABI, this.Boolean, [this.DialogRef, this.EventRecord.ptr, this.DialogItemIndex.ptr]).ptr;
this.CGEventTapCallBack = ctypes.FunctionType(this.CALLBACK_ABI, this.CGEventRef, [this.CGEventTapProxy, this.CGEventType, this.CGEventRef, this.VOID.ptr]).ptr;
// ADVANCED FUNCTION TYPES
this.EventHandlerUPP = this.EventHandlerProcPtr;
this.ModalFilterUPP = this.ModalFilterProcPtr;
// STRUCTS USING FUNC TYPES
this.AlertStdAlertParamRec = ctypes.StructType('AlertStdAlertParamRec', [
{ movable: this.Boolean },
{ helpButton: this.Boolean },
{ filterProc: this.ModalFilterUPP },
{ defaultText: this.ConstStringPtr },
{ cancelText: this.ConstStringPtr },
{ otherText: this.ConstStringPtr },
{ defaultButton: this.SInt16 },
{ cancelButton: this.SInt16 },
{ position: this.UInt16 }
]);
this.CFArrayCallBacks = ctypes.StructType('CFArrayCallBacks', [
{ version: this.CFIndex },
{ retain: this.CFArrayRetainCallBack },
{ release: this.CFArrayReleaseCallBack },
{ copyDescription: this.CFArrayCopyDescriptionCallBack },
{ equal: this.CFArrayEqualCallBack }
]);
this.CFRunLoopTimerContext = ctypes.StructType('CFRunLoopTimerContext', [ // https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopTimerRef/index.html#//apple_ref/c/tdef/CFRunLoopTimerContext
{ version: this.CFIndex },
{ info: this.void.ptr },
{ retain: this.CFAllocatorRetainCallBack },
{ release: this.CFAllocatorReleaseCallBack },
{ copyDescription: this.CFAllocatorCopyDescriptionCallBack }
]);
this.FSEventStreamContext = ctypes.StructType('FSEventStreamContext', [
{version: this.CFIndex},
{info: this.void.ptr},
{retain: this.CFAllocatorRetainCallBack},
{release: this.CFAllocatorReleaseCallBack},
{copyDescription: this.CFAllocatorCopyDescriptionCallBack}
]);
///// OBJC
// SIMPLE OBJC TYPES
this.BOOL = ctypes.signed_char;
this.NSInteger = is64bit ? ctypes.long: ctypes.int;
this.NSUInteger = is64bit ? ctypes.unsigned_long : ctypes.unsigned_int;
// ADV OBJC TYPES
this.NSBitmapFormat = this.NSUInteger;
this.NSEventType = this.NSUInteger;
this.NSEventMask = this.NSUInteger;
this.NSURLBookmarkCreationOptions = this.NSUInteger;
// GUESS TYPES OBJC - they work though
this.id = ctypes.voidptr_t;
this.IMP = ctypes.voidptr_t;
this.SEL = ctypes.voidptr_t;
this.Class = ctypes.voidptr_t;
this.NSEvent = ctypes.voidptr_t;
this.NSWindow = ctypes.voidptr_t;
// NULL CONSTs that i use for vaiadic args
// SIMPLE OBJC STRUCTS
this.Block_descriptor_1 = ctypes.StructType('Block_descriptor_1', [
{ reserved: this.unsigned_long_long },
{ size: this.unsigned_long_long }
]);
this.NSPoint = ctypes.StructType('_NSPoint', [
{ 'x': this.CGFloat },
{ 'y': this.CGFloat }
]);
this.NSSize = ctypes.StructType('_NSSize', [
{ 'width': this.CGFloat },
{ 'height': this.CGFloat }
]);
// ADV OBJC STRUCTS
this.Block_literal_1 = ctypes.StructType('Block_literal_1', [
{ isa: this.void.ptr },
{ flags: this.int32_t },
{ reserved: this.int32_t },
{ invoke: this.void.ptr },
{ descriptor: this.Block_descriptor_1.ptr }
]);
this.NSRect = ctypes.StructType('_NSRect', [
{ 'origin': this.NSPoint },
{ 'size': this.NSSize }
]);
// FUNC OBJC TYPES
this.IMP_for_EventMonitorCallback = ctypes.FunctionType(this.CALLBACK_ABI, this.NSEvent.ptr, [this.id, this.NSEvent.ptr]);
// LIBDISPATCH STUFF
this.dispatch_block_t = ctypes.FunctionType(this.CALLBACK_ABI, this.void, []).ptr;
this.dispatch_queue_t = ctypes.voidptr_t; // guess
}
var macInit = function() {
var self = this;
this.IS64BIT = is64bit;
this.TYPE = new macTypes();
// CONSTANTS
var _const = {}; // lazy load consts
this.CONST = {
get CGRectNull () { if (!('CGRectNull' in _const)) { _const['CGRectNull'] = lib('CoreGraphics').declare('CGRectNull', self.TYPE.CGRect); } return _const['CGRectNull']; },
get kCFTypeArrayCallBacks () { if (!('kCFTypeArrayCallBacks' in _const)) { _const['kCFTypeArrayCallBacks'] = lib('CoreFoundation').declare('kCFTypeArrayCallBacks', self.TYPE.CFArrayCallBacks); } return _const['kCFTypeArrayCallBacks']; },
get _NSConcreteGlobalBlock () { if (!('_NSConcreteGlobalBlock' in _const)) { _const['_NSConcreteGlobalBlock'] = lib('objc').declare('_NSConcreteGlobalBlock', self.TYPE.void.ptr); } return _const['_NSConcreteGlobalBlock']; },
get kCFAllocatorDefault () { if (!('kCFAllocatorDefault' in _const)) { _const['kCFAllocatorDefault'] = lib('CoreFoundation').declare('kCFAllocatorDefault', self.TYPE.CFAllocatorRef); } return _const['kCFAllocatorDefault']; },
get kCFAllocatorSystemDefault () { if (!('kCFAllocatorSystemDefault' in _const)) { _const['kCFAllocatorSystemDefault'] = lib('CoreFoundation').declare('kCFAllocatorSystemDefault', self.TYPE.CFAllocatorRef); } return _const['kCFAllocatorSystemDefault']; },
get kCFRunLoopDefaultMode () { if (!('kCFRunLoopDefaultMode' in _const)) { _const['kCFRunLoopDefaultMode'] = lib('CoreFoundation').declare('kCFRunLoopDefaultMode', self.TYPE.CFStringRef); } return _const['kCFRunLoopDefaultMode']; },
get kCFRunLoopCommonModes () { if (!('kCFRunLoopCommonModes' in _const)) { _const['kCFRunLoopCommonModes'] = lib('CoreFoundation').declare('kCFRunLoopCommonModes', self.TYPE.CFStringRef); } return _const['kCFRunLoopCommonModes']; },
get CGSDefaultConnection () { if (!('CGSDefaultConnection' in _const)) { _const['CGSDefaultConnection'] = self.API('_CGSDefaultConnection')(); } return _const['CGSDefaultConnection']; }, // https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L39
kCGErrorSuccess: 0,
kCGNullDirectDisplay: 0,
kCGBaseWindowLevelKey: 0,
kCGMinimumWindowLevelKey: 1,
kCGDesktopWindowLevelKey: 2,
kCGBackstopMenuLevelKey: 3,
kCGNormalWindowLevelKey: 4,
kCGFloatingWindowLevelKey: 5,
kCGTornOffMenuWindowLevelKey: 6,
kCGDockWindowLevelKey: 7,
kCGMainMenuWindowLevelKey: 8,
kCGStatusWindowLevelKey: 9,
kCGModalPanelWindowLevelKey: 10,
kCGPopUpMenuWindowLevelKey: 11,
kCGDraggingWindowLevelKey: 12,
kCGScreenSaverWindowLevelKey: 13,
kCGMaximumWindowLevelKey: 14,
kCGOverlayWindowLevelKey: 15,
kCGHelpWindowLevelKey: 16,
kCGUtilityWindowLevelKey: 17,
kCGDesktopIconWindowLevelKey: 18,
kCGCursorWindowLevelKey: 19,
kCGAssistiveTechHighWindowLevelKey: 20,
kCGNumberOfWindowLevelKeys: 21,
kCGNullWindowID: 0,
kCGWindowListOptionAll: 0,
kCGWindowListOptionOnScreenOnly: 1,
kCGWindowListOptionOnScreenAboveWindow: 2,
kCGWindowListOptionOnScreenBelowWindow: 4,
kCGWindowListOptionIncludingWindow: 8,
kCGWindowListExcludeDesktopElements: 16,
kCGHIDEventTap: 0,
kCGSessionEventTap: 1,
kCGAnnotatedSessionEventTap: 2,
kCGHeadInsertEventTap: 0,
kCGTailAppendEventTap: 1,
kCGEventTapOptionDefault: 0,
kCGEventTapOptionListenOnly: 1,
cmdKey: 256,
shiftKey: 512,
alphaLock: 1024,
optionKey: 2048,
controlKey: 4096,
rightShiftKey: 8192,
rightOptionKey: 16384,
rightControlKey: 32768,
kEventClassKeyboard: 0x6B657962,
kEventHotKeyPressed: 5,
kCGEventNull: 0,
kCGEventLeftMouseDown: 1,
kCGEventLeftMouseUp: 2,
kCGEventRightMouseDown: 3,
kCGEventRightMouseUp: 4,
kCGEventMouseMoved: 5,
kCGEventLeftMouseDragged: 6,
kCGEventRightMouseDragged: 7,
kCGEventKeyDown: 10,
kCGEventKeyUp: 11,
kCGEventFlagsChanged: 12,
kCGEventScrollWheel: 22,
kCGEventTabletPointer: 23,
kCGEventTabletProximity: 24,
kCGEventOtherMouseDown: 25,
kCGEventOtherMouseUp: 26,
kCGEventOtherMouseDragged: 27,
kCGEventTapDisabledByTimeout: 0xFFFFFFFE, // this.TYPE.CGEventType('0xFFFFFFFE'),
kCGEventTapDisabledByUserInput: 0xFFFFFFFF, // this.TYPE.CGEventType('0xFFFFFFFF'),
kCGEventMaskForAllEvents: ctypes.UInt64('0xffffffffffffffff'), // #define kCGEventMaskForAllEvents (~(CGEventMask)0) // https://github.com/sschiesser/ASK_server/blob/a51e2fbdac894c37d97142fc72faa35f89057744/MacOSX10.6/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers/CGEventTypes.h#L380
kCGMouseEventNumber: 0,
kCGMouseEventClickState: 1,
kCGMouseEventPressure: 2,
kCGMouseEventButtonNumber: 3,
kCGMouseEventDeltaX: 4,
kCGMouseEventDeltaY: 5,
kCGMouseEventInstantMouser: 6,
kCGMouseEventSubtype: 7,
kCGScrollWheelEventDeltaAxis1: 11,
kCGScrollWheelEventDeltaAxis2: 12,
kCGScrollWheelEventDeltaAxis3: 13,
kCGScrollWheelEventFixedPtDeltaAxis1: 93,
kCGScrollWheelEventFixedPtDeltaAxis2: 94,
kCGScrollWheelEventFixedPtDeltaAxis3: 95,
kCGScrollWheelEventPointDeltaAxis1: 96,
kCGScrollWheelEventPointDeltaAxis2: 97,
kCGScrollWheelEventPointDeltaAxis3: 98,
kCGScrollWheelEventInstantMouser: 14,
kCFRunLoopRunFinished: 1,
kCFRunLoopRunStopped: 2,
kCFRunLoopRunTimedOut: 3,
kCFRunLoopRunHandledSource: 4,
kCGSOrderAbove: 1,
kCGSOrderBelow: -1,
kCGSOrderOut: 0,
NX_SYSDEFINED: 14,
NX_KEYTYPE_SOUND_UP: 0,
NX_KEYTYPE_SOUND_DOWN: 1,
NX_KEYTYPE_PLAY: 16,
NX_KEYTYPE_NEXT: 17,
NX_KEYTYPE_PREVIOUS: 18,
NX_KEYTYPE_FAST: 19,
NX_KEYTYPE_REWIND: 20,
kLSRolesNone: 1,
kLSRolesViewer: 2,
kLSRolesEditor: 4,
kLSRolesShell: 8,
kLSRolesAll: 0xffffffff, // sources show this as -1 but type is uint32 so this should be 0xffffffff
///////// OBJC - all consts are wrapped in a type as if its passed to variadic it needs to have type defind, see jsctypes chat with arai on 051015 357p
NO: self.TYPE.BOOL(0),
NSPNGFileType: self.TYPE.NSUInteger(4),
YES: self.TYPE.BOOL(1), // i do this instead of 1 becuase for varidic types we need to expclicitly define it
NIL: self.TYPE.void.ptr(ctypes.UInt64('0x0')), // needed for varidic args, as i cant pass null there
NSFileWriteFileExistsError: 516, // i dont use this a variadic, just for compare so i dont wrap this in a type, but the type is NSInteger. I figured this because NSError says its code value is NSInteger. The types for NSFileWriteFileExistsError says its enum - but by looking up code i can see that enum is type NSInteger - sources: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/index.html#//apple_ref/occ/instp/NSError/code && https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/doc/constant_group/NSError_Codes
NSURLBookmarkCreationSuitableForBookmarkFile: self.TYPE.NSURLBookmarkCreationOptions(1 << 10),
NSApplicationActivateAllWindows: self.TYPE.NSUInteger(1 << 0),
NSApplicationActivateIgnoringOtherApps: self.TYPE.NSUInteger(1 << 1),
NSLeftMouseDown: 1, // TYPES.NSEventType
NSLeftMouseUp: 2, // TYPES.NSEventType
NSRightMouseDown: 3, // TYPES.NSEventType
NSRightMouseUp: 4, // TYPES.NSEventType
NSMouseMoved: 5, // TYPES.NSEventType
NSLeftMouseDragged: 6, // TYPES.NSEventType
NSRightMouseDragged: 7, // TYPES.NSEventType
NSMouseEntered: 8, // TYPES.NSEventType
NSMouseExited: 9, // TYPES.NSEventType
NSKeyDown: 10, // TYPES.NSEventType
NSKeyUp: 11, // TYPES.NSEventType
NSFlagsChanged: 12, // TYPES.NSEventType
NSAppKitDefined: 13, // TYPES.NSEventType
NSSystemDefined: 14, // TYPES.NSEventType
NSApplicationDefined: 15, // TYPES.NSEventType
NSPeriodic: 16, // TYPES.NSEventType
NSCursorUpdate: 17, // TYPES.NSEventType
NSScrollWheel: 22, // TYPES.NSEventType
NSTabletPoint: 23, // TYPES.NSEventType
NSTabletProximity: 24, // TYPES.NSEventType
NSOtherMouseDown: 25, // TYPES.NSEventType
NSOtherMouseUp: 26, // TYPES.NSEventType
NSOtherMouseDragged: 27, // TYPES.NSEventType
NSEventTypeGesture: 29, // TYPES.NSEventType
NSEventTypeMagnify: 30, // TYPES.NSEventType
NSEventTypeSwipe: 31, // TYPES.NSEventType
NSEventTypeRotate: 18, // TYPES.NSEventType
NSEventTypeBeginGesture: 19, // TYPES.NSEventType
NSEventTypeEndGesture: 20, // TYPES.NSEventType
NSEventTypeSmartMagnify: 32, // TYPES.NSEventType
NSEventTypeQuickLook: 33, // TYPES.NSEventType
NSEventTypePressure: 34, // TYPES.NSEventType
NSUIntegerMax: this.TYPE.NSUInteger(is64bit ? '0xffffffff' : '0xffff'), // TYPES.NSUInteger
BLOCK_HAS_COPY_DISPOSE: 1 << 25,
BLOCK_HAS_CTOR: 1 << 26,
BLOCK_IS_GLOBAL: 1 << 28,
BLOCK_HAS_STRET: 1 << 29,
BLOCK_HAS_SIGNATURE: 1 << 30,
};
// ADVANCED CONST
this.CONST.NULL = this.CONST.NIL.address();
this.CONST.NSLeftMouseDownMask = 1 << this.CONST.NSLeftMouseDown;
this.CONST.NSLeftMouseUpMask = 1 << this.CONST.NSLeftMouseUp;
this.CONST.NSRightMouseDownMask = 1 << this.CONST.NSRightMouseDown;
this.CONST.NSRightMouseUpMask = 1 << this.CONST.NSRightMouseUp;
this.CONST.NSMouseMovedMask = 1 << this.CONST.NSMouseMoved;
this.CONST.NSLeftMouseDraggedMask = 1 << this.CONST.NSLeftMouseDragged;
this.CONST.NSRightMouseDraggedMask = 1 << this.CONST.NSRightMouseDragged;
this.CONST.NSMouseEnteredMask = 1 << this.CONST.NSMouseEntered;
this.CONST.NSMouseExitedMask = 1 << this.CONST.NSMouseExited;
this.CONST.NSKeyDownMask = 1 << this.CONST.NSKeyDown;
this.CONST.NSKeyUpMask = 1 << this.CONST.NSKeyUp;
this.CONST.NSFlagsChangedMask = 1 << this.CONST.NSFlagsChanged;
this.CONST.NSAppKitDefinedMask = 1 << this.CONST.NSAppKitDefined;
this.CONST.NSSystemDefinedMask = 1 << this.CONST.NSSystemDefined;
this.CONST.NSApplicationDefinedMask = 1 << this.CONST.NSApplicationDefined;
this.CONST.NSPeriodicMask = 1 << this.CONST.NSPeriodic;
this.CONST.NSCursorUpdateMask = 1 << this.CONST.NSCursorUpdate;
this.CONST.NSScrollWheelMask = 1 << this.CONST.NSScrollWheel;
this.CONST.NSTabletPointMask = 1 << this.CONST.NSTabletPoint;
this.CONST.NSTabletProximityMask = 1 << this.CONST.NSTabletProximity;
this.CONST.NSOtherMouseDownMask = 1 << this.CONST.NSOtherMouseDown;
this.CONST.NSOtherMouseUpMask = 1 << this.CONST.NSOtherMouseUp;
this.CONST.NSOtherMouseDraggedMask = 1 << this.CONST.NSOtherMouseDragged;
this.CONST.NSEventMaskGesture = 1 << this.CONST.NSEventTypeGesture;
this.CONST.NSEventMaskMagnify = 1 << this.CONST.NSEventTypeMagnify;
this.CONST.NSEventMaskSwipe = 1 << this.CONST.NSEventTypeSwipe; // 1U << NSEventTypeSwipe
this.CONST.NSEventMaskRotate = 1 << this.CONST.NSEventTypeRotate;
this.CONST.NSEventMaskBeginGesture = 1 << this.CONST.NSEventTypeBeginGesture;
this.CONST.NSEventMaskEndGesture = 1 << this.CONST.NSEventTypeEndGesture;
this.CONST.NSEventMaskSmartMagnify = 1 << this.CONST.NSEventTypeSmartMagnify; // 1ULL << NSEventTypeSmartMagnify;
this.CONST.NSEventMaskPressure = 1 << this.CONST.NSEventTypePressure; // 1ULL << NSEventTypePressure
this.CONST.NSAnyEventMask = this.CONST.NSUIntegerMax; //0xffffffffU
var _lib = {}; // cache for lib
var lib = function(path) {
//ensures path is in lib, if its in lib then its open, if its not then it adds it to lib and opens it. returns lib
//path is path to open library
//returns lib so can use straight away
if (!(path in _lib)) {
//need to open the library
//default it opens the path, but some things are special like libc in mac is different then linux or like x11 needs to be located based on linux version
switch (path) {
case 'CarbonCore':
_lib[path] = ctypes.open('/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/CarbonCore');
break;
case 'CoreFoundation':
_lib[path] = ctypes.open('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation');
break;
case 'CoreGraphics':
_lib[path] = ctypes.open('/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics');
break;
case 'FSEvents':
try {
// for osx 10.10
_lib[path] = ctypes.open('/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents');
} catch (ex) {
if (ex.message.indexOf('couldn\'t open library') == -1) {
throw ex; // failed due to some othe reason
}
// for osx < 10.10
_lib[path] = lib('CarbonCore');
}
break;
case 'libc':
switch (core.os.name) {
case 'darwin':
_lib[path] = ctypes.open('libc.dylib');
break;
case 'freebsd':
_lib[path] = ctypes.open('libc.so.7');
break;
case 'openbsd':
_lib[path] = ctypes.open('libc.so.61.0');
break;
case 'android':
case 'sunos':
case 'netbsd': // physically unverified
case 'dragonfly': // physcially unverified
_lib[path] = ctypes.open('libc.so');
break;
case 'linux':
_lib[path] = ctypes.open('libc.so.6');
break;
case 'gnu/kfreebsd': // physically unverified
lib = ctypes.open('libc.so.0.1');
break;
default:
throw new Error({
name: 'watcher-api-error',
message: 'Path to libc on operating system of , "' + OS.Constants.Sys.Name + '" is not supported for kqueue'
});
}
break;
case 'objc':
_lib[path] = ctypes.open(ctypes.libraryName('objc'));
break;
default:
try {
_lib[path] = ctypes.open(path);
} catch (ex) {
throw new Error({
name: 'addon-error',
message: 'Could not open ctypes library path of "' + path + '"',
ex_msg: ex.message
});
}
}
}
return _lib[path];
};
// start - function declares
var _api = {};
this.API = function(declaration) { // it means ensureDeclared and return declare. if its not declared it declares it. else it returns the previously declared.
if (!(declaration in _api)) {
_api[declaration] = preDec[declaration](); //if declaration is not in preDec then dev messed up
}
return _api[declaration];
};
// start - predefine your declares here
var preDec = { //stands for pre-declare (so its just lazy stuff) //this must be pre-populated by dev // do it alphabateized by key so its ez to look through
_CGSDefaultConnection: function () {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L39
* CGSConnection _CGSDefaultConnection(
* void
* );
*/
return lib('CoreGraphics').declare('_CGSDefaultConnection', self.TYPE.ABI,
self.TYPE.CGSConnection // return
);
},
CGSConnectionGetPID: function () {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L108
* CGError CGSConnectionGetPID(
* const CGSConnection cid,
* pid_t *pid,
* const CGSConnection ownerCid
* );
*/
return lib('CoreGraphics').declare('CGSConnectionGetPID', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.pid_t.ptr, // *pid
self.TYPE.CGSConnection // ownerCid
);
},
CGSMoveWorkspaceWindowList: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L96
* CGError CGSMoveWorkspaceWindowList(
* const CGSConnection connection,
* CGSWindow *wids,
* int count,
* CGSWorkspace toWorkspace
* );
*/
return lib('CoreGraphics').declare('CGSMoveWorkspaceWindowList', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWindow.ptr, // *wids
self.TYPE.CGSWorkspace // toWorkspace
);
},
CGSGetWindowCount: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L48
* CGError CGSGetWindowCount(
* const CGSConnection cid,
* CGSConnection targetCID,
* int* outCount
* );
*/
return lib('CoreGraphics').declare('CGSGetWindowCount', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSConnection, // targetCID
self.TYPE.int.ptr // outCount
);
},
CGSGetWindowWorkspace: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L196
* CGError CGSGetWindowWorkspace(
* const CGSConnection cid,
* const CGSWindow wid,
* CGSWorkspace *workspace
* );
*/
return lib('CoreGraphics').declare('CGSGetWindowWorkspace', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWindow, // wid
self.TYPE.CGSWorkspace.ptr // *workspace
);
},
CGSGetWindowOwner: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L107
* CGError CGSGetWindowOwner(
* const CGSConnection cid,
* const CGSWindow wid,
* CGSConnection *ownerCid
* );
*/
return lib('CoreGraphics').declare('CGSGetWindowOwner', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWindow, // wid
self.TYPE.CGSConnection.ptr // *ownerCid
);
},
CGSGetWorkspace: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L56
* CGSGetWorkspace(
* const CGSConnection cid,
* CGSWorkspace *workspace
* );
*/
return lib('CoreGraphics').declare('CGSGetWorkspace', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWorkspace.ptr // *workspace
);
},
CGSOrderWindow: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L72
* CGError CGSOrderWindow(
* const CGSConnection cid,
* const CGSWindow wid,
* CGSWindowOrderingMode place,
* CGSWindow relativeToWindowID // can be NULL
* );
*/
return lib('CoreGraphics').declare('CGSOrderWindow', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWindow, // wid
self.TYPE.CGSWindowOrderingMode, // place
self.TYPE.CGSWindow // relativeToWindowID
);
},
CGSSetWorkspace: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L197
* CGError CGSSetWorkspace(
* const CGSConnection cid,
* CGSWorkspace workspace
* );
*/
return lib('CoreGraphics').declare('CGSSetWorkspace', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWorkspace // workspace
);
},
CGSSetWorkspaceWithTransition: function() {
/* https://gist.github.com/Noitidart/3664c5c2059c9aa6779f#file-cgsprivate-h-L198
* CGError CGSSetWorkspaceWithTransition(
* const CGSConnection cid,
* CGSWorkspace workspace,
* CGSTransitionType transition,
* CGSTransitionOption subtype,
* float time
* );
*/
return lib('CoreGraphics').declare('CGSSetWorkspaceWithTransition', self.TYPE.ABI,
self.TYPE.CGError, // return
self.TYPE.CGSConnection, // cid
self.TYPE.CGSWorkspace, // workspace
self.TYPE.CGSTransitionType, // transition
self.TYPE.CGSTransitionOption, // subtype
self.TYPE.float // time
);
},
CFAbsoluteTimeGetCurrent: function() {
/* https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFTimeUtils/index.html#//apple_ref/c/func/CFAbsoluteTimeGetCurrent
* CFAbsoluteTime CFAbsoluteTimeGetCurrent (
* void
* );
*/
return lib('CoreFoundation').declare('CFAbsoluteTimeGetCurrent', self.TYPE.ABI,
self.TYPE.CFAbsoluteTime // return
);
},
CFArrayCreate: function() {
return lib('CoreFoundation').declare('CFArrayCreate', self.TYPE.ABI,
self.TYPE.CFArrayRef,
self.TYPE.CFAllocatorRef,
self.TYPE.void.ptr.ptr,
self.TYPE.CFIndex,
self.TYPE.CFArrayCallBacks.ptr
);
},
CFArrayGetCount: function() {
return lib('CoreFoundation').declare('CFArrayGetCount', self.TYPE.ABI,
self.TYPE.CFIndex,
self.TYPE.CFArrayRef
);
},
CFArrayGetValueAtIndex: function() {
return lib('CoreFoundation').declare('CFArrayGetValueAtIndex', self.TYPE.ABI,
self.TYPE.void.ptr,
self.TYPE.CFArrayRef,
self.TYPE.CFIndex
);
},
CFMachPortCreateRunLoopSource: function() {
return lib('CoreFoundation').declare('CFMachPortCreateRunLoopSource', self.TYPE.ABI,
self.TYPE.CFRunLoopSourceRef,
self.TYPE.CFAllocatorRef,
self.TYPE.CFMachPortRef,
self.TYPE.CFIndex
);
},
CFRunLoopAddSource: function() {
return lib('CoreFoundation').declare('CFRunLoopAddSource', self.TYPE.ABI,
self.TYPE.VOID,
self.TYPE.CFRunLoopRef,
self.TYPE.CFRunLoopSourceRef,
self.TYPE.CFStringRef
);
},
CFRunLoopAddTimer: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopRef/index.html#//apple_ref/c/func/CFRunLoopAddTimer
* void CFRunLoopAddTimer (
* CFRunLoopRef rl,
* CFRunLoopTimerRef timer,
* CFStringRef mode
* );
*/
return lib('CoreFoundation').declare('CFRunLoopAddTimer', self.TYPE.ABI,
self.TYPE.void, // return
self.TYPE.CFRunLoopRef, // rl
self.TYPE.CFRunLoopTimerRef, // timer
self.TYPE.CFStringRef // mode
);
},
CFRunLoopGetCurrent: function() {
return lib('CoreFoundation').declare('CFRunLoopGetCurrent', self.TYPE.ABI,
self.TYPE.CFRunLoopRef
);
},
CFRunLoopRemoveTimer: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopRef/index.html#//apple_ref/c/func/CFRunLoopRemoveTimer
* void CFRunLoopRemoveTimer (
* CFRunLoopRef rl,
* CFRunLoopTimerRef timer,
* CFStringRef mode
* );
*/
return lib('CoreFoundation').declare('CFRunLoopRemoveTimer', self.TYPE.ABI,
self.TYPE.void, // return
self.TYPE.CFRunLoopRef, // rl
self.TYPE.CFRunLoopTimerRef, // timer
self.TYPE.CFStringRef // mode
);
},
CFRunLoopRemoveSource: function() {
lib('CoreFoundation').declare('CFRunLoopRemoveSource', self.TYPE.ABI,
self.TYPE.VOID,
self.TYPE.CFRunLoopRef,
self.TYPE.CFRunLoopSourceRef,
self.TYPE.CFStringRef
);
},
CFRunLoopRun: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopRef/index.html#//apple_ref/c/func/CFRunLoopRun
*/
return lib('CoreFoundation').declare('CFRunLoopRun', self.TYPE.ABI,
self.TYPE.VOID
);
},
CFRunLoopRunInMode: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopRef/index.html#//apple_ref/c/func/CFRunLoopRunInMode
*/
return lib('CoreFoundation').declare("CFRunLoopRunInMode", self.TYPE.ABI,
self.TYPE.SInt32,
self.TYPE.CFStringRef,
self.TYPE.CFTimeInterval,
self.TYPE.Boolean
);
},
CFRunLoopSourceInvalidate: function() {
return lib('CoreFoundation').declare('CFRunLoopSourceInvalidate', self.TYPE.ABI,
self.TYPE.VOID,
self.TYPE.CFRunLoopSourceRef
);
},
CFRunLoopStop: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopRef/index.html#//apple_ref/c/func/CFRunLoopStop
*/
return lib('CoreFoundation').declare('CFRunLoopStop', self.TYPE.ABI,
self.TYPE.VOID,
self.TYPE.CFRunLoopRef
);
},
CFRunLoopTimerCreate: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopTimerRef/index.html#//apple_ref/c/func/CFRunLoopTimerCreate
* CFRunLoopTimerRef CFRunLoopTimerCreate (
* CFAllocatorRef allocator,
* CFAbsoluteTime fireDate,
* CFTimeInterval interval,
* CFOptionFlags flags,
* CFIndex order,
* CFRunLoopTimerCallBack callout,
* CFRunLoopTimerContext *context
* );
*/
return lib('CoreFoundation').declare('CFRunLoopTimerCreate', self.TYPE.ABI,
self.TYPE.CFRunLoopTimerRef, // return
self.TYPE.CFAllocatorRef, // allocator
self.TYPE.CFAbsoluteTime, // fireDate
self.TYPE.CFTimeInterval, // interval
self.TYPE.CFOptionFlags, // flags
self.TYPE.CFIndex, // order
self.TYPE.CFRunLoopTimerCallBack, // callout
self.TYPE.CFRunLoopTimerContext.ptr // *context
);
},
CFRunLoopTimerInvalidate: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopTimerRef/index.html#//apple_ref/c/func/CFRunLoopTimerInvalidate
* void CFRunLoopTimerInvalidate (
* CFRunLoopTimerRef timer
* );
*/
return lib('CoreFoundation').declare('CFRunLoopTimerInvalidate', self.TYPE.ABI,
self.TYPE.void, // return
self.TYPE.CFRunLoopTimerRef // timer
);
},
CFStringCreateWithCharacters: function() {
/* https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFStringRef/#//apple_ref/c/func/CFStringCreateWithCharacters
* CFStringRef CFStringCreateWithCharacters (
* CFAllocatorRef alloc,
* const UniChar *chars,
* CFIndex numChars
* );
*/
return lib('CoreFoundation').declare('CFStringCreateWithCharacters', self.TYPE.ABI,
self.TYPE.CFStringRef, // return
self.TYPE.CFAllocatorRef, // alloc
self.TYPE.UniChar.ptr, // *chars
self.TYPE.CFIndex // numChars
);
},
CFRelease: function() {
/* https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFTypeRef/#//apple_ref/c/func/CFRelease
* void CFRelease (
* CFTypeRef cf
* );
*/
return lib('CoreFoundation').declare('CFRelease', self.TYPE.ABI,
self.TYPE.void, // return
self.TYPE.CFTypeRef // cf
);
},
CFRunLoopRun: function() {
/* https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFRunLoopRef/index.html#//apple_ref/c/func/CFRunLoopRun
*/