Code::Blocks  SVN r11506
Classes | Macros | Functions | Variables
sqstdio.cpp File Reference
#include <new>
#include <stdio.h>
#include <squirrel.h>
#include <sqstdio.h>
#include "sqstdstream.h"
Include dependency graph for sqstdio.cpp:

Go to the source code of this file.

Classes

struct  SQFile
 

Macros

#define SQSTD_FILE_TYPE_TAG   (SQSTD_STREAM_TYPE_TAG | 0x00000001)
 
#define _DECL_FILE_FUNC(name, nparams, typecheck)   {_SC(#name),_file_##name,nparams,typecheck}
 
#define READ()
 
#define _DECL_GLOBALIO_FUNC(name, nparams, typecheck)   {_SC(#name),_g_io_##name,nparams,typecheck}
 

Functions

SQFILE sqstd_fopen (const SQChar *filename, const SQChar *mode)
 
SQInteger sqstd_fread (void *buffer, SQInteger size, SQInteger count, SQFILE file)
 
SQInteger sqstd_fwrite (const SQUserPointer buffer, SQInteger size, SQInteger count, SQFILE file)
 
SQInteger sqstd_fseek (SQFILE file, SQInteger offset, SQInteger origin)
 
SQInteger sqstd_ftell (SQFILE file)
 
SQInteger sqstd_fflush (SQFILE file)
 
SQInteger sqstd_fclose (SQFILE file)
 
SQInteger sqstd_feof (SQFILE file)
 
static SQInteger _file__typeof (HSQUIRRELVM v)
 
static SQInteger _file_releasehook (SQUserPointer p, SQInteger)
 
static SQInteger _file_constructor (HSQUIRRELVM v)
 
SQRESULT sqstd_createfile (HSQUIRRELVM v, SQFILE file, SQBool own)
 
SQRESULT sqstd_getfile (HSQUIRRELVM v, SQInteger idx, SQFILE *file)
 
static SQInteger _io_file_lexfeed_ASCII (SQUserPointer file)
 
static SQInteger _io_file_lexfeed_UTF8 (SQUserPointer file)
 
static SQInteger _io_file_lexfeed_UCS2_LE (SQUserPointer file)
 
static SQInteger _io_file_lexfeed_UCS2_BE (SQUserPointer file)
 
SQInteger file_read (SQUserPointer file, SQUserPointer buf, SQInteger size)
 
SQInteger file_write (SQUserPointer file, SQUserPointer p, SQInteger size)
 
SQRESULT sqstd_loadfile (HSQUIRRELVM v, const SQChar *filename, SQBool printerror)
 
SQRESULT sqstd_dofile (HSQUIRRELVM v, const SQChar *filename, SQBool retval, SQBool printerror)
 
SQRESULT sqstd_writeclosuretofile (HSQUIRRELVM v, const SQChar *filename)
 
SQInteger _g_io_loadfile (HSQUIRRELVM v)
 
SQInteger _g_io_writeclosuretofile (HSQUIRRELVM v)
 
SQInteger _g_io_dofile (HSQUIRRELVM v)
 
SQRESULT sqstd_register_iolib (HSQUIRRELVM v)
 

Variables

static SQRegFunction _file_methods []
 
static SQRegFunction iolib_funcs []
 

Macro Definition Documentation

◆ _DECL_FILE_FUNC

