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
|
/* 28 february 2014 */
/*
This includes all Objective-C runtime headers for convenience. It also creates wrappers around objc_msgSend() out of necessity.
cgo doesn't support calling variable argument list C functions, so objc_msgSend() cannot be called directly.
Furthermore, Objective-C selectors work by basically sending the arguments to objc_msgSend() verbatim across the wire. This basically means we're stuck making wrapper functions for every possible argument list. What fun!
The format should be self-explanatory.
*/
/* for some reason I now have to use an include guard after commit [master 9b4e30c] ("Started to build a single global delegate object; now to fix issues.") */
#ifndef _OBJC_DARWIN_H_
#define _OBJC_DARWIN_H_
#include <objc/message.h>
#include <objc/objc.h>
#include <objc/runtime.h>
#include <stdint.h>
/* for listbox_darwin.go */
extern id *_NSObservedObjectKey;
static inline id objc_msgSend_noargs(id obj, SEL sel)
{
return objc_msgSend(obj, sel);
}
struct xrect {
int64_t x;
int64_t y;
int64_t width;
int64_t height;
};
extern struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel);
struct xsize {
int64_t width;
int64_t height;
};
extern struct xsize objc_msgSend_stret_size_noargs(id obj, SEL sel);
struct xpoint {
int64_t x;
int64_t y;
};
extern uintptr_t objc_msgSend_uintret_noargs(id obj, SEL sel);
extern uintptr_t objc_msgSend_uintret_uint(id obj, SEL sel, uintptr_t a);
extern intptr_t objc_msgSend_intret_noargs(id obj, SEL sel);
extern uintptr_t objc_msgSend_ushortret_noargs(id obj, SEL sel);
#define m1(name, type1) \
static inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a) \
{ \
return objc_msgSend(obj, sel, a); \
}
#define m2(name, type1, type2) \
static inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a, type2 b) \
{ \
return objc_msgSend(obj, sel, a, b); \
}
#define m3(name, type1, type2, type3) \
static inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a, type2 b, type3 c) \
{ \
return objc_msgSend(obj, sel, a, b, c); \
}
#define m4(name, type1, type2, type3, type4) \
static inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a, type2 b, type3 c, type4 d) \
{ \
return objc_msgSend(obj, sel, a, b, c, d); \
}
m1(str, char *) /* TODO Go string? */
m1(id, id)
extern id objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h);
m1(sel, SEL)
extern id objc_msgSend_uint(id obj, SEL sel, uintptr_t a);
m1(ptr, void *)
m1(bool, BOOL)
extern id objc_msgSend_int(id obj, SEL sel, intptr_t a);
m1(double, double)
extern id objc_msgSend_point(id obj, SEL sel, int64_t x, int64_t y);
extern id objc_msgSend_size(id obj, SEL sel, int64_t width, int64_t height);
extern id objc_msgSendSuper_id(id obj, id class, SEL sel, id a);
m2(id_id, id, id)
extern id objc_msgSend_rect_bool(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h, BOOL b);
extern id objc_msgSend_id_int(id obj, SEL sel, id a, intptr_t b);
extern id objc_msgSend_id_uint(id obj, SEL sel, id a, uintptr_t b);
m2(id_bool, id, BOOL)
m3(id_id_id, id, id, id)
m3(sel_id_bool, SEL, id, BOOL)
extern id objc_msgSend_rect_uint_uint_bool(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h, uintptr_t b, uintptr_t c, BOOL d);
m4(id_sel_id_id, id, SEL, id, id)
m4(id_id_id_id, id, id, id, id)
/* for listbox_darwin.go */
extern uintptr_t *NSIndexSetEntries(id, uintptr_t);
/* for uitask_darwin.go */
extern void initBleh();
extern id makeDummyEvent();
/* for area_darwin.go */
/* TODO apparently ISO C forbids casting a function pointer to a non-function pointer; this will need to change???? */
extern void *_areaView_drawRect;
extern void drawImage(void *, int64_t, int64_t, int64_t, int64_t, int64_t);
extern id makeTrackingArea(id);
extern struct xpoint getTranslatedEventPoint(id, id);
/* for objc_darwin.go */
extern char *encodedNSRect;
extern char *encodedTerminateReply;
/* for sysdata_darwin.go */
extern void objc_setFont(id, unsigned int);
/* for delegate_darwin.go */
extern void *_appDelegate_applicationShouldTerminate;
#endif
|