naev 0.12.5
nlua_data.c File Reference

Handles datas. More...

#include "nlua_data.h"
#include "nluadef.h"
Include dependency graph for nlua_data.c:

Go to the source code of this file.

Macros

#define POS(U, V, W)

Functions

static size_t dataL_checkpos (lua_State *L, const LuaData_t *ld, long pos)
static int dataL_gc (lua_State *L)
 Frees a data.
static int dataL_eq (lua_State *L)
 Compares two datas to see if they are the same.
static int dataL_new (lua_State *L)
 Opens a new data.
static int dataL_get (lua_State *L)
 Gets the value of an element.
static int dataL_set (lua_State *L)
 Sets the value of an element.
static int dataL_getSize (lua_State *L)
 Gets the number of elements.
static int dataL_getString (lua_State *L)
 Returns the data contents as a string.
static int dataL_paste (lua_State *L)
 Writes the contents of "source" into "dest".
static int dataL_addWeighted (lua_State *L)
 Returns alpha*A + beta*B + bias.
static int dataL_convolve2d (lua_State *L)
 Does a convolution. You'd rather be writing shaders, right?
int nlua_loadData (nlua_env env)
 Loads the data library.
LuaData_tlua_todata (lua_State *L, int ind)
 Lua bindings to interact with datas.
LuaData_tluaL_checkdata (lua_State *L, int ind)
 Gets data at index or raises error if there is no data at index.
LuaData_tlua_pushdata (lua_State *L, LuaData_t data)
 Pushes a data on the stack.
int lua_isdata (lua_State *L, int ind)
 Checks to see if ind is a data.

Variables

static const luaL_Reg dataL_methods []

Detailed Description

Handles datas.

Definition in file nlua_data.c.

Macro Definition Documentation

◆ POS

#define POS ( U,
V,
W )
Value:
( 4 * ( ( V ) * ( W ) + ( U ) ) )

Function Documentation

◆ dataL_addWeighted()

int dataL_addWeighted ( lua_State * L)
static

Returns alpha*A + beta*B + bias.

Lua function parameter: Data A as above. Lua function parameter: Data B as above. Lua function parameter: number alpha as above. Lua function parameter: number beta as above. Lua function parameter: number bias as above. Lua return parameter: Data alpha*A + beta*B + bias.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: addWeighted

Definition at line 321 of file nlua_data.c.

◆ dataL_checkpos()

size_t dataL_checkpos ( lua_State * L,
const LuaData_t * ld,
long pos )
static

Definition at line 184 of file nlua_data.c.

◆ dataL_convolve2d()

int dataL_convolve2d ( lua_State * L)
static

Does a convolution. You'd rather be writing shaders, right?

Lua function parameter: Data I left-hand side of the convolution operator. Lua function parameter: number iw width of I. Lua function parameter: number ih height of I. Lua function parameter: Data K right-hand side of the convolution operator. Lua function parameter: number kw width of K. Lua function parameter: number kh height of K. Lua return parameter: (I*K, width, height)

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: convolve2d

Definition at line 372 of file nlua_data.c.

◆ dataL_eq()

int dataL_eq ( lua_State * L)
static

Compares two datas to see if they are the same.

Lua function parameter: Data d1 Data 1 to compare. Lua function parameter: Data d2 Data 2 to compare. Lua return parameter: boolean true if both datas are the same.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __eq

Definition at line 147 of file nlua_data.c.

◆ dataL_gc()

int dataL_gc ( lua_State * L)
static

Frees a data.

Lua function parameter: Data data Data to free.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __gc

Definition at line 132 of file nlua_data.c.

◆ dataL_get()

int dataL_get ( lua_State * L)
static

Gets the value of an element.

Lua function parameter: Data data Data to index. Lua function parameter: number pos Element position. Lua return parameter: number The entry.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: get

Definition at line 205 of file nlua_data.c.

◆ dataL_getSize()

int dataL_getSize ( lua_State * L)
static

Gets the number of elements.

Lua function parameter: Data data ... Lua return parameter: number Data size.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getSize

Definition at line 250 of file nlua_data.c.

◆ dataL_getString()

int dataL_getString ( lua_State * L)
static

