Skip to content
Browse files

Fix this and that for Rakudo nom

  • Loading branch information...
1 parent 1d1d117 commit 7b1137d4b41673c71b2dd8265e2f9321733acc7a @tadzik committed
Showing with 26 additions and 27 deletions.
  1. +0 −1 deps.proto
  2. +26 −26 lib/MPD.pm
View
1 deps.proto
@@ -1 +0,0 @@
-zavolaj
View
52 lib/MPD.pm
@@ -2,10 +2,22 @@ use v6;
use NativeCall;
class MPD {
- has $!conn;
+ class Connection is repr('CPointer') {};
+ class Song is repr('CPointer') {};
+ class Status is repr('CPointer') {};
+
+ has OpaquePointer $!conn;
+
method new(Str $host, Int $port) {
- self.bless(*, :$host, :$port);
+ my $conn = mpd_connection_new($host, $port);
+ if mpd_connection_get_error($conn) {
+ die mpd_connection_get_error_message($conn);
+ }
+ self.bless(*, :$conn);
}
+
+ submethod BUILD (:$!conn) {}
+
method current-song {
# TODO: a proper Song object
my $s = mpd_run_current_song($!conn);
@@ -14,66 +26,54 @@ class MPD {
mpd_song_free($s);
return $ret;
}
+
method state {
my $s = mpd_run_status($!conn);
my $r = mpd_status_get_state($s);
mpd_status_free($s);
return <unknown stop play pause>[$r];
}
- submethod BUILD(Str $host, Int $port) {
- $!conn = mpd_connection_new($host, $port);
- if mpd_connection_get_error($!conn) {
- die mpd_connection_get_error_message($!conn);
- }
- }
- submethod DESTROY {
- mpd_connection_free($!obj);
- }
}
sub mpd_connection_new(Str $host, Int $port)
returns OpaquePointer
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_connection_free(OpaquePointer)
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_connection_get_error(OpaquePointer)
returns Int
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_connection_get_error_message(OpaquePointer)
returns Str
- is native('libmpdclient') { ... }
-
-sub mpd_connection_get_server_version(OpaquePointer) # FIXME
- returns Positional of Int
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_run_current_song(OpaquePointer)
returns OpaquePointer
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_song_free(OpaquePointer)
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_song_get_uri(OpaquePointer)
returns Str
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_song_get_id(OpaquePointer)
returns Int
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_run_status(OpaquePointer)
returns OpaquePointer
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_status_free(OpaquePointer)
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
sub mpd_status_get_state(OpaquePointer)
returns Int
- is native('libmpdclient') { ... }
+ is native('libmpdclient.so') { ... }
# vim: ft=perl6

0 comments on commit 7b1137d

Please sign in to comment.
Something went wrong with that request. Please try again.