Skip to content

Commit 8eaa95c

Browse files
committed
[[ Bug 20644 ]] Additional comment and test
- Add a comment TODO to investigate structs with long doubles on x86-64 arch - Add a test that takes objc_msgSend_stret path on x86-64 arch
1 parent c45076b commit 8eaa95c

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

libscript/src/script-execute.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

tests/lcb/vm/interop-objc.lcb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,36 @@ public handler TestReturnNSRange()
148148
tRangeList is [1,3]
149149
end 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+
151183
end module

0 commit comments

Comments
 (0)