IncludeCPP 3.7.24__tar.gz → 3.7.26__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.
Files changed (60) hide show
  1. includecpp-3.7.24/README.md → includecpp-3.7.26/IncludeCPP.egg-info/PKG-INFO +855 -1042
  2. {includecpp-3.7.24 → includecpp-3.7.26}/IncludeCPP.egg-info/SOURCES.txt +2 -0
  3. {includecpp-3.7.24/IncludeCPP.egg-info → includecpp-3.7.26}/PKG-INFO +4 -225
  4. includecpp-3.7.24/PKG-INFO → includecpp-3.7.26/README.md +821 -1076
  5. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/__init__.py +1 -1
  6. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_parser.py +13 -2
  7. includecpp-3.7.26/includecpp/vscode/cssl/extension.js +133 -0
  8. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/package.json +73 -4
  9. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/snippets/cssl.snippets.json +88 -0
  10. {includecpp-3.7.24 → includecpp-3.7.26}/pyproject.toml +2 -1
  11. {includecpp-3.7.24 → includecpp-3.7.26}/IncludeCPP.egg-info/dependency_links.txt +0 -0
  12. {includecpp-3.7.24 → includecpp-3.7.26}/IncludeCPP.egg-info/entry_points.txt +0 -0
  13. {includecpp-3.7.24 → includecpp-3.7.26}/IncludeCPP.egg-info/requires.txt +0 -0
  14. {includecpp-3.7.24 → includecpp-3.7.26}/IncludeCPP.egg-info/top_level.txt +0 -0
  15. {includecpp-3.7.24 → includecpp-3.7.26}/LICENSE +0 -0
  16. {includecpp-3.7.24 → includecpp-3.7.26}/MANIFEST.in +0 -0
  17. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/__init__.pyi +0 -0
  18. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/__main__.py +0 -0
  19. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/cli/__init__.py +0 -0
  20. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/cli/commands.py +0 -0
  21. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/cli/config_parser.py +0 -0
  22. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/__init__.py +0 -0
  23. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/ai_integration.py +0 -0
  24. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/build_manager.py +0 -0
  25. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cpp_api.py +0 -0
  26. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cpp_api.pyi +0 -0
  27. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cppy_converter.py +0 -0
  28. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/CSSL_DOCUMENTATION.md +0 -0
  29. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/__init__.py +0 -0
  30. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_builtins.py +0 -0
  31. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_builtins.pyi +0 -0
  32. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_events.py +0 -0
  33. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_modules.py +0 -0
  34. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_runtime.py +0 -0
  35. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_syntax.py +0 -0
  36. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl/cssl_types.py +0 -0
  37. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl_bridge.py +0 -0
  38. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/cssl_bridge.pyi +0 -0
  39. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/error_catalog.py +0 -0
  40. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/error_formatter.py +0 -0
  41. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/exceptions.py +0 -0
  42. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/path_discovery.py +0 -0
  43. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/project_ui.py +0 -0
  44. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/core/settings_ui.py +0 -0
  45. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/generator/__init__.py +0 -0
  46. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/generator/parser.cpp +0 -0
  47. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/generator/parser.h +0 -0
  48. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/generator/type_resolver.cpp +0 -0
  49. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/generator/type_resolver.h +0 -0
  50. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/py.typed +0 -0
  51. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/templates/cpp.proj.template +0 -0
  52. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/__init__.py +0 -0
  53. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/__init__.py +0 -0
  54. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/images/cssl.png +0 -0
  55. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/images/cssl_pl.png +0 -0
  56. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/language-configuration.json +0 -0
  57. {includecpp-3.7.24 → includecpp-3.7.26}/includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +0 -0
  58. {includecpp-3.7.24 → includecpp-3.7.26}/requirements.txt +0 -0
  59. {includecpp-3.7.24 → includecpp-3.7.26}/setup.cfg +0 -0
  60. {includecpp-3.7.24 → includecpp-3.7.26}/setup.py +0 -0
