File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,6 +307,8 @@ class MCScriptForeignInvocation
307307 else
308308 t_objc_msgSend = (void (*)())objc_msgSend;
309309#elif defined(__X86_64__)
310+ /* TODO: Investigate structs containing long doubles
311+ * as they will not work at the moment */
310312 if (t_cif->rtype ->type == FFI_TYPE_STRUCT &&
311313 t_rsize > 16 )
312314 t_objc_msgSend = (void (*)())objc_msgSend_stret;
Original file line number Diff line number Diff line change @@ -148,4 +148,36 @@ public handler TestReturnNSRange()
148148 tRangeList is [1,3]
149149end handler
150150
151+ // NSRect is a quadruple of (natural sized) floats
152+ public foreign type NSRect binds to "MCAggregateTypeInfo:qqqq"
153+
154+ foreign handler NSValueWithRect(in pRect as NSRect) returns ObjcId \
155+ binds to "objc:NSValue.+valueWithRect:"
156+
157+ // NSRect is 32 bytes on 64-bit arch, 16 bytes on 32-bit
158+ // so will use objc_msgSend_stret on both archs
159+ foreign handler NSRectFromValue(in pValue as ObjcId) returns NSRect \
160+ binds to "objc:NSValue.-rectValue"
161+
162+ public handler TestReturnNSRect()
163+ if not the operating system is in ["mac", "ios"] then
164+ skip test "return NSRange struct succeeds" because "not implemented on" && the operating system
165+ return
166+ end if
167+
168+ variable tRect as NSRect
169+ put [0,0,0,0] into tRect
170+ unsafe
171+ variable tValue as ObjcId
172+ put NSValueWithRect(tRect) into tValue
173+ put NSRectFromValue(tValue) into tRect
174+ end unsafe
175+
176+ variable tRectList as List
177+ put tRect into tRectList
178+
179+ test "return NSRect struct succeeds" when \
180+ tRectList is [0,0,0,0]
181+ end handler
182+
151183end module
You can’t perform that action at this time.
0 commit comments