PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Core/objects/RWOps.xs

http://github.com/PerlGameDev/SDL
Unknown | 127 lines | 106 code | 21 blank | 0 comment | 0 complexity | 06dcf593c7ce3f815954b3ce7e33d82b MD5 | raw file
  1#include "EXTERN.h"
  2#include "perl.h"
  3#include "XSUB.h"
  4#include "ppport.h"
  5
  6#ifndef aTHX_
  7#define aTHX_
  8#endif
  9
 10#include <SDL.h>
 11
 12MODULE = SDL::RWOps 	PACKAGE = SDL::RWOps    PREFIX = rwops_
 13
 14=for documentation
 15
 16SDL_RWops -- Direct memory read write.
 17
 18=cut
 19
 20
 21SDL_RWops*
 22rwops_alloc (CLASS)
 23	char* CLASS
 24	CODE:
 25		RETVAL = SDL_AllocRW();
 26	OUTPUT:
 27	 	RETVAL
 28
 29
 30SDL_RWops*
 31rwops_new_file ( CLASS, file, mode )
 32	char* CLASS
 33	char* file
 34	char * mode
 35	CODE:
 36		RETVAL = SDL_RWFromFile(file,mode);
 37	OUTPUT:
 38		RETVAL
 39
 40SDL_RWops*
 41rwops_new_FP ( CLASS, fp, autoclose )
 42	char* CLASS
 43	FILE* fp
 44	int autoclose
 45	CODE:
 46		RETVAL = SDL_RWFromFP(fp,autoclose);
 47	OUTPUT:
 48		RETVAL
 49
 50SDL_RWops*
 51rwops_new_mem ( CLASS, mem, size )
 52	char* CLASS
 53	char* mem
 54	int size
 55	CODE:
 56		RETVAL = SDL_RWFromMem((void*)mem,size);
 57	OUTPUT:
 58		RETVAL
 59
 60SDL_RWops *
 61rwops_new_const_mem (CLASS, mem, ... )
 62	char* CLASS
 63	SV* mem
 64	CODE:
 65		STRLEN len;
 66		unsigned char *text = SvPV(mem, len);
 67		if(items > 2 && SvIOK(ST(2)))
 68			len = SvIV(ST(2));
 69		RETVAL = SDL_RWFromConstMem((const void*)text, len);
 70	OUTPUT:
 71		RETVAL
 72
 73int
 74rwops_seek ( rw, off, whence )
 75	SDL_RWops* rw
 76	int off
 77	int whence
 78	CODE:
 79		RETVAL = SDL_RWseek(rw,off,whence);
 80	OUTPUT:
 81		RETVAL
 82
 83int
 84rwops_tell ( rw )
 85	SDL_RWops* rw
 86	CODE:
 87		RETVAL = SDL_RWtell(rw);
 88	OUTPUT:
 89		RETVAL
 90
 91int
 92rwops_read ( rw, mem, size, n )
 93	SDL_RWops* rw
 94	char* mem
 95	int size
 96	int n
 97	CODE:
 98		RETVAL = SDL_RWread(rw,mem,size,n);
 99	OUTPUT:
100		RETVAL
101
102int
103rwops_write ( rw, mem, size, n )
104	SDL_RWops* rw
105	char* mem
106	int size
107	int n
108	CODE:
109		RETVAL = SDL_RWwrite(rw,mem,size,n);
110	OUTPUT:
111		RETVAL
112
113int
114rwops_close ( rw )
115	SDL_RWops* rw
116	CODE:
117		RETVAL = SDL_RWclose(rw);
118	OUTPUT:
119		RETVAL
120
121void
122rwops_free ( rw )
123	SDL_RWops* rw
124	CODE:
125		SDL_FreeRW(rw);
126
127