IncludeCPP 3.5.9__tar.gz → 3.6.1__tar.gz
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-3.5.9 → includecpp-3.6.1}/IncludeCPP.egg-info/PKG-INFO +1 -1
- {includecpp-3.5.9 → includecpp-3.6.1}/PKG-INFO +1 -1
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/__init__.py +1 -1
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/CSSL_DOCUMENTATION.md +427 -20
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_builtins.py +259 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_parser.py +86 -52
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_runtime.py +75 -6
- {includecpp-3.5.9 → includecpp-3.6.1}/pyproject.toml +1 -1
- {includecpp-3.5.9 → includecpp-3.6.1}/IncludeCPP.egg-info/SOURCES.txt +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/IncludeCPP.egg-info/dependency_links.txt +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/IncludeCPP.egg-info/entry_points.txt +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/IncludeCPP.egg-info/requires.txt +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/IncludeCPP.egg-info/top_level.txt +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/LICENSE +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/MANIFEST.in +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/README.md +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/__init__.pyi +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/__main__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/cli/__init__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/cli/commands.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/cli/config_parser.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/__init__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/ai_integration.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/build_manager.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cpp_api.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cpp_api.pyi +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cppy_converter.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/__init__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_events.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_modules.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_syntax.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl/cssl_types.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl_bridge.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/cssl_bridge.pyi +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/error_catalog.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/error_formatter.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/exceptions.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/path_discovery.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/project_ui.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/core/settings_ui.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/generator/__init__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/generator/parser.cpp +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/generator/parser.h +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/generator/type_resolver.cpp +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/generator/type_resolver.h +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/py.typed +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/templates/cpp.proj.template +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/vscode/__init__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/vscode/cssl/__init__.py +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/vscode/cssl/language-configuration.json +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/vscode/cssl/package.json +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/requirements.txt +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/setup.cfg +0 -0
- {includecpp-3.5.9 → includecpp-3.6.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CSSL - C-Style Scripting Language
|
|
2
2
|
|
|
3
|
-
> Version 3.
|
|
3
|
+
> Version 3.6.1 | A modern scripting language with C++-style syntax and unique features like CodeInfusion and BruteInjection.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -15,16 +15,20 @@
|
|
|
15
15
|
7. [Functions](#functions)
|
|
16
16
|
8. [Function Keywords](#function-keywords)
|
|
17
17
|
9. [String Methods](#string-methods)
|
|
18
|
-
10. [
|
|
19
|
-
11. [
|
|
20
|
-
12. [
|
|
21
|
-
13. [
|
|
22
|
-
14. [
|
|
23
|
-
15. [
|
|
24
|
-
16. [
|
|
25
|
-
17. [
|
|
26
|
-
18. [
|
|
27
|
-
19. [
|
|
18
|
+
10. [File I/O](#file-io)
|
|
19
|
+
11. [JSON Functions](#json-functions)
|
|
20
|
+
12. [Instance Management](#instance-management)
|
|
21
|
+
13. [Live Object Sharing](#live-object-sharing)
|
|
22
|
+
14. [CodeInfusion](#codeinfusion)
|
|
23
|
+
15. [Value Capture](#value-capture)
|
|
24
|
+
16. [BruteInjection](#bruteinjection)
|
|
25
|
+
17. [Filter Syntax](#filter-syntax)
|
|
26
|
+
18. [Module System](#module-system)
|
|
27
|
+
19. [Parameter Bridge](#parameter-bridge)
|
|
28
|
+
20. [Structures](#structures)
|
|
29
|
+
21. [Error Handling](#error-handling)
|
|
30
|
+
22. [CLI Commands](#cli-commands)
|
|
31
|
+
23. [Examples](#examples)
|
|
28
32
|
|
|
29
33
|
---
|
|
30
34
|
|
|
@@ -336,14 +340,26 @@ int number = 42;
|
|
|
336
340
|
// Declaration with 'global'
|
|
337
341
|
global myGlobal = "visible everywhere";
|
|
338
342
|
|
|
339
|
-
// Access with '@'
|
|
343
|
+
// Access with '@' prefix
|
|
340
344
|
printl(@myGlobal);
|
|
341
345
|
|
|
342
|
-
//
|
|
346
|
+
// Or access directly without '@' (since v3.5.9)
|
|
347
|
+
printl(myGlobal); // Works the same!
|
|
348
|
+
|
|
349
|
+
// Alternative: r@ syntax for declaration
|
|
343
350
|
r@anotherGlobal = "also global";
|
|
344
351
|
printl(@anotherGlobal);
|
|
352
|
+
printl(anotherGlobal); // Also works
|
|
345
353
|
```
|
|
346
354
|
|
|
355
|
+
### Lookup Order
|
|
356
|
+
|
|
357
|
+
When accessing a variable, CSSL checks in order:
|
|
358
|
+
1. Local scope
|
|
359
|
+
2. Global scope
|
|
360
|
+
3. Promoted globals
|
|
361
|
+
4. Built-in functions
|
|
362
|
+
|
|
347
363
|
### Usage in Functions
|
|
348
364
|
|
|
349
365
|
```cssl
|
|
@@ -539,6 +555,29 @@ string n = getName();
|
|
|
539
555
|
int sum = add(5, 3);
|
|
540
556
|
```
|
|
541
557
|
|
|
558
|
+
### Named Parameters
|
|
559
|
+
|
|
560
|
+
Functions can be called with named parameters for clarity.
|
|
561
|
+
|
|
562
|
+
```cssl
|
|
563
|
+
// Define function
|
|
564
|
+
int calculate(int base, int multiplier, int offset) {
|
|
565
|
+
return base * multiplier + offset;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Call with positional arguments
|
|
569
|
+
int r1 = calculate(10, 5, 3); // 53
|
|
570
|
+
|
|
571
|
+
// Call with named parameters
|
|
572
|
+
int r2 = calculate(base=10, multiplier=5, offset=3); // 53
|
|
573
|
+
|
|
574
|
+
// Mix positional and named (positional must come first)
|
|
575
|
+
int r3 = calculate(10, multiplier=5, offset=3); // 53
|
|
576
|
+
|
|
577
|
+
// Named parameters can be in any order
|
|
578
|
+
int r4 = calculate(offset=3, base=10, multiplier=5); // 53
|
|
579
|
+
```
|
|
580
|
+
|
|
542
581
|
### Nested Functions
|
|
543
582
|
|
|
544
583
|
```cssl
|
|
@@ -798,6 +837,245 @@ string padded2 = num.padEnd(5, "."); // "42..."
|
|
|
798
837
|
|
|
799
838
|
---
|
|
800
839
|
|
|
840
|
+
## File I/O
|
|
841
|
+
|
|
842
|
+
CSSL provides built-in functions for file operations.
|
|
843
|
+
|
|
844
|
+
### Basic File Operations
|
|
845
|
+
|
|
846
|
+
```cssl
|
|
847
|
+
// Read entire file
|
|
848
|
+
string content = read("/path/to/file.txt");
|
|
849
|
+
printl(content);
|
|
850
|
+
|
|
851
|
+
// Read specific line (1-indexed)
|
|
852
|
+
string line5 = readline(5, "/path/to/file.txt");
|
|
853
|
+
printl(line5);
|
|
854
|
+
|
|
855
|
+
// Write to file (overwrites)
|
|
856
|
+
write("/path/to/file.txt", "Hello World");
|
|
857
|
+
|
|
858
|
+
// Write/replace specific line
|
|
859
|
+
writeline(3, "New line content", "/path/to/file.txt");
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
### Extended File Functions
|
|
863
|
+
|
|
864
|
+
```cssl
|
|
865
|
+
// Read all lines as array
|
|
866
|
+
stack<string> lines = readlines("/path/to/file.txt");
|
|
867
|
+
|
|
868
|
+
// Append to file
|
|
869
|
+
appendfile("/path/to/file.txt", "\nNew content");
|
|
870
|
+
|
|
871
|
+
// File checks
|
|
872
|
+
bool exists = pathexists("/path/to/file.txt");
|
|
873
|
+
bool isFile = isfile("/path/to/file.txt");
|
|
874
|
+
bool isDir = isdir("/path/to/folder");
|
|
875
|
+
|
|
876
|
+
// File size
|
|
877
|
+
int size = filesize("/path/to/file.txt");
|
|
878
|
+
|
|
879
|
+
// Directory listing
|
|
880
|
+
stack<string> files = listdir("/path/to/folder");
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### Path Functions
|
|
884
|
+
|
|
885
|
+
```cssl
|
|
886
|
+
// Path manipulation
|
|
887
|
+
string base = basename("/path/to/file.txt"); // "file.txt"
|
|
888
|
+
string dir = dirname("/path/to/file.txt"); // "/path/to"
|
|
889
|
+
string full = joinpath("/path", "to", "file.txt"); // "/path/to/file.txt"
|
|
890
|
+
string abs = abspath("./file.txt"); // "/current/dir/file.txt"
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
### All File I/O Functions
|
|
894
|
+
|
|
895
|
+
| Function | Description |
|
|
896
|
+
|----------|-------------|
|
|
897
|
+
| `read(path)` | Read entire file content |
|
|
898
|
+
| `readline(line, path)` | Read specific line (1-indexed) |
|
|
899
|
+
| `write(path, content)` | Write content to file |
|
|
900
|
+
| `writeline(line, content, path)` | Write/replace specific line |
|
|
901
|
+
| `readfile(path)` | Read file (alias for read) |
|
|
902
|
+
| `writefile(path, content)` | Write file (alias for write) |
|
|
903
|
+
| `readlines(path)` | Read all lines as array |
|
|
904
|
+
| `appendfile(path, content)` | Append to file |
|
|
905
|
+
| `pathexists(path)` | Check if path exists |
|
|
906
|
+
| `isfile(path)` | Check if is file |
|
|
907
|
+
| `isdir(path)` | Check if is directory |
|
|
908
|
+
| `filesize(path)` | Get file size in bytes |
|
|
909
|
+
| `listdir(path)` | List directory contents |
|
|
910
|
+
| `makedirs(path)` | Create directories |
|
|
911
|
+
| `removefile(path)` | Delete file |
|
|
912
|
+
| `removedir(path)` | Delete empty directory |
|
|
913
|
+
| `copyfile(src, dst)` | Copy file |
|
|
914
|
+
| `movefile(src, dst)` | Move file |
|
|
915
|
+
|
|
916
|
+
---
|
|
917
|
+
|
|
918
|
+
## JSON Functions
|
|
919
|
+
|
|
920
|
+
CSSL provides namespace-style JSON functions with the `json::` prefix.
|
|
921
|
+
|
|
922
|
+
### Reading & Writing JSON Files
|
|
923
|
+
|
|
924
|
+
```cssl
|
|
925
|
+
// Read and parse JSON file
|
|
926
|
+
json data = json::read("/path/to/config.json");
|
|
927
|
+
printl(data.name);
|
|
928
|
+
|
|
929
|
+
// Write data to JSON file
|
|
930
|
+
json::write("/path/to/output.json", data);
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
### JSON Parsing & Stringifying
|
|
934
|
+
|
|
935
|
+
```cssl
|
|
936
|
+
// Parse JSON string
|
|
937
|
+
string jsonStr = '{"name": "Alice", "age": 30}';
|
|
938
|
+
json obj = json::parse(jsonStr);
|
|
939
|
+
|
|
940
|
+
// Convert to JSON string
|
|
941
|
+
string str = json::stringify(obj);
|
|
942
|
+
|
|
943
|
+
// Pretty print with indentation
|
|
944
|
+
string pretty = json::pretty(obj);
|
|
945
|
+
printl(pretty);
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
### JSON Path Operations
|
|
949
|
+
|
|
950
|
+
```cssl
|
|
951
|
+
json data = json::read("config.json");
|
|
952
|
+
|
|
953
|
+
// Get value by dot-path
|
|
954
|
+
string name = json::get(data, "user.name");
|
|
955
|
+
int age = json::get(data, "user.profile.age");
|
|
956
|
+
string city = json::get(data, "address.city", "Unknown"); // with default
|
|
957
|
+
|
|
958
|
+
// Set value by dot-path
|
|
959
|
+
data = json::set(data, "user.name", "Bob");
|
|
960
|
+
data = json::set(data, "settings.theme", "dark");
|
|
961
|
+
|
|
962
|
+
// Check if path exists
|
|
963
|
+
if (json::has(data, "user.email")) {
|
|
964
|
+
printl("Email exists");
|
|
965
|
+
}
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
### JSON Object Operations
|
|
969
|
+
|
|
970
|
+
```cssl
|
|
971
|
+
json obj = json::read("data.json");
|
|
972
|
+
|
|
973
|
+
// Get all keys
|
|
974
|
+
stack<string> keys = json::keys(obj);
|
|
975
|
+
foreach (key in keys) {
|
|
976
|
+
printl(key);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// Get all values
|
|
980
|
+
stack<dynamic> values = json::values(obj);
|
|
981
|
+
|
|
982
|
+
// Deep merge objects
|
|
983
|
+
json merged = json::merge(obj1, obj2, obj3);
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
### All JSON Functions
|
|
987
|
+
|
|
988
|
+
| Function | Description |
|
|
989
|
+
|----------|-------------|
|
|
990
|
+
| `json::read(path)` | Read and parse JSON file |
|
|
991
|
+
| `json::write(path, data)` | Write data to JSON file |
|
|
992
|
+
| `json::parse(str)` | Parse JSON string to object |
|
|
993
|
+
| `json::stringify(data)` | Convert to JSON string |
|
|
994
|
+
| `json::pretty(data)` | Pretty print JSON |
|
|
995
|
+
| `json::get(data, path, default)` | Get value by dot-path |
|
|
996
|
+
| `json::set(data, path, value)` | Set value by dot-path |
|
|
997
|
+
| `json::has(data, path)` | Check if path exists |
|
|
998
|
+
| `json::keys(data)` | Get all keys |
|
|
999
|
+
| `json::values(data)` | Get all values |
|
|
1000
|
+
| `json::merge(obj1, obj2, ...)` | Deep merge objects |
|
|
1001
|
+
|
|
1002
|
+
---
|
|
1003
|
+
|
|
1004
|
+
## Instance Management
|
|
1005
|
+
|
|
1006
|
+
CSSL provides `instance<"name">` syntax and `instance::` namespace for working with shared instances.
|
|
1007
|
+
|
|
1008
|
+
### Instance Declaration
|
|
1009
|
+
|
|
1010
|
+
```cssl
|
|
1011
|
+
// Get/create shared instance by name
|
|
1012
|
+
instance<"MyApp"> app;
|
|
1013
|
+
|
|
1014
|
+
// With initialization
|
|
1015
|
+
instance<"tk"> tk = include("tkinter.cssl-mod");
|
|
1016
|
+
|
|
1017
|
+
// Register object as shared instance
|
|
1018
|
+
myModule ==> $AppModule
|
|
1019
|
+
// Or using instance syntax:
|
|
1020
|
+
myModule ==> instance<"AppModule">
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
### Instance Introspection
|
|
1024
|
+
|
|
1025
|
+
```cssl
|
|
1026
|
+
@tk = include("tk.cssl-mod");
|
|
1027
|
+
|
|
1028
|
+
// Get all methods from module
|
|
1029
|
+
stack<string> methods = instance::getMethods(@tk);
|
|
1030
|
+
foreach (m in methods) {
|
|
1031
|
+
printl("Method: " + m);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// Get all classes
|
|
1035
|
+
stack<string> classes = instance::getClasses(@tk);
|
|
1036
|
+
|
|
1037
|
+
// Get all variables
|
|
1038
|
+
stack<string> vars = instance::getVars(@tk);
|
|
1039
|
+
|
|
1040
|
+
// Get everything categorized
|
|
1041
|
+
json all = instance::getAll(@tk);
|
|
1042
|
+
printl(all.methods); // ["method1", "method2", ...]
|
|
1043
|
+
printl(all.classes); // ["Class1", "Class2", ...]
|
|
1044
|
+
printl(all.vars); // ["var1", "var2", ...]
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
### Dynamic Method Calls
|
|
1048
|
+
|
|
1049
|
+
```cssl
|
|
1050
|
+
// Call method dynamically by name
|
|
1051
|
+
result = instance::call(@module, "methodName", arg1, arg2);
|
|
1052
|
+
|
|
1053
|
+
// Check if method/attribute exists
|
|
1054
|
+
if (instance::has(@module, "initialize")) {
|
|
1055
|
+
instance::call(@module, "initialize");
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// Get type name
|
|
1059
|
+
string typeName = instance::type(@module);
|
|
1060
|
+
printl(typeName); // "module"
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
### All Instance Functions
|
|
1064
|
+
|
|
1065
|
+
| Function | Description |
|
|
1066
|
+
|----------|-------------|
|
|
1067
|
+
| `instance<"name"> var` | Declare instance variable |
|
|
1068
|
+
| `obj ==> instance<"name">` | Register as shared instance |
|
|
1069
|
+
| `instance::getMethods(obj)` | Get all method names |
|
|
1070
|
+
| `instance::getClasses(obj)` | Get all class names |
|
|
1071
|
+
| `instance::getVars(obj)` | Get all variable names |
|
|
1072
|
+
| `instance::getAll(obj)` | Get categorized dict |
|
|
1073
|
+
| `instance::call(obj, 'name', ...)` | Call method dynamically |
|
|
1074
|
+
| `instance::has(obj, 'name')` | Check if attribute exists |
|
|
1075
|
+
| `instance::type(obj)` | Get type name |
|
|
1076
|
+
|
|
1077
|
+
---
|
|
1078
|
+
|
|
801
1079
|
## Live Object Sharing
|
|
802
1080
|
|
|
803
1081
|
Share Python objects with CSSL. Changes in CSSL reflect back to Python.
|
|
@@ -934,6 +1212,74 @@ exit(); // Executes injection
|
|
|
934
1212
|
|
|
935
1213
|
---
|
|
936
1214
|
|
|
1215
|
+
## Value Capture
|
|
1216
|
+
|
|
1217
|
+
The `%identifier` syntax captures values at registration time, useful for saving original functions before replacement.
|
|
1218
|
+
|
|
1219
|
+
### Capturing Variables
|
|
1220
|
+
|
|
1221
|
+
```cssl
|
|
1222
|
+
string version = "1.0.0";
|
|
1223
|
+
|
|
1224
|
+
// Capture current value
|
|
1225
|
+
v <== { %version; }
|
|
1226
|
+
printl(v); // "1.0.0"
|
|
1227
|
+
|
|
1228
|
+
// Even if version changes later, v keeps captured value
|
|
1229
|
+
version = "2.0.0";
|
|
1230
|
+
printl(v); // Still "1.0.0"
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
### Capturing Functions
|
|
1234
|
+
|
|
1235
|
+
```cssl
|
|
1236
|
+
// Save original exit function before replacing
|
|
1237
|
+
originalExit <<== { %exit(); }
|
|
1238
|
+
|
|
1239
|
+
// Replace exit with custom behavior
|
|
1240
|
+
exit() <<== {
|
|
1241
|
+
printl("Custom cleanup...");
|
|
1242
|
+
originalExit(); // Call saved original
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
exit();
|
|
1246
|
+
// Output:
|
|
1247
|
+
// Custom cleanup...
|
|
1248
|
+
// (original exit behavior)
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
### Use Cases
|
|
1252
|
+
|
|
1253
|
+
```cssl
|
|
1254
|
+
// 1. Preserving original behavior
|
|
1255
|
+
void myFunc() {
|
|
1256
|
+
printl("Original");
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
savedFunc <<== { %myFunc(); }
|
|
1260
|
+
|
|
1261
|
+
myFunc() <<== {
|
|
1262
|
+
printl("Modified");
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
myFunc(); // "Modified"
|
|
1266
|
+
savedFunc(); // "Original"
|
|
1267
|
+
|
|
1268
|
+
// 2. Capturing configuration at startup
|
|
1269
|
+
global config = loadConfig();
|
|
1270
|
+
startupConfig <== { %config; }
|
|
1271
|
+
|
|
1272
|
+
// 3. Snapshot values for later comparison
|
|
1273
|
+
int counter = 0;
|
|
1274
|
+
initial <== { %counter; }
|
|
1275
|
+
// ... operations ...
|
|
1276
|
+
if (counter != initial) {
|
|
1277
|
+
printl("Counter changed!");
|
|
1278
|
+
}
|
|
1279
|
+
```
|
|
1280
|
+
|
|
1281
|
+
---
|
|
1282
|
+
|
|
937
1283
|
## BruteInjection
|
|
938
1284
|
|
|
939
1285
|
BruteInjection copies/moves data between containers.
|
|
@@ -981,6 +1327,26 @@ container ==> data;
|
|
|
981
1327
|
|
|
982
1328
|
---
|
|
983
1329
|
|
|
1330
|
+
### ==>- (Receive Minus)
|
|
1331
|
+
|
|
1332
|
+
Removes matching items from target.
|
|
1333
|
+
|
|
1334
|
+
```cssl
|
|
1335
|
+
stack<string> names;
|
|
1336
|
+
names.push("Alice");
|
|
1337
|
+
names.push("Bob");
|
|
1338
|
+
names.push("Alice");
|
|
1339
|
+
|
|
1340
|
+
stack<string> toRemove;
|
|
1341
|
+
toRemove.push("Alice");
|
|
1342
|
+
|
|
1343
|
+
// Remove all "Alice" from names
|
|
1344
|
+
names ==>- toRemove;
|
|
1345
|
+
printl(names); // ["Bob"]
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
---
|
|
1349
|
+
|
|
984
1350
|
## Filter Syntax
|
|
985
1351
|
|
|
986
1352
|
Filters enable targeted data operations in BruteInjection.
|
|
@@ -1014,6 +1380,30 @@ result +<== [string::contains="App"] fruits; // Apple, Apricot
|
|
|
1014
1380
|
result +<== [string::length=5] fruits; // Apple
|
|
1015
1381
|
```
|
|
1016
1382
|
|
|
1383
|
+
### String Cutting Filters
|
|
1384
|
+
|
|
1385
|
+
Cut strings at specific positions or substrings.
|
|
1386
|
+
|
|
1387
|
+
```cssl
|
|
1388
|
+
string version = "1.0.0-beta";
|
|
1389
|
+
|
|
1390
|
+
// Cut at position (integer index)
|
|
1391
|
+
x = <==[string::cut=3] version;
|
|
1392
|
+
printl(x); // "1.0" (first 3 chars)
|
|
1393
|
+
|
|
1394
|
+
// Cut at substring position
|
|
1395
|
+
x = <==[string::cut="0-"] version;
|
|
1396
|
+
printl(x); // "1.0." (before "0-")
|
|
1397
|
+
|
|
1398
|
+
// Get everything after substring
|
|
1399
|
+
x = <==[string::cutAfter=".0."] version;
|
|
1400
|
+
printl(x); // "0-beta" (after ".0.")
|
|
1401
|
+
|
|
1402
|
+
// Cut after at position
|
|
1403
|
+
x = <==[string::cutAfter=4] version;
|
|
1404
|
+
printl(x); // ".0-beta" (after index 4)
|
|
1405
|
+
```
|
|
1406
|
+
|
|
1017
1407
|
### All Filters
|
|
1018
1408
|
|
|
1019
1409
|
| Filter | Description |
|
|
@@ -1022,6 +1412,10 @@ result +<== [string::length=5] fruits; // Apple
|
|
|
1022
1412
|
| `string::not=VALUE` | Everything except this value |
|
|
1023
1413
|
| `string::contains=VALUE` | Contains substring |
|
|
1024
1414
|
| `string::length=LENGTH` | Exact string length |
|
|
1415
|
+
| `string::cut=INDEX` | Cut at index (returns first N chars) |
|
|
1416
|
+
| `string::cut="SUBSTR"` | Cut at substring position |
|
|
1417
|
+
| `string::cutAfter=INDEX` | Get everything after index |
|
|
1418
|
+
| `string::cutAfter="SUBSTR"` | Get everything after substring |
|
|
1025
1419
|
| `integer::where=VALUE` | Exact int match |
|
|
1026
1420
|
| `json::key=KEYNAME` | Filter by JSON key |
|
|
1027
1421
|
| `json::value=VALUE` | Filter by JSON value |
|
|
@@ -1457,12 +1851,25 @@ print(result) # ["Missing colon after def"]
|
|
|
1457
1851
|
|
|
1458
1852
|
| Operator | Type | Description |
|
|
1459
1853
|
|----------|------|-------------|
|
|
1460
|
-
| `<<==` | CodeInfusion | Replace |
|
|
1461
|
-
| `+<<==` | CodeInfusion | Add |
|
|
1462
|
-
| `-<<==` | CodeInfusion | Remove |
|
|
1463
|
-
|
|
|
1464
|
-
|
|
|
1465
|
-
|
|
|
1854
|
+
| `<<==` | CodeInfusion | Replace function |
|
|
1855
|
+
| `+<<==` | CodeInfusion | Add code (before) |
|
|
1856
|
+
| `-<<==` | CodeInfusion | Remove code |
|
|
1857
|
+
| `<==` | ValueCapture | Capture/assign value |
|
|
1858
|
+
| `+<==` | BruteInjection | Copy data |
|
|
1859
|
+
| `-<==` | BruteInjection | Move data |
|
|
1860
|
+
| `==>` | BruteInjection | Replace data |
|
|
1861
|
+
| `==>-` | BruteInjection | Remove matching items |
|
|
1862
|
+
|
|
1863
|
+
### Special Syntax
|
|
1864
|
+
|
|
1865
|
+
| Syntax | Description |
|
|
1866
|
+
|--------|-------------|
|
|
1867
|
+
| `%identifier` | Capture value at registration time |
|
|
1868
|
+
| `json::func()` | Namespace function call |
|
|
1869
|
+
| `@name` | Access global variable |
|
|
1870
|
+
| `$name` | Access shared Python object |
|
|
1871
|
+
| `s@name` | Self-reference to struct |
|
|
1872
|
+
| `r@name` | Global variable declaration |
|
|
1466
1873
|
|
|
1467
1874
|
---
|
|
1468
1875
|
|
|
@@ -1479,4 +1886,4 @@ print(result) # ["Missing colon after def"]
|
|
|
1479
1886
|
|
|
1480
1887
|
---
|
|
1481
1888
|
|
|
1482
|
-
*CSSL v3.
|
|
1889
|
+
*CSSL v3.6.1 - Developed as part of IncludeCPP*
|