Freeciv-3.3
Loading...
Searching...
No Matches
Macros | Functions
api_specenum.h File Reference

Go to the source code of this file.

Macros

#define API_SPECENUM_INDEX_NAME(type)   api_specenum_##type##_index
 
#define API_SPECENUM_NAME_NAME(type)   api_specenum_##type##_name
 
#define API_SPECENUM_DEFINE_INDEX(type_name, prefix)
 
#define API_SPECENUM_DEFINE_INDEX_REV(type_name)
 
#define API_SPECENUM_CREATE_TABLE(L, type, name)    api_specenum_create_table((L), (name), API_SPECENUM_INDEX_NAME(type))
 
#define API_SPECENUM_CREATE_TABLE_REV(L, type, name)    api_specenum_create_table((L), (name), API_SPECENUM_NAME_NAME(type))
 

Functions

void api_specenum_create_table (lua_State *L, const char *name, lua_CFunction findex)
 

Macro Definition Documentation

◆ API_SPECENUM_CREATE_TABLE

#define API_SPECENUM_CREATE_TABLE (   L,
  type,
  name 
)     api_specenum_create_table((L), (name), API_SPECENUM_INDEX_NAME(type))

Definition at line 81 of file api_specenum.h.

◆ API_SPECENUM_CREATE_TABLE_REV

#define API_SPECENUM_CREATE_TABLE_REV (   L,
  type,
  name 
)     api_specenum_create_table((L), (name), API_SPECENUM_NAME_NAME(type))

Definition at line 83 of file api_specenum.h.

◆ API_SPECENUM_DEFINE_INDEX

#define API_SPECENUM_DEFINE_INDEX (   type_name,
  prefix 
)
Value:
{ \
static char _buf[128]; \
const char *_key; \
fc_snprintf(_buf, sizeof(_buf), prefix "%s", _key); \
/* T[_key] = _value */ \
} else { \
} \
return 1; \
}
#define API_SPECENUM_INDEX_NAME(type)
char * incite_cost
Definition comments.c:76
static enum SPECENUM_NAME SPECENUM_FOO() _by_name(const char *name, int(*strcmp_func)(const char *, const char *))

Define a the __index (table, key) -> value metamethod Return the enum value whose name is the concatenation of prefix and key. The fetched value is written back to the lua table, and further accesses will resolve there instead of this function.

Definition at line 29 of file api_specenum.h.

◆ API_SPECENUM_DEFINE_INDEX_REV

#define API_SPECENUM_DEFINE_INDEX_REV (   type_name)
Value:
{ \
enum type_name _key; \
const char *_value; \
/* T[_key] = _value */ \
} else { \
} \
return 1; \
}
#define API_SPECENUM_NAME_NAME(type)

Define the __index (table, key) -> value metamethod Return the enum name whose value is supplied. The fetched value is written back to the lua table, and further accesses will resolve there instead of this function. Note that the indices usually go from 0, not 1.

Definition at line 58 of file api_specenum.h.

◆ API_SPECENUM_INDEX_NAME

#define API_SPECENUM_INDEX_NAME (   type)    api_specenum_##type##_index

Definition at line 20 of file api_specenum.h.

◆ API_SPECENUM_NAME_NAME

#define API_SPECENUM_NAME_NAME (   type)    api_specenum_##type##_name

Definition at line 21 of file api_specenum.h.

Function Documentation

◆ api_specenum_create_table()

void api_specenum_create_table ( lua_State L,
const char name,
lua_CFunction  findex 
)

Create a module table and set the member lookup function.

Definition at line 29 of file api_specenum.c.