IncludeCPP 3.5.0__py3-none-any.whl → 3.7.1__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.
@@ -429,7 +429,7 @@ class CsslLang:
429
429
  runtime._inline_payloads = {}
430
430
  runtime._inline_payloads[name] = code
431
431
 
432
- def share(self, instance: Any, name: str) -> str:
432
+ def share(self, instance: Any, name: str = None) -> str:
433
433
  """
434
434
  Share a Python object instance with CSSL scripts (LIVE sharing).
435
435
 
@@ -437,6 +437,14 @@ class CsslLang:
437
437
  will be reflected in the original Python object immediately.
438
438
  Call share() again with the same name to update the shared object.
439
439
 
440
+ Args:
441
+ instance: The Python object to share (or name if using old API)
442
+ name: The name to reference the object in CSSL ($name)
443
+
444
+ Note: Arguments can be passed in either order:
445
+ cssl.share(my_object, "name") # Preferred
446
+ cssl.share("name", my_object) # Also works
447
+
440
448
  Usage in Python:
441
449
  from includecpp import CSSL
442
450
  cssl = CSSL.CsslLang()
@@ -474,6 +482,21 @@ class CsslLang:
474
482
  global _live_objects
475
483
  runtime = self._get_runtime()
476
484
 
485
+ # Handle argument order flexibility: share(instance, name) or share(name, instance)
486
+ if name is None:
487
+ # Only one argument - use object type as name
488
+ name = type(instance).__name__
489
+ elif isinstance(instance, str) and not isinstance(name, str):
490
+ # Arguments are swapped: share("name", instance) -> swap them
491
+ instance, name = name, instance
492
+ elif not isinstance(name, str):
493
+ # name is not a string - use its type as name
494
+ name = type(name).__name__
495
+
496
+ # Sanitize filename: remove invalid characters for Windows
497
+ import re
498
+ safe_name = re.sub(r'[<>:"/\\|?*\x00-\x1f]', '_', str(name))
499
+
477
500
  # Initialize shared objects registry
478
501
  if not hasattr(runtime, '_shared_objects'):
479
502
  runtime._shared_objects = {}
@@ -481,7 +504,7 @@ class CsslLang:
481
504
  # Generate unique filename: <name>.shareobj<7digits>
482
505
  random_suffix = ''.join([str(random.randint(0, 9)) for _ in range(7)])
483
506
  share_dir = _get_share_directory()
484
- filepath = share_dir / f"{name}.shareobj{random_suffix}"
507
+ filepath = share_dir / f"{safe_name}.shareobj{random_suffix}"
485
508
 
486
509
  # Remove old file if updating
487
510
  if name in runtime._shared_objects:
@@ -577,22 +600,65 @@ class CsslLang:
577
600
 
578
601
  return None
579
602
 
603
+ def shared(self, name: str) -> Optional[Any]:
604
+ """
605
+ Get a shared object by name (alias for get_shared).
606
+
607
+ Returns the actual live object reference, not a copy.
608
+ Works with both Python cssl.share() and CSSL ==> $name shared objects.
609
+
610
+ Usage:
611
+ from includecpp import CSSL
612
+ cssl = CSSL.CsslLang()
613
+
614
+ # Share an object
615
+ my_obj = {"value": 42}
616
+ cssl.share(my_obj, "data")
617
+
618
+ # Retrieve it later
619
+ obj = cssl.shared("data")
620
+ print(obj["value"]) # 42
621
+
622
+ Args:
623
+ name: Name of the shared object (without $ prefix)
624
+
625
+ Returns:
626
+ The live shared object or None if not found
627
+ """
628
+ return self.get_shared(name)
629
+
580
630
 
581
631
  # Global shared objects registry (for cross-instance sharing)
582
632
  _global_shared_objects: Dict[str, str] = {}
583
633
 
584
634
 
585
- def share(instance: Any, name: str) -> str:
635
+ def share(instance: Any, name: str = None) -> str:
586
636
  """
587
637
  Share a Python object globally for all CSSL instances (LIVE sharing).
588
638
 
589
639
  Changes made through CSSL will reflect back to the original object.
