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 CHANGED
@@ -2,7 +2,7 @@ from .core.cpp_api import CppApi
2
2
  from .core import cssl_bridge as CSSL
3
3
  import warnings
4
4
 
5
- __version__ = "3.4.8"
5
+ __version__ = "3.4.21"
6
6
  __all__ = ["CppApi", "CSSL"]
7
7
 
8
8
  # Module-level cache for C++ modules
includecpp/__init__.pyi CHANGED
@@ -1,8 +1,9 @@
1
1
  """Type stubs for includecpp package - VSCode IntelliSense support."""
2
2
 
3
- from typing import Any, Dict, Optional, List, Literal, overload
3
+ from typing import Any, Dict, Optional, List, Literal, overload, Callable
4
4
  from pathlib import Path
5
5
  from types import ModuleType
6
+ import threading
6
7
 
7
8
  # Import generated module wrappers for VSCode autocomplete
8
9
  # These are created by 'includecpp rebuild' and provide module-specific type hints
@@ -11,6 +12,136 @@ try:
11
12
  except ImportError:
12
13
  pass # Generated during rebuild
13
14
 
15
+
16
+ # ========== CSSL Module - CSO Service Script Language ==========
17
+ class _CSSLModule:
18
+ """CSSL callable module created via CSSL.module()"""
19
+ def __call__(self, *args: Any) -> Any:
20
+ """Execute the module code with arguments."""
21
+ ...
22
+
23
+ class _CSSLFunctionModule:
24
+ """CSSL function module created via CSSL.makemodule()"""
25
+ def __getattr__(self, name: str) -> Callable[..., Any]:
26
+ """Get a function from the module."""
27
+ ...
28
+
29
+ class _CsslLang:
30
+ """CSSL Language interface."""
31
+
32
+ def exec(self, path_or_code: str, *args: Any) -> Any:
33
+ """Execute CSSL code or file.
34
+
35
+ Args:
36
+ path_or_code: Path to .cssl file or CSSL code string
37
+ *args: Arguments accessible via parameter.get(index)
38
+
39
+ Returns:
40
+ Execution result
41
+ """
42
+ ...
43
+
44
+ def T_exec(
45
+ self,
46
+ path_or_code: str,
47
+ *args: Any,
48
+ callback: Optional[Callable[[Any], None]] = None
49
+ ) -> threading.Thread:
50
+ """Execute CSSL code asynchronously in a thread."""
51
+ ...
52
+
53
+ def wait_all(self, timeout: Optional[float] = None) -> None:
54
+ """Wait for all async executions to complete."""
55
+ ...
56
+
57
+ def get_output(self) -> List[str]:
58
+ """Get output buffer from last execution."""
59
+ ...
60
+
61
+ def clear_output(self) -> None:
62
+ """Clear output buffer."""
63
+ ...
64
+
65
+ def set_global(self, name: str, value: Any) -> None:
66
+ """Set a global variable in CSSL runtime."""
67
+ ...
68
+
69
+ def get_global(self, name: str) -> Any:
70
+ """Get a global variable from CSSL runtime."""
71
+ ...
72
+
73
+ def module(self, code: str) -> _CSSLModule:
74
+ """Create a callable CSSL module from code."""
75
+ ...
76
+
77
+ def makemodule(self, code: str) -> _CSSLFunctionModule:
78
+ """Create a CSSL module with accessible functions."""
79
+ ...
80
+
81
+
82
+ class _CSSLBridge:
83
+ """CSSL Bridge module - access to CSSL language from Python."""
84
+
85
+ CsslLang: type[_CsslLang]
86
+
87
+ def exec(self, path_or_code: str, *args: Any) -> Any:
88
+ """Execute CSSL code or file."""
89
+ ...
90
+
91
+ def _exec(self, code: str, *args: Any) -> Any:
92
+ """Execute CSSL code (alias for exec)."""
93
+ ...
94
+
95
+ def T_exec(
96
+ self,
97
+ path_or_code: str,
98
+ *args: Any,
99
+ callback: Optional[Callable[[Any], None]] = None
100
+ ) -> threading.Thread:
101
+ """Execute CSSL code asynchronously."""
102
+ ...
103
+
104
+ def _T_exec(
105
+ self,
106
+ code: str,
107
+ *args: Any,
108
+ callback: Optional[Callable[[Any], None]] = None
109
+ ) -> threading.Thread:
110
+ """Execute CSSL code asynchronously (alias)."""
111
+ ...
112
+
113
+ def set_global(self, name: str, value: Any) -> None:
114
+ """Set a global variable."""
115
+ ...
116
+
117
+ def get_global(self, name: str) -> Any:
118
+ """Get a global variable."""
119
+ ...
120
+
121
+ def get_output(self) -> List[str]:
122
+ """Get output buffer."""
123
+ ...
124
+
125
+ def clear_output(self) -> None:
126
+ """Clear output buffer."""
127
+ ...
128
+
129
+ def module(self, code: str) -> _CSSLModule:
130
+ """Create a callable CSSL module."""
131
+ ...
132
+
133
+ def makemodule(self, code: str) -> _CSSLFunctionModule:
134
+ """Create a CSSL function module."""
135
+ ...
136
+
137
+ def get_cssl(self) -> _CsslLang:
138
+ """Get default CSSL instance."""
139
+ ...
140
+
141
+
142
+ # CSSL module instance - CSO Service Script Language
143
+ CSSL: _CSSLBridge
144
+
14
145
  __version__: str
