@@ -44,6 +44,62 @@ fn object_ne(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
44
44
objbool:: not ( vm, & eq)
45
45
}
46
46
47
+ fn object_lt ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
48
+ arg_check ! (
49
+ vm,
50
+ args,
51
+ required = [ ( i, Some ( vm. ctx. object( ) ) ) , ( i2, None ) ]
52
+ ) ;
53
+
54
+ Err ( vm. new_type_error ( format ! (
55
+ "'<' not supported between instances of {} and {}" ,
56
+ i. borrow( ) ,
57
+ i2. borrow( )
58
+ ) ) )
59
+ }
60
+
61
+ fn object_le ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
62
+ arg_check ! (
63
+ vm,
64
+ args,
65
+ required = [ ( i, Some ( vm. ctx. object( ) ) ) , ( i2, None ) ]
66
+ ) ;
67
+
68
+ Err ( vm. new_type_error ( format ! (
69
+ "'<=' not supported between instances of {} and {}" ,
70
+ i. borrow( ) ,
71
+ i2. borrow( )
72
+ ) ) )
73
+ }
74
+
75
+ fn object_gt ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
76
+ arg_check ! (
77
+ vm,
78
+ args,
79
+ required = [ ( i, Some ( vm. ctx. object( ) ) ) , ( i2, None ) ]
80
+ ) ;
81
+
82
+ Err ( vm. new_type_error ( format ! (
83
+ "'>' not supported between instances of {} and {}" ,
84
+ i. borrow( ) ,
85
+ i2. borrow( )
86
+ ) ) )
87
+ }
88
+
89
+ fn object_ge ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
90
+ arg_check ! (
91
+ vm,
92
+ args,
93
+ required = [ ( i, Some ( vm. ctx. object( ) ) ) , ( i2, None ) ]
94
+ ) ;
95
+
96
+ Err ( vm. new_type_error ( format ! (
97
+ "'>=' not supported between instances of {} and {}" ,
98
+ i. borrow( ) ,
99
+ i2. borrow( )
100
+ ) ) )
101
+ }
102
+
47
103
fn object_hash ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
48
104
arg_check ! ( vm, args, required = [ ( _zelf, Some ( vm. ctx. object( ) ) ) ] ) ;
49
105
@@ -92,6 +148,10 @@ pub fn init(context: &PyContext) {
92
148
context. set_attr ( & object, "__init__" , context. new_rustfunc ( object_init) ) ;
93
149
context. set_attr ( & object, "__eq__" , context. new_rustfunc ( object_eq) ) ;
94
150
context. set_attr ( & object, "__ne__" , context. new_rustfunc ( object_ne) ) ;
151
+ context. set_attr ( & object, "__lt__" , context. new_rustfunc ( object_lt) ) ;
152
+ context. set_attr ( & object, "__le__" , context. new_rustfunc ( object_le) ) ;
153
+ context. set_attr ( & object, "__gt__" , context. new_rustfunc ( object_gt) ) ;
154
+ context. set_attr ( & object, "__ge__" , context. new_rustfunc ( object_ge) ) ;
95
155
context. set_attr ( & object, "__delattr__" , context. new_rustfunc ( object_delattr) ) ;
96
156
context. set_attr (
97
157
& object,
0 commit comments