nomen-lang 0.7.0 → 0.8.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 (50) hide show
  1. package/core/System/Buffer.nm +32 -0
  2. package/core/System/ClassBuffer.nm +24 -0
  3. package/core/System/Controls/Alert.nm +326 -0
  4. package/core/System/Controls/App.nm +147 -0
  5. package/core/System/Controls/Button.nm +119 -1
  6. package/core/System/Controls/CheckBox.nm +24 -0
  7. package/core/System/Controls/ColorPicker.nm +307 -0
  8. package/core/System/Controls/ComboBox.nm +430 -0
  9. package/core/System/Controls/Container.nm +837 -9
  10. package/core/System/Controls/Control.nm +443 -0
  11. package/core/System/Controls/DatePicker.nm +288 -0
  12. package/core/System/Controls/Form.nm +70 -0
  13. package/core/System/Controls/GroupBox.nm +267 -0
  14. package/core/System/Controls/ImageView.nm +311 -0
  15. package/core/System/Controls/LevelIndicator.nm +305 -0
  16. package/core/System/Controls/ListView.nm +633 -0
  17. package/core/System/Controls/Menu.nm +428 -0
  18. package/core/System/Controls/NumberInput.nm +56 -0
  19. package/core/System/Controls/OtpInput.nm +50 -0
  20. package/core/System/Controls/OutlineView.nm +598 -0
  21. package/core/System/Controls/Pagination.nm +142 -0
  22. package/core/System/Controls/Popover.nm +296 -0
  23. package/core/System/Controls/Progress.nm +348 -0
  24. package/core/System/Controls/Radio.nm +292 -0
  25. package/core/System/Controls/Scrollable.nm +584 -0
  26. package/core/System/Controls/SearchField.nm +326 -0
  27. package/core/System/Controls/SecureField.nm +344 -0
  28. package/core/System/Controls/Segmented.nm +380 -0
  29. package/core/System/Controls/Select.nm +340 -0
  30. package/core/System/Controls/Separator.nm +198 -0
  31. package/core/System/Controls/Sheet.nm +329 -0
  32. package/core/System/Controls/Slider.nm +315 -0
  33. package/core/System/Controls/Spinner.nm +287 -0
  34. package/core/System/Controls/SplitView.nm +509 -0
  35. package/core/System/Controls/Stepper.nm +349 -0
  36. package/core/System/Controls/Switch.nm +259 -0
  37. package/core/System/Controls/Table.nm +833 -0
  38. package/core/System/Controls/Tabs.nm +500 -0
  39. package/core/System/Controls/Text.nm +108 -11
  40. package/core/System/Controls/TextBox.nm +112 -1
  41. package/core/System/Controls/TextView.nm +329 -0
  42. package/core/System/Controls/Toggle.nm +346 -0
  43. package/core/System/Controls/Toolbar.nm +501 -0
  44. package/core/System/Controls/Tooltip.nm +76 -0
  45. package/core/System/Controls/Window.nm +1549 -91
  46. package/core/System/List.nm +34 -0
  47. package/core/System/Map.nm +21 -4
  48. package/core/System/Set.nm +14 -0
  49. package/dist/index.mjs +3425 -710
  50. package/package.json +1 -1
@@ -73,6 +73,40 @@ pub mv struct List<T>: Viewable {
73
73
  panic("index out of range")
74
74
  }
75
75
 
76
+ // Address of element `i` (library-only): the ELEMENT BORROW primitive —
77
+ // `ref T x = list.at(i)` (docs/HANDLERS.md Stage 4, dynamic-tree
78
+ // dispatch) lowers to this, binding the alias to the slot itself rather
79
+ // than to a bitwise copy. The pointer is valid while the list is
80
+ // exclusively borrowed and not resized; a `ref self` call on the list
81
+ // invalidates the borrow through the ordinary borrow-invalidation
82
+ // rules. The length constraint is the caller's proof obligation — the
83
+ // handler desugar's synthesized loops satisfy it from the loop
84
+ // condition, exactly like `.at`.
85
+ pub func slot_ptr = (ref self, int i: i >= 0 && i < self.length, out ptr T) {
86
+ return self.items.slot_ptr(i)
87
+ }
88
+
89
+ // Bounds-checked removal that traps when i is outside [0, self.length) —
90
+ // same contract as at_or_panic/set_or_panic, for indices that can't be
91
+ // proven at compile time. The element is moved out (later elements
92
+ // backward-shift into place) and returned: the caller owns it, so its
93
+ // resources are reclaimed when the binding's scope ends — binding the
94
+ // result in a nested block is the way to free an owning element at a
95
+ // chosen point (its #destroy runs at the block's closing brace).
96
+ pub func remove_at_or_panic = (ref self, int i, mv out T) {
97
+ if i < 0 || i >= self.length {
98
+ panic("index out of range")
99
+ }
100
+ var T v = self.items.move(i)
101
+ var int last = self.length - 1
102
+ var int j = i
103
+ while j < last; j += 1 {
104
+ self.items.shift(j, j + 1)
105
+ }
106
+ self.length -= 1
107
+ return v
108
+ }
109
+
76
110
  // A deep copy: a fresh List<T> with an independent copy of every element.
