Skip to content

Commit 92a8539

Browse files
Auto-bridge foreign types when exporting to LCS-world
1 parent ae5a54b commit 92a8539

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

engine/src/exec-extension.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,31 @@ bool MCExtensionConvertToScriptType(MCExecContext& ctxt, MCValueRef& x_value)
666666
}
667667
return true;
668668

669+
case kMCValueTypeCodeForeignValue:
670+
{
671+
// Get the type info for the foreign value so we can find its bridge
672+
// type
673+
MCTypeInfoRef t_foreign_type = MCValueGetTypeInfo(x_value);
674+
const MCForeignTypeDescriptor* t_desc = MCForeignTypeInfoGetDescriptor(t_foreign_type);
675+
if (t_desc->bridgetype == nil)
676+
break;
677+
678+
// Import the type
679+
MCValueRef t_imported;
680+
if (!t_desc->doimport(MCForeignValueGetContentsPtr(x_value), false, t_imported))
681+
return false;
682+
683+
// Recursively convert to a script type
684+
if (!MCExtensionConvertToScriptType(ctxt, t_imported))
685+
{
686+
MCValueRelease(t_imported);
687+
return false;
688+
}
689+
690+
MCValueAssign(x_value, t_imported);
691+
}
692+
return true;
693+
669694
// The rest have no conversion
670695
default:
671696
break;

0 commit comments

Comments
 (0)