Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 8df1f68c03fb13119177b8e04be5dc8edd7a2047 0 parents
@tadzik authored
Showing with 67 additions and 0 deletions.
  1. +1 −0  README
  2. +1 −0  deps.proto
  3. +57 −0 lib/MPD.pm
  4. +8 −0 test.pl
1  README
@@ -0,0 +1 @@
+Don't get too excited, almost nothing works yet
1  deps.proto
@@ -0,0 +1 @@
+zavolaj
57 lib/MPD.pm
@@ -0,0 +1,57 @@
+use v6;
+use NativeCall;
+
+class MPD {
+ has $!conn;
+ method new(Str $host, Int $port) {
+ self.bless(*, :$host, :$port);
+ }
+ method current-song {
+ # TODO: a proper Song object
+ my $s = mpd_run_current_song($!conn);
+ my $ret = mpd_song_get_uri($s);
+ mpd_song_free($s);
+ return $ret;
+ }
+ 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') { ... }
+
+sub mpd_connection_free(OpaquePointer)
+ is native('libmpdclient') { ... }
+
+sub mpd_connection_get_error(OpaquePointer)
+ returns Int
+ is native('libmpdclient') { ... }
+
+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') { ... }
+
+sub mpd_run_current_song(OpaquePointer)
+ returns OpaquePointer
+ is native('libmpdclient') { ... }
+
+sub mpd_song_free(OpaquePointer)
+ is native('libmpdclient') { ... }
+
+sub mpd_song_get_uri(OpaquePointer)
+ returns Str
+ is native('libmpdclient') { ... }
+
+# vim: ft=perl6
8 test.pl
@@ -0,0 +1,8 @@
+use v6;
+
+BEGIN { @*INC.push: 'lib' }
+
+use MPD;
+
+my $a = MPD.new('localhost', 6600);
+say $a.current-song;
Please sign in to comment.
Something went wrong with that request. Please try again.