Lua-API

 view release on metacpan or  search on metacpan

API.xs  view on Meta::CPAN

   lua_pushvfstring(L, fmt, argp);
   va_end(argp);
   lua_concat(L, 2);
   lua_pcall( L, 1, 0, 0 ); 
}


/*-------------------------------------------------------------------*/


#include "wrap.h"


/*-------------------------------------------------------------------*/

MODULE = Lua::API		PACKAGE = Lua::API

INCLUDE: const-xs.inc

BOOT:
{
    MY_CXT_INIT;
    MY_CXT.OOB = newHV();
}

 # oh, ick

const char *
RELEASE( )
      CODE:
        RETVAL = LUA_RELEASE;
      OUTPUT:
        RETVAL

const char *
COPYRIGHT( )
      CODE :
        RETVAL = LUA_COPYRIGHT;
      OUTPUT:
        RETVAL

MODULE = Lua::API		PACKAGE = Lua::API::State		PREFIX = lua_

lua_CFunction
lua_atpanic(L, panicf)
	lua_State *	L
	lua_CFunction	panicf

void
lua_call(L, nargs, nresults)
	lua_State *	L
	int	nargs
	int	nresults

 # call either lua_checkstack or luaL_checkstack based upon the number
 # of parameters
void
lua_checkstack(L, sz, ...)
	lua_State *	L
	int	  sz
	PPCODE:
	  /* call lua_checkstack */
	  if ( items == 2 )
	  {
	    int status = lua_checkstack( L, sz );
            EXTEND(SP, 1);
            PUSHs(sv_2mortal(newSViv(status)));
	  }
	  /* emulate luaL_checkstack */
	  else if ( items == 3 )
	  {
	    const char *msg = (const char*) SvPV_nolen(ST(2));
	    if ( !lua_checkstack( L, sz ) )
	    {
	       throw_luaL_error( L, "stack overflow (%s)", msg );
	       SV *rv = newSV(0);
	       SV *sv = newSVrv( rv, "Lua::API::State::Error" );
	       sv_setsv((SV*) get_sv("@", GV_ADD), rv);
	       croak(NULL);
	    }
	  }
	  else
	  {
	    croak_xs_usage( cv, "L,sz,[msg]" );
	  }

 # void
 # lua_close(L)
 # 	lua_State *	L


void
lua_concat(L, n)
	lua_State *	L
	int	n

int
lua_cpcall(L, func, ud)
	lua_State *	L
	SV *func
	SV *ud
      PREINIT:
	CPCallData data = { func, ud };
      CODE:
	RETVAL = lua_cpcall( L, l2p_cpcall, &data );
      OUTPUT:
	RETVAL

void
lua_createtable(L, narr, nrec)
	lua_State *	L
	int	narr
	int	nrec

 # No support for lua_Writer

 # int
 # lua_dump(L, writer, data)
 # 	lua_State *	L
 # 	lua_Writer	writer
 # 	void *	data

API.xs  view on Meta::CPAN

	int	idx2

int
lua_gc(L, what, data)
	lua_State *	L
	int	what
	int	data

lua_Alloc
lua_getallocf(L, ud)
	lua_State *	L
	void **	ud

void
lua_getfenv(L, idx)
	lua_State *	L
	int	idx

void
lua_getfield(L, idx, k)
	lua_State *	L
	int	idx
	const char *	k

int
lua_getgccount(L)
	lua_State *	L

void
lua_getglobal(L, name)
	lua_State *	L
	const char *	name

lua_Hook
lua_gethook(L)
	lua_State *	L

int
lua_gethookcount(L)
	lua_State *	L

int
lua_gethookmask(L)
	lua_State *	L

int
lua_getinfo(L, what, ar)
	lua_State *	L
	const char *	what
	lua_Debug *	ar

const char *
lua_getlocal(L, ar, n)
	lua_State *	L
	const lua_Debug *	ar
	int	n

void
lua_getmetatable(L, ...)
	lua_State *	L
      PPCODE:
	if ( items != 1 )
	    croak_xs_usage( cv, "L,(objindex|name)" );
	if ( looks_like_number( ST(1) ) )
	{
	    int	objindex = (int)SvIV(ST(1));
	    int RETVAL = lua_getmetatable(L, objindex);
	    EXTEND(SP,1);
	    PUSHs(sv_2mortal(newSViv(RETVAL)));
	}
        else
	{
	    const char *n = (const char *)SvPV_nolen(ST(1));
	    luaL_getmetatable(L, n);
	    XSRETURN_EMPTY;
	}

void
lua_getregistry(L)
	lua_State *	L

int
lua_getstack(L, level, ar)
	lua_State *	L
	int	level
	lua_Debug *	ar

void
lua_gettable(L, idx)
	lua_State *	L
	int	idx

int
lua_gettop(L)
	lua_State *	L

const char *
lua_getupvalue(L, funcindex, n)
	lua_State *	L
	int	funcindex
	int	n

void
lua_insert(L, idx)
	lua_State *	L
	int	idx

int
lua_isboolean(L, index)
	lua_State *	L
	int	index

int
lua_iscfunction(L, idx)
	lua_State *	L
	int	idx

int
lua_isfunction(L, index)
	lua_State *	L
	int	index

API.xs  view on Meta::CPAN

int
luaL_dostring(L, s)
	lua_State *	L
	const char *	s

 # implemented in Lua/API.pm
 # int
 # luaL_error(L, fmt, ...)
 # 	lua_State *	L
 # 	const char *	fmt

