34 enum api_types *parg_types,
36 enum api_types *preturn_types);
47#define SPECHASH_TAG luascript_func
48#define SPECHASH_ASTR_KEY_TYPE
49#define SPECHASH_IDATA_TYPE struct luascript_func *
50#define SPECHASH_IDATA_FREE func_destroy
53#define luascript_func_hash_keys_iterate(phash, key) \
54 TYPED_HASH_KEYS_ITERATE(char *, phash, key)
55#define luascript_func_hash_keys_iterate_end \
62 enum api_types *parg_types,
64 enum api_types *preturn_types)
95 struct strvec *missing_func_required,
96 struct strvec *missing_func_optional)
107#ifndef FREECIV_NDEBUG
110 luascript_func_hash_lookup(fcl->
funcs, func_name, &pfunc);
135 enum api_types *parg_types;
136 enum api_types *pret_types;
141 if (luascript_func_hash_lookup(fcl->
funcs, func_name, &pfunc)) {
152 for (i = 0; i <
nargs; i++) {
153 *(parg_types + i) = va_arg(args,
int);
165 *(pret_types + i) = va_arg(args,
int);
172 luascript_func_hash_insert(fcl->
funcs, func_name, pfunc);
194 if (fcl && fcl->
funcs) {
195 luascript_func_hash_destroy(fcl->
funcs);
207 if (fcl->
funcs == NULL) {
209 fcl->
funcs = luascript_func_hash_new();
224 bool success =
FALSE;
230 if (!luascript_func_hash_lookup(fcl->
funcs, func_name, &pfunc)) {
232 "so cannot be invoked.", func_name);
237 lua_getglobal(fcl->
state, func_name);
239 if (!lua_isfunction(fcl->
state, -1)) {
243 lua_pop(fcl->
state, 1);
274 va_start(args, func_name);
292 if (!luascript_func_hash_lookup(fcl->
funcs, func_name, &pfunc)) {
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
void luascript_pop_returns(struct fc_lua *fcl, const char *func_name, int nreturns, enum api_types *preturn_types, va_list args)
void luascript_push_args(struct fc_lua *fcl, int nargs, enum api_types *parg_types, va_list args)
bool luascript_check_function(struct fc_lua *fcl, const char *funcname)
void luascript_log(struct fc_lua *fcl, enum log_level level, const char *format,...)
int luascript_call(struct fc_lua *fcl, int narg, int nret, const char *code)
bool luascript_func_call_valist(struct fc_lua *fcl, const char *func_name, va_list args)
static void func_destroy(struct luascript_func *pfunc)
#define luascript_func_hash_keys_iterate_end
bool luascript_func_check(struct fc_lua *fcl, struct strvec *missing_func_required, struct strvec *missing_func_optional)
void luascript_func_init(struct fc_lua *fcl)
void luascript_func_add(struct fc_lua *fcl, const char *func_name, bool required, int nargs, int nreturns,...)
static struct luascript_func * func_new(bool required, int nargs, enum api_types *parg_types, int nreturns, enum api_types *preturn_types)
bool luascript_func_call(struct fc_lua *fcl, const char *func_name,...)
void luascript_func_add_valist(struct fc_lua *fcl, const char *func_name, bool required, int nargs, int nreturns, va_list args)
bool luascript_func_is_required(struct fc_lua *fcl, const char *func_name)
#define luascript_func_hash_keys_iterate(phash, key)
void luascript_func_free(struct fc_lua *fcl)
#define fc_calloc(n, esz)
void strvec_append(struct strvec *psv, const char *string)
struct luascript_func_hash * funcs
enum api_types * arg_types
enum api_types * return_types