@@ -459,6 +459,22 @@ impl PyContext {
459
459
)
460
460
}
461
461
462
+ pub fn new_frame ( & self , frame : Frame ) -> PyObjectRef {
463
+ PyObject :: new ( PyObjectKind :: Frame { frame : frame } , self . frame_type ( ) )
464
+ }
465
+
466
+ pub fn new_property ( & self , function : RustPyFunc ) -> PyObjectRef {
467
+ let fget = self . new_rustfunc ( function) ;
468
+ let py_obj = PyObject :: new (
469
+ PyObjectKind :: Instance {
470
+ dict : self . new_dict ( ) ,
471
+ } ,
472
+ self . property_type ( ) ,
473
+ ) ;
474
+ py_obj. set_attr ( "fget" , fget. clone ( ) ) ;
475
+ py_obj
476
+ }
477
+
462
478
pub fn new_function (
463
479
& self ,
464
480
code_obj : PyObjectRef ,
@@ -782,6 +798,9 @@ pub enum PyObjectKind {
782
798
Code {
783
799
code : bytecode:: CodeObject ,
784
800
} ,
801
+ Frame {
802
+ frame : Frame ,
803
+ } ,
785
804
Function {
786
805
code : PyObjectRef ,
787
806
scope : PyObjectRef ,
@@ -856,6 +875,7 @@ impl fmt::Debug for PyObjectKind {
856
875
} => write ! ( f, "class {:?}" , name) ,
857
876
& PyObjectKind :: Instance { dict : _ } => write ! ( f, "instance" ) ,
858
877
& PyObjectKind :: RustFunction { function : _ } => write ! ( f, "rust function" ) ,
878
+ & PyObjectKind :: Frame { .. } => write ! ( f, "frame" ) ,
859
879
}
860
880
}
861
881
}
@@ -913,6 +933,7 @@ impl PyObject {
913
933
PyObjectKind :: Code { code : _ } => format ! ( "<code>" ) ,
914
934
PyObjectKind :: Function { .. } => format ! ( "<func>" ) ,
915
935
PyObjectKind :: Generator { .. } => format ! ( "<generator>" ) ,
936
+ PyObjectKind :: Frame { .. } => format ! ( "<frame>" ) ,
916
937
PyObjectKind :: BoundMethod { .. } => format ! ( "<bound-method>" ) ,
917
938
PyObjectKind :: RustFunction { function : _ } => format ! ( "<rustfunc>" ) ,
918
939
PyObjectKind :: Module { ref name, dict : _ } => format ! ( "<module '{}'>" , name) ,
0 commit comments