Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
luascript_func.c File Reference
#include <stdarg.h>
#include "lua.h"
#include "lualib.h"
#include "string_vector.h"
#include "luascript.h"
#include "luascript_types.h"
#include "luascript_func.h"
#include "spechash.h"

Go to the source code of this file.

Data Structures

struct  luascript_func
 

Macros

#define SPECHASH_TAG   luascript_func
 
#define SPECHASH_ASTR_KEY_TYPE
 
#define SPECHASH_IDATA_TYPE   struct luascript_func *
 
#define SPECHASH_IDATA_FREE   func_destroy
 
#define luascript_func_hash_keys_iterate(phash, key)    TYPED_HASH_KEYS_ITERATE(char *, phash, key)
 
#define luascript_func_hash_keys_iterate_end    HASH_KEYS_ITERATE_END
 

Functions

static struct luascript_funcfunc_new (bool required, int nargs, enum api_types *parg_types, int nreturns, enum api_types *preturn_types)
 
static void func_destroy (struct luascript_func *pfunc)
 
bool luascript_func_check (struct fc_lua *fcl, struct strvec *missing_func_required, struct strvec *missing_func_optional)
 
void luascript_func_add_valist (struct fc_lua *fcl, const char *func_name, bool required, int nargs, int nreturns, va_list args)
 
void luascript_func_add (struct fc_lua *fcl, const char *func_name, bool required, int nargs, int nreturns,...)
 
void luascript_func_free (struct fc_lua *fcl)
 
void luascript_func_init (struct fc_lua *fcl)
 
bool luascript_func_call_valist (struct fc_lua *fcl, const char *func_name, va_list args)
 
bool luascript_func_call (struct fc_lua *fcl, const char *func_name,...)
 
bool luascript_func_is_required (struct fc_lua *fcl, const char *func_name)
 

Macro Definition Documentation

◆ luascript_func_hash_keys_iterate

#define luascript_func_hash_keys_iterate (   phash,
  key 
)     TYPED_HASH_KEYS_ITERATE(char *, phash, key)

Definition at line 53 of file luascript_func.c.

◆ luascript_func_hash_keys_iterate_end

#define luascript_func_hash_keys_iterate_end    HASH_KEYS_ITERATE_END

Definition at line 55 of file luascript_func.c.

◆ SPECHASH_ASTR_KEY_TYPE

#define SPECHASH_ASTR_KEY_TYPE

Definition at line 48 of file luascript_func.c.

◆ SPECHASH_IDATA_FREE

#define SPECHASH_IDATA_FREE   func_destroy

Definition at line 50 of file luascript_func.c.

◆ SPECHASH_IDATA_TYPE

#define SPECHASH_IDATA_TYPE   struct luascript_func *

Definition at line 49 of file luascript_func.c.

◆ SPECHASH_TAG

#define SPECHASH_TAG   luascript_func

Definition at line 47 of file luascript_func.c.

Function Documentation

◆ func_destroy()

static void func_destroy ( struct luascript_func pfunc)
static

Free a function definition.

Definition at line 80 of file luascript_func.c.

◆ func_new()

static struct luascript_func * func_new ( bool  required,
int  nargs,
enum api_types parg_types,
int  nreturns,
enum api_types preturn_types 
)
static

Create a new function definition.

Definition at line 61 of file luascript_func.c.

Referenced by luascript_func_add_valist().

◆ luascript_func_add()

void luascript_func_add ( struct fc_lua fcl,
const char func_name,
bool  required,
int  nargs,
int  nreturns,
  ... 
)

Add a lua function.

Definition at line 178 of file luascript_func.c.

Referenced by script_server_functions_define().

◆ luascript_func_add_valist()

void luascript_func_add_valist ( struct fc_lua fcl,
const char func_name,
bool  required,
int  nargs,
int  nreturns,
va_list  args 
)

Add a lua function.

Definition at line 130 of file luascript_func.c.

Referenced by luascript_func_add().

◆ luascript_func_call()

bool luascript_func_call ( struct fc_lua fcl,
const char func_name,
  ... 
)

Call a lua function; return value is TRUE if no errors occurred, otherwise FALSE.

Example call to the lua function 'user_load()': success = luascript_func_call(L, "user_load", pconn, &password);

Definition at line 269 of file luascript_func.c.

◆ luascript_func_call_valist()

bool luascript_func_call_valist ( struct fc_lua fcl,
const char func_name,
va_list  args 
)

Call a lua function; return value is TRUE if no errors occurred, otherwise FALSE.

Example call to the lua function 'user_load()': success = luascript_func_call(L, "user_load", pconn, &password);

Definition at line 220 of file luascript_func.c.

Referenced by luascript_func_call(), script_fcdb_call(), and script_server_call().

◆ luascript_func_check()

bool luascript_func_check ( struct fc_lua fcl,
struct strvec missing_func_required,
struct strvec missing_func_optional 
)

Test if all function are defined. If it fails (return value FALSE), the missing functions are listed in 'missing_func_required' and 'missing_func_optional'.

Definition at line 94 of file luascript_func.c.

◆ luascript_func_free()

void luascript_func_free ( struct fc_lua fcl)

Free the function definitions.

Definition at line 192 of file luascript_func.c.

Referenced by luascript_destroy().

◆ luascript_func_init()

void luascript_func_init ( struct fc_lua fcl)

Initialize the structures needed to save functions definitions.

Definition at line 203 of file luascript_func.c.

Referenced by script_fcdb_init(), and script_server_init().

◆ luascript_func_is_required()

bool luascript_func_is_required ( struct fc_lua fcl,
const char func_name 
)

Return iff the function is required.

Definition at line 284 of file luascript_func.c.