IncludeCPP 3.7.9__py3-none-any.whl → 3.8.0__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.
@@ -1,7 +1,7 @@
1
1
  """
2
2
  CSSL Syntax Highlighting
3
3
 
4
- Provides syntax highlighting for CSSL (CSO Service Script Language) code.
4
+ Provides syntax highlighting for CSSL code.
5
5
  Can be used with:
6
6
  - PyQt5/6 QSyntaxHighlighter
7
7
  - VSCode/TextMate grammar export
@@ -216,8 +216,8 @@ class CSSLSyntaxRules:
216
216
  class ColorScheme:
217
217
  """Color scheme for syntax highlighting"""
218
218
 
219
- # CSO Theme (Orange accent, dark background)
220
- CSO_THEME = {
219
+ # CSSL Theme (Orange accent, dark background)
220
+ CSSL_THEME = {
221
221
  TokenCategory.KEYWORD: '#508cff', # Blue
222
222
  TokenCategory.BUILTIN: '#ff8c00', # Orange
223
223
  TokenCategory.OPERATOR: '#c8c8d2', # Light gray
@@ -261,13 +261,13 @@ def highlight_cssl(source: str, scheme: Dict[TokenCategory, str] = None) -> List
261
261
 
262
262
  Args:
263
263
  source: CSSL source code
264
- scheme: Color scheme dict (defaults to CSO_THEME)
264
+ scheme: Color scheme dict (defaults to CSSL_THEME)
265
265
 
266
266
  Returns:
267
267
  List of (start, end, color, category) tuples
268
268
  """
269
269
  if scheme is None:
270
- scheme = ColorScheme.CSO_THEME
270
+ scheme = ColorScheme.CSSL_THEME
271
271
 
272
272
  highlights = []
273
273
  rules = CSSLSyntaxRules.get_rules()
@@ -337,7 +337,7 @@ def highlight_cssl_ansi(source: str) -> str:
337
337
  }
338
338
  RESET = '\033[0m'
339
339
 
340
- highlights = highlight_cssl(source, ColorScheme.CSO_THEME)
340
+ highlights = highlight_cssl(source, ColorScheme.CSSL_THEME)
341
341
 
342
342
  # Build highlighted string
343
343
  result = []
@@ -388,7 +388,7 @@ def get_pyqt_highlighter():
388
388
 
389
389
  def _setup_rules(self):
390
390
  """Setup highlighting rules"""
391
- scheme = ColorScheme.CSO_THEME
391
+ scheme = ColorScheme.CSSL_THEME
392
392
 
393
393
  for rule in CSSLSyntaxRules.get_rules():
394
394
  fmt = QTextCharFormat()
