IncludeCPP 4.0.2__py3-none-any.whl → 4.2.2__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/CHANGELOG.md +175 -0
- includecpp/DOCUMENTATION.md +593 -0
- includecpp/__init__.py +1 -1
- includecpp/__init__.pyi +4 -1
- includecpp/cli/commands.py +698 -84
- includecpp/core/ai_integration.py +46 -13
- includecpp/core/cpp_api_extensions.pyi +350 -0
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +186 -5
- includecpp/core/cssl/cssl_builtins.py +101 -4
- includecpp/core/cssl/cssl_languages.py +1757 -0
- includecpp/core/cssl/cssl_parser.py +429 -98
- includecpp/core/cssl/cssl_runtime.py +666 -51
- includecpp/core/cssl/cssl_syntax.py +88 -4
- includecpp/core/cssl/cssl_types.py +172 -1
- includecpp/core/cssl_bridge.py +194 -8
- includecpp/core/cssl_bridge.pyi +148 -10
- includecpp/generator/parser.cpp +121 -4
- includecpp/generator/parser.h +6 -0
- includecpp/vscode/cssl/package.json +43 -1
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +140 -17
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/METADATA +101 -1
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/RECORD +26 -22
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/WHEEL +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/entry_points.txt +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/top_level.txt +0 -0
|
@@ -36,6 +36,7 @@ class CSSLBuiltins:
|
|
|
36
36
|
# Output functions
|
|
37
37
|
self._functions['print'] = self.builtin_print
|
|
38
38
|
self._functions['println'] = self.builtin_println
|
|
39
|
+
self._functions['input'] = self.builtin_input
|
|
39
40
|
self._functions['debug'] = self.builtin_debug
|
|
40
41
|
self._functions['error'] = self.builtin_error
|
|
41
42
|
self._functions['warn'] = self.builtin_warn
|
|
@@ -291,6 +292,7 @@ class CSSLBuiltins:
|
|
|
291
292
|
self._functions['include'] = self.builtin_include
|
|
292
293
|
self._functions['payload'] = self.builtin_payload
|
|
293
294
|
self._functions['get'] = self.builtin_get
|
|
295
|
+
self._functions['libinclude'] = self.builtin_libinclude # v4.1.0: Multi-language support
|
|
294
296
|
|
|
295
297
|
# NEW: Extended OS Functions
|
|
296
298
|
self._functions['Listdir'] = self.builtin_listdir # Alias with capital L
|
|
@@ -365,6 +367,27 @@ class CSSLBuiltins:
|
|
|
365
367
|
else:
|
|
366
368
|
print(output)
|
|
367
369
|
|
|
370
|
+
def builtin_input(self, prompt: str = "") -> str:
|
|
371
|
+
"""Read user input from console.
|
|
372
|
+
|
|
373
|
+
Usage:
|
|
374
|
+
name = input("Enter your name: ");
|
|
375
|
+
age = int(input("Enter your age: "));
|
|
376
|
+
|
|
377
|
+
// Without prompt
|
|
378
|
+
value = input();
|
|
379
|
+
|
|
380
|
+
Args:
|
|
381
|
+
prompt: Optional prompt text to display
|
|
382
|
+
|
|
383
|
+
Returns:
|
|
384
|
+
The user's input as a string
|
|
385
|
+
"""
|
|
386
|
+
if self.runtime and hasattr(self.runtime, 'input'):
|
|
387
|
+
return self.runtime.input(prompt)
|
|
388
|
+
else:
|
|
389
|
+
return input(prompt)
|
|
390
|
+
|
|
368
391
|
def builtin_debug(self, *args) -> None:
|
|
369
392
|
"""Debug output"""
|
|
370
393
|
msg = ' '.join(str(a) for a in args)
|
|
@@ -1418,8 +1441,20 @@ class CSSLBuiltins:
|
|
|
1418
1441
|
time.sleep(ms / 1000.0)
|
|
1419
1442
|
|
|
1420
1443
|
def builtin_pyimport(self, module_name: str) -> Any:
|
|
1421
|
-
"""
|
|
1422
|
-
|
|
1444
|
+
"""
|
|
1445
|
+
Import a Python module for use in CSSL.
|
|
1446
|
+
|
|
1447
|
+
v4.1.1: Fixed to use importlib.import_module for proper nested module support.
|
|
1448
|
+
|
|
1449
|
+
Usage:
|
|
1450
|
+
module = pyimport("plugins.app")
|
|
1451
|
+
result = module.my_function()
|
|
1452
|
+
|
|
1453
|
+
os = pyimport("os")
|
|
1454
|
+
path = os.path.join("a", "b")
|
|
1455
|
+
"""
|
|
1456
|
+
import importlib
|
|
1457
|
+
return importlib.import_module(module_name)
|
|
1423
1458
|
|
|
1424
1459
|
# ============= Extended String Functions =============
|
|
1425
1460
|
|
|
@@ -1937,6 +1972,45 @@ class CSSLBuiltins:
|
|
|
1937
1972
|
except Exception as e:
|
|
1938
1973
|
raise CSSLBuiltinError(f"Failed to include '{filepath}': {e}")
|
|
1939
1974
|
|
|
1975
|
+
def builtin_libinclude(self, lang_id: str) -> Any:
|
|
1976
|
+
"""
|
|
1977
|
+
Load a language support module for multi-language syntax support.
|
|
1978
|
+
|
|
1979
|
+
v4.1.0: Multi-language support for CSSL.
|
|
1980
|
+
|
|
1981
|
+
Usage:
|
|
1982
|
+
@py = libinclude("python")
|
|
1983
|
+
cpp = libinclude("c++")
|
|
1984
|
+
java = libinclude("java")
|
|
1985
|
+
js = libinclude("javascript")
|
|
1986
|
+
csharp = libinclude("c#")
|
|
1987
|
+
|
|
1988
|
+
Returns: LanguageSupport object that can be used with 'supports' keyword.
|
|
1989
|
+
|
|
1990
|
+
Example:
|
|
1991
|
+
@py = libinclude("python");
|
|
1992
|
+
|
|
1993
|
+
define my_func() : supports @py {
|
|
1994
|
+
# Python syntax here!
|
|
1995
|
+
for i in range(10):
|
|
1996
|
+
print(i)
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
class MyClass : extends cpp$BaseClass {
|
|
2000
|
+
// Inherit from C++ class
|
|
2001
|
+
}
|
|
2002
|
+
"""
|
|
2003
|
+
from .cssl_languages import get_language
|
|
2004
|
+
|
|
2005
|
+
lang_support = get_language(lang_id)
|
|
2006
|
+
if lang_support is None:
|
|
2007
|
+
supported = ["python", "py", "java", "c#", "csharp", "c++", "cpp", "javascript", "js"]
|
|
2008
|
+
raise CSSLBuiltinError(
|
|
2009
|
+
f"Unknown language '{lang_id}'. Supported languages: {', '.join(supported)}"
|
|
2010
|
+
)
|
|
2011
|
+
|
|
2012
|
+
return lang_support
|
|
2013
|
+
|
|
1940
2014
|
def _load_cssl_module(self, filepath: str, source: str) -> Any:
|
|
1941
2015
|
"""
|
|
1942
2016
|
Load a .cssl-mod module file and return a callable module object.
|
|
@@ -2688,8 +2762,8 @@ class PythonizedCSSLInstance:
|
|
|
2688
2762
|
return value
|
|
2689
2763
|
|
|
2690
2764
|
# Check for method
|
|
2691
|
-
|
|
2692
|
-
|
|
2765
|
+
if instance.has_method(name):
|
|
2766
|
+
method = instance.get_method(name)
|
|
2693
2767
|
# Return a callable wrapper for the method
|
|
2694
2768
|
return PythonizedMethod(instance, name, method, runtime)
|
|
2695
2769
|
|
|
@@ -2744,6 +2818,29 @@ class PythonizedMethod:
|
|
|
2744
2818
|
if self._runtime is None:
|
|
2745
2819
|
raise RuntimeError(f"Cannot call method '{self._method_name}' - no runtime available")
|
|
2746
2820
|
|
|
2821
|
+
# Validate argument count
|
|
2822
|
+
# Method AST structure: node.value is a dict with 'params' key
|
|
2823
|
+
method_info = getattr(self._method_ast, 'value', {}) or {}
|
|
2824
|
+
method_params = method_info.get('params', []) if isinstance(method_info, dict) else []
|
|
2825
|
+
param_names = [p.get('name', str(p)) if isinstance(p, dict) else (p.name if hasattr(p, 'name') else str(p)) for p in method_params]
|
|
2826
|
+
expected_count = len(param_names)
|
|
2827
|
+
actual_count = len(args)
|
|
2828
|
+
|
|
2829
|
+
if actual_count < expected_count:
|
|
2830
|
+
missing = param_names[actual_count:]
|
|
2831
|
+
class_name = self._instance._class.name
|
|
2832
|
+
raise TypeError(
|
|
2833
|
+
f"{class_name}.{self._method_name}() missing {len(missing)} required argument(s): {', '.join(repr(p) for p in missing)}\n"
|
|
2834
|
+
f" Expected: {self._method_name}({', '.join(param_names)})\n"
|
|
2835
|
+
f" Got: {self._method_name}({', '.join(repr(a) for a in args)})"
|
|
2836
|
+
)
|
|
2837
|
+
elif actual_count > expected_count:
|
|
2838
|
+
class_name = self._instance._class.name
|
|
2839
|
+
raise TypeError(
|
|
2840
|
+
f"{class_name}.{self._method_name}() takes {expected_count} argument(s) but {actual_count} were given\n"
|
|
2841
|
+
f" Expected: {self._method_name}({', '.join(param_names)})"
|
|
2842
|
+
)
|
|
2843
|
+
|
|
2747
2844
|
# Execute the method through the runtime
|
|
2748
2845
|
# Pass the method AST node, not the method name
|
|
2749
2846
|
result = self._runtime._call_method(self._instance, self._method_ast, list(args), kwargs)
|