IncludeCPP 4.2.2__py3-none-any.whl → 4.5.2__py3-none-any.whl

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