* Re: A little guile query.
[not found] <87oenq30ml.fsf@cisco.com>
@ 2004-11-27 15:02 ` Neil Jerram
2004-12-06 5:10 ` nkv
0 siblings, 1 reply; 2+ messages in thread
From: Neil Jerram @ 2004-11-27 15:02 UTC (permalink / raw)
Cc: Guile Gnu
Noufal Ibrahim wrote:
> Hello everyone,
> I have a question regarding calling C functions with REST
> arguments.
>
> Basically, I have a 2D array made using
>
> (define foo (create-array (make-array 0 10 10))
>
> And then I do a
>
> (array-set! foo 1 5 5 )
>
> Now, to access this element from the scheme side of the program, I
> can do
> (array-ref foo 5 5)
> And I get a 1
>
> What I want to know is how do I frame the C equivalent of this
> array reference.
>
> The problem is that the function needs to accept a REST argument
> that contains the indices of the array. How do I do this?
>
> scm_uniform_vector_ref(scm_c_lookup("foo"),SCM_LIST2(SCM_MAKINUM(5),SCM_MAKINUM(5)));
>
> errors out saying
> ERROR: Wrong number of arguments to uniform-vector-ref
>
>
> Any sample code snippets on how to do this?
>
> Thank you.
Noufal,
I think the problem is actually the first arg. scm_c_lookup returns a
variable which holds your array, not the array itself; you need to add
scm_variable_ref to fix this:
scm_uniform_vector_ref(scm_variable_ref(scm_c_lookup("foo")),
SCM_LIST2(SCM_MAKINUM(5),SCM_MAKINUM(5)));
(Guile's uniform array and vector code is rather bad about spotting args
that are not actually arrays or vectors!)
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: A little guile query.
2004-11-27 15:02 ` A little guile query Neil Jerram
@ 2004-12-06 5:10 ` nkv
0 siblings, 0 replies; 2+ messages in thread
From: nkv @ 2004-12-06 5:10 UTC (permalink / raw)
Cc: Guile Gnu
Neil Jerram <neil@ossau.uklinux.net> writes:
[...]
> Noufal,
>
> I think the problem is actually the first arg. scm_c_lookup returns a
> variable which holds your array, not the array itself; you need to add
> scm_variable_ref to fix this:
>
> scm_uniform_vector_ref(scm_variable_ref(scm_c_lookup("foo")),
> SCM_LIST2(SCM_MAKINUM(5),SCM_MAKINUM(5)));
[...]
Thanks Neil. I got an answer to this earlier and hadn't checked my Yahoo!
mail for a while.
Thanks for the reply. :)
--
Noufal
http://hcoop.net/~nkv
AWAKE! FEAR! FIRE! FOES! AWAKE!
FEAR! FIRE! FOES!
AWAKE! AWAKE!
-- J. R. R. Tolkien
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-06 5:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <87oenq30ml.fsf@cisco.com>
2004-11-27 15:02 ` A little guile query Neil Jerram
2004-12-06 5:10 ` nkv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).