- Subject: Re: [slang-users] USIng the LIST inside of C ...
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Sun, 10 Jun 2007 14:10:59 -0400
Ben Duncan <linux4ms@xxxxxxx> wrote:
>I would like to USE the LIST functions:
>such as :
>
> list = { "hello", 7, 3.14, {&sin, &cos}}
>
> then
>
> list_insert (list, 0, "hi");
> list_append (list, 0, "there");
> list_insert (list, -1, "before");
> list_append (list, -1, "after");
>
>inside of my C SLAG programs, then return the created LIST
>back to the S-Lang program.
>
>Any Pointers on how to go about doing this ?
I have not yet created an API to access the slang interpreter list
functions from C. Until then, you can should be able to call the
interpreter from C and have it create the list for you. Consider this
slang function:
define _create_list ()
{
variable args = __pop_args (_NARGS);
return { __push_args (args) };
}
This can be used from the slang interpreter via, e.g.,
list = _create_list ("hello", 7, 3.14);
Moreover, you can call this from C (error checking has been omitted
for clarity):
(void) SLang_start_arg_list ();
(void) SLang_push_string ("hello");
(void) SLang_push_int (7);
(void) SLang_push_double (3.14);
(void) SLang_end_arg_list ();
(void) SLang_execute_function ("_create_list");
This will create the list and leave it on the slang stack.
You will have to use a similar approach if you want to manipulate the
list from C.
--John
[2007 date index]
[2007 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]