MCPcopy Index your code
hub / github.com/RustPython/RustPython / collation_callback

Method collation_callback

crates/stdlib/src/_sqlite3.rs:511–541  ·  view source on GitHub ↗
(
            data: *mut c_void,
            a_len: c_int,
            a_ptr: *const c_void,
            b_len: c_int,
            b_ptr: *const c_void,
        )

Source from the content-addressed store, hash-verified

509 }
510
511 unsafe extern "C" fn collation_callback(
512 data: *mut c_void,
513 a_len: c_int,
514 a_ptr: *const c_void,
515 b_len: c_int,
516 b_ptr: *const c_void,
517 ) -> c_int {
518 let (callable, vm) = unsafe { (*data.cast::<Self>()).retrieve() };
519
520 let f = || -> PyResult<c_int> {
521 let text1 = ptr_to_string(a_ptr.cast(), a_len, null_mut(), vm)?;
522 let text1 = vm.ctx.new_str(text1);
523 let text2 = ptr_to_string(b_ptr.cast(), b_len, null_mut(), vm)?;
524 let text2 = vm.ctx.new_str(text2);
525
526 let val = callable.call((text1, text2), vm)?;
527 let Some(val) = val.number().index(vm) else {
528 return Ok(0);
529 };
530
531 let val = match val?.as_bigint().sign() {
532 Sign::Plus => 1,
533 Sign::Minus => -1,
534 Sign::NoSign => 0,
535 };
536
537 Ok(val)
538 };
539
540 f().unwrap_or(0)
541 }
542
543 unsafe extern "C" fn value_callback(context: *mut sqlite3_context) {
544 let context = SqliteContext::from(context);

Callers

nothing calls this directly

Calls 9

ptr_to_stringFunction · 0.85
retrieveMethod · 0.80
numberMethod · 0.80
as_bigintMethod · 0.80
fFunction · 0.50
castMethod · 0.45
new_strMethod · 0.45
callMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected