IncludeCPP 4.5.2__py3-none-any.whl → 4.9.3__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.
Files changed (35) hide show
  1. includecpp/CHANGELOG.md +241 -0
  2. includecpp/__init__.py +89 -3
  3. includecpp/__init__.pyi +2 -1
  4. includecpp/cli/commands.py +1747 -266
  5. includecpp/cli/config_parser.py +1 -1
  6. includecpp/core/build_manager.py +64 -13
  7. includecpp/core/cpp_api_extensions.pyi +43 -270
  8. includecpp/core/cssl/CSSL_DOCUMENTATION.md +1799 -1445
  9. includecpp/core/cssl/cpp/build/api.pyd +0 -0
  10. includecpp/core/cssl/cpp/build/api.pyi +274 -0
  11. includecpp/core/cssl/cpp/build/cssl_core.pyi +0 -99
  12. includecpp/core/cssl/cpp/cssl_core.cp +2 -23
  13. includecpp/core/cssl/cssl_builtins.py +2116 -171
  14. includecpp/core/cssl/cssl_builtins.pyi +1324 -104
  15. includecpp/core/cssl/cssl_compiler.py +4 -1
  16. includecpp/core/cssl/cssl_modules.py +605 -6
  17. includecpp/core/cssl/cssl_optimizer.py +12 -1
  18. includecpp/core/cssl/cssl_parser.py +1048 -52
  19. includecpp/core/cssl/cssl_runtime.py +2041 -131
  20. includecpp/core/cssl/cssl_syntax.py +405 -277
  21. includecpp/core/cssl/cssl_types.py +5891 -1655
  22. includecpp/core/cssl_bridge.py +429 -3
  23. includecpp/core/error_catalog.py +54 -10
  24. includecpp/core/homeserver.py +1037 -0
  25. includecpp/generator/parser.cpp +203 -39
  26. includecpp/generator/parser.h +15 -1
  27. includecpp/templates/cpp.proj.template +1 -1
  28. includecpp/vscode/cssl/snippets/cssl.snippets.json +163 -0
  29. includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +87 -12
  30. {includecpp-4.5.2.dist-info → includecpp-4.9.3.dist-info}/METADATA +81 -10
  31. {includecpp-4.5.2.dist-info → includecpp-4.9.3.dist-info}/RECORD +35 -33
  32. {includecpp-4.5.2.dist-info → includecpp-4.9.3.dist-info}/WHEEL +1 -1
  33. {includecpp-4.5.2.dist-info → includecpp-4.9.3.dist-info}/entry_points.txt +0 -0
  34. {includecpp-4.5.2.dist-info → includecpp-4.9.3.dist-info}/licenses/LICENSE +0 -0
  35. {includecpp-4.5.2.dist-info → includecpp-4.9.3.dist-info}/top_level.txt +0 -0
includecpp/CHANGELOG.md CHANGED
@@ -1,5 +1,246 @@
1
1
  # IncludeCPP Changelog
2
2
 
