From 6a51cb33cbd16cc4b9235dec9b87a742671e0bfa Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:01:46 +0800 Subject: [PATCH 01/12] fix(ci): use nightly instead --- .github/workflows/check.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index c4405d6..0354716 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -31,7 +31,7 @@ jobs: # TODO: remove bleeding - name: Install Moonbit run: | - curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s bleeding + curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s nightly echo "$HOME/.moon/bin" >> $GITHUB_PATH - name: Moon version @@ -111,7 +111,7 @@ jobs: done (exit $_passed) - bleeding-check: + nightly-check: continue-on-error: true strategy: matrix: @@ -125,9 +125,9 @@ jobs: with: python-version: '3.13' - - name: Install Moonbit (bleeding) + - name: Install Moonbit (nightly) run: | - curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s bleeding + curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s nightly echo "$HOME/.moon/bin" >> $GITHUB_PATH - name: Moon version From cdffce168b22c4660a92cc44c63199c3dec82b0e Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:03:52 +0800 Subject: [PATCH 02/12] refactor: MisMatch -> Mismatch --- bool.mbt | 4 ++-- callable.mbt | 4 ++-- dict.mbt | 4 ++-- errors.mbt | 2 +- float.mbt | 4 ++-- integer.mbt | 4 ++-- list.mbt | 4 ++-- module.mbt | 4 ++-- str.mbt | 4 ++-- tuple.mbt | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bool.mbt b/bool.mbt index ec9cef7..d0d3d93 100644 --- a/bool.mbt +++ b/bool.mbt @@ -10,7 +10,7 @@ pub struct PyBool { ///| Create a python boolean object from a python object. /// If the object is not a boolean, it will raise a TypeMisMatchError. pub fn PyBool::create(obj : PyObject) -> PyBool raise PyRuntimeError { - guard obj.is_bool() else { raise TypeMisMatchError } + guard obj.is_bool() else { raise TypeMismatchError } PyBool::{ obj, } } @@ -24,7 +24,7 @@ fn PyBool::create_unchecked(obj : PyObject) -> PyBool { pub fn PyBool::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyBool raise PyRuntimeError { - guard @cpython.py_bool_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_bool_check(obj_ref) else { raise TypeMismatchError } PyBool::{ obj: PyObject::create(obj_ref) } } diff --git a/callable.mbt b/callable.mbt index f105417..1abbc9f 100644 --- a/callable.mbt +++ b/callable.mbt @@ -10,7 +10,7 @@ pub struct PyCallable { ///| Create a python callable object from a PyObject. /// If the object is not callable, a TypeMisMatchError is raised. pub fn PyCallable::create(obj : PyObject) -> PyCallable raise PyRuntimeError { - guard obj.is_callable() else { raise TypeMisMatchError } + guard obj.is_callable() else { raise TypeMismatchError } PyCallable::{ obj, } } @@ -24,7 +24,7 @@ fn PyCallable::create_unchecked(obj : PyObject) -> PyCallable { pub fn PyCallable::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyCallable raise PyRuntimeError { - guard @cpython.py_callable_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_callable_check(obj) else { raise TypeMismatchError } PyCallable::{ obj: PyObject::create(obj) } } diff --git a/dict.mbt b/dict.mbt index 50e4d35..85adad8 100644 --- a/dict.mbt +++ b/dict.mbt @@ -10,7 +10,7 @@ pub struct PyDict { ///| Create a python dict object. /// If the python object is not a dict, it will raise a TypeMisMatchError. pub fn PyDict::create(obj : PyObject) -> PyDict raise PyRuntimeError { - guard obj.is_dict() else { raise TypeMisMatchError } + guard obj.is_dict() else { raise TypeMismatchError } PyDict::{ obj, } } @@ -24,7 +24,7 @@ fn PyDict::create_unchecked(obj : PyObject) -> PyDict { pub fn PyDict::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyDict raise PyRuntimeError { - guard @cpython.py_dict_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_dict_check(obj) else { raise TypeMismatchError } PyDict::{ obj: PyObject::create(obj) } } diff --git a/errors.mbt b/errors.mbt index b59613c..869699e 100644 --- a/errors.mbt +++ b/errors.mbt @@ -1,6 +1,6 @@ ///| pub suberror PyRuntimeError { - TypeMisMatchError + TypeMismatchError IndexOutOfBoundsError KeyIsUnHashableError InVokeError diff --git a/float.mbt b/float.mbt index ba2e904..12bec98 100644 --- a/float.mbt +++ b/float.mbt @@ -6,7 +6,7 @@ pub struct PyFloat { ///| Create a python float object from a python object. /// If the python object is not a float, it will raise a TypeMisMatchError. pub fn PyFloat::create(obj : PyObject) -> PyFloat raise PyRuntimeError { - guard obj.is_float() else { raise TypeMisMatchError } + guard obj.is_float() else { raise TypeMismatchError } PyFloat::{ obj, } } @@ -20,7 +20,7 @@ fn PyFloat::create_unchecked(obj : PyObject) -> PyFloat { pub fn PyFloat::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyFloat raise PyRuntimeError { - guard @cpython.py_float_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_float_check(obj) else { raise TypeMismatchError } PyFloat::{ obj: PyObject::create(obj) } } diff --git a/integer.mbt b/integer.mbt index b36be88..c1559b8 100644 --- a/integer.mbt +++ b/integer.mbt @@ -10,7 +10,7 @@ pub struct PyInteger { ///| Create a python integer object from a python object. /// If pub fn PyInteger::create(obj : PyObject) -> PyInteger raise PyRuntimeError { - guard obj.is_int() else { raise TypeMisMatchError } + guard obj.is_int() else { raise TypeMismatchError } PyInteger::{ obj, } } @@ -23,7 +23,7 @@ pub fn PyInteger::create_unchecked(obj : PyObject) -> PyInteger { pub fn PyInteger::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyInteger raise PyRuntimeError { - guard @cpython.py_int_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_int_check(obj) else { raise TypeMismatchError } PyInteger::{ obj: PyObject::create(obj) } } diff --git a/list.mbt b/list.mbt index 213dc1d..fd6d1d2 100644 --- a/list.mbt +++ b/list.mbt @@ -23,7 +23,7 @@ pub fn PyList::new() -> PyList { ///| Create a python list object from a pyobject. /// If the pyobject is not a list, it will raise a TypeMisMatchError. pub fn PyList::create(obj : PyObject) -> PyList raise PyRuntimeError { - guard obj.is_list() else { raise TypeMisMatchError } + guard obj.is_list() else { raise TypeMismatchError } PyList::{ obj, } } @@ -37,7 +37,7 @@ fn PyList::create_unchecked(obj : PyObject) -> PyList { pub fn PyList::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyList raise PyRuntimeError { - guard @cpython.py_list_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_list_check(obj) else { raise TypeMismatchError } PyList::{ obj: PyObject::create(obj) } } diff --git a/module.mbt b/module.mbt index ed8ba6b..ce9a570 100644 --- a/module.mbt +++ b/module.mbt @@ -11,7 +11,7 @@ pub struct PyModule { ///| pub fn PyModule::create(obj : PyObject) -> PyModule raise PyRuntimeError { - guard obj.is_module() else { raise TypeMisMatchError } + guard obj.is_module() else { raise TypeMismatchError } PyModule::{ obj, name: None, attrs: Map::new() } } @@ -24,7 +24,7 @@ fn PyModule::create_unchecked(obj : PyObject) -> PyModule { pub fn PyModule::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyModule raise PyRuntimeError { - guard @cpython.py_module_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_module_check(obj_ref) else { raise TypeMismatchError } PyModule::{ obj: PyObject::create(obj_ref), name: None, attrs: Map::new() } } diff --git a/str.mbt b/str.mbt index 39dd5ea..884b151 100644 --- a/str.mbt +++ b/str.mbt @@ -10,7 +10,7 @@ pub struct PyString { ///| Create a python string from a python object. /// If the python object is not a string, it will raise a TypeMisMatchError. pub fn PyString::create(obj : PyObject) -> PyString raise PyRuntimeError { - guard obj.is_string() else { raise TypeMisMatchError } + guard obj.is_string() else { raise TypeMismatchError } PyString::{ obj, } } @@ -24,7 +24,7 @@ fn PyString::create_unchecked(obj : PyObject) -> PyString { pub fn PyString::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyString raise PyRuntimeError { - guard @cpython.py_string_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_string_check(obj_ref) else { raise TypeMismatchError } PyString::{ obj: PyObject::create(obj_ref) } } diff --git a/tuple.mbt b/tuple.mbt index 5847804..8b69477 100644 --- a/tuple.mbt +++ b/tuple.mbt @@ -29,7 +29,7 @@ pub fn PyTuple::new(size : UInt64) -> PyTuple { ///| Create a PyTuple object from a python object. /// If the python object is not a tuple, it will raise a TypeMisMatchError. pub fn PyTuple::create(obj : PyObject) -> PyTuple raise PyRuntimeError { - guard obj.is_tuple() else { raise TypeMisMatchError } + guard obj.is_tuple() else { raise TypeMismatchError } PyTuple::{ obj, } } @@ -43,7 +43,7 @@ fn PyTuple::create_unchecked(obj : PyObject) -> PyTuple { pub fn PyTuple::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyTuple raise PyRuntimeError { - guard @cpython.py_tuple_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_tuple_check(obj_ref) else { raise TypeMismatchError } PyTuple::{ obj: PyObject::create(obj_ref) } } From 6ef095a6f95ae78d7075504aa5f8cb08825a65bf Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:03:52 +0800 Subject: [PATCH 03/12] refactor: MisMatch -> Mismatch --- bool.mbt | 8 ++++---- callable.mbt | 8 ++++---- dict.mbt | 8 ++++---- errors.mbt | 2 +- float.mbt | 8 ++++---- integer.mbt | 4 ++-- list.mbt | 8 ++++---- module.mbt | 4 ++-- python.mbti | 2 +- str.mbt | 8 ++++---- tuple.mbt | 8 ++++---- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/bool.mbt b/bool.mbt index ec9cef7..bea3d6b 100644 --- a/bool.mbt +++ b/bool.mbt @@ -8,9 +8,9 @@ pub struct PyBool { } ///| Create a python boolean object from a python object. -/// If the object is not a boolean, it will raise a TypeMisMatchError. +/// If the object is not a boolean, it will raise a TypeMismatchError. pub fn PyBool::create(obj : PyObject) -> PyBool raise PyRuntimeError { - guard obj.is_bool() else { raise TypeMisMatchError } + guard obj.is_bool() else { raise TypeMismatchError } PyBool::{ obj, } } @@ -20,11 +20,11 @@ fn PyBool::create_unchecked(obj : PyObject) -> PyBool { } ///| Create a python boolean object from a python object reference. -/// If the object is not a boolean, it will raise a TypeMisMatchError. +/// If the object is not a boolean, it will raise a TypeMismatchError. pub fn PyBool::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyBool raise PyRuntimeError { - guard @cpython.py_bool_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_bool_check(obj_ref) else { raise TypeMismatchError } PyBool::{ obj: PyObject::create(obj_ref) } } diff --git a/callable.mbt b/callable.mbt index f105417..69d3a9b 100644 --- a/callable.mbt +++ b/callable.mbt @@ -8,9 +8,9 @@ pub struct PyCallable { } ///| Create a python callable object from a PyObject. -/// If the object is not callable, a TypeMisMatchError is raised. +/// If the object is not callable, a TypeMismatchError is raised. pub fn PyCallable::create(obj : PyObject) -> PyCallable raise PyRuntimeError { - guard obj.is_callable() else { raise TypeMisMatchError } + guard obj.is_callable() else { raise TypeMismatchError } PyCallable::{ obj, } } @@ -20,11 +20,11 @@ fn PyCallable::create_unchecked(obj : PyObject) -> PyCallable { } ///| Create a python callable object from a PyObjectRef. -/// If the object is not callable, a TypeMisMatchError is raised. +/// If the object is not callable, a TypeMismatchError is raised. pub fn PyCallable::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyCallable raise PyRuntimeError { - guard @cpython.py_callable_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_callable_check(obj) else { raise TypeMismatchError } PyCallable::{ obj: PyObject::create(obj) } } diff --git a/dict.mbt b/dict.mbt index 50e4d35..9f0daca 100644 --- a/dict.mbt +++ b/dict.mbt @@ -8,9 +8,9 @@ pub struct PyDict { } ///| Create a python dict object. -/// If the python object is not a dict, it will raise a TypeMisMatchError. +/// If the python object is not a dict, it will raise a TypeMismatchError. pub fn PyDict::create(obj : PyObject) -> PyDict raise PyRuntimeError { - guard obj.is_dict() else { raise TypeMisMatchError } + guard obj.is_dict() else { raise TypeMismatchError } PyDict::{ obj, } } @@ -20,11 +20,11 @@ fn PyDict::create_unchecked(obj : PyObject) -> PyDict { } ///| Create a python dict object from a python object reference. -/// If the python object is not a dict, it will raise a TypeMisMatchError. +/// If the python object is not a dict, it will raise a TypeMismatchError. pub fn PyDict::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyDict raise PyRuntimeError { - guard @cpython.py_dict_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_dict_check(obj) else { raise TypeMismatchError } PyDict::{ obj: PyObject::create(obj) } } diff --git a/errors.mbt b/errors.mbt index b59613c..869699e 100644 --- a/errors.mbt +++ b/errors.mbt @@ -1,6 +1,6 @@ ///| pub suberror PyRuntimeError { - TypeMisMatchError + TypeMismatchError IndexOutOfBoundsError KeyIsUnHashableError InVokeError diff --git a/float.mbt b/float.mbt index ba2e904..7876676 100644 --- a/float.mbt +++ b/float.mbt @@ -4,9 +4,9 @@ pub struct PyFloat { } ///| Create a python float object from a python object. -/// If the python object is not a float, it will raise a TypeMisMatchError. +/// If the python object is not a float, it will raise a TypeMismatchError. pub fn PyFloat::create(obj : PyObject) -> PyFloat raise PyRuntimeError { - guard obj.is_float() else { raise TypeMisMatchError } + guard obj.is_float() else { raise TypeMismatchError } PyFloat::{ obj, } } @@ -16,11 +16,11 @@ fn PyFloat::create_unchecked(obj : PyObject) -> PyFloat { } ///| Ceate a python float object from a python object reference. -/// If the python object is not a float, it will raise a TypeMisMatchError. +/// If the python object is not a float, it will raise a TypeMismatchError. pub fn PyFloat::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyFloat raise PyRuntimeError { - guard @cpython.py_float_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_float_check(obj) else { raise TypeMismatchError } PyFloat::{ obj: PyObject::create(obj) } } diff --git a/integer.mbt b/integer.mbt index b36be88..c1559b8 100644 --- a/integer.mbt +++ b/integer.mbt @@ -10,7 +10,7 @@ pub struct PyInteger { ///| Create a python integer object from a python object. /// If pub fn PyInteger::create(obj : PyObject) -> PyInteger raise PyRuntimeError { - guard obj.is_int() else { raise TypeMisMatchError } + guard obj.is_int() else { raise TypeMismatchError } PyInteger::{ obj, } } @@ -23,7 +23,7 @@ pub fn PyInteger::create_unchecked(obj : PyObject) -> PyInteger { pub fn PyInteger::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyInteger raise PyRuntimeError { - guard @cpython.py_int_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_int_check(obj) else { raise TypeMismatchError } PyInteger::{ obj: PyObject::create(obj) } } diff --git a/list.mbt b/list.mbt index 213dc1d..ca62219 100644 --- a/list.mbt +++ b/list.mbt @@ -21,9 +21,9 @@ pub fn PyList::new() -> PyList { } ///| Create a python list object from a pyobject. -/// If the pyobject is not a list, it will raise a TypeMisMatchError. +/// If the pyobject is not a list, it will raise a TypeMismatchError. pub fn PyList::create(obj : PyObject) -> PyList raise PyRuntimeError { - guard obj.is_list() else { raise TypeMisMatchError } + guard obj.is_list() else { raise TypeMismatchError } PyList::{ obj, } } @@ -33,11 +33,11 @@ fn PyList::create_unchecked(obj : PyObject) -> PyList { } ///| Create a python list object from a pyobject reference. -/// If the pyobject is not a list, it will raise a TypeMisMatchError. +/// If the pyobject is not a list, it will raise a TypeMismatchError. pub fn PyList::create_by_ref( obj : @cpython.PyObjectRef, ) -> PyList raise PyRuntimeError { - guard @cpython.py_list_check(obj) else { raise TypeMisMatchError } + guard @cpython.py_list_check(obj) else { raise TypeMismatchError } PyList::{ obj: PyObject::create(obj) } } diff --git a/module.mbt b/module.mbt index ed8ba6b..ce9a570 100644 --- a/module.mbt +++ b/module.mbt @@ -11,7 +11,7 @@ pub struct PyModule { ///| pub fn PyModule::create(obj : PyObject) -> PyModule raise PyRuntimeError { - guard obj.is_module() else { raise TypeMisMatchError } + guard obj.is_module() else { raise TypeMismatchError } PyModule::{ obj, name: None, attrs: Map::new() } } @@ -24,7 +24,7 @@ fn PyModule::create_unchecked(obj : PyObject) -> PyModule { pub fn PyModule::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyModule raise PyRuntimeError { - guard @cpython.py_module_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_module_check(obj_ref) else { raise TypeMismatchError } PyModule::{ obj: PyObject::create(obj_ref), name: None, attrs: Map::new() } } diff --git a/python.mbti b/python.mbti index 9f42e20..4b6b30c 100644 --- a/python.mbti +++ b/python.mbti @@ -14,7 +14,7 @@ fn strip_quot(String) -> String // Errors pub suberror PyRuntimeError { - TypeMisMatchError + TypeMismatchError IndexOutOfBoundsError KeyIsUnHashableError InVokeError diff --git a/str.mbt b/str.mbt index 39dd5ea..a3b9e26 100644 --- a/str.mbt +++ b/str.mbt @@ -8,9 +8,9 @@ pub struct PyString { } ///| Create a python string from a python object. -/// If the python object is not a string, it will raise a TypeMisMatchError. +/// If the python object is not a string, it will raise a TypeMismatchError. pub fn PyString::create(obj : PyObject) -> PyString raise PyRuntimeError { - guard obj.is_string() else { raise TypeMisMatchError } + guard obj.is_string() else { raise TypeMismatchError } PyString::{ obj, } } @@ -20,11 +20,11 @@ fn PyString::create_unchecked(obj : PyObject) -> PyString { } ///| Create a python string from a python object reference. -///If the python object is not a string, it will raise a TypeMisMatchError. +///If the python object is not a string, it will raise a TypeMismatchError. pub fn PyString::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyString raise PyRuntimeError { - guard @cpython.py_string_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_string_check(obj_ref) else { raise TypeMismatchError } PyString::{ obj: PyObject::create(obj_ref) } } diff --git a/tuple.mbt b/tuple.mbt index 5847804..b7f7aaa 100644 --- a/tuple.mbt +++ b/tuple.mbt @@ -27,9 +27,9 @@ pub fn PyTuple::new(size : UInt64) -> PyTuple { } ///| Create a PyTuple object from a python object. -/// If the python object is not a tuple, it will raise a TypeMisMatchError. +/// If the python object is not a tuple, it will raise a TypeMismatchError. pub fn PyTuple::create(obj : PyObject) -> PyTuple raise PyRuntimeError { - guard obj.is_tuple() else { raise TypeMisMatchError } + guard obj.is_tuple() else { raise TypeMismatchError } PyTuple::{ obj, } } @@ -39,11 +39,11 @@ fn PyTuple::create_unchecked(obj : PyObject) -> PyTuple { } ///| Create a PyTuple object from a python object reference. -/// If the python object is not a tuple, it will raise a TypeMisMatchError. +/// If the python object is not a tuple, it will raise a TypeMismatchError. pub fn PyTuple::create_by_ref( obj_ref : @cpython.PyObjectRef, ) -> PyTuple raise PyRuntimeError { - guard @cpython.py_tuple_check(obj_ref) else { raise TypeMisMatchError } + guard @cpython.py_tuple_check(obj_ref) else { raise TypeMismatchError } PyTuple::{ obj: PyObject::create(obj_ref) } } From baa89722cf7ab3b627944ebd644f409bfd0fd8d0 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:04:52 +0800 Subject: [PATCH 04/12] feat(ci): add licenserc.toml for license checking --- licenserc.toml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 licenserc.toml diff --git a/licenserc.toml b/licenserc.toml new file mode 100644 index 0000000..5274b73 --- /dev/null +++ b/licenserc.toml @@ -0,0 +1,39 @@ +# Copyright 2025 International Digital Economy Academy +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Configuration file for the "license header checker github action" [HawkEye](https://github.com/marketplace/actions/hawkeye-action) +# For detailed configuration, see https://github.com/korandoru/hawkeye?tab=readme-ov-file#configurations + +# https://github.com/korandoru/hawkeye/blob/badc166be6ed1a2f6c5cdff6422f8b1cf597dfe6/fmt/src/license/Apache-2.0.txt +inlineHeader = ''' +Copyright {{ attrs.git_file_modified_year }} International Digital Economy Academy + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +''' + +includes = ["*.mbt"] + +[git] +ignore = 'auto' +attrs = 'enable' \ No newline at end of file From 6446801217436f5a28e3d45c68cb306c41c4396a Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:06:58 +0800 Subject: [PATCH 05/12] chore: add license header to source files --- bool.mbt | 14 ++++++++++++++ callable.mbt | 14 ++++++++++++++ cpython/abstract.mbt | 14 ++++++++++++++ cpython/cell.mbt | 14 ++++++++++++++ cpython/ceval.mbt | 14 ++++++++++++++ cpython/class.mbt | 14 ++++++++++++++ cpython/code.mbt | 14 ++++++++++++++ cpython/codecs.mbt | 14 ++++++++++++++ cpython/context.mbt | 14 ++++++++++++++ cpython/core.mbt | 14 ++++++++++++++ cpython/dict.mbt | 14 ++++++++++++++ cpython/error.mbt | 14 ++++++++++++++ cpython/file.mbt | 14 ++++++++++++++ cpython/func.mbt | 14 ++++++++++++++ cpython/import.mbt | 14 ++++++++++++++ cpython/iter.mbt | 14 ++++++++++++++ cpython/lifecycle.mbt | 14 ++++++++++++++ cpython/list.mbt | 14 ++++++++++++++ cpython/module.mbt | 14 ++++++++++++++ cpython/number.mbt | 14 ++++++++++++++ cpython/object.mbt | 14 ++++++++++++++ cpython/odict.mbt | 14 ++++++++++++++ cpython/set.mbt | 14 ++++++++++++++ cpython/tuple.mbt | 14 ++++++++++++++ cpython/unicode.mbt | 14 ++++++++++++++ cpython/utils.mbt | 14 ++++++++++++++ dict.mbt | 14 ++++++++++++++ enums.mbt | 14 ++++++++++++++ errors.mbt | 14 ++++++++++++++ float.mbt | 14 ++++++++++++++ integer.mbt | 14 ++++++++++++++ list.mbt | 14 ++++++++++++++ main/main.mbt | 14 ++++++++++++++ module.mbt | 14 ++++++++++++++ obj.mbt | 14 ++++++++++++++ set.mbt | 13 +++++++++++++ str.mbt | 14 ++++++++++++++ test/module_test.mbt | 14 ++++++++++++++ test/object_test.mbt | 14 ++++++++++++++ time/lib.mbt | 14 ++++++++++++++ tkinter/tkinter.mbt | 14 ++++++++++++++ traits.mbt | 14 ++++++++++++++ tuple.mbt | 14 ++++++++++++++ turtle/color.mbt | 14 ++++++++++++++ turtle/lib.mbt | 14 ++++++++++++++ turtle/pen.mbt | 14 ++++++++++++++ turtle/pen2.mbt | 14 ++++++++++++++ turtle/screen.mbt | 14 ++++++++++++++ turtle/shape.mbt | 14 ++++++++++++++ turtle/speed.mbt | 14 ++++++++++++++ utils.mbt | 14 ++++++++++++++ 51 files changed, 713 insertions(+) diff --git a/bool.mbt b/bool.mbt index ec9cef7..9b0d72e 100644 --- a/bool.mbt +++ b/bool.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // PyBool // ======================================== diff --git a/callable.mbt b/callable.mbt index f105417..6003a93 100644 --- a/callable.mbt +++ b/callable.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // Function // ======================================== diff --git a/cpython/abstract.mbt b/cpython/abstract.mbt index 2fbe15a..3f62986 100644 --- a/cpython/abstract.mbt +++ b/cpython/abstract.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Abstract ///| Call a callable Python object 'callable' with arguments given by the diff --git a/cpython/cell.mbt b/cpython/cell.mbt index 4b75abc..1151243 100644 --- a/cpython/cell.mbt +++ b/cpython/cell.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // cell ///| diff --git a/cpython/ceval.mbt b/cpython/ceval.mbt index 73818e5..10cf17a 100644 --- a/cpython/ceval.mbt +++ b/cpython/ceval.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ceval ///| diff --git a/cpython/class.mbt b/cpython/class.mbt index 1651d32..8fe1afa 100644 --- a/cpython/class.mbt +++ b/cpython/class.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // class ///| diff --git a/cpython/code.mbt b/cpython/code.mbt index db33590..a82f95b 100644 --- a/cpython/code.mbt +++ b/cpython/code.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // code ///| diff --git a/cpython/codecs.mbt b/cpython/codecs.mbt index 831198e..9936481 100644 --- a/cpython/codecs.mbt +++ b/cpython/codecs.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // code cs ///| diff --git a/cpython/context.mbt b/cpython/context.mbt index efee81e..d63e6fc 100644 --- a/cpython/context.mbt +++ b/cpython/context.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // context ///| diff --git a/cpython/core.mbt b/cpython/core.mbt index 749f46a..e51bff3 100644 --- a/cpython/core.mbt +++ b/cpython/core.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| type CStr // const char* diff --git a/cpython/dict.mbt b/cpython/dict.mbt index 98bf824..d21556b 100644 --- a/cpython/dict.mbt +++ b/cpython/dict.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // dict ///| diff --git a/cpython/error.mbt b/cpython/error.mbt index 7e03ede..7493ee9 100644 --- a/cpython/error.mbt +++ b/cpython/error.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub extern "C" fn py_err_occurred() -> PyObjectRef = "PyErr_Occurred" diff --git a/cpython/file.mbt b/cpython/file.mbt index b328c8d..15197ff 100644 --- a/cpython/file.mbt +++ b/cpython/file.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // File ///| diff --git a/cpython/func.mbt b/cpython/func.mbt index 258794b..5f08fb8 100644 --- a/cpython/func.mbt +++ b/cpython/func.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Func Object ///| diff --git a/cpython/import.mbt b/cpython/import.mbt index 6286d8c..5fc31e5 100644 --- a/cpython/import.mbt +++ b/cpython/import.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Import ///| diff --git a/cpython/iter.mbt b/cpython/iter.mbt index 1687705..cfd5b76 100644 --- a/cpython/iter.mbt +++ b/cpython/iter.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Iter ///| diff --git a/cpython/lifecycle.mbt b/cpython/lifecycle.mbt index 52e4ce3..66e2148 100644 --- a/cpython/lifecycle.mbt +++ b/cpython/lifecycle.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub extern "C" fn py_init() = "Py_Initialize" diff --git a/cpython/list.mbt b/cpython/list.mbt index 72de4a0..65d29b9 100644 --- a/cpython/list.mbt +++ b/cpython/list.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // List ///| diff --git a/cpython/module.mbt b/cpython/module.mbt index 55f9743..092f202 100644 --- a/cpython/module.mbt +++ b/cpython/module.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Module ///| diff --git a/cpython/number.mbt b/cpython/number.mbt index c28383f..4236f5e 100644 --- a/cpython/number.mbt +++ b/cpython/number.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // PyObjectRef PyBool_FromLong(long); ///| diff --git a/cpython/object.mbt b/cpython/object.mbt index 029e241..480d7a9 100644 --- a/cpython/object.mbt +++ b/cpython/object.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| #owned(a) pub extern "C" fn py_object_repr(a : PyObjectRef) -> PyObjectRef = "PyObject_Repr" diff --git a/cpython/odict.mbt b/cpython/odict.mbt index 21bb9f1..6bf9656 100644 --- a/cpython/odict.mbt +++ b/cpython/odict.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ODict ///| diff --git a/cpython/set.mbt b/cpython/set.mbt index 4429686..46475c2 100644 --- a/cpython/set.mbt +++ b/cpython/set.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Set ///| diff --git a/cpython/tuple.mbt b/cpython/tuple.mbt index b76492f..325018d 100644 --- a/cpython/tuple.mbt +++ b/cpython/tuple.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Tuple ///| diff --git a/cpython/unicode.mbt b/cpython/unicode.mbt index 6ae7872..fe0b87f 100644 --- a/cpython/unicode.mbt +++ b/cpython/unicode.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Unicode ///| diff --git a/cpython/utils.mbt b/cpython/utils.mbt index 392c6ab..da3f44e 100644 --- a/cpython/utils.mbt +++ b/cpython/utils.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| priv trait ToCStr { to_cstr(Self) -> Bytes diff --git a/dict.mbt b/dict.mbt index 50e4d35..1dce5cf 100644 --- a/dict.mbt +++ b/dict.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // Dict // ======================================== diff --git a/enums.mbt b/enums.mbt index 31f7af5..019b993 100644 --- a/enums.mbt +++ b/enums.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub enum PyType { PyInteger diff --git a/errors.mbt b/errors.mbt index b59613c..484d31b 100644 --- a/errors.mbt +++ b/errors.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub suberror PyRuntimeError { TypeMisMatchError diff --git a/float.mbt b/float.mbt index ba2e904..308c7b9 100644 --- a/float.mbt +++ b/float.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub struct PyFloat { priv obj : PyObject diff --git a/integer.mbt b/integer.mbt index b36be88..e857c02 100644 --- a/integer.mbt +++ b/integer.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // PyInteger // ======================================== diff --git a/list.mbt b/list.mbt index 213dc1d..aabe0ae 100644 --- a/list.mbt +++ b/list.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // py_list // ======================================== diff --git a/main/main.mbt b/main/main.mbt index 265c8c8..b794b6a 100644 --- a/main/main.mbt +++ b/main/main.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| typealias @python.(PyInteger, PyList, PyTuple) diff --git a/module.mbt b/module.mbt index ed8ba6b..a7cf09d 100644 --- a/module.mbt +++ b/module.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // Import // ======================================== diff --git a/obj.mbt b/obj.mbt index ba62b98..52d36ac 100644 --- a/obj.mbt +++ b/obj.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub struct PyObject { priv obj : @cpython.PyObjectRef diff --git a/set.mbt b/set.mbt index 8b13789..fa84495 100644 --- a/set.mbt +++ b/set.mbt @@ -1 +1,14 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. diff --git a/str.mbt b/str.mbt index 39dd5ea..55c9e06 100644 --- a/str.mbt +++ b/str.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // PyString // ======================================== diff --git a/test/module_test.mbt b/test/module_test.mbt index 06faf54..0a08d06 100644 --- a/test/module_test.mbt +++ b/test/module_test.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| test "Module Test" { let os = @python.pyimport("os", print_err=true) diff --git a/test/object_test.mbt b/test/object_test.mbt index 912be8f..3a7b795 100644 --- a/test/object_test.mbt +++ b/test/object_test.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| typealias @python.( PyInteger, diff --git a/time/lib.mbt b/time/lib.mbt index e3966dc..de5c732 100644 --- a/time/lib.mbt +++ b/time/lib.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| typealias @python.(PyModule, PyTuple, PyFloat) diff --git a/tkinter/tkinter.mbt b/tkinter/tkinter.mbt index e573d1e..631222d 100644 --- a/tkinter/tkinter.mbt +++ b/tkinter/tkinter.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Example //typealias Window = @tkinter.Window //typealias Label = @tkinter.Label diff --git a/traits.mbt b/traits.mbt index f1b8257..d15a85b 100644 --- a/traits.mbt +++ b/traits.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub trait IsPyObject { obj(Self) -> PyObject diff --git a/tuple.mbt b/tuple.mbt index 5847804..db10af6 100644 --- a/tuple.mbt +++ b/tuple.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ======================================== // Tuple // ======================================== diff --git a/turtle/color.mbt b/turtle/color.mbt index 1ebc64e..8616e0c 100644 --- a/turtle/color.mbt +++ b/turtle/color.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| Represents common colors used for drawing. /// Deriving Show provides a default to_string() which can be converted to lowercase for Python. pub(all) enum Color { diff --git a/turtle/lib.mbt b/turtle/lib.mbt index 4a1ec3f..379d77e 100644 --- a/turtle/lib.mbt +++ b/turtle/lib.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| typealias @python.( PyModule, diff --git a/turtle/pen.mbt b/turtle/pen.mbt index de37106..10b2140 100644 --- a/turtle/pen.mbt +++ b/turtle/pen.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /////| //pub struct Pen { // priv pen : PyObject diff --git a/turtle/pen2.mbt b/turtle/pen2.mbt index 35a69f4..4bafa7a 100644 --- a/turtle/pen2.mbt +++ b/turtle/pen2.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| Represents a turtle pen object, capable of drawing on the screen. /// corresponds to `turtle.Pen` or the default turtle instance in Python. pub struct Pen { diff --git a/turtle/screen.mbt b/turtle/screen.mbt index b7cb671..c31c6af 100644 --- a/turtle/screen.mbt +++ b/turtle/screen.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub struct Screen { priv screen : PyObject diff --git a/turtle/shape.mbt b/turtle/shape.mbt index 893773a..bca278e 100644 --- a/turtle/shape.mbt +++ b/turtle/shape.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| Represents common shapes for the turtle cursor. /// Deriving Show provides a default to_string() which can be converted to lowercase for Python. pub(all) enum Shape { diff --git a/turtle/speed.mbt b/turtle/speed.mbt index 6e0b185..1c443c5 100644 --- a/turtle/speed.mbt +++ b/turtle/speed.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| pub(all) enum Speed { Fastest diff --git a/utils.mbt b/utils.mbt index 364c711..9612bc6 100644 --- a/utils.mbt +++ b/utils.mbt @@ -1,3 +1,17 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + ///| fn[T] unless(cond : Bool, value : () -> T) -> T? { if !cond { From ba65723d0a83a43275852a242ceee0686e937b03 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:17:05 +0800 Subject: [PATCH 06/12] fix(licenserc): update hawkeye version --- .github/workflows/check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index c4405d6..88c8059 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -83,7 +83,7 @@ jobs: license-header-check: runs-on: ubuntu-latest env: - HAWKEYE_VERSION: v5.8.1 + HAWKEYE_VERSION: v6.3.0 steps: - uses: actions/checkout@v4 with: From 0c93e7d2fc8e0c3a7f17adda7e1b261b3b685409 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:16:03 +0800 Subject: [PATCH 07/12] fix: typos --- float.mbt | 4 ++-- integer.mbt | 2 +- str.mbt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/float.mbt b/float.mbt index 7876676..702c0e6 100644 --- a/float.mbt +++ b/float.mbt @@ -15,7 +15,7 @@ fn PyFloat::create_unchecked(obj : PyObject) -> PyFloat { PyFloat::{ obj, } } -///| Ceate a python float object from a python object reference. +///| Create a python float object from a python object reference. /// If the python object is not a float, it will raise a TypeMismatchError. pub fn PyFloat::create_by_ref( obj : @cpython.PyObjectRef, @@ -58,7 +58,7 @@ pub fn PyFloat::to_double(self : PyFloat) -> Double { @cpython.py_float_as_double(self.obj_ref()) } -///| Print the PyFloat object direcly. +///| Print the PyFloat object directly. /// /// Different from use `println`, `dump` means we made python interpreter /// print the object directly. diff --git a/integer.mbt b/integer.mbt index c1559b8..2d8496d 100644 --- a/integer.mbt +++ b/integer.mbt @@ -73,7 +73,7 @@ pub fn PyInteger::to_double(self : PyInteger) -> Double { @cpython.py_long_as_double(self.obj_ref()) } -///| Print the PyInteger object direcly. +///| Print the PyInteger object directly. /// /// Different from use `println`, `dump` means we made python interpreter /// print the object directly. diff --git a/str.mbt b/str.mbt index a3b9e26..7c1036f 100644 --- a/str.mbt +++ b/str.mbt @@ -54,7 +54,7 @@ pub fn PyString::from(s : String) -> PyString { } } -///| Print the PyString object direcly. +///| Print the PyString object directly. /// /// Different from use `println`, `dump` means we made python interpreter /// print the object directly. From 025f811d5d3531cb1ad24e5f083d77cbad92c3f1 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:22:20 +0800 Subject: [PATCH 08/12] fix: ignore pen.ba(distance) in typo checks --- _typos.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 _typos.toml diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..5b6e8b1 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,13 @@ +[files] +extend-exclude = ["**/*_gen.mbt"] + +[default.extend-identifiers] +IDentifier = "IDentifier" + +[default] +extend-ignore-re = [ + # ignore string literals + "pen.ba\\(distance\\)", + "\"(.*?)\"", + ".*#|.*", +] From 48d1550a388e26bc0748654eb31bc7d1f879874b Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:27:50 +0800 Subject: [PATCH 09/12] chore: format --- bool.mbt | 18 ++-- callable.mbt | 12 ++- cpython/abstract.mbt | 216 ++++++++++++++++++++++++++++--------------- cpython/cell.mbt | 2 +- cpython/ceval.mbt | 2 +- cpython/class.mbt | 2 +- cpython/code.mbt | 2 +- cpython/codecs.mbt | 2 +- cpython/context.mbt | 2 +- dict.mbt | 48 ++++++---- float.mbt | 15 ++- integer.mbt | 15 ++- list.mbt | 33 ++++--- main/main.mbt | 2 +- module.mbt | 13 ++- obj.mbt | 2 +- set.mbt | 1 - str.mbt | 12 ++- test/object_test.mbt | 18 ++-- time/lib.mbt | 29 ++++-- tkinter/tkinter.mbt | 8 +- traits.mbt | 3 +- tuple.mbt | 24 +++-- turtle/color.mbt | 6 +- turtle/lib.mbt | 20 ++-- turtle/pen2.mbt | 123 +++++++++++++++--------- turtle/shape.mbt | 3 +- utils.mbt | 3 +- 28 files changed, 412 insertions(+), 224 deletions(-) diff --git a/bool.mbt b/bool.mbt index 492d867..4282eb7 100644 --- a/bool.mbt +++ b/bool.mbt @@ -21,7 +21,8 @@ pub struct PyBool { priv obj : PyObject } -///| Create a python boolean object from a python object. +///| +/// Create a python boolean object from a python object. /// If the object is not a boolean, it will raise a TypeMismatchError. pub fn PyBool::create(obj : PyObject) -> PyBool raise PyRuntimeError { guard obj.is_bool() else { raise TypeMismatchError } @@ -33,7 +34,8 @@ fn PyBool::create_unchecked(obj : PyObject) -> PyBool { PyBool::{ obj, } } -///| Create a python boolean object from a python object reference. +///| +/// Create a python boolean object from a python object reference. /// If the object is not a boolean, it will raise a TypeMismatchError. pub fn PyBool::create_by_ref( obj_ref : @cpython.PyObjectRef, @@ -52,7 +54,8 @@ pub fn PyBool::dump(self : PyBool) -> Unit { self.obj.dump() } -///| Create a python boolean object from moonbit bool. +///| +/// Create a python boolean object from moonbit bool. /// /// ## Example /// @@ -75,7 +78,8 @@ pub fn PyBool::from(value : Bool) -> PyBool { PyBool::create_by_ref_unchecked(obj_ref) } -///| Return `true` if it is true, using python interpreter. +///| +/// Return `true` if it is true, using python interpreter. /// /// ## Example /// @@ -96,7 +100,8 @@ pub fn PyBool::to_bool(self : PyBool) -> Bool { self.is_true() } -///| Return `true` if it is false, using python interpreter. +///| +/// Return `true` if it is false, using python interpreter. /// /// ## Example /// @@ -111,7 +116,8 @@ pub fn PyBool::is_false(self : PyBool) -> Bool { self.is_true() |> not } -///| Return the reverse of the boolean value. +///| +/// Return the reverse of the boolean value. /// /// ## Example /// diff --git a/callable.mbt b/callable.mbt index d519384..81830b7 100644 --- a/callable.mbt +++ b/callable.mbt @@ -21,7 +21,8 @@ pub struct PyCallable { priv obj : PyObject } -///| Create a python callable object from a PyObject. +///| +/// Create a python callable object from a PyObject. /// If the object is not callable, a TypeMismatchError is raised. pub fn PyCallable::create(obj : PyObject) -> PyCallable raise PyRuntimeError { guard obj.is_callable() else { raise TypeMismatchError } @@ -33,7 +34,8 @@ fn PyCallable::create_unchecked(obj : PyObject) -> PyCallable { PyCallable::{ obj, } } -///| Create a python callable object from a PyObjectRef. +///| +/// Create a python callable object from a PyObjectRef. /// If the object is not callable, a TypeMismatchError is raised. pub fn PyCallable::create_by_ref( obj : @cpython.PyObjectRef, @@ -63,9 +65,9 @@ pub fn PyCallable::dump(self : PyCallable) -> Unit { ///| pub fn PyCallable::invoke( self : PyCallable, - args~ : PyTuple = PyTuple::new(0), - kwargs~ : PyDict = PyDict::new(), - print_err~ : Bool = false, + args? : PyTuple = PyTuple::new(0), + kwargs? : PyDict = PyDict::new(), + print_err? : Bool = false, ) -> PyObjectEnum? raise PyRuntimeError { let obj_ref = if kwargs.len() > 0 { @cpython.py_object_call(self.obj_ref(), args.obj_ref(), kwargs.obj_ref()) diff --git a/cpython/abstract.mbt b/cpython/abstract.mbt index 3f62986..65b779e 100644 --- a/cpython/abstract.mbt +++ b/cpython/abstract.mbt @@ -14,7 +14,8 @@ // Abstract -///| Call a callable Python object 'callable' with arguments given by the +///| +/// Call a callable Python object 'callable' with arguments given by the /// tuple 'args' and keywords arguments given by the dictionary 'kwargs'. /// /// 'args' must not be NULL, use an empty tuple if no arguments are @@ -29,7 +30,8 @@ pub extern "C" fn py_object_call( kwargs : PyObjectRef, ) -> PyObjectRef = "PyObject_Call" -///| Call a callable Python object 'callable', with arguments given by the +///| +/// Call a callable Python object 'callable', with arguments given by the /// tuple 'args'. If no arguments are needed, then 'args' can be NULL. /// /// Returns the result of the call on success, or NULL on failure. @@ -42,7 +44,8 @@ pub extern "C" fn py_object_call_object( args : PyObjectRef, ) -> PyObjectRef = "PyObject_CallObject" -///| Get the type of an object. +///| +/// Get the type of an object. /// /// On success, returns a type object corresponding to the object type of object /// 'o'. On failure, returns NULL. @@ -51,7 +54,8 @@ pub extern "C" fn py_object_call_object( #owned(obj) pub extern "C" fn py_object_type(obj : PyObjectRef) -> PyObjectRef = "PyObject_Type" -///| Return the size of object 'o'. If the object 'o' provides both sequence and +///| +/// Return the size of object 'o'. If the object 'o' provides both sequence and /// mapping protocols, the sequence size is returned. /// /// On error, -1 is returned. @@ -60,7 +64,8 @@ pub extern "C" fn py_object_type(obj : PyObjectRef) -> PyObjectRef = "PyObject_T #owned(obj) pub extern "C" fn py_object_size(obj : PyObjectRef) -> UInt64 = "PyObject_Size" -///| Return element of 'o' corresponding to the object 'key'. Return NULL +///| +/// Return element of 'o' corresponding to the object 'key'. Return NULL /// on failure. /// /// This is the equivalent of the Python expression: o[key] */ @@ -70,7 +75,8 @@ pub extern "C" fn py_object_get_item( key : PyObjectRef, ) -> PyObjectRef = "PyObject_GetItem" -///| Map the object 'key' to the value 'v' into 'o'. +///| +/// Map the object 'key' to the value 'v' into 'o'. /// /// Raise an exception and return -1 on failure; return 0 on success. /// @@ -82,7 +88,8 @@ pub extern "C" fn py_object_set_item( value : PyObjectRef, ) -> Int = "py_object_SetItem" -///| Remove the mapping for the string 'key' from the object 'o'. +///| +/// Remove the mapping for the string 'key' from the object 'o'. /// Returns -1 on failure. /// /// This is equivalent to the Python statement: del o[key]. @@ -92,7 +99,8 @@ pub extern "C" fn py_object_del_item_string( key : CStr, ) -> Int = "PyObject_DelItemString" -///| Delete the mapping for the object 'key' from the object 'o'. +///| +/// Delete the mapping for the object 'key' from the object 'o'. /// Returns -1 on failure. /// /// This is the equivalent of the Python statement: del o[key]. @@ -102,7 +110,8 @@ pub extern "C" fn py_object_del_item( key : PyObjectRef, ) -> Int = "PyObject_DelItem" -///| Takes an arbitrary object and returns the result of calling +///| +/// Takes an arbitrary object and returns the result of calling /// obj.__format__(format_spec). #owned(obj, format_spec) pub extern "C" fn pyobkect_format( @@ -110,19 +119,22 @@ pub extern "C" fn pyobkect_format( format_spec : PyObjectRef, ) -> PyObjectRef = "PyObject_Format" -///| Takes an object and returns an iterator for it. +///| +/// Takes an object and returns an iterator for it. /// This is typically a new iterator but if the argument is an iterator, this /// returns itself. */ #owned(obj) pub extern "C" fn py_object_get_iter(obj : PyObjectRef) -> PyObjectRef = "PyObject_GetIter" -///| Returns 1 if the object 'obj' provides iterator protocols, and 0 otherwise. +///| +/// Returns 1 if the object 'obj' provides iterator protocols, and 0 otherwise. /// /// This function always succeeds. */ #owned(obj) pub extern "C" fn pyiter_check(obj : PyObjectRef) -> Int = "PyIter_Check" -///| Takes an iterator object and calls its tp_iternext slot, +///| +/// Takes an iterator object and calls its tp_iternext slot, /// returning the next value. /// /// If the iterator is exhausted, this returns NULL without setting an @@ -132,13 +144,15 @@ pub extern "C" fn pyiter_check(obj : PyObjectRef) -> Int = "PyIter_Check" #owned(iter) pub extern "C" fn pyiter_next(iter : PyObjectRef) -> PyObjectRef = "PyIter_Next" -///| Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise. +///| +/// Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise. /// /// This function always succeeds. */ #owned(obj) pub extern "C" fn pynumber_check(obj : PyObjectRef) -> Int = "PyNumber_Check" -///| Returns the result of adding o1 and o2, or NULL on failure. +///| +/// Returns the result of adding o1 and o2, or NULL on failure. /// /// This is the equivalent of the Python expression: o1 + o2. */ #owned(obj1, obj2) @@ -147,7 +161,8 @@ pub extern "C" fn pynumber_add( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Add" -///| Returns the result of subtracting o2 from o1, or NULL on failure. +///| +/// Returns the result of subtracting o2 from o1, or NULL on failure. /// /// This is the equivalent of the Python expression: o1 - o2. */ #owned(obj1, obj2) @@ -156,7 +171,8 @@ pub extern "C" fn pynumber_subtract( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Subtract" -///| Returns the result of multiplying o1 and o2, or NULL on failure. +///| +/// Returns the result of multiplying o1 and o2, or NULL on failure. /// /// This is the equivalent of the Python expression: o1 * o2. */ #owned(obj1, obj2) @@ -165,7 +181,8 @@ pub extern "C" fn pynumber_multiply( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Multiply" -///| Returns the result of dividing o1 by o2 giving an integral result, +///| +/// Returns the result of dividing o1 by o2 giving an integral result, /// or NULL on failure. /// /// This is the equivalent of the Python expression: o1 // o2. */ @@ -175,7 +192,8 @@ pub extern "C" fn pynumber_floor_divide( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_FloorDivide" -///| Returns the result of dividing o1 by o2 giving a float result, or NULL on +///| +/// Returns the result of dividing o1 by o2 giving a float result, or NULL on /// failure. /// /// This is the equivalent of the Python expression: o1 / o2. @@ -185,7 +203,8 @@ pub extern "C" fn pynumber_true_divide( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_TrueDivide" -///| Returns the remainder of dividing o1 by o2, or NULL on failure. +///| +/// Returns the remainder of dividing o1 by o2, or NULL on failure. /// /// This is the equivalent of the Python expression: o1 % o2. #owned(obj1, obj2) @@ -194,7 +213,8 @@ pub extern "C" fn pynumber_remainder( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Remainder" -///| See the built-in function divmod. +///| +/// See the built-in function divmod. /// /// Returns NULL on failure. /// @@ -205,7 +225,8 @@ pub extern "C" fn pynumber_divmod( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Divmod" -///| See the built-in function pow. Returns NULL on failure. +///| +/// See the built-in function pow. Returns NULL on failure. /// /// This is the equivalent of the Python expression: pow(o1, o2, o3), /// where o3 is optional. @@ -216,31 +237,36 @@ pub extern "C" fn pynumber_power( obj3 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Power" -///| Returns the negation of o on success, or NULL on failure. +///| +/// Returns the negation of o on success, or NULL on failure. /// /// This is the equivalent of the Python expression: -o. #owned(obj) pub extern "C" fn pynumber_negative(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Negative" -///| Returns the positive of o on success, or NULL on failure. +///| +/// Returns the positive of o on success, or NULL on failure. /// /// This is the equivalent of the Python expression: +o. #owned(obj) pub extern "C" fn pynumber_positive(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Positive" -///| Returns the absolute value of 'o', or NULL on failure. +///| +/// Returns the absolute value of 'o', or NULL on failure. /// /// This is the equivalent of the Python expression: abs(o). #owned(obj) pub extern "C" fn pynumber_absolute(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Absolute" -///| Returns the bitwise negation of 'o' on success, or NULL on failure. +///| +/// Returns the bitwise negation of 'o' on success, or NULL on failure. /// /// This is the equivalent of the Python expression: ~o. #owned(obj) pub extern "C" fn pynumber_invert(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Invert" -///| Returns the result of left shifting o1 by o2 on success, or NULL on failure. +///| +/// Returns the result of left shifting o1 by o2 on success, or NULL on failure. /// /// This is the equivalent of the Python expression: o1 << o2. #owned(obj1, obj2) @@ -249,7 +275,8 @@ pub extern "C" fn pynumber_lshift( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Lshift" -///| Returns the result of right shifting o1 by o2 on success, or NULL on +///| +/// Returns the result of right shifting o1 by o2 on success, or NULL on /// failure. /// /// This is the equivalent of the Python expression: o1 >> o2. @@ -259,7 +286,8 @@ pub extern "C" fn pynumber_rshift( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Rshift" -///| Returns the result of bitwise and of o1 and o2 on success, or NULL on +///| +/// Returns the result of bitwise and of o1 and o2 on success, or NULL on /// failure. /// /// This is the equivalent of the Python expression: o1 & o2. @@ -269,7 +297,8 @@ pub extern "C" fn pynumber_and( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_And" -///| Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure. +///| +/// Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure. /// /// This is the equivalent of the Python expression: o1 ^ o2. #owned(obj1, obj2) @@ -278,7 +307,8 @@ pub extern "C" fn pynumber_xor( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Xor" -///| Returns the result of bitwise or on o1 and o2 on success, or NULL on +///| +/// Returns the result of bitwise or on o1 and o2 on success, or NULL on /// failure. /// /// This is the equivalent of the Python expression: o1 | o2. @@ -288,17 +318,20 @@ pub extern "C" fn pynumber_or( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_Or" -///| Returns 1 if obj is an index integer (has the nb_index slot of the +///| +/// Returns 1 if obj is an index integer (has the nb_index slot of the /// tp_as_number structure filled in), and 0 otherwise. #owned(obj) pub extern "C" fn pyindex_check(obj : PyObjectRef) -> Int = "PyIndex_Check" -///| Returns the object 'o' converted to a Python int, or NULL with an exception +///| +/// Returns the object 'o' converted to a Python int, or NULL with an exception /// raised on failure. #owned(obj) pub extern "C" fn pynumber_index(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Index" -///| Returns the object 'o' converted to Py_ssize_t by going through +///| +/// Returns the object 'o' converted to Py_ssize_t by going through /// PyNumber_Index() first. /// /// If an overflow error occurs while converting the int to Py_ssize_t, then the @@ -310,21 +343,24 @@ pub extern "C" fn pynumber_as_ssize_t( exc : PyObjectRef, ) -> Int = "PyNumber_AsSsize_t" -///| Returns the object 'o' converted to an integer object on success, or NULL +///| +/// Returns the object 'o' converted to an integer object on success, or NULL /// on failure. /// /// This is the equivalent of the Python expression: int(o). #owned(obj) pub extern "C" fn pynumber_long(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Long" -///| Returns the object 'o' converted to a float object on success, or NULL +///| +/// Returns the object 'o' converted to a float object on success, or NULL /// on failure. /// /// This is the equivalent of the Python expression: float(o). #owned(obj) pub extern "C" fn pynumber_float(obj : PyObjectRef) -> PyObjectRef = "PyNumber_Float" -///| Returns the result of adding o2 to o1, possibly in-place, or NULL +///| +/// Returns the result of adding o2 to o1, possibly in-place, or NULL /// on failure. /// /// This is the equivalent of the Python expression: o1 += o2. @@ -334,7 +370,8 @@ pub extern "C" fn pynumber_inplace_add( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceAdd" -///| Returns the result of subtracting o2 from o1, possibly in-place or +///| +/// Returns the result of subtracting o2 from o1, possibly in-place or /// NULL on failure. /// /// This is the equivalent of the Python expression: o1 -= o2. @@ -344,7 +381,8 @@ pub extern "C" fn pynumber_inplace_subtract( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceSubtract" -///| Returns the result of multiplying o1 by o2, possibly in-place, or NULL on +///| +/// Returns the result of multiplying o1 by o2, possibly in-place, or NULL on /// failure. /// /// This is the equivalent of the Python expression: o1 *= o2. @@ -361,7 +399,8 @@ pub extern "C" fn pynumber_inplace_floor_divide( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceFloorDivide" -///| Returns the result of dividing o1 by o2 giving a float result, possibly +///| +/// Returns the result of dividing o1 by o2 giving a float result, possibly /// in-place, or null on failure. /// /// This is the equivalent of the Python expression: o1 /= o2. @@ -371,7 +410,8 @@ pub extern "C" fn pynumber_inplace_true_divide( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceTrueDivide" -///| Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on +///| +/// Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on /// failure. /// /// This is the equivalent of the Python expression: o1 %= o2. @@ -381,7 +421,8 @@ pub extern "C" fn pynumber_inplace_remainder( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceRemainder" -///| Returns the result of raising o1 to the power of o2, possibly in-place, +///| +/// Returns the result of raising o1 to the power of o2, possibly in-place, /// or NULL on failure. /// /// This is the equivalent of the Python expression: o1 **= o2, @@ -393,7 +434,8 @@ pub extern "C" fn pynumber_inplace_power( obj3 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlacePower" -///| Returns the result of left shifting o1 by o2, possibly in-place, or NULL +///| +/// Returns the result of left shifting o1 by o2, possibly in-place, or NULL /// on failure. /// /// This is the equivalent of the Python expression: o1 <<= o2. @@ -403,7 +445,8 @@ pub extern "C" fn pynumber_inplace_lshift( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceLshift" -///| Returns the result of right shifting o1 by o2, possibly in-place or NULL +///| +/// Returns the result of right shifting o1 by o2, possibly in-place or NULL /// on failure. /// /// This is the equivalent of the Python expression: o1 >>= o2. @@ -413,7 +456,8 @@ pub extern "C" fn pynumber_inplace_rshift( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceRshift" -///| Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL +///| +/// Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL /// on failure. /// /// This is the equivalent of the Python expression: o1 &= o2. @@ -423,7 +467,8 @@ pub extern "C" fn pynumber_inplace_and( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceAnd" -///| Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL +///| +/// Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL /// on failure. /// /// This is the equivalent of the Python expression: o1 ^= o2. @@ -433,7 +478,8 @@ pub extern "C" fn pynumber_inplace_xor( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceXor" -///| Returns the result of bitwise or of o1 and o2, possibly in-place, +///| +/// Returns the result of bitwise or of o1 and o2, possibly in-place, /// or NULL on failure. /// /// This is the equivalent of the Python expression: o1 |= o2. @@ -443,7 +489,8 @@ pub extern "C" fn pynumber_inplace_or( obj2 : PyObjectRef, ) -> PyObjectRef = "PyNumber_InPlaceOr" -///| Returns the integer n converted to a string with a base, with a base +///| +/// Returns the integer n converted to a string with a base, with a base /// marker of 0b, 0o or 0x prefixed if applicable. /// /// If n is not an int object, it is converted with PyNumber_Index first. */ @@ -453,18 +500,21 @@ pub extern "C" fn pynumber_to_base( base : Int, ) -> PyObjectRef = "PyNumber_ToBase" -///| Return 1 if the object provides sequence protocol, and zero +///| +/// Return 1 if the object provides sequence protocol, and zero /// otherwise. /// /// This function always succeeds. #owned(obj) pub extern "C" fn pysequence_check(obj : PyObjectRef) -> Int = "PySequence_Check" -///| Return the size of sequence object o, or -1 on failure. +///| +/// Return the size of sequence object o, or -1 on failure. #owned(obj) pub extern "C" fn pysequence_size(obj : PyObjectRef) -> Int = "PySequence_Size" -///| Return the concatenation of o1 and o2 on success, and NULL on failure. +///| +/// Return the concatenation of o1 and o2 on success, and NULL on failure. /// /// This is the equivalent of the Python expression: o1 + o2. */ #owned(obj1, obj2) @@ -473,7 +523,8 @@ pub extern "C" fn pysequence_concat( obj2 : PyObjectRef, ) -> PyObjectRef = "PySequence_Concat" -///| Return the result of repeating sequence object 'o' 'count' times, +///| +/// Return the result of repeating sequence object 'o' 'count' times, /// or NULL on failure. /// /// This is the equivalent of the Python expression: o * count. */ @@ -483,7 +534,8 @@ pub extern "C" fn pysequence_repeat( count : Int, ) -> PyObjectRef = "PySequence_Repeat" -///| Return the ith element of o, or NULL on failure. +///| +/// Return the ith element of o, or NULL on failure. /// /// This is the equivalent of the Python expression: o[i]. #owned(obj) @@ -492,7 +544,8 @@ pub extern "C" fn pysequence_get_item( idx : UInt64, ) -> PyObjectRef = "PySequence_GetItem" -///| Return the slice of sequence object o between i1 and i2, or NULL on failure. +///| +/// Return the slice of sequence object o between i1 and i2, or NULL on failure. /// /// This is the equivalent of the Python expression: o[i1:i2]. #owned(obj) @@ -502,7 +555,8 @@ pub extern "C" fn pysequence_get_slice( end : UInt64, ) -> PyObjectRef = "PySequence_GetSlice" -///| Assign object 'v' to the ith element of the sequence 'o'. Raise an exception +///| +/// Assign object 'v' to the ith element of the sequence 'o'. Raise an exception /// and return -1 on failure; return 0 on success. /// /// This is the equivalent of the Python statement o[i] = v. */ @@ -513,13 +567,15 @@ pub extern "C" fn pysequence_set_item( value : PyObjectRef, ) -> Int = "PySequence_SetItem" -///| Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure. +///| +/// Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure. /// /// This is the equivalent of the Python statement: del o[i]. */ #owned(obj) pub extern "C" fn pysequence_del_item(obj : PyObjectRef, idx : UInt64) -> Int = "PySequence_DelItem" -///| Assign the sequence object 'v' to the slice in sequence object 'o', +///| +/// Assign the sequence object 'v' to the slice in sequence object 'o', /// from 'i1' to 'i2'. Returns -1 on failure. /// /// This is the equivalent of the Python statement: o[i1:i2] = v. */ @@ -531,7 +587,8 @@ pub extern "C" fn pysequence_set_slice( new_list : PyObjectRef, ) -> Int = "PySequence_SetSlice" -///| Delete the slice in sequence object 'o' from 'i1' to 'i2'. +///| +/// Delete the slice in sequence object 'o' from 'i1' to 'i2'. /// Returns -1 on failure. /// /// This is the equivalent of the Python statement: del o[i1:i2]. */ @@ -542,18 +599,21 @@ pub extern "C" fn pysequence_del_slice( end : UInt64, ) -> Int = "PySequence_DelSlice" -///| Returns the sequence 'o' as a tuple on success, and NULL on failure. +///| +/// Returns the sequence 'o' as a tuple on success, and NULL on failure. /// /// This is equivalent to the Python expression: tuple(o). */ #owned(obj) pub extern "C" fn pysequence_tuple(obj : PyObjectRef) -> PyObjectRef = "PySequence_Tuple" -///| Returns the sequence 'o' as a list on success, and NULL on failure. +///| +/// Returns the sequence 'o' as a list on success, and NULL on failure. /// This is equivalent to the Python expression: list(o) */ #owned(obj) pub extern "C" fn pysequence_list(obj : PyObjectRef) -> PyObjectRef = "PySequence_List" -///| Return the sequence 'o' as a list, unless it's already a tuple or list. +///| +/// Return the sequence 'o' as a list, unless it's already a tuple or list. /// /// Use PySequence_Fast_GET_ITEM to access the members of this list, and /// PySequence_Fast_GET_SIZE to get its length. @@ -572,7 +632,8 @@ pub extern "C" fn pysequence_count( value : PyObjectRef, ) -> Int = "PySequence_Count" -///| Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence +///| +/// Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence /// 'seq'; -1 on error. /// /// Use __contains__ if possible, else _PySequence_IterSearch(). @@ -591,7 +652,8 @@ pub extern "C" fn pysequence_index( value : PyObjectRef, ) -> Int = "PySequence_Index" -///| Append sequence 'o2' to sequence 'o1', in-place when possible. Return the +///| +/// Append sequence 'o2' to sequence 'o1', in-place when possible. Return the /// resulting object, which could be 'o1', or NULL on failure. /// /// This is the equivalent of the Python expression: o1 += o2. */ @@ -601,7 +663,8 @@ pub extern "C" fn pysequence_inplace_concat( obj2 : PyObjectRef, ) -> PyObjectRef = "PySequence_InPlaceConcat" -///| Repeat sequence 'o' by 'count', in-place when possible. Return the resulting +///| +/// Repeat sequence 'o' by 'count', in-place when possible. Return the resulting /// object, which could be 'o', or NULL on failure. /// /// This is the equivalent of the Python expression: o1 *= count. */ @@ -611,18 +674,21 @@ pub extern "C" fn pysequence_inplace_repeat( count : Int, ) -> PyObjectRef = "PySequence_InPlaceRepeat" -///| Return 1 if the object provides mapping protocol, and 0 otherwise. +///| +/// Return 1 if the object provides mapping protocol, and 0 otherwise. /// /// This function always succeeds. #owned(obj) pub extern "C" fn pymapping_check(obj : PyObjectRef) -> Int = "PyMapping_Check" -///| Returns the number of keys in mapping object 'o' on success, and -1 on +///| +/// Returns the number of keys in mapping object 'o' on success, and -1 on /// failure. This is equivalent to the Python expression: len(o). */ #owned(obj) pub extern "C" fn pymapping_size(obj : PyObjectRef) -> Int = "PyMapping_Size" -///| On success, return 1 if the mapping object 'o' has the key 'key', +///| +/// On success, return 1 if the mapping object 'o' has the key 'key', /// and 0 otherwise. /// /// This is equivalent to the Python expression: key in o. @@ -634,7 +700,8 @@ pub extern "C" fn pymapping_has_key_string( key : CStr, ) -> Int = "PyMapping_HasKeyString" -///| Return 1 if the mapping object has the key 'key', and 0 otherwise. +///| +/// Return 1 if the mapping object has the key 'key', and 0 otherwise. /// /// This is equivalent to the Python expression: key in o. /// @@ -645,17 +712,20 @@ pub extern "C" fn pymapping_has_key( key : PyObjectRef, ) -> Int = "PyMapping_HasKey" -///| On success, return a list or tuple of the keys in mapping object 'o'. +///| +/// On success, return a list or tuple of the keys in mapping object 'o'. /// On failure, return NULL. */ #owned(obj) pub extern "C" fn pymapping_keys(obj : PyObjectRef) -> PyObjectRef = "PyMapping_Keys" -///| On success, return a list or tuple of the values in mapping object 'o'. +///| +/// On success, return a list or tuple of the values in mapping object 'o'. /// On failure, return NULL. #owned(obj) pub extern "C" fn pymapping_values(obj : PyObjectRef) -> PyObjectRef = "PyMapping_Values" -///| On success, return a list or tuple of the items in mapping object 'o', +///| +/// On success, return a list or tuple of the items in mapping object 'o', /// where each item is a tuple containing a key-value pair. On failure, return /// NULL. #owned(obj) @@ -690,13 +760,15 @@ pub extern "C" fn py_object_is_subclass( typeorclass : PyObjectRef, ) -> Int = "PyObject_IsSubclass" -///| PyObject repr to string +///| +/// PyObject repr to string pub fn py_object_moonbit_repr(obj : PyObjectRef) -> String { let repr = py_object_repr(obj) py_unicode_as_moonbit_string(repr) } -///| PyObject str to string +///| +/// PyObject str to string pub fn py_object_moonbit_str(obj : PyObjectRef) -> String { let str = py_object_str(obj) py_unicode_as_moonbit_string(str) diff --git a/cpython/cell.mbt b/cpython/cell.mbt index 1151243..8411a49 100644 --- a/cpython/cell.mbt +++ b/cpython/cell.mbt @@ -34,4 +34,4 @@ pub extern "C" fn py_eval_eval_code( a : PyObjectRef, b : PyObjectRef, c : PyObjectRef, -) -> PyObjectRef = "PyEval_EvalCode" \ No newline at end of file +) -> PyObjectRef = "PyEval_EvalCode" diff --git a/cpython/ceval.mbt b/cpython/ceval.mbt index 10cf17a..dea7ab4 100644 --- a/cpython/ceval.mbt +++ b/cpython/ceval.mbt @@ -75,4 +75,4 @@ pub extern "C" fn py_eval_acquire_thread(tstate : PyThreadStateRef) = "PyEval_Ac ///| #owned(tstate) -pub extern "C" fn py_eval_release_thread(tstate : PyThreadStateRef) = "PyEval_ReleaseThread" \ No newline at end of file +pub extern "C" fn py_eval_release_thread(tstate : PyThreadStateRef) = "PyEval_ReleaseThread" diff --git a/cpython/class.mbt b/cpython/class.mbt index 8fe1afa..3c173f8 100644 --- a/cpython/class.mbt +++ b/cpython/class.mbt @@ -38,4 +38,4 @@ pub extern "C" fn py_instance_method_new(a : PyObjectRef) -> PyObjectRef = "PyIn ///| #owned(a) -pub extern "C" fn py_instance_method_function(a : PyObjectRef) -> PyObjectRef = "PyInstanceMethod_Function" \ No newline at end of file +pub extern "C" fn py_instance_method_function(a : PyObjectRef) -> PyObjectRef = "PyInstanceMethod_Function" diff --git a/cpython/code.mbt b/cpython/code.mbt index a82f95b..b51b422 100644 --- a/cpython/code.mbt +++ b/cpython/code.mbt @@ -65,4 +65,4 @@ pub extern "C" fn py_code_new_empty( ///| #owned(a) -pub extern "C" fn py_code_addr2_line(a : PyCodeObjectRef, b : Int) -> Int = "PyCode_Addr2Line" \ No newline at end of file +pub extern "C" fn py_code_addr2_line(a : PyCodeObjectRef, b : Int) -> Int = "PyCode_Addr2Line" diff --git a/cpython/codecs.mbt b/cpython/codecs.mbt index 9936481..2722323 100644 --- a/cpython/codecs.mbt +++ b/cpython/codecs.mbt @@ -115,4 +115,4 @@ pub extern "C" fn py_codec_backslash_replace_errors( #owned(exc) pub extern "C" fn py_codec_name_replace_errors( exc : PyObjectRef, -) -> PyObjectRef = "PyCodec_NameReplaceErrors" \ No newline at end of file +) -> PyObjectRef = "PyCodec_NameReplaceErrors" diff --git a/cpython/context.mbt b/cpython/context.mbt index d63e6fc..8dc25d4 100644 --- a/cpython/context.mbt +++ b/cpython/context.mbt @@ -65,4 +65,4 @@ pub extern "C" fn py_context_var_reset( pub extern "C" fn _py_context_new_hamt_for_tests() -> PyObjectRef = "_PyContext_NewHamtForTests" ///| -pub extern "C" fn py_context_clear_free_list() -> Int = "PyContext_ClearFreeList" \ No newline at end of file +pub extern "C" fn py_context_clear_free_list() -> Int = "PyContext_ClearFreeList" diff --git a/dict.mbt b/dict.mbt index 97e163b..b4f437e 100644 --- a/dict.mbt +++ b/dict.mbt @@ -21,7 +21,8 @@ pub struct PyDict { priv obj : PyObject } -///| Create a python dict object. +///| +/// Create a python dict object. /// If the python object is not a dict, it will raise a TypeMismatchError. pub fn PyDict::create(obj : PyObject) -> PyDict raise PyRuntimeError { guard obj.is_dict() else { raise TypeMismatchError } @@ -33,7 +34,8 @@ fn PyDict::create_unchecked(obj : PyObject) -> PyDict { PyDict::{ obj, } } -///| Create a python dict object from a python object reference. +///| +/// Create a python dict object from a python object reference. /// If the python object is not a dict, it will raise a TypeMismatchError. pub fn PyDict::create_by_ref( obj : @cpython.PyObjectRef, @@ -42,7 +44,8 @@ pub fn PyDict::create_by_ref( PyDict::{ obj: PyObject::create(obj) } } -///| Creates a new python dict object. +///| +/// Creates a new python dict object. /// /// ## Example /// @@ -67,7 +70,8 @@ pub fn PyDict::new() -> PyDict { PyDict::{ obj: PyObject::create(@cpython.py_dict_new()) } } -///| Return the length of the dict. +///| +/// Return the length of the dict. /// /// ## Example /// @@ -84,7 +88,8 @@ pub fn PyDict::len(self : PyDict) -> Int { @cpython.py_dict_size(self.obj_ref()).to_int() } -///| Return the elements of the dict by its key. +///| +/// Return the elements of the dict by its key. /// /// ## Example /// @@ -105,14 +110,16 @@ pub fn PyDict::get(self : PyDict, key : String) -> PyObjectEnum? { when(not(obj_ref.is_null()), fn() { PyObjectEnum::create_by_ref(obj_ref) }) } -///| Return the elements of the dict by its key, when the key is not string. +///| +/// Return the elements of the dict by its key, when the key is not string. pub fn PyDict::getByObj(self : PyDict, key : PyObject) -> PyObjectEnum? { let dict = self.obj_ref() let obj_ref = @cpython.py_dict_get_item(dict, key.obj_ref()) when(not(obj_ref.is_null()), fn() { PyObjectEnum::create_by_ref(obj_ref) }) } -///| Return the elements of the dict by its key. +///| +/// Return the elements of the dict by its key. /// /// **Note**: Will panic if the key is not found. /// @@ -133,7 +140,8 @@ pub fn PyDict::op_get(self : PyDict, key : String) -> PyObjectEnum { self.get(key).unwrap() } -///| Set the elements of the dict by its key (String). +///| +/// Set the elements of the dict by its key (String). /// /// ## Example /// @@ -166,7 +174,8 @@ pub fn[V : IsPyObject] PyDict::set( } -///| Set the elements of the dict by its key. (Object) +///| +/// Set the elements of the dict by its key. (Object) /// /// ## Example /// @@ -205,7 +214,8 @@ pub fn[K : IsPyObject, V : IsPyObject] PyDict::setByObj( } } -///| Set the elements of the dict by its key (String). +///| +/// Set the elements of the dict by its key (String). /// /// ## Example /// @@ -235,20 +245,23 @@ pub fn[V : IsPyObject] PyDict::op_set( self.set(key, val) } -///| Check if the dict contains the key. Note that the key is a string. +///| +/// Check if the dict contains the key. Note that the key is a string. /// If the key is not string, use `containsObj` instead. pub fn PyDict::contains(self : PyDict, key : String) -> Bool { let dict = self.obj_ref() @cpython.py_dict_contains(dict, PyString::from(key).obj_ref()) } -///| Check if the dict contains the key. +///| +/// Check if the dict contains the key. pub fn PyDict::containsObj(self : PyDict, key : PyObject) -> Bool { let dict = self.obj_ref() @cpython.py_dict_contains(dict, key.obj_ref()) } -///| Get the keys of the dict. +///| +/// Get the keys of the dict. /// /// **Notes**: It is slight different from the python dict.keys() method. /// In python, dict.keys() returns a view object that displays a list of all the keys. @@ -277,7 +290,8 @@ pub fn PyDict::keys(self : PyDict) -> PyList { PyList::create_by_ref_unchecked(@cpython.py_dict_keys(self.obj_ref())) } -///| Get the values of the dict. +///| +/// Get the values of the dict. /// /// **Notes**: It is slight different from the python dict.values() method. /// In python, dict.values() returns a view object that displays a list of all the values. @@ -306,7 +320,8 @@ pub fn PyDict::values(self : PyDict) -> PyList { PyList::create_by_ref_unchecked(@cpython.py_dict_values(self.obj_ref())) } -///| Get the items of the dict. +///| +/// Get the items of the dict. /// /// **Notes**: It is slight different from the python dict.items() method. /// In python, dict.items() returns a view object that displays a list of all the items. @@ -327,7 +342,8 @@ pub fn PyDict::items(self : PyDict) -> PyList { PyList::create_by_ref_unchecked(@cpython.py_dict_items(self.obj_ref())) } -///| Let python interpret print the dict directly. +///| +/// Let python interpret print the dict directly. /// /// **Note**: This is different from `println(dict)` and `dict.dump()`. /// although they always print the same content. diff --git a/float.mbt b/float.mbt index 9d45268..a994534 100644 --- a/float.mbt +++ b/float.mbt @@ -17,7 +17,8 @@ pub struct PyFloat { priv obj : PyObject } -///| Create a python float object from a python object. +///| +/// Create a python float object from a python object. /// If the python object is not a float, it will raise a TypeMismatchError. pub fn PyFloat::create(obj : PyObject) -> PyFloat raise PyRuntimeError { guard obj.is_float() else { raise TypeMismatchError } @@ -29,7 +30,8 @@ fn PyFloat::create_unchecked(obj : PyObject) -> PyFloat { PyFloat::{ obj, } } -///| Create a python float object from a python object reference. +///| +/// Create a python float object from a python object reference. /// If the python object is not a float, it will raise a TypeMismatchError. pub fn PyFloat::create_by_ref( obj : @cpython.PyObjectRef, @@ -48,7 +50,8 @@ test { ignore(PyFloat::create_by_ref_unchecked) } -///| Create a PyFloat from a Double value. +///| +/// Create a PyFloat from a Double value. /// /// ## Example /// @@ -60,7 +63,8 @@ pub fn PyFloat::from(value : Double) -> PyFloat { PyFloat::{ obj: @cpython.py_float_from_double(value) |> PyObject::create } } -///| Convert a PyFloat to a Double. +///| +/// Convert a PyFloat to a Double. /// /// ## Example /// @@ -72,7 +76,8 @@ pub fn PyFloat::to_double(self : PyFloat) -> Double { @cpython.py_float_as_double(self.obj_ref()) } -///| Print the PyFloat object directly. +///| +/// Print the PyFloat object directly. /// /// Different from use `println`, `dump` means we made python interpreter /// print the object directly. diff --git a/integer.mbt b/integer.mbt index d7ae669..20940fa 100644 --- a/integer.mbt +++ b/integer.mbt @@ -21,7 +21,8 @@ pub struct PyInteger { priv obj : PyObject } -///| Create a python integer object from a python object. +///| +/// Create a python integer object from a python object. /// If pub fn PyInteger::create(obj : PyObject) -> PyInteger raise PyRuntimeError { guard obj.is_int() else { raise TypeMismatchError } @@ -51,7 +52,8 @@ test { ignore(PyInteger::create_by_ref_unchecked) } -///| Create a PyInteger from an integer. +///| +/// Create a PyInteger from an integer. /// /// ## Example /// @@ -63,7 +65,8 @@ pub fn PyInteger::from(value : Int64) -> PyInteger { PyInteger::{ obj: PyObject::create(@cpython.py_long_from_long(value)) } } -///| Convert a PyInteger to an integer. +///| +/// Convert a PyInteger to an integer. /// /// ## Example /// @@ -75,7 +78,8 @@ pub fn PyInteger::to_int64(self : PyInteger) -> Int64 { @cpython.py_long_as_long(self.obj_ref()) } -///| Convert a PyInteger to a double. +///| +/// Convert a PyInteger to a double. /// /// ## Example /// @@ -87,7 +91,8 @@ pub fn PyInteger::to_double(self : PyInteger) -> Double { @cpython.py_long_as_double(self.obj_ref()) } -///| Print the PyInteger object directly. +///| +/// Print the PyInteger object directly. /// /// Different from use `println`, `dump` means we made python interpreter /// print the object directly. diff --git a/list.mbt b/list.mbt index a986b2c..38e3821 100644 --- a/list.mbt +++ b/list.mbt @@ -21,7 +21,8 @@ pub struct PyList { priv obj : PyObject } -///| Create an empty python list. +///| +/// Create an empty python list. /// /// ## Example /// @@ -34,7 +35,8 @@ pub fn PyList::new() -> PyList { PyList::{ obj: @cpython.py_list_new(0) |> PyObject::create } } -///| Create a python list object from a pyobject. +///| +/// Create a python list object from a pyobject. /// If the pyobject is not a list, it will raise a TypeMismatchError. pub fn PyList::create(obj : PyObject) -> PyList raise PyRuntimeError { guard obj.is_list() else { raise TypeMismatchError } @@ -46,7 +48,8 @@ fn PyList::create_unchecked(obj : PyObject) -> PyList { PyList::{ obj, } } -///| Create a python list object from a pyobject reference. +///| +/// Create a python list object from a pyobject reference. /// If the pyobject is not a list, it will raise a TypeMismatchError. pub fn PyList::create_by_ref( obj : @cpython.PyObjectRef, @@ -60,7 +63,8 @@ fn PyList::create_by_ref_unchecked(obj : @cpython.PyObjectRef) -> PyList { PyList::{ obj: PyObject::create(obj) } } -///| Returns the length of the list. +///| +/// Returns the length of the list. /// /// ## Example /// @@ -87,7 +91,8 @@ pub fn PyList::len(self : PyList) -> Int { @cpython.py_list_size(self.obj_ref()).to_int() } -///| Append an item to the end of the list. +///| +/// Append an item to the end of the list. /// /// ## Example /// @@ -126,7 +131,8 @@ pub fn[T : IsPyObject] PyList::append(self : PyList, item : T) -> Unit { // let _ = @cpython.py_list_reverse(self.obj_ref()) //} -///| Create a new python list from a python object array +///| +/// Create a new python list from a python object array /// /// ## Example /// @@ -149,7 +155,8 @@ pub fn[T : IsPyObject] PyList::from(items : Array[T]) -> PyList { pylist } -///| Get the item at the specified index. +///| +/// Get the item at the specified index. /// /// **Notes**: Although python support negative index, the moonbit api does not /// support it. Code like `list.get(-1)` will return `None`. @@ -175,7 +182,8 @@ pub fn PyList::get(self : PyList, idx : Int) -> PyObjectEnum? { }) } -///| Get the item at the specified index. +///| +/// Get the item at the specified index. /// /// **Notes**: Although python support negative index, the moonbit api does not /// support it. which means code like `list[-1]` will be panic. @@ -196,7 +204,8 @@ pub fn PyList::op_get(self : PyList, idx : Int) -> PyObjectEnum { self.get(idx).unwrap() } -///| Set the item at the specified index. +///| +/// Set the item at the specified index. /// /// **Notes**: Although python support negative index, the moonbit api does not /// support it. which means code like `list.set(-1) = ...` will raise IndexOutOfBoundsError. @@ -227,7 +236,8 @@ pub fn[T : IsPyObject] PyList::set( } -///| Set the item at the specified index. +///| +/// Set the item at the specified index. /// /// **Notes**: Although python support negative index, the moonbit api does not /// support it. which means code like `list[-1] = ...` will be panic. @@ -254,7 +264,8 @@ pub fn[T : IsPyObject] PyList::op_set( } } -///| Let python interpreter print the list directly. +///| +/// Let python interpreter print the list directly. /// /// **Note**: It is different from `println(list)` and `list.dump()` /// although they always print the same content. diff --git a/main/main.mbt b/main/main.mbt index b794b6a..6ed8a30 100644 --- a/main/main.mbt +++ b/main/main.mbt @@ -13,7 +13,7 @@ // limitations under the License. ///| -typealias @python.(PyInteger, PyList, PyTuple) +using @python {type PyInteger, type PyList, type PyTuple} ///| fn main { diff --git a/module.mbt b/module.mbt index 5b59ecb..0fe2b5b 100644 --- a/module.mbt +++ b/module.mbt @@ -55,7 +55,8 @@ test { } // REVIEW: what if user call pyimport twice or more? -///| Import a python module +///| +/// Import a python module /// /// ## Example /// @@ -64,7 +65,7 @@ test { /// /// assert_true(os is Some(_)) /// ``` -pub fn pyimport(name : String, print_err~ : Bool = false) -> PyModule? { +pub fn pyimport(name : String, print_err? : Bool = false) -> PyModule? { let obj = @cpython.py_import_import_module(name) if obj.is_null() { if print_err { @@ -78,7 +79,8 @@ pub fn pyimport(name : String, print_err~ : Bool = false) -> PyModule? { |> Some } -///| Get the name of the module. +///| +/// Get the name of the module. /// /// ## Example /// @@ -111,7 +113,8 @@ pub fn PyModule::dump(self : PyModule) -> Unit { self.obj.dump() } -///| Get attribute by name. +///| +/// Get attribute by name. /// /// ## Example /// @@ -145,7 +148,7 @@ pub fn PyModule::dump(self : PyModule) -> Unit { pub fn PyModule::get_attr( self : PyModule, attr : String, - print_err~ : Bool = false, + print_err? : Bool = false, ) -> PyObjectEnum? { if self.attrs.contains(attr) { return self.attrs.get(attr) diff --git a/obj.mbt b/obj.mbt index 52d36ac..838125b 100644 --- a/obj.mbt +++ b/obj.mbt @@ -123,7 +123,7 @@ pub fn PyObject::type_name(self : PyObject) -> String { pub fn PyObject::get_attr( self : PyObject, attr : String, - print_err~ : Bool = false, + print_err? : Bool = false, ) -> PyObjectEnum? { let f = @cpython.py_object_get_attr_string(self.obj_ref(), attr) if f.is_null() { diff --git a/set.mbt b/set.mbt index fa84495..4e36a8a 100644 --- a/set.mbt +++ b/set.mbt @@ -11,4 +11,3 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - diff --git a/str.mbt b/str.mbt index 78fd4ba..f39dea8 100644 --- a/str.mbt +++ b/str.mbt @@ -21,7 +21,8 @@ pub struct PyString { priv obj : PyObject } -///| Create a python string from a python object. +///| +/// Create a python string from a python object. /// If the python object is not a string, it will raise a TypeMismatchError. pub fn PyString::create(obj : PyObject) -> PyString raise PyRuntimeError { guard obj.is_string() else { raise TypeMismatchError } @@ -33,7 +34,8 @@ fn PyString::create_unchecked(obj : PyObject) -> PyString { PyString::{ obj, } } -///| Create a python string from a python object reference. +///| +/// Create a python string from a python object reference. ///If the python object is not a string, it will raise a TypeMismatchError. pub fn PyString::create_by_ref( obj_ref : @cpython.PyObjectRef, @@ -54,7 +56,8 @@ test { ignore(PyString::create_by_ref_unchecked) } -///| Create a PyString from a string +///| +/// Create a PyString from a string /// /// ## Example /// @@ -68,7 +71,8 @@ pub fn PyString::from(s : String) -> PyString { } } -///| Print the PyString object directly. +///| +/// Print the PyString object directly. /// /// Different from use `println`, `dump` means we made python interpreter /// print the object directly. diff --git a/test/object_test.mbt b/test/object_test.mbt index 3a7b795..e62928f 100644 --- a/test/object_test.mbt +++ b/test/object_test.mbt @@ -13,15 +13,15 @@ // limitations under the License. ///| -typealias @python.( - PyInteger, - PyFloat, - PyString, - PyList, - PyTuple, - PyBool, - PyDict -) +using @python { + type PyInteger, + type PyFloat, + type PyString, + type PyList, + type PyTuple, + type PyBool, + type PyDict, +} ///| test "PyInteger Test" { diff --git a/time/lib.mbt b/time/lib.mbt index de5c732..1991c47 100644 --- a/time/lib.mbt +++ b/time/lib.mbt @@ -13,7 +13,7 @@ // limitations under the License. ///| -typealias @python.(PyModule, PyTuple, PyFloat) +using @python {type PyModule, type PyTuple, type PyFloat} ///| pub struct TimeModule { @@ -58,7 +58,8 @@ pub fn sleep(seconds : Double) -> Unit { () } -///| Returns the time in seconds since the epoch as a floating-point number. +///| +/// Returns the time in seconds since the epoch as a floating-point number. /// Corresponds to `time.time()` in Python. pub fn time() -> Double { let lib = singleton() @@ -74,7 +75,8 @@ pub fn time() -> Double { t.to_double() } -///| Returns the time in nanoseconds since the epoch as an integer. +///| +/// Returns the time in nanoseconds since the epoch as an integer. /// Corresponds to `time.time_ns()` in Python. pub fn time_ns() -> Int64 { let lib = singleton() @@ -89,7 +91,8 @@ pub fn time_ns() -> Int64 { t.to_int64() } -///| Returns the value (in fractional seconds) of a monotonic clock. +///| +/// Returns the value (in fractional seconds) of a monotonic clock. /// Corresponds to `time.monotonic()` in Python. pub fn monotonic() -> Double { let lib = singleton() @@ -104,7 +107,8 @@ pub fn monotonic() -> Double { t.to_double() } -///| Returns the value (in nanoseconds) of a monotonic clock. +///| +/// Returns the value (in nanoseconds) of a monotonic clock. /// Corresponds to `time.monotonic_ns()` in Python. pub fn monotonic_ns() -> Int64 { let lib = singleton() @@ -119,7 +123,8 @@ pub fn monotonic_ns() -> Int64 { t.to_int64() } -///| Returns the value (in fractional seconds) of a performance counter. +///| +/// Returns the value (in fractional seconds) of a performance counter. /// Corresponds to `time.perf_counter()` in Python. pub fn perf_counter() -> Double { let lib = singleton() @@ -134,7 +139,8 @@ pub fn perf_counter() -> Double { t.to_double() } -///| Returns the value (in nanoseconds) of a performance counter. +///| +/// Returns the value (in nanoseconds) of a performance counter. /// Corresponds to `time.perf_counter_ns()` in Python. pub fn perf_counter_ns() -> Int64 { let lib = singleton() @@ -149,7 +155,8 @@ pub fn perf_counter_ns() -> Int64 { t.to_int64() } -///| Returns the value (in fractional seconds) of the sum of the system and user CPU time of the current process. +///| +/// Returns the value (in fractional seconds) of the sum of the system and user CPU time of the current process. /// Corresponds to `time.process_time()` in Python. pub fn process_time() -> Double { let lib = singleton() @@ -164,7 +171,8 @@ pub fn process_time() -> Double { t.to_double() } -///| Returns the value (in nanoseconds) of the sum of the system and user CPU time of the current process. +///| +/// Returns the value (in nanoseconds) of the sum of the system and user CPU time of the current process. /// Corresponds to `time.process_time_ns()` in Python. pub fn process_time_ns() -> Int64 { let lib = singleton() @@ -179,7 +187,8 @@ pub fn process_time_ns() -> Int64 { t.to_int64() } -///| Converts a time expressed in seconds since the epoch to a string representing local time. +///| +/// Converts a time expressed in seconds since the epoch to a string representing local time. /// If `secs_option` is `None`, the current time as returned by `time()` is used. /// Corresponds to `time.ctime([secs])` in Python. pub fn ctime(secs_option : Double?) -> String { diff --git a/tkinter/tkinter.mbt b/tkinter/tkinter.mbt index 631222d..b512bd3 100644 --- a/tkinter/tkinter.mbt +++ b/tkinter/tkinter.mbt @@ -27,7 +27,13 @@ //} ///| -typealias @python.(PyModule, PyObject, PyTuple, PyDict, PyString) +using @python { + type PyModule, + type PyObject, + type PyTuple, + type PyDict, + type PyString, +} ///| pub suberror TkinterError { diff --git a/traits.mbt b/traits.mbt index d15a85b..98991f5 100644 --- a/traits.mbt +++ b/traits.mbt @@ -24,7 +24,8 @@ impl IsPyObject with obj_ref(self) { self.obj().obj } -///| Return the type name of the object. +///| +/// Return the type name of the object. /// /// ## Example /// diff --git a/tuple.mbt b/tuple.mbt index 0aee404..278f61c 100644 --- a/tuple.mbt +++ b/tuple.mbt @@ -21,7 +21,8 @@ pub struct PyTuple { priv obj : PyObject } -///| Create a PyTuple object. +///| +/// Create a PyTuple object. /// /// **Notes**: Tuple type must know the size of the tuple. /// @@ -40,7 +41,8 @@ pub fn PyTuple::new(size : UInt64) -> PyTuple { PyTuple::{ obj: @cpython.pytuple_new(size) |> PyObject::create } } -///| Create a PyTuple object from a python object. +///| +/// Create a PyTuple object from a python object. /// If the python object is not a tuple, it will raise a TypeMismatchError. pub fn PyTuple::create(obj : PyObject) -> PyTuple raise PyRuntimeError { guard obj.is_tuple() else { raise TypeMismatchError } @@ -52,7 +54,8 @@ fn PyTuple::create_unchecked(obj : PyObject) -> PyTuple { PyTuple::{ obj, } } -///| Create a PyTuple object from a python object reference. +///| +/// Create a PyTuple object from a python object reference. /// If the python object is not a tuple, it will raise a TypeMismatchError. pub fn PyTuple::create_by_ref( obj_ref : @cpython.PyObjectRef, @@ -71,7 +74,8 @@ test { ignore(PyTuple::create_by_ref_unchecked) } -///| Return the size of the tuple. +///| +/// Return the size of the tuple. /// /// ## Example: /// @@ -84,7 +88,8 @@ pub fn PyTuple::len(self : PyTuple) -> UInt64 { @cpython.pytuple_size(self.obj_ref()) } -///| Get the item at the given index. +///| +/// Get the item at the given index. /// /// **Notes**: Although python supports negative index, in moonbit, we don't have plan to /// support it. Code like `tuple.get(-1)` will return `None`. @@ -122,7 +127,8 @@ pub fn PyTuple::get(self : PyTuple, idx : Int) -> PyObjectEnum? { }) } -///| Get the item at the given index. +///| +/// Get the item at the given index. /// /// **Notes**: Although python supports negative index, in moonbit, we don't have plan to /// support it. Code like `tuple[-1]` will return `None`. @@ -144,7 +150,8 @@ pub fn PyTuple::op_get(self : PyTuple, idx : Int) -> PyObjectEnum { self.get(idx).unwrap() } -///| Set the item at the given index. +///| +/// Set the item at the given index. /// /// **Notes**: Although python supports negative index, in moonbit, we don't have plan to /// support it. Code like `tuple.set(-1, item)` will raise `IndexOutOfBoundError`. @@ -174,7 +181,8 @@ pub fn[T : IsPyObject] PyTuple::set( } -///| Set the item at the given index. +///| +/// Set the item at the given index. /// /// **Notes**: Although python supports negative index, in moonbit, we don't have plan to /// support it. Code like `tuple[-1] = item` will raise `IndexOutOfBoundError`. diff --git a/turtle/color.mbt b/turtle/color.mbt index 8616e0c..b4c9f80 100644 --- a/turtle/color.mbt +++ b/turtle/color.mbt @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -///| Represents common colors used for drawing. +///| +/// Represents common colors used for drawing. /// Deriving Show provides a default to_string() which can be converted to lowercase for Python. pub(all) enum Color { Red @@ -35,7 +36,8 @@ pub(all) enum Color { Violet } derive(Show) -///| Converts the Color enum to a lowercase string representation suitable for Python turtle. +///| +/// Converts the Color enum to a lowercase string representation suitable for Python turtle. /// - self: The Color enum value. /// Returns: The color name as a PyString. pub fn Color::to_pystr(self : Color) -> PyString { diff --git a/turtle/lib.mbt b/turtle/lib.mbt index 379d77e..f770475 100644 --- a/turtle/lib.mbt +++ b/turtle/lib.mbt @@ -13,16 +13,16 @@ // limitations under the License. ///| -typealias @python.( - PyModule, - PyObject, - PyTuple, - PyDict, - PyString, - PyInteger, - PyFloat, - PyCallable -) +using @python { + type PyModule, + type PyObject, + type PyTuple, + type PyDict, + type PyString, + type PyInteger, + type PyFloat, + type PyCallable, +} ///| pub suberror TurtleError { diff --git a/turtle/pen2.mbt b/turtle/pen2.mbt index 4bafa7a..26351c4 100644 --- a/turtle/pen2.mbt +++ b/turtle/pen2.mbt @@ -12,14 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -///| Represents a turtle pen object, capable of drawing on the screen. +///| +/// Represents a turtle pen object, capable of drawing on the screen. /// corresponds to `turtle.Pen` or the default turtle instance in Python. pub struct Pen { priv pen : PyObject methods : Map[String, PyCallable] // Caches method lookups } -///| Retrieves a callable Python method from the cached methods or the underlying Python object. +///| +/// Retrieves a callable Python method from the cached methods or the underlying Python object. /// - name: The name of the method. /// Returns Some(PyCallable) if the method is found, None otherwise. fn Pen::get_method(self : Pen, name : String) -> PyCallable? { @@ -36,7 +38,8 @@ fn Pen::get_method(self : Pen, name : String) -> PyCallable? { } } -///| Creates a new turtle pen instance. +///| +/// Creates a new turtle pen instance. /// In Python, this might correspond to `turtle.Pen()` or obtaining the default instance. /// This Moonbit function creates a new `turtle.Pen()` instance. pub fn Pen::new() -> Pen { @@ -46,7 +49,8 @@ pub fn Pen::new() -> Pen { Pen::{ pen, methods: Map::new() } } -///| Moves the pen to the home position (0,0) and sets heading to 0 degrees. +///| +/// Moves the pen to the home position (0,0) and sets heading to 0 degrees. /// corresponds to `pen.home()` in Python. pub fn Pen::home(self : Pen) -> Unit { guard self.get_method("home") is Some(func) else { @@ -57,7 +61,8 @@ pub fn Pen::home(self : Pen) -> Unit { () } -///| Sets the pen size (thickness). +///| +/// Sets the pen size (thickness). /// - size: The pen thickness. Must be positive. /// corresponds to `pen.pensize(size)` in Python. pub fn Pen::pensize(self : Pen, size : Double) -> Unit { @@ -75,7 +80,8 @@ pub fn Pen::pensize(self : Pen, size : Double) -> Unit { } -///| Returns the current x-coordinate of the pen. +///| +/// Returns the current x-coordinate of the pen. /// corresponds to `pen.xcor()` in Python. pub fn Pen::xcor(self : Pen) -> Double { guard self.get_method("xcor") is Some(func) else { @@ -87,7 +93,8 @@ pub fn Pen::xcor(self : Pen) -> Double { x.to_double() } -///| Returns the current y-coordinate of the pen. +///| +/// Returns the current y-coordinate of the pen. /// corresponds to `pen.ycor()` in Python. pub fn Pen::ycor(self : Pen) -> Double { guard self.get_method("ycor") is Some(func) else { @@ -99,7 +106,8 @@ pub fn Pen::ycor(self : Pen) -> Double { y.to_double() } -///| Returns the current position as a tuple of (x, y) coordinates. +///| +/// Returns the current position as a tuple of (x, y) coordinates. /// corresponds to `pen.position()` or `pen.pos()` in Python. pub fn Pen::position(self : Pen) -> (Double, Double) { guard self.get_method("position") is Some(func) else { @@ -128,7 +136,8 @@ pub fn Pen::position(self : Pen) -> (Double, Double) { (x_py.to_double(), y_py.to_double()) } -///| Returns the current heading of the pen in degrees. +///| +/// Returns the current heading of the pen in degrees. /// corresponds to `pen.heading()` in Python. pub fn Pen::heading(self : Pen) -> Double { guard self.get_method("heading") is Some(func) else { @@ -143,7 +152,8 @@ pub fn Pen::heading(self : Pen) -> Double { h.to_double() } -///| Returns the current unit for angles set by the `degrees()` or `radians()` methods. +///| +/// Returns the current unit for angles set by the `degrees()` or `radians()` methods. /// Note: This method name might be slightly misleading in Python's turtle documentation. /// corresponds to `pen.radians()` in Python (when radians are used). /// If using degrees, you might check `turtle.degrees()` which is usually global. @@ -161,7 +171,8 @@ pub fn Pen::radians(self : Pen) -> Double { r.to_double() } -///| Sets the pen speed. +///| +/// Sets the pen speed. /// - speed: An enum representing the desired drawing speed. /// corresponds to `pen.speed(speed)` in Python, where speed is an integer. pub fn Pen::speed(self : Pen, speed : Speed) -> Unit { @@ -175,7 +186,8 @@ pub fn Pen::speed(self : Pen, speed : Speed) -> Unit { } -///| Sets the pen color. +///| +/// Sets the pen color. /// - color: The pen color. /// corresponds to `pen.pencolor(color)` in Python. pub fn Pen::pencolor(self : Pen, color : Color) -> Unit { @@ -189,7 +201,8 @@ pub fn Pen::pencolor(self : Pen, color : Color) -> Unit { } -///| Sets the pen width. +///| +/// Sets the pen width. /// - width: The pen width. Must be positive. /// corresponds to `pen.width(width)` in Python. pub fn Pen::width(self : Pen, width : Double) -> Unit { @@ -207,7 +220,8 @@ pub fn Pen::width(self : Pen, width : Double) -> Unit { } -///| Moves the pen forward by the specified distance. +///| +/// Moves the pen forward by the specified distance. /// - distance: The distance to move forward. Must be positive. /// corresponds to `pen.forward(distance)` or `pen.fd(distance)` in Python. pub fn Pen::forward(self : Pen, distance : Double) -> Unit { @@ -225,7 +239,8 @@ pub fn Pen::forward(self : Pen, distance : Double) -> Unit { } -///| Moves the pen backward by the specified distance. +///| +/// Moves the pen backward by the specified distance. /// - distance: The distance to move backward. Must be positive. /// corresponds to `pen.backward(distance)` or `pen.bk(distance)` or `pen.ba(distance)` in Python. pub fn Pen::backward(self : Pen, distance : Double) -> Unit { @@ -244,7 +259,8 @@ pub fn Pen::backward(self : Pen, distance : Double) -> Unit { } -///| Turns the pen left by the specified angle. +///| +/// Turns the pen left by the specified angle. /// - angle: The angle in degrees to turn left. /// corresponds to `pen.left(angle)` or `pen.lt(angle)` in Python. pub fn Pen::left(self : Pen, angle : Double) -> Unit { @@ -258,7 +274,8 @@ pub fn Pen::left(self : Pen, angle : Double) -> Unit { } -///| Turns the pen right by the specified angle. +///| +/// Turns the pen right by the specified angle. /// - angle: The angle in degrees to turn right. /// corresponds to `pen.right(angle)` or `pen.rt(angle)` in Python. pub fn Pen::right(self : Pen, angle : Double) -> Unit { @@ -272,7 +289,8 @@ pub fn Pen::right(self : Pen, angle : Double) -> Unit { } -///| Moves the pen to an absolute position (x, y). +///| +/// Moves the pen to an absolute position (x, y). /// - x: The target x-coordinate. /// - y: The target y-coordinate. /// corresponds to `pen.goto(x, y)` or `pen.setpos(x, y)` or `pen.setposition(x, y)` in Python. @@ -287,7 +305,8 @@ pub fn Pen::goto(self : Pen, x : Double, y : Double) -> Unit { } -///| Makes the turtle invisible. +///| +/// Makes the turtle invisible. /// corresponds to `pen.hideturtle()` or `pen.ht()` in Python. pub fn Pen::hide(self : Pen) -> Unit { guard self.get_method("hideturtle") is Some(func) else { @@ -298,7 +317,8 @@ pub fn Pen::hide(self : Pen) -> Unit { } -///| Lifts the pen up. No drawing will occur when the pen moves. +///| +/// Lifts the pen up. No drawing will occur when the pen moves. /// corresponds to `pen.penup()` or `pen.pu()` or `pen.up()` in Python. pub fn Pen::penup(self : Pen) -> Unit { guard self.get_method("penup") is Some(func) else { @@ -309,7 +329,8 @@ pub fn Pen::penup(self : Pen) -> Unit { } -///| Puts the pen down. Drawing will occur when the pen moves. +///| +/// Puts the pen down. Drawing will occur when the pen moves. /// corresponds to `pen.pendown()` or `pen.pd()` or `pen.down()` in Python. pub fn Pen::pendown(self : Pen) -> Unit { guard self.get_method("pendown") is Some(func) else { @@ -320,7 +341,8 @@ pub fn Pen::pendown(self : Pen) -> Unit { } -///| Draws a dot at the current position. +///| +/// Draws a dot at the current position. /// - size: The diameter of the dot. Must be positive. /// - color: The color of the dot. /// corresponds to `pen.dot(size, color)` in Python. @@ -343,7 +365,8 @@ pub fn Pen::dot(self : Pen, size : Double, color : Color) -> Unit { // Simpler way to ignore return value } -///| Deletes the pen's drawings from the screen, but does not move the pen. +///| +/// Deletes the pen's drawings from the screen, but does not move the pen. /// corresponds to `pen.clear()` in Python. pub fn Pen::clear(self : Pen) -> Unit { guard self.get_method("clear") is Some(func) else { @@ -356,7 +379,8 @@ pub fn Pen::clear(self : Pen) -> Unit { // Add more Pen methods -///| Sets the fill color. +///| +/// Sets the fill color. /// - color: The color used for filling. /// corresponds to `pen.fillcolor(color)` in Python. pub fn Pen::fillcolor(self : Pen, color : Color) -> Unit { @@ -370,7 +394,8 @@ pub fn Pen::fillcolor(self : Pen, color : Color) -> Unit { } -///| Sets the pen color and fill color. +///| +/// Sets the pen color and fill color. /// - color: The color used for pen and fill. /// corresponds to `pen.color(color)` in Python. Can also take two colors, but we simplify here. pub fn Pen::color(self : Pen, color : Color) -> Unit { @@ -384,7 +409,8 @@ pub fn Pen::color(self : Pen, color : Color) -> Unit { } -///| Returns True if the pen is down, False otherwise. +///| +/// Returns True if the pen is down, False otherwise. /// corresponds to `pen.isdown()` in Python. pub fn Pen::isdown(self : Pen) -> Bool { guard self.get_method("isdown") is Some(func) else { @@ -396,7 +422,8 @@ pub fn Pen::isdown(self : Pen) -> Bool { b.to_bool() } -///| Makes the turtle visible. +///| +/// Makes the turtle visible. /// corresponds to `pen.showturtle()` or `pen.st()` in Python. pub fn Pen::show(self : Pen) -> Unit { guard self.get_method("showturtle") is Some(func) else { @@ -407,7 +434,8 @@ pub fn Pen::show(self : Pen) -> Unit { } -///| Returns True if the turtle is visible, False otherwise. +///| +/// Returns True if the turtle is visible, False otherwise. /// corresponds to `pen.isvisible()` in Python. pub fn Pen::isvisible(self : Pen) -> Bool { guard self.get_method("isvisible") is Some(func) else { @@ -419,7 +447,8 @@ pub fn Pen::isvisible(self : Pen) -> Bool { b.to_bool() } -///| Starts color filling. +///| +/// Starts color filling. /// corresponds to `pen.begin_fill()` in Python. pub fn Pen::begin_fill(self : Pen) -> Unit { guard self.get_method("begin_fill") is Some(func) else { @@ -430,7 +459,8 @@ pub fn Pen::begin_fill(self : Pen) -> Unit { } -///| Stops color filling and fills the area bounded by the last begin_fill() and this call. +///| +/// Stops color filling and fills the area bounded by the last begin_fill() and this call. /// corresponds to `pen.end_fill()` in Python. pub fn Pen::end_fill(self : Pen) -> Unit { guard self.get_method("end_fill") is Some(func) else { @@ -441,7 +471,8 @@ pub fn Pen::end_fill(self : Pen) -> Unit { } -///| Draws a circle. +///| +/// Draws a circle. /// - radius: The radius of the circle. A positive radius means counterclockwise, negative means clockwise. /// - extent: Optional. An angle in degrees. If given, only part of the circle is drawn. /// - steps: Optional. An integer. The number of steps to use for approximating the circle. @@ -449,8 +480,8 @@ pub fn Pen::end_fill(self : Pen) -> Unit { pub fn Pen::circle( self : Pen, radius : Double, - extent~ : Double? = None, - steps~ : Int? = None, + extent? : Double? = None, + steps? : Int? = None, ) -> Unit { guard self.get_method("circle") is Some(func) else { println("Failed to get Pen::circle method") @@ -471,7 +502,8 @@ pub fn Pen::circle( } -///| Leaves a copy of the turtle shape at the current location. +///| +/// Leaves a copy of the turtle shape at the current location. /// Returns a stamp_id which can be used later with clearstamp() or clearstamps(). /// corresponds to `pen.stamp()` in Python. /// Note: The return value (stamp_id) is an integer in Python, we return it as Int. @@ -488,7 +520,8 @@ pub fn Pen::stamp(self : Pen) -> Int { i.to_int64().to_int() // Convert to Int } -///| Deletes the stamp with the given stampid. +///| +/// Deletes the stamp with the given stampid. /// - stamp_id: The id of the stamp to delete, as returned by stamp(). /// corresponds to `pen.clearstamp(stampid)` in Python. pub fn Pen::clearstamp(self : Pen, stamp_id : Int) -> Unit { @@ -502,10 +535,11 @@ pub fn Pen::clearstamp(self : Pen, stamp_id : Int) -> Unit { } -///| Deletes all or the first/last n stamps. +///| +/// Deletes all or the first/last n stamps. /// - n: Optional. If None, delete all stamps. If n > 0, delete the first n stamps. If n < 0, delete the last abs(n) stamps. /// corresponds to `pen.clearstamps(n=None)` in Python. -pub fn Pen::clearstamps(self : Pen, n~ : Int? = None) -> Unit { +pub fn Pen::clearstamps(self : Pen, n? : Int? = None) -> Unit { guard self.get_method("clearstamps") is Some(func) else { println("Failed to get Pen::clearstamps method") return @@ -523,7 +557,8 @@ pub fn Pen::clearstamps(self : Pen, n~ : Int? = None) -> Unit { } -///| Resets the pen's and screen's state. Deletes drawings, recenters pen, resets variables. +///| +/// Resets the pen's and screen's state. Deletes drawings, recenters pen, resets variables. /// corresponds to `pen.reset()` in Python. pub fn Pen::reset(self : Pen) -> Unit { guard self.get_method("reset") is Some(func) else { @@ -534,7 +569,8 @@ pub fn Pen::reset(self : Pen) -> Unit { } -///| Sets the turtle shape. +///| +/// Sets the turtle shape. /// - name: The name of the shape. Use the Shape enum for common shapes. /// corresponds to `pen.shape(name)` in Python. pub fn Pen::shape(self : Pen, name : Shape) -> Unit { @@ -548,16 +584,17 @@ pub fn Pen::shape(self : Pen, name : Shape) -> Unit { } -///| Sets the shape's stretches and outline. +///| +/// Sets the shape's stretches and outline. /// - stretch_width: Stretchfactor for width, perpendicular to orientation. /// - stretch_len: Stretchfactor for length, in direction of orientation. /// - outline: Optional outline thickness. /// corresponds to `pen.shapesize(stretch_wid=None, stretch_len=None, outline=None)` in Python. pub fn Pen::shapesize( self : Pen, - stretch_width~ : Double? = None, - stretch_len~ : Double? = None, - outline~ : Int? = None, + stretch_width? : Double? = None, + stretch_len? : Double? = None, + outline? : Int? = None, ) -> Unit { guard self.get_method("shapesize") is Some(func) else { println("Failed to get Pen::shapesize method") diff --git a/turtle/shape.mbt b/turtle/shape.mbt index bca278e..13d065c 100644 --- a/turtle/shape.mbt +++ b/turtle/shape.mbt @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -///| Represents common shapes for the turtle cursor. +///| +/// Represents common shapes for the turtle cursor. /// Deriving Show provides a default to_string() which can be converted to lowercase for Python. pub(all) enum Shape { Arrow diff --git a/utils.mbt b/utils.mbt index 9612bc6..b96851b 100644 --- a/utils.mbt +++ b/utils.mbt @@ -46,7 +46,8 @@ fn init { init_py() } -///| elimnate the quotes from a string +///| +/// elimnate the quotes from a string /// /// ## Example /// From ee641e97d4f6da41f1673b53e32d7227cfaf1183 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:27:59 +0800 Subject: [PATCH 10/12] chore: update interfaces --- cpython/pkg.generated.mbti | 633 +++++++++++++++++++++++++++++++++++++ main/pkg.generated.mbti | 13 + pkg.generated.mbti | 214 +++++++++++++ test/pkg.generated.mbti | 13 + time/pkg.generated.mbti | 39 +++ tkinter/pkg.generated.mbti | 33 ++ turtle/pkg.generated.mbti | 116 +++++++ 7 files changed, 1061 insertions(+) create mode 100644 cpython/pkg.generated.mbti create mode 100644 main/pkg.generated.mbti create mode 100644 pkg.generated.mbti create mode 100644 test/pkg.generated.mbti create mode 100644 time/pkg.generated.mbti create mode 100644 tkinter/pkg.generated.mbti create mode 100644 turtle/pkg.generated.mbti diff --git a/cpython/pkg.generated.mbti b/cpython/pkg.generated.mbti new file mode 100644 index 0000000..290c4b8 --- /dev/null +++ b/cpython/pkg.generated.mbti @@ -0,0 +1,633 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python/cpython" + +// Values +fn __py_callable_check(PyObjectRef) -> Int + +fn __py_dict_contains(PyObjectRef, PyObjectRef) -> Int + +fn _py_context_new_hamt_for_tests() -> PyObjectRef + +fn print_pyobject(PyObjectRef) -> Unit + +fn py_bool_check(PyObjectRef) -> Bool + +fn py_bool_from_long(Int64) -> PyObjectRef + +fn py_call_iter_new(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_callable_check(PyObjectRef) -> Bool + +fn py_cell_get(PyObjectRef) -> PyObjectRef + +fn py_cell_new(PyObjectRef) -> PyObjectRef + +fn py_cell_set(PyObjectRef, PyObjectRef) -> Int + +fn py_class_method_new(PyObjectRef) -> PyObjectRef + +fn py_code_addr2_line(PyCodeObjectRef, Int) -> Int + +fn py_code_new(Int, Int, Int, Int, Int, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, Int, PyObjectRef) -> PyCodeObjectRef + +fn py_code_new_empty(CStr, CStr, Int) -> PyCodeObjectRef + +fn py_code_new_with_pos_only_args(Int, Int, Int, Int, Int, Int, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, Int, PyObjectRef) -> PyCodeObjectRef + +fn py_codec_backslash_replace_errors(PyObjectRef) -> PyObjectRef + +fn py_codec_decode(PyObjectRef, CStr, CStr) -> PyObjectRef + +fn py_codec_decoder(CStr) -> PyObjectRef + +fn py_codec_encode(PyObjectRef, CStr, CStr) -> PyObjectRef + +fn py_codec_encoder(CStr) -> PyObjectRef + +fn py_codec_ignore_errors(PyObjectRef) -> PyObjectRef + +fn py_codec_incremental_decoder(CStr, CStr) -> PyObjectRef + +fn py_codec_incremental_encoder(CStr, CStr) -> PyObjectRef + +fn py_codec_known_encoding(CStr) -> Int + +fn py_codec_lookup_error(CStr) -> PyObjectRef + +fn py_codec_name_replace_errors(PyObjectRef) -> PyObjectRef + +fn py_codec_register(PyObjectRef) -> Int + +fn py_codec_register_error(CStr, PyObjectRef) -> Int + +fn py_codec_replace_errors(PyObjectRef) -> PyObjectRef + +fn py_codec_stream_reader(CStr, PyObjectRef, CStr) -> PyObjectRef + +fn py_codec_stream_writer(CStr, PyObjectRef, CStr) -> PyObjectRef + +fn py_codec_strict_errors(PyObjectRef) -> PyObjectRef + +fn py_codec_xml_char_ref_replace_errors(PyObjectRef) -> PyObjectRef + +fn py_complex_from_doubles(Double, Double) -> PyObjectRef + +fn py_complex_imag_as_double(PyObjectRef) -> Double + +fn py_complex_real_as_double(PyObjectRef) -> Double + +fn py_context_clear_free_list() -> Int + +fn py_context_copy(PyObjectRef) -> PyObjectRef + +fn py_context_copy_current() -> PyObjectRef + +fn py_context_enter(PyObjectRef) -> Int + +fn py_context_exit(PyObjectRef) -> Int + +fn py_context_new() -> PyObjectRef + +fn py_context_var_get(PyObjectRef, PyObjectRef, ArrayPyObjectRef) -> Int + +fn py_context_var_new(CStr, PyObjectRef) -> PyObjectRef + +fn py_context_var_reset(PyObjectRef, PyObjectRef) -> Int + +fn py_context_var_set(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_decref(PyObjectRef) -> Unit + +fn py_dict_check(PyObjectRef) -> Bool + +fn py_dict_clear(PyObjectRef) -> Unit + +fn py_dict_contains(PyObjectRef, PyObjectRef) -> Bool + +fn py_dict_copy(PyObjectRef) -> PyObjectRef + +fn py_dict_del_item(PyObjectRef, PyObjectRef) -> Int + +fn py_dict_del_item_string(PyObjectRef, String) -> Int + +fn py_dict_get_item(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_dict_get_item_string(PyObjectRef, String) -> PyObjectRef + +fn py_dict_items(PyObjectRef) -> PyObjectRef + +fn py_dict_keys(PyObjectRef) -> PyObjectRef + +fn py_dict_merge(PyObjectRef, PyObjectRef, Int) -> Int + +fn py_dict_merge_from_seq2(PyObjectRef, PyObjectRef, Int) -> Int + +fn py_dict_new() -> PyObjectRef + +fn py_dict_set_item(PyObjectRef, PyObjectRef, PyObjectRef) -> Int + +fn py_dict_set_item_string(PyObjectRef, String, PyObjectRef) -> Int + +fn py_dict_size(PyObjectRef) -> UInt64 + +fn py_dict_update(PyObjectRef, PyObjectRef) -> Int + +fn py_dict_values(PyObjectRef) -> PyObjectRef + +fn py_err_clear() -> Unit + +fn py_err_occurred() -> PyObjectRef + +fn py_err_print() -> Unit + +fn py_eval_acquire_thread(PyThreadStateRef) -> Unit + +fn py_eval_call_object_with_keywords(PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_eval_eval_code(PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_eval_get_builtins() -> PyObjectRef + +fn py_eval_get_func_desc(PyObjectRef) -> CStr + +fn py_eval_get_func_name(PyObjectRef) -> CStr + +fn py_eval_get_globals() -> PyObjectRef + +fn py_eval_get_locals() -> PyObjectRef + +fn py_eval_init_threads() -> Unit + +fn py_eval_release_thread(PyThreadStateRef) -> Unit + +fn py_eval_restore_thread(PyThreadStateRef) -> Unit + +fn py_eval_save_thread() -> PyThreadStateRef + +fn py_eval_threads_initialized() -> Int + +fn py_file_from_fd(Int, CStr, CStr, Int, CStr, CStr, CStr, Int) -> PyObjectRef + +fn py_file_get_line(PyObjectRef, Int) -> PyObjectRef + +fn py_file_new_std_printer(Int) -> PyObjectRef + +fn py_file_open_code(CStr) -> PyObjectRef + +fn py_file_open_code_object(PyObjectRef) -> PyObjectRef + +fn py_file_write_object(PyObjectRef, PyObjectRef, Int) -> Int + +fn py_file_write_string(CStr, PyObjectRef) -> Int + +fn py_finalize() -> Unit + +fn py_float_as_double(PyObjectRef) -> Double + +fn py_float_check(PyObjectRef) -> Bool + +fn py_float_from_double(Double) -> PyObjectRef + +fn py_float_from_string(PyObjectRef) -> PyObjectRef + +fn py_float_get_info() -> PyObjectRef + +fn py_float_get_max() -> Double + +fn py_float_get_min() -> Double + +fn py_frozen_set_new(PyObjectRef) -> PyObjectRef + +fn py_function_check(PyObjectRef) -> Bool + +fn py_function_get_annotations(PyObjectRef) -> PyObjectRef + +fn py_function_get_closure(PyObjectRef) -> PyObjectRef + +fn py_function_get_code(PyObjectRef) -> PyObjectRef + +fn py_function_get_defaults(PyObjectRef) -> PyObjectRef + +fn py_function_get_globals(PyObjectRef) -> PyObjectRef + +fn py_function_get_kw_defaults(PyObjectRef) -> PyObjectRef + +fn py_function_get_module(PyObjectRef) -> PyObjectRef + +fn py_function_new(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_function_new_with_qual_name(PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_function_set_annotations(PyObjectRef, PyObjectRef) -> Int + +fn py_function_set_closure(PyObjectRef, PyObjectRef) -> Int + +fn py_function_set_defaults(PyObjectRef, PyObjectRef) -> Int + +fn py_function_set_kw_defaults(PyObjectRef, PyObjectRef) -> Int + +fn py_get_recursion_limit() -> Int + +fn py_import_add_module(CStr) -> PyObjectRef + +fn py_import_add_module_object(PyObjectRef) -> PyObjectRef + +fn py_import_cleanup() -> Unit + +fn py_import_exec_code_module(CStr, PyObjectRef) -> PyObjectRef + +fn py_import_exec_code_module_ex(CStr, PyObjectRef, CStr) -> PyObjectRef + +fn py_import_exec_code_module_object(PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_import_exec_code_module_with_pathnames(CStr, PyObjectRef, CStr, CStr) -> PyObjectRef + +fn py_import_get_importer(PyObjectRef) -> PyObjectRef + +fn py_import_get_magic_number() -> Int + +fn py_import_get_magic_tag() -> CStr + +fn py_import_get_module(PyObjectRef) -> PyObjectRef + +fn py_import_get_module_dict() -> PyObjectRef + +fn py_import_import(PyObjectRef) -> PyObjectRef + +fn py_import_import_frozen_module(CStr) -> Int + +fn py_import_import_frozen_module_object(PyObjectRef) -> Int + +fn py_import_import_module(String) -> PyObjectRef + +fn py_import_import_module_level(CStr, PyObjectRef, PyObjectRef, PyObjectRef, Int) -> PyObjectRef + +fn py_import_import_module_level_object(PyObjectRef, PyObjectRef, PyObjectRef, PyObjectRef, Int) -> PyObjectRef + +fn py_import_import_module_no_block(CStr) -> PyObjectRef + +fn py_import_reload_module(PyObjectRef) -> PyObjectRef + +fn py_incref(PyObjectRef) -> Unit + +fn py_init() -> Unit + +fn py_instance_method_function(PyObjectRef) -> PyObjectRef + +fn py_instance_method_new(PyObjectRef) -> PyObjectRef + +fn py_int_check(PyObjectRef) -> Bool + +fn py_is_initialized() -> Bool + +fn py_list_append(PyObjectRef, PyObjectRef) -> Int + +fn py_list_as_tuple(PyObjectRef) -> PyObjectRef + +fn py_list_check(PyObjectRef) -> Bool + +fn py_list_get_item(PyObjectRef, Int64) -> PyObjectRef + +fn py_list_get_slice(PyObjectRef, Int64, Int64) -> PyObjectRef + +fn py_list_insert(PyObjectRef, Int64, PyObjectRef) -> Int + +fn py_list_new(Int64) -> PyObjectRef + +fn py_list_reverse(PyObjectRef) -> Int + +fn py_list_set_item(PyObjectRef, Int64, PyObjectRef) -> Int + +fn py_list_set_slice(PyObjectRef, Int64, Int64, PyObjectRef) -> Int + +fn py_list_size(PyObjectRef) -> Int64 + +fn py_list_sort(PyObjectRef) -> Int + +fn py_long_as_double(PyObjectRef) -> Double + +fn py_long_as_long(PyObjectRef) -> Int64 + +fn py_long_from_long(Int64) -> PyObjectRef + +fn py_make_pending_calls() -> Int + +fn py_method_clear_free_list() -> Int + +fn py_method_function(PyObjectRef) -> PyObjectRef + +fn py_method_new(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_method_self(PyObjectRef) -> PyObjectRef + +fn py_module_check(PyObjectRef) -> Bool + +fn py_module_get_dict(PyObjectRef) -> PyObjectRef + +fn py_module_get_filename_object(PyObjectRef) -> PyObjectRef + +fn py_module_get_name(PyObjectRef) -> CStr + +fn py_module_get_name_object(PyObjectRef) -> PyObjectRef + +fn py_module_new(CStr) -> PyObjectRef + +fn py_module_new_object(PyObjectRef) -> PyObjectRef + +fn py_none_check(PyObjectRef) -> Bool + +fn py_object_as_file_descriptor(PyObjectRef) -> Int + +fn py_object_ascii(PyObjectRef) -> PyObjectRef + +fn py_object_bytes(PyObjectRef) -> PyObjectRef + +fn py_object_call(PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_object_call_object(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_object_clear_weak_refs(PyObjectRef) -> Unit + +fn py_object_del_item(PyObjectRef, PyObjectRef) -> Int + +fn py_object_del_item_string(PyObjectRef, CStr) -> Int + +fn py_object_dir(PyObjectRef) -> PyObjectRef + +fn py_object_generic_get_attr(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_object_generic_set_attr(PyObjectRef, PyObjectRef, PyObjectRef) -> Int + +fn py_object_get_attr(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_object_get_attr_string(PyObjectRef, String) -> PyObjectRef + +fn py_object_get_item(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn py_object_get_iter(PyObjectRef) -> PyObjectRef + +fn py_object_has_attr(PyObjectRef, PyObjectRef) -> Int + +fn py_object_has_attr_string(PyObjectRef, String) -> Int + +fn py_object_is_instance(PyObjectRef, PyObjectRef) -> Int + +fn py_object_is_subclass(PyObjectRef, PyObjectRef) -> Int + +fn py_object_is_true(PyObjectRef) -> Bool + +fn py_object_moonbit_repr(PyObjectRef) -> String + +fn py_object_moonbit_str(PyObjectRef) -> String + +fn py_object_not(PyObjectRef) -> Int + +fn py_object_repr(PyObjectRef) -> PyObjectRef + +fn py_object_rich_compare(PyObjectRef, PyObjectRef, Int) -> PyObjectRef + +fn py_object_rich_compare_bool(PyObjectRef, PyObjectRef, Int) -> Int + +fn py_object_self_iter(PyObjectRef) -> PyObjectRef + +fn py_object_set_attr(PyObjectRef, PyObjectRef, PyObjectRef) -> Int + +fn py_object_set_attr_string(PyObjectRef, String, PyObjectRef) -> Int + +fn py_object_set_item(PyObjectRef, PyObjectRef, PyObjectRef) -> Int + +fn py_object_size(PyObjectRef) -> UInt64 + +fn py_object_str(PyObjectRef) -> PyObjectRef + +fn py_object_type(PyObjectRef) -> PyObjectRef + +fn py_odict_del_item(PyObjectRef, PyObjectRef) -> Int + +fn py_odict_new() -> PyObjectRef + +fn py_odict_set_item(PyObjectRef, PyObjectRef, PyObjectRef) -> Int + +fn py_repr_enter(PyObjectRef) -> Int + +fn py_repr_leave(PyObjectRef) -> Unit + +fn py_seq_iter_new(PyObjectRef) -> PyObjectRef + +fn py_set_add(PyObjectRef, PyObjectRef) -> Int + +fn py_set_check(PyObjectRef) -> Bool + +fn py_set_clear(PyObjectRef) -> Int + +fn py_set_contains(PyObjectRef, PyObjectRef) -> Int + +fn py_set_discard(PyObjectRef, PyObjectRef) -> Int + +fn py_set_new(PyObjectRef) -> PyObjectRef + +fn py_set_pop(PyObjectRef) -> PyObjectRef + +fn py_set_recursion_limit(Int) -> Unit + +fn py_set_size(PyObjectRef) -> Int64 + +fn py_static_method_new(PyObjectRef) -> PyObjectRef + +fn py_string_check(PyObjectRef) -> Bool + +fn py_tuple_check(PyObjectRef) -> Bool + +fn py_type(PyObjectRef) -> PyTypeObjectRef + +fn py_type_name(PyTypeObjectRef) -> String + +fn py_unicode_as_moonbit_string(PyObjectRef) -> String + +fn py_unicode_as_utf16_string(PyObjectRef) -> PyObjectRef + +fn py_unicode_as_utf8(PyObjectRef) -> String + +fn py_unicode_from_moonbit_string(String) -> PyObjectRef + +fn py_unicode_from_string(String) -> PyObjectRef + +fn py_unicode_from_string_and_size(CStr, UInt64) -> PyObjectRef + +fn py_unicode_from_unicode(CWStr, UInt64) -> PyObjectRef + +fn pyindex_check(PyObjectRef) -> Int + +fn pyiter_check(PyObjectRef) -> Int + +fn pyiter_next(PyObjectRef) -> PyObjectRef + +fn pymapping_check(PyObjectRef) -> Int + +fn pymapping_get_item_string(PyObjectRef, CStr) -> PyObjectRef + +fn pymapping_has_key(PyObjectRef, PyObjectRef) -> Int + +fn pymapping_has_key_string(PyObjectRef, CStr) -> Int + +fn pymapping_items(PyObjectRef) -> PyObjectRef + +fn pymapping_keys(PyObjectRef) -> PyObjectRef + +fn pymapping_set_item_string(PyObjectRef, CStr, PyObjectRef) -> Int + +fn pymapping_size(PyObjectRef) -> Int + +fn pymapping_values(PyObjectRef) -> PyObjectRef + +fn pynumber_absolute(PyObjectRef) -> PyObjectRef + +fn pynumber_add(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_and(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_as_ssize_t(PyObjectRef, PyObjectRef) -> Int + +fn pynumber_check(PyObjectRef) -> Int + +fn pynumber_divmod(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_float(PyObjectRef) -> PyObjectRef + +fn pynumber_floor_divide(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_index(PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_add(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_and(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_floor_divide(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_lshift(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_multiply(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_or(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_power(PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_remainder(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_rshift(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_subtract(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_true_divide(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_inplace_xor(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_invert(PyObjectRef) -> PyObjectRef + +fn pynumber_long(PyObjectRef) -> PyObjectRef + +fn pynumber_lshift(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_multiply(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_negative(PyObjectRef) -> PyObjectRef + +fn pynumber_or(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_positive(PyObjectRef) -> PyObjectRef + +fn pynumber_power(PyObjectRef, PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_remainder(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_rshift(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_subtract(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_to_base(PyObjectRef, Int) -> PyObjectRef + +fn pynumber_true_divide(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pynumber_xor(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pyobkect_format(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pysequence_check(PyObjectRef) -> Int + +fn pysequence_concat(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pysequence_contains(PyObjectRef, PyObjectRef) -> Int + +fn pysequence_count(PyObjectRef, PyObjectRef) -> Int + +fn pysequence_del_item(PyObjectRef, UInt64) -> Int + +fn pysequence_del_slice(PyObjectRef, UInt64, UInt64) -> Int + +fn pysequence_fast(PyObjectRef, CStr) -> PyObjectRef + +fn pysequence_get_item(PyObjectRef, UInt64) -> PyObjectRef + +fn pysequence_get_slice(PyObjectRef, UInt64, UInt64) -> PyObjectRef + +fn pysequence_index(PyObjectRef, PyObjectRef) -> Int + +fn pysequence_inplace_concat(PyObjectRef, PyObjectRef) -> PyObjectRef + +fn pysequence_inplace_repeat(PyObjectRef, Int) -> PyObjectRef + +fn pysequence_list(PyObjectRef) -> PyObjectRef + +fn pysequence_repeat(PyObjectRef, Int) -> PyObjectRef + +fn pysequence_set_item(PyObjectRef, UInt64, PyObjectRef) -> Int + +fn pysequence_set_slice(PyObjectRef, UInt64, UInt64, PyObjectRef) -> Int + +fn pysequence_size(PyObjectRef) -> Int + +fn pysequence_tuple(PyObjectRef) -> PyObjectRef + +fn pytuple_get_item(PyObjectRef, UInt64) -> PyObjectRef + +fn pytuple_get_slice(PyObjectRef, UInt64, UInt64) -> PyObjectRef + +fn pytuple_new(UInt64) -> PyObjectRef + +fn pytuple_set_item(PyObjectRef, UInt64, PyObjectRef) -> Int + +fn pytuple_size(PyObjectRef) -> UInt64 + +// Errors + +// Types and methods +type ArrayPyObjectRef + +type CStr + +type CWStr + +type PyCodeObjectRef + +type PyObjectRef +fn PyObjectRef::dump(Self) -> Unit +fn PyObjectRef::is_bool(Self) -> Bool +fn PyObjectRef::is_callable(Self) -> Bool +fn PyObjectRef::is_dict(Self) -> Bool +fn PyObjectRef::is_float(Self) -> Bool +fn PyObjectRef::is_function(Self) -> Bool +fn PyObjectRef::is_int(Self) -> Bool +fn PyObjectRef::is_list(Self) -> Bool +fn PyObjectRef::is_module(Self) -> Bool +fn PyObjectRef::is_null(Self) -> Bool +fn PyObjectRef::is_set(Self) -> Bool +fn PyObjectRef::is_string(Self) -> Bool + +type PyThreadStateRef + +type PyTypeObjectRef + +// Type aliases + +// Traits + diff --git a/main/pkg.generated.mbti b/main/pkg.generated.mbti new file mode 100644 index 0000000..56682a9 --- /dev/null +++ b/main/pkg.generated.mbti @@ -0,0 +1,13 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python/main" + +// Values + +// Errors + +// Types and methods + +// Type aliases + +// Traits + diff --git a/pkg.generated.mbti b/pkg.generated.mbti new file mode 100644 index 0000000..4b6b30c --- /dev/null +++ b/pkg.generated.mbti @@ -0,0 +1,214 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python" + +import( + "Kaida-Amethyst/python/cpython" +) + +// Values +fn init_py() -> Unit + +fn pyimport(String, print_err? : Bool) -> PyModule? + +fn strip_quot(String) -> String + +// Errors +pub suberror PyRuntimeError { + TypeMismatchError + IndexOutOfBoundsError + KeyIsUnHashableError + InVokeError +} +impl Show for PyRuntimeError + +// Types and methods +pub struct PyBool { + // private fields +} +fn PyBool::create(PyObject) -> Self raise PyRuntimeError +fn PyBool::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyBool::dump(Self) -> Unit +fn PyBool::from(Bool) -> Self +fn PyBool::is_false(Self) -> Bool +fn PyBool::is_true(Self) -> Bool +fn PyBool::not(Self) -> Self +fn PyBool::to_bool(Self) -> Bool +impl IsPyObject for PyBool +impl Show for PyBool + +pub struct PyCallable { + // private fields +} +fn PyCallable::create(PyObject) -> Self raise PyRuntimeError +fn PyCallable::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyCallable::dump(Self) -> Unit +fn PyCallable::invoke(Self, args? : PyTuple, kwargs? : PyDict, print_err? : Bool) -> PyObjectEnum? raise PyRuntimeError +impl IsPyObject for PyCallable +impl Show for PyCallable + +pub struct PyDict { + // private fields +} +fn PyDict::contains(Self, String) -> Bool +fn PyDict::containsObj(Self, PyObject) -> Bool +fn PyDict::create(PyObject) -> Self raise PyRuntimeError +fn PyDict::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyDict::drop(Self) -> Unit +fn PyDict::dump(Self) -> Unit +fn PyDict::get(Self, String) -> PyObjectEnum? +fn PyDict::getByObj(Self, PyObject) -> PyObjectEnum? +fn PyDict::items(Self) -> PyList +fn PyDict::keys(Self) -> PyList +fn PyDict::len(Self) -> Int +fn PyDict::new() -> Self +fn PyDict::op_get(Self, String) -> PyObjectEnum +fn[V : IsPyObject] PyDict::op_set(Self, String, V) -> Unit +fn[V : IsPyObject] PyDict::set(Self, String, V) -> Unit +fn[K : IsPyObject, V : IsPyObject] PyDict::setByObj(Self, K, V) -> Unit raise PyRuntimeError +fn PyDict::values(Self) -> PyList +impl IsPyObject for PyDict +impl Show for PyDict + +pub struct PyFloat { + // private fields +} +fn PyFloat::create(PyObject) -> Self raise PyRuntimeError +fn PyFloat::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyFloat::drop(Self) -> Unit +fn PyFloat::dump(Self) -> Unit +fn PyFloat::from(Double) -> Self +fn PyFloat::to_double(Self) -> Double +impl IsPyObject for PyFloat +impl Show for PyFloat + +pub struct PyInteger { + // private fields +} +fn PyInteger::create(PyObject) -> Self raise PyRuntimeError +fn PyInteger::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyInteger::create_unchecked(PyObject) -> Self +fn PyInteger::drop(Self) -> Unit +fn PyInteger::dump(Self) -> Unit +fn PyInteger::from(Int64) -> Self +fn PyInteger::to_double(Self) -> Double +fn PyInteger::to_int64(Self) -> Int64 +impl IsPyObject for PyInteger +impl Show for PyInteger + +pub struct PyList { + // private fields +} +fn[T : IsPyObject] PyList::append(Self, T) -> Unit +fn PyList::create(PyObject) -> Self raise PyRuntimeError +fn PyList::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyList::drop(Self) -> Unit +fn PyList::dump(Self) -> Unit +fn[T : IsPyObject] PyList::from(Array[T]) -> Self +fn PyList::get(Self, Int) -> PyObjectEnum? +fn PyList::len(Self) -> Int +fn PyList::new() -> Self +fn PyList::op_get(Self, Int) -> PyObjectEnum +fn[T : IsPyObject] PyList::op_set(Self, Int, T) -> Unit +fn[T : IsPyObject] PyList::set(Self, Int, T) -> Unit raise PyRuntimeError +impl IsPyObject for PyList +impl Show for PyList + +pub struct PyModule { + // private fields +} +fn PyModule::create(PyObject) -> Self raise PyRuntimeError +fn PyModule::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyModule::dump(Self) -> Unit +fn PyModule::get_attr(Self, String, print_err? : Bool) -> PyObjectEnum? +fn PyModule::get_name(Self) -> String +impl IsPyObject for PyModule +impl Show for PyModule + +pub struct PyObject { + // private fields +} +fn PyObject::create(@cpython.PyObjectRef) -> Self +fn PyObject::drop(Self) -> Unit +fn PyObject::dump(Self) -> Unit +fn PyObject::get_attr(Self, String, print_err? : Bool) -> PyObjectEnum? +fn PyObject::is_bool(Self) -> Bool +fn PyObject::is_callable(Self) -> Bool +fn PyObject::is_dict(Self) -> Bool +fn PyObject::is_float(Self) -> Bool +fn PyObject::is_int(Self) -> Bool +fn PyObject::is_list(Self) -> Bool +fn PyObject::is_module(Self) -> Bool +fn PyObject::is_null(Self) -> Bool +fn PyObject::is_string(Self) -> Bool +fn PyObject::is_tuple(Self) -> Bool +fn PyObject::type_name(Self) -> String +fn PyObject::type_of(Self) -> PyType +impl IsPyObject for PyObject +impl Show for PyObject + +pub(all) enum PyObjectEnum { + PyInteger(PyInteger) + PyFloat(PyFloat) + PyBool(PyBool) + PyString(PyString) + PyTuple(PyTuple) + PyList(PyList) + PyDict(PyDict) + PyModule(PyModule) + PyCallable(PyCallable) + PyClass(PyObject) +} +fn PyObjectEnum::create(PyObject) -> Self +fn PyObjectEnum::create_by_ref(@cpython.PyObjectRef) -> Self +fn PyObjectEnum::dump(Self) -> Unit +impl Show for PyObjectEnum + +pub struct PyString { + // private fields +} +fn PyString::create(PyObject) -> Self raise PyRuntimeError +fn PyString::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyString::drop(Self) -> Unit +fn PyString::dump(Self) -> Unit +fn PyString::from(String) -> Self +impl IsPyObject for PyString +impl Show for PyString + +pub struct PyTuple { + // private fields +} +fn PyTuple::create(PyObject) -> Self raise PyRuntimeError +fn PyTuple::create_by_ref(@cpython.PyObjectRef) -> Self raise PyRuntimeError +fn PyTuple::drop(Self) -> Unit +fn PyTuple::dump(Self) -> Unit +fn PyTuple::get(Self, Int) -> PyObjectEnum? +fn PyTuple::len(Self) -> UInt64 +fn PyTuple::new(UInt64) -> Self +fn PyTuple::op_get(Self, Int) -> PyObjectEnum +fn[T : IsPyObject] PyTuple::op_set(Self, Int, T) -> Unit +fn[T : IsPyObject] PyTuple::set(Self, Int, T) -> Unit +impl IsPyObject for PyTuple +impl Show for PyTuple + +pub enum PyType { + PyInteger + PyFloat + PyBool + PyString + PyTuple + PyList + PyDict + PyModule + PyCallable + PyClass +} + +// Type aliases + +// Traits +pub trait IsPyObject { + obj(Self) -> PyObject + obj_ref(Self) -> @cpython.PyObjectRef + type_name(Self) -> String +} + diff --git a/test/pkg.generated.mbti b/test/pkg.generated.mbti new file mode 100644 index 0000000..7d3e998 --- /dev/null +++ b/test/pkg.generated.mbti @@ -0,0 +1,13 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python/test" + +// Values + +// Errors + +// Types and methods + +// Type aliases + +// Traits + diff --git a/time/pkg.generated.mbti b/time/pkg.generated.mbti new file mode 100644 index 0000000..3655ba2 --- /dev/null +++ b/time/pkg.generated.mbti @@ -0,0 +1,39 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python/time" + +// Values +fn ctime(Double?) -> String + +fn monotonic() -> Double + +fn monotonic_ns() -> Int64 + +fn perf_counter() -> Double + +fn perf_counter_ns() -> Int64 + +fn process_time() -> Double + +fn process_time_ns() -> Int64 + +fn sleep(Double) -> Unit + +fn time() -> Double + +fn time_ns() -> Int64 + +// Errors +pub suberror TurtleError { + LoadTimeModuleError +} +impl Show for TurtleError + +// Types and methods +pub struct TimeModule { + // private fields +} + +// Type aliases + +// Traits + diff --git a/tkinter/pkg.generated.mbti b/tkinter/pkg.generated.mbti new file mode 100644 index 0000000..3ca13ff --- /dev/null +++ b/tkinter/pkg.generated.mbti @@ -0,0 +1,33 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python/tkinter" + +// Values + +// Errors +pub suberror TkinterError { + LoadTkinterError +} +impl Show for TkinterError + +// Types and methods +pub struct Label { + // private fields +} +fn Label::new(Window, String) -> Self +fn Label::pack(Self) -> Unit + +pub struct Tkinter { + // private fields +} + +pub struct Window { + // private fields +} +fn Window::mainloop(Self) -> Unit +fn Window::new() -> Self +fn Window::set_title(Self, String) -> Unit + +// Type aliases + +// Traits + diff --git a/turtle/pkg.generated.mbti b/turtle/pkg.generated.mbti new file mode 100644 index 0000000..c5211c4 --- /dev/null +++ b/turtle/pkg.generated.mbti @@ -0,0 +1,116 @@ +// Generated using `moon info`, DON'T EDIT IT +package "Kaida-Amethyst/python/turtle" + +import( + "Kaida-Amethyst/python" +) + +// Values +fn bgcolor(Color) -> Unit + +// Errors +pub suberror TurtleError { + LoadTurtleError +} +impl Show for TurtleError + +// Types and methods +pub(all) enum Color { + Red + Green + Blue + Purple + Orange + Yellow + Black + Silver + White + Gray + Brown + Cyan + Magenta + Lime + Pink + Teal + Indigo + Violet +} +fn Color::to_pystr(Self) -> @python.PyString +impl Show for Color + +pub struct Pen { + methods : Map[String, @python.PyCallable] + // private fields +} +fn Pen::backward(Self, Double) -> Unit +fn Pen::begin_fill(Self) -> Unit +fn Pen::circle(Self, Double, extent? : Double?, steps? : Int?) -> Unit +fn Pen::clear(Self) -> Unit +fn Pen::clearstamp(Self, Int) -> Unit +fn Pen::clearstamps(Self, n? : Int?) -> Unit +fn Pen::color(Self, Color) -> Unit +fn Pen::dot(Self, Double, Color) -> Unit +fn Pen::end_fill(Self) -> Unit +fn Pen::fillcolor(Self, Color) -> Unit +fn Pen::forward(Self, Double) -> Unit +fn Pen::goto(Self, Double, Double) -> Unit +fn Pen::heading(Self) -> Double +fn Pen::hide(Self) -> Unit +fn Pen::home(Self) -> Unit +fn Pen::isdown(Self) -> Bool +fn Pen::isvisible(Self) -> Bool +fn Pen::left(Self, Double) -> Unit +fn Pen::new() -> Self +fn Pen::pencolor(Self, Color) -> Unit +fn Pen::pendown(Self) -> Unit +fn Pen::pensize(Self, Double) -> Unit +fn Pen::penup(Self) -> Unit +fn Pen::position(Self) -> (Double, Double) +fn Pen::radians(Self) -> Double +fn Pen::reset(Self) -> Unit +fn Pen::right(Self, Double) -> Unit +fn Pen::shape(Self, Shape) -> Unit +fn Pen::shapesize(Self, stretch_width? : Double?, stretch_len? : Double?, outline? : Int?) -> Unit +fn Pen::show(Self) -> Unit +fn Pen::speed(Self, Speed) -> Unit +fn Pen::stamp(Self) -> Int +fn Pen::width(Self, Double) -> Unit +fn Pen::xcor(Self) -> Double +fn Pen::ycor(Self) -> Double + +pub struct Screen { + // private fields +} +fn Screen::bgcolor(Self, Color) -> Unit +fn Screen::new() -> Self +fn Screen::setup(Self, Double, Double) -> Unit +fn Screen::title(Self, String) -> Unit +fn Screen::tracer(Self, Int) -> Unit +fn Screen::update(Self) -> Unit + +pub(all) enum Shape { + Arrow + Turtle + Circle + Square + Triangle + Classic +} +impl Show for Shape + +pub(all) enum Speed { + Fastest + Fast + Normal + Slow + Slowest +} + +pub struct Turtle { + // private fields +} + +// Type aliases + +// Traits + From 7d8b64dc86ed8a7038e86c10fc88602e57f4b056 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:26:03 +0800 Subject: [PATCH 11/12] fix(utils): use encoding/utf8 to encode C strings --- cpython/utils.mbt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cpython/utils.mbt b/cpython/utils.mbt index da3f44e..8cdbedd 100644 --- a/cpython/utils.mbt +++ b/cpython/utils.mbt @@ -19,7 +19,5 @@ priv trait ToCStr { ///| impl ToCStr for String with to_cstr(self) { - let s = self.to_bytes().to_array().filter(fn(c) { c != 0 }) - s.push(0) - s |> @bytes.from_array + @encoding/utf8.encode(self) } From e1856f4f6f5c13f1c1d8614e574836a0a1324c29 Mon Sep 17 00:00:00 2001 From: Haoxiang Fei Date: Sat, 8 Nov 2025 14:34:00 +0800 Subject: [PATCH 12/12] try(ci): enable -fsanitize=address for debugging --- build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.js b/build.js index 4de9f85..3d9eead 100644 --- a/build.js +++ b/build.js @@ -27,7 +27,7 @@ try { const pyIncludeDir = path.join(pyPrefix, 'include', `python${pyVersion}`) // 4. Construct CC_FLAGS - const stubCCFlags = `-I${pyIncludeDir} -DNDEBUG` + const stubCCFlags = `-I${pyIncludeDir} -DNDEBUG -fsanitize=address -g` const ccFlags = stubCCFlags // 5. Get Python ldflags @@ -37,7 +37,7 @@ try { // 6. Construct CC_LINK_FLAGS // Sometimes ldflags already includes the -lpython part, remove it if present before adding ours const baseLdflags = pyLdflags.replace(/-lpython[\d.]+\w*/, '').trim() - const ccLinkFlags = `${baseLdflags} -lpython${pyVersion}` + const ccLinkFlags = `${baseLdflags} -lpython${pyVersion} -fsanitize=address -g` // 7. Construct C_INCLUDE_PATH const existingCIncludePath = process.env.C_INCLUDE_PATH || ''