640
+
641
+ Args can be passed in either order:
642
+ share(my_object, "name") # Preferred
643
+ share("name", my_object) # Also works
590
644
  """
591
645
  global _live_objects
646
+ import re
647
+
648
+ # Handle argument order flexibility
649
+ if name is None:
650
+ name = type(instance).__name__
651
+ elif isinstance(instance, str) and not isinstance(name, str):
652
+ instance, name = name, instance
653
+ elif not isinstance(name, str):
654
+ name = type(name).__name__
655
+
656
+ # Sanitize filename
657
+ safe_name = re.sub(r'[<>:"/\\|?*\x00-\x1f]', '_', str(name))
592
658
 
593
659
  random_suffix = ''.join([str(random.randint(0, 9)) for _ in range(7)])
594
660
  share_dir = _get_share_directory()
595
- filepath = share_dir / f"{name}.shareobj{random_suffix}"
661
+ filepath = share_dir / f"{safe_name}.shareobj{random_suffix}"
596
662
 
597
663
  # Remove old file if updating
598
664
  if name in _global_shared_objects:
@@ -645,6 +711,32 @@ def get_shared(name: str) -> Optional[Any]:
645
711
  return _live_objects.get(name)
646
712
 
647
713
 
714
+ def shared(name: str) -> Optional[Any]:
715
+ """
716
+ Get a shared object by name (alias for get_shared).
717
+
718
+ Works with both Python share() and CSSL ==> $name shared objects.
719
+
720
+ Usage:
721
+ from includecpp import CSSL
722
+
723
+ # Share an object
724
+ my_obj = {"value": 42}
725
+ CSSL.share(my_obj, "data")
726
+
727
+ # Retrieve it later
728
+ obj = CSSL.shared("data")
729
+ print(obj["value"]) # 42
730
+
731
+ Args:
732
+ name: Name of the shared object (without $ prefix)
733
+
734
+ Returns:
735
+ The live shared object or None if not found
736
+ """
737
+ return get_shared(name)
738
+
739
+
648
740
  # Singleton for convenience
649
741
  _default_instance: Optional[CsslLang] = None
650
742
 
@@ -783,4 +875,8 @@ __all__ = [
783
875
  'clear_output',
784
876
  'module',
785
877
  'makemodule',
878
+ 'share',
879
+ 'unshare',
880
+ 'shared',
881
+ 'get_shared',
786
882
  ]
@@ -149,6 +149,111 @@ class CsslLang:
149
149
  """
150
150
  ...
151
151
 
152
+ def share(self, instance: Any, name: str = ...) -> str:
153
+ """
154
+ Share a Python object with CSSL (LIVE sharing).
155
+
156
+ Changes in CSSL reflect back to Python immediately.
157
+
158
+ Args can be passed in either order:
159
+ cssl.share(my_object, "name") # Preferred
160
+ cssl.share("name", my_object) # Also works
161
+
162
+ Usage:
163
+ class Counter:
164
+ def __init__(self):
165
+ self.value = 0
166
+
167
+ counter = Counter()
168
+ cssl.share(counter, "cnt")
169
+ cssl.exec('''
170
+ $cnt.value = $cnt.value + 1;
171
+ ''')
172
+ print(counter.value) # 1
173
+
174
+ Args:
175
+ instance: Python object to share
176
+ name: Name to reference in CSSL as $name
177
+
178
+ Returns:
179
+ Path to the shared object marker file
180
+ """
181
+ ...
182
+
183
+ def unshare(self, name: str) -> bool:
184
+ """
185
+ Remove a shared object.
186
+
187
+ Args:
188
+ name: Name of the shared object to remove
189
+
190
+ Returns:
191
+ True if removed, False if not found
192
+ """
193
+ ...
194
+
195
+ def code(self, name: str, code: str) -> None:
196
+ """
197
+ Register inline CSSL code as a named payload.
198
+
199
+ Usage:
200
+ cssl.code("helpers", '''
201
+ void log(string msg) {
202
+ printl("[LOG] " + msg);
203
+ }
204
+ ''')
205
+ cssl.exec('''
206
+ payload("helpers");
207
+ @log("Hello");
208
+ ''')
209
+
210
+ Args:
211
+ name: Name for the payload
212
+ code: CSSL code string
213
+ """
214
+ ...
215
+
216
+ def get_shared(self, name: str) -> Optional[Any]:
217
+ """
218
+ Get a shared object by name (for Python-side access).
219
+
220
+ Returns the actual live object reference, not a copy.
221
+
222
+ Args:
223
+ name: Name of the shared object
224
+
225
+ Returns:
226
+ The live shared object or None if not found
227
+ """
228
+ ...
229
+
230
+ def shared(self, name: str) -> Optional[Any]:
231
+ """
232
+ Get a shared object by name (alias for get_shared).
233
+
234
+ Returns the actual live object reference, not a copy.
235
+ Works with both Python cssl.share() and CSSL ==> $name shared objects.
236
+
237
+ Usage:
238
+ from includecpp import CSSL
239
+ cssl = CSSL.CsslLang()
240
+
241
+ # Share an object
242
+ my_obj = {"value": 42}
243
+ cssl.share(my_obj, "data")
244
+
245
+ # Retrieve it later
246
+ obj = cssl.shared("data")
247
+ print(obj["value"]) # 42
248
+
249
+ Args:
250
+ name: Name of the shared object (without $ prefix)
251
+
252
+ Returns:
253
+ The live shared object or None if not found
254
+ """
255
+ ...
256
+
152
257
 