3
+ ## v4.9.3 (2026-01-27)
4
+
5
+ ### New Features - Full Async/Await System
6
+
7
+ #### Async Functions
8
+ - **`async` function modifier**: Define async functions that return Futures
9
+ ```cssl
10
+ async define fetchData(string url) {
11
+ result = http.get(url);
12
+ return result;
13
+ }
14
+
15
+ // Calling returns Future immediately
16
+ future f = fetchData("http://example.com");
17
+ data = await f;
18
+ ```
19
+
20
+ #### Await Keyword
21
+ - **`await`**: Wait for async operations to complete
22
+ ```cssl
23
+ data = await asyncFunction();
24
+ result = await future;
25
+ ```
26
+
27
+ #### Generator Functions with Yield
28
+ - **`yield` statement**: Create lazy iterators
29
+ ```cssl
30
+ generator<int> define Range(int n) {
31
+ int i = 0;
32
+ while (i < n) {
33
+ yield i;
34
+ i = i + 1;
35
+ }
36
+ }
37
+
38
+ gen = Range(5);
39
+ while (gen.has_next()) {
40
+ printl(gen.next()); // 0, 1, 2, 3, 4
41
+ }
42
+ ```
43
+
44
+ #### Async Module (`async::` / `Async::`)
45
+ - **`async.run(func, *args)`**: Run function asynchronously, returns Future
46
+ - **`async.stop(future)`**: Cancel async operation
47
+ - **`async.wait(future, timeout?)`**: Wait for Future with optional timeout
48
+ - **`async.all(futures, timeout?)`**: Wait for all Futures to complete
49
+ - **`async.race(futures, timeout?)`**: Return first completed Future's result
50
+ - **`async.sleep(ms)`**: Async sleep for milliseconds
51
+
52
+ #### New Types
53
+ - **`CSSLFuture`**: Represents result of async operation
54
+ - States: `pending`, `running`, `completed`, `cancelled`, `failed`
55
+ - Methods: `result()`, `is_done()`, `cancel()`, `then(callback)`
56
+ - **`CSSLGenerator`**: Lazy iteration via yield
57
+ - Methods: `next()`, `has_next()`, `send(val)`, `to_list()`, `take(n)`, `skip(n)`
58
+ - **`CSSLAsyncFunction`**: Wrapper for async-defined functions
59
+
60
+ ### Parser Enhancements
61
+ - Added `async`, `yield`, `generator`, `future` keywords
62
+ - Added `async` to function modifiers
63
+ - Added `generator` and `future` to generic type keywords
64
+
65
+ ### Type Stubs
66
+ - Updated `cssl_builtins.pyi` with full async type documentation
67
+ - Added `CSSLFuture`, `CSSLGenerator`, `AsyncModule` stubs
68
+
69
+ ### Documentation
70
+ - Added comprehensive Async/Await section to CSSL documentation
71
+ - Added generator function examples and patterns
72
+
73
+ ---
74
+
75
+ ## v4.9.2 (2026-01-26)
76
+
77
+ ### New Features - Builtin Function Hooks & Introspection
78
+
79
+ #### Builtin Function Hooks (`&builtin ++`)
80
+ - **Hook into any builtin function** with append mode:
81
+ ```cssl
82
+ embedded define __hook_print(msg) &printl ++ {
83
+ printl("LOG: " + _result); // _result has original's return value
84
+ }
85
+
86
+ // Now all printl calls trigger the hook AFTER original runs
87
+ printl("Hello"); // Prints: "Hello" then "LOG: null"
88
+ ```
89
+
90
+ - **Append mode semantics**: Original runs first, then hook body executes
91
+ - **`_result` variable**: Automatically contains the original function's return value
92
+ - **`local::` references**: Access hook context variables
93
+ ```cssl
94
+ local::_result // Original's return value
95
+ local::0 // First positional argument
96
+ local::_args // All positional arguments
97
+ local::_kwargs // All keyword arguments
98
+ ```
99
+
100
+ #### New Builtins
101
+ - **`destroy(target)`**: Destroy object and free memory
102
+ ```cssl
103
+ list data = [1, 2, 3];
104
+ destroy(data); // Clears the list
105
+ ```
106
+
107
+ - **`execute(code, context?)`**: Execute CSSL code string inline
108
+ ```cssl
109
+ result = execute("return 5 + 3;"); // Returns 8
110
+ execute("printl(name);", {"name": "World"}); // With context
111
+ ```
112
+
113
+ #### Parser Enhancements
114
+ - **Position syntax for hooks**: `&name[-1]` (places hook at specific position)
115
+ - **`local::varname`** token type for accessing hooked function locals
116
+
117
+ ### Bug Fixes
118
+ - Fixed infinite recursion when hook body calls the hooked builtin
119
+ - Fixed `skip` keyword argument error in builtin hooks
120
+ - Fixed hook execution order (original now runs before hook body in append mode)
121
+
122
+ ### Syntax Highlighting
123
+ - Added `local::` reference highlighting
124
+ - Added `_result`, `_args`, `_kwargs` special variable highlighting
125
+ - Added `destroy` and `execute` builtin highlighting
126
+
127
+ ---
128
+
129
+ ## v4.9.0 (2026-01-25)
130
+
131
+ ### New Features - CSSL Language Enhancements
132
+
133
+ #### Binary Data Types
134
+ - **`bit`**: Single binary value (0 or 1)
135
+ ```cssl
136
+ bit flag = 1;
137
+ flag.switch(); // Toggle: 1 -> 0
138
+ flag.set(1); // Set to 1
139
+ flag.clear(); // Set to 0
140
+ bit copy = flag.copy();
141
+ ```
142
+
143
+ - **`byte`**: 8-bit value with `x^y` notation
144
+ ```cssl
145
+ byte b = 1^200; // base^weight notation
146
+ printl(b.value()); // 200
147
+ printl(b.to_str()); // "11001000" (binary)
148
+ b.switch(7); // Toggle bit 7
149
+ b.set(0, 1); // Set bit 0 to 1
150
+ printl(b.info()); // Full info dict
151
+ byte r = b.reverse(); // Reverse bit order
152
+ ```
153
+
154
+ - **`address`**: Memory reference (pointer-like)
155
+ ```cssl
156
+ string text = "Hello";
157
+ address addr = address(text); // Get address
158
+ obj = addr.reflect(); // Dereference
159
+ obj = reflect(addr); // Also works
160
+
161
+ // Use in functions
162
+ define useAddress() {
163
+ string val = reflect(addr); // Access from anywhere
164
+ }
165
+ ```
166
+
167
+ #### Pointer Syntax (`?`)
168
+ - **`?name = obj`**: Create pointer to object (simple C-like syntax)
169
+ - **`?name`**: Dereference pointer to get object
170
+ ```cssl
171
+ string text = "Hello";
172
+ ?ptr = text; // Create pointer
173
+
174
+ define usePointer() {
175
+ string val = ?ptr; // Dereference: "Hello"
176
+ printl(val);
177
+ }
178
+ usePointer();
179
+ ```
180
+
181
+ #### Memory Functions
182
+ - **`address(obj)`**: Shortcut for `memory(obj).get("address")`
183
+ - **`reflect(addr)`**: Dereference an address to get the original object
184
+ - **`memory()`**: Now registers objects for later reflection
185
+
186
+ #### Snapshot Assignment
187
+ - **`%var = value`**: Direct snapshot assignment syntax
188
+ ```cssl
189
+ string greeting = "Hello";
190
+ %savedGreeting = greeting;
191
+ greeting = "Changed";
192
+ printl(%savedGreeting); // "Hello"
193
+ ```
194
+
195
+ ### Bug Fixes
196
+ - Fixed bit/byte method calls returning null in CSSL runtime
197
+ - Fixed parser not recognizing bit/byte as type keywords
198
+ - Fixed typed declarations for bit/byte/address types
199
+
200
+ ### Syntax Highlighting
201
+ - Added `bit`, `byte`, `address` type highlighting
202
+ - Updated `%variable` snapshot highlighting (% pink, variable blue-pink)
203
+
204
+ ---
205
+
206
+ ## v4.6.7 (2026-01-14)
207
+
208
+ ### New Features
209
+ - **HomeServer**: Local storage server for modules, projects and files
210
+ - `includecpp server install` - Install and auto-start HomeServer
211
+ - `includecpp server start/stop` - Manual server control
212
+ - `includecpp server status` - Check server status
213
+ - `includecpp server upload/download` - File and project management
214
+ - `includecpp server list` - List stored items
215
+ - `includecpp server delete` - Remove items
216
+ - `includecpp server port` - Change server port
217
+ - `includecpp server deinstall` - Remove HomeServer completely
218
+ - Server runs in background (no terminal window)
219
+ - Auto-start support on Windows
220
+ - SQLite database for metadata storage
221
+ - Default port: 2007
222
+
223
+ ---
224
+
225
+ ## v4.6.6 (2026-01-14)
226
+
227
+ ### New Features
228
+ - **ENUM support**: Expose C++ enums to Python via `ENUM(EnumName) CLASS { values... }` syntax
229
+ - **Multiple SOURCE support**: `SOURCE(file1) && SOURCE(file2)` in .cp files
230
+ - **FIELD_ARRAY support**: C-style arrays now properly bound as read-only `bytes` properties
231
+ - Automatic detection of array fields in plugin command
232
+
233
+ ### Bug Fixes
234
+ - Fixed signed/unsigned comparison warning from pybind11 enum bindings
235
+ - Removed SIGNED_UNSIGNED from error catalog (was a warning, not error)
236
+ - Fixed array fields causing `invalid array assignment` error
237
+ - Version display now shows X.X format in build output
238
+
239
+ ### Breaking Changes
240
+ - Array fields in structs are now read-only (accessible as `bytes`)
241
+
242
+ ---
243
+
3
244
  ## v4.3.2 (2026-01-08)
