4 * Copyright (c) Tuomo Valkonen 1999-2005.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
12 #ifndef LIBEXTL_LUAEXTL_H
13 #define LIBEXTL_LUAEXTL_H
19 #define EXTL_EXTENSION "lua"
20 #define EXTL_COMPILED_EXTENSION "lc"
21 #define EXTL_MAX_SERIALISE_DEPTH 128
29 * f: function (c or lua)
46 typedef bool ExtlL2CallHandler(void (*fn)(), ExtlL2Param *in,
49 typedef void ExtlExportedFn(void);
56 ExtlL2CallHandler *l2handler;
62 typedef struct ExtlSafelist_struct{
64 struct ExtlSafelist_struct *next, *prev;
65 ExtlExportedFn **list;
68 #define EXTL_SAFELIST_INIT(L) {0, NULL, NULL, L}
70 extern ExtlFn extl_unref_fn(ExtlFn ref);
71 extern ExtlTab extl_unref_table(ExtlTab ref);
72 extern ExtlFn extl_fn_none();
73 extern ExtlTab extl_table_none();
75 extern bool extl_fn_eq(ExtlFn fn1, ExtlFn fn2);
76 extern bool extl_table_eq(ExtlTab fn1, ExtlTab fn2);
78 /* These should be called to store function and table references gotten
79 * as arguments to functions.
81 extern ExtlFn extl_ref_fn(ExtlFn ref);
82 extern ExtlTab extl_ref_table(ExtlTab ref);
84 extern ExtlTab extl_create_table();
87 extern bool extl_table_get_vararg(ExtlTab ref, char itype, char type,
89 extern bool extl_table_get(ExtlTab ref, char itype, char type, ...);
91 extern bool extl_table_gets_o(ExtlTab ref, const char *entry, Obj **ret);
92 extern bool extl_table_gets_i(ExtlTab ref, const char *entry, int *ret);
93 extern bool extl_table_gets_d(ExtlTab ref, const char *entry, double *ret);
94 extern bool extl_table_gets_b(ExtlTab ref, const char *entry, bool *ret);
95 extern bool extl_table_gets_s(ExtlTab ref, const char *entry, char **ret);
96 extern bool extl_table_gets_f(ExtlTab ref, const char *entry, ExtlFn *ret);
97 extern bool extl_table_gets_t(ExtlTab ref, const char *entry, ExtlTab *ret);
99 extern int extl_table_get_n(ExtlTab ref);
100 extern bool extl_table_geti_o(ExtlTab ref, int entry, Obj **ret);
101 extern bool extl_table_geti_i(ExtlTab ref, int entry, int *ret);
102 extern bool extl_table_geti_d(ExtlTab ref, int entry, double *ret);
103 extern bool extl_table_geti_b(ExtlTab ref, int entry, bool *ret);
104 extern bool extl_table_geti_s(ExtlTab ref, int entry, char **ret);
105 extern bool extl_table_geti_f(ExtlTab ref, int entry, ExtlFn *ret);
106 extern bool extl_table_geti_t(ExtlTab ref, int entry, ExtlTab *ret);
109 extern bool extl_table_set_vararg(ExtlTab ref, char itype, char type,
111 extern bool extl_table_set(ExtlTab ref, char itype, char type, ...);
113 extern bool extl_table_sets_o(ExtlTab ref, const char *entry, Obj *val);
114 extern bool extl_table_sets_i(ExtlTab ref, const char *entry, int val);
115 extern bool extl_table_sets_d(ExtlTab ref, const char *entry, double val);
116 extern bool extl_table_sets_b(ExtlTab ref, const char *entry, bool val);
117 extern bool extl_table_sets_s(ExtlTab ref, const char *entry, const char *val);
118 extern bool extl_table_sets_f(ExtlTab ref, const char *entry, ExtlFn val);
119 extern bool extl_table_sets_t(ExtlTab ref, const char *entry, ExtlTab val);
121 extern bool extl_table_seti_o(ExtlTab ref, int entry, Obj *val);
122 extern bool extl_table_seti_i(ExtlTab ref, int entry, int val);
123 extern bool extl_table_seti_d(ExtlTab ref, int entry, double val);
124 extern bool extl_table_seti_b(ExtlTab ref, int entry, bool val);
125 extern bool extl_table_seti_s(ExtlTab ref, int entry, const char *val);
126 extern bool extl_table_seti_f(ExtlTab ref, int entry, ExtlFn val);
127 extern bool extl_table_seti_t(ExtlTab ref, int entry, ExtlTab val);
131 extern bool extl_table_clear_vararg(ExtlTab ref, char itype, va_list *args);
132 extern bool extl_table_clear(ExtlTab ref, char itype, ...);
134 extern bool extl_table_clears(ExtlTab ref, const char *entry);
135 extern bool extl_table_cleari(ExtlTab ref, int entry);
139 extern void extl_protect(ExtlSafelist *sl);
140 extern void extl_unprotect(ExtlSafelist *sl);
142 extern bool extl_call_vararg(ExtlFn fnref, const char *spec,
143 const char *rspec, va_list *args);
144 extern bool extl_call(ExtlFn fnref, const char *spec,
145 const char *rspec, ...);
149 extern bool extl_loadfile(const char *file, ExtlFn *ret);
150 extern bool extl_loadstring(const char *str, ExtlFn *ret);
151 extern bool extl_serialise(const char *file, ExtlTab tab);
155 extern bool extl_register_function(ExtlExportedFnSpec *spec);
156 extern void extl_unregister_function(ExtlExportedFnSpec *spec);
157 extern bool extl_register_functions(ExtlExportedFnSpec *spec);
158 extern void extl_unregister_functions(ExtlExportedFnSpec *spec);
160 bool extl_register_class(const char *cls, ExtlExportedFnSpec *fns,
162 void extl_unregister_class(const char *cls, ExtlExportedFnSpec *fns);
164 bool extl_register_module(const char *cls, ExtlExportedFnSpec *fns);
165 void extl_unregister_module(const char *cls, ExtlExportedFnSpec *fns);
169 extern bool extl_init();
170 extern void extl_deinit();
172 #endif /* LIBEXTL_LUAEXTL_H */