nomen-lang 0.0.6 → 0.0.8

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 (115) hide show
  1. package/NOMEN_AGENTS.md +235 -0
  2. package/core/System/Ansi.nm +150 -0
  3. package/core/System/Array.nm +358 -0
  4. package/core/System/BigInt.nm +887 -0
  5. package/core/System/Buffer.nm +526 -0
  6. package/core/System/Channel.nm +198 -0
  7. package/core/System/ClassBuffer.nm +229 -0
  8. package/core/System/Console.nm +211 -0
  9. package/core/System/Controls/Button.nm +138 -0
  10. package/core/System/Controls/CheckBox.nm +158 -0
  11. package/core/System/Controls/Container.nm +1562 -0
  12. package/core/System/Controls/Control.nm +28 -0
  13. package/core/System/Controls/Geometry.nm +101 -0
  14. package/core/System/Controls/Layout.nm +228 -0
  15. package/core/System/Controls/LayoutParams.nm +50 -0
  16. package/core/System/Controls/Text.nm +129 -0
  17. package/core/System/Controls/TextBox.nm +157 -0
  18. package/core/System/Controls/Window.nm +280 -0
  19. package/core/System/Disposable.nm +8 -0
  20. package/core/System/Enumerable.nm +10 -0
  21. package/core/System/Equatable.nm +10 -0
  22. package/core/System/Graph.nm +68 -0
  23. package/core/System/Hashable.nm +13 -0
  24. package/core/System/Init.nm +21 -0
  25. package/core/System/LinkedList.nm +64 -0
  26. package/core/System/List.nm +44 -0
  27. package/core/System/Map.nm +153 -0
  28. package/core/System/Math.nm +54 -0
  29. package/core/System/Mutex.nm +78 -0
  30. package/core/System/Nursery.nm +27 -0
  31. package/core/System/Sendable.nm +9 -0
  32. package/core/System/Set.nm +97 -0
  33. package/core/System/Stream/Directory.nm +176 -0
  34. package/core/System/Stream/File.nm +432 -0
  35. package/core/System/Stream/Http.nm +453 -0
  36. package/core/System/String.nm +154 -0
  37. package/core/System/StringBuilder.nm +249 -0
  38. package/core/System/Stringable.nm +8 -0
  39. package/core/System/Task.nm +263 -0
  40. package/core/System/Test.nm +241 -0
  41. package/core/System/Text/Json.nm +377 -0
  42. package/core/System/Text/JsonTree.nm +187 -0
  43. package/core/System/Text/Regex.nm +655 -0
  44. package/core/System/Time.nm +112 -0
  45. package/core/System/Tree.nm +70 -0
  46. package/core/System/Viewable.nm +27 -0
  47. package/core/System/bool.nm +66 -0
  48. package/core/System/char.nm +42 -0
  49. package/core/System/float.nm +43 -0
  50. package/core/System/int.nm +54 -0
  51. package/core/System/int64.nm +42 -0
  52. package/core/System/int8.nm +42 -0
  53. package/core/System/uint.nm +42 -0
  54. package/core/System/uint64.nm +42 -0
  55. package/core/System/uint8.nm +42 -0
  56. package/core/docs/System/Ansi.md +40 -0
  57. package/core/docs/System/Array.md +16 -0
  58. package/core/docs/System/BigInt.md +30 -0
  59. package/core/docs/System/Buffer.md +31 -0
  60. package/core/docs/System/Channel.md +10 -0
  61. package/core/docs/System/ClassBuffer.md +15 -0
  62. package/core/docs/System/Console.md +13 -0
  63. package/core/docs/System/Controls/Button.md +12 -0
  64. package/core/docs/System/Controls/CheckBox.md +15 -0
  65. package/core/docs/System/Controls/Container.md +82 -0
  66. package/core/docs/System/Controls/Control.md +5 -0
  67. package/core/docs/System/Controls/Geometry.md +26 -0
  68. package/core/docs/System/Controls/Layout.md +37 -0
  69. package/core/docs/System/Controls/LayoutParams.md +13 -0
  70. package/core/docs/System/Controls/Text.md +12 -0
  71. package/core/docs/System/Controls/TextBox.md +13 -0
  72. package/core/docs/System/Controls/Window.md +20 -0
  73. package/core/docs/System/Disposable.md +5 -0
  74. package/core/docs/System/Enumerable.md +5 -0
  75. package/core/docs/System/Graph.md +17 -0
  76. package/core/docs/System/Init.md +9 -0
  77. package/core/docs/System/LinkedList.md +16 -0
  78. package/core/docs/System/List.md +13 -0
  79. package/core/docs/System/Map.md +14 -0
  80. package/core/docs/System/Math.md +11 -0
  81. package/core/docs/System/Mutex.md +10 -0
  82. package/core/docs/System/Nursery.md +5 -0
  83. package/core/docs/System/Sendable.md +5 -0
  84. package/core/docs/System/Set.md +14 -0
  85. package/core/docs/System/Stream/Directory.md +12 -0
  86. package/core/docs/System/Stream/File.md +21 -0
  87. package/core/docs/System/String.md +14 -0
  88. package/core/docs/System/StringBuilder.md +12 -0
  89. package/core/docs/System/Stringable.md +5 -0
  90. package/core/docs/System/Task.md +15 -0
  91. package/core/docs/System/Text/Json.md +12 -0
  92. package/core/docs/System/Text/JsonTree.md +21 -0
  93. package/core/docs/System/Text/Regex.md +12 -0
  94. package/core/docs/System/Time.md +11 -0
  95. package/core/docs/System/Tree.md +18 -0
  96. package/core/docs/System/Viewable.md +5 -0
  97. package/core/docs/System/bool.md +9 -0
  98. package/core/docs/System/char.md +9 -0
  99. package/core/docs/System/float.md +9 -0
  100. package/core/docs/System/int.md +10 -0
  101. package/core/docs/System/int64.md +9 -0
  102. package/core/docs/System/int8.md +9 -0
  103. package/core/docs/System/uint.md +9 -0
  104. package/core/docs/System/uint64.md +9 -0
  105. package/core/docs/System/uint8.md +9 -0
  106. package/core/package.jsonc +4 -0
  107. package/dist/index.mjs +17039 -21482
  108. package/package.json +33 -30
  109. package/src/args.ts +171 -0
  110. package/src/bench_loop.nm +113 -0
  111. package/src/index.ts +61 -95
  112. package/src/init.ts +128 -0
  113. package/src/test.ts +522 -0
  114. package/tsconfig.json +0 -21
  115. package/vite.config.ts +0 -7
