Re: LCB Woes

2018-04-13 Thread Mark Wieder via use-livecode

On 04/12/2018 07:37 PM, Pi Digital via use-livecode wrote:

Why on earth would you have to type them? Why not for loop them or copy-paste 
or get LC to give you a 1024 char string of them you can copy-paste in? Odd.


Well, yeah, obviously it would be a cut and paste thing.
But even so, when dealing with a foreign struct like

struct{
blah,
blah,
char[1024],
blah,
blah,
};

and you have to use a string like


it gets to be a bit much and at least requires a comment to explain wtf 
that thing is doing in there. Would be so much easier to type


1024b

--
 Mark Wieder
 ahsoftw...@gmail.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: LCB Woes

2018-04-12 Thread Brian Milby via use-livecode
Here's an snip from my libSodium start:

private __safe foreign handler \
MCDataCreateWithBytesAndRelease( \
in pBytes as Pointer, \
in pCount as LCUIndex, \
out rData as Data) \
returns CBool binds to ""

private __safe foreign handler \
MCMemoryAllocate( \
in pSize as LCUIndex, \
out rBlock as Pointer) \
returns CBool binds to ""

private __safe foreign handler \
MCMemoryDeallocate( \
in pBlock as Pointer) \
returns nothing binds to ""

constant kCrypto_kx_PUBLICKEYBYTES is 32
constant kCrypto_kx_SECRETKEYBYTES is 32

private foreign handler \
_crypto_kx_keypair( \
in pPK as Pointer, /* unsigned char pk[crypto_kx_PUBLICKEYBYTES] */ \
in pSK as Pointer) /* unsigned char sk[crypto_kx_SECRETKEYBYTES] */ \
returns CInt binds to "c:libsodium>crypto_kx_keypair"

public handler sodiumKxKeypair(out rPK as Data, out rSK as Data) returns
Boolean
variable tPKbuffer as Pointer
variable tSKbuffer as Pointer

if not MCMemoryAllocate(kCrypto_kx_PUBLICKEYBYTES, tPKbuffer) then
throw "can't allocate PK buffer"
end if
if not MCMemoryAllocate(kCrypto_kx_SECRETKEYBYTES, tSKbuffer) then
MCMemoryDeallocate(tPKbuffer)
throw "can't allocate SK buffer"
end if
unsafe
if _crypto_kx_keypair(tPKbuffer, tSKbuffer) < 0 then
MCMemoryDeallocate(tPKbuffer)
MCMemoryDeallocate(tSKbuffer)
throw "could not get keys"
end if
end unsafe

if not MCDataCreateWithBytesAndRelease(tPKbuffer, \
kCrypto_kx_PUBLICKEYBYTES, rPK) then
MCMemoryDeallocate(tPKbuffer)
MCMemoryDeallocate(tSKbuffer)
throw "error copying PK"
end if
if not MCDataCreateWithBytesAndRelease(tSKbuffer, \
kCrypto_kx_SECRETKEYBYTES, rSK) then
MCMemoryDeallocate(tSKbuffer)
throw "error copying SK"
end if

return true
end handler


On Thu, Apr 12, 2018 at 9:37 PM, Pi Digital via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Why on earth would you have to type them? Why not for loop them or
> copy-paste or get LC to give you a 1024 char string of them you can
> copy-paste in? Odd.
>
> LCB is very much in its youth especially for java and objc. We have only
> the bare minimum of examples and tutorials and documentation of course.
> Building a library is very similar to widgets with the exception that they
> are not linked to a gui control or display. So they just handle calls and
> functions but don’t have an object/control on the card and thus no property
> dialogue either. The examples for widgets work practically the same for a
> library. But there will be occasional differences you’ll come across as you
> go. No doubt Ali will be providing some more info on these in time. But
> start digging into it now. I’m still playing around trying to make some
> libraries of my own - simple ones to start with.
>
> All the best.
>
> Sean Cole
> Pi Digital
>
> > On 13 Apr 2018, at 03:04, Mark Wieder via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> >> On 04/12/2018 06:03 PM, Brian Milby via use-livecode wrote:
> >> What language is the library written in? Which platform? I have some
> code
> >> that I’ve started to put together for libSodium, but I have not done
> much
> >> more than reference the calls.
> >
> > Interesting. I started down the libSodium path and gave it up when I
> found that I had to create a struct with 1024 individual byte references
> for an embedded buffer. There really should be a way to specify a number so
> you don't have to type 1024 "h" characters in a row.
> >
> > --
> > Mark Wieder
> > ahsoftw...@gmail.com
> >
> >
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LCB Woes