77
111
  // For mv element types (strings, mv value structs) each slot in the
78
112
  // copy owns its own heap data (Buffer deep-copies on store), so the source
@@ -17,13 +17,16 @@ pub mv struct Map<TK: Hashable + Equatable, TV> {
17
17
  // Variadic-tuple constructor: Map<string, int>(["a", 1], ["b", 2]) or
18
18
  // Map(["a", 1], ["b", 2]) (type args inferred from the first pair).
19
19
  // Zero pairs yields an empty Map, so this also covers Map<K, V>().
20
- // The pair reads are temp-rooted (`pairs.at(i)` is a statement temp):
21
- // the element transfer is absorbed by set's mv store (store_T
22
- // deep-copies string-field elements), so no explicit mv is spelled.
20
+ // Each pair is read into a local and its fields are MV-DESTRUCTURED into
21
+ // bindings, so set's mv store receives an explicit transfer chain — no
22
+ // temp-rooted read exemption involved. (String bindings lower as the
23
+ // borrow-copy convention: the slot's owner reclaims heap bytes, and the
24
+ // callee materializes its own copy.)
23
25
  pub func #init = (self, ...[TK, TV] pairs) {
24
26
  var i = 0
25
27
  while i < pairs.length; i += 1 {
26
- self.set(pairs.at(i)._0, pairs.at(i)._1)
28
+ var [mv k, mv v] = pairs.at(i)
29
+ self.set(mv k, mv v)
27
30
  }
28
31
  }
29
32
 
@@ -155,6 +158,20 @@ pub mv struct Map<TK: Hashable + Equatable, TV> {
155
158
  self.length = self.length - 1
156
159
  }
157
160
 
161
+ // An independent copy: a fresh Map whose every member slab is a fresh
162
+ // `Buffer.copy` (which deep-copies mv key/value elements), with the same
163
+ // length and entries. Not available for class/trait keys or values (the
164
+ // member routes to ClassBuffer, which has no copy — the checker rejects
165
+ // the call; see the copy gate in check_access_node).
166
+ pub func copy = (self, out Map<TK, TV>) {
167
+ var dst = Map<TK, TV>()
168
+ dst.keys = self.keys.copy()
169
+ dst.values = self.values.copy()
170
+ dst.used = self.used.copy()
171
+ dst.length = self.length
172
+ return dst
173
+ }
174
+
158
175
  func find_slot = (self, TK key, int cap, out int: out >= 0 && out < cap) {
159
176
  // cap is a power of two, so this is `hash mod cap` via a mask —
160
177
  // non-negative for any hash (two's complement), no adjustment.
@@ -131,6 +131,20 @@ pub mv struct Set<T: Hashable + Equatable> {
131
131
  self.length = self.length - 1
132
132
  }
133
133
 
134
+ // An independent copy: a fresh Set whose both member slabs are fresh
135
+ // `Buffer.copy` calls (which deep-copy mv elements), with the same length
136
+ // and entries. Not available for class/trait elements (the member routes
137
+ // to ClassBuffer, which has no copy — the checker rejects the call; the
138
+ // shape is also unreachable today since `T: Hashable + Equatable` cannot
139
+ // be a trait without trait-conformance syntax).
140
+ pub func copy = (self, out Set<T>) {
141
+ var dst = Set<T>()
142
+ dst.slots = self.slots.copy()
143
+ dst.used = self.used.copy()
144
+ dst.length = self.length
145
+ return dst
146
+ }
147
+
134
148
  func find_slot = (self, T value, int cap, out int: out >= 0 && out < cap) {
135
149
  // cap is a power of two: `hash mod cap` via a mask, non-negative
136
150
  // for any hash — no adjustment needed.