Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/scriptcore/luascript_signal.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
luascript_signal.c File Reference
`#include <stdarg.h>`
`#include "deprecations.h"`
`#include "log.h"`
`#include "luascript.h"`
`#include "luascript_types.h"`
`#include "luascript_signal.h"`
`#include "speclist.h"`
`#include "spechash.h"`

Go to the source code of this file.

## Data Structures

struct | signal
struct | signal_callback

## Macros

#define | SPECLIST_TAG signal_callback
#define | SPECLIST_TYPE struct signal_callback
#define | signal_callback_list_iterate(list, pcallback) TYPED_LIST_ITERATE(struct signal_callback, list, pcallback)
#define | signal_callback_list_iterate_end LIST_ITERATE_END
#define | SPECHASH_TAG luascript_signal
#define | SPECHASH_ASTR_KEY_TYPE
#define | SPECHASH_IDATA_TYPE struct signal *
#define | SPECHASH_IDATA_FREE signal_destroy
#define | signal_hash_iterate(phash, key, data) TYPED_HASH_ITERATE(char *, struct signal *, phash, key, data)
#define | signal_hash_iterate_end HASH_ITERATE_END
#define | SPECLIST_TAG luascript_signal_name
#define | SPECLIST_TYPE char
#define | luascript_signal_name_list_iterate(list, pname) TYPED_LIST_ITERATE(struct signal_callback, list, pcallback)
#define | luascript_signal_name_list_iterate_end LIST_ITERATE_END

## Functions

static struct signal_callback * | signal_callback_new (const char *name)
static void | signal_callback_destroy (struct signal_callback *pcallback)
static struct signal * | signal_new (int nargs, enum api_types *parg_types)
static void | signal_destroy (struct signal *psignal)
void | luascript_signal_emit_valist (struct fc_lua *fcl, const char *signal_name, va_list args)
void | luascript_signal_emit (struct fc_lua *fcl, const char *signal_name,...)
static struct signal * | luascript_signal_create_valist (struct fc_lua *fcl, const char *signal_name, int nargs, va_list args)
signal_deprecator * | luascript_signal_create (struct fc_lua *fcl, const char *signal_name, int nargs,...)
void | deprecate_signal (signal_deprecator *deprecator, char *signal_name, char *replacement, char *deprecated_since)
void | luascript_signal_callback (struct fc_lua *fcl, const char *signal_name, const char *callback_name, bool create)
bool | luascript_signal_callback_defined (struct fc_lua *fcl, const char *signal_name, const char *callback_name)
static void | sn_free (char *name)
void | luascript_signal_init (struct fc_lua *fcl)
void | luascript_signal_free (struct fc_lua *fcl)
const char * | luascript_signal_by_index (struct fc_lua *fcl, int sindex)
const char * | luascript_signal_callback_by_index (struct fc_lua *fcl, const char *signal_name, int sindex)

## Macro Definition Documentation

## ◆ luascript_signal_name_list_iterate

#define luascript_signal_name_list_iterate | ( |  | list,
|  |  | pname
| ) |  | TYPED_LIST_ITERATE(struct signal_callback, list, pcallback)

Definition at line 106 of file luascript_signal.c.

## ◆ luascript_signal_name_list_iterate_end

#define luascript_signal_name_list_iterate_end LIST_ITERATE_END

Definition at line 108 of file luascript_signal.c.

## ◆ signal_callback_list_iterate

#define signal_callback_list_iterate | ( |  | list,
|  |  | pcallback
| ) |  | TYPED_LIST_ITERATE(struct signal_callback, list, pcallback)

Definition at line 64 of file luascript_signal.c.

## ◆ signal_callback_list_iterate_end

#define signal_callback_list_iterate_end LIST_ITERATE_END

Definition at line 66 of file luascript_signal.c.

## ◆ signal_hash_iterate

#define signal_hash_iterate | ( |  | phash,
|  |  | key,
|  |  | data
| ) |  | TYPED_HASH_ITERATE(char *, struct signal *, phash, key, data)

Definition at line 96 of file luascript_signal.c.

## ◆ signal_hash_iterate_end

#define signal_hash_iterate_end HASH_ITERATE_END

Definition at line 98 of file luascript_signal.c.

## ◆ SPECHASH_ASTR_KEY_TYPE

#define SPECHASH_ASTR_KEY_TYPE

Definition at line 91 of file luascript_signal.c.

## ◆ SPECHASH_IDATA_FREE

#define SPECHASH_IDATA_FREE signal_destroy

Definition at line 93 of file luascript_signal.c.

## ◆ SPECHASH_IDATA_TYPE

#define SPECHASH_IDATA_TYPE struct signal *

Definition at line 92 of file luascript_signal.c.

## ◆ SPECHASH_TAG

#define SPECHASH_TAG luascript_signal

Definition at line 90 of file luascript_signal.c.

