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.
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__ = "3.7.9"
5
+ __version__ = "3.8.0"
6
6
  __all__ = ["CppApi", "CSSL"]
7
7
 
8
8
  # Module-level cache for C++ modules
includecpp/__init__.pyi CHANGED
@@ -13,7 +13,7 @@ except ImportError:
13
13
  pass # Generated during rebuild
14
14
 
15
15
 
16
- # ========== CSSL Module - CSO Service Script Language ==========
16
+ # ========== CSSL Module ==========
17
17
  class _CSSLModule:
18
18
  """CSSL callable module created via CSSL.module()"""
19
19
  def __call__(self, *args: Any) -> Any:
@@ -139,7 +139,7 @@ class _CSSLBridge:
139
139
  ...
140
140
 
141
141
 
142
- # CSSL module instance - CSO Service Script Language
142
+ # CSSL module instance
143
143
  CSSL: _CSSLBridge
144
144
 
145
145
  __version__: str
@@ -7457,11 +7457,24 @@ def cssl():
7457
7457
  pass
7458
7458
 
7459
7459
 
7460
+ @cssl.command(name='run')
7461
+ @click.argument('path', required=False, type=click.Path())
7462
+ @click.option('--code', '-c', type=str, help='Execute code directly')
7463
+ def cssl_run(path, code):
7464
+ """Run/execute CSSL code or file."""
7465
+ _cssl_execute(path, code)
7466
+
7467
+
7460
7468
  @cssl.command(name='exec')
7461
7469
  @click.argument('path', required=False, type=click.Path())
7462
7470
  @click.option('--code', '-c', type=str, help='Execute code directly')
7463
7471
  def cssl_exec(path, code):
7464
- """Execute CSSL code or file."""
7472
+ """Execute CSSL code or file (alias for 'run')."""
7473
+ _cssl_execute(path, code)
7474
+
7475
+
7476
+ def _cssl_execute(path, code):
7477
+ """Internal: Execute CSSL code or file."""
7465
7478
  from pathlib import Path as PathLib
7466
7479
 
7467
7480
  try:
@@ -7720,7 +7733,13 @@ def cssl_doc(search, list_sections):
7720
7733
  click.echo("Or use: includecpp cssl doc --list")
7721
7734
  else:
7722
7735
  # Full documentation mode
7723
- click.echo_via_pager(content)
7736
+ # Replace Unicode characters that may not be supported on all terminals
7737
+ safe_content = content.replace('✓', '[OK]').replace('✗', '[X]').replace('→', '->').replace('←', '<-').replace('•', '*').replace('─', '-').replace('│', '|').replace('└', '+').replace('├', '+').replace('▸', '>').replace('▾', 'v')
7738
+ try:
7739
+ click.echo_via_pager(safe_content)
7740
+ except UnicodeEncodeError:
7741
+ # Fallback: encode with errors='replace'
7742
+ click.echo(safe_content.encode('ascii', errors='replace').decode('ascii'))
7724
7743
  else:
7725
7744
  click.secho("Documentation file not found.", fg='yellow')
7726
7745
  click.echo("Looking for: CSSL_DOCUMENTATION.md")
@@ -7858,26 +7877,46 @@ def cssl_vscode():
7858
7877
  click.secho("CSSL extension files not found in package.", fg='red')
7859
7878
  return
7860
7879
 
7861
- # Install extension
7862
- target_dir = vscode_ext_dir / 'includecpp.cssl-1.0.0'
7880
+ # Get version from package.json
7881
+ pkg_json = source_ext_dir / 'package.json'
7882
+ current_version = "1.1.0"
7883
+ if pkg_json.exists():
7884
+ try:
7885
+ pkg_data = json.loads(pkg_json.read_text(encoding='utf-8'))
7886
+ current_version = pkg_data.get('version', '1.1.0')
7887
+ except:
7888
+ pass
7889
+
7890
+ target_dir = vscode_ext_dir / f'includecpp.cssl-{current_version}'
7863
7891
 
7864
7892
  try:
7893
+ # Check for existing installations
7894
+ existing_version = None
7895
+ for existing in vscode_ext_dir.glob('includecpp.cssl-*'):
7896
+ existing_version = existing.name.split('-')[-1]
7897
+ if existing_version != current_version:
7898
+ click.echo(f"Removing old version: {existing_version}")
7899
+ shutil.rmtree(existing)
7900
+
7865
7901
  if target_dir.exists():
7866
7902
  shutil.rmtree(target_dir)
7867
7903
 
7868
7904
  shutil.copytree(source_ext_dir, target_dir)
7869
7905
 
7870
- click.secho("CSSL VSCode extension installed!", fg='green', bold=True)
7906
+ if existing_version and existing_version != current_version:
7907
+ click.secho(f"CSSL extension updated: v{existing_version} -> v{current_version}", fg='green', bold=True)
7908
+ else:
7909
+ click.secho(f"CSSL VSCode extension installed! (v{current_version})", fg='green', bold=True)
7871
7910
  click.echo()
7872
7911
  click.echo(f"Installed to: {target_dir}")
7873
7912
  click.echo()
7874
7913
  click.echo("Features:")
7875
7914
  click.echo(" - Syntax highlighting for .cssl, .cssl-pl, .cssl-mod files")
7876
- click.echo(" - BruteInjection operators: <==, ==>, <<==, +<==, etc.")
7877
- click.echo(" - Type highlighting: int, string, stack<T>, datastruct<T>")
7915
+ click.echo(" - OOP support: class, constructor, this->member")
7916
+ click.echo(" - Injection operators: <== (brute), <<== (infuse)")
7917
+ click.echo(" - Type highlighting: int, string, stack<T>, instance<>")
7878
7918
  click.echo(" - Global references: @Name, r@Name, s@Name")
7879
7919
  click.echo(" - Shared objects: $Name")
7880
- click.echo(" - Filter helpers: string::contains, json::key, etc.")
7881
7920
  click.echo()
7882
7921
  click.secho("Restart VSCode to activate the extension.", fg='yellow')
7883
7922
 
@@ -7897,39 +7936,34 @@ cli.add_command(cssl)
7897
7936
 
7898
7937
  @cli.command()
7899
7938
  @click.option('--force', '-f', is_flag=True, help='Force overwrite existing files')
7939
+ @click.option('--reinstall', '-r', is_flag=True, help='Reinstall extension (removes all versions first)')
7900
7940
  @click.option('--stubs-only', is_flag=True, help='Only update stubs, skip extension files')
7901
- def vscode(force, stubs_only):
7941
+ def vscode(force, reinstall, stubs_only):
7902
7942
  """Initialize or update VSCode configuration for IncludeCPP/CSSL.
7903
7943
 
7904
- Sets up .vscode folder with:
7905
- - CSSL language support (syntax highlighting, snippets)
7906
- - Type stubs for builtins (.pyi files)
7907
- - Auto-generated stubs for your plugins and modules
7944
+ Installs CSSL extension globally and sets up project stubs.
7908
7945
 
7909
7946
  \b
7910
7947
  Usage:
7911
- includecpp vscode # Initialize .vscode
7912
- includecpp vscode --force # Force overwrite existing
7948
+ includecpp vscode # Install/update extension + stubs
7949
+ includecpp vscode --force # Force reinstall extension
7950
+ includecpp vscode --reinstall # Remove ALL versions & reinstall fresh
7913
7951
  includecpp vscode --stubs-only # Only update stubs
7914
7952
 
7915
7953
  \b
7916
- What it creates:
7917
- .vscode/
7918
- settings.json - VSCode settings for CSSL
7919
- cssl/ - CSSL language extension
7920
- stubs/ - Type stubs for IDE support
7921
- cssl_builtins.pyi - CSSL builtin functions
7922
- plugins/ - Stubs for your .cp plugins
7923
- modules/ - Stubs for your modules
7954
+ What it does:
7955
+ 1. Installs CSSL extension globally (~/.vscode/extensions/)
7956
+ 2. Creates .vscode/settings.json with file associations
7957
+ 3. Creates .vscode/stubs/ with type hints for IDE support
7924
7958
  """
7925
7959
  from pathlib import Path as PathLib
7960
+ import os
7926
7961
 
7927
7962
  cwd = PathLib.cwd()
7928
7963
  vscode_dir = cwd / '.vscode'
7929
7964
  stubs_dir = vscode_dir / 'stubs'
7930
7965
  plugins_stubs_dir = stubs_dir / 'plugins'
7931
7966
  modules_stubs_dir = stubs_dir / 'modules'
7932
- cssl_ext_dir = vscode_dir / 'cssl'
7933
7967
 
7934
7968
  # Create directories
7935
7969
  vscode_dir.mkdir(exist_ok=True)
@@ -7945,56 +7979,84 @@ def vscode(force, stubs_only):
7945
7979
  updated_count = 0
7946
7980
  created_count = 0
7947
7981
 
7948
- # 1. Copy CSSL extension files (unless stubs-only)
7982
+ # 1. Install CSSL extension GLOBALLY (unless stubs-only)
7949
7983
  if not stubs_only:
7950
- click.secho("Setting up CSSL language support...", fg='yellow')
7984
+ click.secho("Installing CSSL extension globally...", fg='yellow')
7951
7985
 
7952
7986
  # Find source extension directory
7953
7987
  source_ext_dir = PathLib(__file__).parent.parent / 'vscode' / 'cssl'
7954
7988
 
7955
7989
  if source_ext_dir.exists():
7956
- cssl_ext_dir.mkdir(exist_ok=True)
7957
-
7958
- # Copy extension files
7959
- ext_files = [
7960
- 'language-configuration.json',
7961
- 'package.json',
7962
- ]
7963
-
7964
- for fname in ext_files:
7965
- src = source_ext_dir / fname
7966
- dst = cssl_ext_dir / fname
7967
- if src.exists():
7968
- if not dst.exists() or force:
7969
- shutil.copy2(src, dst)
7970
- created_count += 1
7971
- click.echo(f" Created: .vscode/cssl/{fname}")
7972
-
7973
- # Copy syntaxes folder
7974
- syntaxes_src = source_ext_dir / 'syntaxes'
7975
- syntaxes_dst = cssl_ext_dir / 'syntaxes'
7976
- if syntaxes_src.exists():
7977
- syntaxes_dst.mkdir(exist_ok=True)
7978
- for f in syntaxes_src.glob('*.json'):
7979
- dst = syntaxes_dst / f.name
7980
- if not dst.exists() or force:
7981
- shutil.copy2(f, dst)
7982
- created_count += 1
7983
- click.echo(f" Created: .vscode/cssl/syntaxes/{f.name}")
7984
-
7985
- # Copy snippets folder
7986
- snippets_src = source_ext_dir / 'snippets'
7987
- snippets_dst = cssl_ext_dir / 'snippets'
7988
- if snippets_src.exists():
7989
- snippets_dst.mkdir(exist_ok=True)
7990
- for f in snippets_src.glob('*.json'):
7991
- dst = snippets_dst / f.name
7992
- if not dst.exists() or force:
7993
- shutil.copy2(f, dst)
7994
- created_count += 1
7995
- click.echo(f" Created: .vscode/cssl/snippets/{f.name}")
7990
+ # Get version from package.json
7991
+ pkg_json = source_ext_dir / 'package.json'
7992
+ current_version = "1.1.0"
7993
+ if pkg_json.exists():
7994
+ try:
7995
+ pkg_data = json.loads(pkg_json.read_text(encoding='utf-8'))
7996
+ current_version = pkg_data.get('version', '1.1.0')
7997
+ except:
7998
+ pass
7999
+
8000
+ # Find global VSCode extensions directory
8001
+ if os.name == 'nt': # Windows
8002
+ global_ext_dir = PathLib(os.environ.get('USERPROFILE', '')) / '.vscode' / 'extensions'
8003
+ else: # Linux/Mac
8004
+ global_ext_dir = PathLib.home() / '.vscode' / 'extensions'
8005
+
8006
+ if not global_ext_dir.exists():
8007
+ # Try VSCode Insiders
8008
+ if os.name == 'nt':
8009
+ global_ext_dir = PathLib(os.environ.get('USERPROFILE', '')) / '.vscode-insiders' / 'extensions'
8010
+ else:
8011
+ global_ext_dir = PathLib.home() / '.vscode-insiders' / 'extensions'
8012
+
8013
+ if global_ext_dir.exists():
8014
+ target_dir = global_ext_dir / f'includecpp.cssl-{current_version}'
8015
+
8016
+ # Check if already installed with same or older version
8017
+ needs_install = force or reinstall
8018
+ existing_version = None
8019
+
8020
+ # Find existing installations
8021
+ for existing in global_ext_dir.glob('includecpp.cssl-*'):
8022
+ existing_version = existing.name.split('-')[-1]
8023
+ if reinstall:
8024
+ # --reinstall: Remove ALL versions
8025
+ click.echo(f" Removing version: {existing_version}")
8026
+ shutil.rmtree(existing)
8027
+ needs_install = True
8028
+ elif existing_version != current_version:
8029
+ # Remove old version
8030
+ click.echo(f" Removing old version: {existing_version}")
8031
+ shutil.rmtree(existing)
8032
+ needs_install = True
8033
+ elif not force:
8034
+ click.echo(f" Already installed: v{current_version}")
8035
+ needs_install = False
8036
+
8037
+ if not target_dir.exists():
8038
+ needs_install = True
8039
+
8040
+ if needs_install:
8041
+ # Remove target if exists (force reinstall)
8042
+ if target_dir.exists():
8043
+ shutil.rmtree(target_dir)
8044
+
8045
+ # Copy extension to global directory
8046
+ shutil.copytree(source_ext_dir, target_dir)
8047
+ created_count += 1
8048
+
8049
+ if existing_version and existing_version != current_version:
8050
+ click.secho(f" Updated: v{existing_version} -> v{current_version}", fg='green')
8051
+ else:
8052
+ click.secho(f" Installed: v{current_version}", fg='green')
7996
8053
 
