nomen-lang 0.0.19 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/NOMEN_AGENTS.md +57 -12
  2. package/core/System/Array.nm +11 -11
  3. package/core/System/Buffer.nm +2 -2
  4. package/core/System/Channel.nm +146 -12
  5. package/core/System/ClassBuffer.nm +2 -2
  6. package/core/System/Console.nm +28 -17
  7. package/core/System/Controls/Button.nm +96 -8
  8. package/core/System/Controls/CheckBox.nm +117 -12
  9. package/core/System/Controls/Container.nm +114 -8
  10. package/core/System/Controls/Text.nm +98 -8
  11. package/core/System/Controls/TextBox.nm +120 -10
  12. package/core/System/Controls/Window.nm +231 -23
  13. package/core/System/Graph.nm +1 -1
  14. package/core/System/Init.nm +4 -8
  15. package/core/System/LinkedList.nm +1 -1
  16. package/core/System/List.nm +3 -3
  17. package/core/System/Map.nm +5 -5
  18. package/core/System/Math.nm +10 -32
  19. package/core/System/Result.nm +1 -1
  20. package/core/System/Set.nm +4 -4
  21. package/core/System/Stream/Directory.nm +189 -63
  22. package/core/System/Stream/DirectoryError.nm +21 -0
  23. package/core/System/Stream/File.nm +339 -141
  24. package/core/System/Stream/FileError.nm +21 -0
  25. package/core/System/Stream/Http.nm +109 -44
  26. package/core/System/Stream/HttpError.nm +20 -0
  27. package/core/System/String.nm +83 -69
  28. package/core/System/StringBuilder.nm +11 -13
  29. package/core/System/Task.nm +46 -12
  30. package/core/System/Test.nm +1 -1
  31. package/core/System/Text/Json.nm +5 -3
  32. package/core/System/Text/JsonTree.nm +23 -14
  33. package/core/System/Text/Regex.nm +124 -64
  34. package/core/System/Tree.nm +1 -1
  35. package/core/System/bool.nm +4 -9
  36. package/core/System/char.nm +3 -9
  37. package/core/System/float.nm +2 -1
  38. package/core/System/float32.nm +44 -0
  39. package/core/System/float64.nm +44 -0
  40. package/core/System/int.nm +3 -9
  41. package/core/System/int16.nm +47 -0
  42. package/core/System/int32.nm +47 -0
  43. package/core/System/int64.nm +3 -9
  44. package/core/System/int8.nm +3 -9
  45. package/core/System/ufloat.nm +44 -0
  46. package/core/System/ufloat32.nm +44 -0
  47. package/core/System/ufloat64.nm +44 -0
  48. package/core/System/uint.nm +3 -9
  49. package/core/System/uint16.nm +47 -0
  50. package/core/System/uint32.nm +47 -0
  51. package/core/System/uint64.nm +3 -9
  52. package/core/System/uint8.nm +3 -9
  53. package/core/docs/System/Channel.md +2 -0
  54. package/core/docs/System/Result.md +5 -1
  55. package/core/docs/System/Task.md +1 -1
  56. package/dist/index.mjs +38794 -21299
  57. package/package.json +38 -34
  58. package/src/args.ts +11 -0
  59. package/src/index.ts +21 -3
  60. package/src/init.ts +1 -1
  61. package/src/test.ts +48 -4
  62. package/src/types/Config.ts +2 -0