@@ -1,5 +1,5 @@
1
1
  """
2
- CSSL Data Types - Advanced container types for CSO Service Script Language
2
+ CSSL Data Types - Advanced container types for CSSL
3
3
 
4
4
  Types:
5
5
  - datastruct<T>: Universal container (lazy declarator) - can hold any type
@@ -64,6 +64,33 @@ class DataStruct(list):
64
64
  return target_type(self[0])
65
65
  return None
66
66
 
67
+ def length(self) -> int:
68
+ """Return datastruct length"""
69
+ return len(self)
70
+
71
+ def size(self) -> int:
72
+ """Return datastruct size (alias for length)"""
73
+ return len(self)
74
+
75
+ def push(self, item: Any) -> 'DataStruct':
76
+ """Push item to datastruct (alias for add)"""
77
+ self.append(item)
78
+ return self
79
+
80
+ def isEmpty(self) -> bool:
81
+ """Check if datastruct is empty"""
82
+ return len(self) == 0
83
+
84
+ def contains(self, item: Any) -> bool:
85
+ """Check if datastruct contains item"""
86
+ return item in self
87
+
88
+ def at(self, index: int) -> Any:
89
+ """Get item at index (safe access)"""
90
+ if 0 <= index < len(self):
91
+ return self[index]
92
+ return None
93
+
67
94
  def begin(self) -> int:
68
95
  """Return iterator to beginning (C++ style)"""
69
96
  return 0
@@ -99,6 +126,16 @@ class Stack(list):
99
126
  self.append(item)
100
127
  return self
101
128
 
129
+ def pop(self) -> Any:
130
+ """Pop and return top element from stack"""
131
+ if len(self) == 0:
132
+ return None
133
+ return super().pop()
134
+
135
+ def pop_back(self) -> Any:
136
+ """Pop and return top element (alias for pop)"""
137
+ return self.pop()
138
+
102
139
  def peek(self) -> Any:
103
140
  """View top item without removing"""
104
141
  return self[-1] if self else None
@@ -701,6 +738,39 @@ class List(list):
701
738
  self.extend([value] * count)
702
739
  return self
703
740
 
741
+ def map(self, func: Callable[[Any], Any]) -> 'List':
742
+ """Apply function to all elements"""
743
+ result = List(self._element_type)
744
+ result.extend(func(item) for item in self)
745
+ return result
746
+
747
+ def filter(self, predicate: Callable[[Any], bool]) -> 'List':
748
+ """Filter elements by predicate"""
749
+ result = List(self._element_type)
750
+ result.extend(item for item in self if predicate(item))
751
+ return result
752
+
753
+ def forEach(self, func: Callable[[Any], None]) -> 'List':
754
+ """Execute function for each element"""
755
+ for item in self:
756
+ func(item)
757
+ return self
758
+
759
+ def reduce(self, func: Callable[[Any, Any], Any], initial: Any = None) -> Any:
760
+ """Reduce list to single value"""
761
+ from functools import reduce as py_reduce
762
+ if initial is None:
763
+ return py_reduce(func, self)
764
+ return py_reduce(func, self, initial)
765
+
766
+ def every(self, predicate: Callable[[Any], bool]) -> bool:
767
+ """Check if all elements match predicate"""
768
+ return all(predicate(item) for item in self)
769
+
770
+ def some(self, predicate: Callable[[Any], bool]) -> bool:
771
+ """Check if any element matches predicate"""
772
+ return any(predicate(item) for item in self)
773
+
704
774
  def begin(self) -> int:
705
775
  """Return iterator to beginning"""
706
776
  return 0
@@ -1499,7 +1569,10 @@ class CSSLInstance:
1499
1569
  object.__setattr__(self, name, value)
1500
1570
 
1501
1571
  def __repr__(self):
1502
- return f"<CSSLInstance of '{self._class.name}'>"
1572
+ return f"<{self._class.name} instance at 0x{id(self):x}>"
1573
+
1574
+ def __str__(self):
1575
+ return f"<{self._class.name} instance at 0x{id(self):x}>"
1503
1576
 
1504
1577
 
1505
1578
  __all__ = [
@@ -11,6 +11,7 @@ v3.8.0 API:
11
11
  cssl.include(path, name) - Register for payload(name)
12
12
  """
13
13
 
14
+ import atexit
14
15
  import os
15
16
  import pickle
16
17
  import random
@@ -33,6 +34,23 @@ def _get_share_directory() -> Path:
33
34
  return share_dir
34
35
 
35
36
 
37
+ def _cleanup_shared_objects() -> None:
38
+ """Clean up all shared object marker files on process exit."""
39
+ try:
40
+ share_dir = _get_share_directory()
41
+ if share_dir.exists():
42
+ for f in share_dir.glob('*.shareobj*'):
43
+ try:
44
+ f.unlink()
45
+ except Exception:
46
+ pass
47
+ except Exception:
48
+ pass
49
+
50
+ # Register cleanup on process exit
51
+ atexit.register(_cleanup_shared_objects)
52
+
53
+
36
54
  # Global live object registry - holds actual object references for live sharing
37
55
  _live_objects: Dict[str, Any] = {}
38
56
 
