Skip to content

Commit

Permalink
get rid of unpacking SDL_version struct by ourself
Browse files Browse the repository at this point in the history
NativeCall supports this since a while very nicely, so just use it.
  • Loading branch information
FROGGS committed Jul 5, 2014
1 parent cea398a commit 02722b7
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/SDL.pm6
Expand Up @@ -5,19 +5,11 @@ use NativeCall;

constant SDL_INIT_VIDEO = 32;

class SDL::Version is repr('CStruct') {
# this is a workaround, since NativeCall doesn't yet handle sized ints right
has int8 $!version;
method major() {
return $!version +& 0xFF;
}
method minor() {
return ($!version +& 0xFF00) +> 8;
}
method patch() {
return ($!version +& 0xFF0000) +> 16;
}
}
class SDL::Version is repr('CStruct') { # typedef struct {
has uint8 $.major; # Uint8 major;
has uint8 $.minor; # Uint8 minor;
has uint8 $.patch; # Uint8 patch;
} # } SDL_version;

=begin pod
Expand Down

0 comments on commit 02722b7

Please sign in to comment.