@@ -1,1042 +1,855 @@
1
- # IncludeCPP
2
-
3
- Write C++ code, use it in Python. Auto-generates pybind11 bindings.
4
-
5
- ```bash
6
- pip install IncludeCPP
7
- ```
8
-
9
- # First Steps
10
-
11
- ## Project Setup
12
-
13
- ```bash
14
- includecpp init
15
- ```
16
-
17
- Creates:
18
- - `cpp.proj` - project configuration
19
- - `include/` - your C++ source files
20
- - `plugins/` - generated binding definitions
21
-
22
- ## Write C++ Code
23
-
24
- Put your code in `namespace includecpp`:
25
-
26
- ```cpp
27
- // include/fast_list.cpp
28
- #include <vector>
29
-
30
- namespace includecpp {
31
-
32
- class FastList {
33
- public:
34
- void append(int val) { data.push_back(val); }
35
- int get(int i) { return data[i]; }
36
- private:
37
- std::vector<int> data;
38
- };
39
-
40
- int add(int a, int b) { return a + b; }
41
-
42
- } // namespace includecpp
43
- ```
44
-
45
- The parser only scans code inside `namespace includecpp`. Everything else is ignored.
46
-
47
- ## Generate Bindings
48
-
49
- ```bash
50
- includecpp plugin fast_list include/fast_list.cpp
51
- ```
52
-
53
- This runs a C++ parser that:
54
- 1. Scans your source files for classes, methods, functions
55
- 2. Extracts signatures, return types, parameter names
56
- 3. Generates `plugins/fast_list.cp` with binding instructions
57
-
58
- ## Build
59
-
60
- ```bash
61
- includecpp rebuild
62
- ```
63
-
64
- Compiles your C++ into a Python extension module (`.pyd` on Windows, `.so` on Linux/Mac).
65
-
66
- ## Use in Python
67
-
68
- ```python
69
- from includecpp import fast_list
70
-
71
- my_list = fast_list.FastList()
72
- my_list.append(42)
73
- print(fast_list.add(1, 2)) # 3
74
- ```
75
-
76
- Alternative syntax:
77
-
78
- ```python
79
- from includecpp import CppApi
80
-
81
- api = CppApi()
82
- fast_list = api.include("fast_list")
83
- ```
84
-
85
- # How to Start
86
-
87
- ## Minimal Example
88
-
89
- ```bash
90
- # 1. Create project
91
- mkdir myproject && cd myproject
92
- includecpp init
93
-
94
- # 2. Write C++ (include/math.cpp)
95
- cat > include/math.cpp << 'EOF'
96
- namespace includecpp {
97
- int square(int x) { return x * x; }
98
- }
99
- EOF
100
-
101
- # 3. Generate plugin
102
- includecpp plugin math include/math.cpp
103
-
104
- # 4. Build
105
- includecpp rebuild
106
-
107
- # 5. Use
108
- python -c "from includecpp import math; print(math.square(7))"
109
- ```
110
-
111
- ## Development Workflow
112
-
113
- For active development, use `auto`:
114
-
115
- ```bash
116
- includecpp auto math
117
- ```
118
-
119
- This regenerates the `.cp` file from source and rebuilds in one command.
120
-
121
- For fastest iteration:
122
-
123
- ```bash
124
- includecpp rebuild --fast
125
- ```
126
-
127
- Skips unchanged files. ~0.4s when nothing changed.
128
-
129
- # How IncludeCPP Works
130
-
131
- ## Architecture
132
-
133
- ```
134
- Your C++ Source Plugin File (.cp) Python Module
135
- include/math.cpp ---> plugins/math.cp ---> math.cpXXX.pyd
136
- ^ ^ ^
137
- | | |
138
- C++ parser Binding config pybind11 compiled
139
- extracts API (editable) extension
140
- ```
141
-
142
- ## The Parser
143
-
144
- The C++ parser (`parser.cpp`) runs as a compiled executable. It:
145
-
146
- 1. Tokenizes your C++ source files
147
- 2. Identifies the `namespace includecpp` block
148
- 3. Extracts:
149
- - Class names and inheritance
150
- - Method signatures (name, return type, parameters)
151
- - Function signatures
152
- - Template instantiations
153
- - Const/static qualifiers
154
- 4. Outputs structured binding instructions to `.cp` files
155
-
156
- ## Plugin Files (.cp)
157
-
158
- The `.cp` format is a declarative binding specification:
159
-
160
- ```
161
- SOURCE(math.cpp) math
162
-
163
- PUBLIC(
164
- math CLASS(Calculator) {
165
- CONSTRUCTOR()
166
- CONSTRUCTOR(int)
167
- METHOD(add)
168
- METHOD_CONST(getValue)
169
- FIELD(value)
170
- }
171
-
172
- math FUNC(square)
173
- math TEMPLATE_FUNC(maximum) TYPES(int, float, double)
174
- )
175
- ```
176
-
177
- Key directives:
178
- - `SOURCE(file.cpp) module_name` - links source to module
179
- - `PUBLIC(...)` - defines public bindings
180
- - `CLASS(Name)` - expose a class
181
- - `STRUCT(Name)` - expose a struct
182
- - `FUNC(name)` - expose a free function
183
- - `METHOD(name)` - expose a class method
184
- - `METHOD_CONST(name, signature)` - for overloaded methods
185
- - `TEMPLATE_FUNC(name) TYPES(...)` - instantiate template
186
- - `CONSTRUCTOR(args)` - expose constructor
187
- - `FIELD(name)` - expose member variable
188
- - `DEPENDS(mod1, mod2)` - declare module dependencies
189
-
190
- ## Build System
191
-
192
- The build manager:
193
-
194
- 1. Reads `cpp.proj` configuration
195
- 2. Parses all `.cp` files in `plugins/`
196
- 3. Generates pybind11 binding code
197
- 4. Compiles using CMake with detected compiler (MSVC, GCC, Clang)
198
- 5. Places output in `~/.includecpp/builds/` (not in your project)
199
- 6. Creates a registry so Python can find modules
200
-
201
- Caching layers:
202
- - **Object files**: Only recompile changed `.cpp` files
203
- - **Generator cache**: Compiler/CMake detection runs once
204
- - **SHA256 hashes**: Skip unchanged modules entirely
205
-
206
- # CLI Reference
207
-
208
- Use `includecpp <command> --help` for details.
209
-
210
- | Command | Description |
211
- |---------|-------------|
212
- | `init` | Create project structure |
213
- | `plugin <name> <files>` | Generate .cp from C++ sources |
214
- | `auto <plugin>` | Regenerate .cp and rebuild |
215
- | `auto --all` | Regenerate and rebuild all plugins |
216
- | `auto --all -x <name>` | All plugins except specified |
217
- | `fix <module>` | Analyze C++ code for issues |
218
- | `fix --all` | Analyze all modules |
219
- | `fix --undo` | Revert last fix changes |
220
- | `fix --ai <module>` | AI-enhanced code analysis |
221
- | `ai key <key>` | Set OpenAI API key |
222
- | `ai enable` | Enable AI features |
223
- | `ai disable` | Disable AI features |
224
- | `ai model --list` | List available models |
225
- | `ai model set <name>` | Set active model |
226
- | `ai --info` | Show AI configuration and usage |
227
- | `ai optimize <module>` | AI code optimization |
228
- | `ai optimize --agent "<task>"` | Custom AI task |
229
- | `ai ask "<question>"` | Ask about project with full context |
230
- | `ai ask "<question>" <module>` | Ask about specific module |
231
- | `ai edit "<task>"` | Edit code with AI assistance |
232
- | `ai edit "<task>" --think2` | Thorough edit mode |
233
- | `ai undo` | Restore files after AI changes |
234
- | `rebuild` / `build` | Compile all modules |
235
- | `get <module>` | Show module API (classes, methods, functions) |
236
- | `install <name>` | Install community module |
237
- | `update` | Update IncludeCPP |
238
- | `bug` | Report an issue |
239
- | `--doc` | Show documentation |
240
- | `--changelog` | Show latest version changelog |
241
- | `cppy convert <files> --cpp` | Convert Python to C++ |
242
- | `cppy convert <files> --py` | Convert C++ to Python |
243
- | `cppy convert <files> --cpp --no-h` | Convert without header |
244
- | `cppy convert <files> --cpp --ai` | AI-assisted conversion |
245
- | `cppy analyze <files>` | Analyze code structure |
246
- | `cppy types` | Show type mapping tables |
247
-
248
- ## Build Flags
249
-
250
- ```bash
251
- includecpp rebuild # Standard build
252
- includecpp rebuild --clean # Full rebuild, clear caches
253
- includecpp rebuild --fast # Fast incremental (~0.4s if unchanged)
254
- includecpp rebuild --verbose # Show compiler output
255
- includecpp rebuild -m crypto # Build specific module only
256
- includecpp rebuild -j 8 # Use 8 parallel jobs
257
- includecpp rebuild --keep # Keep generator between builds
258
- includecpp rebuild --no-incremental # Force full recompilation
259
- includecpp rebuild --this # Build current directory as module
260
- ```
261
-
262
- ## Fast Mode
263
-
264
- `--fast` enables object file caching:
265
-
266
- | Scenario | Time |
267
- |----------|------|
268
- | No changes | ~0.4s |
269
- | Source changed | ~5-10s |
270
- | Full rebuild | ~30s |
271
-
272
- Clear caches with `--clean`.
273
-
274
- ## Incompatible Flag Combinations
275
-
276
- | Flags | Reason |
277
- |-------|--------|
278
- | `--fast` + `--no-incremental` | Fast mode requires incremental |
279
- | `--fast` + `--clean` | Fast uses caches, clean deletes them |
280
- | `--fast` + `--this` | Not supported together |
281
- | `--incremental` + `--no-incremental` | Contradictory |
282
-
283
- # Advanced Features
284
-
285
- ## AI Integration
286
-
287
- IncludeCPP integrates with OpenAI for intelligent code analysis and optimization.
288
-
289
- ### Setup
290
-
291
- ```bash
292
- includecpp ai key sk-your-api-key-here
293
- includecpp ai enable
294
- ```
295
-
296
- ### Available Models
297
-
298
- ```bash
299
- includecpp ai model --list
300
- ```
301
-
302
- - `gpt-5` (default) - 256k context
303
- - `gpt-5-nano` - 32k context, fast
304
- - `gpt-4o` - 128k context
305
- - `gpt-4-turbo` - 128k context
306
- - `gpt-3.5-turbo` - 16k context
307
-
308
- ### AI-Enhanced Fix
309
-
310
- ```bash
311
- includecpp fix --ai mymodule
312
- includecpp fix --ai --all
313
- ```
314
-
315
- Sends source files to AI for analysis, suggests improvements while preserving all existing functions.
316
-
317
- ### AI Optimize
318
-
319
- ```bash
320
- includecpp ai optimize mymodule # Optimize module sources
321
- includecpp ai optimize --file src/utils.cpp # Optimize specific files
322
- includecpp ai optimize --agent mymodule "add SIMD" # Custom task
323
- ```
324
-
325
- ### AI Ask
326
-
327
- Ask questions about your project with full context awareness:
328
-
329
- ```bash
330
- includecpp ai ask "where is collision detection?" # Search all modules
331
- includecpp ai ask "how does chunk generation work?" chunk_utils # Specific module
332
- includecpp ai ask "explain the biome system" --file include/biomes.cpp
333
- includecpp ai ask "list all public methods" --all -x tests # All except tests
334
- ```
335
-
336
- Supports: module name, --file, --all, -x/--exclude
337
-
338
- ### AI Edit
339
-
340
- Edit code with AI assistance:
341
-
342
- ```bash
343
- includecpp ai edit "add logging to all methods" collision
344
- includecpp ai edit "optimize the loop" --file include/utils.cpp
345
- includecpp ai edit "add error handling" --all --think2 # Thorough mode
346
- ```
347
-
348
- Flags:
349
- - `--file` - specific files
350
- - `--all` - all modules
351
- - `-x/--exclude` - exclude modules
352
- - `--think2` - thorough analysis (more tokens)
353
-
354
- ### AI Generate (Super Assistant)
355
-
356
- The most powerful AI command - a full assistant with file operations and command execution.
357
-
358
- ```bash
359
- # Basic usage
360
- includecpp ai generate "add error handling to all functions" --file mymodule.cp
361
-
362
- # Create new module from scratch
363
- includecpp ai generate "fast SIMD math library" --t-new-module simd_math
364
-
365
- # Planning mode (search, analyze, then execute)
366
- includecpp ai generate "refactor for better performance" --t-plan --think2
367
-
368
- # With Python file (auto-detect module usage)
369
- includecpp ai generate "update api methods" --file mymod.cp --python main.py
370
-
371
- # Full context mode
372
- includecpp ai generate "comprehensive optimization" --t-max-context --think3
373
- ```
374
-
375
- **Flags:**
376
- | Flag | Description |
377
- |------|-------------|
378
- | `--file <path>` | Add files (multiple allowed). .cp files auto-resolve to source |
379
- | `--think/2/3` | Extended context and planning |
380
- | `--websearch` | Enable web research |
381
- | `--t-max-context` | No context reduction |
382
- | `--t-plan` | Search/grep before executing |
383
- | `--t-new-module <name>` | Create new module (cpp + plugin + build) |
384
- | `--python <file.py>` | Include Python file, auto-detect modules |
385
- | `--confirm` | Skip confirmations |
386
-
387
- ### AI Tools
388
-
389
- List available tools for the generate command:
390
-
391
- ```bash
392
- includecpp ai tools
393
- ```
394
-
395
- Available tools: READ_FILE, WRITE_FILE, EDIT_FILE, DELETE_FILE, CREATE_FOLDER, LIST_FOLDER, SEARCH_FILES, GREP, RUN_CMD, INCLUDECPP_CMD
396
-
397
- ### Build Error Analysis
398
-
399
- When AI is enabled and `rebuild` fails, the build error is automatically analyzed:
400
- - Root cause identification
401
- - Code fix suggestions
402
- - Prevention tips
403
-
404
- ### Configuration
405
-
406
- ```bash
407
- includecpp ai --info # Show status, model, usage stats
408
- includecpp ai disable # Disable without removing key
409
- ```
410
-
411
- API key stored in `~/.includecpp/.secret`.
412
-
413
- ## Overloaded Methods
414
-
415
- Specify the signature to disambiguate:
416
-
417
- ```
418
- MODULE CLASS(Circle) {
419
- METHOD_CONST(intersects, const Circle&)
420
- METHOD_CONST(intersects, const Rect&)
421
- }
422
- ```
423
-
424
- ## Template Instantiation
425
-
426
- ```
427
- MODULE TEMPLATE_FUNC(maximum) TYPES(int, float, double)
428
-
429
- MODULE STRUCT(Point) TYPES(int, float) {
430
- FIELD(x)
431
- FIELD(y)
432
- }
433
- ```
434
-
435
- Generates `maximum_int`, `maximum_float`, `maximum_double` and `Point_int`, `Point_float`.
436
-
437
- ## Module Dependencies
438
-
439
- ```
440
- DEPENDS(math_utils, geometry)
441
- ```
442
-
443
- Ensures dependent modules build first.
444
-
445
- ## VSCode IntelliSense
446
-
447
- Generates `.pyi` stub files for autocomplete. Enable in `cpp.proj`:
448
-
449
- ```json
450
- {
451
- "CPI-IntelliSense": true
452
- }
453
- ```
454
-
455
- ## CPPY Code Conversion
456
-
457
- Convert code between Python and C++ with full support for classes, functions, and type hints.
458
-
459
- ### Python to C++
460
-
461
- ```bash
462
- includecpp cppy convert math_utils.py --cpp
463
- includecpp cppy convert data.py --cpp --no-h # Skip header
464
- includecpp cppy convert src/*.py --cpp -o include/
465
- ```
466
-
467
- Converts Python code to optimized C++ with:
468
- - Type hints mapped to C++ types (int, str -> std::string, List -> std::vector)
469
- - Classes with constructors, methods, fields
470
- - Functions with proper signatures
471
- - List comprehensions to STL algorithms
472
- - Exception handling to try/catch
473
-
474
- ### C++ to Python
475
-
476
- ```bash
477
- includecpp cppy convert utils.cpp --py
478
- includecpp cppy convert mymodule.cp --py # Auto-resolve SOURCE()
479
- ```
480
-
481
- Converts C++ to Python with:
482
- - STL types mapped to Python equivalents
483
- - Classes with type hints
484
- - Methods become class methods with self
485
- - Structs become dataclasses
486
-
487
- ### AI-Assisted Conversion
488
-
489
- ```bash
490
- includecpp cppy convert complex_lib.py --cpp --ai
491
- includecpp cppy convert advanced.cpp --py --ai -v
492
- ```
493
-
494
- The `--ai` flag enables intelligent conversion with:
495
- - Section-by-section analysis and processing
496
- - Automatic `--think2` context level
497
- - Comprehensive rulebase for precise conversions
498
- - pybind11 wrappers for Python features without C++ equivalents:
499
- - Generators -> callback pattern / py::iterator
500
- - Async/await -> std::async / std::future
501
- - Context managers -> RAII pattern
502
- - Duck typing -> templates with concepts
503
- - Reports API changes to user
504
- - Fallback to standard conversion if AI unavailable
505
-
506
- **Workaround Examples:**
507
- | Python Feature | C++ Workaround |
508
- |----------------|----------------|
509
- | `yield` | Callback pattern or py::iterator |
510
- | `async/await` | std::async + std::future |
511
- | `with` context | RAII ScopedResource class |
512
- | List comprehension | transform_to_vector template |
513
- | Dict comprehension | transform_to_map template |
514
- | Dynamic attributes | py::object |
515
-
516
- ### Analyze Code
517
-
518
- ```bash
519
- includecpp cppy analyze math.py # View structure
520
- includecpp cppy analyze utils.cpp --json # JSON output
521
- ```
522
-
523
- ### Type Mapping
524
-
525
- ```bash
526
- includecpp cppy types # Show conversion tables
527
- ```
528
-
529
- | Python | C++ |
530
- |--------|-----|
531
- | int | int |
532
- | float | double |
533
- | str | std::string |
534
- | bool | bool |
535
- | List[T] | std::vector<T> |
536
- | Dict[K,V] | std::unordered_map<K,V> |
537
- | Optional[T] | std::optional<T> |
538
- | Tuple[...] | std::tuple<...> |
539
-
540
- # Configuration
541
-
542
- ## cpp.proj
543
-
544
- ```json
545
- {
546
- "project": "MyProject",
547
- "include": "/include",
548
- "plugins": "/plugins",
549
- "compiler": {
550
- "standard": "c++17",
551
- "optimization": "O3"
552
- }
553
- }
554
- ```
555
-
556
- Options:
557
- - `project` - project name
558
- - `include` - C++ source directory
559
- - `plugins` - plugin file directory
560
- - `compiler.standard` - C++ standard (c++11, c++14, c++17, c++20)
561
- - `compiler.optimization` - optimization level (O0, O1, O2, O3)
562
-
563
- # Requirements
564
-
565
- - Python 3.8+
566
- - C++ compiler (g++, clang++, MSVC)
567
- - pybind11 (installed automatically)
568
- - CMake (for build generation)
569
-
570
- # Experimental Features
571
-
572
- The following features are **experimental** and may contain bugs:
573
-
574
- - `includecpp ai` - AI-powered code assistance
575
- - `includecpp cppy` - Python to C++ code conversion
576
-
577
- These commands are **hidden by default**. To enable them:
578
-
579
- ```bash
580
- includecpp settings
581
- ```
582
-
583
- Then check **"Enable Experimental Features"** and save.
584
-
585
- **Warning:** Experimental features are under active development and may:
586
- - Produce incorrect output
587
- - Have breaking changes between versions
588
- - Be removed or significantly changed
589
-
590
- Use at your own discretion. Report issues at: https://github.com/liliassg/IncludeCPP/issues
591
-
592
- # CSSL - C-Style Scripting Language
593
-
594
- IncludeCPP includes CSSL, a scripting language with advanced data manipulation features.
595
-
596
- ## Basic Usage
597
-
598
- ```python
599
- from includecpp import CSSL
600
-
601
- # Execute CSSL code
602
- CSSL.exec('''
603
- printl("Hello from CSSL!");
604
-
605
- int x = 10;
606
- for (i in range(0, 5)) {
607
- x = x + i;
608
- }
609
- printl(x);
610
- ''')
611
-
612
- # Execute with arguments
613
- result = CSSL.exec('''
614
- int a = parameter.get(0);
615
- int b = parameter.get(1);
616
- parameter.return(a + b);
617
- ''', 5, 3)
618
- print(result) # 8
619
- ```
620
-
621
- ## Live Object Sharing
622
-
623
- Share Python objects with CSSL scripts. Changes in CSSL reflect back to Python:
624
-
625
- ```python
626
- from includecpp import CSSL
627
-
628
- class Counter:
629
- def __init__(self):
630
- self.value = 100
631
-
632
- counter = Counter()
633
- cssl = CSSL.CsslLang()
634
- cssl.share(counter, "cnt")
635
-
636
- # Modify in CSSL - changes reflect in Python!
637
- cssl.exec('''
638
- $cnt.value = $cnt.value - 10;
639
- printl($cnt.value); // 90
640
- ''')
641
-
642
- print(counter.value) # 90 - Changed!
643
- ```
644
-
645
- ### Shared Object Syntax
646
-
647
- - `$name` - Access shared object
648
- - `$name.property` - Access/modify properties
649
- - `$name.method()` - Call methods
650
- - `delete("name")` - Remove shared object
651
-
652
- ## Data Types
653
-
654
- ```cssl
655
- // Basic types
656
- int x = 42;
657
- float pi = 3.14;
658
- string name = "CSSL";
659
- bool active = true;
660
-
661
- // Collections
662
- array<int> arr;
663
- arr.push(1);
664
- arr.push(2);
665
- printl(arr.length()); // 2
666
-
667
- vector<string> vec;
668
- vec.push("A");
669
- vec.push("B");
670
-
671
- stack<int> s;
672
- s.push(10);
673
- s.pop();
674
- ```
675
-
676
- ## Control Flow
677
-
678
- ```cssl
679
- // If/elif/else
680
- if (x > 10) {
681
- printl("big");
682
- } elif (x > 5) {
683
- printl("medium");
684
- } else {
685
- printl("small");
686
- }
687
-
688
- // For loops
689
- for (i in range(0, 10)) {
690
- printl(i);
691
- }
692
-
693
- for (i in range(0, 10, 2)) { // with step
694
- printl(i); // 0, 2, 4, 6, 8
695
- }
696
-
697
- // Foreach
698
- array<string> items;
699
- items.push("A");
700
- items.push("B");
701
- foreach (item in items) {
702
- printl(item);
703
- }
704
-
705
- // While
706
- int count = 0;
707
- while (count < 5) {
708
- printl(count);
709
- count = count + 1;
710
- }
711
- ```
712
-
713
- ## Functions
714
-
715
- ```cssl
716
- // Basic function
717
- void greet(string name) {
718
- printl("Hello, " + name + "!");
719
- }
720
-
721
- // Return value
722
- int add(int a, int b) {
723
- return a + b;
724
- }
725
-
726
- // Global variables
727
- global version = "1.0.0";
728
- printl(@version);
729
-
730
- // r@ syntax for global declaration
731
- r@myGlobal = "value";
732
- printl(@myGlobal);
733
- ```
734
-
735
- ## BruteForce Injection System
736
-
737
- CSSL's unique injection operators for data manipulation:
738
-
739
- ```cssl
740
- // <== Move data (replaces target)
741
- target <== source;
742
-
743
- // +<== Copy & add to target
744
- target +<== source;
745
-
746
- // -<== Move & remove from source
747
- target -<== source;
748
-
749
- // <<== Code infusion into functions
750
- myFunc() <<== {
751
- printl("Injected code!");
752
- };
753
-
754
- // +<<== Add code without replacing
755
- myFunc() +<<== {
756
- printl("Additional code!");
757
- };
758
- ```
759
-
760
- ## String Methods
761
-
762
- ```cssl
763
- string s = "Hello World";
764
-
765
- // Methods
766
- s.length(); // 11
767
- s.toUpper(); // "HELLO WORLD"
768
- s.toLower(); // "hello world"
769
- s.contains("World"); // true
770
- s.startsWith("Hello"); // true
771
- s.endsWith("World"); // true
772
- s.replace("World", "CSSL");
773
- s.split(" "); // ["Hello", "World"]
774
- s.trim(); // Remove whitespace
775
- s.substring(0, 5); // "Hello"
776
- ```
777
-
778
- ## CSSL Modules
779
-
780
- ```python
781
- # Create callable module
782
- module = CSSL.module('''
783
- string name = parameter.get(0);
784
- printl("Hello, " + name + "!");
785
- ''')
786
- module("World") # Prints: Hello, World!
787
-
788
- # Create module with functions
789
- math_mod = CSSL.makemodule('''
790
- int add(int a, int b) {
791
- return a + b;
792
- }
793
-
794
- int multiply(int a, int b) {
795
- return a * b;
796
- }
797
- ''')
798
- print(math_mod.add(2, 3)) # 5
799
- print(math_mod.multiply(4, 5)) # 20
800
- ```
801
-
802
- ## Inline Payloads
803
-
804
- ```python
805
- cssl = CSSL.CsslLang()
806
-
807
- # Register code as payload
808
- cssl.code("helpers", '''
809
- global version = "1.0.0";
810
- void log(string msg) {
811
- printl("[LOG] " + msg);
812
- }
813
- ''')
814
-
815
- # Use in CSSL
816
- cssl.exec('''
817
- payload("helpers");
818
- @log("Application started");
819
- printl(@version);
820
- ''')
821
- ```
822
-
823
- # Changelog
824
-
825
- ## v3.4.20
826
- - **Documentation:**
827
- - Added complete CSSL language documentation
828
- - Live object sharing with `$name` syntax
829
- - Data types, control flow, functions, injection system
830
- - String methods, modules, and inline payloads
831
-
832
- ## v3.4.19
833
- - **Critical Bug Fixes:**
834
- - Fixed generator raw string literal in parser.cpp (regex pattern with `)"` prematurely terminated)
835
- - Fixed shared object property writes inside loops not persisting to Python
836
- - Added member_access handling in flow operations for shared objects
837
-
838
- ## v3.4.18
839
- - **Bug Fix:**
840
- - Attempted fix for shared object loop writes (partially fixed)
841
-
842
- ## v3.4.17
843
- - **New Feature: Live Object Sharing**
844
- - `cssl.share(instance, name)` - Share Python objects with CSSL
845
- - `$name` syntax for accessing shared objects
846
- - Live bidirectional updates - changes in CSSL reflect in Python
847
- - `delete("name")` builtin for removing shared objects
848
- - Shared object metadata stored in `%APPDATA%/IncludeCPP/shared_objects/`
849
-
850
- ## v3.4.16
851
- - **CSSL Bug Fixes:**
852
- - Fixed `startsWith()` and `endsWith()` parser errors
853
-
854
- ## v3.4.15
855
- - **CSSL Enhancements:**
856
- - Added `elif` keyword support
857
- - Added `range(start, end, step)` with step parameter
858
- - Added `begin()` and `end()` methods to all collection types
859
- - Added `cssl.code(name, code)` for inline payload registration
860
-
861
- ## v3.4.2
862
- - **New Feature: `exec` Command**
863
- - Interactive REPL for quick code testing without creating files
864
- - `includecpp exec py` - Python REPL with IncludeCPP support
865
- - `includecpp exec cpp` - C++ REPL with auto-compilation
866
- - Auto-import modules: `includecpp exec py mymodule`
867
- - Auto-import from plugins: `includecpp exec py plugins/math.cp`
868
- - Import all modules: `includecpp exec py --all`
869
- - Enter code line by line, press ENTER on empty line to execute
870
-
871
- ## v3.4.1
872
- - **Bug Fixes:**
873
- - fix command: Fixed false positives for unused variables (sum, memory_) using word-boundary matching
874
- - CPPY: C++ reserved words (double, int, void, etc.) now properly escaped as Python identifiers
875
- - CPPY: C++ STL functions (accumulate, find, sort, reverse) properly converted to Python equivalents
876
- - CPPY: Member variables with trailing underscore (memory_) now get self. prefix
877
- - CPPY: Private class members now detected for self. prefix conversion
878
- - Plugin: Auto-detect header files from #include directives in source files
879
-
880
- ## v3.4.0
881
- - **CodeMaker Major Update:**
882
- - New Source node type with 8 connection ports for code generation
883
- - Smart code generation: Source nodes generate Python/Plugin files with all connected nodes included
884
- - Right-click on Source node: "Create Python" creates .py in project root
885
- - Right-click on Source node: "Create Plugin" creates .cp, .h, .cpp in plugins/ and include/
886
- - Code options hidden after file generation (prevents duplicates)
887
- - Enhanced description display with background rect in node body
888
- - Arrow key navigation to pan the canvas
889
- - New toolbar buttons: Align H, Align V, Auto-Arrange
890
- - Quick-add buttons: +Source, +Class, +Function
891
- - Properties Panel on the right side for editing selected nodes
892
- - Auto-arrange algorithm for grid layout
893
- - Align horizontal/vertical for selected nodes
894
- - **Bug Fixes:**
895
- - Changelog encoding fixes for Windows console
896
- - CPPY C++ keyword escaping (double, int, etc.)
897
- - CPPY C++ to Python syntax conversion improvements
898
- - CPPY self. prefix for member variables
899
- - Plugin auto-header detection from #include
900
-
901
- ## v3.3.21
902
- - **Encoding Fixes:**
903
- - Replaced Unicode arrow characters with ASCII in changelog (Windows console compatibility)
904
-
905
- ## v3.3.20
906
- - **Bug Fixes:**
907
- - Fixed `QPoint.toPoint()` AttributeError in rubber band selection
908
- - Added UTF-8 encoding to all file read/write operations for cross-platform compatibility
909
- - Fixed bare `except:` clauses to proper `except Exception:` in settings_ui.py
910
-
911
- ## v3.3.19
912
- - **PyQt6 Import Fix:**
913
- - Fixed silent import failure that caused "PyQt6 not installed" error even when installed
914
- - Moved `QUndoStack`, `QUndoCommand`, `QShortcut` from QtWidgets to QtGui (correct location in PyQt6)
915
-
916
- ## v3.3.18
917
- - **CodeMaker Visual Editor (Experimental):**
918
- - Complete rewrite of `project` command with professional-grade UI
919
- - 24 node types across 5 categories (Code Structures, Functions, Data, Organization, Flow)
920
- - Undo/redo system with full command history
921
- - Multi-selection with rubber band and Ctrl+Click
922
- - Copy/paste/duplicate with Ctrl+C/V/D shortcuts
923
- - Node grouping with Ctrl+G
924
- - Code generation for C++ (header/source) and Python
925
- - Search and filter nodes by name and type
926
- - Export to PNG/SVG with transparency support
927
- - Categorized right-click context menus
928
- - Toolbar with common actions
929
- - Cross-platform font detection (Windows/macOS/Linux)
930
- - DPI-aware scaling for high-resolution displays
931
- - **Experimental Feature Gating:**
932
- - `project` command now requires "Enable Experimental Features" in settings
933
- - Consistent gating with `ai` and `cppy` commands
934
-
935
- ## v3.3.16-3.3.17
936
- - **QPen Bug Fixes:**
937
- - Fixed 3 instances of `setPen(Qt.PenStyle.NoPen)` to `setPen(QPen(Qt.PenStyle.NoPen))`
938
- - Proper QPen construction for PyQt6 compatibility
939
-
940
- ## v3.3.15
941
- - **CPPY Converter Major Fixes:**
942
- - Functions returning container now get `std::vector<T>` return type (e.g., shuffle_list)
943
- - `max(items)` / `min(items)` now correctly uses `std::max_element` / `std::min_element`
944
- - Template element parameters (`value`, `item`) now use `const T&` instead of `double`
945
- - Explicit template instantiations now include correct return types and all parameters
946
- - Python docstrings now become C++ comments instead of dangling string literals
947
- - **Unicode Fallback System:**
948
- - AI progress indicators use ASCII fallbacks on Windows terminals
949
- - Fixed encoding errors in changelog display
950
-
951
- ## v3.3.14
952
- - **Experimental Features System:**
953
- - AI and CPPY commands now hidden by default
954
- - Enable via Settings UI: "Enable Experimental Features" checkbox
955
- - Warning about potential bugs documented in README
956
- - **Settings UI Improvements:**
957
- - Added scrollable content area to prevent layout squashing
958
- - New "Experimental" section with orange header
959
- - Better spacing and styling for all elements
960
- - Preserved existing config values on save
961
-
962
- ## v3.3.13
963
- - **Template Support for Generic Functions:**
964
- - Generic container parameters now generate proper C++ templates
965
- - `template<typename T> T getChoice(const std::vector<T>& choices)` instead of invalid `std::vector<auto>`
966
- - Automatic explicit template instantiations for int, double, std::string
967
- - **AI Conversion - No pybind11:**
968
- - AI no longer generates pybind11 code - IncludeCPP handles bindings automatically
969
- - Clean C++ output in `namespace includecpp`
970
- - User runs `includecpp plugin` separately to generate bindings
971
- - **AI Context - Dynamic README:**
972
- - AI now loads README.md dynamically for accurate IncludeCPP documentation
973
- - Better understanding of IncludeCPP workflow and patterns
974
-
975
- ## v3.3.12
976
- - **Smart Type Inference:**
977
- - Parameter types now inferred from common naming patterns (start/end -> int, name/path -> string, etc.)
978
- - Variable type tracking throughout conversion for accurate string detection
979
- - Loop variable types inferred from iterables (enumerate, for loops)
980
- - **String Conversion Fix:**
981
- - No more `std::to_string()` on already-string variables in f-strings
982
- - `_is_string_expr()` method for comprehensive string type detection
983
- - String variables detected by name, type tracking, and method calls
984
- - **AI Conversion Improvements:**
985
- - Explicit file extension enforcement (.cpp NOT .cp, .h NOT .hpp)
986
- - Better --no-h flag handling with clear AI instructions
987
- - AI can request clarification on unconvertible modules (tkinter, pygame, etc.)
988
- - User prompted for input when AI needs guidance
989
-
990
- ## v3.3.11
991
- - **CPPY Converter Improvements:**
992
- - Added `_safe_arg()` and `_safe_get()` for robust bounds checking on all args
993
- - Added comprehensive try-except handling in `_convert_expr()` with warnings
994
- - Improved type inference with empty container handling and exception safety
995
- - Complete string escaping: `\0`, `\f`, `\b`, `\a`, `\v` now properly escaped
996
- - **New Python Constructs:**
997
- - Dict comprehensions: `{k: v for k, v in items}` now converts to C++
998
- - Set comprehensions: `{x for x in items}` now converts to C++
999
- - Generator expressions: `(x for x in items)` now converts to vector
1000
- - Tuple unpacking: `a, b = func()` now uses C++17 structured bindings
1001
- - **AI Conversion Flags:**
1002
- - New `--think` flag for less context mode
1003
- - New `--think3` flag for maximum context mode
1004
- - New `--websearch` flag for web search in AI conversion
1005
- - Default: `--think2` mode (unchanged behavior)
1006
-
1007
- ## v3.3.10
1008
- - **CPPY Converter seeded RNG fixes:**
1009
- - Fixed `rng = random.Random(seed)` then `rng.randint()` - now properly tracks seeded RNG variables
1010
- - Fixed `random.choices(...)[0]` subscript - returns single element directly without `[0]`
1011
- - Seeded RNG methods (randint, uniform, choice, random) now use the tracked variable with proper C++ distributions
1012
-
1013
- ## v3.3.9
1014
- - **CPPY Converter fixes:**
1015
- - Added f-string (JoinedStr) support - f"text {expr}" now converts to string concatenation
1016
- - Fixed `random.Random(seed).method()` chained calls - now generates proper inline lambda with seeded RNG
1017
- - Fixed `random.choices(items, weights=weights)` keyword argument handling
1018
- - Improved string type detection in f-string expressions
1019
-
1020
- ## v3.3.8
1021
- - **Major rulebased converter improvements:**
1022
- - Added Python `random` module support (randint, uniform, choice, sample, shuffle, gauss, etc.)
1023
- - Added `os` module support (getcwd, path.join, path.exists, listdir, mkdir, etc.)
1024
- - Added `time` module support (sleep, time, perf_counter, monotonic)
1025
- - Added `sys` module support (exit, platform)
1026
- - Added `math` module support (sqrt, pow, sin, cos, log, etc.)
1027
- - Added `re` (regex) module support (match, search, sub, findall)
1028
- - Added `threading` module support (Thread, Lock, Semaphore, etc.)
1029
- - Added `collections` module support (deque, defaultdict, Counter)
1030
- - Added `pathlib.Path` support
1031
- - **Unconvertible code detection:**
1032
- - Automatically detects GUI frameworks (tkinter, PyQt, PySide, pygame) and other unconvertible modules
1033
- - Shows red warning with line numbers when unconvertible code is found
1034
- - New `--force` flag to convert anyway (with `/* UNCONVERTIBLE */` comments)
1035
- - Supports 30+ modules in detection (numpy, pandas, flask, django, etc.)
1036
- - Fixed duplicate file output in `cppy convert --ai`
1037
- - Plugin command now skips inline and underscore-prefixed functions
1038
-
1039
-
1040
- ---
1041
-
1042
- MIT License | v3.4.20 | [GitHub](https://github.com/liliassg/IncludeCPP)
1
+ Metadata-Version: 2.4
2
+ Name: IncludeCPP
3
+ Version: 3.7.26
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
+ Dynamic: author-email
31
+ Dynamic: home-page
32
+ Dynamic: license-file
33
+ Dynamic: requires-python
34
+
35
+ # IncludeCPP
36
+
37
+ Write C++ code, use it in Python. Auto-generates pybind11 bindings.
38
+
39
+ ```bash
40
+ pip install IncludeCPP
41
+ ```
42
+
43
+ # First Steps
44
+
45
+ ## Project Setup
46
+
47
+ ```bash
48
+ includecpp init
49
+ ```
50
+
51
+ Creates:
52
+ - `cpp.proj` - project configuration
53
+ - `include/` - your C++ source files
54
+ - `plugins/` - generated binding definitions
55
+
56
+ ## Write C++ Code
57
+
58
+ Put your code in `namespace includecpp`:
59
+
60
+ ```cpp
61
+ // include/fast_list.cpp
62
+ #include <vector>
63
+
64
+ namespace includecpp {
65
+
66
+ class FastList {
67
+ public:
68
+ void append(int val) { data.push_back(val); }
69
+ int get(int i) { return data[i]; }
70
+ private:
71
+ std::vector<int> data;
72
+ };
73
+
74
+ int add(int a, int b) { return a + b; }
75
+
76
+ } // namespace includecpp
77
+ ```
78
+
79
+ The parser only scans code inside `namespace includecpp`. Everything else is ignored.
80
+
81
+ ## Generate Bindings
82
+
83
+ ```bash
84
+ includecpp plugin fast_list include/fast_list.cpp
85
+ ```
86
+
87
+ This runs a C++ parser that:
88
+ 1. Scans your source files for classes, methods, functions
89
+ 2. Extracts signatures, return types, parameter names
90
+ 3. Generates `plugins/fast_list.cp` with binding instructions
91
+
92
+ ## Build
93
+
94
+ ```bash
95
+ includecpp rebuild
96
+ ```
97
+
98
+ Compiles your C++ into a Python extension module (`.pyd` on Windows, `.so` on Linux/Mac).
99
+
100
+ ## Use in Python
101
+
102
+ ```python
103
+ from includecpp import fast_list
104
+
105
+ my_list = fast_list.FastList()
106
+ my_list.append(42)
107
+ print(fast_list.add(1, 2)) # 3
108
+ ```
109
+
110
+ Alternative syntax:
111
+
112
+ ```python
113
+ from includecpp import CppApi
114
+
115
+ api = CppApi()
116
+ fast_list = api.include("fast_list")
117
+ ```
118
+
119
+ # How to Start
120
+
121
+ ## Minimal Example
122
+
123
+ ```bash
124
+ # 1. Create project
125
+ mkdir myproject && cd myproject
126
+ includecpp init
127
+
128
+ # 2. Write C++ (include/math.cpp)
129
+ cat > include/math.cpp << 'EOF'
130
+ namespace includecpp {
131
+ int square(int x) { return x * x; }
132
+ }
133
+ EOF
134
+
135
+ # 3. Generate plugin
136
+ includecpp plugin math include/math.cpp
137
+
138
+ # 4. Build
139
+ includecpp rebuild
140
+
141
+ # 5. Use
142
+ python -c "from includecpp import math; print(math.square(7))"
143
+ ```
144
+
145
+ ## Development Workflow
146
+
147
+ For active development, use `auto`:
148
+
149
+ ```bash
150
+ includecpp auto math
151
+ ```
152
+
153
+ This regenerates the `.cp` file from source and rebuilds in one command.
154
+
155
+ For fastest iteration:
156
+
157
+ ```bash
158
+ includecpp rebuild --fast
159
+ ```
160
+
161
+ Skips unchanged files. ~0.4s when nothing changed.
162
+
163
+ # How IncludeCPP Works
164
+
165
+ ## Architecture
166
+
167
+ ```
168
+ Your C++ Source Plugin File (.cp) Python Module
169
+ include/math.cpp ---> plugins/math.cp ---> math.cpXXX.pyd
170
+ ^ ^ ^
171
+ | | |
172
+ C++ parser Binding config pybind11 compiled
173
+ extracts API (editable) extension
174
+ ```
175
+
176
+ ## The Parser
177
+
178
+ The C++ parser (`parser.cpp`) runs as a compiled executable. It:
179
+
180
+ 1. Tokenizes your C++ source files
181
+ 2. Identifies the `namespace includecpp` block
182
+ 3. Extracts:
183
+ - Class names and inheritance
184
+ - Method signatures (name, return type, parameters)
185
+ - Function signatures
186
+ - Template instantiations
187
+ - Const/static qualifiers
188
+ 4. Outputs structured binding instructions to `.cp` files
189
+
190
+ ## Plugin Files (.cp)
191
+
192
+ The `.cp` format is a declarative binding specification:
193
+
194
+ ```
195
+ SOURCE(math.cpp) math
196
+
197
+ PUBLIC(
198
+ math CLASS(Calculator) {
199
+ CONSTRUCTOR()
200
+ CONSTRUCTOR(int)
201
+ METHOD(add)
202
+ METHOD_CONST(getValue)
203
+ FIELD(value)
204
+ }
205
+
206
+ math FUNC(square)
207
+ math TEMPLATE_FUNC(maximum) TYPES(int, float, double)
208
+ )
209
+ ```
210
+
211
+ Key directives:
212
+ - `SOURCE(file.cpp) module_name` - links source to module
213
+ - `PUBLIC(...)` - defines public bindings
214
+ - `CLASS(Name)` - expose a class
215
+ - `STRUCT(Name)` - expose a struct
216
+ - `FUNC(name)` - expose a free function
217
+ - `METHOD(name)` - expose a class method
218
+ - `METHOD_CONST(name, signature)` - for overloaded methods
219
+ - `TEMPLATE_FUNC(name) TYPES(...)` - instantiate template
220
+ - `CONSTRUCTOR(args)` - expose constructor
221
+ - `FIELD(name)` - expose member variable
222
+ - `DEPENDS(mod1, mod2)` - declare module dependencies
223
+
224
+ ## Build System
225
+
226
+ The build manager:
227
+
228
+ 1. Reads `cpp.proj` configuration
229
+ 2. Parses all `.cp` files in `plugins/`
230
+ 3. Generates pybind11 binding code
231
+ 4. Compiles using CMake with detected compiler (MSVC, GCC, Clang)
232
+ 5. Places output in `~/.includecpp/builds/` (not in your project)
233
+ 6. Creates a registry so Python can find modules
234
+
235
+ Caching layers:
236
+ - **Object files**: Only recompile changed `.cpp` files
237
+ - **Generator cache**: Compiler/CMake detection runs once
238
+ - **SHA256 hashes**: Skip unchanged modules entirely
239
+
240
+ # CLI Reference
241
+
242
+ Use `includecpp <command> --help` for details.
243
+
244
+ | Command | Description |
245
+ |---------|-------------|
246
+ | `init` | Create project structure |
247
+ | `plugin <name> <files>` | Generate .cp from C++ sources |
248
+ | `auto <plugin>` | Regenerate .cp and rebuild |
249
+ | `auto --all` | Regenerate and rebuild all plugins |
250
+ | `auto --all -x <name>` | All plugins except specified |
251
+ | `fix <module>` | Analyze C++ code for issues |
252
+ | `fix --all` | Analyze all modules |
253
+ | `fix --undo` | Revert last fix changes |
254
+ | `fix --ai <module>` | AI-enhanced code analysis |
255
+ | `ai key <key>` | Set OpenAI API key |
256
+ | `ai enable` | Enable AI features |
257
+ | `ai disable` | Disable AI features |
258
+ | `ai model --list` | List available models |
259
+ | `ai model set <name>` | Set active model |
260
+ | `ai --info` | Show AI configuration and usage |
261
+ | `ai optimize <module>` | AI code optimization |
262
+ | `ai optimize --agent "<task>"` | Custom AI task |
263
+ | `ai ask "<question>"` | Ask about project with full context |
264
+ | `ai ask "<question>" <module>` | Ask about specific module |
265
+ | `ai edit "<task>"` | Edit code with AI assistance |
266
+ | `ai edit "<task>" --think2` | Thorough edit mode |
267
+ | `ai undo` | Restore files after AI changes |
268
+ | `rebuild` / `build` | Compile all modules |
269
+ | `get <module>` | Show module API (classes, methods, functions) |
270
+ | `install <name>` | Install community module |
271
+ | `update` | Update IncludeCPP |
272
+ | `bug` | Report an issue |
273
+ | `--doc` | Show documentation |
274
+ | `--changelog` | Show latest version changelog |
275
+ | `cppy convert <files> --cpp` | Convert Python to C++ |
276
+ | `cppy convert <files> --py` | Convert C++ to Python |
277
+ | `cppy convert <files> --cpp --no-h` | Convert without header |
278
+ | `cppy convert <files> --cpp --ai` | AI-assisted conversion |
279
+ | `cppy analyze <files>` | Analyze code structure |
280
+ | `cppy types` | Show type mapping tables |
281
+
282
+ ## Build Flags
283
+
284
+ ```bash
285
+ includecpp rebuild # Standard build
286
+ includecpp rebuild --clean # Full rebuild, clear caches
287
+ includecpp rebuild --fast # Fast incremental (~0.4s if unchanged)
288
+ includecpp rebuild --verbose # Show compiler output
289
+ includecpp rebuild -m crypto # Build specific module only
290
+ includecpp rebuild -j 8 # Use 8 parallel jobs
291
+ includecpp rebuild --keep # Keep generator between builds
292
+ includecpp rebuild --no-incremental # Force full recompilation
293
+ includecpp rebuild --this # Build current directory as module
294
+ ```
295
+
296
+ ## Fast Mode
297
+
298
+ `--fast` enables object file caching:
299
+
300
+ | Scenario | Time |
301
+ |----------|------|
302
+ | No changes | ~0.4s |
303
+ | Source changed | ~5-10s |
304
+ | Full rebuild | ~30s |
305
+
306
+ Clear caches with `--clean`.
307
+
308
+ ## Incompatible Flag Combinations
309
+
310
+ | Flags | Reason |
311
+ |-------|--------|
312
+ | `--fast` + `--no-incremental` | Fast mode requires incremental |
313
+ | `--fast` + `--clean` | Fast uses caches, clean deletes them |
314
+ | `--fast` + `--this` | Not supported together |
315
+ | `--incremental` + `--no-incremental` | Contradictory |
316
+
317
+ # Advanced Features
318
+
319
+ ## AI Integration
320
+
321
+ IncludeCPP integrates with OpenAI for intelligent code analysis and optimization.
322
+
323
+ ### Setup
324
+
325
+ ```bash
326
+ includecpp ai key sk-your-api-key-here
327
+ includecpp ai enable
328
+ ```
329
+
330
+ ### Available Models
331
+
332
+ ```bash
333
+ includecpp ai model --list
334
+ ```
335
+
336
+ - `gpt-5` (default) - 256k context
337
+ - `gpt-5-nano` - 32k context, fast
338
+ - `gpt-4o` - 128k context
339
+ - `gpt-4-turbo` - 128k context
340
+ - `gpt-3.5-turbo` - 16k context
341
+
342
+ ### AI-Enhanced Fix
343
+
344
+ ```bash
345
+ includecpp fix --ai mymodule
346
+ includecpp fix --ai --all
347
+ ```
348
+
349
+ Sends source files to AI for analysis, suggests improvements while preserving all existing functions.
350
+
351
+ ### AI Optimize
352
+
353
+ ```bash
354
+ includecpp ai optimize mymodule # Optimize module sources
355
+ includecpp ai optimize --file src/utils.cpp # Optimize specific files
356
+ includecpp ai optimize --agent mymodule "add SIMD" # Custom task
357
+ ```
358
+
359
+ ### AI Ask
360
+
361
+ Ask questions about your project with full context awareness:
362
+
363
+ ```bash
364
+ includecpp ai ask "where is collision detection?" # Search all modules
365
+ includecpp ai ask "how does chunk generation work?" chunk_utils # Specific module
366
+ includecpp ai ask "explain the biome system" --file include/biomes.cpp
367
+ includecpp ai ask "list all public methods" --all -x tests # All except tests
368
+ ```
369
+
370
+ Supports: module name, --file, --all, -x/--exclude
371
+
372
+ ### AI Edit
373
+
374
+ Edit code with AI assistance:
375
+
376
+ ```bash
377
+ includecpp ai edit "add logging to all methods" collision
378
+ includecpp ai edit "optimize the loop" --file include/utils.cpp
379
+ includecpp ai edit "add error handling" --all --think2 # Thorough mode
380
+ ```
381
+
382
+ Flags:
383
+ - `--file` - specific files
384
+ - `--all` - all modules
385
+ - `-x/--exclude` - exclude modules
386
+ - `--think2` - thorough analysis (more tokens)
387
+
388
+ ### AI Generate (Super Assistant)
389
+
390
+ The most powerful AI command - a full assistant with file operations and command execution.
391
+
392
+ ```bash
393
+ # Basic usage
394
+ includecpp ai generate "add error handling to all functions" --file mymodule.cp
395
+
396
+ # Create new module from scratch
397
+ includecpp ai generate "fast SIMD math library" --t-new-module simd_math
398
+
399
+ # Planning mode (search, analyze, then execute)
400
+ includecpp ai generate "refactor for better performance" --t-plan --think2
401
+
402
+ # With Python file (auto-detect module usage)
403
+ includecpp ai generate "update api methods" --file mymod.cp --python main.py
404
+
405
+ # Full context mode
406
+ includecpp ai generate "comprehensive optimization" --t-max-context --think3
407
+ ```
408
+
409
+ **Flags:**
410
+ | Flag | Description |
411
+ |------|-------------|
412
+ | `--file <path>` | Add files (multiple allowed). .cp files auto-resolve to source |
413
+ | `--think/2/3` | Extended context and planning |
414
+ | `--websearch` | Enable web research |
415
+ | `--t-max-context` | No context reduction |
416
+ | `--t-plan` | Search/grep before executing |
417
+ | `--t-new-module <name>` | Create new module (cpp + plugin + build) |
418
+ | `--python <file.py>` | Include Python file, auto-detect modules |
419
+ | `--confirm` | Skip confirmations |
420
+
421
+ ### AI Tools
422
+
423
+ List available tools for the generate command:
424
+
425
+ ```bash
426
+ includecpp ai tools
427
+ ```
428
+
429
+ Available tools: READ_FILE, WRITE_FILE, EDIT_FILE, DELETE_FILE, CREATE_FOLDER, LIST_FOLDER, SEARCH_FILES, GREP, RUN_CMD, INCLUDECPP_CMD
430
+
431
+ ### Build Error Analysis
432
+
433
+ When AI is enabled and `rebuild` fails, the build error is automatically analyzed:
434
+ - Root cause identification
435
+ - Code fix suggestions
436
+ - Prevention tips
437
+
438
+ ### Configuration
439
+
440
+ ```bash
441
+ includecpp ai --info # Show status, model, usage stats
442
+ includecpp ai disable # Disable without removing key
443
+ ```
444
+
445
+ API key stored in `~/.includecpp/.secret`.
446
+
447
+ ## Overloaded Methods
448
+
449
+ Specify the signature to disambiguate:
450
+
451
+ ```
452
+ MODULE CLASS(Circle) {
453
+ METHOD_CONST(intersects, const Circle&)
454
+ METHOD_CONST(intersects, const Rect&)
455
+ }
456
+ ```
457
+
458
+ ## Template Instantiation
459
+
460
+ ```
461
+ MODULE TEMPLATE_FUNC(maximum) TYPES(int, float, double)
462
+
463
+ MODULE STRUCT(Point) TYPES(int, float) {
464
+ FIELD(x)
465
+ FIELD(y)
466
+ }
467
+ ```
468
+
469
+ Generates `maximum_int`, `maximum_float`, `maximum_double` and `Point_int`, `Point_float`.
470
+
471
+ ## Module Dependencies
472
+
473
+ ```
474
+ DEPENDS(math_utils, geometry)
475
+ ```
476
+
477
+ Ensures dependent modules build first.
478
+
479
+ ## VSCode IntelliSense
480
+
481
+ Generates `.pyi` stub files for autocomplete. Enable in `cpp.proj`:
482
+
483
+ ```json
484
+ {
485
+ "CPI-IntelliSense": true
486
+ }
487
+ ```
488
+
489
+ ## CPPY Code Conversion
490
+
491
+ Convert code between Python and C++ with full support for classes, functions, and type hints.
492
+
493
+ ### Python to C++
494
+
495
+ ```bash
496
+ includecpp cppy convert math_utils.py --cpp
497
+ includecpp cppy convert data.py --cpp --no-h # Skip header
498
+ includecpp cppy convert src/*.py --cpp -o include/
499
+ ```
500
+
501
+ Converts Python code to optimized C++ with:
502
+ - Type hints mapped to C++ types (int, str -> std::string, List -> std::vector)
503
+ - Classes with constructors, methods, fields
504
+ - Functions with proper signatures
505
+ - List comprehensions to STL algorithms
506
+ - Exception handling to try/catch
507
+
508
+ ### C++ to Python
509
+
510
+ ```bash
511
+ includecpp cppy convert utils.cpp --py
512
+ includecpp cppy convert mymodule.cp --py # Auto-resolve SOURCE()
513
+ ```
514
+
515
+ Converts C++ to Python with:
516
+ - STL types mapped to Python equivalents
517
+ - Classes with type hints
518
+ - Methods become class methods with self
519
+ - Structs become dataclasses
520
+
521
+ ### AI-Assisted Conversion
522
+
523
+ ```bash
524
+ includecpp cppy convert complex_lib.py --cpp --ai
525
+ includecpp cppy convert advanced.cpp --py --ai -v
526
+ ```
527
+
528
+ The `--ai` flag enables intelligent conversion with:
529
+ - Section-by-section analysis and processing
530
+ - Automatic `--think2` context level
531
+ - Comprehensive rulebase for precise conversions
532
+ - pybind11 wrappers for Python features without C++ equivalents:
533
+ - Generators -> callback pattern / py::iterator
534
+ - Async/await -> std::async / std::future
535
+ - Context managers -> RAII pattern
536
+ - Duck typing -> templates with concepts
537
+ - Reports API changes to user
538
+ - Fallback to standard conversion if AI unavailable
539
+
540
+ **Workaround Examples:**
541
+ | Python Feature | C++ Workaround |
542
+ |----------------|----------------|
543
+ | `yield` | Callback pattern or py::iterator |
544
+ | `async/await` | std::async + std::future |
545
+ | `with` context | RAII ScopedResource class |
546
+ | List comprehension | transform_to_vector template |
547
+ | Dict comprehension | transform_to_map template |
548
+ | Dynamic attributes | py::object |
549
+
550
+ ### Analyze Code
551
+
552
+ ```bash
553
+ includecpp cppy analyze math.py # View structure
554
+ includecpp cppy analyze utils.cpp --json # JSON output
555
+ ```
556
+
557
+ ### Type Mapping
558
+
559
+ ```bash
560
+ includecpp cppy types # Show conversion tables
561
+ ```
562
+
563
+ | Python | C++ |
564
+ |--------|-----|
565
+ | int | int |
566
+ | float | double |
567
+ | str | std::string |
568
+ | bool | bool |
569
+ | List[T] | std::vector<T> |
570
+ | Dict[K,V] | std::unordered_map<K,V> |
571
+ | Optional[T] | std::optional<T> |
572
+ | Tuple[...] | std::tuple<...> |
573
+
574
+ # Configuration
575
+
576
+ ## cpp.proj
577
+
578
+ ```json
579
+ {
580
+ "project": "MyProject",
581
+ "include": "/include",
582
+ "plugins": "/plugins",
583
+ "compiler": {
584
+ "standard": "c++17",
585
+ "optimization": "O3"
586
+ }
587
+ }
588
+ ```
589
+
590
+ Options:
591
+ - `project` - project name
592
+ - `include` - C++ source directory
593
+ - `plugins` - plugin file directory
594
+ - `compiler.standard` - C++ standard (c++11, c++14, c++17, c++20)
595
+ - `compiler.optimization` - optimization level (O0, O1, O2, O3)
596
+
597
+ # Requirements
598
+
599
+ - Python 3.8+
600
+ - C++ compiler (g++, clang++, MSVC)
601
+ - pybind11 (installed automatically)
602
+ - CMake (for build generation)
603
+
604
+ # Experimental Features
605
+
606
+ The following features are **experimental** and may contain bugs:
607
+
608
+ - `includecpp ai` - AI-powered code assistance
609
+ - `includecpp cppy` - Python to C++ code conversion
610
+
611
+ These commands are **hidden by default**. To enable them:
612
+
613
+ ```bash
614
+ includecpp settings
615
+ ```
616
+
617
+ Then check **"Enable Experimental Features"** and save.
618
+
619
+ **Warning:** Experimental features are under active development and may:
620
+ - Produce incorrect output
621
+ - Have breaking changes between versions
622
+ - Be removed or significantly changed
623
+
624
+ Use at your own discretion. Report issues at: https://github.com/liliassg/IncludeCPP/issues
625
+
626
+ # CSSL - C-Style Scripting Language
627
+
628
+ IncludeCPP includes CSSL, a scripting language with advanced data manipulation features.
629
+
630
+ ## Basic Usage
631
+
632
+ ```python
633
+ from includecpp import CSSL
634
+
635
+ # Execute CSSL code
636
+ CSSL.exec('''
637
+ printl("Hello from CSSL!");
638
+
639
+ int x = 10;
640
+ for (i in range(0, 5)) {
641
+ x = x + i;
642
+ }
643
+ printl(x);
644
+ ''')
645
+
646
+ # Execute with arguments
647
+ result = CSSL.exec('''
648
+ int a = parameter.get(0);
649
+ int b = parameter.get(1);
650
+ parameter.return(a + b);
651
+ ''', 5, 3)
652
+ print(result) # 8
653
+ ```
654
+
655
+ ## Live Object Sharing
656
+
657
+ Share Python objects with CSSL scripts. Changes in CSSL reflect back to Python:
658
+
659
+ ```python
660
+ from includecpp import CSSL
661
+
662
+ class Counter:
663
+ def __init__(self):
664
+ self.value = 100
665
+
666
+ counter = Counter()
667
+ cssl = CSSL.CsslLang()
668
+ cssl.share(counter, "cnt")
669
+
670
+ # Modify in CSSL - changes reflect in Python!
671
+ cssl.exec('''
672
+ $cnt.value = $cnt.value - 10;
673
+ printl($cnt.value); // 90
674
+ ''')
675
+
676
+ print(counter.value) # 90 - Changed!
677
+ ```
678
+
679
+ ### Shared Object Syntax
680
+
681
+ - `$name` - Access shared object
682
+ - `$name.property` - Access/modify properties
683
+ - `$name.method()` - Call methods
684
+ - `delete("name")` - Remove shared object
685
+
686
+ ## Data Types
687
+
688
+ ```cssl
689
+ // Basic types
690
+ int x = 42;
691
+ float pi = 3.14;
692
+ string name = "CSSL";
693
+ bool active = true;
694
+
695
+ // Collections
696
+ array<int> arr;
697
+ arr.push(1);
698
+ arr.push(2);
699
+ printl(arr.length()); // 2
700
+
701
+ vector<string> vec;
702
+ vec.push("A");
703
+ vec.push("B");
704
+
705
+ stack<int> s;
706
+ s.push(10);
707
+ s.pop();
708
+ ```
709
+
710
+ ## Control Flow
711
+
712
+ ```cssl
713
+ // If/elif/else
714
+ if (x > 10) {
715
+ printl("big");
716
+ } elif (x > 5) {
717
+ printl("medium");
718
+ } else {
719
+ printl("small");
720
+ }
721
+
722
+ // For loops
723
+ for (i in range(0, 10)) {
724
+ printl(i);
725
+ }
726
+
727
+ for (i in range(0, 10, 2)) { // with step
728
+ printl(i); // 0, 2, 4, 6, 8
729
+ }
730
+
731
+ // Foreach
732
+ array<string> items;
733
+ items.push("A");
734
+ items.push("B");
735
+ foreach (item in items) {
736
+ printl(item);
737
+ }
738
+
739
+ // While
740
+ int count = 0;
741
+ while (count < 5) {
742
+ printl(count);
743
+ count = count + 1;
744
+ }
745
+ ```
746
+
747
+ ## Functions
748
+
749
+ ```cssl
750
+ // Basic function
751
+ void greet(string name) {
752
+ printl("Hello, " + name + "!");
753
+ }
754
+
755
+ // Return value
756
+ int add(int a, int b) {
757
+ return a + b;
758
+ }
759
+
760
+ // Global variables
761
+ global version = "1.0.0";
762
+ printl(@version);
763
+
764
+ // r@ syntax for global declaration
765
+ r@myGlobal = "value";
766
+ printl(@myGlobal);
767
+ ```
768
+
769
+ ## BruteForce Injection System
770
+
771
+ CSSL's unique injection operators for data manipulation:
772
+
773
+ ```cssl
774
+ // <== Move data (replaces target)
775
+ target <== source;
776
+
777
+ // +<== Copy & add to target
778
+ target +<== source;
779
+
780
+ // -<== Move & remove from source
781
+ target -<== source;
782
+
783
+ // <<== Code infusion into functions
784
+ myFunc() <<== {
785
+ printl("Injected code!");
786
+ };
787
+
788
+ // +<<== Add code without replacing
789
+ myFunc() +<<== {
790
+ printl("Additional code!");
791
+ };
792
+ ```
793
+
794
+ ## String Methods
795
+
796
+ ```cssl
797
+ string s = "Hello World";
798
+
799
+ // Methods
800
+ s.length(); // 11
801
+ s.toUpper(); // "HELLO WORLD"
802
+ s.toLower(); // "hello world"
803
+ s.contains("World"); // true
804
+ s.startsWith("Hello"); // true
805
+ s.endsWith("World"); // true
806
+ s.replace("World", "CSSL");
807
+ s.split(" "); // ["Hello", "World"]
808
+ s.trim(); // Remove whitespace
809
+ s.substring(0, 5); // "Hello"
810
+ ```
811
+
812
+ ## CSSL Modules
813
+
814
+ ```python
815
+ # Create callable module
816
+ module = CSSL.module('''
817
+ string name = parameter.get(0);
818
+ printl("Hello, " + name + "!");
819
+ ''')
820
+ module("World") # Prints: Hello, World!
821
+
822
+ # Create module with functions
823
+ math_mod = CSSL.makemodule('''
824
+ int add(int a, int b) {
825
+ return a + b;
826
+ }
827
+
828
+ int multiply(int a, int b) {
829
+ return a * b;
830
+ }
831
+ ''')
832
+ print(math_mod.add(2, 3)) # 5
833
+ print(math_mod.multiply(4, 5)) # 20
834
+ ```
835
+
836
+ ## Inline Payloads
837
+
838
+ ```python
839
+ cssl = CSSL.CsslLang()
840
+
841
+ # Register code as payload
842
+ cssl.script(<name>, "helpers", '''
843
+ global version = "1.0.0";
844
+ void log(string msg) {
845
+ printl("[LOG] " + msg);
846
+ }
847
+ ''')
848
+
849
+ # Use in CSSL
850
+ cssl.run('''
851
+ payload("<name>"); // use module you declared in cssl.script(<name>, ...)
852
+ @log("Application started");
853
+ printl(@version);
854
+ ''')
855
+ ```