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

Method create_window_function

crates/stdlib/src/_sqlite3.rs:1332–1375  ·  view source on GitHub ↗
(
            &self,
            name: PyStrRef,
            narg: c_int,
            aggregate_class: PyObjectRef,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1330
1331 #[pymethod]
1332 fn create_window_function(
1333 &self,
1334 name: PyStrRef,
1335 narg: c_int,
1336 aggregate_class: PyObjectRef,
1337 vm: &VirtualMachine,
1338 ) -> PyResult<()> {
1339 let name = name.to_cstring(vm)?;
1340 let db = self.db_lock(vm)?;
1341 let Some(data) = CallbackData::new(aggregate_class, vm) else {
1342 unsafe {
1343 sqlite3_create_window_function(
1344 db.db,
1345 name.as_ptr(),
1346 narg,
1347 SQLITE_UTF8,
1348 null_mut(),
1349 None,
1350 None,
1351 None,
1352 None,
1353 None,
1354 )
1355 };
1356 return Ok(());
1357 };
1358
1359 let ret = unsafe {
1360 sqlite3_create_window_function(
1361 db.db,
1362 name.as_ptr(),
1363 narg,
1364 SQLITE_UTF8,
1365 Box::into_raw(Box::new(data)).cast(),
1366 Some(CallbackData::step_callback),
1367 Some(CallbackData::finalize_callback),
1368 Some(CallbackData::value_callback),
1369 Some(CallbackData::inverse_callback),
1370 Some(CallbackData::destructor),
1371 )
1372 };
1373 db.check(ret, vm)
1374 .map_err(|_| new_programming_error(vm, "Error creating window function".to_owned()))
1375 }
1376
1377 #[pymethod]
1378 fn set_authorizer(&self, callable: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {

Calls 8

newFunction · 0.85
db_lockMethod · 0.80
SomeClass · 0.50
to_cstringMethod · 0.45
as_ptrMethod · 0.45
castMethod · 0.45
checkMethod · 0.45
to_ownedMethod · 0.45