const char *
luaL_findtable(L, idx, fname, szhint)
	lua_State *	L
	int	idx
	const char *	fname
	int	szhint

int
luaL_getmetafield(L, obj, e)
	lua_State *	L
	int	obj
	const char *	e

const char *
luaL_gsub(L, s, p, r)
	lua_State *	L
	const char *	s
	const char *	p
	const char *	r

int
luaL_loadbuffer(L, buff, sz, name)
	lua_State *	L
	const char *	buff
	size_t	sz
	const char *	name

int
luaL_loadfile(L, filename)
	lua_State *	L
	const char *	filename

int
luaL_loadstring(L, s)
	lua_State *	L
	const char *	s

int
luaL_newmetatable(L, tname)
	lua_State *	L
	const char *	tname

lua_State *
luaL_newstate(CLASS)
	char *CLASS = NO_INIT
    PROTOTYPE: $
    ALIAS:
	open = 1
	new = 2
    PPCODE:
        RETVAL = luaL_newstate();
	ST(0) = sv_newmortal();
        sv_setref_iv(ST(0), "Lua::API::State", PTR2IV(RETVAL));
	set_Perl_object( RETVAL, ST(0) );
        XSRETURN(1);


int
luaL_ref(L, t)
	lua_State *	L
	int	t

 # implemented in Lua/API.pm
 # void
 # luaL_register(L, libname, l)
 # 	lua_State *	L
 # 	const char *	libname
 # 	const luaL_Reg *	l

void
luaL_unref(L, t, ref)
	lua_State *	L
	int	t
	int	ref

void
luaL_where(L, lvl)
	lua_State *	L
	int	lvl


MODULE = Lua::API		PACKAGE = Lua::API::State

void
DESTROY( lua_State * L )
     ALIAS:
       close = 1
     CODE:
 	if ( NULL != delete_oob_entry( L ) )
	    lua_close( L );


  # These functions are wrapped in Lua/API.pm, which calls them
  # explicitly, so don't remove the prefix

int
lua_error(L)
	lua_State *	L

void
lua_register(L, name, f)
	lua_State *	L
	const char *	name
 	SV *	f
	PREINIT:
	SV *sv_c = newSVsv(f);
        CODE:
        lua_pushlightuserdata(L, sv_c );
        lua_pushcclosure(L, l2p_closure, 1 );
	lua_setglobal(L, name );

int
lua_getmetatable(L, index)
	lua_State *	L
	int             index

void
luaL_getmetatable(L, n)
	lua_State *	L
	const char *	n

const char *
lua_typename(L, tp)
	lua_State *	L
	int	tp

const char *
luaL_typename(L, i)
	lua_State *	L
	int	i

MODULE = Lua::API		PACKAGE = Lua::API::Debug

lua_Debug *
new(CLASS)
	char *CLASS = NO_INIT
    PROTOTYPE: $
    PPCODE:
        Newxz( RETVAL, 1, lua_Debug );
	ST(0) = sv_newmortal();
        sv_setref_iv(ST(0), "Lua::API::Debug", PTR2IV(RETVAL));
	set_Perl_object( RETVAL, ST(0) );
        XSRETURN(1);

void
DESTROY(THIS)
	lua_Debug * THIS;
    CODE:
        delete_oob_entry( THIS );
        Safefree(THIS);

int
event(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->event;
    OUTPUT:
	RETVAL

const char *
name(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->name;
    OUTPUT:
	RETVAL

const char *
namewhat(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->namewhat;
    OUTPUT:
	RETVAL

const char *
what(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->what;
    OUTPUT:
	RETVAL

const char *
source(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->source;
    OUTPUT:
	RETVAL

int
currentline(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->currentline;
    OUTPUT:
	RETVAL

int
nups(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->nups;
    OUTPUT:
	RETVAL

int
linedefined(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->linedefined;
    OUTPUT:
	RETVAL

int
lastlinedefined(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->lastlinedefined;
    OUTPUT:
	RETVAL

char *
short_src(THIS)
	lua_Debug * THIS
    PROTOTYPE: $
    CODE:
	RETVAL = THIS->short_src;
    OUTPUT:
	RETVAL

MODULE = Lua::API		PACKAGE = Lua::API::Buffer		PREFIX = luaL_

luaL_Buffer *
new(CLASS)
	char *CLASS = NO_INIT
    PROTOTYPE: $
    PPCODE:
        Newxz( RETVAL, 1, luaL_Buffer );
	ST(0) = sv_newmortal();
        sv_setref_iv(ST(0), "Lua::API::Buffer", PTR2IV(RETVAL));
	set_Perl_object( RETVAL, ST(0) );
        XSRETURN(1);

void
DESTROY(THIS)
	luaL_Buffer * THIS;
    CODE:
        delete_oob_entry( THIS );
        Safefree(THIS);


void
luaL_addchar(B, c)
	luaL_Buffer *	B
	char	c

void
luaL_addlstring(B, s, l)
	luaL_Buffer *	B
	const char *	s
	size_t	l

void
luaL_addsize(B, n)
	luaL_Buffer *	B
	size_t	n

void
luaL_addstring(B, s)
	luaL_Buffer *	B
	const char *	s

void
luaL_addvalue(B)
	luaL_Buffer *	B

char *
luaL_prepbuffer(B)
	luaL_Buffer *	B

void
luaL_pushresult(B)
	luaL_Buffer *	B



( run in 1.552 second using v1.01-cache-2.11-cpan-5511b514fd6 )