Permalink
Browse files

Wrap SDL_version

  • Loading branch information...
acme committed Nov 3, 2009
1 parent bfb478a commit ce88b52ff6ee5cc7c7a7e30d06f9253836cad31a
Showing with 107 additions and 3 deletions.
  1. +7 −0 Build.PL
  2. +9 −0 lib/SDL/Version.pm
  3. +49 −0 src/Core/objects/Version.xs
  4. +21 −0 src/SDL.xs
  5. +0 −3 t/core.t
  6. +20 −0 t/core_version.t
  7. +1 −0 typemap
View
@@ -114,6 +114,13 @@ my %subsystems =
},
libraries => [qw( SDL SDL_ttf )],
},
+ Version => {
+ file => {
+ from => 'src/Core/objects/Version.xs',
+ to => 'lib/SDL/Version.xs',
+ },
+ libraries => [qw( SDL )],
+ },
OpenGL => {
file => {
from => 'src/OpenGL.xs',
View
@@ -0,0 +1,9 @@
+package SDL::Version;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Version;
+
+1;
@@ -0,0 +1,49 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+#include <SDL_version.h>
+
+MODULE = SDL::Version PACKAGE = SDL::Version PREFIX = version_
+
+=for documentation
+
+SDL_Version -- Version structure
+
+ typedef struct SDL_version {
+ Uint8 major;
+ Uint8 minor;
+ Uint8 patch;
+ } SDL_version;
+
+=cut
+
+Uint8
+version_major ( version, ... )
+ SDL_version *version
+ CODE:
+ RETVAL = version->major;
+ OUTPUT:
+ RETVAL
+
+Uint8
+version_minor ( version, ... )
+ SDL_version *version
+ CODE:
+ RETVAL = version->minor;
+ OUTPUT:
+ RETVAL
+
+Uint8
+version_patch ( version, ... )
+ SDL_version *version
+ CODE:
+ RETVAL = version->patch;
+ OUTPUT:
+ RETVAL
+
View
@@ -308,6 +308,27 @@ was_init ( flags )
OUTPUT:
RETVAL
+SDL_version *
+version ()
+ PREINIT:
+ char * CLASS = "SDL::Version";
+ SDL_version *version;
+ CODE:
+ version = (SDL_version *) safemalloc (sizeof(SDL_version));
+ SDL_VERSION(version);
+ RETVAL = version;
+ OUTPUT:
+ RETVAL
+
+SDL_version *
+linked_version ()
+ PREINIT:
+ char * CLASS = "SDL::Version";
+ CODE:
+ RETVAL = (SDL_version *) SDL_Linked_Version();
+ OUTPUT:
+ RETVAL
+
void
delay ( ms )
int ms
View
@@ -39,9 +39,6 @@ my @left = qw/
unload_fuction
unload_object
envvars
- linked_version
- version
- Version
/;
my $why = '[Percentage Completion] '.int( 100 * $#done / ($#done + $#left) ) ."\% implementation. $#done / ".($#done+$#left);
View
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+use strict;
+use SDL;
+use SDL::Version;
+use Test::More tests => 8;
+
+my $version = SDL::version();
+isa_ok( $version, 'SDL::Version' );
+like( $version->major, qr/^\d+$/, 'Compile-time version major is a number' );
+like( $version->minor, qr/^\d+$/, 'Compile-time version minor is a number' );
+like( $version->patch, qr/^\d+$/, 'Compile-time version patch is a number' );
+
+my $linked_version = SDL::linked_version();
+isa_ok( $linked_version, 'SDL::Version' );
+like( $linked_version->major, qr/^\d+$/,
+ 'Link-time version major is a number' );
+like( $linked_version->minor, qr/^\d+$/,
+ 'Link-time version minor is a number' );
+like( $linked_version->patch, qr/^\d+$/,
+ 'Link-time version patch is a number' );
View
@@ -24,6 +24,7 @@ SDL_Color * O_OBJECT
SDL_Palette * O_OBJECT
SDL_PixelFormat * O_OBJECT
SDL_VideoInfo * O_OBJECT
+SDL_version * O_OBJECT
SDL_Cursor * T_PTR
SDL_AudioSpec * T_PTR
SDL_AudioCVT * T_PTR

0 comments on commit ce88b52

Please sign in to comment.