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

Method create_function

crates/stdlib/src/_sqlite3.rs:1220–1253  ·  view source on GitHub ↗
(&self, args: CreateFunctionArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1218
1219 #[pymethod]
1220 fn create_function(&self, args: CreateFunctionArgs, vm: &VirtualMachine) -> PyResult<()> {
1221 let name = args.name.to_cstring(vm)?;
1222 let flags = if args.deterministic {
1223 SQLITE_UTF8 | SQLITE_DETERMINISTIC
1224 } else {
1225 SQLITE_UTF8
1226 };
1227 let db = self.db_lock(vm)?;
1228 let Some(data) = CallbackData::new(args.func, vm) else {
1229 return db.create_function(
1230 name.as_ptr(),
1231 args.narg,
1232 flags,
1233 null_mut(),
1234 None,
1235 None,
1236 None,
1237 None,
1238 vm,
1239 );
1240 };
1241
1242 db.create_function(
1243 name.as_ptr(),
1244 args.narg,
1245 flags,
1246 Box::into_raw(Box::new(data)).cast(),
1247 Some(CallbackData::func_callback),
1248 None,
1249 None,
1250 Some(CallbackData::destructor),
1251 vm,
1252 )
1253 }
1254
1255 #[pymethod]
1256 fn create_aggregate(&self, args: CreateAggregateArgs, 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