[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

one C function to many Scheme functions

From: bajcik
Subject: one C function to many Scheme functions
Date: Mon, 6 Jan 2003 21:30:29 +0100
User-agent: Mutt/1.4i


I know how to use gh_new_procedure* functions to declare function
visible in scheme script.

But I want to declare many functions in a loop. I have a table of names
and a table of C-functions [ mytype_t function(my_type arg) ] and only
ONE C-function that converts SCM to mytype_t. It is a wrapper.

I would like to do it this way:

typedef struct
        mytype_t (*func)(mytype_t arg);
        char *name;
} scm_func_t;

scm_func_t FuncTable[50]; /* Initialized */

SCM wrapper(SCM arg, void *data) /* !!! watch "data" */
        scm_func_t *sf = (scm_func_t *)data;
        my_type_t my_result;
        my_arg = SCM2my(arg);
        my_result = sf->func(my_arg)

        return my2SCM(my_result);

void declare_all_functions()
        int i;
        for (i=0; i<50; i++)
                gh_new_procedure_data(FuncTable[i].func, &FuncTable[i]);

Do you feel the sense?

FuncTable can't be a table with "SCM (*)(SCM)" functions, because my
program uses few script languages in plugins.

.----- Krzysztof Garus ----- --.
| - proszę o krytykę :)  |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]