IncludeCPP 3.7.1__py3-none-any.whl → 3.7.9__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.
@@ -1,14 +1,23 @@
1
1
  """
2
2
  CSSL Bridge - Python API for CSSL Language
3
3
  Provides CsslLang class for executing CSSL code from Python.
4
+
5
+ v3.8.0 API:
6
+ cssl.run(code, *args) - Execute CSSL code
7
+ cssl.script("cssl", code) - Create typed script
8
+ cssl.makemodule(script, pl) - Bundle main script + payload
9
+ cssl.load(path, name) - Load .cssl/.cssl-pl file
10
+ cssl.execute(name) - Execute loaded script
11
+ cssl.include(path, name) - Register for payload(name)
4
12
  """
5
13
 
6
14
  import os
7
15
  import pickle
8
16
  import random
9
17
  import threading
18
+ import warnings
10
19
  from pathlib import Path
11
- from typing import Any, List, Optional, Callable, Dict
20
+ from typing import Any, List, Optional, Callable, Dict, Union, Tuple
12
21
 
13
22
 
14
23
  def _get_share_directory() -> Path:
@@ -142,6 +151,79 @@ class CSSLModule:
142
151
  return f"<CSSLModule code_len={len(self._code)}>"
143
152
 
144
153
 
154
+ class CSSLScript:
155
+ """
156
+ A typed CSSL script object.
157
+
158
+ Created via cssl.script("cssl", code) or cssl.script("cssl-pl", code).
159
+ Can be executed directly or bundled into a module.
160
+
161
+ Usage:
162
+ main = cssl.script("cssl", '''
163
+ printl("Main script");
164
+ myFunc();
165
+ ''')
166
+
167
+ payload = cssl.script("cssl-pl", '''
168
+ void myFunc() {
169
+ printl("From payload!");
170
+ }
171
+ ''')
172
+
173
+ # Execute directly
174
+ main.run()
175
+
176
+ # Or bundle into module
177
+ mod = cssl.makemodule(main, payload, "mymod")
178
+ """
179
+
180
+ def __init__(self, cssl_instance: 'CsslLang', script_type: str, code: str, params: Tuple = ()):
181
+ """
182
+ Initialize a CSSL script.
183
+
184
+ Args:
185
+ cssl_instance: The parent CsslLang instance
186
+ script_type: "cssl" for main script, "cssl-pl" for payload
187
+ code: The CSSL code
188
+ params: Optional parameters accessible via parameter.get(index)
189
+ """
190
+ if script_type not in ('cssl', 'cssl-pl'):
191
+ raise ValueError(f"Invalid script type '{script_type}'. Must be 'cssl' or 'cssl-pl'")
192
+
193
+ self._cssl = cssl_instance
194
+ self._type = script_type
195
+ self._code = code
196
+ self._params = params
197
+ self._name: Optional[str] = None
198
+
199
+ @property
200
+ def type(self) -> str:
201
+ """Get script type ('cssl' or 'cssl-pl')."""
202
+ return self._type
203
+
204
+ @property
205
+ def code(self) -> str:
206
+ """Get the script code."""
207
+ return self._code
208
+
209
+ @property
210
+ def is_payload(self) -> bool:
211
+ """Check if this is a payload script."""
212
+ return self._type == 'cssl-pl'
213
+
214
+ def run(self, *args) -> Any:
215
+ """Execute this script with optional arguments."""
216
+ all_args = self._params + args
217
+ return self._cssl.run(self._code, *all_args)
218
+
219
+ def __call__(self, *args) -> Any:
220
+ """Allow calling the script directly."""
221
+ return self.run(*args)
222
+
223
+ def __repr__(self) -> str:
224
+ return f"<CSSLScript type='{self._type}' code_len={len(self._code)}>"
225
+
226
+
145
227
  class CSSLFunctionModule:
146
228
  """
147
229
  A CSSL module with accessible functions as methods.
@@ -150,9 +232,11 @@ class CSSLFunctionModule:
150
232
  become callable attributes on this module.
151
233
  """
