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

Function create

crates/stdlib/src/tkinter.rs:367–538  ·  view source on GitHub ↗
(args: TkAppConstructorArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

365
366 #[pyfunction]
367 fn create(args: TkAppConstructorArgs, vm: &VirtualMachine) -> PyResult<TkApp> {
368 unsafe {
369 let interp = tk_sys::Tcl_CreateInterp();
370 let want_objects = args.wantobjects != 0;
371 let threaded = !{
372 let part1 = String::from("tcl_platform");
373 let part2 = String::from("threaded");
374 let part1 = ffi::CString::new(part1).map_err(|e| e.into_pyexception(vm))?;
375 let part2 = ffi::CString::new(part2).map_err(|e| e.into_pyexception(vm))?;
376 let part1_ptr = part1.as_ptr();
377 let part2_ptr = part2.as_ptr();
378 tk_sys::Tcl_GetVar2Ex(
379 interp,
380 part1_ptr as _,
381 part2_ptr as _,
382 tk_sys::TCL_GLOBAL_ONLY as ffi::c_int,
383 )
384 }
385 .is_null();
386 let thread_id = tk_sys::Tcl_GetCurrentThread();
387 let dispatching = false;
388 let trace = None;
389 // TODO: Handle threaded build
390 let bool_str = String::from("oldBoolean");
391 let old_boolean_type = tk_sys::Tcl_GetObjType(bool_str.as_ptr() as _);
392 let (boolean_type, byte_array_type) = {
393 let true_str = String::from("true");
394 let mut value = *tk_sys::Tcl_NewStringObj(true_str.as_ptr() as _, -1);
395 let mut bool_value = 0;
396 tk_sys::Tcl_GetBooleanFromObj(interp, &mut value, &mut bool_value);
397 let boolean_type = value.typePtr;
398 tk_sys::Tcl_DecrRefCount(&mut value);
399
400 let mut value =
401 *tk_sys::Tcl_NewByteArrayObj(&bool_value as *const i32 as *const u8, 1);
402 let byte_array_type = value.typePtr;
403 tk_sys::Tcl_DecrRefCount(&mut value);
404 (boolean_type, byte_array_type)
405 };
406 let double_str = String::from("double");
407 let double_type = tk_sys::Tcl_GetObjType(double_str.as_ptr() as _);
408 let int_str = String::from("int");
409 let int_type = tk_sys::Tcl_GetObjType(int_str.as_ptr() as _);
410 let int_type = if int_type.is_null() {
411 let mut value = *tk_sys::Tcl_NewWideIntObj(0);
412 let res = value.typePtr;
413 tk_sys::Tcl_DecrRefCount(&mut value);
414 res
415 } else {
416 int_type
417 };
418 let wide_int_str = String::from("wideInt");
419 let wide_int_type = tk_sys::Tcl_GetObjType(wide_int_str.as_ptr() as _);
420 let bignum_str = String::from("bignum");
421 let bignum_type = tk_sys::Tcl_GetObjType(bignum_str.as_ptr() as _);
422 let list_str = String::from("list");
423 let list_type = tk_sys::Tcl_GetObjType(list_str.as_ptr() as _);
424 let string_str = String::from("string");

Callers 11

py_newMethod · 0.70
newMethod · 0.70
py_newMethod · 0.70
new_objectMethod · 0.50
test_read_homeFunction · 0.50
test_read_home_no_spacesFunction · 0.50
mainFunction · 0.50
create_builtinFunction · 0.50
CreateJunctionFunction · 0.50
create_moduleMethod · 0.50

Calls 11

newFunction · 0.85
_get_tcl_lib_pathFunction · 0.85
to_lowercaseMethod · 0.80
is_errMethod · 0.80
SomeClass · 0.50
into_pyexceptionMethod · 0.45
as_ptrMethod · 0.45
cloneMethod · 0.45
push_strMethod · 0.45
pushMethod · 0.45
unwrapMethod · 0.45

Tested by 3

test_read_homeFunction · 0.40
test_read_home_no_spacesFunction · 0.40