nomen-lang 0.7.1 → 0.9.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 (80) hide show
  1. package/audit_runtime.c +12 -2
  2. package/core/System/Arena.nm +8 -1
  3. package/core/System/Buffer.nm +397 -8
  4. package/core/System/ClassBuffer.nm +156 -0
  5. package/core/System/Controls/Alert.nm +326 -0
  6. package/core/System/Controls/App.nm +147 -0
  7. package/core/System/Controls/Button.nm +119 -1
  8. package/core/System/Controls/CheckBox.nm +25 -1
  9. package/core/System/Controls/ColorPicker.nm +307 -0
  10. package/core/System/Controls/ComboBox.nm +430 -0
  11. package/core/System/Controls/Container.nm +843 -9
  12. package/core/System/Controls/Control.nm +443 -0
  13. package/core/System/Controls/DatePicker.nm +288 -0
  14. package/core/System/Controls/Form.nm +70 -0
  15. package/core/System/Controls/GroupBox.nm +267 -0
  16. package/core/System/Controls/ImageView.nm +311 -0
  17. package/core/System/Controls/LevelIndicator.nm +305 -0
  18. package/core/System/Controls/ListView.nm +633 -0
  19. package/core/System/Controls/Menu.nm +428 -0
  20. package/core/System/Controls/NumberInput.nm +56 -0
  21. package/core/System/Controls/OtpInput.nm +50 -0
  22. package/core/System/Controls/OutlineView.nm +598 -0
  23. package/core/System/Controls/Pagination.nm +142 -0
  24. package/core/System/Controls/Popover.nm +296 -0
  25. package/core/System/Controls/Progress.nm +348 -0
  26. package/core/System/Controls/Radio.nm +292 -0
  27. package/core/System/Controls/Scrollable.nm +584 -0
  28. package/core/System/Controls/SearchField.nm +326 -0
  29. package/core/System/Controls/SecureField.nm +344 -0
  30. package/core/System/Controls/Segmented.nm +380 -0
  31. package/core/System/Controls/Select.nm +340 -0
  32. package/core/System/Controls/Separator.nm +198 -0
  33. package/core/System/Controls/Sheet.nm +329 -0
  34. package/core/System/Controls/Slider.nm +315 -0
  35. package/core/System/Controls/Spinner.nm +287 -0
  36. package/core/System/Controls/SplitView.nm +509 -0
  37. package/core/System/Controls/Stepper.nm +349 -0
  38. package/core/System/Controls/Switch.nm +259 -0
  39. package/core/System/Controls/Table.nm +833 -0
  40. package/core/System/Controls/Tabs.nm +500 -0
  41. package/core/System/Controls/Text.nm +108 -11
  42. package/core/System/Controls/TextBox.nm +113 -2
  43. package/core/System/Controls/TextView.nm +329 -0
  44. package/core/System/Controls/Toggle.nm +346 -0
  45. package/core/System/Controls/Toolbar.nm +501 -0
  46. package/core/System/Controls/Tooltip.nm +76 -0
  47. package/core/System/Controls/Window.nm +1548 -91
  48. package/core/System/LinkedList.nm +8 -1
  49. package/core/System/List.nm +97 -7
  50. package/core/System/Map.nm +191 -18
  51. package/core/System/Mutex.nm +4 -4
  52. package/core/System/Random.nm +3 -4
  53. package/core/System/Set.nm +101 -13
  54. package/core/System/StableList.nm +371 -0
  55. package/core/System/Stream/Directory.nm +2 -2
  56. package/core/System/Stream/File.nm +2 -2
  57. package/core/System/Stream/Http.nm +2 -2
  58. package/core/System/String.nm +10 -5
  59. package/core/System/StringBuilder.nm +213 -2
  60. package/core/System/Text/CharIndex.nm +9 -9
  61. package/core/System/Text/Json.nm +60 -46
  62. package/core/System/Text/JsonTree.nm +120 -92
  63. package/core/System/Text/Regex.nm +23 -18
  64. package/core/System/Text/Utf8.nm +5 -5
  65. package/core/System/float.nm +36 -22
  66. package/core/System/int.nm +80 -28
  67. package/core/System/int16.nm +11 -0
  68. package/core/System/int32.nm +11 -0
  69. package/core/System/int64.nm +11 -0
  70. package/core/System/int8.nm +11 -0
  71. package/core/System/uint.nm +11 -0
  72. package/core/System/uint16.nm +11 -0
  73. package/core/System/uint32.nm +11 -0
  74. package/core/System/uint64.nm +11 -0
  75. package/core/System/uint8.nm +11 -0
  76. package/core/docs/System/StringBuilder.md +6 -0
  77. package/core/docs/System/Text/JsonTree.md +3 -2
  78. package/dist/index.mjs +38332 -30604
  79. package/package.json +1 -1
  80. package/src/bench_loop.nm +9 -9