152
234
 
153
- def __init__(self, cssl_instance: 'CsslLang', code: str):
235
+ def __init__(self, cssl_instance: 'CsslLang', code: str, payload_code: str = None, name: str = None):
154
236
  self._cssl = cssl_instance
155
237
  self._code = code
238
+ self._payload_code = payload_code
239
+ self._name = name
156
240
  self._runtime = None
157
241
  self._functions: Dict[str, Any] = {}
158
242
  self._initialized = False
@@ -167,7 +251,22 @@ class CSSLFunctionModule:
167
251
  # Create a dedicated runtime for this module
168
252
  self._runtime = CSSLRuntime()
169
253
 
170
- # Parse the code
254
+ # If we have a payload, load it first (defines functions/globals for main)
255
+ if self._payload_code:
256
+ payload_ast = parse_cssl_program(self._payload_code)
257
+ for child in payload_ast.children:
258
+ if child.type == 'function':
259
+ func_info = child.value
260
+ func_name = func_info.get('name')
261
+ self._functions[func_name] = child
262
+ self._runtime.scope.set(func_name, child)
263
+ else:
264
+ try:
265
+ self._runtime._execute_node(child)
266
+ except Exception:
267
+ pass
268
+
269
+ # Parse the main code
171
270
  ast = parse_cssl_program(self._code)
172
271
 
173
272
  # Execute to register all function definitions
@@ -184,6 +283,16 @@ class CSSLFunctionModule:
184
283
  except Exception:
185
284
  pass
186
285
 
286
+ # If module has a name, register for payload() access
287
+ if self._name:
288
+ cssl_instance = self._cssl
289
+ runtime = cssl_instance._get_runtime()
290
+ if not hasattr(runtime, '_inline_payloads'):
291
+ runtime._inline_payloads = {}
292
+ # Store combined code for payload() access
293
+ combined = (self._payload_code or '') + '\n' + self._code
294
+ runtime._inline_payloads[self._name] = combined
295
+
187
296
  self._initialized = True
188
297
 
189
298
  def __getattr__(self, name: str) -> Callable:
@@ -224,11 +333,27 @@ class CsslLang:
224
333
  """
225
334
  CSSL Language interface for Python.
226
335
 
227
- Usage:
336
+ v3.8.0 API:
228
337
  from includecpp import CSSL
229
338
  cssl = CSSL.CsslLang()
230
- result = cssl.exec("script.cssl", arg1, arg2)
231
- cssl.T_exec("async_script.cssl", arg1) # Threaded
339
+
340
+ # Execute CSSL code
341
+ result = cssl.run("script.cssl", arg1, arg2)
342
+ result = cssl.run('''printl("Hello");''')
343
+
344
+ # Create typed scripts
345
+ main = cssl.script("cssl", '''printl("Main");''')
346
+ payload = cssl.script("cssl-pl", '''void helper() {}''')
347
+
348
+ # Bundle into module
349
+ mod = cssl.makemodule(main, payload, "mymod")
350
+
351
+ # Load and execute files
352
+ cssl.load("utils.cssl-pl", "utils")
353
+ cssl.execute("utils")
354
+
355
+ # Register for payload() access
356
+ cssl.include("helpers.cssl-pl", "helpers")
232
357
  """
233
358
 
234
359
  def __init__(self, output_callback: Optional[Callable[[str, str], None]] = None):
@@ -241,6 +366,7 @@ class CsslLang:
241
366
  self._output_callback = output_callback
242
367
  self._runtime = None
243
368
  self._threads: List[threading.Thread] = []
369
+ self._loaded_scripts: Dict[str, Dict[str, Any]] = {}
244
370
 
245
371
  def _get_runtime(self):
246
372
  """Lazy load CSSL runtime."""
@@ -249,23 +375,38 @@ class CsslLang:
249
375
  self._runtime = CSSLRuntime(output_callback=self._output_callback)
250
376
  return self._runtime
251
377
 
