MCPcopy Create free account
hub / github.com/SSheldon/rust-objc / custom_subclass

Function custom_subclass

src/test_utils.rs:160–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

158}
159
160pub 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
185pub fn custom_subclass_object() -> CustomObject {
186 CustomObject::new(custom_subclass())

Callers 2

test_classFunction · 0.85
custom_subclass_objectFunction · 0.85

Calls 3

custom_classFunction · 0.85
add_methodMethod · 0.80
registerMethod · 0.45

Tested by

no test coverage detected