60#define SPECLIST_TAG signal_callback
61#define SPECLIST_TYPE struct signal_callback
64#define signal_callback_list_iterate(list, pcallback) \
65 TYPED_LIST_ITERATE(struct signal_callback, list, pcallback)
66#define signal_callback_list_iterate_end \
90#define SPECHASH_TAG luascript_signal
91#define SPECHASH_ASTR_KEY_TYPE
92#define SPECHASH_IDATA_TYPE struct signal *
93#define SPECHASH_IDATA_FREE signal_destroy
96#define signal_hash_iterate(phash, key, data) \
97 TYPED_HASH_ITERATE(char *, struct signal *, phash, key, data)
98#define signal_hash_iterate_end \
102#define SPECLIST_TAG luascript_signal_name
103#define SPECLIST_TYPE char
106#define luascript_signal_name_list_iterate(list, pname) \
107 TYPED_LIST_ITERATE(struct signal_callback, list, pcallback)
108#define luascript_signal_name_list_iterate_end \
127 free(pcallback->
name);
158 signal_callback_list_destroy(psignal->
callbacks);
166 const char *signal_name,
174 if (luascript_signal_hash_lookup(fcl->
signals, signal_name, &psignal)) {
178 va_copy(args_cb, args);
188 "be invoked.", signal_name);
196 const char *signal_name, ...)
200 va_start(args, signal_name);
209 const char *signal_name,
210 int nargs, va_list args)
217 if (luascript_signal_hash_lookup(fcl->
signals, signal_name, &psignal)) {
222 enum api_types *parg_types;
223 char *sn =
fc_malloc(strlen(signal_name) + 1);
231 for (i = 0; i <
nargs; i++) {
232 *(parg_types + i) = va_arg(args,
int);
239 luascript_signal_hash_insert(fcl->
signals, signal_name,
241 strcpy(sn, signal_name);
242 luascript_signal_name_list_append(fcl->
signal_names, sn);
252 const char *signal_name,
258 va_start(args,
nargs);
262 if (created != NULL) {
273 char *replacement,
char *deprecated_since)
275 if (deprecator != NULL) {
278 if (deprecated_since != NULL && replacement != NULL) {
280 "Deprecated: lua signal \"%s\", deprecated since \"%s\", used. "
281 "Use \"%s\" instead", signal_name, deprecated_since, replacement);
282 }
else if (replacement != NULL) {
284 "Deprecated: lua signal \"%s\" used. Use \"%s\" instead",
285 signal_name, replacement);
288 "Deprecated: lua signal \"%s\" used.", signal_name);
299 const char *callback_name,
bool create)
307 if (luascript_signal_hash_lookup(fcl->
signals, signal_name, &psignal)) {
310 if (!strcmp(pcallback->name, callback_name)) {
311 pcallback_found = pcallback;
321 if (pcallback_found) {
323 "called \"%s\".", signal_name,
326 signal_callback_list_append(psignal->
callbacks,
330 if (pcallback_found) {
331 signal_callback_list_remove(psignal->
callbacks, pcallback_found);
344 const char *signal_name,
345 const char *callback_name)
352 if (luascript_signal_hash_lookup(fcl->
signals, signal_name, &psignal)) {
355 if (!strcmp(pcallback->name, callback_name)) {
381 fcl->
signals = luascript_signal_hash_new();
391 if (NULL != fcl && NULL != fcl->
signals) {
392 luascript_signal_hash_destroy(fcl->
signals);
408 return luascript_signal_name_list_get(fcl->
signal_names, sindex);
416 const char *signal_name,
424 if (luascript_signal_hash_lookup(fcl->
signals, signal_name, &psignal)) {
426 = signal_callback_list_get(psignal->
callbacks, sindex);
428 return pcallback->
name;
#define log_deprecation(message,...)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
bool luascript_callback_invoke(struct fc_lua *fcl, const char *callback_name, int nargs, enum api_types *parg_types, va_list args)
int luascript_error(lua_State *L, const char *format,...)
void luascript_log(struct fc_lua *fcl, enum log_level level, const char *format,...)
void luascript_signal_free(struct fc_lua *fcl)
void luascript_signal_init(struct fc_lua *fcl)
static void signal_destroy(struct signal *psignal)
bool luascript_signal_callback_defined(struct fc_lua *fcl, const char *signal_name, const char *callback_name)
void luascript_signal_emit_valist(struct fc_lua *fcl, const char *signal_name, va_list args)
static struct signal * luascript_signal_create_valist(struct fc_lua *fcl, const char *signal_name, int nargs, va_list args)
const char * luascript_signal_by_index(struct fc_lua *fcl, int sindex)
#define signal_callback_list_iterate(list, pcallback)
void deprecate_signal(signal_deprecator *deprecator, char *signal_name, char *replacement, char *deprecated_since)
static struct signal_callback * signal_callback_new(const char *name)
static void signal_callback_destroy(struct signal_callback *pcallback)
const char * luascript_signal_callback_by_index(struct fc_lua *fcl, const char *signal_name, int sindex)
void luascript_signal_emit(struct fc_lua *fcl, const char *signal_name,...)
#define signal_callback_list_iterate_end
void luascript_signal_callback(struct fc_lua *fcl, const char *signal_name, const char *callback_name, bool create)
static void sn_free(char *name)
signal_deprecator * luascript_signal_create(struct fc_lua *fcl, const char *signal_name, int nargs,...)
static struct signal * signal_new(int nargs, enum api_types *parg_types)
#define fc_calloc(n, esz)
struct luascript_signal_hash * signals
struct luascript_signal_name_list * signal_names
struct signal_callback_list * callbacks
enum api_types * arg_types
int fc_snprintf(char *str, size_t n, const char *format,...)