2018-04-12 Thread Pi Digital via use-livecode
Why on earth would you have to type them? Why not for loop them or copy-paste 
or get LC to give you a 1024 char string of them you can copy-paste in? Odd. 

LCB is very much in its youth especially for java and objc. We have only the 
bare minimum of examples and tutorials and documentation of course. Building a 
library is very similar to widgets with the exception that they are not linked 
to a gui control or display. So they just handle calls and functions but don’t 
have an object/control on the card and thus no property dialogue either. The 
examples for widgets work practically the same for a library. But there will be 
occasional differences you’ll come across as you go. No doubt Ali will be 
providing some more info on these in time. But start digging into it now. I’m 
still playing around trying to make some libraries of my own - simple ones to 
start with. 

All the best. 

Sean Cole
Pi Digital

> On 13 Apr 2018, at 03:04, Mark Wieder via use-livecode 
>  wrote:
> 
>> On 04/12/2018 06:03 PM, Brian Milby via use-livecode wrote:
>> What language is the library written in? Which platform? I have some code
>> that I’ve started to put together for libSodium, but I have not done much
>> more than reference the calls.
> 
> Interesting. I started down the libSodium path and gave it up when I found 
> that I had to create a struct with 1024 individual byte references for an 
> embedded buffer. There really should be a way to specify a number so you 
> don't have to type 1024 "h" characters in a row.
> 
> -- 
> Mark Wieder
> ahsoftw...@gmail.com
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LCB Woes

2018-04-12 Thread Brian Milby via use-livecode
Here's what I have so far...

On Thu, Apr 12, 2018 at 9:04 PM, Mark Wieder via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On 04/12/2018 06:03 PM, Brian Milby via use-livecode wrote:
>
>> What language is the library written in? Which platform? I have some code
>> that I’ve started to put together for libSodium, but I have not done much
>> more than reference the calls.
>>
>
> Interesting. I started down the libSodium path and gave it up when I found
> that I had to create a struct with 1024 individual byte references for an
> embedded buffer. There really should be a way to specify a number so you
> don't have to type 1024 "h" characters in a row.
>
> --
>  Mark Wieder
>  ahsoftw...@gmail.com
>
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LCB Woes

2018-04-12 Thread Mark Wieder via use-livecode

On 04/12/2018 06:03 PM, Brian Milby via use-livecode wrote:

What language is the library written in? Which platform? I have some code
that I’ve started to put together for libSodium, but I have not done much
more than reference the calls.


Interesting. I started down the libSodium path and gave it up when I 
found that I had to create a struct with 1024 individual byte references 
for an embedded buffer. There really should be a way to specify a number 
so you don't have to type 1024 "h" characters in a row.


--
 Mark Wieder
 ahsoftw...@gmail.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LCB Woes

2018-04-12 Thread Brian Milby via use-livecode
What language is the library written in? Which platform? I have some code
that I’ve started to put together for libSodium, but I have not done much
more than reference the calls.
On Thu, Apr 12, 2018 at 7:55 PM Dan Friedman via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Greetings!   I am trying to learn how to make a LC Library that will
> connect to an external SDK that I can use in my LC Apps.  But, I seem to be
> stuck before I even got started.   I have LC Builder open, and I have
> downloaded the SDK I want to write the wrapper for, but I don’t know what
> to do with it.   How do you connect the two?  I’ve looked at LC’s examples
> and they talk A LOT about making widgets, but not much about making a
> library.   Does anyone know the process?  Or, know good resource to explain
> how to do this?
>
> Any advice would be greatly appreciated.
>
> -Dan
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode