KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
lua.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include <kos/dbgio.h>
#include <dc/maple.h>
#include <dc/maple/keyboard.h>
#include <dc/maple/controller.h>

Macros

#define lua_c
 
#define lua_readline(L, b, p)
 
#define lua_saveline(L, idx)
 
#define lua_freeline(L, b)
 
#define lua_stdin_is_tty()
 
#define LUA_PROMPT   "> "
 
#define LUA_PROMPT2   ">> "
 
#define LUA_PROGNAME   "lua"
 
#define LUA_MAXINPUT   512
 
#define LUA_INIT_VAR   "LUA_INIT"
 
#define LUA_INITVARVERSION    LUA_INIT_VAR "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
 
#define EOFMARK   "<eof>"
 
#define marklen   (sizeof(EOFMARK)/sizeof(char) - 1)
 

Functions

void cont_cb (uint8_t addr, uint32_t btns)
 
static int kbd_readline (char *buf, int len)
 
static void l_message (const char *pname, const char *msg)
 
static int report (lua_State *L, int status)
 
static int msghandler (lua_State *L)
 
static int docall (lua_State *L, int narg, int nres)
 
static void print_version (void)
 
static const char * get_prompt (lua_State *L, int firstline)
 
static int incomplete (lua_State *L, int status)
 
static int pushline (lua_State *L, int firstline)
 
static int addreturn (lua_State *L)
 
static int multiline (lua_State *L)
 
static int loadline (lua_State *L)
 
static void l_print (lua_State *L)
 
static void doREPL (lua_State *L)
 
static int pmain (lua_State *L)
 
int main (int argc, char **argv)
 

Variables

static lua_State * globalL = NULL
 
static const char * progname = LUA_PROGNAME
 

Macro Definition Documentation

◆ EOFMARK

#define EOFMARK   "<eof>"

Referenced by incomplete().

◆ lua_c

#define lua_c

◆ lua_freeline

#define lua_freeline ( L,
b )
Value:
{ (void)L; (void)b; }

Referenced by pushline().

◆ LUA_INIT_VAR

#define LUA_INIT_VAR   "LUA_INIT"

◆ LUA_INITVARVERSION

#define LUA_INITVARVERSION    LUA_INIT_VAR "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR

◆ LUA_MAXINPUT

#define LUA_MAXINPUT   512

Referenced by pushline().

◆ LUA_PROGNAME

#define LUA_PROGNAME   "lua"

◆ LUA_PROMPT

#define LUA_PROMPT   "> "

Referenced by get_prompt().

◆ LUA_PROMPT2

#define LUA_PROMPT2   ">> "

Referenced by get_prompt().

◆ lua_readline

#define lua_readline ( L,
b,
p )
Value:
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
kbd_readline(b, LUA_MAXINPUT) != 0) /* get line */
#define LUA_MAXINPUT
Definition lua.c:91
#define fflush(a)
Definition wump.c:79

Referenced by pushline().

◆ lua_saveline

#define lua_saveline ( L,
idx )
Value:
{ (void)L; (void)idx; }

Referenced by loadline().

◆ lua_stdin_is_tty

#define lua_stdin_is_tty ( )
Value:
1 /* assume stdin is a tty */

◆ marklen

#define marklen   (sizeof(EOFMARK)/sizeof(char) - 1)

Referenced by incomplete().

Function Documentation

◆ addreturn()

static int addreturn ( lua_State * L)
static

Referenced by loadline().

◆ cont_cb()

void cont_cb ( uint8_t addr,
uint32_t btns )

Referenced by main().

◆ docall()

static int docall ( lua_State * L,
int narg,
int nres )
static

References globalL, and msghandler().

Referenced by doREPL().

◆ doREPL()

static void doREPL ( lua_State * L)
static

References docall(), l_print(), loadline(), NULL, progname, and report().

Referenced by pmain().

◆ get_prompt()

static const char * get_prompt ( lua_State * L,
int firstline )
static

References LUA_PROMPT, LUA_PROMPT2, and NULL.

Referenced by pushline().

◆ incomplete()

static int incomplete ( lua_State * L,
int status )
static

References EOFMARK, and marklen.

Referenced by multiline().

◆ kbd_readline()

static int kbd_readline ( char * buf,
int len )
static

◆ l_message()

static void l_message ( const char * pname,
const char * msg )
static

Referenced by l_print(), main(), and report().

◆ l_print()

static void l_print ( lua_State * L)
static

References l_message(), and progname.

Referenced by doREPL().

◆ loadline()

static int loadline ( lua_State * L)
static

References addreturn(), lua_saveline, multiline(), and pushline().

Referenced by doREPL().

◆ main()

int main ( int argc,
char ** argv )

◆ msghandler()

static int msghandler ( lua_State * L)
static

References NULL.

Referenced by docall().

◆ multiline()

static int multiline ( lua_State * L)
static

References incomplete(), and pushline().

Referenced by loadline().

◆ pmain()

static int pmain ( lua_State * L)
static

References doREPL(), and print_version().

Referenced by main().

◆ print_version()

static void print_version ( void )
static

Referenced by pmain().

◆ pushline()

static int pushline ( lua_State * L,
int firstline )
static

◆ report()

static int report ( lua_State * L,
int status )
static

References l_message(), and progname.

Referenced by doREPL(), and main().

Variable Documentation

◆ globalL

lua_State* globalL = NULL
static

Referenced by docall().

◆ progname

const char* progname = LUA_PROGNAME
static

Referenced by doREPL(), l_print(), and report().