@@ -26,3 +26,446 @@ pub trait Control {
26
26
  // wrapping, scrolling, etc. Default: call measure with infinity.)
27
27
  func intrinsic_size = (self, out Size)
28
28
  }
29
+
30
+ // ── Native click events (target/action) ──
31
+ //
32
+ // NSButton-family controls (Button, CheckBox, Radio, Toggle — and
33
+ // composites over them) arm a shared action target at construction; the
34
+ // action records the sender's view pointer — which IS the Nomen handle —
35
+ // into a ring queue, and `was_clicked` drains it. That is an
36
+ // edge-triggered click poll with no coordinates and no hit-testing, and it
37
+ // works for controls hosted on a Scrollable's document view. Handlers that
38
+ // need shared app state stay in `App.frame` — a capturing `on_click`
39
+ // closure is not expressible soundly (capturing a control MOVES it; see
40
+ // CLOSURE.md), so the poll form is the ownership-clean equivalent.
41
+
42
+ // Arm a control's native click action. Called by the button-family
43
+ // constructors; safe to call again (re-sets target/action).
44
+ pub func nomen_control_arm_clicks = (uint64 handle) {
45
+ ```
46
+ #arch: c
47
+ #platform: macos
48
+ #scope: file
49
+ // The shared click target: NSControl.target/action fires clickAction:
50
+ // on the main thread; the sender's view pointer is the Nomen handle.
51
+ static void *nomen_click_target = 0;
52
+ // Ring queue of clicked handles (64 deep; a click that is never
53
+ // consumed is stale, so dropping the oldest when full is fine).
54
+ static unsigned long long nomen_click_queue[64];
55
+ static int nomen_click_count = 0;
56
+ static void nomen_click_push(unsigned long long h) {
57
+ if (nomen_click_count >= 64) return;
58
+ nomen_click_queue[nomen_click_count++] = h;
59
+ }
60
+ static long nomen_click_take(unsigned long long h) {
61
+ for (int i = 0; i < nomen_click_count; i++) {
62
+ if (nomen_click_queue[i] == h) {
63
+ for (int j = i; j < nomen_click_count - 1; j++) {
64
+ nomen_click_queue[j] = nomen_click_queue[j + 1];
65
+ }
66
+ nomen_click_count--;
67
+ return 1;
68
+ }
69
+ }
70
+ return 0;
71
+ }
72
+ static void nomen_click_action(id self, SEL cmd, id sender) {
73
+ (void)self; (void)cmd;
74
+ nomen_click_push((unsigned long long)(void *)sender);
75
+ }
76
+ static void nomen_click_arm(unsigned long long handle) {
77
+ Class Tc = objc_getClass("NomenClickTarget");
78
+ if (!Tc) {
79
+ Tc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenClickTarget", 0);
80
+ if (Tc) {
81
+ class_addMethod(Tc, sel_registerName("clickAction:"), (IMP)nomen_click_action, "v@:@");
82
+ objc_registerClassPair(Tc);
83
+ }
84
+ }
85
+ if (!nomen_click_target && Tc) {
86
+ nomen_click_target = (void *)((id(*)(id, SEL))objc_msgSend)((id)Tc, sel_registerName("new"));
87
+ }
88
+ if (nomen_click_target) {
89
+ id control = (id)handle;
90
+ ((void(*)(id, SEL, id))objc_msgSend)(control, sel_registerName("setTarget:"), (id)nomen_click_target);
91
+ ((void(*)(id, SEL, SEL))objc_msgSend)(control, sel_registerName("setAction:"), sel_registerName("clickAction:"));
92
+ }
93
+ }
94
+ ```
95
+ ```
96
+ #arch: aarch64_use_c
97
+ #platform: macos
98
+ #scope: file
99
+ static void *nomen_click_target = 0;
100
+ static unsigned long long nomen_click_queue[64];
101
+ static int nomen_click_count = 0;
102
+ static void nomen_click_push(unsigned long long h) {
103
+ if (nomen_click_count >= 64) return;
104
+ nomen_click_queue[nomen_click_count++] = h;
105
+ }
106
+ static long nomen_click_take(unsigned long long h) {
107
+ for (int i = 0; i < nomen_click_count; i++) {
108
+ if (nomen_click_queue[i] == h) {
109
+ for (int j = i; j < nomen_click_count - 1; j++) {
110
+ nomen_click_queue[j] = nomen_click_queue[j + 1];
111
+ }
112
+ nomen_click_count--;
113
+ return 1;
114
+ }
115
+ }
116
+ return 0;
117
+ }
118
+ static void nomen_click_action(id self, SEL cmd, id sender) {
119
+ (void)self; (void)cmd;
120
+ nomen_click_push((unsigned long long)(void *)sender);
121
+ }
122
+ static void nomen_click_arm(unsigned long long handle) {
123
+ Class Tc = objc_getClass("NomenClickTarget");
124
+ if (!Tc) {
125
+ Tc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenClickTarget", 0);
126
+ if (Tc) {
127
+ class_addMethod(Tc, sel_registerName("clickAction:"), (IMP)nomen_click_action, "v@:@");
128
+ objc_registerClassPair(Tc);
129
+ }
130
+ }
131
+ if (!nomen_click_target && Tc) {
132
+ nomen_click_target = (void *)((id(*)(id, SEL))objc_msgSend)((id)Tc, sel_registerName("new"));
133
+ }
134
+ if (nomen_click_target) {
135
+ id control = (id)handle;
136
+ ((void(*)(id, SEL, id))objc_msgSend)(control, sel_registerName("setTarget:"), (id)nomen_click_target);
137
+ ((void(*)(id, SEL, SEL))objc_msgSend)(control, sel_registerName("setAction:"), sel_registerName("clickAction:"));
138
+ }
139
+ }
140
+ ```
141
+ ```
142
+ #arch: c
143
+ #platform: macos
144
+ nomen_click_arm(handle);
145
+ ```
146
+ ```
147
+ #arch: aarch64_use_c
148
+ #platform: macos
149
+ nomen_click_arm(handle);
150
+ ```
151
+ ```
152
+ #arch: c
153
+ #platform: ios
154
+ /* TODO: iOS (see #init) */
155
+ ```
156
+ ```
157
+ #arch: aarch64_use_c
158
+ #platform: ios
159
+ /* TODO: iOS (see #init) */
160
+ ```
161
+ }
162
+
163
+ // Drain a control's click record: true exactly once per click (the record
164
+ // is consumed). Called by the button-family `was_clicked` polls.
165
+ pub func nomen_control_take_click = (uint64 handle, out bool) {
166
+ ```
167
+ #arch: c
168
+ #platform: macos
169
+ extern long nomen_click_take(unsigned long long);
170
+ return (long)nomen_click_take(handle);
171
+ ```
172
+ ```
173
+ #arch: aarch64_use_c
174
+ #platform: macos
175
+ extern long nomen_click_take(unsigned long long);
176
+ return (long)nomen_click_take(handle);
177
+ ```
178
+ ```
179
+ #arch: c
180
+ #platform: ios
181
+ return 0;
182
+ ```
183
+ ```
184
+ #arch: aarch64_use_c
185
+ #platform: ios
186
+ return 0;
187
+ ```
188
+ }
189
+
190
+ // Arm a control's native selection action — the on_select plumbing for the
191
+ // ACTION family (Select, Segmented, ComboBox: NSControls whose target/action
192
+ // fires on a user-driven selection change). The DELEGATE family (Tabs,
193
+ // ListView, Table, OutlineView) pushes into the same record from its
194
+ // selection delegate instead. Called by those constructors; safe to call
195
+ // again (re-sets target/action). A control carries ONE target/action, so a
196
+ // control arms clicks OR selects, never both — the families are disjoint.
197
+ pub func nomen_control_arm_selects = (uint64 handle) {
198
+ ```
199
+ #arch: c
200
+ #platform: macos
201
+ #scope: file
202
+ // The shared selection record: the click ring's shape, fed by both
203
+ // families — the target's selectAction: (the sender's view pointer is
204
+ // the Nomen handle) and the delegate family's selection callbacks
205
+ // (nomen_select_push is EXTERNAL: Tabs/ListView/Table/OutlineView
206
+ // delegates in other files push into this ring).
207
+ static unsigned long long nomen_select_queue[64];
208
+ static int nomen_select_count = 0;
209
+ void nomen_select_push(unsigned long long h) {
210
+ if (nomen_select_count >= 64) return;
211
+ nomen_select_queue[nomen_select_count++] = h;
212
+ }
213
+ long nomen_select_take(unsigned long long h) {
214
+ for (int i = 0; i < nomen_select_count; i++) {
215
+ if (nomen_select_queue[i] == h) {
216
+ for (int j = i; j < nomen_select_count - 1; j++) {
217
+ nomen_select_queue[j] = nomen_select_queue[j + 1];
218
+ }
219
+ nomen_select_count--;
220
+ return 1;
221
+ }
222
+ }
223
+ return 0;
224
+ }
225
+ static void *nomen_select_target = 0;
226
+ static void nomen_select_action(id self, SEL cmd, id sender) {
227
+ (void)self; (void)cmd;
228
+ nomen_select_push((unsigned long long)(void *)sender);
229
+ }
230
+ static void nomen_select_arm(unsigned long long handle) {
231
+ Class Tc = objc_getClass("NomenSelectTarget");
232
+ if (!Tc) {
233
+ Tc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenSelectTarget", 0);
234
+ if (Tc) {
235
+ class_addMethod(Tc, sel_registerName("selectAction:"), (IMP)nomen_select_action, "v@:@");
236
+ objc_registerClassPair(Tc);
237
+ }
238
+ }
239
+ if (!nomen_select_target && Tc) {
240
+ nomen_select_target = (void *)((id(*)(id, SEL))objc_msgSend)((id)Tc, sel_registerName("new"));
241
+ }
242
+ if (nomen_select_target) {
243
+ id control = (id)handle;
244
+ ((void(*)(id, SEL, id))objc_msgSend)(control, sel_registerName("setTarget:"), (id)nomen_select_target);
245
+ ((void(*)(id, SEL, SEL))objc_msgSend)(control, sel_registerName("setAction:"), sel_registerName("selectAction:"));
246
+ }
247
+ }
248
+ ```
249
+ ```
250
+ #arch: c
251
+ #platform: macos
252
+ nomen_select_arm(handle);
253
+ ```
254
+ ```
255
+ #arch: aarch64_use_c
256
+ #platform: macos
257
+ #scope: file
258
+ static unsigned long long nomen_select_queue[64];
259
+ static int nomen_select_count = 0;
260
+ void nomen_select_push(unsigned long long h) {
261
+ if (nomen_select_count >= 64) return;
262
+ nomen_select_queue[nomen_select_count++] = h;
263
+ }
264
+ long nomen_select_take(unsigned long long h) {
265
+ for (int i = 0; i < nomen_select_count; i++) {
266
+ if (nomen_select_queue[i] == h) {
267
+ for (int j = i; j < nomen_select_count - 1; j++) {
268
+ nomen_select_queue[j] = nomen_select_queue[j + 1];
269
+ }
270
+ nomen_select_count--;
271
+ return 1;
272
+ }
273
+ }
274
+ return 0;
275
+ }
276
+ static void *nomen_select_target = 0;
277
+ static void nomen_select_action(id self, SEL cmd, id sender) {
278
+ (void)self; (void)cmd;
279
+ nomen_select_push((unsigned long long)(void *)sender);
280
+ }
281
+ static void nomen_select_arm(unsigned long long handle) {
282
+ Class Tc = objc_getClass("NomenSelectTarget");
283
+ if (!Tc) {
284
+ Tc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenSelectTarget", 0);
285
+ if (Tc) {
286
+ class_addMethod(Tc, sel_registerName("selectAction:"), (IMP)nomen_select_action, "v@:@");
287
+ objc_registerClassPair(Tc);
288
+ }
289
+ }
290
+ if (!nomen_select_target && Tc) {
291
+ nomen_select_target = (void *)((id(*)(id, SEL))objc_msgSend)((id)Tc, sel_registerName("new"));
292
+ }
293
+ if (nomen_select_target) {
294
+ id control = (id)handle;
295
+ ((void(*)(id, SEL, id))objc_msgSend)(control, sel_registerName("setTarget:"), (id)nomen_select_target);
296
+ ((void(*)(id, SEL, SEL))objc_msgSend)(control, sel_registerName("setAction:"), sel_registerName("selectAction:"));
297
+ }
298
+ }
299
+ ```
300
+ ```
301
+ #arch: aarch64_use_c
302
+ #platform: macos
303
+ nomen_select_arm(handle);
304
+ ```
305
+ ```
306
+ #arch: c
307
+ #platform: ios
308
+ /* TODO: iOS (see #init) */
309
+ ```
310
+ ```
311
+ #arch: aarch64_use_c
312
+ #platform: ios
313
+ /* TODO: iOS (see #init) */
314
+ ```
315
+ }
316
+
317
+ // Arm a text field's native commit action — the on_submit plumbing for the
318
+ // single-line fields (TextBox, SecureField, SearchField). NSTextField
319
+ // sends its target/action exactly on the USER commit (Return), so one
320
+ // shared target serves every field: the field editor maps back to the
321
+ // editing control (the on_focus mapping), and the action's sender IS the
322
+ // field's handle. The record is the submit ring — the selection ring's
323
+ // shape, one entry per committed field, consumed by the field's
324
+ // take_submit drain. Called by those constructors; safe to call again.
325
+ pub func nomen_control_arm_submits = (uint64 handle) {
326
+ ```
327
+ #arch: c
328
+ #platform: macos
329
+ #scope: file
330
+ // The shared submit record: the selection ring's shape. The commit is
331
+ // USER-driven only (the field's action; programmatic set_string_value
332
+ // stays silent).
333
+ static unsigned long long nomen_submit_queue[64];
334
+ static int nomen_submit_count = 0;
335
+ void nomen_submit_push(unsigned long long h) {
336
+ if (nomen_submit_count >= 64) return;
337
+ nomen_submit_queue[nomen_submit_count++] = h;
338
+ }
339
+ long nomen_submit_take(unsigned long long h) {
340
+ for (int i = 0; i < nomen_submit_count; i++) {
341
+ if (nomen_submit_queue[i] == h) {
342
+ for (int j = i; j < nomen_submit_count - 1; j++) {
343
+ nomen_submit_queue[j] = nomen_submit_queue[j + 1];
344
+ }
345
+ nomen_submit_count--;
346
+ return 1;
347
+ }
348
+ }
349
+ return 0;
350
+ }
351
+ static void *nomen_submit_target = 0;
352
+ static void nomen_submit_action(id self, SEL cmd, id sender) {
353
+ (void)self; (void)cmd;
354
+ nomen_submit_push((unsigned long long)(void *)sender);
355
+ }
356
+ static void nomen_submit_arm(unsigned long long handle) {
357
+ Class Tc = objc_getClass("NomenSubmitTarget");
358
+ if (!Tc) {
359
+ Tc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenSubmitTarget", 0);
360
+ if (Tc) {
361
+ class_addMethod(Tc, sel_registerName("submitAction:"), (IMP)nomen_submit_action, "v@:@");
362
+ objc_registerClassPair(Tc);
363
+ }
364
+ }
365
+ if (!nomen_submit_target && Tc) {
366
+ nomen_submit_target = (void *)((id(*)(id, SEL))objc_msgSend)((id)Tc, sel_registerName("new"));
367
+ }
368
+ if (nomen_submit_target) {
369
+ id control = (id)handle;
370
+ ((void(*)(id, SEL, id))objc_msgSend)(control, sel_registerName("setTarget:"), (id)nomen_submit_target);
371
+ ((void(*)(id, SEL, SEL))objc_msgSend)(control, sel_registerName("setAction:"), sel_registerName("submitAction:"));
372
+ }
373
+ }
374
+ ```
375
+ ```
376
+ #arch: c
377
+ #platform: macos
378
+ nomen_submit_arm(handle);
379
+ ```
380
+ ```
381
+ #arch: aarch64_use_c
382
+ #platform: macos
383
+ #scope: file
384
+ static unsigned long long nomen_submit_queue[64];
385
+ static int nomen_submit_count = 0;
386
+ void nomen_submit_push(unsigned long long h) {
387
+ if (nomen_submit_count >= 64) return;
388
+ nomen_submit_queue[nomen_submit_count++] = h;
389
+ }
390
+ long nomen_submit_take(unsigned long long h) {
391
+ for (int i = 0; i < nomen_submit_count; i++) {
392
+ if (nomen_submit_queue[i] == h) {
393
+ for (int j = i; j < nomen_submit_count - 1; j++) {
394
+ nomen_submit_queue[j] = nomen_submit_queue[j + 1];
395
+ }
396
+ nomen_submit_count--;
397
+ return 1;
398
+ }
399
+ }
400
+ return 0;
401
+ }
402
+ static void *nomen_submit_target = 0;
403
+ static void nomen_submit_action(id self, SEL cmd, id sender) {
404
+ (void)self; (void)cmd;
405
+ nomen_submit_push((unsigned long long)(void *)sender);
406
+ }
407
+ static void nomen_submit_arm(unsigned long long handle) {
408
+ Class Tc = objc_getClass("NomenSubmitTarget");
409
+ if (!Tc) {
410
+ Tc = objc_allocateClassPair(objc_getClass("NSObject"), "NomenSubmitTarget", 0);
411
+ if (Tc) {
412
+ class_addMethod(Tc, sel_registerName("submitAction:"), (IMP)nomen_submit_action, "v@:@");
413
+ objc_registerClassPair(Tc);
414
+ }
415
+ }
416
+ if (!nomen_submit_target && Tc) {
417
+ nomen_submit_target = (void *)((id(*)(id, SEL))objc_msgSend)((id)Tc, sel_registerName("new"));
418
+ }
419
+ if (nomen_submit_target) {
420
+ id control = (id)handle;
421
+ ((void(*)(id, SEL, id))objc_msgSend)(control, sel_registerName("setTarget:"), (id)nomen_submit_target);
422
+ ((void(*)(id, SEL, SEL))objc_msgSend)(control, sel_registerName("setAction:"), sel_registerName("submitAction:"));
423
+ }
424
+ }
425
+ ```
426
+ ```
427
+ #arch: aarch64_use_c
428
+ #platform: macos
429
+ nomen_submit_arm(handle);
430
+ ```
431
+ ```
432
+ #arch: c
433
+ #platform: ios
434
+ /* TODO: iOS (see #init) */
435
+ ```
436
+ ```
437
+ #arch: aarch64_use_c
438
+ #platform: ios
439
+ /* TODO: iOS (see #init) */
440
+ ```
441
+ }
442
+
443
+ // Drain a control's selection record: true exactly once per selection
444
+ // change (the record is consumed). Called by the selection-family
445
+ // `take_select` drains — the on_select desugar's arm primitive. The
446
+ // payload is NOT stashed here: the handler body reads it through the
447
+ // control's own selected_index() / selected_row().
448
+ pub func nomen_control_take_select = (uint64 handle, out bool) {
449
+ ```
450
+ #arch: c
451
+ #platform: macos
452
+ extern long nomen_select_take(unsigned long long);
453
+ return (long)nomen_select_take(handle);
454
+ ```
455
+ ```
456
+ #arch: aarch64_use_c
457
+ #platform: macos
458
+ extern long nomen_select_take(unsigned long long);
459
+ return (long)nomen_select_take(handle);
460
+ ```
461
+ ```
462
+ #arch: c
463
+ #platform: ios
464
+ return 0;
465
+ ```
466
+ ```
467
+ #arch: aarch64_use_c
468
+ #platform: ios
469
+ return 0;
470
+ ```
471
+ }