4
245
 
5
246
  ### New Features
includecpp/__init__.py CHANGED
@@ -1,19 +1,91 @@
1
1
  from .core.cpp_api import CppApi
2
2
  from .core import cssl_bridge as CSSL
3
3
  import warnings
4
+ import os
5
+ import sys
6
+ from pathlib import Path
4
7
 
5
- __version__ = "4.5.2"
8
+ __version__ = "4.9.3"
6
9
  __all__ = ["CppApi", "CSSL"]
7
10
 
8
11
  # Module-level cache for C++ modules
9
12
  _api_instance = None
10
13
  _loaded_modules = {}
14
+ _frozen_api = None # Cached API module for frozen (PyInstaller) mode
15
+
16
+ def _is_frozen():
17
+ """Check if running in a frozen PyInstaller bundle."""
18
+ return getattr(sys, 'frozen', False)
19
+
20
+ def _get_frozen_api():
21
+ """Get the bundled API module when running frozen."""
22
+ global _frozen_api
23
+ if _frozen_api is None:
24
+ try:
25
+ import importlib.util
26
+ import importlib.machinery
27
+ ext = '.pyd' if sys.platform == 'win32' else '.so'
28
+
29
+ # Look for includecpp.dll in the same directory as the executable
30
+ exe_dir = Path(sys.executable).parent
31
+ dll_path = exe_dir / 'includecpp.dll'
32
+
33
+ if dll_path.exists():
34
+ # Use ExtensionFileLoader - module name must be 'api' to match PyInit_api
35
+ loader = importlib.machinery.ExtensionFileLoader('api', str(dll_path))
36
+ spec = importlib.util.spec_from_loader('api', loader, origin=str(dll_path))
37
+ if spec:
38
+ api_module = importlib.util.module_from_spec(spec)
39
+ sys.modules['api'] = api_module
40
+ loader.exec_module(api_module)
41
+ _frozen_api = api_module
42
+ return _frozen_api
43
+
44
+ # Fallback: try api.pyd in _MEIPASS (legacy/bundled mode)
45
+ if hasattr(sys, '_MEIPASS'):
46
+ meipass = sys._MEIPASS
47
+ if meipass not in sys.path:
48
+ sys.path.insert(0, meipass)
49
+
50
+ api_path = os.path.join(meipass, f'api{ext}')
51
+
52
+ if os.path.exists(api_path):
53
+ loader = importlib.machinery.ExtensionFileLoader('api', api_path)
54
+ spec = importlib.util.spec_from_loader('api', loader, origin=api_path)
55
+ if spec:
56
+ api_module = importlib.util.module_from_spec(spec)
57
+ sys.modules['api'] = api_module
58
+ loader.exec_module(api_module)
59
+ _frozen_api = api_module
60
+ return _frozen_api
61
+
62
+ # Fallback to regular import
63
+ import api
64
+ _frozen_api = api
65
+ except Exception as e:
66
+ # Store error for debugging
67
+ _frozen_api = False
68
+ print(f"[IncludeCPP] Failed to load frozen API: {e}", file=sys.stderr)
69
+ return _frozen_api if _frozen_api else None
11
70
 