Returns the data contents as a string.

Lua function parameter: Data data ... Lua return parameter: string The bytes inside.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getString

Definition at line 264 of file nlua_data.c.

◆ dataL_new()

int dataL_new ( lua_State * L)
static

Opens a new data.

Lua function parameter: number size Size to allocate for data. Lua function parameter: string type Type of the data to create ("number") Lua return parameter: Data New data object.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: new

Definition at line 168 of file nlua_data.c.

◆ dataL_paste()

int dataL_paste ( lua_State * L)
static

Writes the contents of "source" into "dest".

Lua function parameter: Data dest Destination. Lua function parameter: Data source Source. Lua function parameter: number dx Offset from start of destination. Lua function parameter: number sx Offset from start of source. Lua function parameter: number sw Number of data elements to copy.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: paste

Definition at line 281 of file nlua_data.c.

◆ dataL_set()

int dataL_set ( lua_State * L)
static

Sets the value of an element.

Lua function parameter: Data data Data to index. Lua function parameter: number pos Element position. Lua function parameter: number value Value to set it to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: set

Definition at line 227 of file nlua_data.c.

◆ lua_isdata()

int lua_isdata ( lua_State * L,
int ind )

Checks to see if ind is a data.

Parameters
LLua state to check.
indIndex position to check.
Returns
1 if ind is a data.

Definition at line 110 of file nlua_data.c.

◆ lua_pushdata()

LuaData_t * lua_pushdata ( lua_State * L,
LuaData_t data )

Pushes a data on the stack.

Parameters
LLua state to push data into.
dataData to push.
Returns
Newly pushed data.

Definition at line 94 of file nlua_data.c.

◆ lua_todata()

LuaData_t * lua_todata ( lua_State * L,
int ind )

Lua bindings to interact with datas.

Lua module: data

Gets data at index.

Parameters
LLua state to get data from.
indIndex position to find the data.
Returns
Data found at the index in the state.

Definition at line 69 of file nlua_data.c.

◆ luaL_checkdata()

LuaData_t * luaL_checkdata ( lua_State * L,
int ind )

Gets data at index or raises error if there is no data at index.

Parameters
LLua state to get data from.
indIndex position to find data.
Returns
Data found at the index in the state.

Definition at line 80 of file nlua_data.c.

◆ nlua_loadData()

int nlua_loadData ( nlua_env env)

Loads the data library.

Parameters
envEnvironment to load data library into.
Returns
0 on success.

Definition at line 51 of file nlua_data.c.

Variable Documentation

◆ dataL_methods

const luaL_Reg dataL_methods[]
static
Initial value:
= {
{ "__gc", dataL_gc },
{ "__eq", dataL_eq },
{ "new", dataL_new },
{ "get", dataL_get },
{ "set", dataL_set },
{ "getSize", dataL_getSize },
{ "getString", dataL_getString },
{ "paste", dataL_paste },
{ "addWeighted", dataL_addWeighted },
{ "convolve2d", dataL_convolve2d },
{ 0, 0 } }
static int dataL_paste(lua_State *L)
Writes the contents of "source" into "dest".
Definition nlua_data.c:281
static int dataL_addWeighted(lua_State *L)
Returns alpha*A + beta*B + bias.
Definition nlua_data.c:321
static int dataL_eq(lua_State *L)
Compares two datas to see if they are the same.
Definition nlua_data.c:147
static int dataL_get(lua_State *L)
Gets the value of an element.
Definition nlua_data.c:205
static int dataL_convolve2d(lua_State *L)
Does a convolution. You'd rather be writing shaders, right?
Definition nlua_data.c:372
static int dataL_gc(lua_State *L)
Frees a data.
Definition nlua_data.c:132
static int dataL_new(lua_State *L)
Opens a new data.
Definition nlua_data.c:168
static int dataL_getSize(lua_State *L)
Gets the number of elements.
Definition nlua_data.c:250
static int dataL_set(lua_State *L)
Sets the value of an element.
Definition nlua_data.c:227
static int dataL_getString(lua_State *L)
Returns the data contents as a string.
Definition nlua_data.c:264

Data metatable methods.

Definition at line 32 of file nlua_data.c.