From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: bajcik@kolos.math.uni.lodz.pl Newsgroups: gmane.lisp.guile.user Subject: one C function to many Scheme functions Date: Mon, 6 Jan 2003 21:30:29 +0100 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <20030106203029.GA11033@gosia> Reply-To: bajcik@kolos.math.uni.lodz.pl NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1041973245 24681 80.91.224.249 (7 Jan 2003 21:00:45 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 7 Jan 2003 21:00:45 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18W0q3-0006Pw-00 for ; Tue, 07 Jan 2003 22:00:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18VyBI-0004dd-05 for guile-user@m.gmane.org; Tue, 07 Jan 2003 13:10:28 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18Vdw1-000442-00 for guile-user@gnu.org; Mon, 06 Jan 2003 15:33:21 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18Vdvn-0003qu-00 for guile-user@gnu.org; Mon, 06 Jan 2003 15:33:13 -0500 Original-Received: from kolos.math.uni.lodz.pl ([212.191.65.6]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Vdtu-0003ez-00 for guile-user@gnu.org; Mon, 06 Jan 2003 15:31:11 -0500 Original-Received: by kolos.math.uni.lodz.pl (Postfix, from userid 500) id 23A3836C21; Mon, 6 Jan 2003 21:30:53 +0100 (CET) Original-To: guile-user@gnu.org Content-Disposition: inline User-Agent: Mutt/1.4i X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1501 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1501 hello, 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. bajcik -- .----- Krzysztof Garus ----- http://kolos.math.uni.lodz.pl/~bajcik/ --. | http://kolos.math.uni.lodz.pl/~bajcik/duskc/ - proszę o krytykę :) | _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user