252
- def exec(self, path_or_code: str, *args) -> Any:
378
+ def _detect_type(self, path: str) -> str:
379
+ """Detect script type from file extension."""
380
+ path_obj = Path(path)
381
+ if path_obj.suffix == '.cssl-pl':
382
+ return 'cssl-pl'
383
+ return 'cssl'
384
+
385
+ def run(self, path_or_code: str, *args) -> Any:
253
386
  """
254
387
  Execute CSSL code or file.
255
388
 
389
+ This is the primary method for running CSSL code in v3.8.0+.
390
+
256
391
  Args:
257
392
  path_or_code: Path to .cssl file or CSSL code string
258
- *args: Arguments to pass to the script
393
+ *args: Arguments to pass to the script (accessible via parameter.get())
259
394
 
260
395
  Returns:
261
396
  Execution result. If parameter.return() was called, returns
262
397
  the list of returned values (or single value if only one).
398
+
399
+ Usage:
400
+ cssl.run("script.cssl", "arg1", 42)
401
+ cssl.run('''
402
+ printl("Hello " + parameter.get(0));
403
+ ''', "World")
263
404
  """
264
405
  runtime = self._get_runtime()
265
406
 
266
407
  # Check if it's a file path
267
408
  path = Path(path_or_code)
268
- if path.exists() and path.suffix in ('.cssl', '.cssl-mod'):
409
+ if path.exists() and path.suffix in ('.cssl', '.cssl-mod', '.cssl-pl'):
269
410
  source = path.read_text(encoding='utf-8')
270
411
  else:
271
412
  source = path_or_code
@@ -296,7 +437,27 @@ class CsslLang:
296
437
  raise RuntimeError(error_msg) from e
297
438
  raise RuntimeError(f"CSSL Error:\n{error_msg}") from e
298
439
 
299
- def T_exec(self, path_or_code: str, *args, callback: Optional[Callable[[Any], None]] = None) -> threading.Thread:
440
+ def exec(self, path_or_code: str, *args) -> Any:
441
+ """
442
+ Execute CSSL code or file.
443
+
444
+ DEPRECATED: Use run() instead. This method is kept for backwards compatibility.
445
+
446
+ Args:
447
+ path_or_code: Path to .cssl file or CSSL code string
448
+ *args: Arguments to pass to the script
449
+
450
+ Returns:
451
+ Execution result
452
+ """
453
+ warnings.warn(
454
+ "exec() is deprecated, use run() instead",
455
+ DeprecationWarning,
456
+ stacklevel=2
457
+ )
458
+ return self.run(path_or_code, *args)
459
+
460
+ def T_run(self, path_or_code: str, *args, callback: Optional[Callable[[Any], None]] = None) -> threading.Thread:
300
461
  """
301
462
  Execute CSSL code asynchronously in a thread.
302
463
 
@@ -308,20 +469,33 @@ class CsslLang:
308
469
  Returns:
309
470
  Thread object
310
471
  """
311
- def _run():
472
+ def _run_async():
312
473
  try:
313
- result = self.exec(path_or_code, *args)
474
+ result = self.run(path_or_code, *args)
314
475
  if callback:
315
476
  callback(result)
316
477
  except Exception as e:
317
478
  if callback:
318
479
  callback(e)
319
480
 
320
- thread = threading.Thread(target=_run, daemon=True)
481
+ thread = threading.Thread(target=_run_async, daemon=True)
321
482
  thread.start()
322
483
  self._threads.append(thread)
323
484
  return thread
324
485
 
486
+ def T_exec(self, path_or_code: str, *args, callback: Optional[Callable[[Any], None]] = None) -> threading.Thread:
487
+ """
488
+ Execute CSSL code asynchronously in a thread.
489
+
490
+ DEPRECATED: Use T_run() instead.
491
+ """
492
+ warnings.warn(
493
+ "T_exec() is deprecated, use T_run() instead",
494
+ DeprecationWarning,
495
+ stacklevel=2
496
+ )
497
+ return self.T_run(path_or_code, *args, callback=callback)
498
+
325
499
  def wait_all(self, timeout: Optional[float] = None):
