Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5df56cf

Browse files
Change UnboxingConvert to always bridge
Not bridging here complicates implementations of various things as they have to do the conversions themselves.
1 parent 6661444 commit 5df56cf

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

libscript/src/script-execute.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -719,18 +719,26 @@ MCScriptExecuteContext::UnboxingConvert(MCValueRef p_value,
719719
const MCForeignTypeDescriptor *t_from_desc =
720720
MCForeignTypeInfoGetDescriptor(t_resolved_from_type.type);
721721

722-
// If the source is foreign, then it must be the bridge type
723-
// of the slot, so we must import.
724-
MCValueRef t_bridged_value;
725-
if (!t_from_desc->doimport(MCForeignValueGetContentsPtr(p_value),
726-
false,
727-
t_bridged_value))
728-
{
729-
Rethrow();
730-
return false;
731-
}
732-
733-
*(MCValueRef *)x_slot_ptr = t_bridged_value;
722+
// If the type of the destination slot is not exactly the foreign type,
723+
// import as the bridge type.
724+
if (t_from_desc->bridgetype != kMCNullTypeInfo &&
725+
t_resolved_from_type.type != p_slot_type.type)
726+
{
727+
MCValueRef t_bridged_value;
728+
if (!t_from_desc->doimport(MCForeignValueGetContentsPtr(p_value),
729+
false,
730+
t_bridged_value))
731+
{
732+
Rethrow();
733+
return false;
734+
}
735+
736+
*(MCValueRef *)x_slot_ptr = t_bridged_value;
737+
}
738+
else
739+
{
740+
*(MCValueRef *)x_slot_ptr = MCValueRetain(p_value);
741+
}
734742
}
735743
else if (MCTypeInfoIsHandler(p_slot_type.type) &&
736744
MCHandlerTypeInfoIsForeign(p_slot_type.type))

0 commit comments

Comments
 (0)