OSDN Git Service

日本語版
[nazghul-jp/nazghul-jp.git] / src / closure.h
1 //
2 // nazghul - an old-school RPG engine
3 // Copyright (C) 2004 Gordon McNutt
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 2 of the License, or (at your option)
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 // more details.
14 //
15 // You should have received a copy of the GNU General Public License along with
16 // this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 // Suite 330, Boston, MA 02111-1307 USA
18 //
19 // Gordon McNutt
20 // gmcnutt@users.sourceforge.net
21 //
22 #ifndef closure_h
23 #define closure_h
24
25 #include "macros.h"
26 #include "scheme.h"
27
28 #include <stdarg.h>
29
30 BEGIN_DECL
31
32 typedef struct closure {
33         scheme *sc;
34         pointer env;
35         pointer code;
36         int ref;
37 } closure_t;
38
39 #define closure_unref_safe(clx) if ((clx)) closure_unref(clx)
40
41 extern closure_t *closure_new(scheme *interp, pointer code);
42 extern closure_t *closure_new_ref(scheme *interp, pointer code);
43 extern void closure_init(closure_t *closure, scheme *interp, pointer code);
44 extern int closure_exec(closure_t *closure, const char *fmt, ...);
45 extern pointer closure_execv(closure_t *closure, const char *fmt, va_list args);
46 extern int closure_translate_result(scheme *sc, pointer result);
47 extern  void closure_save(closure_t *closure, struct save *save);
48 extern void closure_ref(closure_t *closure);
49 extern void closure_unref(closure_t *closure);
50
51 /* Special form of closure_exec() made for running object hooks. */
52 int closure_execlpv(closure_t *closure, pointer gob, void *obj, 
53                      const char *fmt, va_list args);
54
55 /* Special form of closure_exec() made for running object hooks where an effect
56  * is attached to more than one hook. */
57 int closure_execlpiv(closure_t *closure, pointer gob, void *obj, int hook_id,
58                      const char *fmt, va_list args);
59
60 /* Another special form - for session_run_hook */
61 int closure_execvl(closure_t *closure, const char *fmt, va_list args, pointer cell);
62
63 END_DECL
64
65 #endif