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

Method new_heap

crates/vm/src/builtins/type.rs:527–553  ·  view source on GitHub ↗
(
        name: &str,
        bases: Vec<PyRef<Self>>,
        attrs: PyAttributes,
        mut slots: PyTypeSlots,
        metaclass: PyRef<Self>,
        ctx: &Context,
    )

Source from the content-addressed store, hash-verified

525 )
526 }
527 pub fn new_heap(
528 name: &str,
529 bases: Vec<PyRef<Self>>,
530 attrs: PyAttributes,
531 mut slots: PyTypeSlots,
532 metaclass: PyRef<Self>,
533 ctx: &Context,
534 ) -> Result<PyRef<Self>, String> {
535 // TODO: ensure clean slot name
536 // assert_eq!(slots.name.borrow(), "");
537
538 // Set HEAPTYPE flag for heap-allocated types
539 slots.flags |= PyTypeFlags::HEAPTYPE;
540
541 let name_utf8 = ctx.new_utf8_str(name);
542 let name = name_utf8.clone().into_wtf8();
543 let heaptype_ext = HeapTypeExt {
544 name: PyRwLock::new(name_utf8),
545 qualname: PyRwLock::new(name),
546 slots: None,
547 type_data: PyRwLock::new(None),
548 specialization_cache: TypeSpecializationCache::new(),
549 };
550 let base = bases[0].clone();
551
552 Self::new_heap_inner(base, bases, attrs, slots, heaptype_ext, metaclass, ctx)
553 }
554
555 /// Equivalent to CPython's PyType_Check macro
556 /// Checks if obj is an instance of type (or its subclass)

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
new_utf8_strMethod · 0.80
into_wtf8Method · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected