Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions bool.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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 }
Expand All @@ -19,7 +20,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,
Expand All @@ -38,7 +40,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
///
Expand All @@ -61,7 +64,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
///
Expand All @@ -82,7 +86,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
///
Expand All @@ -97,7 +102,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
///
Expand Down
12 changes: 7 additions & 5 deletions callable.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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 }
Expand All @@ -19,7 +20,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,
Expand Down Expand Up @@ -49,9 +51,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())
Expand Down
Loading
Loading