IncludeCPP 4.0.2__py3-none-any.whl → 4.2.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.
@@ -0,0 +1,593 @@
1
+ # IncludeCPP Documentation
2
+
3
+ Version 4.2.0 | C++ Performance in Python, Zero Hassle
4
+
5
+ ---
6
+
7
+ ## Overview
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
+ ```
14
+
15
+ ---
16
+
17
+ ## Project Setup
18
+
19
+ ### Initialize Project
20
+
21
+ ```bash
22
+ includecpp init
23
+ ```
24
+
25
+ Creates:
26
+ - `cpp.proj` - project configuration
27
+ - `include/` - C++ source files
28
+ - `plugins/` - generated binding definitions
29
+
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
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Writing C++ Code
46
+
47
+ All C++ code must be in `namespace includecpp`:
48
+
49
+ ```cpp
50
+ // include/math.cpp
51
+ #include <vector>
52
+
53
+ namespace includecpp {
54
+
55
+ class Calculator {
56
+ public:
57
+ int add(int a, int b) { return a + b; }
58
+ int multiply(int a, int b) { return a * b; }
59
+ private:
60
+ int memory = 0;
61
+ };
62
+
63
+ int square(int x) { return x * x; }
64
+
65
+ } // namespace includecpp
66
+ ```
67
+
68
+ The parser only scans code inside `namespace includecpp`. Everything else is ignored.
69
+
70
+ ---
71
+
72
+ ## Generate Bindings
73
+
74
+ Create a plugin file from C++ source:
75
+
76
+ ```bash
77
+ includecpp plugin math include/math.cpp
78
+ ```
79
+
80
+ This creates `plugins/math.cp` with binding instructions.
81
+
82
+ ### Plugin File Format
83
+
84
+ ```
85
+ SOURCE(math.cpp) math
86
+
87
+ PUBLIC(
88
+ math CLASS(Calculator) {
89
+ CONSTRUCTOR()
90
+ METHOD(add)
91
+ METHOD(multiply)
92
+ }
93
+
94
+ math FUNC(square)
95
+ )
96
+ ```
97
+
98
+ ### Key Directives
99
+
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 |
111
+
112
+ ---
113
+
114
+ ## Build
115
+
116
+ ```bash
117
+ includecpp rebuild
118
+ ```
119
+
120
+ Compiles C++ into Python extension (`.pyd` on Windows, `.so` on Linux/Mac).
121
+
122
+ ### Build Flags
123
+
124
+ ```bash
125
+ includecpp rebuild # Standard build
126
+ includecpp rebuild --clean # Full rebuild, clear caches
127
+ includecpp rebuild --fast # Fast incremental (~0.4s if unchanged)
128
+ includecpp rebuild --verbose # Show compiler output
129
+ includecpp rebuild -m crypto # Build specific module only
130
+ includecpp rebuild -j 8 # Use 8 parallel jobs
131
+ ```
132
+
133
+ ### Build Times
134
+
135
+ | Scenario | Time |
136
+ |----------|------|
137
+ | No changes (--fast) | ~0.4s |
138
+ | Source changed | ~5-10s |
139
+ | Full rebuild | ~30s |
140
+
141
+ ---
142
+
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
167
+
168
+ ### Auto Command
169
+
170
+ For active development:
171
+
172
+ ```bash
173
+ includecpp auto math
174
+ ```
175
+
176
+ Regenerates `.cp` file from source and rebuilds in one command.
177
+
178
+ ### Rebuild All
179
+
180
+ ```bash
181
+ includecpp auto --all
182
+ includecpp auto --all -x tests # All except tests
183
+ ```
184
+
185
+ ---
186
+
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
204
+
205
+ ### Overloaded Methods
206
+
207
+ ```
208
+ MODULE CLASS(Circle) {
209
+ METHOD_CONST(intersects, const Circle&)
210
+ METHOD_CONST(intersects, const Rect&)
211
+ }
212
+ ```
213
+
214
+ ### Template Instantiation
215
+
216
+ ```
217
+ MODULE TEMPLATE_FUNC(maximum) TYPES(int, float, double)
218
+ ```
219
+
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.
229
+
230
+ ---
231
+
232
+ ## Configuration
233
+
234
+ ### cpp.proj
235
+
236
+ ```json
237
+ {
238
+ "project": "MyProject",
239
+ "include": "/include",
240
+ "plugins": "/plugins",
241
+ "compiler": {
242
+ "standard": "c++17",
243
+ "optimization": "O3"
244
+ }
245
+ }
246
+ ```
247
+
248
+ ### Options
249
+
250
+ | Option | Description |
251
+ |--------|-------------|
252
+ | `project` | Project name |
253
+ | `include` | C++ source directory |
254
+ | `plugins` | Plugin file directory |
255
+ | `compiler.standard` | C++ standard (c++11/14/17/20) |
256
+ | `compiler.optimization` | Optimization level (O0-O3) |
257
+
258
+ ---
259
+
260
+ ## CSSL Scripting
261
+
262
+ IncludeCPP includes CSSL (C-Style Scripting Language) for runtime scripting.
263
+
264
+ ### Basic Usage
265
+
266
+ ```python
267
+ from includecpp import CSSL
268
+
269
+ CSSL.run('''
270
+ printl("Hello from CSSL!");
271
+
272
+ int x = 10;
273
+ for (i in range(0, 5)) {
274
+ x = x + i;
275
+ }
276
+ printl(x);
277
+ ''')
278
+ ```
279
+
280
+ ### Parameters and Return
281
+
282
+ ```python
283
+ result = CSSL.run('''
284
+ int a = parameter.get(0);
285
+ int b = parameter.get(1);
286
+ parameter.return(a + b);
287
+ ''', 5, 3)
288
+
289
+ print(result) # 8
290
+ ```
291
+
292
+ ### Shared Objects
293
+
294
+ Share Python objects with CSSL:
295
+
296
+ ```python
297
+ class Counter:
298
+ def __init__(self):
299
+ self.value = 100
300
+
301
+ counter = Counter()
302
+ cssl = CSSL.CsslLang()
303
+ cssl.share(counter, "cnt")
304
+
305
+ cssl.run('''
306
+ $cnt.value = $cnt.value - 10;
307
+ printl($cnt.value); // 90
308
+ ''')
309
+
310
+ print(counter.value) # 90 - Changed!
311
+ ```
312
+
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
327
+
328
+ ```cssl
329
+ int x = 42;
330
+ float pi = 3.14;
331
+ string name = "CSSL";
332
+ bool active = true;
333
+ dynamic any = "flexible";
334
+ ```
335
+
336
+ ### Collections
337
+
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
+ list items = [1, 2, 3];
347
+ dict data = {"a": 1};
348
+ ```
349
+
350
+ ---
351
+
352
+ ## CSSL Control Flow
353
+
354
+ ```cssl
355
+ // If/elif/else
356
+ if (x > 10) {
357
+ printl("big");
358
+ } elif (x > 5) {
359
+ printl("medium");
360
+ } else {
361
+ printl("small");
362
+ }
363
+
364
+ // For loop
365
+ for (i in range(0, 10)) {
366
+ printl(i);
367
+ }
368
+
369
+ // Foreach
370
+ foreach (item in items) {
371
+ printl(item);
372
+ }
373
+
374
+ // While
375
+ while (count < 5) {
376
+ count = count + 1;
377
+ }
378
+ ```
379
+
380
+ ---
381
+
382
+ ## CSSL Functions
383
+
384
+ ```cssl
385
+ // Basic function
386
+ void greet(string name) {
387
+ printl("Hello, " + name + "!");
388
+ }
389
+
390
+ // Return value
391
+ int add(int a, int b) {
392
+ return a + b;
393
+ }
394
+
395
+ // Typed function (C++ style)
396
+ int multiply(int a, int b) {
397
+ return a * b;
398
+ }
399
+ ```
400
+
401
+ ---
402
+
403
+ ## CSSL Classes
404
+
405
+ ```cssl
406
+ class Person {
407
+ string name;
408
+ int age;
409
+
410
+ constr Person(string n, int a) {
411
+ this->name = n;
412
+ this->age = a;
413
+ }
414
+
415
+ void greet() {
416
+ printl("I am " + this->name);
417
+ }
418
+ }
419
+
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
+ }
435
+ ```
436
+
437
+ ---
438
+
439
+ ## CSSL Injection Operators
440
+
441
+ ### Data Movement
442
+
443
+ ```cssl
444
+ target <== source; // Move data (replace)
445
+ target +<== source; // Copy & add
446
+ target -<== source; // Move & remove from source
447
+ ```
448
+
449
+ ### Code Infusion
450
+
451
+ ```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
487
+ ```
488
+
489
+ ---
490
+
491
+ ## Pythonize CSSL Classes
492
+
493
+ Return CSSL classes to Python:
494
+
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
538
+
539
+ ```bash
540
+ includecpp ai key sk-your-api-key
541
+ includecpp ai enable
542
+ ```
543
+
544
+ ### Commands
545
+
546
+ ```bash
547
+ includecpp ai ask "where is collision detection?"
548
+ includecpp ai edit "add logging" --file utils.cpp
549
+ includecpp ai optimize mymodule
550
+ includecpp fix --ai mymodule
551
+ ```
552
+
553
+ ---
554
+
555
+ ## CPPY Code Conversion
556
+
557
+ ### Python to C++
558
+
559
+ ```bash
560
+ includecpp cppy convert math.py --cpp
561
+ ```
562
+
563
+ ### C++ to Python
564
+
565
+ ```bash
566
+ 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
593
+ ```
includecpp/__init__.py CHANGED
@@ -2,7 +2,7 @@ from .core.cpp_api import CppApi
2
2
  from .core import cssl_bridge as CSSL
3
3
  import warnings
4
4
 
5
- __version__ = "4.0.2"
5
+ __version__ = "4.2.2"
6
6
  __all__ = ["CppApi", "CSSL"]
7
7
 
8
8
  # Module-level cache for C++ modules
includecpp/__init__.pyi CHANGED
@@ -147,7 +147,10 @@ __version__: str
147
147
  # Dynamic module access via: from includecpp import <module_name>
148
148
  # Auto-generated module declarations
149
149
  # These allow: from includecpp import <module_name>
150
- # (Run 'includecpp rebuild' to generate declarations for your modules)
150
+ fast_list: Fast_listModuleWrapper
151
+ game_math: Game_mathModuleWrapper
152
+ solar_system: Solar_systemModuleWrapper
153
+ templates: TemplatesModuleWrapper
151
154
 
152
155
  def __dir__() -> List[str]:
153
156
  """List available modules including dynamically loaded C++ modules."""