This is clearly something to add to the documentation of NativeBoost. Igor can you do it? Stef On Nov 6, 2012, at 6:34 PM, Igor Stasenko wrote:
On 6 November 2012 11:23, Max Leske <maxleske@gmail.com> wrote:
Thanks Igor.
I meant a pointer to an array, sorry. Here's the function prototype:
int run_command(const char *command, char *argv[]);
I could then simply pass this to execve like so:
status = execve(command, argv, envp);
so, like i said, prepare a buffer which will hold strings, i.e.
buffer := NativeBoost allocate: (numArgs * 4). arg1ptr := NativeBoost allocate: arg1 size+1.
NativeBoost memcopy: arg1 to: arg1ptr size: arg1 size. arg1ptr nbUInt8At: arg1 size put: 0. "terminating null char"
buffer nbUInt32At: 0 put: (arg1ptr value).
something like that. (and then , of course free memory after you no longer need it :)
On 06.11.2012, at 15:12, Igor Stasenko <siguctua@gmail.com> wrote:
well, you have to decompose it to fn(arg1, arg2, arg3 ... )
because NB does not supports vararg functions.
But if function takes a pointer to array, then you can just use external memory buffer and fill it with anything you want. What exactly function you wanna use?
On 6 November 2012 11:06, Max Leske <maxleske@gmail.com> wrote:
Hi
Working with NativeBoost I'm trying to figure out if there is a way I can pass an array of arguments to a function like so:
MyExample run: 'echo' args: { 'foo' }.
nbRun: str args: args <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode > ^ self nbCall: #( int run_command (String str, Array args) ) module: 'librunner.dylib'
The intention is of course to be able to pass arguments to execve() (for example). I guess I could simply parse a string on the C-side but I'd rather not.
Any suggestions?
Cheers, Max
-- Best regards, Igor Stasenko.
-- Best regards, Igor Stasenko.