File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,33 @@ pub unsafe extern "C" fn PyType_IsSubtype(a: *const PyTypeObject, b: *const PyTy
6666 } )
6767}
6868
69+ #[ unsafe( no_mangle) ]
70+ pub unsafe extern "C" fn PyType_GetName ( ptr : * const PyTypeObject ) -> * mut PyObject {
71+ with_vm ( |vm| unsafe { & * ptr } . __name__ ( vm) )
72+ }
73+
74+ #[ unsafe( no_mangle) ]
75+ pub unsafe extern "C" fn PyType_GetQualName ( ptr : * const PyTypeObject ) -> * mut PyObject {
76+ with_vm ( |vm| unsafe { & * ptr } . __qualname__ ( vm) )
77+ }
78+
79+ #[ unsafe( no_mangle) ]
80+ pub unsafe extern "C" fn PyType_GetFullyQualifiedName ( ptr : * const PyTypeObject ) -> * mut PyObject {
81+ with_vm ( |vm| {
82+ let ty = unsafe { & * ptr } ;
83+ let qualname = ty. __qualname__ ( vm) . try_downcast :: < PyStr > ( vm) ?;
84+ let module = ty. __module__ ( vm) ;
85+
86+ if let Some ( module) = module. downcast_ref :: < PyStr > ( )
87+ && module. as_wtf8 ( ) != "builtins"
88+ {
89+ Ok ( vm. ctx . new_str ( format ! ( "{module}.{qualname}" ) ) )
90+ } else {
91+ Ok ( qualname)
92+ }
93+ } )
94+ }
95+
6996#[ unsafe( no_mangle) ]
7097pub extern "C" fn Py_GetConstantBorrowed ( constant_id : c_uint ) -> * mut PyObject {
7198 with_vm ( |vm| {
You can’t perform that action at this time.
0 commit comments