IncludeCPP 4.0.2__py3-none-any.whl → 4.1.0__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 +1 -1
- includecpp/__init__.pyi +3 -1
- includecpp/cli/commands.py +3 -3
- includecpp/core/ai_integration.py +46 -13
- includecpp/core/cpp_api_extensions.pyi +622 -0
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +186 -5
- includecpp/core/cssl/cssl_builtins.py +87 -2
- includecpp/core/cssl/cssl_languages.py +836 -0
- includecpp/core/cssl/cssl_parser.py +138 -38
- includecpp/core/cssl/cssl_runtime.py +364 -24
- 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/vscode/cssl/package.json +43 -1
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +140 -17
- {includecpp-4.0.2.dist-info → includecpp-4.1.0.dist-info}/METADATA +101 -1
- {includecpp-4.0.2.dist-info → includecpp-4.1.0.dist-info}/RECORD +22 -20
- {includecpp-4.0.2.dist-info → includecpp-4.1.0.dist-info}/WHEEL +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.1.0.dist-info}/entry_points.txt +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.1.0.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CSSL - C-Style Scripting Language
|
|
2
2
|
|
|
3
|
-
> Version 4.
|
|
3
|
+
> Version 4.1.0 | A modern scripting language with C++-style syntax and unique features like CodeInfusion, BruteInjection, Python Interop, and Multi-Language Support.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
12. [BruteInjection](#bruteinjection)
|
|
21
21
|
13. [Value Capture](#value-capture)
|
|
22
22
|
14. [Module System](#module-system)
|
|
23
|
-
15. [
|
|
24
|
-
16. [
|
|
23
|
+
15. [Multi-Language Support](#multi-language-support)
|
|
24
|
+
16. [Error Handling](#error-handling)
|
|
25
|
+
17. [Quick Reference](#quick-reference)
|
|
25
26
|
|
|
26
27
|
---
|
|
27
28
|
|
|
@@ -101,15 +102,21 @@ printl("Hello") // Works
|
|
|
101
102
|
printl("Hello"); // Also works (recommended)
|
|
102
103
|
```
|
|
103
104
|
|
|
104
|
-
###
|
|
105
|
+
### I/O Functions
|
|
105
106
|
|
|
106
107
|
```cssl
|
|
108
|
+
// Output
|
|
107
109
|
printl("Text"); // Print with newline
|
|
108
110
|
print("No newline"); // Print without newline
|
|
109
111
|
debug("Debug info"); // Print with [DEBUG] prefix
|
|
110
112
|
error("Error message"); // Print with [ERROR] prefix
|
|
111
113
|
warn("Warning"); // Print with [WARN] prefix
|
|
112
114
|
log("INFO", "Message"); // Print with custom prefix
|
|
115
|
+
|
|
116
|
+
// Input
|
|
117
|
+
string name = input("Enter your name: ");
|
|
118
|
+
int age = int(input("Enter your age: "));
|
|
119
|
+
string raw = input(); // Without prompt
|
|
113
120
|
```
|
|
114
121
|
|
|
115
122
|
---
|
|
@@ -1398,6 +1405,161 @@ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
|
|
|
1398
1405
|
|
|
1399
1406
|
---
|
|
1400
1407
|
|
|
1408
|
+
## Multi-Language Support
|
|
1409
|
+
|
|
1410
|
+
CSSL v4.1.0 introduces multi-language support for interoperability with other programming languages.
|
|
1411
|
+
|
|
1412
|
+
### libinclude - Load Language Support
|
|
1413
|
+
|
|
1414
|
+
Use `libinclude()` to load a language support module:
|
|
1415
|
+
|
|
1416
|
+
```cssl
|
|
1417
|
+
// Load language support
|
|
1418
|
+
@py = libinclude("python");
|
|
1419
|
+
cpp = libinclude("c++");
|
|
1420
|
+
java = libinclude("java");
|
|
1421
|
+
csharp = libinclude("c#");
|
|
1422
|
+
js = libinclude("javascript");
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
**Supported Languages:**
|
|
1426
|
+
|
|
1427
|
+
| Language | Identifiers |
|
|
1428
|
+
|----------|-------------|
|
|
1429
|
+
| Python | `python`, `py` |
|
|
1430
|
+
| C++ | `c++`, `cpp` |
|
|
1431
|
+
| Java | `java` |
|
|
1432
|
+
| C# | `c#`, `csharp` |
|
|
1433
|
+
| JavaScript | `javascript`, `js` |
|
|
1434
|
+
|
|
1435
|
+
### supports - Multi-Language Syntax
|
|
1436
|
+
|
|
1437
|
+
Use the `supports` keyword to write functions or classes using another language's syntax:
|
|
1438
|
+
|
|
1439
|
+
```cssl
|
|
1440
|
+
// Python-style function
|
|
1441
|
+
define calculate(numbers) : supports @py {
|
|
1442
|
+
total = 0
|
|
1443
|
+
for n in numbers:
|
|
1444
|
+
total = total + n
|
|
1445
|
+
return total
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
// C++ style class
|
|
1449
|
+
class Engine : supports cpp {
|
|
1450
|
+
int power;
|
|
1451
|
+
bool running;
|
|
1452
|
+
|
|
1453
|
+
void start() {
|
|
1454
|
+
this->running = true;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// JavaScript style function
|
|
1459
|
+
define fetchData(url) : supports js {
|
|
1460
|
+
let response = fetch(url);
|
|
1461
|
+
console.log("Fetched: " + url);
|
|
1462
|
+
return response;
|
|
1463
|
+
}
|
|
1464
|
+
```
|
|
1465
|
+
|
|
1466
|
+
### Cross-Language Instance Access
|
|
1467
|
+
|
|
1468
|
+
Access instances shared from other languages using `lang$InstanceName` syntax:
|
|
1469
|
+
|
|
1470
|
+
```cssl
|
|
1471
|
+
cpp = libinclude("c++");
|
|
1472
|
+
|
|
1473
|
+
// Access C++ shared instance
|
|
1474
|
+
engine = cpp$MyEngine;
|
|
1475
|
+
printl(engine.power);
|
|
1476
|
+
|
|
1477
|
+
// Cross-language inheritance
|
|
1478
|
+
class TurboEngine : extends cpp$Engine {
|
|
1479
|
+
int turboBoost;
|
|
1480
|
+
|
|
1481
|
+
constr TurboEngine(int boost) {
|
|
1482
|
+
this->turboBoost = boost;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
```
|
|
1486
|
+
|
|
1487
|
+
### Instance Sharing API
|
|
1488
|
+
|
|
1489
|
+
Share instances between languages using the `share()` and `get_instance()` methods:
|
|
1490
|
+
|
|
1491
|
+
```cssl
|
|
1492
|
+
// Get language support
|
|
1493
|
+
cpp = libinclude("c++");
|
|
1494
|
+
|
|
1495
|
+
// Share a CSSL instance with C++
|
|
1496
|
+
class MyClass {
|
|
1497
|
+
string value;
|
|
1498
|
+
}
|
|
1499
|
+
instance = new MyClass();
|
|
1500
|
+
cpp.share("MyClass", instance);
|
|
1501
|
+
|
|
1502
|
+
// Access from C++:
|
|
1503
|
+
// auto* obj = CSSL_GET(MyClass, "MyClass");
|
|
1504
|
+
```
|
|
1505
|
+
|
|
1506
|
+
### Language SDKs
|
|
1507
|
+
|
|
1508
|
+
SDKs are available for sharing instances from other languages into CSSL:
|
|
1509
|
+
|
|
1510
|
+
**C++ SDK:**
|
|
1511
|
+
```cpp
|
|
1512
|
+
#include "includecpp.h"
|
|
1513
|
+
|
|
1514
|
+
class Engine { public: int power = 100; };
|
|
1515
|
+
|
|
1516
|
+
Engine engine;
|
|
1517
|
+
CSSL_SHARE(Engine, &engine);
|
|
1518
|
+
// Now accessible as cpp$Engine in CSSL
|
|
1519
|
+
```
|
|
1520
|
+
|
|
1521
|
+
**Java SDK:**
|
|
1522
|
+
```java
|
|
1523
|
+
import com.includecpp.CSSL;
|
|
1524
|
+
|
|
1525
|
+
MyService svc = new MyService();
|
|
1526
|
+
CSSL.share("MyService", svc);
|
|
1527
|
+
// Now accessible as java$MyService in CSSL
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
**C# SDK:**
|
|
1531
|
+
```csharp
|
|
1532
|
+
using IncludeCPP;
|
|
1533
|
+
|
|
1534
|
+
var service = new MyService();
|
|
1535
|
+
CSSL.Share("MyService", service);
|
|
1536
|
+
// Now accessible as csharp$MyService in CSSL
|
|
1537
|
+
```
|
|
1538
|
+
|
|
1539
|
+
**JavaScript SDK:**
|
|
1540
|
+
```javascript
|
|
1541
|
+
import { CSSL } from 'includecpp-cssl';
|
|
1542
|
+
|
|
1543
|
+
class DataProcessor { process(data) { } }
|
|
1544
|
+
CSSL.share('DataProcessor', new DataProcessor());
|
|
1545
|
+
// Now accessible as js$DataProcessor in CSSL
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
### SDK API Reference
|
|
1549
|
+
|
|
1550
|
+
All language SDKs provide these methods:
|
|
1551
|
+
|
|
1552
|
+
| Method | Description |
|
|
1553
|
+
|--------|-------------|
|
|
1554
|
+
| `share(name, instance)` | Share an instance by name |
|
|
1555
|
+
| `get(name)` | Get a shared instance |
|
|
1556
|
+
| `has(name)` | Check if instance exists |
|
|
1557
|
+
| `remove(name)` | Remove a shared instance |
|
|
1558
|
+
| `list()` | Get all instance names |
|
|
1559
|
+
| `clear()` | Clear all instances |
|
|
1560
|
+
|
|
1561
|
+
---
|
|
1562
|
+
|
|
1401
1563
|
## Error Handling
|
|
1402
1564
|
|
|
1403
1565
|
### Try / Catch
|
|
@@ -1495,7 +1657,26 @@ assert(x > 0, "x must be positive");
|
|
|
1495
1657
|
| `global define func()` | Global function declaration |
|
|
1496
1658
|
| `define @func()` | Global function (alt syntax) |
|
|
1497
1659
|
| `new @ClassName()` | Instantiate global class |
|
|
1660
|
+
| `libinclude("lang")` | Load language support module |
|
|
1661
|
+
| `supports @lang` | Use other language syntax |
|
|
1662
|
+
| `lang$InstanceName` | Cross-language instance access |
|
|
1663
|
+
|
|
1664
|
+
### Multi-Language Keywords
|
|
1665
|
+
|
|
1666
|
+
| Keyword | Description |
|
|
1667
|
+
|---------|-------------|
|
|
1668
|
+
| `libinclude` | Load language support module |
|
|
1669
|
+
| `supports` | Use another language's syntax in function/class |
|
|
1670
|
+
|
|
1671
|
+
### Cross-Language Syntax
|
|
1672
|
+
|
|
1673
|
+
| Syntax | Description | Example |
|
|
1674
|
+
|--------|-------------|---------|
|
|
1675
|
+
| `libinclude("lang")` | Load language support | `cpp = libinclude("c++")` |
|
|
1676
|
+
| `: supports @lang` | Use language syntax | `define func() : supports @py { }` |
|
|
1677
|
+
| `lang$Name` | Access shared instance | `cpp$Engine`, `java$Service` |
|
|
1678
|
+
| `extends lang$Name` | Inherit from shared class | `class Child : extends cpp$Parent { }` |
|
|
1498
1679
|
|
|
1499
1680
|
---
|
|
1500
1681
|
|
|
1501
|
-
*CSSL v4.
|
|
1682
|
+
*CSSL v4.1.0 - Developed as part of IncludeCPP*
|
|
@@ -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)
|
|
@@ -1937,6 +1960,45 @@ class CSSLBuiltins:
|
|
|
1937
1960
|
except Exception as e:
|
|
1938
1961
|
raise CSSLBuiltinError(f"Failed to include '{filepath}': {e}")
|
|
1939
1962
|
|
|
1963
|
+
def builtin_libinclude(self, lang_id: str) -> Any:
|
|
1964
|
+
"""
|
|
1965
|
+
Load a language support module for multi-language syntax support.
|
|
1966
|
+
|
|
1967
|
+
v4.1.0: Multi-language support for CSSL.
|
|
1968
|
+
|
|
1969
|
+
Usage:
|
|
1970
|
+
@py = libinclude("python")
|
|
1971
|
+
cpp = libinclude("c++")
|
|
1972
|
+
java = libinclude("java")
|
|
1973
|
+
js = libinclude("javascript")
|
|
1974
|
+
csharp = libinclude("c#")
|
|
1975
|
+
|
|
1976
|
+
Returns: LanguageSupport object that can be used with 'supports' keyword.
|
|
1977
|
+
|
|
1978
|
+
Example:
|
|
1979
|
+
@py = libinclude("python");
|
|
1980
|
+
|
|
1981
|
+
define my_func() : supports @py {
|
|
1982
|
+
# Python syntax here!
|
|
1983
|
+
for i in range(10):
|
|
1984
|
+
print(i)
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
class MyClass : extends cpp$BaseClass {
|
|
1988
|
+
// Inherit from C++ class
|
|
1989
|
+
}
|
|
1990
|
+
"""
|
|
1991
|
+
from .cssl_languages import get_language
|
|
1992
|
+
|
|
1993
|
+
lang_support = get_language(lang_id)
|
|
1994
|
+
if lang_support is None:
|
|
1995
|
+
supported = ["python", "py", "java", "c#", "csharp", "c++", "cpp", "javascript", "js"]
|
|
1996
|
+
raise CSSLBuiltinError(
|
|
1997
|
+
f"Unknown language '{lang_id}'. Supported languages: {', '.join(supported)}"
|
|
1998
|
+
)
|
|
1999
|
+
|
|
2000
|
+
return lang_support
|
|
2001
|
+
|
|
1940
2002
|
def _load_cssl_module(self, filepath: str, source: str) -> Any:
|
|
1941
2003
|
"""
|
|
1942
2004
|
Load a .cssl-mod module file and return a callable module object.
|
|
@@ -2688,8 +2750,8 @@ class PythonizedCSSLInstance:
|
|
|
2688
2750
|
return value
|
|
2689
2751
|
|
|
2690
2752
|
# Check for method
|
|
2691
|
-
|
|
2692
|
-
|
|
2753
|
+
if instance.has_method(name):
|
|
2754
|
+
method = instance.get_method(name)
|
|
2693
2755
|
# Return a callable wrapper for the method
|
|
2694
2756
|
return PythonizedMethod(instance, name, method, runtime)
|
|
2695
2757
|
|
|
@@ -2744,6 +2806,29 @@ class PythonizedMethod:
|
|
|
2744
2806
|
if self._runtime is None:
|
|
2745
2807
|
raise RuntimeError(f"Cannot call method '{self._method_name}' - no runtime available")
|
|
2746
2808
|
|
|
2809
|
+
# Validate argument count
|
|
2810
|
+
# Method AST structure: node.value is a dict with 'params' key
|
|
2811
|
+
method_info = getattr(self._method_ast, 'value', {}) or {}
|
|
2812
|
+
method_params = method_info.get('params', []) if isinstance(method_info, dict) else []
|
|
2813
|
+
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]
|
|
2814
|
+
expected_count = len(param_names)
|
|
2815
|
+
actual_count = len(args)
|
|
2816
|
+
|
|
2817
|
+
if actual_count < expected_count:
|
|
2818
|
+
missing = param_names[actual_count:]
|
|
2819
|
+
class_name = self._instance._class.name
|
|
2820
|
+
raise TypeError(
|
|
2821
|
+
f"{class_name}.{self._method_name}() missing {len(missing)} required argument(s): {', '.join(repr(p) for p in missing)}\n"
|
|
2822
|
+
f" Expected: {self._method_name}({', '.join(param_names)})\n"
|
|
2823
|
+
f" Got: {self._method_name}({', '.join(repr(a) for a in args)})"
|
|
2824
|
+
)
|
|
2825
|
+
elif actual_count > expected_count:
|
|
2826
|
+
class_name = self._instance._class.name
|
|
2827
|
+
raise TypeError(
|
|
2828
|
+
f"{class_name}.{self._method_name}() takes {expected_count} argument(s) but {actual_count} were given\n"
|
|
2829
|
+
f" Expected: {self._method_name}({', '.join(param_names)})"
|
|
2830
|
+
)
|
|
2831
|
+
|
|
2747
2832
|
# Execute the method through the runtime
|
|
2748
2833
|
# Pass the method AST node, not the method name
|
|
2749
2834
|
result = self._runtime._call_method(self._instance, self._method_ast, list(args), kwargs)
|