You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@compileError("Can only perform checked cast into a PyDust class type");
48
+
}
49
+
50
+
// TODO(ngates): to perform fast type checking, we need to store our PyType on the parent module.
51
+
// See how the Python JSON module did this: https://github.com/python/cpython/commit/33f15a16d40cb8010a8c758952cbf88d7912ee2d#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39edR1814
52
+
// For now, we perform a slow import/isinstance check by using the `as` conversion.
53
+
returnas(T, obj);
54
+
}
55
+
56
+
/// Python -> Pydust. Perform an unchecked cast from a PyObject to a given PyDust class type.
57
+
pubinlinefnunchecked(comptimeT: type, obj: py.PyObject) T {
58
+
constDefinition=@typeInfo(T).Pointer.child;
59
+
constdefinition=State.getDefinition(Definition);
60
+
if (definition.type!=.class) {
61
+
@compileError("Can only perform unchecked cast into a PyDust class type. Found "++@typeName(Definition));
0 commit comments