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

/src/Core/objects/Color.xs

http://github.com/PerlGameDev/SDL
Unknown | 73 lines | 61 code | 12 blank | 0 comment | 0 complexity | 46829ceeb8af5e7cf3e37d73bcfa8647 MD5 | raw file
 1#include "EXTERN.h"
 2#include "perl.h"
 3#include "XSUB.h"
 4#include "ppport.h"
 5#include "helper.h"
 6
 7#ifndef aTHX_
 8#define aTHX_
 9#endif
10
11#include <SDL.h>
12
13MODULE = SDL::Color 	PACKAGE = SDL::Color    PREFIX = color_
14
15=for documentation
16
17SDL_Color -- Format independent color description
18
19  typedef struct{
20    Uint8 r;
21    Uint8 g;
22    Uint8 b;
23    Uint8 unused;
24  } SDL_Color;
25
26=cut
27
28SDL_Color *
29color_new (CLASS, r, g, b )
30	char* CLASS
31	Uint8 r
32	Uint8 g
33	Uint8 b
34	CODE:
35		RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color));
36		RETVAL->r = r;
37		RETVAL->g = g;
38		RETVAL->b = b;
39	OUTPUT:
40		RETVAL
41
42Uint8
43color_r ( color, ... )
44	SDL_Color *color
45	CODE:
46		if (items > 1 ) color->r = SvIV(ST(1)); 
47		RETVAL = color->r;
48	OUTPUT:
49		RETVAL
50
51Uint8
52color_g ( color, ... )
53	SDL_Color *color
54	CODE:
55		if (items > 1 ) color->g = SvIV(ST(1)); 
56		RETVAL = color->g;
57	OUTPUT:
58		RETVAL
59
60Uint8
61color_b ( color, ... )
62	SDL_Color *color
63	CODE:
64		if (items > 1 ) color->b = SvIV(ST(1)); 
65		RETVAL = color->b;
66	OUTPUT:
67		RETVAL
68
69void
70color_DESTROY ( bag )
71	SV *bag
72	CODE:
73		objDESTROY(bag, safefree);