PageRenderTime 51ms CodeModel.GetById 48ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Core/Time.xs

http://github.com/PerlGameDev/SDL
Unknown | 57 lines | 44 code | 13 blank | 0 comment | 0 complexity | 57a12194615c6f5034a375f2807b0544 MD5 | raw file
 1#include "EXTERN.h"
 2#include "perl.h"
 3#include "XSUB.h"
 4#include "ppport.h"
 5#include "defines.h"
 6
 7#include <SDL.h>
 8
 9Uint32 add_timer_cb (Uint32 interval, void* param )
10{
11	Uint32 ret_interval;
12	ENTER_TLS_CONTEXT;
13	dSP;
14
15	int count;
16
17	ENTER;
18	SAVETMPS;
19	PUSHMARK(SP);
20	XPUSHs(sv_2mortal(newSViv(interval)));
21	PUTBACK;
22
23	count = call_pv(param,G_SCALAR);
24
25	SPAGAIN;
26
27	if (count != 1 ) croak("callback returned more than 1 value\n");	
28		ret_interval = POPi;
29
30	PUTBACK;
31	FREETMPS;
32	LEAVE;
33	LEAVE_TLS_CONTEXT;
34
35	return ret_interval;
36}
37
38MODULE = SDL::Time 	PACKAGE = SDL::Time    PREFIX = time_
39
40SDL_TimerID
41time_add_timer ( interval, cmd )
42	Uint32 interval
43	char *cmd
44	CODE:
45		GET_TLS_CONTEXT;
46		RETVAL = SDL_AddTimer(interval, add_timer_cb, (void *)cmd);
47	OUTPUT:
48		RETVAL
49
50int
51time_remove_timer ( id)
52	SDL_TimerID id
53	CODE:
54		RETVAL = SDL_RemoveTimer((SDL_TimerID) id);
55	OUTPUT:
56		RETVAL
57