LiveCode Builder: Passing buffer to foreign handler

Dar Scott dsc at swcp.com
Tue Apr 19 03:56:48 EDT 2016


Thanks!

I did something very similar and am about to check it out.  

Oh, packing handlers.  I better check them out.  

Dar


> On Apr 18, 2016, at 1:57 AM, Peter TB Brett <peter.brett at livecode.com> wrote:
> 
> 
> 
> On 17/04/2016 16:14, Dar Scott wrote:
>> I'm using LiveCode 8.0.0 RC 1 on the Mac.  I'm tinkering with LiveCode Builder to make library extensions.
>> 
>> I want to pass a buffer pointer to a foreign handler, in a hardware vendor supplied dynamic library  Then I want to access the bytes/words in that buffer.
>> 
>> What's the best way to do this?
>> 
>> I thought about building up a value of type data of the right length.  Is the data value contiguous?  Does it stay in one place?  Is the value allowed to change?  I think breaking equality is OK.  How do I get the pointer to the underlying first byte?  (MCDataGetBytePtr()?)  Or is a data ref automatically converted to pointer as needed?
>> 
>> Or do I need to allocate my own memory?  Are any <builtin> functions are available to do this?  How do I get to the bytes after I make the call to the foreign function?  (MCMemoryAllocate()?)
> 
> If you want a particularly horrible example, check out my wrapper for the poll(2) system call:
> 
> https://github.com/peter-b/undergrowth/blob/master/_poll.lcb
> 
> I won't claim it's the "best way to do this" but it appears to mostly work!
> 
>> Is this noise on this list?  Should this question be elsewhere?
> 
> No, it's completely on-topic.
> 
>                                   Peter
> 
> -- 
> Dr Peter Brett <peter.brett at livecode.com>
> LiveCode Open Source Team
> 
> LiveCode 2016 Conference: https://livecode.com/edinburgh-2016/
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list