@@ -6,7 +6,7 @@ pub class Button : Control {
6
6
 
7
7
  pub func #init = (self, Window window, string title) {
8
8
  ```
9
- #arch: c, aarch64_use_c
9
+ #arch: c
10
10
  #platform: macos
11
11
  id btn = ((id(*)(id, SEL, CGRect))objc_msgSend)(
12
12
  ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
@@ -25,7 +25,26 @@ pub class Button : Control {
25
25
  self->handle = (uint64_t)btn;
26
26
  ```
27
27
  ```
28
- #arch: c, aarch64_use_c
28
+ #arch: aarch64_use_c
29
+ #platform: macos
30
+ id btn = ((id(*)(id, SEL, CGRect))objc_msgSend)(
31
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
32
+ sel_registerName("initWithFrame:"),
33
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 100, 32));
34
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
35
+ btn, sel_registerName("setButtonType:"), 1); // NSPushInButton = 1 (momentary push)
36
+ ((void(*)(id, SEL, id))objc_msgSend)(
37
+ btn, sel_registerName("setTitle:"),
38
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
39
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
40
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
41
+ (id)window->handle, sel_registerName("contentView"));
42
+ ((void(*)(id, SEL, id))objc_msgSend)(
43
+ contentView, sel_registerName("addSubview:"), btn);
44
+ self->handle = (uint64_t)btn;
45
+ ```
46
+ ```
47
+ #arch: c
29
48
  #platform: ios
30
49
  id btn = ((id(*)(id, SEL, CGRect))objc_msgSend)(
31
50
  ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIButton"), sel_registerName("alloc")),
@@ -44,18 +63,52 @@ pub class Button : Control {
44
63
  parentView, sel_registerName("addSubview:"), btn);
45
64
  self->handle = (uint64_t)btn;
46
65
  ```
66
+ ```
67
+ #arch: aarch64_use_c
68
+ #platform: ios
69
+ id btn = ((id(*)(id, SEL, CGRect))objc_msgSend)(
70
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIButton"), sel_registerName("alloc")),
71
+ sel_registerName("initWithFrame:"),
72
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 100, 32));
73
+ ((void(*)(id, SEL, unsigned long, id, id))objc_msgSend)(
74
+ btn, sel_registerName("setTitle:forState:"),
75
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
76
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr),
77
+ 0); // UIControlStateNormal = 0
78
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
79
+ ((id(*)(id, SEL))objc_msgSend)(
80
+ (id)window->handle, sel_registerName("rootViewController")),
81
+ sel_registerName("view"));
82
+ ((void(*)(id, SEL, id))objc_msgSend)(
83
+ parentView, sel_registerName("addSubview:"), btn);
84
+ self->handle = (uint64_t)btn;
85
+ ```
47
86
  }
48
87
 
