IncludeCPP 3.7.1__py3-none-any.whl → 3.7.25__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.
@@ -307,6 +307,10 @@ class CSSLBuiltins:
307
307
  self._functions['dataspace'] = self.builtin_dataspace
308
308
  self._functions['openquote'] = self.builtin_openquote
309
309
  self._functions['OpenFind'] = self.builtin_openfind
310
+ self._functions['vector'] = self.builtin_vector
311
+ self._functions['array'] = self.builtin_array
312
+ self._functions['stack'] = self.builtin_stack
313
+ self._functions['map'] = self.builtin_map
310
314
 
311
315
  # Print aliases for CSSL
312
316
  self._functions['printl'] = self.builtin_println # CSSL uses printl for println
@@ -433,13 +437,50 @@ class CSSLBuiltins:
433
437
  # ============= Type Checking =============
434
438
 
435
439
  def builtin_typeof(self, value: Any) -> str:
436
- """Get type name"""
440
+ """Get type name - returns CSSL-specific type names for CSSL types"""
437
441
  if value is None:
438
442
  return 'null'
443
+
444
+ # Check CSSL-specific types first
445
+ from .cssl_types import (Vector, Array, Stack, DataStruct,
446
+ List as CSSLList, Dictionary, Map,
447
+ Shuffled, Iterator, Combo, DataSpace,
448
+ OpenQuote, Parameter, CSSLInstance)
449
+
450
+ if isinstance(value, Vector):
451
+ return 'vector'
452
+ elif isinstance(value, Array):
453
+ return 'array'
454
+ elif isinstance(value, Stack):
455
+ return 'stack'
456
+ elif isinstance(value, DataStruct):
457
+ return 'datastruct'
458
+ elif isinstance(value, CSSLList):
459
+ return 'list'
460
+ elif isinstance(value, Dictionary):
461
+ return 'dictionary'
462
+ elif isinstance(value, Map):
463
+ return 'map'
464
+ elif isinstance(value, Shuffled):
465
+ return 'shuffled'
466
+ elif isinstance(value, Iterator):
467
+ return 'iterator'
468
+ elif isinstance(value, Combo):
469
+ return 'combo'
470
+ elif isinstance(value, DataSpace):
471
+ return 'dataspace'
472
+ elif isinstance(value, OpenQuote):
473
+ return 'openquote'
474
+ elif isinstance(value, Parameter):
475
+ return 'parameter'
476
+ elif isinstance(value, CSSLInstance):
477
+ return value._class.name
478
+
479
+ # Python types as fallback
439
480
  type_map = {
440
481
  int: 'int',
441
482
  float: 'float',
442
- str: 'str',
483
+ str: 'string',
443
484
  bool: 'bool',
444
485
  list: 'list',
445
486
  dict: 'dict',
@@ -1044,6 +1085,13 @@ class CSSLBuiltins:
1044
1085
  Usage: instance::getMethods(@module) or instance::getMethods($obj)
1045
1086
  Returns list of method names.
1046
1087
  """
1088
+ from .cssl_types import CSSLInstance
1089
+
1090
+ # Handle CSSL class instances
1091
+ if isinstance(obj, CSSLInstance):
1092
+ return list(obj._class.methods.keys())
1093
+
1094
+ # Handle Python objects
1047
1095
  import inspect
1048
1096
  methods = []
1049
1097
  for name in dir(obj):
@@ -1056,8 +1104,20 @@ class CSSLBuiltins:
1056
1104
  def builtin_instance_getClasses(self, obj: Any) -> list:
1057
1105
  """Get all classes from an object/module.
1058
1106
  Usage: instance::getClasses(@module)
1059
- Returns list of class names.
1107
+ Returns list of class names (including merged classes).
1060
1108
  """
1109
+ from .cssl_types import CSSLInstance
1110
+
1111
+ # Handle CSSL class instances
1112
+ if isinstance(obj, CSSLInstance):
1113
+ classes = [obj._class.name] # Primary class
1114
+ # Check for merged class instances in members
1115
+ for name, member in obj._members.items():
1116
+ if isinstance(member, CSSLInstance):
1117
+ classes.append(member._class.name)
1118
+ return classes
1119
+
1120
+ # Handle Python objects
1061
1121
  import inspect
1062
1122
  classes = []
1063
1123
  for name in dir(obj):
@@ -1070,8 +1130,20 @@ class CSSLBuiltins:
1070
1130
  def builtin_instance_getVars(self, obj: Any) -> list:
1071
1131
  """Get all variables/attributes (non-callable) from an object.
1072
1132
  Usage: instance::getVars(@module)
1073
- Returns list of variable names.
1133
+ Returns list of variable names (excludes merged class instances).
1074
1134
  """
1135
+ from .cssl_types import CSSLInstance
1136
+
1137
+ # Handle CSSL class instances
1138
+ if isinstance(obj, CSSLInstance):
1139
+ vars_list = []
1140
+ for name, member in obj._members.items():
1141
+ # Exclude merged class instances
1142
+ if not isinstance(member, CSSLInstance):
1143
+ vars_list.append(name)
1144
+ return vars_list
1145
+
1146
+ # Handle Python objects
1075
1147
  vars_list = []
1076
1148
  for name in dir(obj):
1077
1149
  if not name.startswith('_'):
@@ -1085,12 +1157,31 @@ class CSSLBuiltins:
1085
1157
  Usage: instance::getAll(@module)
1086
1158
  Returns dict with 'methods', 'classes', 'vars' keys.
1087
1159
  """
1088
- import inspect
1160
+ from .cssl_types import CSSLInstance
1161
+
1089
1162
  result = {
1090
1163
  'methods': [],
1091
1164
  'classes': [],
1092
1165
  'vars': []
1093
1166
  }
1167
+
1168
+ # Handle CSSL class instances
1169
+ if isinstance(obj, CSSLInstance):
1170
+ result['methods'] = list(obj._class.methods.keys())
1171
+ result['classes'] = [obj._class.name]
1172
+
1173
+ # Separate regular vars from merged class instances
1174
+ for name, member in obj._members.items():
1175
+ if isinstance(member, CSSLInstance):
1176
+ # Merged class - add to classes list
1177
+ result['classes'].append(member._class.name)
1178
+ else:
1179
+ # Regular variable
1180
+ result['vars'].append(name)
1181
+ return result
1182
+
1183
+ # Handle Python objects
1184
+ import inspect
1094
1185
  for name in dir(obj):
1095
1186
  if not name.startswith('_'):
1096
1187
  attr = getattr(obj, name, None)
@@ -1106,21 +1197,46 @@ class CSSLBuiltins:
1106
1197
  """Dynamically call a method on an object.
1107
1198
  Usage: instance::call(@module, 'methodName', arg1, arg2)
1108
1199
  """
1200
+ from .cssl_types import CSSLInstance
1201
+
1202
+ # Handle CSSL class instances
1203
+ if isinstance(obj, CSSLInstance):
1204
+ if obj.has_method(method_name):
1205
+ # Need runtime to call the method
1206
+ if self.runtime:
1207
+ return self.runtime._call_method(obj, obj.get_method(method_name), list(args), kwargs or {})
1208
+ raise RuntimeError(f"Method '{method_name}' not found on CSSL instance")
1209
+
1210
+ # Handle Python objects
1109
1211
  method = getattr(obj, method_name, None)
1110
1212
  if method and callable(method):
1111
1213
  return method(*args, **kwargs)
1112
1214
  raise RuntimeError(f"Method '{method_name}' not found on object")
1113
1215
 
1114
1216
  def builtin_instance_has(self, obj: Any, name: str) -> bool:
1115
- """Check if object has an attribute.
1217
+ """Check if object has an attribute or method.
1116
1218
  Usage: instance::has(@module, 'methodName')
1117
1219
  """
1220
+ from .cssl_types import CSSLInstance
1221
+
1222
+ # Handle CSSL class instances
1223
+ if isinstance(obj, CSSLInstance):
1224
+ return obj.has_member(name) or obj.has_method(name)
1225
+
1226
+ # Handle Python objects
1118
1227
  return hasattr(obj, name)
1119
1228
 
1120
1229
  def builtin_instance_type(self, obj: Any) -> str:
1121
1230
  """Get the type name of an object.
1122
1231
  Usage: instance::type(@module)
1123
1232
  """
1233
+ from .cssl_types import CSSLInstance
1234
+
1235
+ # Handle CSSL class instances
1236
+ if isinstance(obj, CSSLInstance):
1237
+ return obj._class.name
1238
+
1239
+ # Handle Python objects
1124
1240
  return type(obj).__name__
1125
1241
 
1126
1242
  def builtin_isavailable(self, name_or_obj: Any) -> bool:
@@ -1140,6 +1256,50 @@ class CSSLBuiltins:
1140
1256
  # Otherwise, check if the object is not None (for $name or instance<"name">)
1141
1257
  return name_or_obj is not None
1142
1258
 
1259
+ # ============= Filter Registration Functions =============
1260
+
1261
+ def builtin_filter_register(self, filter_type: str, helper: str, callback: Any) -> bool:
1262
+ """Register a custom filter.
1263
+ Usage: filter::register("mytype", "where", myCallback)
1264
+
1265
+ The callback receives (source, filter_value, runtime) and returns filtered result.
1266
+ Use "*" as helper for catch-all.
1267
+
1268
+ Example:
1269
+ define myFilter(source, value, runtime) {
1270
+ return source + value;
1271
+ }
1272
+ filter::register("custom", "add", myFilter);
1273
+
1274
+ result <==[custom::add=10] 5; // result = 15
1275
+ """
1276
+ from .cssl_runtime import register_filter
1277
+ register_filter(filter_type, helper, callback)
1278
+ return True
1279
+
1280
+ def builtin_filter_unregister(self, filter_type: str, helper: str) -> bool:
1281
+ """Unregister a custom filter.
1282
+ Usage: filter::unregister("mytype", "where")
1283
+ """
1284
+ from .cssl_runtime import unregister_filter
1285
+ return unregister_filter(filter_type, helper)
1286
+
1287
+ def builtin_filter_list(self) -> list:
1288
+ """List all registered custom filters.
1289
+ Usage: filter::list()
1290
+ Returns list of filter keys like ["mytype::where", "custom::*"]
1291
+ """
1292
+ from .cssl_runtime import get_custom_filters
1293
+ return list(get_custom_filters().keys())
1294
+
1295
+ def builtin_filter_exists(self, filter_type: str, helper: str) -> bool:
1296
+ """Check if a custom filter exists.
1297
+ Usage: filter::exists("mytype", "where")
1298
+ """
1299
+ from .cssl_runtime import get_custom_filters
1300
+ key = f"{filter_type}::{helper}"
1301
+ return key in get_custom_filters()
1302
+
1143
1303
  # ============= Regex Functions =============
1144
1304
 
1145
1305
  def builtin_match(self, pattern: str, string: str) -> Optional[dict]:
@@ -1680,7 +1840,7 @@ class CSSLBuiltins:
1680
1840
 
1681
1841
  def builtin_cso_root(self, path: str = "") -> str:
1682
1842
  """
1683
- Get absolute path relative to CSO root directory
1843
+ Get absolute path relative to project root directory
1684
1844
  Usage: cso_root('/services/myservice.cssl')
1685
1845
  Returns: Full absolute path to the file
1686
1846
  """
@@ -1729,7 +1889,7 @@ class CSSLBuiltins:
1729
1889
  if os.path.exists(cwd_path):
1730
1890
  filepath = cwd_path
1731
1891
  else:
1732
- # Fall back to cso_root for CSO service context
1892
+ # Fall back to cso_root for service context
1733
1893
  filepath = self.builtin_cso_root(filepath)
1734
1894
 
1735
1895
  # Check file exists
@@ -1923,7 +2083,7 @@ class CSSLBuiltins:
1923
2083
  if os.path.exists(cwd_path):
1924
2084
  filepath = cwd_path
1925
2085
  else:
1926
- # Fall back to cso_root for CSO service context
2086
+ # Fall back to cso_root for service context
1927
2087
  filepath = self.builtin_cso_root(filepath)
1928
2088
 
1929
2089
  # Check file exists
@@ -2203,6 +2363,38 @@ class CSSLBuiltins:
2203
2363
  from .cssl_types import OpenQuote
2204
2364
  return OpenQuote(db_ref)
2205
2365
 
2366
+ def builtin_vector(self, element_type: str = 'dynamic') -> Any:
2367
+ """Create a vector container.
2368
+
2369
+ Usage: vector<int> myVector; or vector('int')
2370
+ """
2371
+ from .cssl_types import Vector
2372
+ return Vector(element_type)
2373
+
2374
+ def builtin_array(self, element_type: str = 'dynamic') -> Any:
2375
+ """Create an array container.
2376
+
2377
+ Usage: array<string> myArray; or array('string')
2378
+ """
2379
+ from .cssl_types import Array
2380
+ return Array(element_type)
2381
+
2382
+ def builtin_stack(self, element_type: str = 'dynamic') -> Any:
2383
+ """Create a stack container.
2384
+
2385
+ Usage: stack<int> myStack; or stack('int')
2386
+ """
2387
+ from .cssl_types import Stack
2388
+ return Stack(element_type)
2389
+
2390
+ def builtin_map(self, key_type: str = 'dynamic', value_type: str = 'dynamic') -> Any:
2391
+ """Create a map container.
2392
+
2393
+ Usage: map<string, int> myMap; or map('string', 'int')
2394
+ """
2395
+ from .cssl_types import Map
2396
+ return Map(key_type, value_type)
2397
+
2206
2398
  def builtin_openfind(self, combo_or_type: Any, index: int = 0, params: list = None) -> Any:
2207
2399
  """Find open parameter by type or combo space.
2208
2400