@@ -0,0 +1,158 @@
1
+ /**
2
+ * A toggle control with a title and checked/hidden state
3
+ **/
4
+ pub class CheckBox : Control {
5
+ var uint64 handle = 0
6
+
7
+ pub func #init = (self, Window window) {
8
+ ```
9
+ #arch: c, aarch64_use_c
10
+ #platform: macos
11
+ id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
12
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
13
+ sel_registerName("initWithFrame:"),
14
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
15
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
16
+ cb, sel_registerName("setButtonType:"), 3); // NSSwitchButton = 3
17
+ ((void(*)(id, SEL, long))objc_msgSend)(
18
+ cb, sel_registerName("setState:"), 0); // NSControlStateValueOff = 0
19
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
20
+ (id)window->handle, sel_registerName("contentView"));
21
+ ((void(*)(id, SEL, id))objc_msgSend)(
22
+ contentView, sel_registerName("addSubview:"), cb);
23
+ self->handle = (uint64_t)cb;
24
+ ```
25
+ ```
26
+ #arch: c, aarch64_use_c
27
+ #platform: ios
28
+ id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
29
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UISwitch"), sel_registerName("alloc")),
30
+ sel_registerName("initWithFrame:"),
31
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 100, 24));
32
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
33
+ ((id(*)(id, SEL))objc_msgSend)(
34
+ (id)window->handle, sel_registerName("rootViewController")),
35
+ sel_registerName("view"));
36
+ ((void(*)(id, SEL, id))objc_msgSend)(
37
+ parentView, sel_registerName("addSubview:"), cb);
38
+ self->handle = (uint64_t)cb;
39
+ ```
40
+ }
41
+
42
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
43
+ ```
44
+ #arch: c, aarch64_use_c
45
+ #platform: macos
46
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
47
+ (id)self->handle, sel_registerName("setFrame:"),
48
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
49
+ ```
50
+ ```
51
+ #arch: c, aarch64_use_c
52
+ #platform: ios
53
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
54
+ (id)self->handle, sel_registerName("setFrame:"),
55
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
56
+ ```
57
+ }
58
+
59
+ pub func set_title = (self, string title) {
60
+ ```
61
+ #arch: c, aarch64_use_c
62
+ #platform: macos
63
+ ((void(*)(id, SEL, id))objc_msgSend)(
64
+ (id)self->handle, sel_registerName("setTitle:"),
65
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
66
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
67
+ ```
68
+ }
69
+
70
+ pub func set_checked = (self, bool checked) {
71
+ ```
72
+ #arch: c, aarch64_use_c
73
+ #platform: macos
74
+ ((void(*)(id, SEL, long))objc_msgSend)(
75
+ (id)self->handle, sel_registerName("setState:"),
76
+ checked ? 1 : 0); // NSControlStateValueOn = 1, Off = 0
77
+ ```
78
+ ```
79
+ #arch: c, aarch64_use_c
80
+ #platform: ios
81
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
82
+ (id)self->handle, sel_registerName("setOn:"), checked ? 1 : 0);
83
+ ```
84
+ }
85
+
86
+ pub func is_checked = (self, out bool) {
87
+ ```
88
+ #arch: c, aarch64_use_c
89
+ #platform: macos
90
+ long state = ((long(*)(id, SEL))objc_msgSend)(
91
+ (id)self->handle, sel_registerName("state"));
92
+ return state == 1; // NSControlStateValueOn = 1
93
+ ```
94
+ ```
95
+ #arch: c, aarch64_use_c
96
+ #platform: ios
97
+ BOOL on = ((BOOL(*)(id, SEL))objc_msgSend)(
98
+ (id)self->handle, sel_registerName("isOn"));
99
+ return on ? 1 : 0;
100
+ ```
101
+ }
102
+
103
+ pub func set_hidden = (self, bool hidden) {
104
+ ```
105
+ #arch: c, aarch64_use_c
106
+ #platform: macos
107
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
108
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
109
+ ```
110
+ }
111
+
112
+ // ── Control trait conformance ──
113
+ pub func intrinsic_size = (self, out Size) {
114
+ var [w, h] = native_intrinsic(self.handle)
115
+ var Size s = Size()
116
+ s.width = w
117
+ s.height = h
118
+ return s
119
+ }
120
+
121
+ pub func measure = (self, BoxConstraints constraints, out Size) {
122
+ var Size s = self.intrinsic_size()
123
+ if s.width > constraints.max_width {
124
+ s.width = constraints.max_width
125
+ }
126
+ if s.width < constraints.min_width {
127
+ s.width = constraints.min_width
128
+ }
129
+ if s.height > constraints.max_height {
130
+ s.height = constraints.max_height
131
+ }
132
+ if s.height < constraints.min_height {
133
+ s.height = constraints.min_height
134
+ }
135
+ return s
136
+ }
137
+
138
+ func #destroy = () {
139
+ ```
140
+ #arch: c, aarch64_use_c
141
+ #platform: macos
142
+ if (self->handle) {
143
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
144
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
145
+ self->handle = 0;
146
+ }
147
+ ```
148
+ ```
149
+ #arch: c, aarch64_use_c
150
+ #platform: ios
151
+ if (self->handle) {
152
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
153
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
154
+ self->handle = 0;
155
+ }
156
+ ```
157
+ }
158
+ }