mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Add Objective-C helper for creating subclasses
This commit is contained in:
@@ -40,3 +40,49 @@ Array_objectAs :: proc "c" (self: ^Array, index: UInteger, $T: typeid) -> T wher
|
||||
Array_count :: proc "c" (self: ^Array) -> UInteger {
|
||||
return msgSend(UInteger, self, "count")
|
||||
}
|
||||
|
||||
|
||||
@(objc_class="NSMutableArray")
|
||||
MutableArray :: struct {
|
||||
using _: Copying(MutableArray),
|
||||
}
|
||||
|
||||
@(objc_type=MutableArray, objc_name="alloc", objc_is_class_method=true)
|
||||
MutableArray_alloc :: proc "c" () -> ^MutableArray {
|
||||
return msgSend(^MutableArray, MutableArray, "alloc")
|
||||
}
|
||||
|
||||
@(objc_type=MutableArray, objc_name="init")
|
||||
MutableArray_init :: proc "c" (self: ^MutableArray) -> ^MutableArray {
|
||||
return msgSend(^MutableArray, self, "init")
|
||||
}
|
||||
|
||||
@(objc_type=MutableArray, objc_name="initWithObjects")
|
||||
MutableArray_initWithObjects :: proc "c" (self: ^MutableArray, objects: [^]^Object, count: UInteger) -> ^MutableArray {
|
||||
return msgSend(^MutableArray, self, "initWithObjects:count:", objects, count)
|
||||
}
|
||||
|
||||
@(objc_type=MutableArray, objc_name="initWithCoder")
|
||||
MutableArray_initWithCoder :: proc "c" (self: ^MutableArray, coder: ^Coder) -> ^MutableArray {
|
||||
return msgSend(^MutableArray, self, "initWithCoder:", coder)
|
||||
}
|
||||
|
||||
@(objc_type=MutableArray, objc_name="object")
|
||||
MutableArray_object :: proc "c" (self: ^MutableArray, index: UInteger) -> ^Object {
|
||||
return msgSend(^Object, self, "objectAtIndex:", index)
|
||||
}
|
||||
@(objc_type=MutableArray, objc_name="objectAs")
|
||||
MutableArray_objectAs :: proc "c" (self: ^MutableArray, index: UInteger, $T: typeid) -> T where intrinsics.type_is_pointer(T), intrinsics.type_is_subtype_of(T, ^Object) {
|
||||
return (T)(MutableArray_object(self, index))
|
||||
}
|
||||
|
||||
@(objc_type=MutableArray, objc_name="count")
|
||||
MutableArray_count :: proc "c" (self: ^MutableArray) -> UInteger {
|
||||
return msgSend(UInteger, self, "count")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=MutableArray, objc_name="exchangeObjectAtIndex")
|
||||
MutableArray_exchangeObjectAtIndex :: proc "c" (self: ^MutableArray, idx1, idx2: UInteger) {
|
||||
msgSend(nil, self, "exchangeObjectAtIndex:withObjectAtIndex:", idx1, idx2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user