src/lua_objs.h
author Tero Marttila <terom@fixme.fi>
Sun, 19 Apr 2009 04:52:12 +0300
changeset 142 dc2bb09d412c
parent 141 0b850238c588
child 143 1edab39c88a8
permissions -rw-r--r--
implement table-as-argument for lua_arg_*
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#ifndef LUA_OBJS_H
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
#define LUA_OBJS_H
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
/**
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 * @file
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
 *
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
 * Defines lua functions to access the various objects in a nexus
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
 */
105
b6b183fbf373 implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
     9
#include "nexus_lua.h"
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
116
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    11
#include <lua5.1/lua.h>
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    12
#include <lua5.1/lauxlib.h>
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    13
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
/**
116
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    15
 * Register a new metatable for a named type, this leaves the metatable on the stack.
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
 */
116
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    17
void lua_obj_create_type (lua_State *L, const char *name, const struct luaL_Reg methods[]);
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    18
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    19
/**
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    20
 * Create a new userdata with the given type metatable name, return the pointer, and keep it on the stack.
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    21
 */
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    22
void* lua_obj_create_obj (lua_State *L, const char *name, size_t size);
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    23
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    24
/**
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    25
 * Create a new metatable for a type, a userdata for that type, and register it as a global
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    26
 */
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    27
void* lua_obj_create_global_type (lua_State *L, const char *type_name, const struct luaL_Reg methods[], const char *global_name, size_t size);
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    28
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    29
/**
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    30
 * Get a userdata with the given type metatable name as the first argument for a function.
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    31
 */
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    32
void* lua_obj_get_obj (lua_State *L, const char *func, const char *name);
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    33
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    34
/**
141
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    35
 * Used as the "invalid" default value
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    36
 */
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    37
#define LUA_ARG_REQUIRED (-1)
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    38
#define LUA_ARG_STRING_REQUIRED ((const char *) (-1))
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    39
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    40
/**
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    41
 * Parse and return a string argument
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    42
 */
142
dc2bb09d412c implement table-as-argument for lua_arg_*
Tero Marttila <terom@fixme.fi>
parents: 141
diff changeset
    43
const char *lua_arg_string (lua_State *L, int nargs, int index, const char *name, const char *def);
141
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    44
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    45
/**
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    46
 * Parse and return a boolean argument
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    47
 */
142
dc2bb09d412c implement table-as-argument for lua_arg_*
Tero Marttila <terom@fixme.fi>
parents: 141
diff changeset
    48
bool lua_arg_bool (lua_State *L, int nargs, int index, const char *name, int def);
141
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    49
0b850238c588 implement SSL stuff for lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 116
diff changeset
    50
/**
116
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    51
 * Registers our lua runtime objects into the given lua state.
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    52
 *
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    53
 * Call in protected mode.
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    54
 */
92e71129074d split off lua_irc from lua_objs
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    55
void lua_objs_init (struct nexus_lua *lua);
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
#endif /* LUA_OBJS_H */