@@ -404,12 +422,19 @@ class CsslLang:
404
422
  """
405
423
  runtime = self._get_runtime()
406
424
 
407
- # Check if it's a file path
408
- path = Path(path_or_code)
409
- if path.exists() and path.suffix in ('.cssl', '.cssl-mod', '.cssl-pl'):
410
- source = path.read_text(encoding='utf-8')
411
- else:
412
- source = path_or_code
425
+ # Check if it's a file path (not code)
426
+ # Code detection: contains newlines, semicolons, or braces = definitely code
427
+ is_likely_code = '\n' in path_or_code or ';' in path_or_code or '{' in path_or_code
428
+ source = path_or_code
429
+
430
+ if not is_likely_code:
431
+ try:
432
+ path = Path(path_or_code)
433
+ if path.exists() and path.suffix in ('.cssl', '.cssl-mod', '.cssl-pl'):
434
+ source = path.read_text(encoding='utf-8')
435
+ except OSError:
436
+ # Path too long or invalid - treat as code
437
+ pass
413
438
 
414
439
  # Set arguments in runtime scope
415
440
  from .cssl import Parameter
@@ -1064,6 +1089,38 @@ def shared(name: str) -> Optional[Any]:
1064
1089
  return get_shared(name)
1065
1090
 
1066
1091
 
1092
+ def cleanup_shared() -> int:
1093
+ """
1094
+ Manually clean up all shared object marker files.
1095
+
1096
+ Call this to remove stale .shareobj files from %APPDATA%/IncludeCPP/shared_objects/
1097
+ that may have accumulated from previous sessions.
1098
+
1099
+ Returns:
1100
+ Number of files deleted
1101
+ """
1102
+ global _live_objects, _global_shared_objects
1103
+
1104
+ count = 0
1105
+ try:
1106
+ share_dir = _get_share_directory()
1107
+ if share_dir.exists():
1108
+ for f in share_dir.glob('*.shareobj*'):
1109
+ try:
1110
+ f.unlink()
1111
+ count += 1
1112
+ except Exception:
1113
+ pass
1114
+ except Exception:
1115
+ pass
1116
+
1117
+ # Clear in-memory registries
1118
+ _live_objects.clear()
1119
+ _global_shared_objects.clear()
1120
+
1121
+ return count
1122
+
1123
+
1067
1124
  # Singleton for convenience
1068
1125
  _default_instance: Optional[CsslLang] = None
1069
1126
 
@@ -1308,4 +1365,5 @@ __all__ = [
1308
1365
  'unshare',
1309
1366
  'shared',
1310
1367
  'get_shared',
1368
+ 'cleanup_shared',
1311
1369
  ]
@@ -0,0 +1,133 @@
1
+ // CSSL Language Extension for VS Code
2
+ // Provides run functionality for .cssl files
3
+
4
+ const vscode = require('vscode');
5
+ const path = require('path');
6
+ const { spawn } = require('child_process');
7
+
8
+ let outputChannel;
9
+
10
+ function activate(context) {
11
+ // Create output channel for CSSL
12
+ outputChannel = vscode.window.createOutputChannel('CSSL');
13
+
14
+ // Register the run command
15
+ const runCommand = vscode.commands.registerCommand('cssl.runFile', async () => {
16
+ const editor = vscode.window.activeTextEditor;
17
+
18
+ if (!editor) {
19
+ vscode.window.showErrorMessage('No active editor found');
20
+ return;
21
+ }
22
+
23
+ const document = editor.document;
24
+ const filePath = document.fileName;
25
+ const ext = path.extname(filePath).toLowerCase();
26
+
27
+ // Only allow .cssl files (not .cssl-mod or .cssl-pl)
28
+ if (ext !== '.cssl') {
29
+ vscode.window.showWarningMessage('Only .cssl files can be executed. Modules (.cssl-mod) and Payloads (.cssl-pl) cannot be run directly.');
30
+ return;
31
+ }
32
+
33
+ // Save the file before running
34
+ if (document.isDirty) {
35
+ await document.save();
36
+ }
37
+
38
+ // Get configuration
39
+ const config = vscode.workspace.getConfiguration('cssl');
40
+ const pythonPath = config.get('pythonPath', 'python');
41
+ const showOutput = config.get('showOutput', true);
42
+
43
+ // Show output channel
44
+ if (showOutput) {
45
+ outputChannel.show(true);
46
+ }
47
+
48
+ outputChannel.clear();
49
+ outputChannel.appendLine(`[CSSL] Running: ${path.basename(filePath)}`);
50
+ outputChannel.appendLine(`[CSSL] Path: ${filePath}`);
51
+ outputChannel.appendLine('─'.repeat(50));
52
+
53
+ // Run the CSSL file using includecpp cssl run
54
+ const args = ['-m', 'includecpp', 'cssl', 'run', filePath];
55
+
56
+ const childProcess = spawn(pythonPath, args, {
57
+ cwd: path.dirname(filePath),
58
+ env: { ...process.env }
59
+ });
60
+
61
+ let hasError = false;
62
+
63
+ childProcess.stdout.on('data', (data) => {
64
+ outputChannel.append(data.toString());
65
+ });
66
+
67
+ childProcess.stderr.on('data', (data) => {
68
+ hasError = true;
69
+ outputChannel.append(data.toString());
70
+ });
71
+
72
+ childProcess.on('close', (code) => {
73
+ outputChannel.appendLine('');
74
+ outputChannel.appendLine('─'.repeat(50));
75
+ if (code === 0) {
76
+ outputChannel.appendLine(`[CSSL] Finished successfully`);
77
+ } else {
78
+ outputChannel.appendLine(`[CSSL] Exited with code: ${code}`);
79
+ }
80
+ });
81
+
82
+ childProcess.on('error', (err) => {
83
+ outputChannel.appendLine(`[CSSL] Error: ${err.message}`);
84
+ vscode.window.showErrorMessage(`Failed to run CSSL: ${err.message}. Make sure IncludeCPP is installed (pip install includecpp).`);
85
+ });
86
+ });
87
+
88
+ context.subscriptions.push(runCommand);
89
+ context.subscriptions.push(outputChannel);
90
+
91
+ // Register task provider for CSSL
92
+ const taskProvider = vscode.tasks.registerTaskProvider('cssl', {
93
+ provideTasks: () => {
94
+ return [];
95
+ },
96
+ resolveTask: (task) => {
97
+ if (task.definition.type === 'cssl') {
98
+ const config = vscode.workspace.getConfiguration('cssl');
99
+ const pythonPath = config.get('pythonPath', 'python');
100
+ const file = task.definition.file;
101
+
102
+ const execution = new vscode.ShellExecution(
103
+ `${pythonPath} -m includecpp cssl run "${file}"`
104
+ );
105
+
106
+ return new vscode.Task(
107
+ task.definition,
108
+ vscode.TaskScope.Workspace,
109
+ 'Run CSSL',
110
+ 'cssl',
111
+ execution,
112
+ []
113
+ );
114
+ }
115
+ return undefined;
116
+ }
117
+ });
118
+
119
+ context.subscriptions.push(taskProvider);
120
+
121
+ console.log('CSSL extension activated');
122
+ }
123
+
124
+ function deactivate() {
125
+ if (outputChannel) {
126
+ outputChannel.dispose();
127
+ }
128
+ }
129
+
130
+ module.exports = {
131
+ activate,
132
+ deactivate
133
+ };
Binary file
@@ -1,35 +1,60 @@
1
1
  {
2
2
  "name": "cssl",
3
- "displayName": "CSSL - CSO Service Script Language",
3
+ "displayName": "CSSL Language",
4
4
  "description": "Professional syntax highlighting, snippets, and language support for CSSL scripts (.cssl, .cssl-pl, .cssl-mod)",
5
- "version": "1.1.0",
5
+ "version": "1.3.1",
6
6
  "publisher": "IncludeCPP",
7
- "icon": "images/cssl-icon.png",
7
+ "icon": "images/cssl.png",
8
8
  "engines": {
9
9
  "vscode": "^1.60.0"
10
10
  },
11
11
  "categories": [
12
12
  "Programming Languages",
13
- "Snippets"
13
+ "Snippets",
14
+ "Debuggers"
14
15
  ],
15
16
  "keywords": [
16
17
  "cssl",
17
- "cso",
18
18
  "script",
19
19
  "includecpp",
20
20
  "c++",
21
- "python"
21
+ "python",
22
+ "run"
22
23
  ],
24
+ "activationEvents": [
25
+ "onLanguage:cssl"
26
+ ],
27
+ "main": "./extension.js",
23
28
  "contributes": {
24
29
  "languages": [
25
30
  {
26
31
  "id": "cssl",
27
- "aliases": ["CSSL", "cssl", "CSO Service Script"],
28
- "extensions": [".cssl", ".cssl-pl", ".cssl-mod"],
32
+ "aliases": ["CSSL", "cssl"],
33
+ "extensions": [".cssl"],
34
+ "configuration": "./language-configuration.json",
35
+ "icon": {
36
+ "light": "./images/cssl.png",
37
+ "dark": "./images/cssl.png"
38
+ }
39
+ },
40
+ {
41
+ "id": "cssl-mod",
42
+ "aliases": ["CSSL Module", "cssl-mod"],
43
+ "extensions": [".cssl-mod"],
44
+ "configuration": "./language-configuration.json",
45
+ "icon": {
46
+ "light": "./images/cssl_pl.png",
47
+ "dark": "./images/cssl_pl.png"
48
+ }
49
+ },
50
+ {
51
+ "id": "cssl-pl",
52
+ "aliases": ["CSSL Payload", "cssl-pl"],
53
+ "extensions": [".cssl-pl"],
29
54
  "configuration": "./language-configuration.json",
30
55
  "icon": {
31
- "light": "./images/cssl-icon.png",
32
- "dark": "./images/cssl-icon.png"
56
+ "light": "./images/cssl_pl.png",
57
+ "dark": "./images/cssl_pl.png"
33
58
  }
34
59
  }
35
60
  ],
@@ -38,13 +63,94 @@
38
63
  "language": "cssl",
39
64
  "scopeName": "source.cssl",
40
65
  "path": "./syntaxes/cssl.tmLanguage.json"
66
+ },
67
+ {
68
+ "language": "cssl-mod",
69
+ "scopeName": "source.cssl",
70
+ "path": "./syntaxes/cssl.tmLanguage.json"
71
+ },
72
+ {
73
+ "language": "cssl-pl",
74
+ "scopeName": "source.cssl",
75
+ "path": "./syntaxes/cssl.tmLanguage.json"
41
76
  }
42
77
  ],
43
78
  "snippets": [
44
79
  {
45
80
  "language": "cssl",
46
81
  "path": "./snippets/cssl.snippets.json"
82
+ },
83
+ {
84
+ "language": "cssl-mod",
85
+ "path": "./snippets/cssl.snippets.json"
86
+ },
87
+ {
88
+ "language": "cssl-pl",
89
+ "path": "./snippets/cssl.snippets.json"
90
+ }
91
+ ],
92
+ "commands": [
93
+ {
94
+ "command": "cssl.runFile",
95
+ "title": "Run CSSL File",
96
+ "icon": "$(play)",
97
+ "enablement": "resourceExtname == .cssl"
98
+ }
99
+ ],
100
+ "menus": {
101
+ "editor/title/run": [
102
+ {
103
+ "command": "cssl.runFile",
104
+ "when": "resourceExtname == .cssl",
105
+ "group": "navigation"
106
+ }
107
+ ],
108
+ "editor/context": [
109
+ {
110
+ "command": "cssl.runFile",
111
+ "when": "resourceExtname == .cssl",
112
+ "group": "1_run"
113
+ }
114
+ ]
115
+ },
116
+ "keybindings": [
117
+ {
118
+ "command": "cssl.runFile",
119
+ "key": "f5",
120
+ "when": "resourceExtname == .cssl && !inDebugMode"
121
+ },
122
+ {
123
+ "command": "cssl.runFile",
124
+ "key": "ctrl+f5",
125
+ "when": "resourceExtname == .cssl"
126
+ }
127
+ ],
128
+ "taskDefinitions": [
129
+ {
130
+ "type": "cssl",
131
+ "required": ["file"],
132
+ "properties": {
133
+ "file": {
134
+ "type": "string",
135
+ "description": "The CSSL file to run"
136
+ }
137
+ }
138
+ }
139
+ ],
140
+ "configuration": {
141
+ "title": "CSSL",
142
+ "properties": {
143
+ "cssl.pythonPath": {
144
+ "type": "string",
145
+ "default": "python",
146
+ "description": "Path to Python executable"
147
+ },
148
+ "cssl.showOutput": {
149
+ "type": "boolean",
150
+ "default": true,
151
+ "description": "Show output panel when running CSSL files"
152
+ }
47
153
  }
48
- ]
154
+ }
49
155
  }
50
156
  }