IncludeCPP 3.4.8__py3-none-any.whl → 3.4.21__py3-none-any.whl
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.
- includecpp/__init__.py +1 -1
- includecpp/__init__.pyi +133 -2
- includecpp/cli/commands.py +126 -3
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +1482 -0
- includecpp/core/cssl/__init__.py +8 -6
- includecpp/core/cssl/cssl_builtins.py +243 -5
- includecpp/core/cssl/cssl_parser.py +447 -12
- includecpp/core/cssl/cssl_runtime.py +831 -51
- includecpp/core/cssl/cssl_types.py +522 -7
- includecpp/core/cssl_bridge.py +374 -2
- includecpp/generator/parser.cpp +1 -1
- {includecpp-3.4.8.dist-info → includecpp-3.4.21.dist-info}/METADATA +270 -3
- {includecpp-3.4.8.dist-info → includecpp-3.4.21.dist-info}/RECORD +17 -16
- {includecpp-3.4.8.dist-info → includecpp-3.4.21.dist-info}/WHEEL +0 -0
- {includecpp-3.4.8.dist-info → includecpp-3.4.21.dist-info}/entry_points.txt +0 -0
- {includecpp-3.4.8.dist-info → includecpp-3.4.21.dist-info}/licenses/LICENSE +0 -0
- {includecpp-3.4.8.dist-info → includecpp-3.4.21.dist-info}/top_level.txt +0 -0
|
@@ -64,6 +64,487 @@ class DataStruct(list):
|
|
|
64
64
|
return target_type(self[0])
|
|
65
65
|
return None
|
|
66
66
|
|
|
67
|
+
def begin(self) -> int:
|
|
68
|
+
"""Return iterator to beginning (C++ style)"""
|
|
69
|
+
return 0
|
|
70
|
+
|
|
71
|
+
def end(self) -> int:
|
|
72
|
+
"""Return iterator to end (C++ style)"""
|
|
73
|
+
return len(self)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Stack(list):
|
|
77
|
+
"""Stack data structure (LIFO).
|
|
78
|
+
|
|
79
|
+
Standard stack with push/pop operations.
|
|
80
|
+
|
|
81
|
+
Usage:
|
|
82
|
+
stack<string> myStack;
|
|
83
|
+
myStack.push("Item1");
|
|
84
|
+
myStack.push("Item2");
|
|
85
|
+
item = myStack.pop(); # Returns "Item2"
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
def __init__(self, element_type: str = 'dynamic'):
|
|
89
|
+
super().__init__()
|
|
90
|
+
self._element_type = element_type
|
|
91
|
+
|
|
92
|
+
def push(self, item: Any) -> 'Stack':
|
|
93
|
+
"""Push item onto stack"""
|
|
94
|
+
self.append(item)
|
|
95
|
+
return self
|
|
96
|
+
|
|
97
|
+
def push_back(self, item: Any) -> 'Stack':
|
|
98
|
+
"""Push item onto stack (alias for push)"""
|
|
99
|
+
self.append(item)
|
|
100
|
+
return self
|
|
101
|
+
|
|
102
|
+
def peek(self) -> Any:
|
|
103
|
+
"""View top item without removing"""
|
|
104
|
+
return self[-1] if self else None
|
|
105
|
+
|
|
106
|
+
def is_empty(self) -> bool:
|
|
107
|
+
"""Check if stack is empty"""
|
|
108
|
+
return len(self) == 0
|
|
109
|
+
|
|
110
|
+
def isEmpty(self) -> bool:
|
|
111
|
+
"""Check if stack is empty (camelCase alias)"""
|
|
112
|
+
return len(self) == 0
|
|
113
|
+
|
|
114
|
+
def size(self) -> int:
|
|
115
|
+
"""Return stack size"""
|
|
116
|
+
return len(self)
|
|
117
|
+
|
|
118
|
+
def length(self) -> int:
|
|
119
|
+
"""Return stack length (alias for size)"""
|
|
120
|
+
return len(self)
|
|
121
|
+
|
|
122
|
+
def contains(self, item: Any) -> bool:
|
|
123
|
+
"""Check if stack contains item"""
|
|
124
|
+
return item in self
|
|
125
|
+
|
|
126
|
+
def indexOf(self, item: Any) -> int:
|
|
127
|
+
"""Find index of item (-1 if not found)"""
|
|
128
|
+
try:
|
|
129
|
+
return self.index(item)
|
|
130
|
+
except ValueError:
|
|
131
|
+
return -1
|
|
132
|
+
|
|
133
|
+
def toArray(self) -> list:
|
|
134
|
+
"""Convert stack to array"""
|
|
135
|
+
return list(self)
|
|
136
|
+
|
|
137
|
+
def swap(self) -> 'Stack':
|
|
138
|
+
"""Swap top two elements"""
|
|
139
|
+
if len(self) >= 2:
|
|
140
|
+
self[-1], self[-2] = self[-2], self[-1]
|
|
141
|
+
return self
|
|
142
|
+
|
|
143
|
+
def dup(self) -> 'Stack':
|
|
144
|
+
"""Duplicate top element"""
|
|
145
|
+
if self:
|
|
146
|
+
self.append(self[-1])
|
|
147
|
+
return self
|
|
148
|
+
|
|
149
|
+
def begin(self) -> int:
|
|
150
|
+
"""Return iterator to beginning (C++ style)"""
|
|
151
|
+
return 0
|
|
152
|
+
|
|
153
|
+
def end(self) -> int:
|
|
154
|
+
"""Return iterator to end (C++ style)"""
|
|
155
|
+
return len(self)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class Vector(list):
|
|
159
|
+
"""Dynamic array (vector) data structure.
|
|
160
|
+
|
|
161
|
+
Resizable array with efficient random access.
|
|
162
|
+
|
|
163
|
+
Usage:
|
|
164
|
+
vector<int> myVector;
|
|
165
|
+
myVector.push(1);
|
|
166
|
+
myVector.push(2);
|
|
167
|
+
myVector.at(0); # Returns 1
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
def __init__(self, element_type: str = 'dynamic'):
|
|
171
|
+
super().__init__()
|
|
172
|
+
self._element_type = element_type
|
|
173
|
+
|
|
174
|
+
def push(self, item: Any) -> 'Vector':
|
|
175
|
+
"""Add item to end"""
|
|
176
|
+
self.append(item)
|
|
177
|
+
return self
|
|
178
|
+
|
|
179
|
+
def push_back(self, item: Any) -> 'Vector':
|
|
180
|
+
"""Add item to end (alias for push)"""
|
|
181
|
+
self.append(item)
|
|
182
|
+
return self
|
|
183
|
+
|
|
184
|
+
def push_front(self, item: Any) -> 'Vector':
|
|
185
|
+
"""Add item to front"""
|
|
186
|
+
self.insert(0, item)
|
|
187
|
+
return self
|
|
188
|
+
|
|
189
|
+
def pop_back(self) -> Any:
|
|
190
|
+
"""Remove and return last element"""
|
|
191
|
+
return self.pop() if self else None
|
|
192
|
+
|
|
193
|
+
def pop_front(self) -> Any:
|
|
194
|
+
"""Remove and return first element"""
|
|
195
|
+
return self.pop(0) if self else None
|
|
196
|
+
|
|
197
|
+
def at(self, index: int) -> Any:
|
|
198
|
+
"""Get item at index"""
|
|
199
|
+
if 0 <= index < len(self):
|
|
200
|
+
return self[index]
|
|
201
|
+
return None
|
|
202
|
+
|
|
203
|
+
def set(self, index: int, value: Any) -> 'Vector':
|
|
204
|
+
"""Set item at index"""
|
|
205
|
+
if 0 <= index < len(self):
|
|
206
|
+
self[index] = value
|
|
207
|
+
return self
|
|
208
|
+
|
|
209
|
+
def size(self) -> int:
|
|
210
|
+
"""Return vector size"""
|
|
211
|
+
return len(self)
|
|
212
|
+
|
|
213
|
+
def length(self) -> int:
|
|
214
|
+
"""Return vector length (alias for size)"""
|
|
215
|
+
return len(self)
|
|
216
|
+
|
|
217
|
+
def empty(self) -> bool:
|
|
218
|
+
"""Check if vector is empty"""
|
|
219
|
+
return len(self) == 0
|
|
220
|
+
|
|
221
|
+
def isEmpty(self) -> bool:
|
|
222
|
+
"""Check if vector is empty (camelCase alias)"""
|
|
223
|
+
return len(self) == 0
|
|
224
|
+
|
|
225
|
+
def front(self) -> Any:
|
|
226
|
+
"""Get first element"""
|
|
227
|
+
return self[0] if self else None
|
|
228
|
+
|
|
229
|
+
def back(self) -> Any:
|
|
230
|
+
"""Get last element"""
|
|
231
|
+
return self[-1] if self else None
|
|
232
|
+
|
|
233
|
+
def contains(self, item: Any) -> bool:
|
|
234
|
+
"""Check if vector contains item"""
|
|
235
|
+
return item in self
|
|
236
|
+
|
|
237
|
+
def indexOf(self, item: Any) -> int:
|
|
238
|
+
"""Find index of item (-1 if not found)"""
|
|
239
|
+
try:
|
|
240
|
+
return self.index(item)
|
|
241
|
+
except ValueError:
|
|
242
|
+
return -1
|
|
243
|
+
|
|
244
|
+
def lastIndexOf(self, item: Any) -> int:
|
|
245
|
+
"""Find last index of item (-1 if not found)"""
|
|
246
|
+
for i in range(len(self) - 1, -1, -1):
|
|
247
|
+
if self[i] == item:
|
|
248
|
+
return i
|
|
249
|
+
return -1
|
|
250
|
+
|
|
251
|
+
def find(self, predicate: Callable[[Any], bool]) -> Any:
|
|
252
|
+
"""Find first item matching predicate"""
|
|
253
|
+
for item in self:
|
|
254
|
+
if callable(predicate) and predicate(item):
|
|
255
|
+
return item
|
|
256
|
+
elif item == predicate:
|
|
257
|
+
return item
|
|
258
|
+
return None
|
|
259
|
+
|
|
260
|
+
def findIndex(self, predicate: Callable[[Any], bool]) -> int:
|
|
261
|
+
"""Find index of first item matching predicate"""
|
|
262
|
+
for i, item in enumerate(self):
|
|
263
|
+
if callable(predicate) and predicate(item):
|
|
264
|
+
return i
|
|
265
|
+
elif item == predicate:
|
|
266
|
+
return i
|
|
267
|
+
return -1
|
|
268
|
+
|
|
269
|
+
def slice(self, start: int, end: int = None) -> 'Vector':
|
|
270
|
+
"""Return slice of vector"""
|
|
271
|
+
if end is None:
|
|
272
|
+
result = Vector(self._element_type)
|
|
273
|
+
result.extend(self[start:])
|
|
274
|
+
else:
|
|
275
|
+
result = Vector(self._element_type)
|
|
276
|
+
result.extend(self[start:end])
|
|
277
|
+
return result
|
|
278
|
+
|
|
279
|
+
def join(self, separator: str = ',') -> str:
|
|
280
|
+
"""Join elements into string"""
|
|
281
|
+
return separator.join(str(item) for item in self)
|
|
282
|
+
|
|
283
|
+
def map(self, func: Callable[[Any], Any]) -> 'Vector':
|
|
284
|
+
"""Apply function to all elements"""
|
|
285
|
+
result = Vector(self._element_type)
|
|
286
|
+
result.extend(func(item) for item in self)
|
|
287
|
+
return result
|
|
288
|
+
|
|
289
|
+
def filter(self, predicate: Callable[[Any], bool]) -> 'Vector':
|
|
290
|
+
"""Filter elements by predicate"""
|
|
291
|
+
result = Vector(self._element_type)
|
|
292
|
+
result.extend(item for item in self if predicate(item))
|
|
293
|
+
return result
|
|
294
|
+
|
|
295
|
+
def forEach(self, func: Callable[[Any], None]) -> 'Vector':
|
|
296
|
+
"""Execute function for each element"""
|
|
297
|
+
for item in self:
|
|
298
|
+
func(item)
|
|
299
|
+
return self
|
|
300
|
+
|
|
301
|
+
def toArray(self) -> list:
|
|
302
|
+
"""Convert to plain list"""
|
|
303
|
+
return list(self)
|
|
304
|
+
|
|
305
|
+
def fill(self, value: Any, start: int = 0, end: int = None) -> 'Vector':
|
|
306
|
+
"""Fill range with value"""
|
|
307
|
+
if end is None:
|
|
308
|
+
end = len(self)
|
|
309
|
+
for i in range(start, min(end, len(self))):
|
|
310
|
+
self[i] = value
|
|
311
|
+
return self
|
|
312
|
+
|
|
313
|
+
def every(self, predicate: Callable[[Any], bool]) -> bool:
|
|
314
|
+
"""Check if all elements match predicate"""
|
|
315
|
+
return all(predicate(item) for item in self)
|
|
316
|
+
|
|
317
|
+
def some(self, predicate: Callable[[Any], bool]) -> bool:
|
|
318
|
+
"""Check if any element matches predicate"""
|
|
319
|
+
return any(predicate(item) for item in self)
|
|
320
|
+
|
|
321
|
+
def reduce(self, func: Callable[[Any, Any], Any], initial: Any = None) -> Any:
|
|
322
|
+
"""Reduce vector to single value"""
|
|
323
|
+
from functools import reduce as py_reduce
|
|
324
|
+
if initial is None:
|
|
325
|
+
return py_reduce(func, self)
|
|
326
|
+
return py_reduce(func, self, initial)
|
|
327
|
+
|
|
328
|
+
def begin(self) -> int:
|
|
329
|
+
"""Return iterator to beginning (C++ style)"""
|
|
330
|
+
return 0
|
|
331
|
+
|
|
332
|
+
def end(self) -> int:
|
|
333
|
+
"""Return iterator to end (C++ style)"""
|
|
334
|
+
return len(self)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
class Array(list):
|
|
338
|
+
"""Array data structure with CSSL methods.
|
|
339
|
+
|
|
340
|
+
Standard array with push/pop/length operations.
|
|
341
|
+
|
|
342
|
+
Usage:
|
|
343
|
+
array<string> arr;
|
|
344
|
+
arr.push("Item");
|
|
345
|
+
arr.length(); # Returns 1
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
def __init__(self, element_type: str = 'dynamic'):
|
|
349
|
+
super().__init__()
|
|
350
|
+
self._element_type = element_type
|
|
351
|
+
|
|
352
|
+
def push(self, item: Any) -> 'Array':
|
|
353
|
+
"""Add item to end"""
|
|
354
|
+
self.append(item)
|
|
355
|
+
return self
|
|
356
|
+
|
|
357
|
+
def push_back(self, item: Any) -> 'Array':
|
|
358
|
+
"""Add item to end (alias for push)"""
|
|
359
|
+
self.append(item)
|
|
360
|
+
return self
|
|
361
|
+
|
|
362
|
+
def push_front(self, item: Any) -> 'Array':
|
|
363
|
+
"""Add item to front"""
|
|
364
|
+
self.insert(0, item)
|
|
365
|
+
return self
|
|
366
|
+
|
|
367
|
+
def pop_back(self) -> Any:
|
|
368
|
+
"""Remove and return last element"""
|
|
369
|
+
return self.pop() if self else None
|
|
370
|
+
|
|
371
|
+
def pop_front(self) -> Any:
|
|
372
|
+
"""Remove and return first element"""
|
|
373
|
+
return self.pop(0) if self else None
|
|
374
|
+
|
|
375
|
+
def at(self, index: int) -> Any:
|
|
376
|
+
"""Get item at index"""
|
|
377
|
+
if 0 <= index < len(self):
|
|
378
|
+
return self[index]
|
|
379
|
+
return None
|
|
380
|
+
|
|
381
|
+
def set(self, index: int, value: Any) -> 'Array':
|
|
382
|
+
"""Set item at index"""
|
|
383
|
+
if 0 <= index < len(self):
|
|
384
|
+
self[index] = value
|
|
385
|
+
return self
|
|
386
|
+
|
|
387
|
+
def size(self) -> int:
|
|
388
|
+
"""Return array size"""
|
|
389
|
+
return len(self)
|
|
390
|
+
|
|
391
|
+
def length(self) -> int:
|
|
392
|
+
"""Return array length"""
|
|
393
|
+
return len(self)
|
|
394
|
+
|
|
395
|
+
def empty(self) -> bool:
|
|
396
|
+
"""Check if array is empty"""
|
|
397
|
+
return len(self) == 0
|
|
398
|
+
|
|
399
|
+
def isEmpty(self) -> bool:
|
|
400
|
+
"""Check if array is empty (camelCase alias)"""
|
|
401
|
+
return len(self) == 0
|
|
402
|
+
|
|
403
|
+
def first(self) -> Any:
|
|
404
|
+
"""Get first element"""
|
|
405
|
+
return self[0] if self else None
|
|
406
|
+
|
|
407
|
+
def last(self) -> Any:
|
|
408
|
+
"""Get last element"""
|
|
409
|
+
return self[-1] if self else None
|
|
410
|
+
|
|
411
|
+
def contains(self, item: Any) -> bool:
|
|
412
|
+
"""Check if array contains item"""
|
|
413
|
+
return item in self
|
|
414
|
+
|
|
415
|
+
def indexOf(self, item: Any) -> int:
|
|
416
|
+
"""Find index of item (-1 if not found)"""
|
|
417
|
+
try:
|
|
418
|
+
return self.index(item)
|
|
419
|
+
except ValueError:
|
|
420
|
+
return -1
|
|
421
|
+
|
|
422
|
+
def lastIndexOf(self, item: Any) -> int:
|
|
423
|
+
"""Find last index of item (-1 if not found)"""
|
|
424
|
+
for i in range(len(self) - 1, -1, -1):
|
|
425
|
+
if self[i] == item:
|
|
426
|
+
return i
|
|
427
|
+
return -1
|
|
428
|
+
|
|
429
|
+
def find(self, predicate: Callable[[Any], bool]) -> Any:
|
|
430
|
+
"""Find first item matching predicate"""
|
|
431
|
+
for item in self:
|
|
432
|
+
if callable(predicate) and predicate(item):
|
|
433
|
+
return item
|
|
434
|
+
elif item == predicate:
|
|
435
|
+
return item
|
|
436
|
+
return None
|
|
437
|
+
|
|
438
|
+
def findIndex(self, predicate: Callable[[Any], bool]) -> int:
|
|
439
|
+
"""Find index of first item matching predicate"""
|
|
440
|
+
for i, item in enumerate(self):
|
|
441
|
+
if callable(predicate) and predicate(item):
|
|
442
|
+
return i
|
|
443
|
+
elif item == predicate:
|
|
444
|
+
return i
|
|
445
|
+
return -1
|
|
446
|
+
|
|
447
|
+
def slice(self, start: int, end: int = None) -> 'Array':
|
|
448
|
+
"""Return slice of array"""
|
|
449
|
+
if end is None:
|
|
450
|
+
result = Array(self._element_type)
|
|
451
|
+
result.extend(self[start:])
|
|
452
|
+
else:
|
|
453
|
+
result = Array(self._element_type)
|
|
454
|
+
result.extend(self[start:end])
|
|
455
|
+
return result
|
|
456
|
+
|
|
457
|
+
def join(self, separator: str = ',') -> str:
|
|
458
|
+
"""Join elements into string"""
|
|
459
|
+
return separator.join(str(item) for item in self)
|
|
460
|
+
|
|
461
|
+
def map(self, func: Callable[[Any], Any]) -> 'Array':
|
|
462
|
+
"""Apply function to all elements"""
|
|
463
|
+
result = Array(self._element_type)
|
|
464
|
+
result.extend(func(item) for item in self)
|
|
465
|
+
return result
|
|
466
|
+
|
|
467
|
+
def filter(self, predicate: Callable[[Any], bool]) -> 'Array':
|
|
468
|
+
"""Filter elements by predicate"""
|
|
469
|
+
result = Array(self._element_type)
|
|
470
|
+
result.extend(item for item in self if predicate(item))
|
|
471
|
+
return result
|
|
472
|
+
|
|
473
|
+
def forEach(self, func: Callable[[Any], None]) -> 'Array':
|
|
474
|
+
"""Execute function for each element"""
|
|
475
|
+
for item in self:
|
|
476
|
+
func(item)
|
|
477
|
+
return self
|
|
478
|
+
|
|
479
|
+
def toArray(self) -> list:
|
|
480
|
+
"""Convert to plain list"""
|
|
481
|
+
return list(self)
|
|
482
|
+
|
|
483
|
+
def fill(self, value: Any, start: int = 0, end: int = None) -> 'Array':
|
|
484
|
+
"""Fill range with value"""
|
|
485
|
+
if end is None:
|
|
486
|
+
end = len(self)
|
|
487
|
+
for i in range(start, min(end, len(self))):
|
|
488
|
+
self[i] = value
|
|
489
|
+
return self
|
|
490
|
+
|
|
491
|
+
def every(self, predicate: Callable[[Any], bool]) -> bool:
|
|
492
|
+
"""Check if all elements match predicate"""
|
|
493
|
+
return all(predicate(item) for item in self)
|
|
494
|
+
|
|
495
|
+
def some(self, predicate: Callable[[Any], bool]) -> bool:
|
|
496
|
+
"""Check if any element matches predicate"""
|
|
497
|
+
return any(predicate(item) for item in self)
|
|
498
|
+
|
|
499
|
+
def reduce(self, func: Callable[[Any, Any], Any], initial: Any = None) -> Any:
|
|
500
|
+
"""Reduce array to single value"""
|
|
501
|
+
from functools import reduce as py_reduce
|
|
502
|
+
if initial is None:
|
|
503
|
+
return py_reduce(func, self)
|
|
504
|
+
return py_reduce(func, self, initial)
|
|
505
|
+
|
|
506
|
+
def concat(self, *arrays) -> 'Array':
|
|
507
|
+
"""Concatenate with other arrays"""
|
|
508
|
+
result = Array(self._element_type)
|
|
509
|
+
result.extend(self)
|
|
510
|
+
for arr in arrays:
|
|
511
|
+
result.extend(arr)
|
|
512
|
+
return result
|
|
513
|
+
|
|
514
|
+
def flat(self, depth: int = 1) -> 'Array':
|
|
515
|
+
"""Flatten nested arrays"""
|
|
516
|
+
result = Array(self._element_type)
|
|
517
|
+
for item in self:
|
|
518
|
+
if isinstance(item, (list, Array)) and depth > 0:
|
|
519
|
+
if depth == 1:
|
|
520
|
+
result.extend(item)
|
|
521
|
+
else:
|
|
522
|
+
nested = Array(self._element_type)
|
|
523
|
+
nested.extend(item)
|
|
524
|
+
result.extend(nested.flat(depth - 1))
|
|
525
|
+
else:
|
|
526
|
+
result.append(item)
|
|
527
|
+
return result
|
|
528
|
+
|
|
529
|
+
def unique(self) -> 'Array':
|
|
530
|
+
"""Return array with unique elements"""
|
|
531
|
+
result = Array(self._element_type)
|
|
532
|
+
seen = set()
|
|
533
|
+
for item in self:
|
|
534
|
+
key = item if isinstance(item, (int, str, float, bool)) else id(item)
|
|
535
|
+
if key not in seen:
|
|
536
|
+
seen.add(key)
|
|
537
|
+
result.append(item)
|
|
538
|
+
return result
|
|
539
|
+
|
|
540
|
+
def begin(self) -> int:
|
|
541
|
+
"""Return iterator to beginning (C++ style)"""
|
|
542
|
+
return 0
|
|
543
|
+
|
|
544
|
+
def end(self) -> int:
|
|
545
|
+
"""Return iterator to end (C++ style)"""
|
|
546
|
+
return len(self)
|
|
547
|
+
|
|
67
548
|
|
|
68
549
|
class Shuffled(list):
|
|
69
550
|
"""Unorganized fast storage for multiple returns.
|
|
@@ -356,10 +837,13 @@ class Parameter:
|
|
|
356
837
|
parameter.get(1) # Get second argument
|
|
357
838
|
parameter.count() # Get total argument count
|
|
358
839
|
parameter.all() # Get all arguments as list
|
|
840
|
+
parameter.return(value) # Yield a return value (generator-like)
|
|
841
|
+
parameter.returns() # Get all yielded return values
|
|
359
842
|
"""
|
|
360
843
|
|
|
361
844
|
def __init__(self, args: List[Any] = None):
|
|
362
845
|
self._args = args if args is not None else []
|
|
846
|
+
self._returns: List[Any] = []
|
|
363
847
|
|
|
364
848
|
def get(self, index: int, default: Any = None) -> Any:
|
|
365
849
|
"""Get argument at index, returns default if not found"""
|
|
@@ -379,6 +863,27 @@ class Parameter:
|
|
|
379
863
|
"""Check if argument exists at index"""
|
|
380
864
|
return 0 <= index < len(self._args)
|
|
381
865
|
|
|
866
|
+
# Using 'return_' to avoid Python keyword conflict
|
|
867
|
+
def return_(self, value: Any) -> None:
|
|
868
|
+
"""Yield a return value (generator-like behavior).
|
|
869
|
+
|
|
870
|
+
Multiple calls accumulate values that can be retrieved via returns().
|
|
871
|
+
The CSSL runtime will collect these as the exec() return value.
|
|
872
|
+
"""
|
|
873
|
+
self._returns.append(value)
|
|
874
|
+
|
|
875
|
+
def returns(self) -> List[Any]:
|
|
876
|
+
"""Get all yielded return values"""
|
|
877
|
+
return list(self._returns)
|
|
878
|
+
|
|
879
|
+
def clear_returns(self) -> None:
|
|
880
|
+
"""Clear all yielded return values"""
|
|
881
|
+
self._returns.clear()
|
|
882
|
+
|
|
883
|
+
def has_returns(self) -> bool:
|
|
884
|
+
"""Check if any values have been returned"""
|
|
885
|
+
return len(self._returns) > 0
|
|
886
|
+
|
|
382
887
|
def __iter__(self):
|
|
383
888
|
return iter(self._args)
|
|
384
889
|
|
|
@@ -424,15 +929,25 @@ def create_dataspace(space_type: str = 'dynamic') -> DataSpace:
|
|
|
424
929
|
def create_openquote(db_ref: Any = None) -> OpenQuote:
|
|
425
930
|
return OpenQuote(db_ref)
|
|
426
931
|
|
|
932
|
+
def create_stack(element_type: str = 'dynamic') -> Stack:
|
|
933
|
+
return Stack(element_type)
|
|
427
934
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
'OpenFind', 'Parameter',
|
|
431
|
-
'create_datastruct', 'create_shuffled', 'create_iterator',
|
|
432
|
-
'create_combo', 'create_dataspace', 'create_openquote', 'create_parameter'
|
|
433
|
-
]
|
|
434
|
-
|
|
935
|
+
def create_vector(element_type: str = 'dynamic') -> Vector:
|
|
936
|
+
return Vector(element_type)
|
|
435
937
|
|
|
436
938
|
def create_parameter(args: List[Any] = None) -> Parameter:
|
|
437
939
|
"""Create a Parameter object for accessing exec arguments"""
|
|
438
940
|
return Parameter(args)
|
|
941
|
+
|
|
942
|
+
def create_array(element_type: str = 'dynamic') -> Array:
|
|
943
|
+
"""Create an Array object"""
|
|
944
|
+
return Array(element_type)
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
__all__ = [
|
|
948
|
+
'DataStruct', 'Shuffled', 'Iterator', 'Combo', 'DataSpace', 'OpenQuote',
|
|
949
|
+
'OpenFind', 'Parameter', 'Stack', 'Vector', 'Array',
|
|
950
|
+
'create_datastruct', 'create_shuffled', 'create_iterator',
|
|
951
|
+
'create_combo', 'create_dataspace', 'create_openquote', 'create_parameter',
|
|
952
|
+
'create_stack', 'create_vector', 'create_array'
|
|
953
|
+
]
|