(
name: &str,
bases: Vec<PyRef<Self>>,
attrs: PyAttributes,
mut slots: PyTypeSlots,
metaclass: PyRef<Self>,
ctx: &Context,
)
| 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) |
nothing calls this directly
no test coverage detected