IncludeCPP 3.7.25__py3-none-any.whl → 3.8.8__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.25"
5
+ __version__ = "3.8.8"
6
6
  __all__ = ["CppApi", "CSSL"]
7
7
 
8
8
  # Module-level cache for C++ modules
@@ -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:
@@ -7923,16 +7936,18 @@ cli.add_command(cssl)
7923
7936
 
7924
7937
  @cli.command()
7925
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)')
7926
7940
  @click.option('--stubs-only', is_flag=True, help='Only update stubs, skip extension files')
7927
- def vscode(force, stubs_only):
7941
+ def vscode(force, reinstall, stubs_only):
7928
7942
  """Initialize or update VSCode configuration for IncludeCPP/CSSL.
7929
7943
 
7930
7944
  Installs CSSL extension globally and sets up project stubs.
7931
7945
 
7932
7946
  \b
7933
7947
  Usage:
7934
- includecpp vscode # Install/update extension + stubs
7935
- includecpp vscode --force # Force reinstall extension
7948
+ includecpp vscode # Install/update extension + stubs
7949
+ includecpp vscode --force # Force reinstall extension
7950
+ includecpp vscode --reinstall # Remove ALL versions & reinstall fresh
7936
7951
  includecpp vscode --stubs-only # Only update stubs
7937
7952
 
7938
7953
  \b
@@ -7999,13 +8014,18 @@ def vscode(force, stubs_only):
7999
8014
  target_dir = global_ext_dir / f'includecpp.cssl-{current_version}'
8000
8015
 
8001
8016
  # Check if already installed with same or older version
8002
- needs_install = force
8017
+ needs_install = force or reinstall
8003
8018
  existing_version = None
8004
8019
 
8005
8020
  # Find existing installations
8006
8021
  for existing in global_ext_dir.glob('includecpp.cssl-*'):
8007
8022
  existing_version = existing.name.split('-')[-1]
8008
- if existing_version != current_version:
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:
8009
8029
  # Remove old version
8010
8030
  click.echo(f" Removing old version: {existing_version}")
8011
8031
  shutil.rmtree(existing)
@@ -1,6 +1,6 @@
1
1
  # CSSL - C-Style Scripting Language
2
2
 
3
- > Version 3.7.6 | A modern scripting language with C++-style syntax and unique features like CodeInfusion and BruteInjection.
3
+ > Version 3.8.6 | A modern scripting language with C++-style syntax and unique features like CodeInfusion, BruteInjection, and Python Interop.
4
4
 
5
5
  ---
6
6
 
@@ -1696,6 +1696,317 @@ string result = b.add("Hello ").add("World!").build();
1696
1696
  printl(result); // prints: "Hello World!"
1697
1697
  ```
1698
1698
 
1699
+ ### Class Inheritance (extends)
1700
+
1701
+ CSSL supports class inheritance using the `: extends` syntax:
1702
+
1703
+ ```cssl
1704
+ // Base class
1705
+ class Animal {
1706
+ string name;
1707
+
1708
+ void Animal(string n) {
1709
+ this->name = n;
1710
+ }
1711
+
1712
+ void speak() {
1713
+ printl("Some sound");
1714
+ }
1715
+ }
1716
+
1717
+ // Derived class - inherits all members and methods from Animal
1718
+ class Dog : extends Animal {
1719
+ void Dog(string n) {
1720
+ this->name = n;
1721
+ }
1722
+
1723
+ // Override parent method
1724
+ void speak() {
1725
+ printl("Woof! I'm " + this->name);
1726
+ }
1727
+
1728
+ // New method only in Dog
1729
+ void fetch() {
1730
+ printl(this->name + " fetches the ball!");
1731
+ }
1732
+ }
1733
+
1734
+ Dog d = new Dog("Buddy");
1735
+ d.speak(); // "Woof! I'm Buddy"
1736
+ d.fetch(); // "Buddy fetches the ball!"
1737
+ ```
1738
+
1739
+ ### Extending Python Objects
1740
+
1741
+ You can extend Python classes/objects directly:
1742
+
1743
+ ```cssl
1744
+ // Extend a Python object using $
1745
+ class ExtendedGame : extends $GameEngine {
1746
+ void newFeature() {
1747
+ printl("New CSSL feature!");
1748
+ }
1749
+
1750
+ // Override a Python method
1751
+ void showUsername() {
1752
+ printl("Custom username display: " + this->username);
1753
+ }
1754
+ }
1755
+ ```
1756
+
1757
+ In Python:
1758
+ ```python
1759
+ class GameEngine:
1760
+ def __init__(self):
1761
+ self.username = "Player1"
1762
+ def showUsername(self):
1763
+ print(f"Username: {self.username}")
1764
+
1765
+ cssl = CSSL.CsslLang()
1766
+ cssl.share('GameEngine', GameEngine())
1767
+ cssl.run('''
1768
+ class MyGame : extends $GameEngine {
1769
+ void customMethod() {
1770
+ printl("Extended from Python!");
1771
+ }
1772
+ }
1773
+ ''')
1774
+ ```
1775
+
1776
+ ### Class Overwrites
1777
+
1778
+ Use `: overwrites` to replace methods in an existing class/object:
1779
+
1780
+ ```cssl
1781
+ // Overwrite methods in a Python object
1782
+ class MyOverrides : extends $GameEngine : overwrites $GameEngine {
1783
+ // This method will REPLACE the original showUsername() in $GameEngine
1784
+ void showUsername() {
1785
+ printl("OVERWRITTEN: " + this->username);
1786
+ }
1787
+ }
1788
+ ```
1789
+
1790
+ When you use `: overwrites TargetClass`, all methods defined in your class will replace the corresponding methods in the target. This works with:
1791
+ - Other CSSL classes
1792
+ - Python objects via `$ObjectName`
1793
+ - Shared objects
1794
+
1795
+ ### python::csslize() - Import Python Objects
1796
+
1797
+ Convert Python objects to CSSL-compatible wrappers:
1798
+
1799
+ ```cssl
1800
+ // Import a Python object
1801
+ py_obj <== python::csslize($MyPythonInstance);
1802
+
1803
+ // Now use it like a CSSL object
1804
+ py_obj.someMethod();
1805
+ printl(py_obj.someProperty);
1806
+
1807
+ // Or use it as a base class
1808
+ class Extended : extends py_obj {
1809
+ void newMethod() { ... }
1810
+ }
1811
+ ```
1812
+
1813
+ In Python:
1814
+ ```python
1815
+ class MyPythonClass:
1816
+ def __init__(self, name):
1817
+ self.name = name
1818
+ def greet(self):
1819
+ return f"Hello, {self.name}!"
1820
+
1821
+ cssl = CSSL.CsslLang()
1822
+ cssl.share('MyPython', MyPythonClass("World"))
1823
+ result = cssl.run('''
1824
+ py_obj <== python::csslize($MyPython);
1825
+ printl(py_obj.greet()); // "Hello, World!"
1826
+ ''')
1827
+ ```
1828
+
1829
+ ### Function Extends & Overwrites
1830
+
1831
+ Functions can also extend or overwrite other functions:
1832
+
1833
+ ```cssl
1834
+ // Base function
1835
+ define baseFunction() {
1836
+ string greeting = "Hello";
1837
+ int count = 42;
1838
+ printl(greeting);
1839
+ }
1840
+
1841
+ // Extend: inherit local variables from baseFunction
1842
+ define extendedFunc : extends baseFunction() {
1843
+ // 'greeting' and 'count' are available here!
1844
+ printl(greeting + " World! Count: " + count);
1845
+ }
1846
+
1847
+ // Overwrite: replace the original function
1848
+ define myReplacement : overwrites baseFunction() {
1849
+ printl("This replaces baseFunction entirely!");
1850
+ }
1851
+
1852
+ // After defining myReplacement, calling baseFunction()
1853
+ // will now execute myReplacement instead
1854
+ baseFunction(); // prints: "This replaces baseFunction entirely!"
1855
+ ```
1856
+
1857
+ Overwriting Python functions:
1858
+ ```cssl
1859
+ // Replace a shared Python function
1860
+ define myVersion : overwrites $pythonFunc() {
1861
+ printl("CSSL implementation replaces Python!");
1862
+ }
1863
+ ```
1864
+
1865
+ ### Non-Null Declarations
1866
+
1867
+ Use `*` prefix to declare non-nullable items:
1868
+
1869
+ ```cssl
1870
+ // Non-null variable - can never be None
1871
+ vector<dynamic> *myList; // Always initialized, never null
1872
+
1873
+ // Non-null function - must never return None
1874
+ define *alwaysReturns() {
1875
+ return "Always a value"; // Error if returns null
1876
+ }
1877
+
1878
+ // Non-null class - all methods return non-null
1879
+ class *MyClass {
1880
+ string getValue() {
1881
+ return "Value"; // All methods must return non-null
1882
+ }
1883
+ }
1884
+
1885
+ // Non-null open parameter - filters out None values
1886
+ define process(open *Params) {
1887
+ // Params will never contain None values
1888
+ foreach item in Params {
1889
+ printl(item); // Guaranteed non-null
1890
+ }
1891
+ }
1892
+ ```
1893
+
1894
+ ### Class Constructors with `constr` Keyword
1895
+
1896
+ The `constr` keyword defines explicit constructors inside classes. Multiple constructors can be defined and will be executed in order.
1897
+
1898
+ ```cssl
1899
+ // Class with constructor parameters in declaration
1900
+ class Vehicle (string brand, int year) {
1901
+ string make;
1902
+ int modelYear;
1903
+
1904
+ // Constructor using constr keyword
1905
+ constr Initialize() {
1906
+ // brand and year are available from class parameters
1907
+ this->make = brand;
1908
+ this->modelYear = year;
1909
+ }
1910
+
1911
+ // Additional constructor - executed after Initialize
1912
+ constr SetupDefaults() {
1913
+ printl("Vehicle created: " + this->make);
1914
+ }
1915
+ }
1916
+
1917
+ Vehicle v = new Vehicle("Toyota", 2024);
1918
+ ```
1919
+
1920
+ ### Constructor Inheritance with `super()`
1921
+
1922
+ Use `super()` to call parent class constructors and methods:
1923
+
1924
+ ```cssl
1925
+ class Animal {
1926
+ string name;
1927
+
1928
+ void Animal(string n) {
1929
+ this->name = n;
1930
+ }
1931
+
1932
+ void speak() {
1933
+ printl("Generic sound");
1934
+ }
1935
+ }
1936
+
1937
+ class Dog : extends Animal {
1938
+ string breed;
1939
+
1940
+ constr DogInit(string n, string b) {
1941
+ super(n); // Call parent constructor with name
1942
+ this->breed = b;
1943
+ }
1944
+
1945
+ void speak() {
1946
+ super::speak(); // Call parent's speak method
1947
+ printl("Woof! I'm " + this->name);
1948
+ }
1949
+ }
1950
+
1951
+ Dog d = new Dog("Buddy", "Labrador");
1952
+ d.speak();
1953
+ // Output:
1954
+ // Generic sound
1955
+ // Woof! I'm Buddy
1956
+ ```
1957
+
1958
+ ### Constructor Extends with Arguments
1959
+
1960
+ Pass arguments to parent constructors in class declaration:
1961
+
1962
+ ```cssl
1963
+ class Parent {
1964
+ int value;
1965
+
1966
+ void Parent(int v) {
1967
+ this->value = v;
1968
+ }
1969
+ }
1970
+
1971
+ // Pass arguments to parent constructor using extends (arg1, arg2)
1972
+ class Child : extends Parent ("defaultValue") {
1973
+ constr ChildInit() {
1974
+ // Parent constructor already called with "defaultValue"
1975
+ printl("Child value: " + this->value);
1976
+ }
1977
+ }
1978
+ ```
1979
+
1980
+ ### Method-Level Extends & Overwrites
1981
+
1982
+ Functions and methods can extend or overwrite specific methods in parent classes using `::` syntax:
1983
+
1984
+ ```cssl
1985
+ class Base {
1986
+ constr Init() {
1987
+ printl("Base init");
1988
+ }
1989
+
1990
+ void process() {
1991
+ printl("Base processing");
1992
+ }
1993
+ }
1994
+
1995
+ class Derived : extends Base {
1996
+ // Extend specific parent constructor
1997
+ constr DerivedInit() :: extends Base::Init {
1998
+ // Base::Init local vars are available here
1999
+ printl("Derived init");
2000
+ }
2001
+
2002
+ // Or define a method that extends parent method
2003
+ define customProcess :: extends Base::process() {
2004
+ // Has access to Base::process local variables
2005
+ printl("Extended processing");
2006
+ }
2007
+ }
2008
+ ```
2009
+
1699
2010
  ---
1700
2011
 
1701
2012
  ## Map Container