326
500
  """Wait for all async executions to complete."""
327
501
  for thread in self._threads:
@@ -368,32 +542,185 @@ class CsslLang:
368
542
  """
369
543
  return CSSLModule(self, code)
370
544
 
371
- def makemodule(self, code: str) -> 'CSSLFunctionModule':
545
+ def script(self, script_type: str, code: str, *params) -> 'CSSLScript':
546
+ """
547
+ Create a typed CSSL script.
548
+
549
+ Args:
550
+ script_type: "cssl" for main script, "cssl-pl" for payload
551
+ code: The CSSL code
552
+ *params: Optional parameters accessible via parameter.get(index)
553
+
554
+ Returns:
555
+ CSSLScript object that can be executed or bundled
556
+
557
+ Usage:
558
+ main = cssl.script("cssl", '''
559
+ printl("Main script running");
560
+ helper();
561
+ ''')
562
+
563
+ payload = cssl.script("cssl-pl", '''
564
+ void helper() {
565
+ printl("Helper called!");
566
+ }
567
+ ''')
568
+
569
+ # Execute directly
570
+ main.run()
571
+
572
+ # Or bundle into module
573
+ mod = cssl.makemodule(main, payload, "mymod")
574
+ """
575
+ return CSSLScript(self, script_type, code, params)
576
+
577
+ def makemodule(
578
+ self,
579
+ main_script: Union[str, 'CSSLScript'],
580
+ payload_script: Union[str, 'CSSLScript', None] = None,
581
+ name: str = None
582
+ ) -> 'CSSLFunctionModule':
372
583
  """
373
584
  Create a CSSL module with accessible functions.
374
585
 
375
586
  Functions defined in the code become methods on the returned module.
587
+ Optionally registers the module for payload() access in other scripts.
376
588
 