15
146
 
16
147
  # Dynamic module access via: from includecpp import <module_name>
@@ -121,4 +252,4 @@ class CppApi:
121
252
  """List all available modules."""
122
253
  ...
123
254
 
124
- __all__: List[str]
255
+ __all__: List[str] # Includes: CppApi, CSSL, __version__
@@ -7455,9 +7455,8 @@ def cssl_exec(path, code):
7455
7455
  try:
7456
7456
  result = cssl_lang.exec(source)
7457
7457
 
7458
- # Print output buffer
7459
- for line in cssl_lang.get_output():
7460
- click.echo(line)
7458
+ # Output is already printed to stdout during execution via runtime.output()
7459
+ # No need to print buffer again - this was causing double output
7461
7460
 
7462
7461
  if result is not None:
7463
7462
  click.echo(f"Result: {result}")
@@ -7508,6 +7507,130 @@ def cssl_makemodule(path, output):
7508
7507
  click.echo(f" Type: {module_data['type']}")
7509
7508
 
7510
7509
 
7510
+ @cssl.command(name='doc')
7511
+ def cssl_doc():
7512
+ """Show CSSL documentation."""
7513
+ from pathlib import Path as PathLib
7514
+ import os
7515
+
7516
+ # Find the documentation file in the cssl package directory
7517
+ cssl_dir = PathLib(__file__).parent.parent / 'core' / 'cssl'
7518
+ doc_path = cssl_dir / 'CSSL_DOCUMENTATION.md'
7519
+
7520
+ if not doc_path.exists():
7521
+ # Try alternative locations
7522
+ alt_paths = [
7523
+ PathLib(__file__).parent.parent.parent / 'CSSL_DOCUMENTATION.md',
7524
+ PathLib(__file__).parent.parent / 'CSSL_DOCUMENTATION.md',
7525
+ PathLib(os.getcwd()) / 'CSSL_DOCUMENTATION.md',
7526
+ ]
7527
+ for alt in alt_paths:
7528
+ if alt.exists():
7529
+ doc_path = alt
7530
+ break
7531
+
7532
+ if doc_path.exists():
7533
+ content = doc_path.read_text(encoding='utf-8')
7534
+ # Use pager for long content
7535
+ click.echo_via_pager(content)
7536
+ else:
7537
+ click.secho("Documentation file not found.", fg='yellow')
7538
+ click.echo("Looking for: CSSL_DOCUMENTATION.md")
7539
+ click.echo()
7540
+ click.echo("Quick Reference:")
7541
+ click.echo(" - Variables: string x = \"hello\"; int n = 42;")
7542
+ click.echo(" - Functions: void foo() { } or define bar() { }")
7543
+ click.echo(" - Loops: for (i in range(0, 10)) { } or for (int i = 0; i < 10; i++) { }")
7544
+ click.echo(" - Conditions: if (x) { } elif (y) { } else { }")
7545
+ click.echo(" - Containers: stack<T>, vector<T>, array<T>")
7546
+ click.echo(" - Globals: global x = value; @x")
7547
+ click.echo(" - Payloads: payload(\"file.cssl-pl\");")
7548
+ click.echo()
7549
+ click.echo("For full docs, see: https://github.com/liliassg/IncludeCPP")
7550
+
7551
+
7552
+ @cssl.command(name='create')
7553
+ @click.argument('name')
7554
+ @click.option('--dir', '-d', type=click.Path(), default='.', help='Output directory')
7555
+ def cssl_create(name, dir):
7556
+ """Create a new CSSL project with .cssl and .cssl-pl files."""
7557
+ from pathlib import Path as PathLib
7558
+
7559
+ out_dir = PathLib(dir)
7560
+ out_dir.mkdir(parents=True, exist_ok=True)
7561
+
7562
+ cssl_file = out_dir / f"{name}.cssl"
7563
+ payload_file = out_dir / f"{name}.cssl-pl"
7564
+
7565
+ # Create .cssl file
7566
+ cssl_content = f'''// {name}.cssl - CSSL Application
7567
+ // Created with: includecpp cssl create {name}
7568
+
7569
+ // Load payload (globals, injections, config)
7570
+ payload("{name}.cssl-pl");
7571
+
7572
+ // Main application code
7573
+ void main() {{
7574
+ printl("Hello from {name}!");
7575
+ printl("Version: " + @version);
7576
+ }}
7577
+
7578
+ main();
7579
+ '''
7580
+
7581
+ # Create .cssl-pl payload file
7582
+ payload_content = f'''// {name}.cssl-pl - CSSL Payload
7583
+ // Loaded via: payload("{name}.cssl-pl");
7584
+
7585
+ // ============================================================================
7586
+ // Configuration & Variables
7587
+ // ============================================================================
7588
+ global version = "1.0.0";
7589
+ global appName = "{name}";
7590
+ global debug = false;
7591
+
7592
+ // ============================================================================
7593
+ // Builtin Injections
7594
+ // ============================================================================
7595
+ // Inject cleanup code into exit()
7596
+ exit() <<== {{
7597
+ if (@debug) {{
7598
+ printl("[DEBUG] {name} shutting down...");
7599
+ }}
7600
+ }}
7601
+
7602
+ // ============================================================================
7603
+ // Helper Functions (globally callable via @functionName)
7604
+ // ============================================================================
7605
+ void log(string message) {{
7606
+ if (@debug) {{
7607
+ printl("[LOG] " + message);
7608
+ }}
7609
+ }}
7610
+
7611
+ void error(string message) {{
7612
+ printl("[ERROR] " + message);
7613
+ }}
7614
+ '''
7615
+
7616
+ # Write files
7617
+ cssl_file.write_text(cssl_content, encoding='utf-8')
7618
+ payload_file.write_text(payload_content, encoding='utf-8')
7619
+
7620
+ click.secho(f"Created CSSL project: {name}", fg='green', bold=True)
7621
+ click.echo()
7622
+ click.echo("Files created:")
7623
+ click.echo(f" {cssl_file} - Main application")
7624
+ click.echo(f" {payload_file} - Payload (globals, injections)")
7625
+ click.echo()
7626
+ click.echo("Run with:")
7627
+ click.secho(f" includecpp cssl exec {cssl_file}", fg='cyan')
7628
+ click.echo()
7629
+ click.echo("Or from Python:")
7630
+ click.echo(" from includecpp import CSSL")
7631
+ click.echo(f" CSSL.exec('{cssl_file}')")
7632
+
7633
+
7511
7634
  # Register hidden cssl command group
7512
7635
  cli.add_command(cssl)
7513
7636