IncludeCPP 4.0.3__py3-none-any.whl → 4.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- includecpp/CHANGELOG.md +164 -0
- includecpp/DOCUMENTATION.md +593 -0
- includecpp/__init__.py +1 -1
- includecpp/__init__.pyi +4 -1
- includecpp/cli/commands.py +698 -84
- includecpp/core/ai_integration.py +46 -13
- includecpp/core/cpp_api_extensions.pyi +350 -0
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +186 -5
- includecpp/core/cssl/cssl_builtins.py +101 -4
- includecpp/core/cssl/cssl_languages.py +1757 -0
- includecpp/core/cssl/cssl_parser.py +424 -98
- includecpp/core/cssl/cssl_runtime.py +480 -38
- includecpp/core/cssl/cssl_syntax.py +88 -4
- includecpp/core/cssl/cssl_types.py +31 -2
- includecpp/generator/parser.cpp +121 -4
- includecpp/generator/parser.h +6 -0
- {includecpp-4.0.3.dist-info → includecpp-4.2.1.dist-info}/METADATA +101 -1
- {includecpp-4.0.3.dist-info → includecpp-4.2.1.dist-info}/RECORD +22 -18
- {includecpp-4.0.3.dist-info → includecpp-4.2.1.dist-info}/WHEEL +0 -0
- {includecpp-4.0.3.dist-info → includecpp-4.2.1.dist-info}/entry_points.txt +0 -0
- {includecpp-4.0.3.dist-info → includecpp-4.2.1.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.0.3.dist-info → includecpp-4.2.1.dist-info}/top_level.txt +0 -0
|
@@ -31,6 +31,11 @@ class TokenCategory(Enum):
|
|
|
31
31
|
NULL = auto() # null, None
|
|
32
32
|
PACKAGE_KW = auto() # package, package-includes - NEW
|
|
33
33
|
TYPE_LITERAL = auto() # list, dict - NEW
|
|
34
|
+
# v4.1.0: Multi-language support
|
|
35
|
+
SUPPORTS_KW = auto() # supports keyword (magenta)
|
|
36
|
+
LIBINCLUDE_KW = auto() # libinclude (yellow/gold)
|
|
37
|
+
LANG_PREFIX = auto() # Language prefix before $ (cyan): cpp$, py$, java$
|
|
38
|
+
LANG_INSTANCE = auto() # Instance name after $ (orange): cpp$ClassName
|
|
34
39
|
|
|
35
40
|
|
|
36
41
|
@dataclass
|
|
@@ -52,9 +57,17 @@ KEYWORDS = {
|
|
|
52
57
|
'start', 'stop', 'wait_for', 'on_event', 'emit_event',
|
|
53
58
|
'await',
|
|
54
59
|
# NEW: Extended keywords
|
|
55
|
-
'package', 'package-includes', 'exec', 'as', 'global'
|
|
60
|
+
'package', 'package-includes', 'exec', 'as', 'global',
|
|
61
|
+
# v4.1.0: Multi-language support (handled separately for special colors)
|
|
62
|
+
# 'supports', 'libinclude' - see MULTI_LANG_KEYWORDS
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
# v4.1.0: Multi-language keywords with special highlighting
|
|
66
|
+
MULTI_LANG_KEYWORDS = {'supports', 'libinclude'}
|
|
67
|
+
|
|
68
|
+
# v4.1.0: Language identifiers for cross-language instance access
|
|
69
|
+
LANGUAGE_IDS = {'cpp', 'py', 'python', 'java', 'csharp', 'js', 'javascript'}
|
|
70
|
+
|
|
58
71
|
# NEW: Package-related keywords for special highlighting
|
|
59
72
|
PACKAGE_KEYWORDS = {'package', 'package-includes'}
|
|
60
73
|
|
|
@@ -145,6 +158,33 @@ class CSSLSyntaxRules:
|
|
|
145
158
|
category=TokenCategory.TYPE_LITERAL
|
|
146
159
|
))
|
|
147
160
|
|
|
161
|
+
# v4.1.0: Multi-language support keywords
|
|
162
|
+
# 'supports' keyword (magenta) - must be before regular keywords
|
|
163
|
+
rules.append(HighlightRule(
|
|
164
|
+
pattern=r'\bsupports\b',
|
|
165
|
+
category=TokenCategory.SUPPORTS_KW
|
|
166
|
+
))
|
|
167
|
+
|
|
168
|
+
# 'libinclude' keyword (yellow/gold)
|
|
169
|
+
rules.append(HighlightRule(
|
|
170
|
+
pattern=r'\blibinclude\b',
|
|
171
|
+
category=TokenCategory.LIBINCLUDE_KW
|
|
172
|
+
))
|
|
173
|
+
|
|
174
|
+
# v4.1.0: Language$Instance patterns (cpp$ClassName, py$Object)
|
|
175
|
+
# Match language prefix before $ (cyan)
|
|
176
|
+
rules.append(HighlightRule(
|
|
177
|
+
pattern=r'\b(cpp|py|python|java|csharp|js|javascript)\$',
|
|
178
|
+
category=TokenCategory.LANG_PREFIX,
|
|
179
|
+
group=1
|
|
180
|
+
))
|
|
181
|
+
# Match instance name after $ (orange)
|
|
182
|
+
rules.append(HighlightRule(
|
|
183
|
+
pattern=r'\b(?:cpp|py|python|java|csharp|js|javascript)\$([A-Za-z_][A-Za-z0-9_]*)',
|
|
184
|
+
category=TokenCategory.LANG_INSTANCE,
|
|
185
|
+
group=1
|
|
186
|
+
))
|
|
187
|
+
|
|
148
188
|
# Self-references (s@Name, s@Backend.Loop)
|
|
149
189
|
rules.append(HighlightRule(
|
|
150
190
|
pattern=r's@[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*',
|
|
@@ -233,6 +273,11 @@ class ColorScheme:
|
|
|
233
273
|
TokenCategory.NULL: '#ff6464', # Red
|
|
234
274
|
TokenCategory.PACKAGE_KW: '#bd93f9', # Purple for package - NEW
|
|
235
275
|
TokenCategory.TYPE_LITERAL: '#8be9fd', # Cyan for type literals - NEW
|
|
276
|
+
# v4.1.0: Multi-language support colors
|
|
277
|
+
TokenCategory.SUPPORTS_KW: '#ff79c6', # Magenta/Pink for 'supports'
|
|
278
|
+
TokenCategory.LIBINCLUDE_KW: '#f1fa8c',# Yellow/Gold for 'libinclude'
|
|
279
|
+
TokenCategory.LANG_PREFIX: '#8be9fd', # Cyan for language prefix (cpp$)
|
|
280
|
+
TokenCategory.LANG_INSTANCE: '#ffb86c',# Orange for instance name ($ClassName)
|
|
236
281
|
}
|
|
237
282
|
|
|
238
283
|
# Light theme variant
|
|
@@ -252,6 +297,11 @@ class ColorScheme:
|
|
|
252
297
|
TokenCategory.NULL: '#ff0000', # Red
|
|
253
298
|
TokenCategory.PACKAGE_KW: '#8b008b', # DarkMagenta for package - NEW
|
|
254
299
|
TokenCategory.TYPE_LITERAL: '#008b8b', # Dark cyan for type literals - NEW
|
|
300
|
+
# v4.1.0: Multi-language support colors
|
|
301
|
+
TokenCategory.SUPPORTS_KW: '#d63384', # Dark Magenta for 'supports'
|
|
302
|
+
TokenCategory.LIBINCLUDE_KW: '#b8860b',# DarkGoldenrod for 'libinclude'
|
|
303
|
+
TokenCategory.LANG_PREFIX: '#0d6efd', # Blue for language prefix (cpp$)
|
|
304
|
+
TokenCategory.LANG_INSTANCE: '#fd7e14',# Orange for instance name ($ClassName)
|
|
255
305
|
}
|
|
256
306
|
|
|
257
307
|
|
|
@@ -334,6 +384,11 @@ def highlight_cssl_ansi(source: str) -> str:
|
|
|
334
384
|
TokenCategory.NULL: '\033[91m', # Red
|
|
335
385
|
TokenCategory.PACKAGE_KW: '\033[95m', # Magenta for package - NEW
|
|
336
386
|
TokenCategory.TYPE_LITERAL: '\033[96m', # Cyan for type literals - NEW
|
|
387
|
+
# v4.1.0: Multi-language support colors
|
|
388
|
+
TokenCategory.SUPPORTS_KW: '\033[95m', # Magenta for 'supports'
|
|
389
|
+
TokenCategory.LIBINCLUDE_KW: '\033[93m',# Yellow for 'libinclude'
|
|
390
|
+
TokenCategory.LANG_PREFIX: '\033[96m', # Cyan for language prefix (cpp$)
|
|
391
|
+
TokenCategory.LANG_INSTANCE: '\033[33m',# Orange/Yellow for instance name
|
|
337
392
|
}
|
|
338
393
|
RESET = '\033[0m'
|
|
339
394
|
|
|
@@ -439,6 +494,10 @@ def export_textmate_grammar() -> dict:
|
|
|
439
494
|
"name": "comment.line.cssl",
|
|
440
495
|
"match": "#.*$"
|
|
441
496
|
},
|
|
497
|
+
{
|
|
498
|
+
"name": "comment.line.double-slash.cssl",
|
|
499
|
+
"match": "//.*$"
|
|
500
|
+
},
|
|
442
501
|
{
|
|
443
502
|
"name": "string.quoted.double.cssl",
|
|
444
503
|
"match": '"(?:[^"\\\\]|\\\\.)*"'
|
|
@@ -447,6 +506,23 @@ def export_textmate_grammar() -> dict:
|
|
|
447
506
|
"name": "string.quoted.single.cssl",
|
|
448
507
|
"match": "'(?:[^'\\\\]|\\\\.)*'"
|
|
449
508
|
},
|
|
509
|
+
# v4.1.0: Multi-language support
|
|
510
|
+
{
|
|
511
|
+
"name": "keyword.control.supports.cssl",
|
|
512
|
+
"match": "\\bsupports\\b"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"name": "support.function.libinclude.cssl",
|
|
516
|
+
"match": "\\blibinclude\\b"
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
"name": "variable.language.lang-instance.cssl",
|
|
520
|
+
"match": "\\b(cpp|py|python|java|csharp|js|javascript)\\$([A-Za-z_][A-Za-z0-9_]*)",
|
|
521
|
+
"captures": {
|
|
522
|
+
"1": {"name": "entity.name.type.language.cssl"},
|
|
523
|
+
"2": {"name": "variable.other.instance.cssl"}
|
|
524
|
+
}
|
|
525
|
+
},
|
|
450
526
|
{
|
|
451
527
|
"name": "variable.other.self-reference.cssl",
|
|
452
528
|
"match": "s@[A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*"
|
|
@@ -455,9 +531,13 @@ def export_textmate_grammar() -> dict:
|
|
|
455
531
|
"name": "variable.other.module-reference.cssl",
|
|
456
532
|
"match": "@[A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*"
|
|
457
533
|
},
|
|
534
|
+
{
|
|
535
|
+
"name": "keyword.other.package.cssl",
|
|
536
|
+
"match": "\\b(package|package-includes)\\b"
|
|
537
|
+
},
|
|
458
538
|
{
|
|
459
539
|
"name": "keyword.control.cssl",
|
|
460
|
-
"match": "\\b(service-init|service-run|service-include|struct|define|if|else|elif|while|for|foreach|in|switch|case|default|break|continue|return|try|catch|await)\\b"
|
|
540
|
+
"match": "\\b(service-init|service-run|service-include|struct|define|class|constr|if|else|elif|while|for|foreach|in|switch|case|default|break|continue|return|try|catch|finally|throw|await|extends|overwrites|global|as|exec)\\b"
|
|
461
541
|
},
|
|
462
542
|
{
|
|
463
543
|
"name": "keyword.operator.cssl",
|
|
@@ -465,7 +545,7 @@ def export_textmate_grammar() -> dict:
|
|
|
465
545
|
},
|
|
466
546
|
{
|
|
467
547
|
"name": "constant.language.cssl",
|
|
468
|
-
"match": "\\b(True|False|true|false|null|None)\\b"
|
|
548
|
+
"match": "\\b(True|False|true|false|null|None|none)\\b"
|
|
469
549
|
},
|
|
470
550
|
{
|
|
471
551
|
"name": "constant.numeric.cssl",
|
|
@@ -473,7 +553,11 @@ def export_textmate_grammar() -> dict:
|
|
|
473
553
|
},
|
|
474
554
|
{
|
|
475
555
|
"name": "keyword.operator.assignment.cssl",
|
|
476
|
-
"match": "
|
|
556
|
+
"match": "<==|==>|->|<-|::"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"name": "support.type.cssl",
|
|
560
|
+
"match": "\\b(list|dict)\\b(?!\\s*\\()"
|
|
477
561
|
}
|
|
478
562
|
]
|
|
479
563
|
}
|
|
@@ -1648,6 +1648,7 @@ class UniversalInstance:
|
|
|
1648
1648
|
self._members: Dict[str, Any] = {}
|
|
1649
1649
|
self._methods: Dict[str, Any] = {} # Method name -> AST node or callable
|
|
1650
1650
|
self._injections: List[Any] = [] # Code blocks injected via +<<==
|
|
1651
|
+
self._runtime = None # Weak reference to CSSL runtime for method calls
|
|
1651
1652
|
# Register globally
|
|
1652
1653
|
UniversalInstance._registry[name] = self
|
|
1653
1654
|
|
|
@@ -1707,9 +1708,16 @@ class UniversalInstance:
|
|
|
1707
1708
|
"""Check if member exists."""
|
|
1708
1709
|
return name in self._members
|
|
1709
1710
|
|
|
1710
|
-
def
|
|
1711
|
+
def set_runtime(self, runtime: Any) -> None:
|
|
1712
|
+
"""Set the runtime reference for method calls from Python."""
|
|
1713
|
+
import weakref
|
|
1714
|
+
self._runtime = weakref.ref(runtime)
|
|
1715
|
+
|
|
1716
|
+
def set_method(self, name: str, method: Any, runtime: Any = None) -> None:
|
|
1711
1717
|
"""Set a method (AST node or callable)."""
|
|
1712
1718
|
self._methods[name] = method
|
|
1719
|
+
if runtime is not None and self._runtime is None:
|
|
1720
|
+
self.set_runtime(runtime)
|
|
1713
1721
|
|
|
1714
1722
|
def get_method(self, name: str) -> Any:
|
|
1715
1723
|
"""Get a method by name."""
|
|
@@ -1744,7 +1752,28 @@ class UniversalInstance:
|
|
|
1744
1752
|
if name in object.__getattribute__(self, '_members'):
|
|
1745
1753
|
return object.__getattribute__(self, '_members')[name]
|
|
1746
1754
|
if name in object.__getattribute__(self, '_methods'):
|
|
1747
|
-
|
|
1755
|
+
method = object.__getattribute__(self, '_methods')[name]
|
|
1756
|
+
runtime_ref = object.__getattribute__(self, '_runtime')
|
|
1757
|
+
|
|
1758
|
+
# If method is an AST node and we have a runtime, create a callable wrapper
|
|
1759
|
+
if hasattr(method, 'type') and method.type == 'function' and runtime_ref is not None:
|
|
1760
|
+
runtime = runtime_ref() # Dereference weakref
|
|
1761
|
+
if runtime is not None:
|
|
1762
|
+
instance = self
|
|
1763
|
+
def method_caller(*args, **kwargs):
|
|
1764
|
+
# Set 'this' context and call the method
|
|
1765
|
+
old_this = runtime.scope.get('this')
|
|
1766
|
+
runtime.scope.set('this', instance)
|
|
1767
|
+
try:
|
|
1768
|
+
return runtime._call_function(method, list(args))
|
|
1769
|
+
finally:
|
|
1770
|
+
if old_this is not None:
|
|
1771
|
+
runtime.scope.set('this', old_this)
|
|
1772
|
+
elif hasattr(runtime.scope, 'remove'):
|
|
1773
|
+
runtime.scope.remove('this')
|
|
1774
|
+
return method_caller
|
|
1775
|
+
# Return method directly if already callable or no runtime
|
|
1776
|
+
return method
|
|
1748
1777
|
raise AttributeError(f"Instance '{object.__getattribute__(self, '_name')}' has no attribute '{name}'")
|
|
1749
1778
|
|
|
1750
1779
|
def __setattr__(self, name: str, value: Any) -> None:
|
includecpp/generator/parser.cpp
CHANGED
|
@@ -599,13 +599,81 @@ ModuleDescriptor API::parse_cp_file(const std::string& filepath) {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
|
|
602
|
-
// Parse
|
|
602
|
+
// v4.1.1: Parse CONSTRUCTOR, METHOD, and FIELD entries for STRUCT
|
|
603
603
|
auto field_lines = split(field_block, '\n');
|
|
604
604
|
for (const auto& fline : field_lines) {
|
|
605
605
|
std::string ftrim = trim(fline);
|
|
606
606
|
if (ftrim.empty()) continue;
|
|
607
607
|
|
|
608
|
-
|
|
608
|
+
// v4.1.1: Parse CONSTRUCTOR(type1, type2, ...) for parametrized constructors
|
|
609
|
+
if (ftrim.find("CONSTRUCTOR") != std::string::npos) {
|
|
610
|
+
size_t c_start = ftrim.find('(');
|
|
611
|
+
size_t c_end = ftrim.rfind(')');
|
|
612
|
+
if (c_start != std::string::npos && c_end != std::string::npos) {
|
|
613
|
+
std::string params_str = ftrim.substr(c_start + 1, c_end - c_start - 1);
|
|
614
|
+
ConstructorInfo ctor;
|
|
615
|
+
if (!params_str.empty()) {
|
|
616
|
+
auto params = split(params_str, ',');
|
|
617
|
+
for (auto& p : params) {
|
|
618
|
+
std::string param_type = trim(p);
|
|
619
|
+
if (!param_type.empty()) {
|
|
620
|
+
ctor.param_types.push_back(param_type);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
sb.constructors.push_back(ctor);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
// v4.1.1: Parse METHOD and METHOD_CONST for STRUCT
|
|
628
|
+
else if (ftrim.find("METHOD") != std::string::npos) {
|
|
629
|
+
MethodSignature sig;
|
|
630
|
+
bool is_const_method = ftrim.find("METHOD_CONST") != std::string::npos;
|
|
631
|
+
|
|
632
|
+
size_t m_start = ftrim.find('(');
|
|
633
|
+
size_t m_end = ftrim.rfind(')');
|
|
634
|
+
|
|
635
|
+
if (m_start != std::string::npos && m_end != std::string::npos) {
|
|
636
|
+
std::string content = ftrim.substr(m_start + 1, m_end - m_start - 1);
|
|
637
|
+
|
|
638
|
+
// Parse method name and optional parameter types
|
|
639
|
+
std::vector<std::string> parts;
|
|
640
|
+
int template_depth = 0;
|
|
641
|
+
std::string current_part;
|
|
642
|
+
|
|
643
|
+
for (char c : content) {
|
|
644
|
+
if (c == '<') {
|
|
645
|
+
template_depth++;
|
|
646
|
+
current_part += c;
|
|
647
|
+
} else if (c == '>') {
|
|
648
|
+
template_depth--;
|
|
649
|
+
current_part += c;
|
|
650
|
+
} else if (c == ',' && template_depth == 0) {
|
|
651
|
+
parts.push_back(trim(current_part));
|
|
652
|
+
current_part.clear();
|
|
653
|
+
} else {
|
|
654
|
+
current_part += c;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (!current_part.empty()) {
|
|
658
|
+
parts.push_back(trim(current_part));
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if (!parts.empty()) {
|
|
662
|
+
sig.name = parts[0];
|
|
663
|
+
sig.is_const = is_const_method;
|
|
664
|
+
|
|
665
|
+
// Remaining parts are parameter types
|
|
666
|
+
for (size_t k = 1; k < parts.size(); ++k) {
|
|
667
|
+
sig.param_types.push_back(parts[k]);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
sb.method_signatures.push_back(sig);
|
|
671
|
+
sb.methods.push_back(sig.name);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
// Parse FIELD(name) or FIELD(type, name)
|
|
676
|
+
else if (ftrim.find("FIELD(") != std::string::npos) {
|
|
609
677
|
size_t f_start = ftrim.find('(');
|
|
610
678
|
size_t f_end = ftrim.find(')');
|
|
611
679
|
if (f_start != std::string::npos && f_end != std::string::npos) {
|
|
@@ -616,6 +684,10 @@ ModuleDescriptor API::parse_cp_file(const std::string& filepath) {
|
|
|
616
684
|
std::string field_type = trim(field_parts[0]);
|
|
617
685
|
std::string field_name = trim(field_parts[1]);
|
|
618
686
|
sb.fields.push_back({field_type, field_name});
|
|
687
|
+
} else if (field_parts.size() == 1) {
|
|
688
|
+
// Simple FIELD(name) - type will be inferred
|
|
689
|
+
std::string field_name = trim(field_parts[0]);
|
|
690
|
+
sb.fields.push_back({"auto", field_name});
|
|
619
691
|
}
|
|
620
692
|
}
|
|
621
693
|
}
|
|
@@ -870,7 +942,24 @@ std::string generate_struct_bindings(const StructBinding& sb, const ModuleDescri
|
|
|
870
942
|
|
|
871
943
|
code << " py::class_<" << cpp_type << ">(";
|
|
872
944
|
code << mod.module_name << "_module, \"" << struct_full_name << "\")\n";
|
|
873
|
-
|
|
945
|
+
|
|
946
|
+
// v4.1.1: Generate all constructor overloads from CONSTRUCTOR() entries
|
|
947
|
+
if (sb.constructors.empty()) {
|
|
948
|
+
// Backward compatibility: default constructor if none specified
|
|
949
|
+
code << " .def(py::init<>())\n";
|
|
950
|
+
} else {
|
|
951
|
+
for (const auto& ctor : sb.constructors) {
|
|
952
|
+
code << " .def(py::init<";
|
|
953
|
+
for (size_t i = 0; i < ctor.param_types.size(); ++i) {
|
|
954
|
+
if (i > 0) code << ", ";
|
|
955
|
+
// Replace T with actual template type
|
|
956
|
+
std::string ptype = ctor.param_types[i];
|
|
957
|
+
if (ptype == "T") ptype = ttype;
|
|
958
|
+
code << ptype;
|
|
959
|
+
}
|
|
960
|
+
code << ">())\n";
|
|
961
|
+
}
|
|
962
|
+
}
|
|
874
963
|
|
|
875
964
|
// Fields - readwrite access
|
|
876
965
|
for (const auto& [field_type, field_name] : sb.fields) {
|
|
@@ -884,6 +973,15 @@ std::string generate_struct_bindings(const StructBinding& sb, const ModuleDescri
|
|
|
884
973
|
<< cpp_type << "::" << field_name << ")\n";
|
|
885
974
|
}
|
|
886
975
|
|
|
976
|
+
// v4.1.1: Generate method bindings
|
|
977
|
+
for (const auto& sig : sb.method_signatures) {
|
|
978
|
+
if (sig.is_const) {
|
|
979
|
+
code << " .def(\"" << sig.name << "\", &" << cpp_type << "::" << sig.name << ")\n";
|
|
980
|
+
} else {
|
|
981
|
+
code << " .def(\"" << sig.name << "\", &" << cpp_type << "::" << sig.name << ")\n";
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
887
985
|
// Auto-generate to_dict() method
|
|
888
986
|
code << " .def(\"to_dict\", [](" << cpp_type << "& self) {\n";
|
|
889
987
|
code << " py::dict d;\n";
|
|
@@ -917,7 +1015,21 @@ std::string generate_struct_bindings(const StructBinding& sb, const ModuleDescri
|
|
|
917
1015
|
// Non-template struct
|
|
918
1016
|
code << " py::class_<" << sb.struct_name << ">(";
|
|
919
1017
|
code << mod.module_name << "_module, \"" << sb.struct_name << "\")\n";
|
|
920
|
-
|
|
1018
|
+
|
|
1019
|
+
// v4.1.1: Generate all constructor overloads from CONSTRUCTOR() entries
|
|
1020
|
+
if (sb.constructors.empty()) {
|
|
1021
|
+
// Backward compatibility: default constructor if none specified
|
|
1022
|
+
code << " .def(py::init<>())\n";
|
|
1023
|
+
} else {
|
|
1024
|
+
for (const auto& ctor : sb.constructors) {
|
|
1025
|
+
code << " .def(py::init<";
|
|
1026
|
+
for (size_t i = 0; i < ctor.param_types.size(); ++i) {
|
|
1027
|
+
if (i > 0) code << ", ";
|
|
1028
|
+
code << ctor.param_types[i];
|
|
1029
|
+
}
|
|
1030
|
+
code << ">())\n";
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
921
1033
|
|
|
922
1034
|
// Fields
|
|
923
1035
|
for (const auto& [field_type, field_name] : sb.fields) {
|
|
@@ -925,6 +1037,11 @@ std::string generate_struct_bindings(const StructBinding& sb, const ModuleDescri
|
|
|
925
1037
|
<< sb.struct_name << "::" << field_name << ")\n";
|
|
926
1038
|
}
|
|
927
1039
|
|
|
1040
|
+
// v4.1.1: Generate method bindings
|
|
1041
|
+
for (const auto& sig : sb.method_signatures) {
|
|
1042
|
+
code << " .def(\"" << sig.name << "\", &" << sb.struct_name << "::" << sig.name << ")\n";
|
|
1043
|
+
}
|
|
1044
|
+
|
|
928
1045
|
// Auto-generate to_dict() method
|
|
929
1046
|
code << " .def(\"to_dict\", [](" << sb.struct_name << "& self) {\n";
|
|
930
1047
|
code << " py::dict d;\n";
|
includecpp/generator/parser.h
CHANGED
|
@@ -127,6 +127,7 @@ struct VariableBinding {
|
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
// v2.0: STRUCT() Bindings for Plain-Old-Data types
|
|
130
|
+
// v4.1.1: Added CONSTRUCTOR and METHOD support (same as CLASS)
|
|
130
131
|
struct StructBinding {
|
|
131
132
|
std::string module_name;
|
|
132
133
|
std::string struct_name;
|
|
@@ -135,6 +136,11 @@ struct StructBinding {
|
|
|
135
136
|
bool is_template = false;
|
|
136
137
|
std::string documentation;
|
|
137
138
|
|
|
139
|
+
// v4.1.1: CONSTRUCTOR and METHOD support for STRUCT (same as CLASS)
|
|
140
|
+
std::vector<ConstructorInfo> constructors;
|
|
141
|
+
std::vector<MethodSignature> method_signatures;
|
|
142
|
+
std::vector<std::string> methods; // Simple method names for backward compatibility
|
|
143
|
+
|
|
138
144
|
// Helper methods
|
|
139
145
|
std::string get_full_name() const {
|
|
140
146
|
return struct_name;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: IncludeCPP
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2.1
|
|
4
4
|
Summary: Professional C++ Python bindings with type-generic templates, pystubs and native threading
|
|
5
5
|
Home-page: https://github.com/liliassg/IncludeCPP
|
|
6
6
|
Author: Lilias Hatterscheidt
|
|
@@ -906,3 +906,103 @@ print(greeter.name) # "Python"
|
|
|
906
906
|
- `python::export(instance)` - Alias
|
|
907
907
|
|
|
908
908
|
All three do the same thing: wrap a CSSL class instance for Python use.
|
|
909
|
+
|
|
910
|
+
## Universal Instances (v4.0.3+)
|
|
911
|
+
|
|
912
|
+
Universal instances are shared containers accessible from CSSL, Python, and C++:
|
|
913
|
+
|
|
914
|
+
```python
|
|
915
|
+
from includecpp import CSSL
|
|
916
|
+
|
|
917
|
+
cssl = CSSL.CsslLang()
|
|
918
|
+
|
|
919
|
+
# Create in CSSL
|
|
920
|
+
cssl.run('''
|
|
921
|
+
instance<"myContainer"> container;
|
|
922
|
+
container.data = "Hello";
|
|
923
|
+
container.count = 42;
|
|
924
|
+
''')
|
|
925
|
+
|
|
926
|
+
# Access from Python
|
|
927
|
+
container = cssl.getInstance("myContainer")
|
|
928
|
+
print(container.data) # "Hello"
|
|
929
|
+
print(container.count) # 42
|
|
930
|
+
|
|
931
|
+
# Modify from Python
|
|
932
|
+
container.newValue = "Added from Python"
|
|
933
|
+
|
|
934
|
+
# Changes reflect in CSSL
|
|
935
|
+
cssl.run('''
|
|
936
|
+
instance<"myContainer"> c;
|
|
937
|
+
printl(c.newValue); // "Added from Python"
|
|
938
|
+
''')
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
### Instance Methods
|
|
942
|
+
|
|
943
|
+
```python
|
|
944
|
+
cssl.getInstance("name") # Get instance (None if not found)
|
|
945
|
+
cssl.createInstance("name") # Create or get instance
|
|
946
|
+
cssl.deleteInstance("name") # Delete instance
|
|
947
|
+
cssl.listInstances() # List all instance names
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
### Method Injection
|
|
951
|
+
|
|
952
|
+
Inject methods into instances using `+<<==`:
|
|
953
|
+
|
|
954
|
+
```cssl
|
|
955
|
+
instance<"api"> api;
|
|
956
|
+
|
|
957
|
+
// Inject a method
|
|
958
|
+
api +<<== {
|
|
959
|
+
void greet(string name) {
|
|
960
|
+
printl("Hello, " + name + "!");
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
api.greet("World"); // Hello, World!
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
## Simplified Module API (v4.0.2+)
|
|
968
|
+
|
|
969
|
+
Create CSSL modules from files with payload binding:
|
|
970
|
+
|
|
971
|
+
```python
|
|
972
|
+
from includecpp import CSSL
|
|
973
|
+
|
|
974
|
+
# Register payload from file
|
|
975
|
+
CSSL.makepayload("api", "lib/api/myapi.cssl-pl")
|
|
976
|
+
|
|
977
|
+
# Create module from file, binding to payload
|
|
978
|
+
mod = CSSL.makemodule("writer", "lib/writer.cssl", bind="api")
|
|
979
|
+
mod.SaySomething("Hello!") # Call functions directly
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
## VSCode Extension
|
|
983
|
+
|
|
984
|
+
IncludeCPP includes a VSCode extension for CSSL syntax highlighting.
|
|
985
|
+
|
|
986
|
+
### Installation
|
|
987
|
+
|
|
988
|
+
```bash
|
|
989
|
+
# Copy extension to VSCode extensions folder
|
|
990
|
+
# Windows: %USERPROFILE%\.vscode\extensions\
|
|
991
|
+
# Linux/Mac: ~/.vscode/extensions/
|
|
992
|
+
|
|
993
|
+
# Or install from included files
|
|
994
|
+
pip show includecpp # Find package location
|
|
995
|
+
# Copy vscode/cssl folder to extensions
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
### Features
|
|
999
|
+
|
|
1000
|
+
- Syntax highlighting for `.cssl`, `.cssl-pl`, `.cssl-mod` files
|
|
1001
|
+
- Snippets for common patterns
|
|
1002
|
+
- Run CSSL files with F5
|
|
1003
|
+
- Proper coloring for:
|
|
1004
|
+
- Keywords and control flow
|
|
1005
|
+
- Data types (purple/lilac)
|
|
1006
|
+
- Variable declarations (light blue)
|
|
1007
|
+
- Injection operators (`<<==`, `<==`)
|
|
1008
|
+
- Global (`@`), shared (`$`), and captured (`%`) references
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
includecpp/
|
|
2
|
-
includecpp/
|
|
1
|
+
includecpp/CHANGELOG.md,sha256=tY7jzlx61TK8Y7Hmaxrwi9tcsrAXE9Lnah-xuKD6YhM,5187
|
|
2
|
+
includecpp/DOCUMENTATION.md,sha256=DuDN5EesEv9h-uTgJpNNBTi3R-RibXjrGfIKUK6uEg0,9762
|
|
3
|
+
includecpp/__init__.py,sha256=KiNyF9Vjc6Snee1SM3ylgiqqXG9TWZReb6uz-Uj6lEE,1672
|
|
4
|
+
includecpp/__init__.pyi,sha256=gfpArSojafkBCUoACntpnPBVgKLPZHecsyJtlVhE1A0,7267
|
|
3
5
|
includecpp/__main__.py,sha256=d6QK0PkvUe1ENofpmHRAg3bwNbZr8PiRscfI3-WRfVg,72
|
|
4
6
|
includecpp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
7
|
includecpp/cli/__init__.py,sha256=Yda-4a5QJb_tKu35YQNfc5lu-LewTsM5abqNNkzS47M,113
|
|
6
|
-
includecpp/cli/commands.py,sha256=
|
|
8
|
+
includecpp/cli/commands.py,sha256=7Cu1zgXmK6ghOebzKqTwZHXvROHWpqiYHKnrBW3g0ZA,372152
|
|
7
9
|
includecpp/cli/config_parser.py,sha256=KveeYUg2TA9sC5hKVzYYfgdNm2WfLG5y7_yxgBWn9yM,4886
|
|
8
10
|
includecpp/core/__init__.py,sha256=L1bT6oikTjdto-6Px7DpjePtM07ymo3Bnov1saZzsGg,390
|
|
9
|
-
includecpp/core/ai_integration.py,sha256=
|
|
11
|
+
includecpp/core/ai_integration.py,sha256=Q44Y1SD_4yXETO4AwtoR51QnX0T4Tc14_Ux9VozQJhQ,89146
|
|
10
12
|
includecpp/core/build_manager.py,sha256=uLuYsuiC6OsOGaU5wAJfl4M3IbdnIDgogfMd8VsVpq8,102866
|
|
11
13
|
includecpp/core/cpp_api.py,sha256=8y_B1L18rhSBZln654xPPzqO2PdvAlLpJrfEjzl7Wnc,14039
|
|
12
14
|
includecpp/core/cpp_api.pyi,sha256=IEiaKqaPItnn6rjL7aK32D3o9FYmRYCgCZbqiQNUwdc,3496
|
|
15
|
+
includecpp/core/cpp_api_extensions.pyi,sha256=Eb_QywS4qpRRsMvHCYxoeBQ8Vw0P1ffu-rwzTIpvpnE,10622
|
|
13
16
|
includecpp/core/cppy_converter.py,sha256=b7yqu-aoa0wShNY0GvQT67TnNhYya4GyYmG7oDdqDV4,156686
|
|
14
17
|
includecpp/core/cssl_bridge.py,sha256=xYfIRagegO8irdWl97dfanRB1qLU80p9lQ2wxkttGQ4,49963
|
|
15
18
|
includecpp/core/cssl_bridge.pyi,sha256=nreh2gtK94I6VFrzTWcYVUHN97wcYQF0dY_-HySi7yQ,28787
|
|
@@ -19,20 +22,21 @@ includecpp/core/exceptions.py,sha256=szeF4qdzi_q8hBBZi7mJxkliyQ0crplkLYe0ymlBGtk
|
|
|
19
22
|
includecpp/core/path_discovery.py,sha256=jI0oSq6Hsd4LKXmU4dOiGSrXcEO_KWMXfQ5_ylBmXvU,2561
|
|
20
23
|
includecpp/core/project_ui.py,sha256=la2EQZKmUkJGuJxnbs09hH1ZhBh9bfndo6okzZsk2dQ,141134
|
|
21
24
|
includecpp/core/settings_ui.py,sha256=B2SlwgdplF2KiBk5UYf2l8Jjifjd0F-FmBP0DPsVCEQ,11798
|
|
22
|
-
includecpp/core/cssl/CSSL_DOCUMENTATION.md,sha256=
|
|
25
|
+
includecpp/core/cssl/CSSL_DOCUMENTATION.md,sha256=M55jgDBNrgjcLQHpdN5KbHvwLWgV7SQBGEAGEFFmNCo,36847
|
|
23
26
|
includecpp/core/cssl/CSSL_DOCUMENTATION_NEW.md,sha256=I_bVeKWlbcgHYkl2o9L2vk3r5sDvG44bGh__RJIYduw,28222
|
|
24
27
|
includecpp/core/cssl/__init__.py,sha256=scDXRBNK2L6A8qmlpNyaqQj6BFcSfPInBlucdeNfMF0,1975
|
|
25
|
-
includecpp/core/cssl/cssl_builtins.py,sha256=
|
|
28
|
+
includecpp/core/cssl/cssl_builtins.py,sha256=x8bKQ2WEzxjkFWmGb6dK2jggiylkj04-6f15iDwEi_U,108791
|
|
26
29
|
includecpp/core/cssl/cssl_builtins.pyi,sha256=-yr9JbxHKFv9Vc1iufChcqCQvNQLL3-Ow_Hgg0YwQnc,135180
|
|
27
30
|
includecpp/core/cssl/cssl_events.py,sha256=nupIcXW_Vjdud7zCU6hdwkQRQ0MujlPM7Tk2u7eDAiY,21013
|
|
31
|
+
includecpp/core/cssl/cssl_languages.py,sha256=qftMcBiNT1pbIn5OniTZDx8rFtGYU4yx4Iw1QYKAC1U,62342
|
|
28
32
|
includecpp/core/cssl/cssl_modules.py,sha256=cUg0-zdymMnWWTsA_BUrW5dx4R04dHpKcUhm-Wfiwwo,103006
|
|
29
|
-
includecpp/core/cssl/cssl_parser.py,sha256=
|
|
30
|
-
includecpp/core/cssl/cssl_runtime.py,sha256=
|
|
31
|
-
includecpp/core/cssl/cssl_syntax.py,sha256=
|
|
32
|
-
includecpp/core/cssl/cssl_types.py,sha256=
|
|
33
|
+
includecpp/core/cssl/cssl_parser.py,sha256=SZ908zCPlbHryktr75OsrYw_6srDVjmoFb4-q39abg8,169935
|
|
34
|
+
includecpp/core/cssl/cssl_runtime.py,sha256=6jz6XnjjEZlWDuHxUhiiuM3HwkT4Ah74yRQqUCfw_KY,237635
|
|
35
|
+
includecpp/core/cssl/cssl_syntax.py,sha256=AcFvqCB9WKitNA32izCWf5jeFWNc6ncc-xLw0J5UjBg,20933
|
|
36
|
+
includecpp/core/cssl/cssl_types.py,sha256=Vs61dnMh8iUxVu7LPz8HM-XyojuQptykkedlVA3J2Bc,60031
|
|
33
37
|
includecpp/generator/__init__.py,sha256=Rsy41bwimaEloD3gDRR_znPfIJzIsCFuWZgCTJBLJlc,62
|
|
34
|
-
includecpp/generator/parser.cpp,sha256=
|
|
35
|
-
includecpp/generator/parser.h,sha256=
|
|
38
|
+
includecpp/generator/parser.cpp,sha256=KT_rrZFJi8KF6emstIW5lKOMaD5gOTC9IcrGEIuIuYw,83251
|
|
39
|
+
includecpp/generator/parser.h,sha256=z8qHnsiY8cXAwq5JW9O-V-hCSjDQacYLgi91ViqzHSw,11405
|
|
36
40
|
includecpp/generator/type_resolver.cpp,sha256=MmFK_4HXd1wqxALDiDyXVuU397SXoQL_o5zb_8N8Hzs,12346
|
|
37
41
|
includecpp/generator/type_resolver.h,sha256=ZsaxQqcCcKJJApYn7KOp2dLlQ1VFVG_oZDjaK5LhBSg,2590
|
|
38
42
|
includecpp/templates/cpp.proj.template,sha256=Iy-L8I4Cl3tIgBMx1Qp5h6gURvkqOAqyodVHuDJ0Luw,359
|
|
@@ -45,9 +49,9 @@ includecpp/vscode/cssl/images/cssl.png,sha256=BxAGsnfS0ZzzCvqV6Zb1OAJAZpDUoXlR86
|
|
|
45
49
|
includecpp/vscode/cssl/images/cssl_pl.png,sha256=z4WMk7g6YCTbUUbSFk343BO6yi_OmNEVYkRenWGydwM,799
|
|
46
50
|
includecpp/vscode/cssl/snippets/cssl.snippets.json,sha256=uV3nHJyQ5f7Pr3FzfbQT2VZOEY3AlGs4wrmqe884jm4,37372
|
|
47
51
|
includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json,sha256=nYy7aRWREcgCu9Jbx5QmtQHfD4WRlk-HkPhqzKVtoIA,42806
|
|
48
|
-
includecpp-4.
|
|
49
|
-
includecpp-4.
|
|
50
|
-
includecpp-4.
|
|
51
|
-
includecpp-4.
|
|
52
|
-
includecpp-4.
|
|
53
|
-
includecpp-4.
|
|
52
|
+
includecpp-4.2.1.dist-info/licenses/LICENSE,sha256=fWCsGGsiWZir0UzDd20Hh-3wtRyk1zqUntvtVuAWhvc,1093
|
|
53
|
+
includecpp-4.2.1.dist-info/METADATA,sha256=zeSBOAz9sK3PP7dcDDSsFE0dlODRWii-e9Wx2kX-l20,24887
|
|
54
|
+
includecpp-4.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
55
|
+
includecpp-4.2.1.dist-info/entry_points.txt,sha256=6A5Mif9gi0139Bf03W5plAb3wnAgbNaEVe1HJoGE-2o,59
|
|
56
|
+
includecpp-4.2.1.dist-info/top_level.txt,sha256=RFUaR1KG-M6mCYwP6w4ydP5Cgc8yNbP78jxGAvyjMa8,11
|
|
57
|
+
includecpp-4.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|