377
- Usage:
378
- module = CSSL.makemodule('''
589
+ Args:
590
+ main_script: Main CSSL code (string or CSSLScript)
591
+ payload_script: Optional payload code (string or CSSLScript)
592
+ name: Optional name to register for payload(name) access
593
+
594
+ Returns:
595
+ CSSLFunctionModule - module with callable function attributes
596
+
597
+ Usage (v3.8.0 - with CSSLScript objects):
598
+ main = cssl.script("cssl", '''
599
+ printl("Main");
600
+ helper();
601
+ ''')
602
+ payload = cssl.script("cssl-pl", '''
603
+ void helper() { printl("Helper!"); }
604
+ ''')
605
+ mod = cssl.makemodule(main, payload, "mymod")
606
+ mod.helper() # Direct call
607
+
608
+ # Also available in other scripts:
609
+ cssl.run('''
610
+ payload("mymod");
611
+ helper(); // Works!
612
+ ''')
613
+
614
+ Usage (legacy - code string):
615
+ module = cssl.makemodule('''
379
616
  string greet(string name) {
380
617
  return "Hello, " + name + "!";
381
618
  }
382
-
383
- int add(int a, int b) {
384
- return a + b;
385
- }
386
619
  ''')
387
620
  module.greet("World") # Returns "Hello, World!"
388
- module.add(2, 3) # Returns 5
621
+ """
622
+ # Extract code from CSSLScript objects if provided
623
+ if isinstance(main_script, CSSLScript):
624
+ main_code = main_script.code
625
+ else:
626
+ main_code = main_script
627
+
628
+ payload_code = None
629
+ if payload_script is not None:
630
+ if isinstance(payload_script, CSSLScript):
631
+ payload_code = payload_script.code
632
+ else:
633
+ payload_code = payload_script
634
+
635
+ return CSSLFunctionModule(self, main_code, payload_code, name)
636
+
637
+ def load(self, path: str, name: str) -> None:
638
+ """
639
+ Load a .cssl or .cssl-pl file and register by name.
640
+
641
+ The file becomes accessible for execute(name) or payload(name).
642
+
643
+ Args:
644
+ path: Path to the .cssl or .cssl-pl file
645
+ name: Name to register the script under
646
+
647
+ Usage:
648
+ cssl.load("utils.cssl-pl", "utils")
649
+ cssl.execute("utils") # Run it
650
+
651
+ # Or in CSSL code:
652
+ cssl.run('''
653
+ payload("utils"); // Loads the registered file
654
+ ''')
655
+ """
656
+ path_obj = Path(path)
657
+ if not path_obj.exists():
658
+ raise FileNotFoundError(f"CSSL file not found: {path}")
659
+
660
+ script_type = self._detect_type(path)
661
+ code = path_obj.read_text(encoding='utf-8')
662
+
663
+ self._loaded_scripts[name] = {
664
+ 'path': str(path_obj.absolute()),
665
+ 'type': script_type,
666
+ 'code': code
667
+ }
668
+
669
+ # Also register for payload() access
670
+ runtime = self._get_runtime()
671
+ if not hasattr(runtime, '_inline_payloads'):
672
+ runtime._inline_payloads = {}
673
+ runtime._inline_payloads[name] = code
674
+
675
+ def execute(self, name: str, *args) -> Any:
676
+ """
677
+ Execute a previously loaded script by name.
389
678
 
390
679
  Args:
391
- code: CSSL code string with function definitions
680
+ name: Name of the loaded script
681
+ *args: Arguments to pass to the script
392
682
 
393
683
  Returns:
394
- CSSLFunctionModule - module with callable function attributes
684
+ Execution result
685
+
686
+ Usage:
687
+ cssl.load("utils.cssl-pl", "utils")
688
+ result = cssl.execute("utils", arg1, arg2)
395
689
  """
396
- return CSSLFunctionModule(self, code)
690
+ if name not in self._loaded_scripts:
691
+ raise KeyError(f"No script loaded with name '{name}'. Use load() first.")
692
+
693
+ script_info = self._loaded_scripts[name]
694
+ return self.run(script_info['code'], *args)
695
+
696
+ def include(self, path: str, name: str) -> None:
697
+ """
698
+ Register a file to be accessible via payload(name) or include(name) in CSSL.
699
+
700
+ Unlike load(), this doesn't store the script for execute() - it only
701
+ makes it available for payload() calls within CSSL code.
702
+
703
+ Args:
704
+ path: Path to the .cssl or .cssl-pl file
705
+ name: Name for payload() access
706
+
707
+ Usage:
708
+ cssl.include("helpers.cssl-pl", "helpers")
709
+ cssl.run('''
710
+ payload("helpers");
711
+ // Functions from helpers are now available
712
+ ''')
713
+ """
714
+ path_obj = Path(path)
715
+ if not path_obj.exists():
716
+ raise FileNotFoundError(f"CSSL file not found: {path}")
717
+
718
+ code = path_obj.read_text(encoding='utf-8')
719
+
720
+ runtime = self._get_runtime()
721
+ if not hasattr(runtime, '_inline_payloads'):
722
+ runtime._inline_payloads = {}
723
+ runtime._inline_payloads[name] = code
397
724
 
398
725
  def code(self, name: str, code: str) -> None:
399
726
  """
@@ -748,15 +1075,18 @@ def get_cssl() -> CsslLang:
748
1075
  return _default_instance
749
1076
 
750
1077
 
751
- # Module-level convenience functions
752
- def exec(path_or_code: str, *args) -> Any:
1078
+ # Module-level convenience functions (v3.8.0 API)
1079
+
1080
+ def run(path_or_code: str, *args) -> Any:
753
1081
  """
754
1082
  Execute CSSL code or file.
755
1083
 
1084
+ This is the primary method for running CSSL code in v3.8.0+.
1085
+
756
1086
  Usage:
757
1087
  from includecpp import CSSL
758
- CSSL.exec("script.cssl", arg1, arg2)
759
- CSSL.exec("printl('Hello World');")
1088
+ CSSL.run("script.cssl", arg1, arg2)
1089
+ CSSL.run("printl('Hello World');")
760
1090
 
761
1091
  Args:
762
1092
  path_or_code: Path to .cssl file or CSSL code string
@@ -765,16 +1095,30 @@ def exec(path_or_code: str, *args) -> Any:
765
1095
  Returns:
766
1096
  Execution result
767
1097
  """
768
- return get_cssl().exec(path_or_code, *args)
1098
+ return get_cssl().run(path_or_code, *args)
769
1099
 
770
1100
 
771
- def T_exec(path_or_code: str, *args, callback: Optional[Callable[[Any], None]] = None) -> threading.Thread:
1101
+ def exec(path_or_code: str, *args) -> Any:
1102
+ """
1103
+ Execute CSSL code or file.
1104
+
1105
+ DEPRECATED: Use run() instead.
1106
+ """
1107
+ warnings.warn(
1108
+ "exec() is deprecated, use run() instead",
1109
+ DeprecationWarning,
1110
+ stacklevel=2
1111
+ )
1112
+ return get_cssl().run(path_or_code, *args)
1113
+
1114
+
1115
+ def T_run(path_or_code: str, *args, callback: Optional[Callable[[Any], None]] = None) -> threading.Thread:
772
1116
  """
773
1117
  Execute CSSL code asynchronously in a thread.
774
1118
 
775
1119
  Usage:
776
1120
  from includecpp import CSSL
777
- CSSL.T_exec("async_script.cssl", arg1, callback=on_done)
1121
+ CSSL.T_run("async_script.cssl", arg1, callback=on_done)
778
1122
 
779
1123
  Args:
780
1124
  path_or_code: Path to .cssl file or CSSL code string
@@ -784,7 +1128,75 @@ def T_exec(path_or_code: str, *args, callback: Optional[Callable[[Any], None]] =
784
1128
  Returns:
785
1129
  Thread object
786
1130
  """
787
- return get_cssl().T_exec(path_or_code, *args, callback=callback)
1131
+ return get_cssl().T_run(path_or_code, *args, callback=callback)
1132
+
1133
+
1134
+ def T_exec(path_or_code: str, *args, callback: Optional[Callable[[Any], None]] = None) -> threading.Thread:
1135
+ """
1136
+ Execute CSSL code asynchronously in a thread.
1137
+
1138
+ DEPRECATED: Use T_run() instead.
1139
+ """
1140
+ warnings.warn(
1141
+ "T_exec() is deprecated, use T_run() instead",
1142
+ DeprecationWarning,
1143
+ stacklevel=2
1144
+ )
1145
+ return get_cssl().T_run(path_or_code, *args, callback=callback)
1146
+
1147
+
1148
+ def script(script_type: str, code: str, *params) -> CSSLScript:
1149
+ """
1150
+ Create a typed CSSL script.
1151
+
1152
+ Usage:
1153
+ from includecpp import CSSL
1154
+ main = CSSL.script("cssl", '''printl("Main");''')
1155
+ payload = CSSL.script("cssl-pl", '''void helper() {}''')
1156
+ mod = CSSL.makemodule(main, payload, "mymod")
1157
+
1158
+ Args:
1159
+ script_type: "cssl" for main script, "cssl-pl" for payload
1160
+ code: The CSSL code
1161
+ *params: Optional parameters
1162
+
1163
+ Returns:
1164
+ CSSLScript object
1165
+ """
1166
+ return get_cssl().script(script_type, code, *params)
1167
+
1168
+
1169
+ def load(path: str, name: str) -> None:
1170
+ """
1171
+ Load a .cssl or .cssl-pl file and register by name.
1172
+
1173
+ Usage:
1174
+ CSSL.load("utils.cssl-pl", "utils")
1175
+ CSSL.execute("utils")
1176
+ """
1177
+ return get_cssl().load(path, name)
1178
+
1179
+
1180
+ def execute(name: str, *args) -> Any:
1181
+ """
1182
+ Execute a previously loaded script by name.
1183
+
1184
+ Usage:
1185
+ CSSL.load("utils.cssl-pl", "utils")
1186
+ result = CSSL.execute("utils", arg1, arg2)
1187
+ """
1188
+ return get_cssl().execute(name, *args)
1189
+
1190
+
1191
+ def include(path: str, name: str) -> None:
1192
+ """
1193
+ Register a file for payload(name) access in CSSL.
1194
+
1195
+ Usage:
1196
+ CSSL.include("helpers.cssl-pl", "helpers")
1197
+ CSSL.run('payload("helpers");')
1198
+ """
1199
+ return get_cssl().include(path, name)
788
1200
 
789
1201
 
790
1202
  def set_global(name: str, value: Any) -> None:
@@ -808,7 +1220,9 @@ def clear_output() -> None:
808
1220
 
809
1221
 
810
1222
  # Aliases to avoid conflict with Python builtin exec
1223
+ _run = run
811
1224
  _exec = exec
1225
+ _T_run = T_run
812
1226
  _T_exec = T_exec
813
1227
 
814
1228
 
@@ -832,43 +1246,58 @@ def module(code: str) -> CSSLModule:
832
1246
  return get_cssl().module(code)
833
1247
 
834
1248
 
835
- def makemodule(code: str) -> CSSLFunctionModule:
1249
+ def makemodule(
1250
+ main_script: Union[str, CSSLScript],
1251
+ payload_script: Union[str, CSSLScript, None] = None,
1252
+ name: str = None
1253
+ ) -> CSSLFunctionModule:
836
1254
  """
837
1255
  Create a CSSL module with accessible functions.
838
1256
 
839
- Usage:
840
- from includecpp import CSSL
841
- math_mod = CSSL.makemodule('''
842
- int add(int a, int b) {
843
- return a + b;
844
- }
1257
+ Usage (v3.8.0 - with CSSLScript):
1258
+ main = CSSL.script("cssl", '''printl("Main");''')
1259
+ payload = CSSL.script("cssl-pl", '''void helper() {}''')
1260
+ mod = CSSL.makemodule(main, payload, "mymod")
845
1261
 
846
- int multiply(int a, int b) {
847
- return a * b;
848
- }
1262
+ Usage (legacy - code string):
1263
+ math_mod = CSSL.makemodule('''
1264
+ int add(int a, int b) { return a + b; }
849
1265
  ''')
850
- math_mod.add(2, 3) # Returns 5
851
- math_mod.multiply(4, 5) # Returns 20
1266
+ math_mod.add(2, 3) # Returns 5
852
1267
 
853
1268
  Args:
854
- code: CSSL code string with function definitions
1269
+ main_script: Main CSSL code (string or CSSLScript)
1270
+ payload_script: Optional payload code (string or CSSLScript)
1271
+ name: Optional name to register for payload(name) access
855
1272
 
856
1273
  Returns:
857
1274
  CSSLFunctionModule - module with callable function attributes
858
1275
  """
859
- return get_cssl().makemodule(code)
1276
+ return get_cssl().makemodule(main_script, payload_script, name)
860
1277
 
861
1278
 
862
1279
  # Export all
863
1280
  __all__ = [
864
1281
  'CsslLang',
865
1282
  'CSSLModule',
1283
+ 'CSSLScript',
866
1284
  'CSSLFunctionModule',
867
1285
  'get_cssl',
1286
+ # v3.8.0 primary API
1287
+ 'run',
1288
+ '_run',
1289
+ 'T_run',
1290
+ '_T_run',
1291
+ 'script',
1292
+ 'load',
1293
+ 'execute',
1294
+ 'include',
1295
+ # Legacy (deprecated)
868
1296
  'exec',
869
- '_exec', # Alias for exec (avoids Python builtin conflict)
1297
+ '_exec',
870
1298
  'T_exec',
871
- '_T_exec', # Alias for T_exec
1299
+ '_T_exec',
1300
+ # Other
872
1301
  'set_global',
873
1302
  'get_global',
874
1303
  'get_output',