()
| 158 | } |
| 159 | |
| 160 | pub fn custom_subclass() -> &'static Class { |
| 161 | static REGISTER_CUSTOM_SUBCLASS: Once = ONCE_INIT; |
| 162 | |
| 163 | REGISTER_CUSTOM_SUBCLASS.call_once(|| { |
| 164 | let superclass = custom_class(); |
| 165 | let mut decl = ClassDecl::new("CustomSubclassObject", superclass).unwrap(); |
| 166 | |
| 167 | extern fn custom_subclass_get_foo(this: &Object, _cmd: Sel) -> u32 { |
| 168 | let foo: u32 = unsafe { |
| 169 | msg_send![super(this, custom_class()), foo] |
| 170 | }; |
| 171 | foo + 2 |
| 172 | } |
| 173 | |
| 174 | unsafe { |
| 175 | let get_foo: extern fn(&Object, Sel) -> u32 = custom_subclass_get_foo; |
| 176 | decl.add_method(sel!(foo), get_foo); |
| 177 | } |
| 178 | |
| 179 | decl.register(); |
| 180 | }); |
| 181 | |
| 182 | class!(CustomSubclassObject) |
| 183 | } |
| 184 | |
| 185 | pub fn custom_subclass_object() -> CustomObject { |
| 186 | CustomObject::new(custom_subclass()) |
no test coverage detected