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.
- includecpp/CHANGELOG.md +175 -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 +429 -98
- includecpp/core/cssl/cssl_runtime.py +666 -51
- includecpp/core/cssl/cssl_syntax.py +88 -4
- includecpp/core/cssl/cssl_types.py +172 -1
- includecpp/core/cssl_bridge.py +194 -8
- includecpp/core/cssl_bridge.pyi +148 -10
- includecpp/generator/parser.cpp +121 -4
- includecpp/generator/parser.h +6 -0
- includecpp/vscode/cssl/package.json +43 -1
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +140 -17
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/METADATA +101 -1
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/RECORD +26 -22
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/WHEEL +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/entry_points.txt +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/licenses/LICENSE +0 -0
- {includecpp-4.0.2.dist-info → includecpp-4.2.2.dist-info}/top_level.txt +0 -0
|
@@ -32,8 +32,12 @@ MODELS = {
|
|
|
32
32
|
'gpt-3.5-turbo': {'context': 16385, 'endpoint': 'gpt-3.5-turbo'},
|
|
33
33
|
'gpt-4-turbo': {'context': 128000, 'endpoint': 'gpt-4-turbo'},
|
|
34
34
|
'gpt-4o': {'context': 128000, 'endpoint': 'gpt-4o'},
|
|
35
|
+
'gpt-4o-mini': {'context': 128000, 'endpoint': 'gpt-4o-mini'},
|
|
35
36
|
'gpt-5': {'context': 256000, 'endpoint': 'gpt-5'},
|
|
36
37
|
'gpt-5-nano': {'context': 32000, 'endpoint': 'gpt-5-nano'},
|
|
38
|
+
'o1': {'context': 200000, 'endpoint': 'o1'},
|
|
39
|
+
'o1-mini': {'context': 128000, 'endpoint': 'o1-mini'},
|
|
40
|
+
'o1-preview': {'context': 128000, 'endpoint': 'o1-preview'},
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
DEFAULT_MODEL = 'gpt-5'
|
|
@@ -981,18 +985,43 @@ class AIManager:
|
|
|
981
985
|
'Content-Type': 'application/json'
|
|
982
986
|
}
|
|
983
987
|
token_limit = min(16000, model_info['context'] // 2)
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
988
|
+
|
|
989
|
+
# o1 models use different message format (no system message, combined into user)
|
|
990
|
+
# gpt-5 models use max_completion_tokens instead of max_tokens
|
|
991
|
+
is_o1_model = model.startswith('o1')
|
|
992
|
+
is_gpt5_model = model.startswith('gpt-5')
|
|
993
|
+
|
|
994
|
+
if is_o1_model:
|
|
995
|
+
# o1 models: combine system + user into single user message
|
|
996
|
+
combined_content = f"{system_prompt}\n\n---\n\n{user_prompt}"
|
|
997
|
+
data = {
|
|
998
|
+
'model': model_info['endpoint'],
|
|
999
|
+
'messages': [
|
|
1000
|
+
{'role': 'user', 'content': combined_content}
|
|
1001
|
+
],
|
|
1002
|
+
'max_completion_tokens': token_limit
|
|
1003
|
+
}
|
|
1004
|
+
# o1 models don't support temperature
|
|
1005
|
+
elif is_gpt5_model:
|
|
1006
|
+
# gpt-5 models: use max_completion_tokens, no custom temperature
|
|
1007
|
+
data = {
|
|
1008
|
+
'model': model_info['endpoint'],
|
|
1009
|
+
'messages': [
|
|
1010
|
+
{'role': 'system', 'content': system_prompt},
|
|
1011
|
+
{'role': 'user', 'content': user_prompt}
|
|
1012
|
+
],
|
|
1013
|
+
'max_completion_tokens': token_limit
|
|
1014
|
+
}
|
|
993
1015
|
else:
|
|
994
|
-
data
|
|
995
|
-
|
|
1016
|
+
data = {
|
|
1017
|
+
'model': model_info['endpoint'],
|
|
1018
|
+
'messages': [
|
|
1019
|
+
{'role': 'system', 'content': system_prompt},
|
|
1020
|
+
{'role': 'user', 'content': user_prompt}
|
|
1021
|
+
],
|
|
1022
|
+
'max_tokens': token_limit,
|
|
1023
|
+
'temperature': temperature
|
|
1024
|
+
}
|
|
996
1025
|
try:
|
|
997
1026
|
response = requests.post(OPENAI_API_URL, headers=headers, json=data, timeout=timeout)
|
|
998
1027
|
if response.status_code == 200:
|
|
@@ -1312,6 +1341,10 @@ class AIManager:
|
|
|
1312
1341
|
import platform
|
|
1313
1342
|
import subprocess
|
|
1314
1343
|
|
|
1344
|
+
# Early fail-fast checks
|
|
1345
|
+
if not self.config.get('api_key'):
|
|
1346
|
+
return False, 'No API key configured. Run: includecpp ai setup', []
|
|
1347
|
+
|
|
1315
1348
|
# Build tools list for prompt
|
|
1316
1349
|
tools_list = '\n'.join([
|
|
1317
1350
|
f"- {name}: {info['desc']}\n Format:\n {info['format']}"
|
|
@@ -1371,9 +1404,9 @@ class AIManager:
|
|
|
1371
1404
|
|
|
1372
1405
|
prompt = self._build_prompt_with_docs(prompt)
|
|
1373
1406
|
|
|
1374
|
-
# Temperature and timeout
|
|
1407
|
+
# Temperature and timeout (reduced for faster failure detection)
|
|
1375
1408
|
temperature = 0.1 if think_three else (0.2 if think_twice else 0.3)
|
|
1376
|
-
timeout =
|
|
1409
|
+
timeout = 180 if think_three else (120 if think_twice else (90 if think else 60))
|
|
1377
1410
|
|
|
1378
1411
|
# Execute with tool loop
|
|
1379
1412
|
all_changes = []
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"""Auto-generated type stubs for IncludeCPP module wrappers.
|
|
2
|
+
|
|
3
|
+
This file enables VSCode IntelliSense autocomplete for C++ modules.
|
|
4
|
+
DO NOT EDIT - Auto-generated by IncludeCPP build system.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any, List, Dict, Optional, Union, Protocol, overload
|
|
8
|
+
|
|
9
|
+
class Fast_listModuleWrapper(Protocol):
|
|
10
|
+
"""Type hints for fast_list module wrapper (VSCode autocomplete support)."""
|
|
11
|
+
|
|
12
|
+
def getInfo(self) -> Dict[str, Any]:
|
|
13
|
+
"""Get fast_list module information."""
|
|
14
|
+
...
|
|
15
|
+
|
|
16
|
+
class FastList:
|
|
17
|
+
"""C++ class: FastList"""
|
|
18
|
+
|
|
19
|
+
def __init__(self) -> None:
|
|
20
|
+
"""Initialize FastList instance"""
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
def add(self, *args: Any, **kwargs: Any) -> Any:
|
|
24
|
+
"""C++ method: add"""
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
def get(self, *args: Any, **kwargs: Any) -> Any:
|
|
28
|
+
"""C++ method: get"""
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
def size(self, *args: Any, **kwargs: Any) -> Any:
|
|
32
|
+
"""C++ method: size"""
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
def clear(self, *args: Any, **kwargs: Any) -> Any:
|
|
36
|
+
"""C++ method: clear"""
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def fast_sort(self, *args: Any, **kwargs: Any) -> Any:
|
|
41
|
+
"""C++ function: fast_sort"""
|
|
42
|
+
...
|
|
43
|
+
|
|
44
|
+
def fast_reverse(self, *args: Any, **kwargs: Any) -> Any:
|
|
45
|
+
"""C++ function: fast_reverse"""
|
|
46
|
+
...
|
|
47
|
+
|
|
48
|
+
def fast_sum(self, *args: Any, **kwargs: Any) -> Any:
|
|
49
|
+
"""C++ function: fast_sum"""
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
def fast_max(self, *args: Any, **kwargs: Any) -> Any:
|
|
53
|
+
"""C++ function: fast_max"""
|
|
54
|
+
...
|
|
55
|
+
|
|
56
|
+
def fast_min(self, *args: Any, **kwargs: Any) -> Any:
|
|
57
|
+
"""C++ function: fast_min"""
|
|
58
|
+
...
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Game_mathModuleWrapper(Protocol):
|
|
63
|
+
"""Type hints for game_math module wrapper (VSCode autocomplete support)."""
|
|
64
|
+
|
|
65
|
+
def getInfo(self) -> Dict[str, Any]:
|
|
66
|
+
"""Get game_math module information."""
|
|
67
|
+
...
|
|
68
|
+
|
|
69
|
+
class Vector2D:
|
|
70
|
+
"""C++ class: Vector2D"""
|
|
71
|
+
|
|
72
|
+
@overload
|
|
73
|
+
def __init__(self) -> None: ...
|
|
74
|
+
@overload
|
|
75
|
+
def __init__(self, arg0: float, arg1: float) -> None: ...
|
|
76
|
+
|
|
77
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
78
|
+
"""Initialize Vector2D instance"""
|
|
79
|
+
...
|
|
80
|
+
|
|
81
|
+
def add(self, *args: Any, **kwargs: Any) -> Any:
|
|
82
|
+
"""C++ method: add"""
|
|
83
|
+
...
|
|
84
|
+
|
|
85
|
+
def dot(self, *args: Any, **kwargs: Any) -> Any:
|
|
86
|
+
"""C++ method: dot"""
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
def length(self, *args: Any, **kwargs: Any) -> Any:
|
|
90
|
+
"""C++ method: length"""
|
|
91
|
+
...
|
|
92
|
+
|
|
93
|
+
def normalize(self, *args: Any, **kwargs: Any) -> Any:
|
|
94
|
+
"""C++ method: normalize"""
|
|
95
|
+
...
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def boxCollision(self, *args: Any, **kwargs: Any) -> Any:
|
|
99
|
+
"""C++ function: boxCollision"""
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
def circleCollision(self, *args: Any, **kwargs: Any) -> Any:
|
|
103
|
+
"""C++ function: circleCollision"""
|
|
104
|
+
...
|
|
105
|
+
|
|
106
|
+
def distance(self, *args: Any, **kwargs: Any) -> Any:
|
|
107
|
+
"""C++ function: distance"""
|
|
108
|
+
...
|
|
109
|
+
|
|
110
|
+
def square(self, *args: Any, **kwargs: Any) -> Any:
|
|
111
|
+
"""C++ function: square"""
|
|
112
|
+
...
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class Solar_systemModuleWrapper(Protocol):
|
|
117
|
+
"""Type hints for solar_system module wrapper (VSCode autocomplete support)."""
|
|
118
|
+
|
|
119
|
+
def getInfo(self) -> Dict[str, Any]:
|
|
120
|
+
"""Get solar_system module information."""
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
class CelestialBody:
|
|
124
|
+
"""C++ class: CelestialBody"""
|
|
125
|
+
|
|
126
|
+
def __init__(self) -> None:
|
|
127
|
+
"""Initialize CelestialBody instance"""
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
def add_trajectory_point(self, *args: Any, **kwargs: Any) -> Any:
|
|
131
|
+
"""C++ method: add_trajectory_point"""
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class SolarSystem:
|
|
136
|
+
"""C++ class: SolarSystem"""
|
|
137
|
+
|
|
138
|
+
def __init__(self) -> None:
|
|
139
|
+
"""Initialize SolarSystem instance"""
|
|
140
|
+
...
|
|
141
|
+
|
|
142
|
+
def calculate_angular_momentum(self, *args: Any, **kwargs: Any) -> Any:
|
|
143
|
+
"""C++ method: calculate_angular_momentum"""
|
|
144
|
+
...
|
|
145
|
+
|
|
146
|
+
def calculate_total_energy(self, *args: Any, **kwargs: Any) -> Any:
|
|
147
|
+
"""C++ method: calculate_total_energy"""
|
|
148
|
+
...
|
|
149
|
+
|
|
150
|
+
def get_body_count(self, *args: Any, **kwargs: Any) -> Any:
|
|
151
|
+
"""C++ method: get_body_count"""
|
|
152
|
+
...
|
|
153
|
+
|
|
154
|
+
def get_distance_from_sun(self, *args: Any, **kwargs: Any) -> Any:
|
|
155
|
+
"""C++ method: get_distance_from_sun"""
|
|
156
|
+
...
|
|
157
|
+
|
|
158
|
+
def get_energy_error(self, *args: Any, **kwargs: Any) -> Any:
|
|
159
|
+
"""C++ method: get_energy_error"""
|
|
160
|
+
...
|
|
161
|
+
|
|
162
|
+
def get_masses(self, *args: Any, **kwargs: Any) -> Any:
|
|
163
|
+
"""C++ method: get_masses"""
|
|
164
|
+
...
|
|
165
|
+
|
|
166
|
+
def get_names(self, *args: Any, **kwargs: Any) -> Any:
|
|
167
|
+
"""C++ method: get_names"""
|
|
168
|
+
...
|
|
169
|
+
|
|
170
|
+
def get_orbital_period(self, *args: Any, **kwargs: Any) -> Any:
|
|
171
|
+
"""C++ method: get_orbital_period"""
|
|
172
|
+
...
|
|
173
|
+
|
|
174
|
+
def get_positions(self, *args: Any, **kwargs: Any) -> Any:
|
|
175
|
+
"""C++ method: get_positions"""
|
|
176
|
+
...
|
|
177
|
+
|
|
178
|
+
def get_positions_au(self, *args: Any, **kwargs: Any) -> Any:
|
|
179
|
+
"""C++ method: get_positions_au"""
|
|
180
|
+
...
|
|
181
|
+
|
|
182
|
+
def get_radii(self, *args: Any, **kwargs: Any) -> Any:
|
|
183
|
+
"""C++ method: get_radii"""
|
|
184
|
+
...
|
|
185
|
+
|
|
186
|
+
def get_simulation_time(self, *args: Any, **kwargs: Any) -> Any:
|
|
187
|
+
"""C++ method: get_simulation_time"""
|
|
188
|
+
...
|
|
189
|
+
|
|
190
|
+
def get_simulation_time_days(self, *args: Any, **kwargs: Any) -> Any:
|
|
191
|
+
"""C++ method: get_simulation_time_days"""
|
|
192
|
+
...
|
|
193
|
+
|
|
194
|
+
def get_simulation_time_years(self, *args: Any, **kwargs: Any) -> Any:
|
|
195
|
+
"""C++ method: get_simulation_time_years"""
|
|
196
|
+
...
|
|
197
|
+
|
|
198
|
+
def get_speed(self, *args: Any, **kwargs: Any) -> Any:
|
|
199
|
+
"""C++ method: get_speed"""
|
|
200
|
+
...
|
|
201
|
+
|
|
202
|
+
def get_step_count(self, *args: Any, **kwargs: Any) -> Any:
|
|
203
|
+
"""C++ method: get_step_count"""
|
|
204
|
+
...
|
|
205
|
+
|
|
206
|
+
def get_total_energy(self, *args: Any, **kwargs: Any) -> Any:
|
|
207
|
+
"""C++ method: get_total_energy"""
|
|
208
|
+
...
|
|
209
|
+
|
|
210
|
+
def get_trajectory(self, *args: Any, **kwargs: Any) -> Any:
|
|
211
|
+
"""C++ method: get_trajectory"""
|
|
212
|
+
...
|
|
213
|
+
|
|
214
|
+
def get_velocities(self, *args: Any, **kwargs: Any) -> Any:
|
|
215
|
+
"""C++ method: get_velocities"""
|
|
216
|
+
...
|
|
217
|
+
|
|
218
|
+
def init_real_solar_system(self, *args: Any, **kwargs: Any) -> Any:
|
|
219
|
+
"""C++ method: init_real_solar_system"""
|
|
220
|
+
...
|
|
221
|
+
|
|
222
|
+
def simulate(self, *args: Any, **kwargs: Any) -> Any:
|
|
223
|
+
"""C++ method: simulate"""
|
|
224
|
+
...
|
|
225
|
+
|
|
226
|
+
def step(self, *args: Any, **kwargs: Any) -> Any:
|
|
227
|
+
"""C++ method: step"""
|
|
228
|
+
...
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def get_AU(self, *args: Any, **kwargs: Any) -> Any:
|
|
232
|
+
"""C++ function: get_AU"""
|
|
233
|
+
...
|
|
234
|
+
|
|
235
|
+
def get_DAY(self, *args: Any, **kwargs: Any) -> Any:
|
|
236
|
+
"""C++ function: get_DAY"""
|
|
237
|
+
...
|
|
238
|
+
|
|
239
|
+
def get_G(self, *args: Any, **kwargs: Any) -> Any:
|
|
240
|
+
"""C++ function: get_G"""
|
|
241
|
+
...
|
|
242
|
+
|
|
243
|
+
def get_YEAR(self, *args: Any, **kwargs: Any) -> Any:
|
|
244
|
+
"""C++ function: get_YEAR"""
|
|
245
|
+
...
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class TemplatesModuleWrapper(Protocol):
|
|
250
|
+
"""Type hints for templates module wrapper (VSCode autocomplete support)."""
|
|
251
|
+
|
|
252
|
+
def getInfo(self) -> Dict[str, Any]:
|
|
253
|
+
"""Get templates module information."""
|
|
254
|
+
...
|
|
255
|
+
|
|
256
|
+
class Pointf:
|
|
257
|
+
"""C++ class: Pointf"""
|
|
258
|
+
|
|
259
|
+
@overload
|
|
260
|
+
def __init__(self) -> None: ...
|
|
261
|
+
@overload
|
|
262
|
+
def __init__(self, arg0: float, arg1: float) -> None: ...
|
|
263
|
+
|
|
264
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
265
|
+
"""Initialize Pointf instance"""
|
|
266
|
+
...
|
|
267
|
+
|
|
268
|
+
def distanceFromOrigin(self, *args: Any, **kwargs: Any) -> Any:
|
|
269
|
+
"""C++ method: distanceFromOrigin"""
|
|
270
|
+
...
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class Pointi:
|
|
274
|
+
"""C++ class: Pointi"""
|
|
275
|
+
|
|
276
|
+
@overload
|
|
277
|
+
def __init__(self) -> None: ...
|
|
278
|
+
@overload
|
|
279
|
+
def __init__(self, arg0: int, arg1: int) -> None: ...
|
|
280
|
+
|
|
281
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
282
|
+
"""Initialize Pointi instance"""
|
|
283
|
+
...
|
|
284
|
+
|
|
285
|
+
def distanceFromOrigin(self, *args: Any, **kwargs: Any) -> Any:
|
|
286
|
+
"""C++ method: distanceFromOrigin"""
|
|
287
|
+
...
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def maximum(self, *args: Any, **kwargs: Any) -> Any:
|
|
291
|
+
"""C++ function: maximum"""
|
|
292
|
+
...
|
|
293
|
+
|
|
294
|
+
def sumVector(self, *args: Any, **kwargs: Any) -> Any:
|
|
295
|
+
"""C++ function: sumVector"""
|
|
296
|
+
...
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
# CppApi with typed include() overloads for each module
|
|
301
|
+
class CppApi:
|
|
302
|
+
"""C++ API Manager with typed module loading.
|
|
303
|
+
|
|
304
|
+
The include() method returns a module wrapper with full type hints
|
|
305
|
+
for VSCode/PyCharm autocomplete support.
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
def __init__(self, project_root: Optional[str] = None, auto_update: bool = True) -> None:
|
|
309
|
+
"""Initialize CppApi.
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
project_root: Path to project root (default: auto-detect)
|
|
313
|
+
auto_update: Whether to auto-rebuild on source changes
|
|
314
|
+
"""
|
|
315
|
+
...
|
|
316
|
+
|
|
317
|
+
@overload
|
|
318
|
+
def include(self, module_name: str = "fast_list", auto_update: Optional[bool] = None) -> Fast_listModuleWrapper: ...
|
|
319
|
+
|
|
320
|
+
@overload
|
|
321
|
+
def include(self, module_name: str = "game_math", auto_update: Optional[bool] = None) -> Game_mathModuleWrapper: ...
|
|
322
|
+
|
|
323
|
+
@overload
|
|
324
|
+
def include(self, module_name: str = "solar_system", auto_update: Optional[bool] = None) -> Solar_systemModuleWrapper: ...
|
|
325
|
+
|
|
326
|
+
@overload
|
|
327
|
+
def include(self, module_name: str = "templates", auto_update: Optional[bool] = None) -> TemplatesModuleWrapper: ...
|
|
328
|
+
|
|
329
|
+
@overload
|
|
330
|
+
def include(self, module_name: str, auto_update: Optional[bool] = None) -> Any: ...
|
|
331
|
+
|
|
332
|
+
def include(self, module_name: str, auto_update: Optional[bool] = None) -> Any:
|
|
333
|
+
"""Load a C++ module.
|
|
334
|
+
|
|
335
|
+
Args:
|
|
336
|
+
module_name: Name of the module to load
|
|
337
|
+
auto_update: Override auto-update setting for this module
|
|
338
|
+
|
|
339
|
+
Returns:
|
|
340
|
+
ModuleWrapper with access to C++ classes, functions, and structs
|
|
341
|
+
"""
|
|
342
|
+
...
|
|
343
|
+
|
|
344
|
+
def rebuild(self, verbose: bool = False) -> bool:
|
|
345
|
+
"""Rebuild all C++ modules."""
|
|
346
|
+
...
|
|
347
|
+
|
|
348
|
+
def list_modules(self) -> List[str]:
|
|
349
|
+
"""List available modules."""
|
|
350
|
+
...
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CSSL - C-Style Scripting Language
|
|
2
2
|
|
|
3
|
-
> Version 4.
|
|
3
|
+
> Version 4.1.0 | A modern scripting language with C++-style syntax and unique features like CodeInfusion, BruteInjection, Python Interop, and Multi-Language Support.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
12. [BruteInjection](#bruteinjection)
|
|
21
21
|
13. [Value Capture](#value-capture)
|
|
22
22
|
14. [Module System](#module-system)
|
|
23
|
-
15. [
|
|
24
|
-
16. [
|
|
23
|
+
15. [Multi-Language Support](#multi-language-support)
|
|
24
|
+
16. [Error Handling](#error-handling)
|
|
25
|
+
17. [Quick Reference](#quick-reference)
|
|
25
26
|
|
|
26
27
|
---
|
|
27
28
|
|
|
@@ -101,15 +102,21 @@ printl("Hello") // Works
|
|
|
101
102
|
printl("Hello"); // Also works (recommended)
|
|
102
103
|
```
|
|
103
104
|
|
|
104
|
-
###
|
|
105
|
+
### I/O Functions
|
|
105
106
|
|
|
106
107
|
```cssl
|
|
108
|
+
// Output
|
|
107
109
|
printl("Text"); // Print with newline
|
|
108
110
|
print("No newline"); // Print without newline
|
|
109
111
|
debug("Debug info"); // Print with [DEBUG] prefix
|
|
110
112
|
error("Error message"); // Print with [ERROR] prefix
|
|
111
113
|
warn("Warning"); // Print with [WARN] prefix
|
|
112
114
|
log("INFO", "Message"); // Print with custom prefix
|
|
115
|
+
|
|
116
|
+
// Input
|
|
117
|
+
string name = input("Enter your name: ");
|
|
118
|
+
int age = int(input("Enter your age: "));
|
|
119
|
+
string raw = input(); // Without prompt
|
|
113
120
|
```
|
|
114
121
|
|
|
115
122
|
---
|
|
@@ -1398,6 +1405,161 @@ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
|
|
|
1398
1405
|
|
|
1399
1406
|
---
|
|
1400
1407
|
|
|
1408
|
+
## Multi-Language Support
|
|
1409
|
+
|
|
1410
|
+
CSSL v4.1.0 introduces multi-language support for interoperability with other programming languages.
|
|
1411
|
+
|
|
1412
|
+
### libinclude - Load Language Support
|
|
1413
|
+
|
|
1414
|
+
Use `libinclude()` to load a language support module:
|
|
1415
|
+
|
|
1416
|
+
```cssl
|
|
1417
|
+
// Load language support
|
|
1418
|
+
@py = libinclude("python");
|
|
1419
|
+
cpp = libinclude("c++");
|
|
1420
|
+
java = libinclude("java");
|
|
1421
|
+
csharp = libinclude("c#");
|
|
1422
|
+
js = libinclude("javascript");
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
**Supported Languages:**
|
|
1426
|
+
|
|
1427
|
+
| Language | Identifiers |
|
|
1428
|
+
|----------|-------------|
|
|
1429
|
+
| Python | `python`, `py` |
|
|
1430
|
+
| C++ | `c++`, `cpp` |
|
|
1431
|
+
| Java | `java` |
|
|
1432
|
+
| C# | `c#`, `csharp` |
|
|
1433
|
+
| JavaScript | `javascript`, `js` |
|
|
1434
|
+
|
|
1435
|
+
### supports - Multi-Language Syntax
|
|
1436
|
+
|
|
1437
|
+
Use the `supports` keyword to write functions or classes using another language's syntax:
|
|
1438
|
+
|
|
1439
|
+
```cssl
|
|
1440
|
+
// Python-style function
|
|
1441
|
+
define calculate(numbers) : supports python {
|
|
1442
|
+
total = 0
|
|
1443
|
+
for n in numbers:
|
|
1444
|
+
total = total + n
|
|
1445
|
+
return total
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
// C++ style class
|
|
1449
|
+
class Engine : supports cpp {
|
|
1450
|
+
int power;
|
|
1451
|
+
bool running;
|
|
1452
|
+
|
|
1453
|
+
void start() {
|
|
1454
|
+
this->running = true;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// JavaScript style function
|
|
1459
|
+
define fetchData(url) : supports javascript {
|
|
1460
|
+
let response = fetch(url);
|
|
1461
|
+
console.log("Fetched: " + url);
|
|
1462
|
+
return response;
|
|
1463
|
+
}
|
|
1464
|
+
```
|
|
1465
|
+
|
|
1466
|
+
### Cross-Language Instance Access
|
|
1467
|
+
|
|
1468
|
+
Access instances shared from other languages using `lang$InstanceName` syntax:
|
|
1469
|
+
|
|
1470
|
+
```cssl
|
|
1471
|
+
cpp = libinclude("c++");
|
|
1472
|
+
|
|
1473
|
+
// Access C++ shared instance
|
|
1474
|
+
engine = cpp$MyEngine;
|
|
1475
|
+
printl(engine.power);
|
|
1476
|
+
|
|
1477
|
+
// Cross-language inheritance
|
|
1478
|
+
class TurboEngine : extends cpp$Engine {
|
|
1479
|
+
int turboBoost;
|
|
1480
|
+
|
|
1481
|
+
constr TurboEngine(int boost) {
|
|
1482
|
+
this->turboBoost = boost;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
```
|
|
1486
|
+
|
|
1487
|
+
### Instance Sharing API
|
|
1488
|
+
|
|
1489
|
+
Share instances between languages using the `share()` and `get_instance()` methods:
|
|
1490
|
+
|
|
1491
|
+
```cssl
|
|
1492
|
+
// Get language support
|
|
1493
|
+
cpp = libinclude("c++");
|
|
1494
|
+
|
|
1495
|
+
// Share a CSSL instance with C++
|
|
1496
|
+
class MyClass {
|
|
1497
|
+
string value;
|
|
1498
|
+
}
|
|
1499
|
+
instance = new MyClass();
|
|
1500
|
+
cpp.share("MyClass", instance);
|
|
1501
|
+
|
|
1502
|
+
// Access from C++:
|
|
1503
|
+
// auto* obj = CSSL_GET(MyClass, "MyClass");
|
|
1504
|
+
```
|
|
1505
|
+
|
|
1506
|
+
### Language SDKs
|
|
1507
|
+
|
|
1508
|
+
SDKs are available for sharing instances from other languages into CSSL:
|
|
1509
|
+
|
|
1510
|
+
**C++ SDK:**
|
|
1511
|
+
```cpp
|
|
1512
|
+
#include "includecpp.h"
|
|
1513
|
+
|
|
1514
|
+
class Engine { public: int power = 100; };
|
|
1515
|
+
|
|
1516
|
+
Engine engine;
|
|
1517
|
+
CSSL_SHARE(Engine, &engine);
|
|
1518
|
+
// Now accessible as cpp$Engine in CSSL
|
|
1519
|
+
```
|
|
1520
|
+
|
|
1521
|
+
**Java SDK:**
|
|
1522
|
+
```java
|
|
1523
|
+
import com.includecpp.CSSL;
|
|
1524
|
+
|
|
1525
|
+
MyService svc = new MyService();
|
|
1526
|
+
CSSL.share("MyService", svc);
|
|
1527
|
+
// Now accessible as java$MyService in CSSL
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
**C# SDK:**
|
|
1531
|
+
```csharp
|
|
1532
|
+
using IncludeCPP;
|
|
1533
|
+
|
|
1534
|
+
var service = new MyService();
|
|
1535
|
+
CSSL.Share("MyService", service);
|
|
1536
|
+
// Now accessible as csharp$MyService in CSSL
|
|
1537
|
+
```
|
|
1538
|
+
|
|
1539
|
+
**JavaScript SDK:**
|
|
1540
|
+
```javascript
|
|
1541
|
+
import { CSSL } from 'includecpp-cssl';
|
|
1542
|
+
|
|
1543
|
+
class DataProcessor { process(data) { } }
|
|
1544
|
+
CSSL.share('DataProcessor', new DataProcessor());
|
|
1545
|
+
// Now accessible as js$DataProcessor in CSSL
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
### SDK API Reference
|
|
1549
|
+
|
|
1550
|
+
All language SDKs provide these methods:
|
|
1551
|
+
|
|
1552
|
+
| Method | Description |
|
|
1553
|
+
|--------|-------------|
|
|
1554
|
+
| `share(name, instance)` | Share an instance by name |
|
|
1555
|
+
| `get(name)` | Get a shared instance |
|
|
1556
|
+
| `has(name)` | Check if instance exists |
|
|
1557
|
+
| `remove(name)` | Remove a shared instance |
|
|
1558
|
+
| `list()` | Get all instance names |
|
|
1559
|
+
| `clear()` | Clear all instances |
|
|
1560
|
+
|
|
1561
|
+
---
|
|
1562
|
+
|
|
1401
1563
|
## Error Handling
|
|
1402
1564
|
|
|
1403
1565
|
### Try / Catch
|
|
@@ -1495,7 +1657,26 @@ assert(x > 0, "x must be positive");
|
|
|
1495
1657
|
| `global define func()` | Global function declaration |
|
|
1496
1658
|
| `define @func()` | Global function (alt syntax) |
|
|
1497
1659
|
| `new @ClassName()` | Instantiate global class |
|
|
1660
|
+
| `libinclude("lang")` | Load language support module |
|
|
1661
|
+
| `supports lang` | Use other language syntax |
|
|
1662
|
+
| `lang$InstanceName` | Cross-language instance access |
|
|
1663
|
+
|
|
1664
|
+
### Multi-Language Keywords
|
|
1665
|
+
|
|
1666
|
+
| Keyword | Description |
|
|
1667
|
+
|---------|-------------|
|
|
1668
|
+
| `libinclude` | Load language support module |
|
|
1669
|
+
| `supports` | Use another language's syntax in function/class |
|
|
1670
|
+
|
|
1671
|
+
### Cross-Language Syntax
|
|
1672
|
+
|
|
1673
|
+
| Syntax | Description | Example |
|
|
1674
|
+
|--------|-------------|---------|
|
|
1675
|
+
| `libinclude("lang")` | Load language support | `cpp = libinclude("c++")` |
|
|
1676
|
+
| `: supports lang` | Use language syntax | `define func() : supports python { }` |
|
|
1677
|
+
| `lang$Name` | Access shared instance | `cpp$Engine`, `java$Service` |
|
|
1678
|
+
| `extends lang$Name` | Inherit from shared class | `class Child : extends cpp$Parent { }` |
|
|
1498
1679
|
|
|
1499
1680
|
---
|
|
1500
1681
|
|
|
1501
|
-
*CSSL v4.
|
|
1682
|
+
*CSSL v4.1.0 - Developed as part of IncludeCPP*
|