153
258
  def get_cssl() -> CsslLang:
154
259
  """Get default CSSL instance."""
@@ -308,4 +413,76 @@ def makemodule(code: str) -> CSSLFunctionModule:
308
413
  ...
309
414
 
310
415
 
416
+ def share(instance: Any, name: str = ...) -> str:
417
+ """
418
+ Share a Python object globally for all CSSL instances (LIVE sharing).
419
+
420
+ Changes made through CSSL will reflect back to the original object.
421
+
422
+ Args can be passed in either order:
423
+ share(my_object, "name") # Preferred
424
+ share("name", my_object) # Also works
425
+
426
+ Args:
427
+ instance: Python object to share
428
+ name: Name to reference in CSSL as $name
429
+
430
+ Returns:
431
+ Path to the shared object marker file
432
+ """
433
+ ...
434
+
435
+
436
+ def unshare(name: str) -> bool:
437
+ """
438
+ Remove a globally shared object.
439
+
440
+ Args:
441
+ name: Name of the shared object to remove
442
+
443
+ Returns:
444
+ True if removed, False if not found
445
+ """
446
+ ...
447
+
448
+
449
+ def get_shared(name: str) -> Optional[Any]:
450
+ """
451
+ Get a globally shared object by name.
452
+
453
+ Args:
454
+ name: Name of the shared object
455
+
456
+ Returns:
457
+ The live shared object or None if not found
458
+ """
459
+ ...
460
+
461
+
462
+ def shared(name: str) -> Optional[Any]:
463
+ """
464
+ Get a shared object by name (alias for get_shared).
465
+
466
+ Works with both Python share() and CSSL ==> $name shared objects.
467
+
468
+ Usage:
469
+ from includecpp import CSSL
470
+
471
+ # Share an object
472
+ my_obj = {"value": 42}
473
+ CSSL.share(my_obj, "data")
474
+
475
+ # Retrieve it later
476
+ obj = CSSL.shared("data")
477
+ print(obj["value"]) # 42
478
+
479
+ Args:
480
+ name: Name of the shared object (without $ prefix)
481
+
482
+ Returns:
483
+ The live shared object or None if not found
484
+ """
485
+ ...
486
+
487
+
311
488
  __all__: List[str]
@@ -1,14 +1,24 @@
1
1
  {
2
2
  "name": "cssl",
3
3
  "displayName": "CSSL - CSO Service Script Language",
4
- "description": "Syntax highlighting and language support for CSSL scripts",
5
- "version": "1.0.0",
4
+ "description": "Professional syntax highlighting, snippets, and language support for CSSL scripts (.cssl, .cssl-pl, .cssl-mod)",
5
+ "version": "1.1.0",
6
6
  "publisher": "IncludeCPP",
7
+ "icon": "images/cssl-icon.png",
7
8
  "engines": {
8
9
  "vscode": "^1.60.0"
9
10
  },
10
11
  "categories": [
11
- "Programming Languages"
12
+ "Programming Languages",
13
+ "Snippets"
14
+ ],
15
+ "keywords": [
16
+ "cssl",
17
+ "cso",
18
+ "script",
19
+ "includecpp",
20
+ "c++",
21
+ "python"
12
22
  ],
13
23
  "contributes": {
14
24
  "languages": [
@@ -16,7 +26,11 @@
16
26
  "id": "cssl",
17
27
  "aliases": ["CSSL", "cssl", "CSO Service Script"],
18
28
  "extensions": [".cssl", ".cssl-pl", ".cssl-mod"],
19
- "configuration": "./language-configuration.json"
29
+ "configuration": "./language-configuration.json",
30
+ "icon": {
31
+ "light": "./images/cssl-icon.png",
32
+ "dark": "./images/cssl-icon.png"
33
+ }
20
34
  }
21
35
  ],
22
36
  "grammars": [
@@ -25,6 +39,12 @@
25
39
  "scopeName": "source.cssl",
26
40
  "path": "./syntaxes/cssl.tmLanguage.json"
27
41
  }
42
+ ],
43
+ "snippets": [
44
+ {
45
+ "language": "cssl",
46
+ "path": "./snippets/cssl.snippets.json"
47
+ }
28
48
  ]
29
49
  }
30
50
  }