## ◆ SPECLIST_TAG [1/2]

#define SPECLIST_TAG signal_callback

Definition at line 60 of file luascript_signal.c.

## ◆ SPECLIST_TAG [2/2]

#define SPECLIST_TAG luascript_signal_name

Definition at line 60 of file luascript_signal.c.

## ◆ SPECLIST_TYPE [1/2]

#define SPECLIST_TYPE struct signal_callback

Definition at line 61 of file luascript_signal.c.

## ◆ SPECLIST_TYPE [2/2]

#define SPECLIST_TYPE char

Definition at line 61 of file luascript_signal.c.

## Function Documentation

## ◆ deprecate_signal()

void deprecate_signal | ( | signal_deprecator * | deprecator,
|  | char * | signal_name,
|  | char * | replacement,
|  | char * | deprecated_since
| ) |  |

Mark signal deprecated.

Definition at line 272 of file luascript_signal.c.

Referenced by script_server_signals_create().

## ◆ luascript_signal_by_index()

const char * luascript_signal_by_index | ( | struct fc_lua * | fcl,
|  | int | sindex
| ) |  |

Return the name of the signal with the given index.

Definition at line 403 of file luascript_signal.c.

Referenced by api_signal_by_index().

## ◆ luascript_signal_callback()

void luascript_signal_callback | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  | const char * | callback_name,
|  | bool | create
| ) |  |

Connects a callback function to a certain signal.

Definition at line 298 of file luascript_signal.c.

Referenced by api_signal_connect(), and api_signal_remove().

## ◆ luascript_signal_callback_by_index()

const char * luascript_signal_callback_by_index | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  | int | sindex
| ) |  |

Return the name of the 'index' callback function of the signal with the name 'signal_name'.

Definition at line 415 of file luascript_signal.c.

Referenced by api_signal_callback_by_index().

## ◆ luascript_signal_callback_defined()

bool luascript_signal_callback_defined | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  | const char * | callback_name
| ) |  |

Returns if a callback function to a certain signal is defined.

Definition at line 343 of file luascript_signal.c.

Referenced by api_signal_defined().

## ◆ luascript_signal_create()

signal_deprecator * luascript_signal_create | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  | int | nargs,
|  |  | ...
| ) |  |

Create a new signal type.

Definition at line 251 of file luascript_signal.c.

Referenced by script_client_signal_create(), and script_server_signals_create().

## ◆ luascript_signal_create_valist()

static struct signal * luascript_signal_create_valist | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  | int | nargs,
|  | va_list | args
| ) |  |

static

Create a new signal type.

Definition at line 208 of file luascript_signal.c.

Referenced by luascript_signal_create().

## ◆ luascript_signal_emit()

void luascript_signal_emit | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  |  | ...
| ) |  |

Invoke all the callback functions attached to a given signal.

Definition at line 195 of file luascript_signal.c.

## ◆ luascript_signal_emit_valist()

void luascript_signal_emit_valist | ( | struct fc_lua * | fcl,
|  | const char * | signal_name,
|  | va_list | args
| ) |  |

Invoke all the callback functions attached to a given signal.

Definition at line 165 of file luascript_signal.c.

Referenced by luascript_signal_emit(), script_client_signal_emit(), and script_server_signal_emit().

## ◆ luascript_signal_free()

void luascript_signal_free | ( | struct fc_lua * | fcl | ) |

Free script signals and callbacks.

Definition at line 389 of file luascript_signal.c.

Referenced by luascript_destroy(), and script_client_free().

## ◆ luascript_signal_init()

void luascript_signal_init | ( | struct fc_lua * | fcl | ) |

Initialize script signals and callbacks.

Definition at line 376 of file luascript_signal.c.

Referenced by script_client_init(), and script_server_init().

## ◆ signal_callback_destroy()

static void signal_callback_destroy | ( | struct signal_callback * | pcallback | ) |

static

Free a signal callback.

Definition at line 125 of file luascript_signal.c.

Referenced by signal_new().

## ◆ signal_callback_new()

static struct signal_callback * signal_callback_new | ( | const char * | name | ) |

static

Create a new signal callback.

Definition at line 114 of file luascript_signal.c.

Referenced by luascript_signal_callback().

## ◆ signal_destroy()

static void signal_destroy | ( | struct signal * | psignal | ) |

static

Free a signal.

Definition at line 150 of file luascript_signal.c.

## ◆ signal_new()

static struct signal * signal_new | ( | int | nargs,
|  | enum api_types * | parg_types
| ) |  |

static

Create a new signal.

Definition at line 134 of file luascript_signal.c.

Referenced by luascript_signal_create_valist().

## ◆ sn_free()

static void sn_free | ( | char * | name | ) |

static

Callback for freeing memory where luascript_signal_name_list has signal name.

Definition at line 368 of file luascript_signal.c.

Referenced by luascript_signal_init().