7997
- click.secho(" CSSL extension configured", fg='green')
8054
+ click.echo(f" Location: {target_dir}")
8055
+ click.echo()
8056
+ click.secho(" Restart VSCode to activate the extension!", fg='yellow', bold=True)
8057
+ else:
8058
+ click.secho(" VSCode extensions directory not found.", fg='red')
8059
+ click.echo(" Make sure VSCode is installed.")
7998
8060
  else:
7999
8061
  click.secho(" Warning: CSSL extension source not found", fg='yellow')
8000
8062
 
@@ -1,5 +1,5 @@
1
1
  """
2
- CSSL - CSO Service Script Language
2
+ CSSL - C-Style Scripting Language
3
3
  Bundled with IncludeCPP for integrated scripting support.
4
4
 
5
5
  Features:
@@ -16,7 +16,10 @@ from .cssl_parser import (
16
16
  CSSLSyntaxError, CSSLLexer, CSSLParser, ASTNode,
17
17
  KEYWORDS, TYPE_GENERICS, TYPE_PARAM_FUNCTIONS, INJECTION_HELPERS
18
18
  )
19
- from .cssl_runtime import CSSLRuntime, CSSLRuntimeError, CSSLServiceRunner, run_cssl, run_cssl_file
19
+ from .cssl_runtime import (
20
+ CSSLRuntime, CSSLRuntimeError, CSSLServiceRunner, run_cssl, run_cssl_file,
21
+ register_filter, unregister_filter, get_custom_filters
22
+ )
20
23
  from .cssl_types import (
21
24
  DataStruct, Shuffled, Iterator, Combo, DataSpace, OpenQuote,
22
25
  OpenFind, Parameter, Stack, Vector, Array,
@@ -33,6 +36,8 @@ __all__ = [
33
36
  # Runtime
34
37
  'CSSLRuntime', 'CSSLRuntimeError', 'CSSLServiceRunner',
35
38
  'run_cssl', 'run_cssl_file',
39
+ # Filter Registration
40
+ 'register_filter', 'unregister_filter', 'get_custom_filters',
36
41
  # Data Types
37
42
  'DataStruct', 'Shuffled', 'Iterator', 'Combo', 'DataSpace', 'OpenQuote',
38
43
  'OpenFind', 'Parameter', 'Stack', 'Vector', 'Array',