#define _DECL_FILE_FUNC (   name,
  nparams,
  typecheck 
)    {_SC(#name),_file_##name,nparams,typecheck}

Definition at line 152 of file sqstdio.cpp.

◆ _DECL_GLOBALIO_FUNC

#define _DECL_GLOBALIO_FUNC (   name,
  nparams,
  typecheck 
)    {_SC(#name),_g_io_##name,nparams,typecheck}

Definition at line 387 of file sqstdio.cpp.

◆ READ

#define READ ( )
Value:
if(sqstd_fread(&inchar,sizeof(inchar),1,(FILE *)file) != 1) \
return 0;
SQInteger sqstd_fread(void *buffer, SQInteger size, SQInteger count, SQFILE file)
Definition: sqstdio.cpp:19

Referenced by _io_file_lexfeed_UTF8().

◆ SQSTD_FILE_TYPE_TAG

#define SQSTD_FILE_TYPE_TAG   (SQSTD_STREAM_TYPE_TAG | 0x00000001)

Definition at line 8 of file sqstdio.cpp.

Referenced by sqstd_getfile(), and sqstd_register_iolib().

Function Documentation

◆ _file__typeof()

static SQInteger _file__typeof ( HSQUIRRELVM  v)
static

Definition at line 111 of file sqstdio.cpp.

References sq_pushstring().

◆ _file_constructor()

static SQInteger _file_constructor ( HSQUIRRELVM  v)
static

◆ _file_releasehook()

static SQInteger _file_releasehook ( SQUserPointer  p,
SQInteger   
)
static

Definition at line 118 of file sqstdio.cpp.

Referenced by _file_constructor().

◆ _g_io_dofile()

SQInteger _g_io_dofile ( HSQUIRRELVM  v)

Definition at line 373 of file sqstdio.cpp.

References sq_getbool(), sq_getstring(), sq_gettop(), sq_push(), and sqstd_dofile().

◆ _g_io_loadfile()

SQInteger _g_io_loadfile ( HSQUIRRELVM  v)

Definition at line 351 of file sqstdio.cpp.

References sq_getbool(), sq_getstring(), sq_gettop(), and sqstd_loadfile().

◆ _g_io_writeclosuretofile()

SQInteger _g_io_writeclosuretofile ( HSQUIRRELVM  v)

Definition at line 364 of file sqstdio.cpp.

References sq_getstring(), and sqstd_writeclosuretofile().

◆ _io_file_lexfeed_ASCII()

static SQInteger _io_file_lexfeed_ASCII ( SQUserPointer  file)
static

Definition at line 197 of file sqstdio.cpp.

References sqstd_fread().

Referenced by sqstd_loadfile().

◆ _io_file_lexfeed_UCS2_BE()

static SQInteger _io_file_lexfeed_UCS2_BE ( SQUserPointer  file)
static

Definition at line 252 of file sqstdio.cpp.

References sqstd_fread().

Referenced by sqstd_loadfile().

◆ _io_file_lexfeed_UCS2_LE()

static SQInteger _io_file_lexfeed_UCS2_LE ( SQUserPointer  file)
static

Definition at line 243 of file sqstdio.cpp.

References sqstd_fread().

Referenced by sqstd_loadfile().

◆ _io_file_lexfeed_UTF8()

static SQInteger _io_file_lexfeed_UTF8 ( SQUserPointer  file)
static

Definition at line 206 of file sqstdio.cpp.

References READ.

Referenced by sqstd_loadfile().

◆ file_read()

SQInteger file_read ( SQUserPointer  file,
SQUserPointer  buf,
SQInteger  size 
)

Definition at line 263 of file sqstdio.cpp.

References sqstd_fread().

Referenced by sqstd_loadfile().

◆ file_write()

SQInteger file_write ( SQUserPointer  file,
SQUserPointer  p,
SQInteger  size 
)

Definition at line 270 of file sqstdio.cpp.

References sqstd_fwrite().

Referenced by sqstd_writeclosuretofile().

◆ sqstd_createfile()

SQRESULT sqstd_createfile ( HSQUIRRELVM  v,
SQFILE  file,
SQBool  own 
)

◆ sqstd_dofile()

SQRESULT sqstd_dofile ( HSQUIRRELVM  v,
const SQChar filename,
SQBool  retval,
SQBool  printerror 
)

Definition at line 326 of file sqstdio.cpp.

References sq_call(), sq_pop(), sq_push(), sq_remove(), and sqstd_loadfile().

Referenced by _g_io_dofile().

◆ sqstd_fclose()

SQInteger sqstd_fclose ( SQFILE  file)

Definition at line 51 of file sqstdio.cpp.

Referenced by SQFile::Close(), sqstd_loadfile(), and sqstd_writeclosuretofile().

◆ sqstd_feof()

SQInteger sqstd_feof ( SQFILE  file)

Definition at line 56 of file sqstdio.cpp.

◆ sqstd_fflush()

SQInteger sqstd_fflush ( SQFILE  file)

Definition at line 46 of file sqstdio.cpp.

Referenced by SQFile::Flush().

◆ sqstd_fopen()

SQFILE sqstd_fopen ( const SQChar filename,
const SQChar mode 
)

◆ sqstd_fread()

SQInteger sqstd_fread ( void *  buffer,
SQInteger  size,
SQInteger  count,
SQFILE  file 
)

◆ sqstd_fseek()

SQInteger sqstd_fseek ( SQFILE  file,
SQInteger  offset,
SQInteger  origin 
)

Definition at line 29 of file sqstdio.cpp.

Referenced by SQFile::Seek(), and sqstd_loadfile().

◆ sqstd_ftell()

SQInteger sqstd_ftell ( SQFILE  file)

Definition at line 41 of file sqstdio.cpp.

Referenced by SQFile::Tell().

◆ sqstd_fwrite()

SQInteger sqstd_fwrite ( const SQUserPointer  buffer,
SQInteger  size,
SQInteger  count,
SQFILE  file 
)

Definition at line 24 of file sqstdio.cpp.

Referenced by file_write(), and SQFile::Write().

◆ sqstd_getfile()

SQRESULT sqstd_getfile ( HSQUIRRELVM  v,
SQInteger  idx,
SQFILE *  file 
)

Definition at line 185 of file sqstdio.cpp.

References NULL, sq_getinstanceup(), sq_throwerror(), and SQSTD_FILE_TYPE_TAG.

◆ sqstd_loadfile()

SQRESULT sqstd_loadfile ( HSQUIRRELVM  v,
const SQChar filename,
SQBool  printerror 
)

◆ sqstd_register_iolib()

SQRESULT sqstd_register_iolib ( HSQUIRRELVM  v)

◆ sqstd_writeclosuretofile()

SQRESULT sqstd_writeclosuretofile ( HSQUIRRELVM  v,
const SQChar filename 
)

Variable Documentation

◆ _file_methods

SQRegFunction _file_methods[]
static
Initial value:
= {
_DECL_FILE_FUNC(constructor,3,_SC("x")),
_DECL_FILE_FUNC(_typeof,1,_SC("x")),
{0,0,0,0},
}
#define _DECL_FILE_FUNC(name, nparams, typecheck)
Definition: sqstdio.cpp:152

Definition at line 153 of file sqstdio.cpp.

Referenced by sqstd_register_iolib().

◆ iolib_funcs

SQRegFunction iolib_funcs[]
static
Initial value:
={
_DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")),
{0,0}
}
#define _DECL_GLOBALIO_FUNC(name, nparams, typecheck)
Definition: sqstdio.cpp:387

Definition at line 388 of file sqstdio.cpp.

Referenced by sqstd_register_iolib().