12
71
  def _get_api():
13
- """Get or create singleton CppApi instance."""
72
+ """Get or create singleton CppApi instance.
73
+
74
+ Checks INCLUDECPP_PROJECT env var for project path when running
75
+ from a different directory (e.g., via 'includecpp server run').
76
+ """
14
77
  global _api_instance
15
78
  if _api_instance is None:
16
- _api_instance = CppApi()
79
+ # Check for project path from environment (set by 'server run -p')
80
+ project_path = os.environ.get('INCLUDECPP_PROJECT')
81
+ if project_path:
82
+ config_path = Path(project_path) / 'cpp.proj'
83
+ if config_path.exists():
84
+ _api_instance = CppApi(config_path=config_path)
85
+ else:
86
+ _api_instance = CppApi()
87
+ else:
88
+ _api_instance = CppApi()
17
89
  return _api_instance
18
90
 
19
91
  def __getattr__(name: str):
@@ -28,6 +100,20 @@ def __getattr__(name: str):
28
100
  if name in _loaded_modules:
29
101
  return _loaded_modules[name]
30
102
 
103
+ # In frozen mode (PyInstaller), try to get module from bundled api
104
+ if _is_frozen():
105
+ frozen_api = _get_frozen_api()
106
+ if frozen_api and hasattr(frozen_api, name):
107
+ module = getattr(frozen_api, name)
108
+ _loaded_modules[name] = module
109
+ return module
110
+ # If not found in frozen api, raise helpful error
111
+ raise AttributeError(
112
+ f"Module '{name}' not found in bundled executable. "
113
+ f"Ensure it was included during build with 'includecpp --make-exe'."
114
+ )
115
+
116
+ # Normal mode: use CppApi
31
117
  api = _get_api()
32
118
 
33
119
  if name not in api.registry:
includecpp/__init__.pyi CHANGED
@@ -147,7 +147,8 @@ __version__: str
147
147
  # Dynamic module access via: from includecpp import <module_name>
148
148
  # Auto-generated module declarations
149
149
  # These allow: from includecpp import <module_name>
150
- cssl_core: Cssl_coreModuleWrapper
150
+ cssl_runner: Cssl_runnerModuleWrapper
151
+ mycpp: MycppModuleWrapper
151
152
 
152
153
  def __dir__() -> List[str]:
153
154
  """List available modules including dynamically loaded C++ modules."""