avoiding releasing foreign types

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

avoiding releasing foreign types

Post by monte » Sat Nov 14, 2015 10:08 pm

Hi

I'm wondering if we can add a generic way to pass the fact that a foreign value shouldn't be released. I'm encountering a crash on a function that returns a pointer to a static string. At the moment it seems doimport just has a hard coded true for release.

Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: avoiding releasing foreign types

Post by LCMark » Tue Dec 01, 2015 9:52 am

@monte: At the moment the FFI interface has no idea of 'give, borrow or take' - in this instance you want to 'borrow' the value from the native function. Unfortunately, the only way to do this at the moment is to return a Pointer, and then use MCStringCreateWithCString directly as a foreign binding.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: avoiding releasing foreign types

Post by monte » Tue Dec 01, 2015 11:53 am

OK, I was thinking it might be possible to add some syntax to the foreign handler definitions to declare ownership or at least whether it should be freed.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “LiveCode Builder”