IncludeCPP 4.2.2__py3-none-any.whl → 4.3.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/CHANGELOG.md +82 -115
- includecpp/DOCUMENTATION.md +208 -355
- includecpp/__init__.py +1 -1
- includecpp/cli/commands.py +2 -2
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +1505 -1467
- includecpp/core/cssl/cssl_builtins.py +129 -19
- includecpp/core/cssl/cssl_parser.py +539 -29
- includecpp/core/cssl/cssl_runtime.py +467 -33
- includecpp/core/cssl/cssl_types.py +189 -0
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +38 -2
- includecpp-4.3.0.dist-info/METADATA +277 -0
- {includecpp-4.2.2.dist-info → includecpp-4.3.0.dist-info}/RECORD +16 -16
- includecpp-4.2.2.dist-info/METADATA +0 -1008
- {includecpp-4.2.2.dist-info → includecpp-4.3.0.dist-info}/WHEEL +0 -0
- {includecpp-4.2.2.dist-info → includecpp-4.3.0.dist-info}/entry_points.txt +0 -0
- {includecpp-4.2.2.dist-info → includecpp-4.3.0.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.2.2.dist-info → includecpp-4.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,1008 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: IncludeCPP
|
|
3
|
-
Version: 4.2.2
|
|
4
|
-
Summary: Professional C++ Python bindings with type-generic templates, pystubs and native threading
|
|
5
|
-
Home-page: https://github.com/liliassg/IncludeCPP
|
|
6
|
-
Author: Lilias Hatterscheidt
|
|
7
|
-
Author-email: lilias@includecpp.dev
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Repository, https://github.com/liliassg/IncludeCPP
|
|
10
|
-
Project-URL: Bug Tracker, https://github.com/liliasg/IncludeCPP/issues
|
|
11
|
-
Keywords: c++,python,bindings,pybind11,template,performance,threading
|
|
12
|
-
Classifier: Development Status :: 4 - Beta
|
|
13
|
-
Classifier: Intended Audience :: Developers
|
|
14
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
-
Classifier: Programming Language :: C++
|
|
21
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
22
|
-
Classifier: Operating System :: OS Independent
|
|
23
|
-
Requires-Python: >=3.8
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
License-File: LICENSE
|
|
26
|
-
Requires-Dist: pybind11>=2.11.0
|
|
27
|
-
Requires-Dist: click>=8.0.0
|
|
28
|
-
Requires-Dist: typing-extensions>=4.0.0
|
|
29
|
-
Requires-Dist: requests>=2.28.0
|
|
30
|
-
Requires-Dist: colorama>=0.4.0
|
|
31
|
-
Dynamic: author-email
|
|
32
|
-
Dynamic: home-page
|
|
33
|
-
Dynamic: license-file
|
|
34
|
-
Dynamic: requires-python
|
|
35
|
-
|
|
36
|
-
# IncludeCPP
|
|
37
|
-
|
|
38
|
-
Write C++ code, use it in Python. Auto-generates pybind11 bindings.
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
pip install IncludeCPP
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
# First Steps
|
|
45
|
-
|
|
46
|
-
## Project Setup
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
includecpp init
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Creates:
|
|
53
|
-
- `cpp.proj` - project configuration
|
|
54
|
-
- `include/` - your C++ source files
|
|
55
|
-
- `plugins/` - generated binding definitions
|
|
56
|
-
|
|
57
|
-
## Write C++ Code
|
|
58
|
-
|
|
59
|
-
Put your code in `namespace includecpp`:
|
|
60
|
-
|
|
61
|
-
```cpp
|
|
62
|
-
// include/fast_list.cpp
|
|
63
|
-
#include <vector>
|
|
64
|
-
|
|
65
|
-
namespace includecpp {
|
|
66
|
-
|
|
67
|
-
class FastList {
|
|
68
|
-
public:
|
|
69
|
-
void append(int val) { data.push_back(val); }
|
|
70
|
-
int get(int i) { return data[i]; }
|
|
71
|
-
private:
|
|
72
|
-
std::vector<int> data;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
int add(int a, int b) { return a + b; }
|
|
76
|
-
|
|
77
|
-
} // namespace includecpp
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
The parser only scans code inside `namespace includecpp`. Everything else is ignored.
|
|
81
|
-
|
|
82
|
-
## Generate Bindings
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
includecpp plugin fast_list include/fast_list.cpp
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
This runs a C++ parser that:
|
|
89
|
-
1. Scans your source files for classes, methods, functions
|
|
90
|
-
2. Extracts signatures, return types, parameter names
|
|
91
|
-
3. Generates `plugins/fast_list.cp` with binding instructions
|
|
92
|
-
|
|
93
|
-
## Build
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
includecpp rebuild
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Compiles your C++ into a Python extension module (`.pyd` on Windows, `.so` on Linux/Mac).
|
|
100
|
-
|
|
101
|
-
## Use in Python
|
|
102
|
-
|
|
103
|
-
```python
|
|
104
|
-
from includecpp import fast_list
|
|
105
|
-
|
|
106
|
-
my_list = fast_list.FastList()
|
|
107
|
-
my_list.append(42)
|
|
108
|
-
print(fast_list.add(1, 2)) # 3
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Alternative syntax:
|
|
112
|
-
|
|
113
|
-
```python
|
|
114
|
-
from includecpp import CppApi
|
|
115
|
-
|
|
116
|
-
api = CppApi()
|
|
117
|
-
fast_list = api.include("fast_list")
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
# How to Start
|
|
121
|
-
|
|
122
|
-
## Minimal Example
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
# 1. Create project
|
|
126
|
-
mkdir myproject && cd myproject
|
|
127
|
-
includecpp init
|
|
128
|
-
|
|
129
|
-
# 2. Write C++ (include/math.cpp)
|
|
130
|
-
cat > include/math.cpp << 'EOF'
|
|
131
|
-
namespace includecpp {
|
|
132
|
-
int square(int x) { return x * x; }
|
|
133
|
-
}
|
|
134
|
-
EOF
|
|
135
|
-
|
|
136
|
-
# 3. Generate plugin
|
|
137
|
-
includecpp plugin math include/math.cpp
|
|
138
|
-
|
|
139
|
-
# 4. Build
|
|
140
|
-
includecpp rebuild
|
|
141
|
-
|
|
142
|
-
# 5. Use
|
|
143
|
-
python -c "from includecpp import math; print(math.square(7))"
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Development Workflow
|
|
147
|
-
|
|
148
|
-
For active development, use `auto`:
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
includecpp auto math
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
This regenerates the `.cp` file from source and rebuilds in one command.
|
|
155
|
-
|
|
156
|
-
For fastest iteration:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
includecpp rebuild --fast
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
Skips unchanged files. ~0.4s when nothing changed.
|
|
163
|
-
|
|
164
|
-
# How IncludeCPP Works
|
|
165
|
-
|
|
166
|
-
## Architecture
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
Your C++ Source Plugin File (.cp) Python Module
|
|
170
|
-
include/math.cpp ---> plugins/math.cp ---> math.cpXXX.pyd
|
|
171
|
-
^ ^ ^
|
|
172
|
-
| | |
|
|
173
|
-
C++ parser Binding config pybind11 compiled
|
|
174
|
-
extracts API (editable) extension
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## The Parser
|
|
178
|
-
|
|
179
|
-
The C++ parser (`parser.cpp`) runs as a compiled executable. It:
|
|
180
|
-
|
|
181
|
-
1. Tokenizes your C++ source files
|
|
182
|
-
2. Identifies the `namespace includecpp` block
|
|
183
|
-
3. Extracts:
|
|
184
|
-
- Class names and inheritance
|
|
185
|
-
- Method signatures (name, return type, parameters)
|
|
186
|
-
- Function signatures
|
|
187
|
-
- Template instantiations
|
|
188
|
-
- Const/static qualifiers
|
|
189
|
-
4. Outputs structured binding instructions to `.cp` files
|
|
190
|
-
|
|
191
|
-
## Plugin Files (.cp)
|
|
192
|
-
|
|
193
|
-
The `.cp` format is a declarative binding specification:
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
SOURCE(math.cpp) math
|
|
197
|
-
|
|
198
|
-
PUBLIC(
|
|
199
|
-
math CLASS(Calculator) {
|
|
200
|
-
CONSTRUCTOR()
|
|
201
|
-
CONSTRUCTOR(int)
|
|
202
|
-
METHOD(add)
|
|
203
|
-
METHOD_CONST(getValue)
|
|
204
|
-
FIELD(value)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
math FUNC(square)
|
|
208
|
-
math TEMPLATE_FUNC(maximum) TYPES(int, float, double)
|
|
209
|
-
)
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
Key directives:
|
|
213
|
-
- `SOURCE(file.cpp) module_name` - links source to module
|
|
214
|
-
- `PUBLIC(...)` - defines public bindings
|
|
215
|
-
- `CLASS(Name)` - expose a class
|
|
216
|
-
- `STRUCT(Name)` - expose a struct
|
|
217
|
-
- `FUNC(name)` - expose a free function
|
|
218
|
-
- `METHOD(name)` - expose a class method
|
|
219
|
-
- `METHOD_CONST(name, signature)` - for overloaded methods
|
|
220
|
-
- `TEMPLATE_FUNC(name) TYPES(...)` - instantiate template
|
|
221
|
-
- `CONSTRUCTOR(args)` - expose constructor
|
|
222
|
-
- `FIELD(name)` - expose member variable
|
|
223
|
-
- `DEPENDS(mod1, mod2)` - declare module dependencies
|
|
224
|
-
|
|
225
|
-
## Build System
|
|
226
|
-
|
|
227
|
-
The build manager:
|
|
228
|
-
|
|
229
|
-
1. Reads `cpp.proj` configuration
|
|
230
|
-
2. Parses all `.cp` files in `plugins/`
|
|
231
|
-
3. Generates pybind11 binding code
|
|
232
|
-
4. Compiles using CMake with detected compiler (MSVC, GCC, Clang)
|
|
233
|
-
5. Places output in `~/.includecpp/builds/` (not in your project)
|
|
234
|
-
6. Creates a registry so Python can find modules
|
|
235
|
-
|
|
236
|
-
Caching layers:
|
|
237
|
-
- **Object files**: Only recompile changed `.cpp` files
|
|
238
|
-
- **Generator cache**: Compiler/CMake detection runs once
|
|
239
|
-
- **SHA256 hashes**: Skip unchanged modules entirely
|
|
240
|
-
|
|
241
|
-
# CLI Reference
|
|
242
|
-
|
|
243
|
-
Use `includecpp <command> --help` for details.
|
|
244
|
-
|
|
245
|
-
| Command | Description |
|
|
246
|
-
|---------|-------------|
|
|
247
|
-
| `init` | Create project structure |
|
|
248
|
-
| `plugin <name> <files>` | Generate .cp from C++ sources |
|
|
249
|
-
| `auto <plugin>` | Regenerate .cp and rebuild |
|
|
250
|
-
| `auto --all` | Regenerate and rebuild all plugins |
|
|
251
|
-
| `auto --all -x <name>` | All plugins except specified |
|
|
252
|
-
| `fix <module>` | Analyze C++ code for issues |
|
|
253
|
-
| `fix --all` | Analyze all modules |
|
|
254
|
-
| `fix --undo` | Revert last fix changes |
|
|
255
|
-
| `fix --ai <module>` | AI-enhanced code analysis |
|
|
256
|
-
| `ai key <key>` | Set OpenAI API key |
|
|
257
|
-
| `ai enable` | Enable AI features |
|
|
258
|
-
| `ai disable` | Disable AI features |
|
|
259
|
-
| `ai model --list` | List available models |
|
|
260
|
-
| `ai model set <name>` | Set active model |
|
|
261
|
-
| `ai --info` | Show AI configuration and usage |
|
|
262
|
-
| `ai optimize <module>` | AI code optimization |
|
|
263
|
-
| `ai optimize --agent "<task>"` | Custom AI task |
|
|
264
|
-
| `ai ask "<question>"` | Ask about project with full context |
|
|
265
|
-
| `ai ask "<question>" <module>` | Ask about specific module |
|
|
266
|
-
| `ai edit "<task>"` | Edit code with AI assistance |
|
|
267
|
-
| `ai edit "<task>" --think2` | Thorough edit mode |
|
|
268
|
-
| `ai undo` | Restore files after AI changes |
|
|
269
|
-
| `rebuild` / `build` | Compile all modules |
|
|
270
|
-
| `get <module>` | Show module API (classes, methods, functions) |
|
|
271
|
-
| `install <name>` | Install community module |
|
|
272
|
-
| `update` | Update IncludeCPP |
|
|
273
|
-
| `bug` | Report an issue |
|
|
274
|
-
| `--doc` | Show documentation |
|
|
275
|
-
| `--changelog` | Show latest version changelog |
|
|
276
|
-
| `cppy convert <files> --cpp` | Convert Python to C++ |
|
|
277
|
-
| `cppy convert <files> --py` | Convert C++ to Python |
|
|
278
|
-
| `cppy convert <files> --cpp --no-h` | Convert without header |
|
|
279
|
-
| `cppy convert <files> --cpp --ai` | AI-assisted conversion |
|
|
280
|
-
| `cppy analyze <files>` | Analyze code structure |
|
|
281
|
-
| `cppy types` | Show type mapping tables |
|
|
282
|
-
|
|
283
|
-
## Build Flags
|
|
284
|
-
|
|
285
|
-
```bash
|
|
286
|
-
includecpp rebuild # Standard build
|
|
287
|
-
includecpp rebuild --clean # Full rebuild, clear caches
|
|
288
|
-
includecpp rebuild --fast # Fast incremental (~0.4s if unchanged)
|
|
289
|
-
includecpp rebuild --verbose # Show compiler output
|
|
290
|
-
includecpp rebuild -m crypto # Build specific module only
|
|
291
|
-
includecpp rebuild -j 8 # Use 8 parallel jobs
|
|
292
|
-
includecpp rebuild --keep # Keep generator between builds
|
|
293
|
-
includecpp rebuild --no-incremental # Force full recompilation
|
|
294
|
-
includecpp rebuild --this # Build current directory as module
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
## Fast Mode
|
|
298
|
-
|
|
299
|
-
`--fast` enables object file caching:
|
|
300
|
-
|
|
301
|
-
| Scenario | Time |
|
|
302
|
-
|----------|------|
|
|
303
|
-
| No changes | ~0.4s |
|
|
304
|
-
| Source changed | ~5-10s |
|
|
305
|
-
| Full rebuild | ~30s |
|
|
306
|
-
|
|
307
|
-
Clear caches with `--clean`.
|
|
308
|
-
|
|
309
|
-
## Incompatible Flag Combinations
|
|
310
|
-
|
|
311
|
-
| Flags | Reason |
|
|
312
|
-
|-------|--------|
|
|
313
|
-
| `--fast` + `--no-incremental` | Fast mode requires incremental |
|
|
314
|
-
| `--fast` + `--clean` | Fast uses caches, clean deletes them |
|
|
315
|
-
| `--fast` + `--this` | Not supported together |
|
|
316
|
-
| `--incremental` + `--no-incremental` | Contradictory |
|
|
317
|
-
|
|
318
|
-
# Advanced Features
|
|
319
|
-
|
|
320
|
-
## AI Integration
|
|
321
|
-
|
|
322
|
-
IncludeCPP integrates with OpenAI for intelligent code analysis and optimization.
|
|
323
|
-
|
|
324
|
-
### Setup
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
includecpp ai key sk-your-api-key-here
|
|
328
|
-
includecpp ai enable
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Available Models
|
|
332
|
-
|
|
333
|
-
```bash
|
|
334
|
-
includecpp ai model --list
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
- `gpt-5` (default) - 256k context
|
|
338
|
-
- `gpt-5-nano` - 32k context, fast
|
|
339
|
-
- `gpt-4o` - 128k context
|
|
340
|
-
- `gpt-4-turbo` - 128k context
|
|
341
|
-
- `gpt-3.5-turbo` - 16k context
|
|
342
|
-
|
|
343
|
-
### AI-Enhanced Fix
|
|
344
|
-
|
|
345
|
-
```bash
|
|
346
|
-
includecpp fix --ai mymodule
|
|
347
|
-
includecpp fix --ai --all
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
Sends source files to AI for analysis, suggests improvements while preserving all existing functions.
|
|
351
|
-
|
|
352
|
-
### AI Optimize
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
includecpp ai optimize mymodule # Optimize module sources
|
|
356
|
-
includecpp ai optimize --file src/utils.cpp # Optimize specific files
|
|
357
|
-
includecpp ai optimize --agent mymodule "add SIMD" # Custom task
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
### AI Ask
|
|
361
|
-
|
|
362
|
-
Ask questions about your project with full context awareness:
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
includecpp ai ask "where is collision detection?" # Search all modules
|
|
366
|
-
includecpp ai ask "how does chunk generation work?" chunk_utils # Specific module
|
|
367
|
-
includecpp ai ask "explain the biome system" --file include/biomes.cpp
|
|
368
|
-
includecpp ai ask "list all public methods" --all -x tests # All except tests
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
Supports: module name, --file, --all, -x/--exclude
|
|
372
|
-
|
|
373
|
-
### AI Edit
|
|
374
|
-
|
|
375
|
-
Edit code with AI assistance:
|
|
376
|
-
|
|
377
|
-
```bash
|
|
378
|
-
includecpp ai edit "add logging to all methods" collision
|
|
379
|
-
includecpp ai edit "optimize the loop" --file include/utils.cpp
|
|
380
|
-
includecpp ai edit "add error handling" --all --think2 # Thorough mode
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
Flags:
|
|
384
|
-
- `--file` - specific files
|
|
385
|
-
- `--all` - all modules
|
|
386
|
-
- `-x/--exclude` - exclude modules
|
|
387
|
-
- `--think2` - thorough analysis (more tokens)
|
|
388
|
-
|
|
389
|
-
### AI Generate (Super Assistant)
|
|
390
|
-
|
|
391
|
-
The most powerful AI command - a full assistant with file operations and command execution.
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
# Basic usage
|
|
395
|
-
includecpp ai generate "add error handling to all functions" --file mymodule.cp
|
|
396
|
-
|
|
397
|
-
# Create new module from scratch
|
|
398
|
-
includecpp ai generate "fast SIMD math library" --t-new-module simd_math
|
|
399
|
-
|
|
400
|
-
# Planning mode (search, analyze, then execute)
|
|
401
|
-
includecpp ai generate "refactor for better performance" --t-plan --think2
|
|
402
|
-
|
|
403
|
-
# With Python file (auto-detect module usage)
|
|
404
|
-
includecpp ai generate "update api methods" --file mymod.cp --python main.py
|
|
405
|
-
|
|
406
|
-
# Full context mode
|
|
407
|
-
includecpp ai generate "comprehensive optimization" --t-max-context --think3
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
**Flags:**
|
|
411
|
-
| Flag | Description |
|
|
412
|
-
|------|-------------|
|
|
413
|
-
| `--file <path>` | Add files (multiple allowed). .cp files auto-resolve to source |
|
|
414
|
-
| `--think/2/3` | Extended context and planning |
|
|
415
|
-
| `--websearch` | Enable web research |
|
|
416
|
-
| `--t-max-context` | No context reduction |
|
|
417
|
-
| `--t-plan` | Search/grep before executing |
|
|
418
|
-
| `--t-new-module <name>` | Create new module (cpp + plugin + build) |
|
|
419
|
-
| `--python <file.py>` | Include Python file, auto-detect modules |
|
|
420
|
-
| `--confirm` | Skip confirmations |
|
|
421
|
-
|
|
422
|
-
### AI Tools
|
|
423
|
-
|
|
424
|
-
List available tools for the generate command:
|
|
425
|
-
|
|
426
|
-
```bash
|
|
427
|
-
includecpp ai tools
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
Available tools: READ_FILE, WRITE_FILE, EDIT_FILE, DELETE_FILE, CREATE_FOLDER, LIST_FOLDER, SEARCH_FILES, GREP, RUN_CMD, INCLUDECPP_CMD
|
|
431
|
-
|
|
432
|
-
### Build Error Analysis
|
|
433
|
-
|
|
434
|
-
When AI is enabled and `rebuild` fails, the build error is automatically analyzed:
|
|
435
|
-
- Root cause identification
|
|
436
|
-
- Code fix suggestions
|
|
437
|
-
- Prevention tips
|
|
438
|
-
|
|
439
|
-
### Configuration
|
|
440
|
-
|
|
441
|
-
```bash
|
|
442
|
-
includecpp ai --info # Show status, model, usage stats
|
|
443
|
-
includecpp ai disable # Disable without removing key
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
API key stored in `~/.includecpp/.secret`.
|
|
447
|
-
|
|
448
|
-
## Overloaded Methods
|
|
449
|
-
|
|
450
|
-
Specify the signature to disambiguate:
|
|
451
|
-
|
|
452
|
-
```
|
|
453
|
-
MODULE CLASS(Circle) {
|
|
454
|
-
METHOD_CONST(intersects, const Circle&)
|
|
455
|
-
METHOD_CONST(intersects, const Rect&)
|
|
456
|
-
}
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
## Template Instantiation
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
MODULE TEMPLATE_FUNC(maximum) TYPES(int, float, double)
|
|
463
|
-
|
|
464
|
-
MODULE STRUCT(Point) TYPES(int, float) {
|
|
465
|
-
FIELD(x)
|
|
466
|
-
FIELD(y)
|
|
467
|
-
}
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
Generates `maximum_int`, `maximum_float`, `maximum_double` and `Point_int`, `Point_float`.
|
|
471
|
-
|
|
472
|
-
## Module Dependencies
|
|
473
|
-
|
|
474
|
-
```
|
|
475
|
-
DEPENDS(math_utils, geometry)
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
Ensures dependent modules build first.
|
|
479
|
-
|
|
480
|
-
## VSCode IntelliSense
|
|
481
|
-
|
|
482
|
-
Generates `.pyi` stub files for autocomplete. Enable in `cpp.proj`:
|
|
483
|
-
|
|
484
|
-
```json
|
|
485
|
-
{
|
|
486
|
-
"CPI-IntelliSense": true
|
|
487
|
-
}
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
## CPPY Code Conversion
|
|
491
|
-
|
|
492
|
-
Convert code between Python and C++ with full support for classes, functions, and type hints.
|
|
493
|
-
|
|
494
|
-
### Python to C++
|
|
495
|
-
|
|
496
|
-
```bash
|
|
497
|
-
includecpp cppy convert math_utils.py --cpp
|
|
498
|
-
includecpp cppy convert data.py --cpp --no-h # Skip header
|
|
499
|
-
includecpp cppy convert src/*.py --cpp -o include/
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
Converts Python code to optimized C++ with:
|
|
503
|
-
- Type hints mapped to C++ types (int, str -> std::string, List -> std::vector)
|
|
504
|
-
- Classes with constructors, methods, fields
|
|
505
|
-
- Functions with proper signatures
|
|
506
|
-
- List comprehensions to STL algorithms
|
|
507
|
-
- Exception handling to try/catch
|
|
508
|
-
|
|
509
|
-
### C++ to Python
|
|
510
|
-
|
|
511
|
-
```bash
|
|
512
|
-
includecpp cppy convert utils.cpp --py
|
|
513
|
-
includecpp cppy convert mymodule.cp --py # Auto-resolve SOURCE()
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
Converts C++ to Python with:
|
|
517
|
-
- STL types mapped to Python equivalents
|
|
518
|
-
- Classes with type hints
|
|
519
|
-
- Methods become class methods with self
|
|
520
|
-
- Structs become dataclasses
|
|
521
|
-
|
|
522
|
-
### AI-Assisted Conversion
|
|
523
|
-
|
|
524
|
-
```bash
|
|
525
|
-
includecpp cppy convert complex_lib.py --cpp --ai
|
|
526
|
-
includecpp cppy convert advanced.cpp --py --ai -v
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
The `--ai` flag enables intelligent conversion with:
|
|
530
|
-
- Section-by-section analysis and processing
|
|
531
|
-
- Automatic `--think2` context level
|
|
532
|
-
- Comprehensive rulebase for precise conversions
|
|
533
|
-
- pybind11 wrappers for Python features without C++ equivalents:
|
|
534
|
-
- Generators -> callback pattern / py::iterator
|
|
535
|
-
- Async/await -> std::async / std::future
|
|
536
|
-
- Context managers -> RAII pattern
|
|
537
|
-
- Duck typing -> templates with concepts
|
|
538
|
-
- Reports API changes to user
|
|
539
|
-
- Fallback to standard conversion if AI unavailable
|
|
540
|
-
|
|
541
|
-
**Workaround Examples:**
|
|
542
|
-
| Python Feature | C++ Workaround |
|
|
543
|
-
|----------------|----------------|
|
|
544
|
-
| `yield` | Callback pattern or py::iterator |
|
|
545
|
-
| `async/await` | std::async + std::future |
|
|
546
|
-
| `with` context | RAII ScopedResource class |
|
|
547
|
-
| List comprehension | transform_to_vector template |
|
|
548
|
-
| Dict comprehension | transform_to_map template |
|
|
549
|
-
| Dynamic attributes | py::object |
|
|
550
|
-
|
|
551
|
-
### Analyze Code
|
|
552
|
-
|
|
553
|
-
```bash
|
|
554
|
-
includecpp cppy analyze math.py # View structure
|
|
555
|
-
includecpp cppy analyze utils.cpp --json # JSON output
|
|
556
|
-
```
|
|
557
|
-
|
|
558
|
-
### Type Mapping
|
|
559
|
-
|
|
560
|
-
```bash
|
|
561
|
-
includecpp cppy types # Show conversion tables
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
| Python | C++ |
|
|
565
|
-
|--------|-----|
|
|
566
|
-
| int | int |
|
|
567
|
-
| float | double |
|
|
568
|
-
| str | std::string |
|
|
569
|
-
| bool | bool |
|
|
570
|
-
| List[T] | std::vector<T> |
|
|
571
|
-
| Dict[K,V] | std::unordered_map<K,V> |
|
|
572
|
-
| Optional[T] | std::optional<T> |
|
|
573
|
-
| Tuple[...] | std::tuple<...> |
|
|
574
|
-
|
|
575
|
-
# Configuration
|
|
576
|
-
|
|
577
|
-
## cpp.proj
|
|
578
|
-
|
|
579
|
-
```json
|
|
580
|
-
{
|
|
581
|
-
"project": "MyProject",
|
|
582
|
-
"include": "/include",
|
|
583
|
-
"plugins": "/plugins",
|
|
584
|
-
"compiler": {
|
|
585
|
-
"standard": "c++17",
|
|
586
|
-
"optimization": "O3"
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
Options:
|
|
592
|
-
- `project` - project name
|
|
593
|
-
- `include` - C++ source directory
|
|
594
|
-
- `plugins` - plugin file directory
|
|
595
|
-
- `compiler.standard` - C++ standard (c++11, c++14, c++17, c++20)
|
|
596
|
-
- `compiler.optimization` - optimization level (O0, O1, O2, O3)
|
|
597
|
-
|
|
598
|
-
# Requirements
|
|
599
|
-
|
|
600
|
-
- Python 3.8+
|
|
601
|
-
- C++ compiler (g++, clang++, MSVC)
|
|
602
|
-
- pybind11 (installed automatically)
|
|
603
|
-
- CMake (for build generation)
|
|
604
|
-
|
|
605
|
-
# Experimental Features
|
|
606
|
-
|
|
607
|
-
The following features are **experimental** and may contain bugs:
|
|
608
|
-
|
|
609
|
-
- `includecpp ai` - AI-powered code assistance
|
|
610
|
-
- `includecpp cppy` - Python to C++ code conversion
|
|
611
|
-
|
|
612
|
-
These commands are **hidden by default**. To enable them:
|
|
613
|
-
|
|
614
|
-
```bash
|
|
615
|
-
includecpp settings
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
Then check **"Enable Experimental Features"** and save.
|
|
619
|
-
|
|
620
|
-
**Warning:** Experimental features are under active development and may:
|
|
621
|
-
- Produce incorrect output
|
|
622
|
-
- Have breaking changes between versions
|
|
623
|
-
- Be removed or significantly changed
|
|
624
|
-
|
|
625
|
-
Use at your own discretion. Report issues at: https://github.com/liliassg/IncludeCPP/issues
|
|
626
|
-
|
|
627
|
-
# CSSL - C-Style Scripting Language
|
|
628
|
-
|
|
629
|
-
IncludeCPP includes CSSL, a scripting language with advanced data manipulation features.
|
|
630
|
-
|
|
631
|
-
## Basic Usage
|
|
632
|
-
|
|
633
|
-
```python
|
|
634
|
-
from includecpp import CSSL
|
|
635
|
-
|
|
636
|
-
# Execute CSSL code
|
|
637
|
-
CSSL.exec('''
|
|
638
|
-
printl("Hello from CSSL!");
|
|
639
|
-
|
|
640
|
-
int x = 10;
|
|
641
|
-
for (i in range(0, 5)) {
|
|
642
|
-
x = x + i;
|
|
643
|
-
}
|
|
644
|
-
printl(x);
|
|
645
|
-
''')
|
|
646
|
-
|
|
647
|
-
# Execute with arguments
|
|
648
|
-
result = CSSL.exec('''
|
|
649
|
-
int a = parameter.get(0);
|
|
650
|
-
int b = parameter.get(1);
|
|
651
|
-
parameter.return(a + b);
|
|
652
|
-
''', 5, 3)
|
|
653
|
-
print(result) # 8
|
|
654
|
-
```
|
|
655
|
-
|
|
656
|
-
## Live Object Sharing
|
|
657
|
-
|
|
658
|
-
Share Python objects with CSSL scripts. Changes in CSSL reflect back to Python:
|
|
659
|
-
|
|
660
|
-
```python
|
|
661
|
-
from includecpp import CSSL
|
|
662
|
-
|
|
663
|
-
class Counter:
|
|
664
|
-
def __init__(self):
|
|
665
|
-
self.value = 100
|
|
666
|
-
|
|
667
|
-
counter = Counter()
|
|
668
|
-
cssl = CSSL.CsslLang()
|
|
669
|
-
cssl.share(counter, "cnt")
|
|
670
|
-
|
|
671
|
-
# Modify in CSSL - changes reflect in Python!
|
|
672
|
-
cssl.exec('''
|
|
673
|
-
$cnt.value = $cnt.value - 10;
|
|
674
|
-
printl($cnt.value); // 90
|
|
675
|
-
''')
|
|
676
|
-
|
|
677
|
-
print(counter.value) # 90 - Changed!
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
### Shared Object Syntax
|
|
681
|
-
|
|
682
|
-
- `$name` - Access shared object
|
|
683
|
-
- `$name.property` - Access/modify properties
|
|
684
|
-
- `$name.method()` - Call methods
|
|
685
|
-
- `delete("name")` - Remove shared object
|
|
686
|
-
|
|
687
|
-
## Data Types
|
|
688
|
-
|
|
689
|
-
```cssl
|
|
690
|
-
// Basic types
|
|
691
|
-
int x = 42;
|
|
692
|
-
float pi = 3.14;
|
|
693
|
-
string name = "CSSL";
|
|
694
|
-
bool active = true;
|
|
695
|
-
|
|
696
|
-
// Collections
|
|
697
|
-
array<int> arr;
|
|
698
|
-
arr.push(1);
|
|
699
|
-
arr.push(2);
|
|
700
|
-
printl(arr.length()); // 2
|
|
701
|
-
|
|
702
|
-
vector<string> vec;
|
|
703
|
-
vec.push("A");
|
|
704
|
-
vec.push("B");
|
|
705
|
-
|
|
706
|
-
stack<int> s;
|
|
707
|
-
s.push(10);
|
|
708
|
-
s.pop();
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
## Control Flow
|
|
712
|
-
|
|
713
|
-
```cssl
|
|
714
|
-
// If/elif/else
|
|
715
|
-
if (x > 10) {
|
|
716
|
-
printl("big");
|
|
717
|
-
} elif (x > 5) {
|
|
718
|
-
printl("medium");
|
|
719
|
-
} else {
|
|
720
|
-
printl("small");
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// For loops
|
|
724
|
-
for (i in range(0, 10)) {
|
|
725
|
-
printl(i);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
for (i in range(0, 10, 2)) { // with step
|
|
729
|
-
printl(i); // 0, 2, 4, 6, 8
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// Foreach
|
|
733
|
-
array<string> items;
|
|
734
|
-
items.push("A");
|
|
735
|
-
items.push("B");
|
|
736
|
-
foreach (item in items) {
|
|
737
|
-
printl(item);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
// While
|
|
741
|
-
int count = 0;
|
|
742
|
-
while (count < 5) {
|
|
743
|
-
printl(count);
|
|
744
|
-
count = count + 1;
|
|
745
|
-
}
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
## Functions
|
|
749
|
-
|
|
750
|
-
```cssl
|
|
751
|
-
// Basic function
|
|
752
|
-
void greet(string name) {
|
|
753
|
-
printl("Hello, " + name + "!");
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
// Return value
|
|
757
|
-
int add(int a, int b) {
|
|
758
|
-
return a + b;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
// Global variables
|
|
762
|
-
global version = "1.0.0";
|
|
763
|
-
printl(@version);
|
|
764
|
-
|
|
765
|
-
// r@ syntax for global declaration
|
|
766
|
-
r@myGlobal = "value";
|
|
767
|
-
printl(@myGlobal);
|
|
768
|
-
```
|
|
769
|
-
|
|
770
|
-
## BruteForce Injection System
|
|
771
|
-
|
|
772
|
-
CSSL's unique injection operators for data manipulation:
|
|
773
|
-
|
|
774
|
-
```cssl
|
|
775
|
-
// <== Move data (replaces target)
|
|
776
|
-
target <== source;
|
|
777
|
-
|
|
778
|
-
// +<== Copy & add to target
|
|
779
|
-
target +<== source;
|
|
780
|
-
|
|
781
|
-
// -<== Move & remove from source
|
|
782
|
-
target -<== source;
|
|
783
|
-
|
|
784
|
-
// <<== Code infusion into functions
|
|
785
|
-
myFunc() <<== {
|
|
786
|
-
printl("Injected code!");
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
// +<<== Add code without replacing
|
|
790
|
-
myFunc() +<<== {
|
|
791
|
-
printl("Additional code!");
|
|
792
|
-
};
|
|
793
|
-
```
|
|
794
|
-
|
|
795
|
-
## String Methods
|
|
796
|
-
|
|
797
|
-
```cssl
|
|
798
|
-
string s = "Hello World";
|
|
799
|
-
|
|
800
|
-
// Methods
|
|
801
|
-
s.length(); // 11
|
|
802
|
-
s.toUpper(); // "HELLO WORLD"
|
|
803
|
-
s.toLower(); // "hello world"
|
|
804
|
-
s.contains("World"); // true
|
|
805
|
-
s.startsWith("Hello"); // true
|
|
806
|
-
s.endsWith("World"); // true
|
|
807
|
-
s.replace("World", "CSSL");
|
|
808
|
-
s.split(" "); // ["Hello", "World"]
|
|
809
|
-
s.trim(); // Remove whitespace
|
|
810
|
-
s.substring(0, 5); // "Hello"
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
## CSSL Modules
|
|
814
|
-
|
|
815
|
-
```python
|
|
816
|
-
# Create callable module
|
|
817
|
-
module = CSSL.module('''
|
|
818
|
-
string name = parameter.get(0);
|
|
819
|
-
printl("Hello, " + name + "!");
|
|
820
|
-
''')
|
|
821
|
-
module("World") # Prints: Hello, World!
|
|
822
|
-
|
|
823
|
-
# Create module with functions
|
|
824
|
-
math_mod = CSSL.makemodule('''
|
|
825
|
-
int add(int a, int b) {
|
|
826
|
-
return a + b;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
int multiply(int a, int b) {
|
|
830
|
-
return a * b;
|
|
831
|
-
}
|
|
832
|
-
''')
|
|
833
|
-
print(math_mod.add(2, 3)) # 5
|
|
834
|
-
print(math_mod.multiply(4, 5)) # 20
|
|
835
|
-
```
|
|
836
|
-
|
|
837
|
-
## Inline Payloads
|
|
838
|
-
|
|
839
|
-
```python
|
|
840
|
-
cssl = CSSL.CsslLang()
|
|
841
|
-
|
|
842
|
-
# Register code as payload
|
|
843
|
-
cssl.script(<name>, "helpers", '''
|
|
844
|
-
global version = "1.0.0";
|
|
845
|
-
void log(string msg) {
|
|
846
|
-
printl("[LOG] " + msg);
|
|
847
|
-
}
|
|
848
|
-
''')
|
|
849
|
-
|
|
850
|
-
# Use in CSSL
|
|
851
|
-
cssl.run('''
|
|
852
|
-
payload("<name>"); // use module you declared in cssl.script(<name>, ...)
|
|
853
|
-
@log("Application started");
|
|
854
|
-
printl(@version);
|
|
855
|
-
''')
|
|
856
|
-
```
|
|
857
|
-
|
|
858
|
-
## Return CSSL Classes to Python
|
|
859
|
-
|
|
860
|
-
Use `python::pythonize()` to convert CSSL class instances into Python-usable objects:
|
|
861
|
-
|
|
862
|
-
```python
|
|
863
|
-
from includecpp import CSSL
|
|
864
|
-
|
|
865
|
-
cssl = CSSL.CsslLang()
|
|
866
|
-
|
|
867
|
-
# Create and return a CSSL class as a Python object
|
|
868
|
-
greeter = cssl.run('''
|
|
869
|
-
class Greeter {
|
|
870
|
-
string name;
|
|
871
|
-
|
|
872
|
-
Greeter(string n) {
|
|
873
|
-
this->name = n;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
string sayHello() {
|
|
877
|
-
return "Hello, " + this->name + "!";
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
void setName(string newName) {
|
|
881
|
-
this->name = newName;
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
string getName() {
|
|
885
|
-
return this->name;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
instance = new Greeter("World");
|
|
890
|
-
pyclass = python::pythonize(instance);
|
|
891
|
-
parameter.return(pyclass);
|
|
892
|
-
''')
|
|
893
|
-
|
|
894
|
-
# Now use it like a normal Python object!
|
|
895
|
-
print(greeter.name) # "World"
|
|
896
|
-
print(greeter.sayHello()) # "Hello, World!"
|
|
897
|
-
greeter.setName("Python")
|
|
898
|
-
print(greeter.getName()) # "Python"
|
|
899
|
-
print(greeter.name) # "Python"
|
|
900
|
-
```
|
|
901
|
-
|
|
902
|
-
### Aliases
|
|
903
|
-
|
|
904
|
-
- `python::pythonize(instance)` - Main function
|
|
905
|
-
- `python::wrap(instance)` - Alias
|
|
906
|
-
- `python::export(instance)` - Alias
|
|
907
|
-
|
|
908
|
-
All three do the same thing: wrap a CSSL class instance for Python use.
|
|
909
|
-
|
|
910
|
-
## Universal Instances (v4.0.3+)
|
|
911
|
-
|
|
912
|
-
Universal instances are shared containers accessible from CSSL, Python, and C++:
|
|
913
|
-
|
|
914
|
-
```python
|
|
915
|
-
from includecpp import CSSL
|
|
916
|
-
|
|
917
|
-
cssl = CSSL.CsslLang()
|
|
918
|
-
|
|
919
|
-
# Create in CSSL
|
|
920
|
-
cssl.run('''
|
|
921
|
-
instance<"myContainer"> container;
|
|
922
|
-
container.data = "Hello";
|
|
923
|
-
container.count = 42;
|
|
924
|
-
''')
|
|
925
|
-
|
|
926
|
-
# Access from Python
|
|
927
|
-
container = cssl.getInstance("myContainer")
|
|
928
|
-
print(container.data) # "Hello"
|
|
929
|
-
print(container.count) # 42
|
|
930
|
-
|
|
931
|
-
# Modify from Python
|
|
932
|
-
container.newValue = "Added from Python"
|
|
933
|
-
|
|
934
|
-
# Changes reflect in CSSL
|
|
935
|
-
cssl.run('''
|
|
936
|
-
instance<"myContainer"> c;
|
|
937
|
-
printl(c.newValue); // "Added from Python"
|
|
938
|
-
''')
|
|
939
|
-
```
|
|
940
|
-
|
|
941
|
-
### Instance Methods
|
|
942
|
-
|
|
943
|
-
```python
|
|
944
|
-
cssl.getInstance("name") # Get instance (None if not found)
|
|
945
|
-
cssl.createInstance("name") # Create or get instance
|
|
946
|
-
cssl.deleteInstance("name") # Delete instance
|
|
947
|
-
cssl.listInstances() # List all instance names
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
### Method Injection
|
|
951
|
-
|
|
952
|
-
Inject methods into instances using `+<<==`:
|
|
953
|
-
|
|
954
|
-
```cssl
|
|
955
|
-
instance<"api"> api;
|
|
956
|
-
|
|
957
|
-
// Inject a method
|
|
958
|
-
api +<<== {
|
|
959
|
-
void greet(string name) {
|
|
960
|
-
printl("Hello, " + name + "!");
|
|
961
|
-
}
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
api.greet("World"); // Hello, World!
|
|
965
|
-
```
|
|
966
|
-
|
|
967
|
-
## Simplified Module API (v4.0.2+)
|
|
968
|
-
|
|
969
|
-
Create CSSL modules from files with payload binding:
|
|
970
|
-
|
|
971
|
-
```python
|
|
972
|
-
from includecpp import CSSL
|
|
973
|
-
|
|
974
|
-
# Register payload from file
|
|
975
|
-
CSSL.makepayload("api", "lib/api/myapi.cssl-pl")
|
|
976
|
-
|
|
977
|
-
# Create module from file, binding to payload
|
|
978
|
-
mod = CSSL.makemodule("writer", "lib/writer.cssl", bind="api")
|
|
979
|
-
mod.SaySomething("Hello!") # Call functions directly
|
|
980
|
-
```
|
|
981
|
-
|
|
982
|
-
## VSCode Extension
|
|
983
|
-
|
|
984
|
-
IncludeCPP includes a VSCode extension for CSSL syntax highlighting.
|
|
985
|
-
|
|
986
|
-
### Installation
|
|
987
|
-
|
|
988
|
-
```bash
|
|
989
|
-
# Copy extension to VSCode extensions folder
|
|
990
|
-
# Windows: %USERPROFILE%\.vscode\extensions\
|
|
991
|
-
# Linux/Mac: ~/.vscode/extensions/
|
|
992
|
-
|
|
993
|
-
# Or install from included files
|
|
994
|
-
pip show includecpp # Find package location
|
|
995
|
-
# Copy vscode/cssl folder to extensions
|
|
996
|
-
```
|
|
997
|
-
|
|
998
|
-
### Features
|
|
999
|
-
|
|
1000
|
-
- Syntax highlighting for `.cssl`, `.cssl-pl`, `.cssl-mod` files
|
|
1001
|
-
- Snippets for common patterns
|
|
1002
|
-
- Run CSSL files with F5
|
|
1003
|
-
- Proper coloring for:
|
|
1004
|
-
- Keywords and control flow
|
|
1005
|
-
- Data types (purple/lilac)
|
|
1006
|
-
- Variable declarations (light blue)
|
|
1007
|
-
- Injection operators (`<<==`, `<==`)
|
|
1008
|
-
- Global (`@`), shared (`$`), and captured (`%`) references
|