Constructs a `ClassDecl` declaring a new root class with the given name. Returns `None` if the class couldn't be allocated. An implementation for `+initialize` must also be given; the runtime calls this method for all classes, so it must be defined on root classes. Note that implementing a root class is not a simple endeavor. For example, your class probably cannot be passed
(name: &str, intitialize_fn: extern fn(&Class, Sel))
| 149 | used by ARC, will not be present otherwise. |
| 150 | */ |
| 151 | pub fn root(name: &str, intitialize_fn: extern fn(&Class, Sel)) |
| 152 | -> Option<ClassDecl> { |
| 153 | let mut decl = ClassDecl::with_superclass(name, None); |
| 154 | if let Some(ref mut decl) = decl { |
| 155 | unsafe { |
| 156 | decl.add_class_method(sel!(initialize), intitialize_fn); |
| 157 | } |
| 158 | } |
| 159 | decl |
| 160 | } |
| 161 | |
| 162 | /// Adds a method with the given name and implementation to self. |
| 163 | /// Panics if the method wasn't sucessfully added |
nothing calls this directly
no test coverage detected