[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] How does Chicken know the # of arguments to a functi
From: |
Joel Reymont |
Subject: |
Re: [Chicken-users] How does Chicken know the # of arguments to a function |
Date: |
Mon, 20 Dec 2004 09:07:12 +0000 |
> felix winkelmann wrote:
>> But how does Chicken know how many arguments _to expect_?
>>
>
>It's compiled into the code:
>
>(define (foo x y)
> (print x y) )
>
>->
>
>/* foo in k18 in k15 in k12 */
>static void f_22(C_word c,C_word t0,C_word t1,C_word t2,C_word t3){
>C_word tmp;
>C_word t4;
>C_word *a;
>if(c!=4) C_bad_argc(c,4); /* <-- check (includes 2 implicit
>args) */
I was talking about the SWIG interface to Chicken where wrapper functions
are registered. I can't figure out where the number of arguments are
registered.
Each function pointer is added to a vector like this:
{
C_word *p0 = a;
*(a++)=C_CLOSURE_TYPE|1;
*(a++)=(C_word)_wrap_Container_clear;
C_mutate(return_vec++, (C_word)p0);
}
to be referred to like this:
(define SDL-EFSEEK (vector-ref swig-init-return 6))
Joel
--
OpenPoker: The Linux of poker software
http://wagerlabs.com/forums
Tenerife: Canary Islands: Spain