Skip to content

Commit

Permalink
fix: make fmt
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <zongzhe1024@163.com>
  • Loading branch information
zong-zhe committed Jan 20, 2025
1 parent 8452692 commit 1d709c9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
10 changes: 8 additions & 2 deletions kclvm/runtime/src/context/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ pub unsafe extern "C-unwind" fn kclvm_scope_get(

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_context_set_debug_mode(p: *mut kclvm_context_t, v: kclvm_bool_t) {
pub unsafe extern "C-unwind" fn kclvm_context_set_debug_mode(
p: *mut kclvm_context_t,
v: kclvm_bool_t,
) {
let p = mut_ptr_as_ref(p);
p.cfg.debug_mode = v != 0;
}
Expand All @@ -237,7 +240,10 @@ pub unsafe extern "C-unwind" fn kclvm_context_set_strict_range_check(

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_context_set_disable_none(p: *mut kclvm_context_t, v: kclvm_bool_t) {
pub unsafe extern "C-unwind" fn kclvm_context_set_disable_none(
p: *mut kclvm_context_t,
v: kclvm_bool_t,
) {
let p = mut_ptr_as_ref(p);
p.plan_opts.disable_none = v != 0;
}
Expand Down
6 changes: 4 additions & 2 deletions kclvm/runtime/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ use crate::{
};

/// Variable setter function type. fn(ctx: &mut Context, scope: &mut ScopeEval, args: ValueRef, kwargs: ValueRef) -> ValueRef.
pub type SetterFuncType =
unsafe extern "C-unwind" fn(*mut kclvm_context_t, *mut kclvm_eval_scope_t) -> *const kclvm_value_ref_t;
pub type SetterFuncType = unsafe extern "C-unwind" fn(
*mut kclvm_context_t,
*mut kclvm_eval_scope_t,
) -> *const kclvm_value_ref_t;

/// LazyEvalScope represents a scope of sequentially independent calculations, where
/// the calculation of values is lazy and only recursively performed through
Expand Down
50 changes: 39 additions & 11 deletions kclvm/runtime/src/value/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ pub unsafe extern "C-unwind" fn kclvm_context_set_import_names(

#[no_mangle]
#[runtime_fn]
pub extern "C-unwind" fn kclvm_value_Undefined(ctx: *mut kclvm_context_t) -> *mut kclvm_value_ref_t {
pub extern "C-unwind" fn kclvm_value_Undefined(
ctx: *mut kclvm_context_t,
) -> *mut kclvm_value_ref_t {
let ctx = mut_ptr_as_ref(ctx);
new_mut_ptr(ctx, ValueRef::undefined())
}
Expand Down Expand Up @@ -517,7 +519,9 @@ pub unsafe extern "C-unwind" fn kclvm_value_to_str_value(

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_value_Str_ptr(p: *const kclvm_value_ref_t) -> *const kclvm_char_t {
pub unsafe extern "C-unwind" fn kclvm_value_Str_ptr(
p: *const kclvm_value_ref_t,
) -> *const kclvm_char_t {
let p = ptr_as_ref(p);
match &*p.rc.borrow() {
Value::str_value(ref v) => v.as_ptr() as *const c_char,
Expand All @@ -527,7 +531,9 @@ pub unsafe extern "C-unwind" fn kclvm_value_Str_ptr(p: *const kclvm_value_ref_t)

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_value_function_ptr(p: *const kclvm_value_ref_t) -> *const u64 {
pub unsafe extern "C-unwind" fn kclvm_value_function_ptr(
p: *const kclvm_value_ref_t,
) -> *const u64 {
let p = ptr_as_ref(p);
match &*p.rc.borrow() {
Value::func_value(ref v) => v.fn_ptr as *const u64,
Expand All @@ -537,7 +543,9 @@ pub unsafe extern "C-unwind" fn kclvm_value_function_ptr(p: *const kclvm_value_r

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_value_check_function_ptr(p: *const kclvm_value_ref_t) -> *const u64 {
pub unsafe extern "C-unwind" fn kclvm_value_check_function_ptr(
p: *const kclvm_value_ref_t,
) -> *const u64 {
let p = ptr_as_ref(p);
match &*p.rc.borrow() {
Value::func_value(ref v) => v.check_fn_ptr as *const u64,
Expand Down Expand Up @@ -663,7 +671,9 @@ pub unsafe extern "C-unwind" fn kclvm_value_delete(p: *mut kclvm_value_ref_t) {

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_value_iter(p: *const kclvm_value_ref_t) -> *mut kclvm_iterator_t {
pub unsafe extern "C-unwind" fn kclvm_value_iter(
p: *const kclvm_value_ref_t,
) -> *mut kclvm_iterator_t {
let p = ptr_as_ref(p);
let iter = ValueIterator::from_value(p);
Box::into_raw(Box::new(iter))
Expand Down Expand Up @@ -734,7 +744,10 @@ pub unsafe extern "C-unwind" fn kclvm_list_len(p: *const kclvm_value_ref_t) -> k

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_list_resize(p: *mut kclvm_value_ref_t, newsize: kclvm_size_t) {
pub unsafe extern "C-unwind" fn kclvm_list_resize(
p: *mut kclvm_value_ref_t,
newsize: kclvm_size_t,
) {
let p = mut_ptr_as_ref(p);
p.list_resize(newsize as usize);
}
Expand Down Expand Up @@ -863,7 +876,10 @@ pub unsafe extern "C-unwind" fn kclvm_list_pop_first(

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_list_append(p: *mut kclvm_value_ref_t, v: *const kclvm_value_ref_t) {
pub unsafe extern "C-unwind" fn kclvm_list_append(
p: *mut kclvm_value_ref_t,
v: *const kclvm_value_ref_t,
) {
let p = mut_ptr_as_ref(p);
let v = ptr_as_ref(v);
p.list_append(v);
Expand All @@ -885,14 +901,20 @@ pub unsafe extern "C-unwind" fn kclvm_list_append_int(p: *mut kclvm_value_ref_t,

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_list_append_float(p: *mut kclvm_value_ref_t, v: kclvm_float_t) {
pub unsafe extern "C-unwind" fn kclvm_list_append_float(
p: *mut kclvm_value_ref_t,
v: kclvm_float_t,
) {
let p = mut_ptr_as_ref(p);
p.list_append(&ValueRef::float(v));
}

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_list_append_str(p: *mut kclvm_value_ref_t, v: *const kclvm_char_t) {
pub unsafe extern "C-unwind" fn kclvm_list_append_str(
p: *mut kclvm_value_ref_t,
v: *const kclvm_char_t,
) {
let p = mut_ptr_as_ref(p);
p.list_append(&ValueRef::str(c2str(v)));
}
Expand Down Expand Up @@ -1283,14 +1305,20 @@ pub unsafe extern "C-unwind" fn kclvm_default_collection_insert_value(

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_dict_remove(p: *mut kclvm_value_ref_t, key: *const kclvm_char_t) {
pub unsafe extern "C-unwind" fn kclvm_dict_remove(
p: *mut kclvm_value_ref_t,
key: *const kclvm_char_t,
) {
let p = mut_ptr_as_ref(p);
p.dict_remove(c2str(key));
}

#[no_mangle]
#[runtime_fn]
pub unsafe extern "C-unwind" fn kclvm_dict_update(p: *mut kclvm_value_ref_t, v: *const kclvm_value_ref_t) {
pub unsafe extern "C-unwind" fn kclvm_dict_update(
p: *mut kclvm_value_ref_t,
v: *const kclvm_value_ref_t,
) {
let p = mut_ptr_as_ref(p);
let v = ptr_as_ref(v);
p.dict_update(v);
Expand Down
5 changes: 4 additions & 1 deletion kclvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ fn kclvm_cli_run_unsafe(

/// KCL CLI main function CAPI.
#[no_mangle]
pub unsafe extern "C-unwind" fn kclvm_cli_main(argc: c_int, argv: *const *const c_char) -> *mut ExitCode {
pub unsafe extern "C-unwind" fn kclvm_cli_main(
argc: c_int,
argv: *const *const c_char,
) -> *mut ExitCode {
let prev_hook = std::panic::take_hook();

// disable print panic info
Expand Down

0 comments on commit 1d709c9

Please sign in to comment.