IncludeCPP 4.2.2__py3-none-any.whl → 4.5.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 +104 -115
- includecpp/DOCUMENTATION.md +208 -355
- includecpp/__init__.py +1 -1
- includecpp/__init__.pyi +1 -4
- includecpp/cli/commands.py +1220 -27
- includecpp/core/cpp_api_extensions.pyi +204 -200
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +1505 -1467
- includecpp/core/cssl/__init__.py +317 -0
- includecpp/core/cssl/cpp/build/api.pyd +0 -0
- includecpp/core/cssl/cpp/build/cssl_core.pyi +323 -0
- includecpp/core/cssl/cpp/build/libgcc_s_seh-1.dll +0 -0
- includecpp/core/cssl/cpp/build/libstdc++-6.dll +0 -0
- includecpp/core/cssl/cpp/build/libwinpthread-1.dll +0 -0
- includecpp/core/cssl/cpp/cssl_core.cp +108 -0
- includecpp/core/cssl/cpp/cssl_lexer.hpp +280 -0
- includecpp/core/cssl/cssl_builtins.py +245 -20
- includecpp/core/cssl/cssl_compiler.py +448 -0
- includecpp/core/cssl/cssl_optimizer.py +833 -0
- includecpp/core/cssl/cssl_parser.py +945 -40
- includecpp/core/cssl/cssl_runtime.py +751 -38
- includecpp/core/cssl/cssl_syntax.py +17 -0
- includecpp/core/cssl/cssl_types.py +321 -0
- includecpp/core/cssl_bridge.py +36 -2
- includecpp/generator/parser.cpp +38 -14
- includecpp/vscode/cssl/package.json +15 -0
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +134 -2
- includecpp-4.5.2.dist-info/METADATA +277 -0
- {includecpp-4.2.2.dist-info → includecpp-4.5.2.dist-info}/RECORD +32 -23
- includecpp-4.2.2.dist-info/METADATA +0 -1008
- {includecpp-4.2.2.dist-info → includecpp-4.5.2.dist-info}/WHEEL +0 -0
- {includecpp-4.2.2.dist-info → includecpp-4.5.2.dist-info}/entry_points.txt +0 -0
- {includecpp-4.2.2.dist-info → includecpp-4.5.2.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.2.2.dist-info → includecpp-4.5.2.dist-info}/top_level.txt +0 -0
includecpp/DOCUMENTATION.md
CHANGED
|
@@ -1,132 +1,128 @@
|
|
|
1
1
|
# IncludeCPP Documentation
|
|
2
2
|
|
|
3
|
-
Version 4.
|
|
3
|
+
Version 4.3.0
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## What is IncludeCPP?
|
|
8
8
|
|
|
9
|
-
IncludeCPP lets you write C++ code and use it directly in Python.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
pip install IncludeCPP
|
|
13
|
-
```
|
|
9
|
+
IncludeCPP lets you write C++ code and use it directly in Python. You write your C++ functions and classes, run a few commands, and then import them in Python like any other module.
|
|
14
10
|
|
|
15
11
|
---
|
|
16
12
|
|
|
17
|
-
##
|
|
13
|
+
## Getting Started
|
|
18
14
|
|
|
19
|
-
###
|
|
15
|
+
### Installation
|
|
20
16
|
|
|
21
17
|
```bash
|
|
22
|
-
|
|
18
|
+
pip install IncludeCPP
|
|
23
19
|
```
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
- `cpp.proj` - project configuration
|
|
27
|
-
- `include/` - C++ source files
|
|
28
|
-
- `plugins/` - generated binding definitions
|
|
21
|
+
### Create Your First Project
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
cpp.proj # Configuration
|
|
35
|
-
include/ # Your C++ code
|
|
36
|
-
math.cpp
|
|
37
|
-
utils.cpp
|
|
38
|
-
plugins/ # Auto-generated binding files
|
|
39
|
-
math.cp
|
|
40
|
-
utils.cp
|
|
23
|
+
```bash
|
|
24
|
+
mkdir myproject
|
|
25
|
+
cd myproject
|
|
26
|
+
includecpp init
|
|
41
27
|
```
|
|
42
28
|
|
|
43
|
-
|
|
29
|
+
This creates three things:
|
|
30
|
+
- `cpp.proj` - Project settings
|
|
31
|
+
- `include/` - Your C++ source files go here
|
|
32
|
+
- `plugins/` - Generated binding files
|
|
44
33
|
|
|
45
|
-
|
|
34
|
+
### Write C++ Code
|
|
46
35
|
|
|
47
|
-
|
|
36
|
+
Create a file `include/math.cpp`:
|
|
48
37
|
|
|
49
38
|
```cpp
|
|
50
|
-
// include/math.cpp
|
|
51
|
-
#include <vector>
|
|
52
|
-
|
|
53
39
|
namespace includecpp {
|
|
54
40
|
|
|
55
|
-
|
|
41
|
+
int add(int a, int b) {
|
|
42
|
+
return a + b;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class Counter {
|
|
56
46
|
public:
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
Counter() : value(0) {}
|
|
48
|
+
void increment() { value++; }
|
|
49
|
+
int get() { return value; }
|
|
59
50
|
private:
|
|
60
|
-
int
|
|
51
|
+
int value;
|
|
61
52
|
};
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} // namespace includecpp
|
|
54
|
+
}
|
|
66
55
|
```
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## Generate Bindings
|
|
57
|
+
Important: All your code must be inside `namespace includecpp`. Anything outside is ignored.
|
|
73
58
|
|
|
74
|
-
|
|
59
|
+
### Generate Bindings
|
|
75
60
|
|
|
76
61
|
```bash
|
|
77
62
|
includecpp plugin math include/math.cpp
|
|
78
63
|
```
|
|
79
64
|
|
|
80
|
-
This creates `plugins/math.cp` with
|
|
65
|
+
This creates `plugins/math.cp` with instructions for building the Python module.
|
|
81
66
|
|
|
82
|
-
###
|
|
67
|
+
### Build
|
|
83
68
|
|
|
69
|
+
```bash
|
|
70
|
+
includecpp rebuild
|
|
84
71
|
```
|
|
85
|
-
SOURCE(math.cpp) math
|
|
86
72
|
|
|
87
|
-
|
|
88
|
-
math CLASS(Calculator) {
|
|
89
|
-
CONSTRUCTOR()
|
|
90
|
-
METHOD(add)
|
|
91
|
-
METHOD(multiply)
|
|
92
|
-
}
|
|
73
|
+
### Use in Python
|
|
93
74
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```
|
|
75
|
+
```python
|
|
76
|
+
from includecpp import math
|
|
97
77
|
|
|
98
|
-
|
|
78
|
+
# Use function
|
|
79
|
+
result = math.add(5, 3)
|
|
80
|
+
print(result) # 8
|
|
99
81
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| `METHOD(name)` | Expose a class method |
|
|
107
|
-
| `METHOD_CONST(name, sig)` | Overloaded method |
|
|
108
|
-
| `CONSTRUCTOR(args)` | Expose constructor |
|
|
109
|
-
| `FIELD(name)` | Expose member variable |
|
|
110
|
-
| `DEPENDS(mod1, mod2)` | Module dependencies |
|
|
82
|
+
# Use class
|
|
83
|
+
counter = math.Counter()
|
|
84
|
+
counter.increment()
|
|
85
|
+
counter.increment()
|
|
86
|
+
print(counter.get()) # 2
|
|
87
|
+
```
|
|
111
88
|
|
|
112
89
|
---
|
|
113
90
|
|
|
114
|
-
##
|
|
91
|
+
## Project Structure
|
|
115
92
|
|
|
116
|
-
```bash
|
|
117
|
-
includecpp rebuild
|
|
118
93
|
```
|
|
94
|
+
myproject/
|
|
95
|
+
cpp.proj # Project configuration
|
|
96
|
+
include/ # Your C++ source files
|
|
97
|
+
math.cpp
|
|
98
|
+
utils.cpp
|
|
99
|
+
plugins/ # Generated binding files
|
|
100
|
+
math.cp
|
|
101
|
+
utils.cp
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## CLI Commands
|
|
107
|
+
|
|
108
|
+
### Basic Commands
|
|
119
109
|
|
|
120
|
-
|
|
110
|
+
| Command | Description |
|
|
111
|
+
|---------|-------------|
|
|
112
|
+
| `includecpp init` | Create new project |
|
|
113
|
+
| `includecpp plugin <name> <file>` | Generate bindings from C++ file |
|
|
114
|
+
| `includecpp rebuild` | Build all modules |
|
|
115
|
+
| `includecpp auto <name>` | Regenerate + rebuild in one step |
|
|
116
|
+
| `includecpp get <name>` | Show module API |
|
|
121
117
|
|
|
122
|
-
### Build
|
|
118
|
+
### Build Options
|
|
123
119
|
|
|
124
120
|
```bash
|
|
125
121
|
includecpp rebuild # Standard build
|
|
126
|
-
includecpp rebuild --
|
|
127
|
-
includecpp rebuild --
|
|
122
|
+
includecpp rebuild --fast # Skip unchanged files (~0.4s)
|
|
123
|
+
includecpp rebuild --clean # Full rebuild from scratch
|
|
128
124
|
includecpp rebuild --verbose # Show compiler output
|
|
129
|
-
includecpp rebuild -m
|
|
125
|
+
includecpp rebuild -m mymodule # Build specific module only
|
|
130
126
|
includecpp rebuild -j 8 # Use 8 parallel jobs
|
|
131
127
|
```
|
|
132
128
|
|
|
@@ -134,98 +130,62 @@ includecpp rebuild -j 8 # Use 8 parallel jobs
|
|
|
134
130
|
|
|
135
131
|
| Scenario | Time |
|
|
136
132
|
|----------|------|
|
|
137
|
-
|
|
|
138
|
-
| Source changed | ~5-10s |
|
|
133
|
+
| Nothing changed (--fast) | ~0.4s |
|
|
134
|
+
| Source file changed | ~5-10s |
|
|
139
135
|
| Full rebuild | ~30s |
|
|
140
136
|
|
|
141
137
|
---
|
|
142
138
|
|
|
143
|
-
##
|
|
144
|
-
|
|
145
|
-
### Direct Import
|
|
146
|
-
|
|
147
|
-
```python
|
|
148
|
-
from includecpp import math
|
|
149
|
-
|
|
150
|
-
calc = math.Calculator()
|
|
151
|
-
print(calc.add(2, 3)) # 5
|
|
152
|
-
print(math.square(4)) # 16
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### CppApi
|
|
156
|
-
|
|
157
|
-
```python
|
|
158
|
-
from includecpp import CppApi
|
|
159
|
-
|
|
160
|
-
api = CppApi()
|
|
161
|
-
math = api.include("math")
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## Development Workflow
|
|
139
|
+
## Plugin File Format (.cp)
|
|
167
140
|
|
|
168
|
-
|
|
141
|
+
Plugin files define what gets exposed to Python. They're auto-generated but you can edit them.
|
|
169
142
|
|
|
170
|
-
For active development:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
includecpp auto math
|
|
174
143
|
```
|
|
144
|
+
SOURCE(math.cpp) math
|
|
175
145
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
146
|
+
PUBLIC(
|
|
147
|
+
math CLASS(Counter) {
|
|
148
|
+
CONSTRUCTOR()
|
|
149
|
+
METHOD(increment)
|
|
150
|
+
METHOD(get)
|
|
151
|
+
}
|
|
179
152
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
includecpp auto --all -x tests # All except tests
|
|
153
|
+
math FUNC(add)
|
|
154
|
+
)
|
|
183
155
|
```
|
|
184
156
|
|
|
185
|
-
|
|
157
|
+
### Directives
|
|
186
158
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
|
190
|
-
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
|
|
|
198
|
-
| `--doc "term"` | Search documentation |
|
|
199
|
-
| `--changelog` | Show latest changes |
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Advanced Features
|
|
159
|
+
| Directive | Use |
|
|
160
|
+
|-----------|-----|
|
|
161
|
+
| `SOURCE(file) name` | Link source file to module name |
|
|
162
|
+
| `CLASS(Name)` | Expose a class |
|
|
163
|
+
| `STRUCT(Name)` | Expose a struct |
|
|
164
|
+
| `FUNC(name)` | Expose a function |
|
|
165
|
+
| `METHOD(name)` | Expose a method |
|
|
166
|
+
| `CONSTRUCTOR()` | Expose default constructor |
|
|
167
|
+
| `CONSTRUCTOR(int, string)` | Expose constructor with parameters |
|
|
168
|
+
| `FIELD(name)` | Expose member variable |
|
|
169
|
+
| `DEPENDS(mod1, mod2)` | Module dependencies |
|
|
204
170
|
|
|
205
171
|
### Overloaded Methods
|
|
206
172
|
|
|
173
|
+
When a class has multiple methods with the same name:
|
|
174
|
+
|
|
207
175
|
```
|
|
208
|
-
|
|
176
|
+
CLASS(Shape) {
|
|
209
177
|
METHOD_CONST(intersects, const Circle&)
|
|
210
178
|
METHOD_CONST(intersects, const Rect&)
|
|
211
179
|
}
|
|
212
180
|
```
|
|
213
181
|
|
|
214
|
-
###
|
|
182
|
+
### Templates
|
|
215
183
|
|
|
216
184
|
```
|
|
217
|
-
|
|
185
|
+
TEMPLATE_FUNC(maximum) TYPES(int, float, double)
|
|
218
186
|
```
|
|
219
187
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
### Module Dependencies
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
DEPENDS(math_utils, geometry)
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
Ensures dependent modules build first.
|
|
188
|
+
Creates: `maximum_int`, `maximum_float`, `maximum_double`
|
|
229
189
|
|
|
230
190
|
---
|
|
231
191
|
|
|
@@ -245,21 +205,84 @@ Ensures dependent modules build first.
|
|
|
245
205
|
}
|
|
246
206
|
```
|
|
247
207
|
|
|
248
|
-
### Options
|
|
249
|
-
|
|
250
208
|
| Option | Description |
|
|
251
209
|
|--------|-------------|
|
|
252
210
|
| `project` | Project name |
|
|
253
211
|
| `include` | C++ source directory |
|
|
254
212
|
| `plugins` | Plugin file directory |
|
|
255
|
-
| `compiler.standard` | C++ standard (c++11
|
|
256
|
-
| `compiler.optimization` | Optimization level (O0
|
|
213
|
+
| `compiler.standard` | C++ standard (c++11, c++14, c++17, c++20) |
|
|
214
|
+
| `compiler.optimization` | Optimization level (O0, O1, O2, O3) |
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Using Modules in Python
|
|
219
|
+
|
|
220
|
+
### Direct Import
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from includecpp import math
|
|
224
|
+
|
|
225
|
+
result = math.add(1, 2)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### CppApi
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from includecpp import CppApi
|
|
232
|
+
|
|
233
|
+
api = CppApi()
|
|
234
|
+
math = api.include("math")
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Requirements
|
|
240
|
+
|
|
241
|
+
- Python 3.9 or newer
|
|
242
|
+
- C++ compiler (g++, clang++, or MSVC)
|
|
243
|
+
- CMake
|
|
244
|
+
- pybind11 (installed automatically)
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Troubleshooting
|
|
249
|
+
|
|
250
|
+
### "Module not found"
|
|
251
|
+
|
|
252
|
+
Run `includecpp rebuild` to compile your modules.
|
|
253
|
+
|
|
254
|
+
### Build errors
|
|
255
|
+
|
|
256
|
+
- Check your C++ code compiles normally
|
|
257
|
+
- Make sure code is inside `namespace includecpp`
|
|
258
|
+
- Run `includecpp rebuild --verbose` for details
|
|
259
|
+
|
|
260
|
+
### Changes not showing
|
|
261
|
+
|
|
262
|
+
Run `includecpp rebuild --clean` to force a full rebuild.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Support
|
|
267
|
+
|
|
268
|
+
Report issues: https://github.com/liliassg/IncludeCPP/issues
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
includecpp bug # Report a bug
|
|
272
|
+
includecpp update # Update to latest version
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
# Experimental Features
|
|
278
|
+
|
|
279
|
+
The following features are experimental and may change between versions.
|
|
257
280
|
|
|
258
281
|
---
|
|
259
282
|
|
|
260
283
|
## CSSL Scripting
|
|
261
284
|
|
|
262
|
-
|
|
285
|
+
CSSL (C-Style Scripting Language) is an embedded scripting language included with IncludeCPP.
|
|
263
286
|
|
|
264
287
|
### Basic Usage
|
|
265
288
|
|
|
@@ -277,7 +300,7 @@ CSSL.run('''
|
|
|
277
300
|
''')
|
|
278
301
|
```
|
|
279
302
|
|
|
280
|
-
### Parameters and Return
|
|
303
|
+
### Parameters and Return Values
|
|
281
304
|
|
|
282
305
|
```python
|
|
283
306
|
result = CSSL.run('''
|
|
@@ -289,70 +312,46 @@ result = CSSL.run('''
|
|
|
289
312
|
print(result) # 8
|
|
290
313
|
```
|
|
291
314
|
|
|
292
|
-
###
|
|
293
|
-
|
|
294
|
-
Share Python objects with CSSL:
|
|
315
|
+
### Sharing Python Objects
|
|
295
316
|
|
|
296
317
|
```python
|
|
297
|
-
|
|
318
|
+
from includecpp import CSSL
|
|
319
|
+
|
|
320
|
+
class Player:
|
|
298
321
|
def __init__(self):
|
|
299
|
-
self.
|
|
322
|
+
self.health = 100
|
|
300
323
|
|
|
301
|
-
|
|
324
|
+
player = Player()
|
|
302
325
|
cssl = CSSL.CsslLang()
|
|
303
|
-
cssl.share(
|
|
326
|
+
cssl.share(player, "player")
|
|
304
327
|
|
|
305
328
|
cssl.run('''
|
|
306
|
-
$
|
|
307
|
-
printl($
|
|
329
|
+
$player.health = $player.health - 10;
|
|
330
|
+
printl($player.health);
|
|
308
331
|
''')
|
|
309
332
|
|
|
310
|
-
print(
|
|
333
|
+
print(player.health) # 90 - Changed!
|
|
311
334
|
```
|
|
312
335
|
|
|
313
|
-
###
|
|
314
|
-
|
|
315
|
-
| Syntax | Description |
|
|
316
|
-
|--------|-------------|
|
|
317
|
-
| `$name` | Access shared object |
|
|
318
|
-
| `@name` | Access global variable |
|
|
319
|
-
| `%name` | Access captured variable |
|
|
320
|
-
| `this->` | Access instance member |
|
|
321
|
-
|
|
322
|
-
---
|
|
323
|
-
|
|
324
|
-
## CSSL Data Types
|
|
325
|
-
|
|
326
|
-
### Primitives
|
|
336
|
+
### Data Types
|
|
327
337
|
|
|
328
338
|
```cssl
|
|
329
339
|
int x = 42;
|
|
330
340
|
float pi = 3.14;
|
|
331
|
-
string name = "
|
|
341
|
+
string name = "test";
|
|
332
342
|
bool active = true;
|
|
333
|
-
dynamic any = "flexible";
|
|
334
|
-
```
|
|
335
343
|
|
|
336
|
-
|
|
344
|
+
array<int> numbers;
|
|
345
|
+
numbers.push(1);
|
|
346
|
+
numbers.push(2);
|
|
337
347
|
|
|
338
|
-
```cssl
|
|
339
|
-
array<int> arr;
|
|
340
|
-
arr.push(1);
|
|
341
|
-
arr.push(2);
|
|
342
|
-
|
|
343
|
-
vector<string> vec;
|
|
344
|
-
stack<int> s;
|
|
345
|
-
map<string, int> ages;
|
|
346
348
|
list items = [1, 2, 3];
|
|
347
|
-
dict data = {"
|
|
349
|
+
dict data = {"key": "value"};
|
|
348
350
|
```
|
|
349
351
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
## CSSL Control Flow
|
|
352
|
+
### Control Flow
|
|
353
353
|
|
|
354
354
|
```cssl
|
|
355
|
-
// If/elif/else
|
|
356
355
|
if (x > 10) {
|
|
357
356
|
printl("big");
|
|
358
357
|
} elif (x > 5) {
|
|
@@ -361,46 +360,28 @@ if (x > 10) {
|
|
|
361
360
|
printl("small");
|
|
362
361
|
}
|
|
363
362
|
|
|
364
|
-
// For loop
|
|
365
363
|
for (i in range(0, 10)) {
|
|
366
364
|
printl(i);
|
|
367
365
|
}
|
|
368
366
|
|
|
369
|
-
// Foreach
|
|
370
|
-
foreach (item in items) {
|
|
371
|
-
printl(item);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// While
|
|
375
367
|
while (count < 5) {
|
|
376
368
|
count = count + 1;
|
|
377
369
|
}
|
|
378
370
|
```
|
|
379
371
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
## CSSL Functions
|
|
372
|
+
### Functions
|
|
383
373
|
|
|
384
374
|
```cssl
|
|
385
|
-
|
|
386
|
-
void greet(string name) {
|
|
375
|
+
define greet(name) {
|
|
387
376
|
printl("Hello, " + name + "!");
|
|
388
377
|
}
|
|
389
378
|
|
|
390
|
-
// Return value
|
|
391
379
|
int add(int a, int b) {
|
|
392
380
|
return a + b;
|
|
393
381
|
}
|
|
394
|
-
|
|
395
|
-
// Typed function (C++ style)
|
|
396
|
-
int multiply(int a, int b) {
|
|
397
|
-
return a * b;
|
|
398
|
-
}
|
|
399
382
|
```
|
|
400
383
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
## CSSL Classes
|
|
384
|
+
### Classes
|
|
404
385
|
|
|
405
386
|
```cssl
|
|
406
387
|
class Person {
|
|
@@ -417,177 +398,49 @@ class Person {
|
|
|
417
398
|
}
|
|
418
399
|
}
|
|
419
400
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
### Inheritance
|
|
425
|
-
|
|
426
|
-
```cssl
|
|
427
|
-
class Employee : extends Person {
|
|
428
|
-
string role;
|
|
429
|
-
|
|
430
|
-
constr Employee(string n, int a, string r) {
|
|
431
|
-
super(n, a);
|
|
432
|
-
this->role = r;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
401
|
+
person = new Person("Alice", 30);
|
|
402
|
+
person.greet();
|
|
435
403
|
```
|
|
436
404
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
## CSSL Injection Operators
|
|
405
|
+
### Payloads
|
|
440
406
|
|
|
441
|
-
|
|
407
|
+
Load reusable CSSL code from files:
|
|
442
408
|
|
|
443
409
|
```cssl
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
target -<== source; // Move & remove from source
|
|
410
|
+
payload("helpers"); // Loads helpers.cssl-pl
|
|
411
|
+
payload("mylib", "mylib"); // Loads into namespace mylib::
|
|
447
412
|
```
|
|
448
413
|
|
|
449
|
-
|
|
450
|
-
|
|
414
|
+
With namespaces:
|
|
451
415
|
```cssl
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
myFunc() +<<== {
|
|
457
|
-
printl("Added!");
|
|
458
|
-
};
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
---
|
|
462
|
-
|
|
463
|
-
## CSSL Modules
|
|
464
|
-
|
|
465
|
-
### Create Module
|
|
466
|
-
|
|
467
|
-
```python
|
|
468
|
-
mod = CSSL.module('''
|
|
469
|
-
int add(int a, int b) {
|
|
470
|
-
return a + b;
|
|
471
|
-
}
|
|
472
|
-
''')
|
|
473
|
-
|
|
474
|
-
result = mod.call("add", 2, 3) # 5
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
### Makemodule
|
|
478
|
-
|
|
479
|
-
```python
|
|
480
|
-
math_mod = CSSL.makemodule('''
|
|
481
|
-
int square(int x) {
|
|
482
|
-
return x * x;
|
|
483
|
-
}
|
|
484
|
-
''')
|
|
485
|
-
|
|
486
|
-
print(math_mod.square(5)) # 25
|
|
416
|
+
payload("engine", "Engine");
|
|
417
|
+
myengine = new Engine::GameEngine();
|
|
418
|
+
Engine::init();
|
|
487
419
|
```
|
|
488
420
|
|
|
489
421
|
---
|
|
490
422
|
|
|
491
|
-
##
|
|
492
|
-
|
|
493
|
-
Return CSSL classes to Python:
|
|
423
|
+
## AI Commands
|
|
494
424
|
|
|
495
|
-
|
|
496
|
-
greeter = cssl.run('''
|
|
497
|
-
class Greeter {
|
|
498
|
-
string name;
|
|
499
|
-
|
|
500
|
-
Greeter(string n) {
|
|
501
|
-
this->name = n;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
string sayHello() {
|
|
505
|
-
return "Hello, " + this->name;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
instance = new Greeter("World");
|
|
510
|
-
pyclass = python::pythonize(instance);
|
|
511
|
-
parameter.return(pyclass);
|
|
512
|
-
''')
|
|
513
|
-
|
|
514
|
-
print(greeter.sayHello()) # "Hello, World"
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
---
|
|
518
|
-
|
|
519
|
-
## Universal Instances
|
|
520
|
-
|
|
521
|
-
Shared containers across CSSL and Python:
|
|
522
|
-
|
|
523
|
-
```python
|
|
524
|
-
cssl.run('''
|
|
525
|
-
instance<"myData"> data;
|
|
526
|
-
data.value = 42;
|
|
527
|
-
''')
|
|
528
|
-
|
|
529
|
-
container = cssl.getInstance("myData")
|
|
530
|
-
print(container.value) # 42
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
---
|
|
534
|
-
|
|
535
|
-
## AI Integration
|
|
536
|
-
|
|
537
|
-
### Setup
|
|
425
|
+
OpenAI-powered code assistance (requires API key).
|
|
538
426
|
|
|
539
427
|
```bash
|
|
540
|
-
includecpp ai key sk-your-
|
|
428
|
+
includecpp ai key sk-your-key
|
|
541
429
|
includecpp ai enable
|
|
542
|
-
```
|
|
543
430
|
|
|
544
|
-
### Commands
|
|
545
|
-
|
|
546
|
-
```bash
|
|
547
431
|
includecpp ai ask "where is collision detection?"
|
|
548
|
-
includecpp ai edit "add logging" --file utils.cpp
|
|
549
432
|
includecpp ai optimize mymodule
|
|
550
433
|
includecpp fix --ai mymodule
|
|
551
434
|
```
|
|
552
435
|
|
|
553
436
|
---
|
|
554
437
|
|
|
555
|
-
## CPPY
|
|
438
|
+
## CPPY Conversion
|
|
556
439
|
|
|
557
|
-
|
|
440
|
+
Convert code between Python and C++.
|
|
558
441
|
|
|
559
442
|
```bash
|
|
560
443
|
includecpp cppy convert math.py --cpp
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
### C++ to Python
|
|
564
|
-
|
|
565
|
-
```bash
|
|
566
444
|
includecpp cppy convert utils.cpp --py
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
### AI-Assisted
|
|
570
|
-
|
|
571
|
-
```bash
|
|
572
|
-
includecpp cppy convert complex.py --cpp --ai
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
---
|
|
576
|
-
|
|
577
|
-
## Requirements
|
|
578
|
-
|
|
579
|
-
- Python 3.8+
|
|
580
|
-
- C++ compiler (g++, clang++, MSVC)
|
|
581
|
-
- pybind11 (installed automatically)
|
|
582
|
-
- CMake
|
|
583
|
-
|
|
584
|
-
---
|
|
585
|
-
|
|
586
|
-
## Support
|
|
587
|
-
|
|
588
|
-
Report issues: https://github.com/liliassg/IncludeCPP/issues
|
|
589
|
-
|
|
590
|
-
```bash
|
|
591
|
-
includecpp bug # Report an issue
|
|
592
|
-
includecpp update # Update IncludeCPP
|
|
445
|
+
includecpp cppy convert file.py --cpp --ai
|
|
593
446
|
```
|