49
88
  pub func set_frame = (ref self, int x, int y, int width, int height) {
50
89
  ```
51
- #arch: c, aarch64_use_c
90
+ #arch: c
91
+ #platform: macos
92
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
93
+ (id)self->handle, sel_registerName("setFrame:"),
94
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
95
+ ```
96
+ ```
97
+ #arch: aarch64_use_c
52
98
  #platform: macos
53
99
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
54
100
  (id)self->handle, sel_registerName("setFrame:"),
55
101
  ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
56
102
  ```
57
103
  ```
58
- #arch: c, aarch64_use_c
104
+ #arch: c
105
+ #platform: ios
106
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
107
+ (id)self->handle, sel_registerName("setFrame:"),
108
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
109
+ ```
110
+ ```
111
+ #arch: aarch64_use_c
59
112
  #platform: ios
60
113
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
61
114
  (id)self->handle, sel_registerName("setFrame:"),
@@ -65,7 +118,7 @@ pub class Button : Control {
65
118
 
66
119
  pub func set_title = (self, string title) {
67
120
  ```
68
- #arch: c, aarch64_use_c
121
+ #arch: c
69
122
  #platform: macos
70
123
  ((void(*)(id, SEL, id))objc_msgSend)(
71
124
  (id)self->handle, sel_registerName("setTitle:"),
@@ -73,7 +126,15 @@ pub class Button : Control {
73
126
  (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
74
127
  ```
75
128
  ```
76
- #arch: c, aarch64_use_c
129
+ #arch: aarch64_use_c
130
+ #platform: macos
131
+ ((void(*)(id, SEL, id))objc_msgSend)(
132
+ (id)self->handle, sel_registerName("setTitle:"),
133
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
134
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
135
+ ```
136
+ ```
137
+ #arch: c
77
138
  #platform: ios
78
139
  ((void(*)(id, SEL, unsigned long, id, id))objc_msgSend)(
79
140
  (id)self->handle, sel_registerName("setTitle:forState:"),
@@ -81,6 +142,15 @@ pub class Button : Control {
81
142
  (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title),
82
143
  0); // UIControlStateNormal = 0
83
144
  ```
145
+ ```
146
+ #arch: aarch64_use_c
147
+ #platform: ios
148
+ ((void(*)(id, SEL, unsigned long, id, id))objc_msgSend)(
149
+ (id)self->handle, sel_registerName("setTitle:forState:"),
150
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
151
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr),
152
+ 0); // UIControlStateNormal = 0
153
+ ```
84
154
  }
85
155
 
86
156
  // ── Control trait conformance ──
@@ -117,7 +187,7 @@ pub class Button : Control {
117
187
 
118
188
  func #destroy = () {
119
189
  ```
120
- #arch: c, aarch64_use_c
190
+ #arch: c
121
191
  #platform: macos
122
192
  if (self->handle) {
123
193
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
@@ -126,7 +196,25 @@ pub class Button : Control {
126
196
  }
127
197
  ```
128
198
  ```
129
- #arch: c, aarch64_use_c
199
+ #arch: aarch64_use_c
200
+ #platform: macos
201
+ if (self->handle) {
202
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
203
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
204
+ self->handle = 0;
205
+ }
206
+ ```
207
+ ```
208
+ #arch: c
209
+ #platform: ios
210
+ if (self->handle) {
211
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
212
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
213
+ self->handle = 0;
214
+ }
215
+ ```
216
+ ```
217
+ #arch: aarch64_use_c
130
218
  #platform: ios
131
219
  if (self->handle) {
132
220
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
@@ -6,7 +6,7 @@ pub class CheckBox : Control {
6
6
 
7
7
  pub func #init = (self, Window window) {
8
8
  ```
9
- #arch: c, aarch64_use_c
9
+ #arch: c
10
10
  #platform: macos
11
11
  id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
12
12
  ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
@@ -23,7 +23,39 @@ pub class CheckBox : Control {
23
23
  self->handle = (uint64_t)cb;
24
24
  ```
25
25
  ```
26
- #arch: c, aarch64_use_c
26
+ #arch: aarch64_use_c
27
+ #platform: macos
28
+ id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
29
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
30
+ sel_registerName("initWithFrame:"),
31
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
32
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
33
+ cb, sel_registerName("setButtonType:"), 3); // NSSwitchButton = 3
34
+ ((void(*)(id, SEL, long))objc_msgSend)(
35
+ cb, sel_registerName("setState:"), 0); // NSControlStateValueOff = 0
36
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
37
+ (id)window->handle, sel_registerName("contentView"));
38
+ ((void(*)(id, SEL, id))objc_msgSend)(
39
+ contentView, sel_registerName("addSubview:"), cb);
40
+ self->handle = (uint64_t)cb;
41
+ ```
42
+ ```
43
+ #arch: c
44
+ #platform: ios
45
+ id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
46
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UISwitch"), sel_registerName("alloc")),
47
+ sel_registerName("initWithFrame:"),
48
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 100, 24));
49
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
50
+ ((id(*)(id, SEL))objc_msgSend)(
51
+ (id)window->handle, sel_registerName("rootViewController")),
52
+ sel_registerName("view"));
53
+ ((void(*)(id, SEL, id))objc_msgSend)(
54
+ parentView, sel_registerName("addSubview:"), cb);
55
+ self->handle = (uint64_t)cb;
56
+ ```
57
+ ```
58
+ #arch: aarch64_use_c
27
59
  #platform: ios
28
60
  id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
29
61
  ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UISwitch"), sel_registerName("alloc")),
@@ -41,14 +73,28 @@ pub class CheckBox : Control {
41
73
 
42
74
  pub func set_frame = (ref self, int x, int y, int width, int height) {
43
75
  ```
44
- #arch: c, aarch64_use_c
76
+ #arch: c
45
77
  #platform: macos
46
78
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
47
79
  (id)self->handle, sel_registerName("setFrame:"),
48
80
  ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
49
81
  ```
50
82
  ```
51
- #arch: c, aarch64_use_c
83
+ #arch: aarch64_use_c
84
+ #platform: macos
85
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
86
+ (id)self->handle, sel_registerName("setFrame:"),
87
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
88
+ ```
89
+ ```
90
+ #arch: c
91
+ #platform: ios
92
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
93
+ (id)self->handle, sel_registerName("setFrame:"),
94
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
95
+ ```
96
+ ```
97
+ #arch: aarch64_use_c
52
98
  #platform: ios
53
99
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
54
100
  (id)self->handle, sel_registerName("setFrame:"),
@@ -58,25 +104,46 @@ pub class CheckBox : Control {
58
104
 
59
105
  pub func set_title = (self, string title) {
60
106
  ```
61
- #arch: c, aarch64_use_c
107
+ #arch: c
62
108
  #platform: macos
63
109
  ((void(*)(id, SEL, id))objc_msgSend)(
64
110
  (id)self->handle, sel_registerName("setTitle:"),
65
111
  ((id(*)(id, SEL, const char*))objc_msgSend)(
66
112
  (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
67
113
  ```
114
+ ```
115
+ #arch: aarch64_use_c
116
+ #platform: macos
117
+ ((void(*)(id, SEL, id))objc_msgSend)(
118
+ (id)self->handle, sel_registerName("setTitle:"),
119
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
120
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
121
+ ```
68
122
  }
69
123
 
70
124
  pub func set_checked = (self, bool checked) {
71
125
  ```
72
- #arch: c, aarch64_use_c
126
+ #arch: c
127
+ #platform: macos
128
+ ((void(*)(id, SEL, long))objc_msgSend)(
129
+ (id)self->handle, sel_registerName("setState:"),
130
+ checked ? 1 : 0); // NSControlStateValueOn = 1, Off = 0
131
+ ```
132
+ ```
133
+ #arch: aarch64_use_c
73
134
  #platform: macos
74
135
  ((void(*)(id, SEL, long))objc_msgSend)(
75
136
  (id)self->handle, sel_registerName("setState:"),
76
137
  checked ? 1 : 0); // NSControlStateValueOn = 1, Off = 0
77
138
  ```
78
139
  ```
79
- #arch: c, aarch64_use_c
140
+ #arch: c
141
+ #platform: ios
142
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
143
+ (id)self->handle, sel_registerName("setOn:"), checked ? 1 : 0);
144
+ ```
145
+ ```
146
+ #arch: aarch64_use_c
80
147
  #platform: ios
81
148
  ((void(*)(id, SEL, BOOL))objc_msgSend)(
82
149
  (id)self->handle, sel_registerName("setOn:"), checked ? 1 : 0);
@@ -85,14 +152,28 @@ pub class CheckBox : Control {
85
152
 
86
153
  pub func is_checked = (self, out bool) {
87
154
  ```
88
- #arch: c, aarch64_use_c
155
+ #arch: c
89
156
  #platform: macos
90
157
  long state = ((long(*)(id, SEL))objc_msgSend)(
91
158
  (id)self->handle, sel_registerName("state"));
92
159
  return state == 1; // NSControlStateValueOn = 1
93
160
  ```
94
161
  ```
95
- #arch: c, aarch64_use_c
162
+ #arch: aarch64_use_c
163
+ #platform: macos
164
+ long state = ((long(*)(id, SEL))objc_msgSend)(
165
+ (id)self->handle, sel_registerName("state"));
166
+ return state == 1; // NSControlStateValueOn = 1
167
+ ```
168
+ ```
169
+ #arch: c
170
+ #platform: ios
171
+ BOOL on = ((BOOL(*)(id, SEL))objc_msgSend)(
172
+ (id)self->handle, sel_registerName("isOn"));
173
+ return on ? 1 : 0;
174
+ ```
175
+ ```
176
+ #arch: aarch64_use_c
96
177
  #platform: ios
97
178
  BOOL on = ((BOOL(*)(id, SEL))objc_msgSend)(
98
179
  (id)self->handle, sel_registerName("isOn"));
@@ -102,7 +183,13 @@ pub class CheckBox : Control {
102
183
 
103
184
  pub func set_hidden = (self, bool hidden) {
104
185
  ```
105
- #arch: c, aarch64_use_c
186
+ #arch: c
187
+ #platform: macos
188
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
189
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
190
+ ```
191
+ ```
192
+ #arch: aarch64_use_c
106
193
  #platform: macos
107
194
  ((void(*)(id, SEL, BOOL))objc_msgSend)(
108
195
  (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
@@ -137,7 +224,7 @@ pub class CheckBox : Control {
137
224
 
138
225
  func #destroy = () {
139
226
  ```
140
- #arch: c, aarch64_use_c
227
+ #arch: c
141
228
  #platform: macos
142
229
  if (self->handle) {
143
230
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
@@ -146,7 +233,25 @@ pub class CheckBox : Control {
146
233
  }
147
234
  ```
148
235
  ```
149
- #arch: c, aarch64_use_c
236
+ #arch: aarch64_use_c
237
+ #platform: macos
238
+ if (self->handle) {
239
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
240
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
241
+ self->handle = 0;
242
+ }
243
+ ```
244
+ ```
245
+ #arch: c
246
+ #platform: ios
247
+ if (self->handle) {
248
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
249
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
250
+ self->handle = 0;
251
+ }
252
+ ```
253
+ ```
254
+ #arch: aarch64_use_c
150
255
  #platform: ios
151
256
  if (self->handle) {
152
257
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
@@ -96,13 +96,24 @@ func length_val = (LayoutLength len, out int) {
96
96
  func is_visible = (uint64 handle, out bool) {
97
97
  if handle == 0 { return true }
98
98
  ```
99
- #arch: c, aarch64_use_c
99
+ #arch: c
100
100
  #platform: macos
101
101
  BOOL hidden = ((BOOL(*)(id, SEL))objc_msgSend)((id)handle, sel_registerName("isHidden"));
102
102
  return !hidden;
103
103
  ```
104
104
  ```
105
- #arch: c, aarch64_use_c
105
+ #arch: aarch64_use_c
106
+ #platform: macos
107
+ BOOL hidden = ((BOOL(*)(id, SEL))objc_msgSend)((id)handle, sel_registerName("isHidden"));
108
+ return !hidden;
109
+ ```
110
+ ```
111
+ #arch: c
112
+ #platform: ios
113
+ return true;
114
+ ```
115
+ ```
116
+ #arch: aarch64_use_c
106
117
  #platform: ios
107
118
  return true;
108
119
  ```
@@ -110,7 +121,7 @@ func is_visible = (uint64 handle, out bool) {
110
121
 
111
122
  func apply_frame = (uint64 handle, int x, int y, int w, int h, int content_w, int content_h) {
112
123
  ```
113
- #arch: c, aarch64_use_c
124
+ #arch: c
114
125
  #platform: macos
115
126
  // AppKit runs its own blocking tracking loop during a live window resize,
116
127
  // so the manual event loop can't re-layout mid-drag. Give the control an
@@ -131,7 +142,36 @@ func apply_frame = (uint64 handle, int x, int y, int w, int h, int content_w, in
131
142
  (double)x, (double)(content_h - y - h), (double)w, (double)h));
132
143
  ```
133
144
  ```
134
- #arch: c, aarch64_use_c
145
+ #arch: aarch64_use_c
146
+ #platform: macos
147
+ // AppKit runs its own blocking tracking loop during a live window resize,
148
+ // so the manual event loop can't re-layout mid-drag. Give the control an
149
+ // autoresizing mask so AppKit repositions it live: pin to the nearest
150
+ // vertical edge (top=NSViewMinYMargin 8 / bottom=NSViewMaxYMargin 32) to
151
+ // respect the top-left-origin layout instead of AppKit's default
152
+ // bottom-left pin, and let wide controls grow with the content width
153
+ // (NSViewWidthSizable 2). Never set NSViewHeightSizable (16): control
154
+ // heights come from the layout pass, not the window. AppKit's result
155
+ // matches what layout() computes, so the post-drag relayout only fixes up
156
+ // cells AppKit can't (column reflow for sub-full-width children).
157
+ unsigned long mask = (y * 2 < content_h) ? 8UL : 32UL;
158
+ if (w * 10 >= content_w * 8) mask |= 2UL;
159
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)((id)handle, sel_registerName("setAutoresizingMask:"), mask);
160
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
161
+ (id)handle, sel_registerName("setFrame:"),
162
+ ((CGRect(*)(double, double, double, double))CGRectMake)(
163
+ (double)x, (double)(content_h - y - h), (double)w, (double)h));
164
+ ```
165
+ ```
166
+ #arch: c
167
+ #platform: ios
168
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
169
+ (id)handle, sel_registerName("setFrame:"),
170
+ ((CGRect(*)(double, double, double, double))CGRectMake)(
171
+ (double)x, (double)y, (double)w, (double)h));
172
+ ```
173
+ ```
174
+ #arch: aarch64_use_c
135
175
  #platform: ios
136
176
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
137
177
  (id)handle, sel_registerName("setFrame:"),
@@ -153,7 +193,18 @@ func apply_frame = (uint64 handle, int x, int y, int w, int h, int content_w, in
153
193
  pub func native_intrinsic = (uint64 handle, out [int, int]) {
154
194
  if handle == 0 { return [0, 0] }
155
195
  ```
156
- #arch: c, aarch64_use_c
196
+ #arch: c
197
+ #platform: macos
198
+ CGSize sz = ((CGSize(*)(id, SEL))objc_msgSend)((id)handle, sel_registerName("intrinsicContentSize"));
199
+ int w = (sz.width < 0 || sz.width > 100000) ? 0 : (int)sz.width;
200
+ int h = (sz.height < 0 || sz.height > 100000) ? 0 : (int)sz.height;
201
+ struct _Tuple_int_int r;
202
+ r._0 = w;
203
+ r._1 = h;
204
+ return r;
205
+ ```
206
+ ```
207
+ #arch: aarch64_use_c
157
208
  #platform: macos
158
209
  CGSize sz = ((CGSize(*)(id, SEL))objc_msgSend)((id)handle, sel_registerName("intrinsicContentSize"));
159
210
  int w = (sz.width < 0 || sz.width > 100000) ? 0 : (int)sz.width;
@@ -164,7 +215,18 @@ pub func native_intrinsic = (uint64 handle, out [int, int]) {
164
215
  return r;
165
216
  ```
166
217
  ```
167
- #arch: c, aarch64_use_c
218
+ #arch: c
219
+ #platform: ios
220
+ CGSize sz = ((CGSize(*)(id, SEL))objc_msgSend)((id)handle, sel_registerName("intrinsicContentSize"));
221
+ int w = (sz.width < 0 || sz.width > 100000) ? 0 : (int)sz.width;
222
+ int h = (sz.height < 0 || sz.height > 100000) ? 0 : (int)sz.height;
223
+ struct _Tuple_int_int r;
224
+ r._0 = w;
225
+ r._1 = h;
226
+ return r;
227
+ ```
228
+ ```
229
+ #arch: aarch64_use_c
168
230
  #platform: ios
169
231
  CGSize sz = ((CGSize(*)(id, SEL))objc_msgSend)((id)handle, sel_registerName("intrinsicContentSize"));
170
232
  int w = (sz.width < 0 || sz.width > 100000) ? 0 : (int)sz.width;
@@ -1384,7 +1446,7 @@ pub class Container : Control {
1384
1446
  // both backends, methods are not.
1385
1447
  pub func set_resize_callback = (ref self, Window win) {
1386
1448
  ```
1387
- #arch: c, aarch64_use_c
1449
+ #arch: c
1388
1450
  #platform: macos
1389
1451
  #scope: file
1390
1452
  struct Container;
@@ -1410,7 +1472,51 @@ pub class Container : Control {
1410
1472
  }
1411
1473
  ```
1412
1474
  ```
1413
- #arch: c, aarch64_use_c
1475
+ #arch: aarch64_use_c
1476
+ #platform: macos
1477
+ #scope: file
1478
+ struct Container;
1479
+ struct Window;
1480
+ // nomen_layout_thunk is a free function (defined in Nomen below) that
1481
+ // forwards to Container.layout — exported for C linkage on both
1482
+ // backends, unlike the layout method itself. It takes the Container by
1483
+ // `ref` (mutable reference): as a `class`, `ref Container` lowers to
1484
+ // `struct Container **` (reference to the instance pointer), so the
1485
+ // callback passes the address of the stored instance pointer.
1486
+ extern void nomen_layout_thunk(struct Container**, struct Window*);
1487
+ static void *g_resize_grid = 0;
1488
+ static void *g_resize_win = 0;
1489
+ void nomen_set_resize_target(void *grid, void *win) {
1490
+ g_resize_grid = grid;
1491
+ g_resize_win = win;
1492
+ }
1493
+ void nomen_window_did_resize(id self, SEL cmd, id notification) {
1494
+ (void)self; (void)cmd; (void)notification;
1495
+ if (g_resize_grid && g_resize_win) {
1496
+ nomen_layout_thunk((struct Container**)&g_resize_grid, (struct Window*)g_resize_win);
1497
+ }
1498
+ }
1499
+ ```
1500
+ ```
1501
+ #arch: c
1502
+ #platform: macos
1503
+ nomen_set_resize_target(self, win);
1504
+ Class Dc = objc_getClass("NomenResizeDelegate");
1505
+ if (!Dc) {
1506
+ Dc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenResizeDelegate", 0);
1507
+ if (Dc) {
1508
+ class_addMethod(Dc, sel_registerName("windowDidResize:"), (IMP)nomen_window_did_resize, "v@:@");
1509
+ objc_registerClassPair(Dc);
1510
+ }
1511
+ }
1512
+ if (Dc) {
1513
+ id delegate = ((id(*)(id, SEL))objc_msgSend)((id)Dc, sel_registerName("alloc"));
1514
+ delegate = ((id(*)(id, SEL))objc_msgSend)(delegate, sel_registerName("init"));
1515
+ ((void(*)(id, SEL, id))objc_msgSend)((id)win->handle, sel_registerName("setDelegate:"), delegate);
1516
+ }
1517
+ ```
1518
+ ```
1519
+ #arch: aarch64_use_c
1414
1520
  #platform: macos
1415
1521
  nomen_set_resize_target(self, win);
1416
1522
  Class Dc = objc_getClass("NomenResizeDelegate");