mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-07 19:14:19 +00:00
Use objc_allocateClassPair for intrinsics.objc_register_class
This commit is contained in:
@@ -12,6 +12,7 @@ objc_SEL :: ^intrinsics.objc_selector
|
||||
foreign Foundation {
|
||||
objc_lookUpClass :: proc "c" (name: cstring) -> objc_Class ---
|
||||
sel_registerName :: proc "c" (name: cstring) -> objc_SEL ---
|
||||
objc_allocateClassPair :: proc "c" (superclass: objc_Class, name: cstring, extraBytes: uint) ---
|
||||
|
||||
objc_msgSend :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) ---
|
||||
objc_msgSend_fpret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> f64 ---
|
||||
|
||||
@@ -225,6 +225,7 @@ void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_type, Slice<T
|
||||
|
||||
add_package_dependency(c, "runtime", "objc_lookUpClass");
|
||||
add_package_dependency(c, "runtime", "sel_registerName");
|
||||
add_package_dependency(c, "runtime", "objc_allocateClassPair");
|
||||
|
||||
add_package_dependency(c, "runtime", "objc_msgSend");
|
||||
add_package_dependency(c, "runtime", "objc_msgSend_fpret");
|
||||
|
||||
@@ -1908,9 +1908,11 @@ lbValue lb_handle_objc_register_class(lbProcedure *p, Ast *expr) {
|
||||
String name = tav.value.value_string;
|
||||
lbAddr dst = lb_handle_objc_find_or_register_class(p, name);
|
||||
|
||||
auto args = array_make<lbValue>(permanent_allocator(), 1);
|
||||
args[0] = lb_const_value(m, t_cstring, exact_value_string(name));
|
||||
lbValue ptr = lb_emit_runtime_call(p, "objc_lookUpClass", args);
|
||||
auto args = array_make<lbValue>(permanent_allocator(), 3);
|
||||
args[0] = lb_const_nil(m, t_objc_Class);
|
||||
args[1] = lb_const_nil(m, t_objc_Class);
|
||||
args[2] = lb_const_int(m, t_uint, 0);
|
||||
lbValue ptr = lb_emit_runtime_call(p, "objc_allocateClassPair", args);
|
||||
lb_addr_store(p, dst, ptr);
|
||||
|
||||
return lb_addr_load(p, dst);
|
||||
|
||||
Reference in New Issue
Block a user