NSNumber.odin 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package objc_Foundation
  2. import "core:c"
  3. _ :: c
  4. when ODIN_OS == .Darwin {
  5. #assert(size_of(c.long) == size_of(int))
  6. #assert(size_of(c.ulong) == size_of(uint))
  7. }
  8. @(objc_class="NSValue")
  9. Value :: struct{using _: Copying(Value)}
  10. @(objc_type=Value, objc_name="alloc", objc_is_class_method=true)
  11. Value_alloc :: proc "c" () -> ^Value {
  12. return msgSend(^Value, Value, "alloc")
  13. }
  14. @(objc_type=Value, objc_name="init")
  15. Value_init :: proc "c" (self: ^Value) -> ^Value {
  16. return msgSend(^Value, self, "init")
  17. }
  18. @(objc_type=Value, objc_name="valueWithBytes", objc_is_class_method=true)
  19. Value_valueWithBytes :: proc "c" (value: rawptr, type: cstring) -> ^Value {
  20. return msgSend(^Value, Value, "valueWithBytes:objCType:", value, type)
  21. }
  22. @(objc_type=Value, objc_name="valueWithPointer", objc_is_class_method=true)
  23. Value_valueWithPointer :: proc "c" (pointer: rawptr) -> ^Value {
  24. return msgSend(^Value, Value, "valueWithPointer:", pointer)
  25. }
  26. @(objc_type=Value, objc_name="initWithBytes")
  27. Value_initWithBytes :: proc "c" (self: ^Value, value: rawptr, type: cstring) -> ^Value {
  28. return msgSend(^Value, self, "initWithBytes:objCType:", value, type)
  29. }
  30. @(objc_type=Value, objc_name="initWithCoder")
  31. Value_initWithCoder :: proc "c" (self: ^Value, coder: ^Coder) -> ^Value {
  32. return msgSend(^Value, self, "initWithCoder:", coder)
  33. }
  34. @(objc_type=Value, objc_name="getValue")
  35. Value_getValue :: proc "c" (self: ^Value, value: rawptr, size: UInteger) {
  36. msgSend(nil, self, "getValue:size:", value, size)
  37. }
  38. @(objc_type=Value, objc_name="objCType")
  39. Value_objCType :: proc "c" (self: ^Value) -> cstring {
  40. return msgSend(cstring, self, "objCType")
  41. }
  42. @(objc_type=Value, objc_name="isEqualToValue")
  43. Value_isEqualToValue :: proc "c" (self, other: ^Value) -> BOOL {
  44. return msgSend(BOOL, self, "isEqualToValue:", other)
  45. }
  46. @(objc_type=Value, objc_name="pointerValue")
  47. Value_pointerValue :: proc "c" (self: ^Value) -> rawptr {
  48. return msgSend(rawptr, self, "pointerValue")
  49. }
  50. @(objc_class="NSNumber")
  51. Number :: struct{using _: Copying(Number), using _: Value}
  52. @(objc_type=Number, objc_name="alloc", objc_is_class_method=true)
  53. Number_alloc :: proc "c" () -> ^Number {
  54. return msgSend(^Number, Number, "alloc")
  55. }
  56. @(objc_type=Number, objc_name="init")
  57. Number_init :: proc "c" (self: ^Number) -> ^Number {
  58. return msgSend(^Number, self, "init")
  59. }
  60. @(objc_type=Number, objc_name="numberWithI8", objc_is_class_method=true) Number_numberWithI8 :: proc "c" (value: i8) -> ^Number { return msgSend(^Number, Number, "numberWithChar:", value) }
  61. @(objc_type=Number, objc_name="numberWithU8", objc_is_class_method=true) Number_numberWithU8 :: proc "c" (value: u8) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedChar:", value) }
  62. @(objc_type=Number, objc_name="numberWithI16", objc_is_class_method=true) Number_numberWithI16 :: proc "c" (value: i16) -> ^Number { return msgSend(^Number, Number, "numberWithShort:", value) }
  63. @(objc_type=Number, objc_name="numberWithU16", objc_is_class_method=true) Number_numberWithU16 :: proc "c" (value: u16) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedShort:", value) }
  64. @(objc_type=Number, objc_name="numberWithI32", objc_is_class_method=true) Number_numberWithI32 :: proc "c" (value: i32) -> ^Number { return msgSend(^Number, Number, "numberWithInt:", value) }
  65. @(objc_type=Number, objc_name="numberWithU32", objc_is_class_method=true) Number_numberWithU32 :: proc "c" (value: u32) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedInt:", value) }
  66. @(objc_type=Number, objc_name="numberWithInt", objc_is_class_method=true) Number_numberWithInt :: proc "c" (value: int) -> ^Number { return msgSend(^Number, Number, "numberWithLong:", value) }
  67. @(objc_type=Number, objc_name="numberWithUint", objc_is_class_method=true) Number_numberWithUint :: proc "c" (value: uint) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedLong:", value) }
  68. @(objc_type=Number, objc_name="numberWithU64", objc_is_class_method=true) Number_numberWithU64 :: proc "c" (value: u64) -> ^Number { return msgSend(^Number, Number, "numberWithLongLong:", value) }
  69. @(objc_type=Number, objc_name="numberWithI64", objc_is_class_method=true) Number_numberWithI64 :: proc "c" (value: i64) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedLongLong:", value) }
  70. @(objc_type=Number, objc_name="numberWithF32", objc_is_class_method=true) Number_numberWithF32 :: proc "c" (value: f32) -> ^Number { return msgSend(^Number, Number, "numberWithFloat:", value) }
  71. @(objc_type=Number, objc_name="numberWithF64", objc_is_class_method=true) Number_numberWithF64 :: proc "c" (value: f64) -> ^Number { return msgSend(^Number, Number, "numberWithDouble:", value) }
  72. @(objc_type=Number, objc_name="numberWithBool", objc_is_class_method=true) Number_numberWithBool :: proc "c" (value: BOOL) -> ^Number { return msgSend(^Number, Number, "numberWithBool:", value) }
  73. @(objc_type=Number, objc_name="number", objc_is_class_method=true)
  74. Number_number :: proc{
  75. Number_numberWithI8,
  76. Number_numberWithU8,
  77. Number_numberWithI16,
  78. Number_numberWithU16,
  79. Number_numberWithI32,
  80. Number_numberWithU32,
  81. Number_numberWithInt,
  82. Number_numberWithUint,
  83. Number_numberWithU64,
  84. Number_numberWithI64,
  85. Number_numberWithF32,
  86. Number_numberWithF64,
  87. Number_numberWithBool,
  88. }
  89. @(objc_type=Number, objc_name="initWithI8") Number_initWithI8 :: proc "c" (self: ^Number, value: i8) -> ^Number { return msgSend(^Number, self, "initWithChar:", value) }
  90. @(objc_type=Number, objc_name="initWithU8") Number_initWithU8 :: proc "c" (self: ^Number, value: u8) -> ^Number { return msgSend(^Number, self, "initWithUnsignedChar:", value) }
  91. @(objc_type=Number, objc_name="initWithI16") Number_initWithI16 :: proc "c" (self: ^Number, value: i16) -> ^Number { return msgSend(^Number, self, "initWithShort:", value) }
  92. @(objc_type=Number, objc_name="initWithU16") Number_initWithU16 :: proc "c" (self: ^Number, value: u16) -> ^Number { return msgSend(^Number, self, "initWithUnsignedShort:", value) }
  93. @(objc_type=Number, objc_name="initWithI32") Number_initWithI32 :: proc "c" (self: ^Number, value: i32) -> ^Number { return msgSend(^Number, self, "initWithInt:", value) }
  94. @(objc_type=Number, objc_name="initWithU32") Number_initWithU32 :: proc "c" (self: ^Number, value: u32) -> ^Number { return msgSend(^Number, self, "initWithUnsignedInt:", value) }
  95. @(objc_type=Number, objc_name="initWithInt") Number_initWithInt :: proc "c" (self: ^Number, value: int) -> ^Number { return msgSend(^Number, self, "initWithLong:", value) }
  96. @(objc_type=Number, objc_name="initWithUint") Number_initWithUint :: proc "c" (self: ^Number, value: uint) -> ^Number { return msgSend(^Number, self, "initWithUnsignedLong:", value) }
  97. @(objc_type=Number, objc_name="initWithU64") Number_initWithU64 :: proc "c" (self: ^Number, value: u64) -> ^Number { return msgSend(^Number, self, "initWithLongLong:", value) }
  98. @(objc_type=Number, objc_name="initWithI64") Number_initWithI64 :: proc "c" (self: ^Number, value: i64) -> ^Number { return msgSend(^Number, self, "initWithUnsignedLongLong:", value) }
  99. @(objc_type=Number, objc_name="initWithF32") Number_initWithF32 :: proc "c" (self: ^Number, value: f32) -> ^Number { return msgSend(^Number, self, "initWithFloat:", value) }
  100. @(objc_type=Number, objc_name="initWithF64") Number_initWithF64 :: proc "c" (self: ^Number, value: f64) -> ^Number { return msgSend(^Number, self, "initWithDouble:", value) }
  101. @(objc_type=Number, objc_name="initWithBool") Number_initWithBool :: proc "c" (self: ^Number, value: BOOL) -> ^Number { return msgSend(^Number, self, "initWithBool:", value) }
  102. @(objc_type=Number, objc_name="i8Value") Number_i8Value :: proc "c" (self: ^Number) -> i8 { return msgSend(i8, self, "charValue") }
  103. @(objc_type=Number, objc_name="u8Value") Number_u8Value :: proc "c" (self: ^Number) -> u8 { return msgSend(u8, self, "unsignedCharValue") }
  104. @(objc_type=Number, objc_name="i16Value") Number_i16Value :: proc "c" (self: ^Number) -> i16 { return msgSend(i16, self, "shortValue") }
  105. @(objc_type=Number, objc_name="u16Value") Number_u16Value :: proc "c" (self: ^Number) -> u16 { return msgSend(u16, self, "unsignedShortValue") }
  106. @(objc_type=Number, objc_name="i32Value") Number_i32Value :: proc "c" (self: ^Number) -> i32 { return msgSend(i32, self, "intValue") }
  107. @(objc_type=Number, objc_name="u32Value") Number_u32Value :: proc "c" (self: ^Number) -> u32 { return msgSend(u32, self, "unsignedIntValue") }
  108. @(objc_type=Number, objc_name="intValue") Number_intValue :: proc "c" (self: ^Number) -> int { return msgSend(int, self, "longValue") }
  109. @(objc_type=Number, objc_name="uintValue") Number_uintValue :: proc "c" (self: ^Number) -> uint { return msgSend(uint, self, "unsignedLongValue") }
  110. @(objc_type=Number, objc_name="u64Value") Number_u64Value :: proc "c" (self: ^Number) -> u64 { return msgSend(u64, self, "longLongValue") }
  111. @(objc_type=Number, objc_name="i64Value") Number_i64Value :: proc "c" (self: ^Number) -> i64 { return msgSend(i64, self, "unsignedLongLongValue") }
  112. @(objc_type=Number, objc_name="f32Value") Number_f32Value :: proc "c" (self: ^Number) -> f32 { return msgSend(f32, self, "floatValue") }
  113. @(objc_type=Number, objc_name="f64Value") Number_f64Value :: proc "c" (self: ^Number) -> f64 { return msgSend(f64, self, "doubleValue") }
  114. @(objc_type=Number, objc_name="boolValue") Number_boolValue :: proc "c" (self: ^Number) -> BOOL { return msgSend(BOOL, self, "boolValue") }
  115. @(objc_type=Number, objc_name="integerValue") Number_integerValue :: proc "c" (self: ^Number) -> Integer { return msgSend(Integer, self, "integerValue") }
  116. @(objc_type=Number, objc_name="uintegerValue") Number_uintegerValue :: proc "c" (self: ^Number) -> UInteger { return msgSend(UInteger, self, "unsignedIntegerValue") }
  117. @(objc_type=Number, objc_name="stringValue") Number_stringValue :: proc "c" (self: ^Number) -> ^String { return msgSend(^String, self, "stringValue") }
  118. @(objc_type=Number, objc_name="compare")
  119. Number_compare :: proc "c" (self, other: ^Number) -> ComparisonResult {
  120. return msgSend(ComparisonResult, self, "compare:", other)
  121. }
  122. @(objc_type=Number, objc_name="isEqualToNumber")
  123. Number_isEqualToNumber :: proc "c" (self, other: ^Number) -> BOOL {
  124. return msgSend(BOOL, self, "isEqualToNumber:", other)
  125. }
  126. @(objc_type=Number, objc_name="descriptionWithLocale")
  127. Number_descriptionWithLocale :: proc "c" (self: ^Number, locale: ^Object) -> ^String {
  128. return msgSend(^String, self, "descriptionWithLocale:", locale)
  129. }