Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make the code a bit better encapsulated

Lexicalise native subs inside the classes wrapping them, remove toggle from the
Connection class since it's not actually an API call
  • Loading branch information...
commit 06e182bb5b15dbd68c4d19127807ee6443799c9d 1 parent 222fc1a
Anthony Parsons authored
10 lib/XMMS2/Client.pm6
View
@@ -2,7 +2,7 @@ use v6;
use XMMS2::Connection;
#####
-# The user-interfaceable part
+# A bit of syntactic sugar over the raw API
class XMMS2::Client {
has XMMS2::Connection $!connection;
@@ -22,14 +22,14 @@ class XMMS2::Client {
return ?$!connection.playback_pause;
}
- method toggle returns Bool {
- return ?$!connection.playback_toggle;
- }
-
method stop returns Bool {
return ?$!connection.playback_stop;
}
+ method toggle returns Bool {
+ ???
+ }
+
method prev returns Bool {
???
}
36 lib/XMMS2/Connection.pm6
View
@@ -8,14 +8,13 @@ class XMMS2::Connection is repr('CPointer') {
#= All commands sent to the server return a result handle (xmmsc_result_t)
my class Result is repr('CPointer') {
#= Blocks until a command completes
- sub xmmsc_result_wait(Result)
+ my sub xmmsc_result_wait(Result)
is native('libxmmsclient.so') { ... }
- sub xmmsc_result_get_value(Result)
- returns XMMS2::Value
+ my sub xmmsc_result_get_value(Result) returns XMMS2::Value
is native('libxmmsclient.so') { ... }
- sub xmmsc_result_unref(Result)
+ my sub xmmsc_result_unref(Result)
is native('libxmmsclient.so') { ... }
#= Returns false if this result contains an error status
@@ -39,35 +38,28 @@ class XMMS2::Connection is repr('CPointer') {
}
# Native functions for Connection
- sub xmmsc_playback_stop(XMMS2::Connection)
- returns Result
+ my sub xmmsc_init(Str $client-name) returns XMMS2::Connection
is native('libxmmsclient.so') { ... }
- sub xmmsc_playback_start(XMMS2::Connection)
- returns Result
+ my sub xmmsc_connect(XMMS2::Connection, Str $path) returns Int
is native('libxmmsclient.so') { ... }
- sub xmmsc_playback_pause(XMMS2::Connection)
- returns Result
+ my sub xmmsc_get_last_error(XMMS2::Connection) returns Str
is native('libxmmsclient.so') { ... }
- sub xmmsc_playback_current_id(XMMS2::Connection)
- returns Result
+ my sub xmmsc_playback_stop(XMMS2::Connection) returns Result
is native('libxmmsclient.so') { ... }
- sub xmmsc_init(Str $client-name)
- returns XMMS2::Connection
+ my sub xmmsc_playback_start(XMMS2::Connection) returns Result
is native('libxmmsclient.so') { ... }
- sub xmmsc_connect(XMMS2::Connection, Str $path)
- returns Int
+ my sub xmmsc_playback_pause(XMMS2::Connection) returns Result
is native('libxmmsclient.so') { ... }
- sub xmmsc_unref(XMMS2::Connection)
+ my sub xmmsc_playback_current_id(XMMS2::Connection) returns Result
is native('libxmmsclient.so') { ... }
- sub xmmsc_get_last_error(XMMS2::Connection)
- returns Str
+ my sub xmmsc_unref(XMMS2::Connection)
is native('libxmmsclient.so') { ... }
method open(Str $client-name, Str $path?) returns XMMS2::Connection {
@@ -98,12 +90,6 @@ class XMMS2::Connection is repr('CPointer') {
return xmmsc_playback_current_id(self);
}
- method playback_toggle returns Result {
- return ???
- ?? self.playback_pause();
- !! self.playback_start();
- }
-
submethod DESTROY {
xmmsc_unref(self);
}
9 lib/XMMS2/Value.pm6
View
@@ -3,16 +3,13 @@ use NativeCall;
#= XMMS2 value struct xmmsv_t, which is more or less a typeless scalar
class XMMS2::Value is repr('CPointer') {
- sub xmmsv_is_error(XMMS2::Value)
- returns Int
+ my sub xmmsv_is_error(XMMS2::Value) returns Int
is native('libxmmsclient.so') { ... }
- sub xmmsv_get_error(XMMS2::Value, Str $error is rw)
- returns Int
+ my sub xmmsv_get_error(XMMS2::Value, Str $error is rw) returns Int
is native('libxmmsclient.so') { ... }
- sub xmmsv_get_int(XMMS2::Value, Int $value is rw)
- returns Int
+ my sub xmmsv_get_int(XMMS2::Value, Int $value is rw) returns Int
is native('libxmmsclient.so') { ... }
#= Returns false if this is an error value
Please sign in to comment.
Something went wrong with that request. Please try again.