spotify 7.0.3 → 7.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ -e ./lib/yard-ffi.rb
@@ -3,23 +3,25 @@ require 'ffi'
3
3
  require 'spotify/version'
4
4
 
5
5
  # FFI wrapper around libspotify.
6
- #
6
+ #
7
7
  # See official documentation for more detailed documentation about
8
8
  # functions and their behavior.
9
- #
9
+ #
10
10
  # @see http://developer.spotify.com/en/libspotify/docs/
11
11
  module Spotify
12
12
  extend FFI::Library
13
13
  ffi_lib ['libspotify', '/Library/Frameworks/libspotify.framework/libspotify']
14
-
14
+
15
15
  # libspotify API version
16
16
  # @return [Fixnum]
17
17
  API_VERSION = VERSION.split('.').first.to_i
18
-
18
+
19
19
  #
20
20
  # Error
21
- #
21
+ #
22
22
  # @see http://developer.spotify.com/en/libspotify/docs/group__error.html
23
+
24
+ #
23
25
  enum :error, [:ok, :bad_api_version, :api_initialization_failed,
24
26
  :track_not_playable, :resource_not_loaded,
25
27
  :bad_application_key, :bad_username_or_password,
@@ -30,18 +32,20 @@ module Spotify
30
32
  :other_transient, :is_loading, :no_stream_available,
31
33
  :permission_denied, :inbox_is_full, :no_cache,
32
34
  :no_such_user]
33
-
35
+
34
36
  attach_function :error_message, :sp_error_message, [ :error ], :string
35
-
37
+
36
38
  #
37
39
  # Audio
38
- #
40
+ #
39
41
  # @see http://developer.spotify.com/en/libspotify/docs/group__session.html
42
+
43
+ #
40
44
  enum :sampletype, [:int16_native_endian]
41
45
  enum :bitrate, %w(160k 320k)
42
-
46
+
43
47
  # FFI::Struct for Audio Format.
44
- #
48
+ #
45
49
  # @attr [:sampletype] sample_type
46
50
  # @attr [Fixnum] sample_rate
47
51
  # @attr [Fixnum] channels
@@ -52,18 +56,20 @@ module Spotify
52
56
  end
53
57
 
54
58
  # FFI::Struct for Audio Buffer Stats.
55
- #
59
+ #
56
60
  # @attr [Fixnum] samples
57
61
  # @attr [Fixnum] stutter
58
62
  class AudioBufferStats < FFI::Struct
59
63
  layout :samples, :int,
60
64
  :stutter, :int
61
65
  end
62
-
66
+
63
67
  #
64
68
  # Session
65
- #
69
+ #
66
70
  # @see http://developer.spotify.com/en/libspotify/docs/group__session.html
71
+
72
+ #
67
73
  enum :connectionstate, [:logged_out, :logged_in, :disconnected, :undefined]
68
74
 
69
75
  attach_function :session_create, :sp_session_create, [ :pointer, :pointer ], :error
@@ -90,7 +96,7 @@ module Spotify
90
96
  attach_function :session_friend, :sp_session_friend, [ :pointer, :int ], :pointer
91
97
 
92
98
  # FFI::Struct for Session callbacks.
93
- #
99
+ #
94
100
  # @attr [callback(:pointer, :error):void] logged_in
95
101
  # @attr [callback(:pointer):void] logged_out
96
102
  # @attr [callback(:pointer):void] metadata_updated
@@ -125,7 +131,7 @@ module Spotify
125
131
  end
126
132
 
127
133
  # FFI::Struct for Session configuration.
128
- #
134
+ #
129
135
  # @attr [Fixnum] api_version
130
136
  # @attr [Pointer] cache_location
131
137
  # @attr [Pointer] settings_location
@@ -146,13 +152,15 @@ module Spotify
146
152
  :userdata, :pointer,
147
153
  :compress_playlists, :int,
148
154
  :dont_save_metadata_for_playlists, :int,
149
- :initially_unload_playlists, :int
155
+ :initially_unload_playlists, :int
150
156
  end
151
-
157
+
152
158
  #
153
159
  # Link
154
- #
160
+ #
155
161
  # @see http://developer.spotify.com/en/libspotify/docs/group__link.html
162
+
163
+ #
156
164
  enum :linktype, [:invalid, :track, :album, :artist, :search,
157
165
  :playlist, :profile, :starred, :localtrack]
158
166
 
@@ -172,11 +180,13 @@ module Spotify
172
180
  attach_function :link_as_user, :sp_link_as_user, [ :pointer ], :pointer
173
181
  attach_function :link_add_ref, :sp_link_add_ref, [ :pointer ], :void
174
182
  attach_function :link_release, :sp_link_release, [ :pointer ], :void
175
-
183
+
176
184
  #
177
185
  # Tracks
178
- #
186
+ #
179
187
  # @see http://developer.spotify.com/en/libspotify/docs/group__track.html
188
+
189
+ #
180
190
  attach_function :track_is_loaded, :sp_track_is_loaded, [ :pointer ], :bool
181
191
  attach_function :track_error, :sp_track_error, [ :pointer ], :error
182
192
  attach_function :track_is_available, :sp_track_is_available, [ :pointer, :pointer ], :bool
@@ -195,11 +205,13 @@ module Spotify
195
205
  attach_function :localtrack_create, :sp_localtrack_create, [ :string, :string, :string, :int ], :pointer
196
206
  attach_function :track_add_ref, :sp_track_add_ref, [ :pointer ], :void
197
207
  attach_function :track_release, :sp_track_release, [ :pointer ], :void
198
-
208
+
199
209
  #
200
210
  # Albums
201
- #
211
+ #
202
212
  # @see http://developer.spotify.com/en/libspotify/docs/group__album.html
213
+
214
+ #
203
215
  enum :albumtype, [:album, :single, :compilation, :unknown]
204
216
 
205
217
  attach_function :album_is_loaded, :sp_album_is_loaded, [ :pointer ], :bool
@@ -211,11 +223,13 @@ module Spotify
211
223
  attach_function :album_type, :sp_album_type, [ :pointer ], :albumtype
212
224
  attach_function :album_add_ref, :sp_album_add_ref, [ :pointer ], :void
213
225
  attach_function :album_release, :sp_album_release, [ :pointer ], :void
214
-
226
+
215
227
  #
216
228
  # Album Browser
217
- #
229
+ #
218
230
  # @see http://developer.spotify.com/en/libspotify/docs/group__albumbrowse.html
231
+
232
+ #
219
233
  attach_function :albumbrowse_create, :sp_albumbrowse_create, [ :pointer, :pointer, callback([:pointer, :pointer], :void), :pointer ], :pointer
220
234
  attach_function :albumbrowse_is_loaded, :sp_albumbrowse_is_loaded, [ :pointer ], :bool
221
235
  attach_function :albumbrowse_error, :sp_albumbrowse_error, [ :pointer ], :error
@@ -228,20 +242,24 @@ module Spotify
228
242
  attach_function :albumbrowse_review, :sp_albumbrowse_review, [ :pointer ], :string
229
243
  attach_function :albumbrowse_add_ref, :sp_albumbrowse_add_ref, [ :pointer ], :void
230
244
  attach_function :albumbrowse_release, :sp_albumbrowse_release, [ :pointer ], :void
231
-
245
+
232
246
  #
233
247
  # Artists
234
- #
248
+ #
235
249
  # @see http://developer.spotify.com/en/libspotify/docs/group__artist.html
250
+
251
+ #
236
252
  attach_function :artist_name, :sp_artist_name, [ :pointer ], :string
237
253
  attach_function :artist_is_loaded, :sp_artist_is_loaded, [ :pointer ], :bool
238
254
  attach_function :artist_add_ref, :sp_artist_add_ref, [ :pointer ], :void
239
255
  attach_function :artist_release, :sp_artist_release, [ :pointer ], :void
240
-
256
+
241
257
  #
242
258
  # Artist Browsing
243
- #
259
+ #
244
260
  # @see http://developer.spotify.com/en/libspotify/docs/group__artistbrowse.html
261
+
262
+ #
245
263
  attach_function :artistbrowse_create, :sp_artistbrowse_create, [ :pointer, :pointer, callback([:pointer, :pointer], :void), :pointer ], :pointer
246
264
  attach_function :artistbrowse_is_loaded, :sp_artistbrowse_is_loaded, [ :pointer ], :bool
247
265
  attach_function :artistbrowse_error, :sp_artistbrowse_error, [ :pointer ], :error
@@ -257,11 +275,13 @@ module Spotify
257
275
  attach_function :artistbrowse_biography, :sp_artistbrowse_biography, [ :pointer ], :string
258
276
  attach_function :artistbrowse_add_ref, :sp_artistbrowse_add_ref, [ :pointer ], :void
259
277
  attach_function :artistbrowse_release, :sp_artistbrowse_release, [ :pointer ], :void
260
-
278
+
261
279
  #
262
280
  # Images
263
- #
281
+ #
264
282
  # @see http://developer.spotify.com/en/libspotify/docs/group__image.html
283
+
284
+ #
265
285
  enum :imageformat, [:unknown, -1, :jpeg]
266
286
 
267
287
  callback :image_loaded, [ :pointer, :pointer ], :void
@@ -272,14 +292,16 @@ module Spotify
272
292
  attach_function :image_error, :sp_image_error, [ :pointer ], :error
273
293
  attach_function :image_format, :sp_image_format, [ :pointer ], :imageformat
274
294
  attach_function :image_data, :sp_image_data, [ :pointer, :pointer ], :pointer
275
- attach_function :image_image_id, :sp_image_image_id, [ :pointer ], :pointer # string?
295
+ attach_function :image_image_id, :sp_image_image_id, [ :pointer ], :pointer
276
296
  attach_function :image_add_ref, :sp_image_add_ref, [ :pointer ], :void
277
297
  attach_function :image_release, :sp_image_release, [ :pointer ], :void
278
-
298
+
279
299
  #
280
300
  # Searching
281
- #
301
+ #
282
302
  # @see http://developer.spotify.com/en/libspotify/docs/group__search.html
303
+
304
+ #
283
305
  enum :radio_genre, [
284
306
  :alt_pop_rock, 0x1,
285
307
  :blues , 0x2,
@@ -301,7 +323,6 @@ module Spotify
301
323
  :techno , 0x20000
302
324
  ]
303
325
 
304
-
305
326
  attach_function :search_create, :sp_search_create, [ :pointer, :string, :int, :int, :int, :int, :int, :int, callback([:pointer, :pointer], :void), :pointer ], :pointer
306
327
  attach_function :radio_search_create, :sp_radio_search_create, [ :pointer, :uint, :uint, :radio_genre, :pointer, :pointer ], :pointer
307
328
  attach_function :search_is_loaded, :sp_search_is_loaded, [ :pointer ], :bool
@@ -319,11 +340,13 @@ module Spotify
319
340
  attach_function :search_total_artists, :sp_search_total_artists, [ :pointer ], :int
320
341
  attach_function :search_add_ref, :sp_search_add_ref, [ :pointer ], :void
321
342
  attach_function :search_release, :sp_search_release, [ :pointer ], :void
322
-
343
+
323
344
  #
324
345
  # Playlists
325
- #
346
+ #
326
347
  # @see http://developer.spotify.com/en/libspotify/docs/group__playlist.html
348
+
349
+ #
327
350
  enum :playlist_type, [:playlist, :start_folder, :end_folder, :placeholder]
328
351
 
329
352
  attach_function :playlist_is_loaded, :sp_playlist_is_loaded, [ :pointer ], :bool
@@ -359,7 +382,7 @@ module Spotify
359
382
  attach_function :playlist_release, :sp_playlist_release, [ :pointer ], :void
360
383
 
361
384
  # FFI::Struct for Playlist callbacks.
362
- #
385
+ #
363
386
  # @attr [callback(:pointer, :pointer, :int, :int, :pointer):void] tracks_added
364
387
  # @attr [callback(:pointer, :pointer, :int, :pointer):void] tracks_removed
365
388
  # @attr [callback(:pointer, :pointer, :int, :int, :pointer):void] tracks_moved
@@ -390,7 +413,7 @@ module Spotify
390
413
  end
391
414
 
392
415
  # FFI::Struct for Subscribers of a Playlist.
393
- #
416
+ #
394
417
  # @attr [Fixnum] count
395
418
  # @attr [Pointer<String>] subscribers
396
419
  class Subscribers < FFI::Struct
@@ -400,8 +423,9 @@ module Spotify
400
423
 
401
424
  #
402
425
  # Playlist Container
403
- #
426
+ #
404
427
 
428
+ #
405
429
  attach_function :playlistcontainer_add_callbacks, :sp_playlistcontainer_add_callbacks, [ :pointer, :pointer, :pointer ], :void
406
430
  attach_function :playlistcontainer_remove_callbacks, :sp_playlistcontainer_remove_callbacks, [ :pointer, :pointer, :pointer ], :void
407
431
  attach_function :playlistcontainer_num_playlists, :sp_playlistcontainer_num_playlists, [ :pointer ], :int
@@ -419,7 +443,7 @@ module Spotify
419
443
  attach_function :playlistcontainer_release, :sp_playlistcontainer_release, [ :pointer ], :void
420
444
 
421
445
  # FFI::Struct for the PlaylistContainer.
422
- #
446
+ #
423
447
  # @attr [callback(:pointer, :pointer, :int, :pointer):void] playlist_added
424
448
  # @attr [callback(:pointer, :pointer, :int, :pointer):void] playlist_removed
425
449
  # @attr [callback(:pointer, :pointer, :int, :int, :pointer):void] playlist_moved
@@ -430,11 +454,13 @@ module Spotify
430
454
  :playlist_moved, callback([ :pointer, :pointer, :int, :int, :pointer ], :void),
431
455
  :container_loaded, callback([ :pointer, :pointer ], :void)
432
456
  end
433
-
457
+
434
458
  #
435
459
  # User handling
436
- #
460
+ #
437
461
  # @see http://developer.spotify.com/en/libspotify/docs/group__user.html
462
+
463
+ #
438
464
  enum :relation_type, [:unknown, :none, :unidirectional, :bidirectional]
439
465
 
440
466
  attach_function :user_canonical_name, :sp_user_canonical_name, [ :pointer ], :string
@@ -445,11 +471,13 @@ module Spotify
445
471
  attach_function :user_relation_type, :sp_user_relation_type, [ :pointer, :pointer ], :relation_type
446
472
  attach_function :user_add_ref, :sp_user_add_ref, [ :pointer ], :void
447
473
  attach_function :user_release, :sp_user_release, [ :pointer ], :void
448
-
474
+
449
475
  #
450
476
  # Toplists
451
- #
477
+ #
452
478
  # @see http://developer.spotify.com/en/libspotify/docs/group__toplist.html
479
+
480
+ #
453
481
  enum :toplisttype, [:artists, :albums, :tracks]
454
482
  enum :toplistregion, [:everywhere, :user]
455
483
 
@@ -464,11 +492,13 @@ module Spotify
464
492
  attach_function :toplistbrowse_album, :sp_toplistbrowse_album, [ :pointer, :int ], :pointer
465
493
  attach_function :toplistbrowse_num_tracks, :sp_toplistbrowse_num_tracks, [ :pointer ], :int
466
494
  attach_function :toplistbrowse_track, :sp_toplistbrowse_track, [ :pointer, :int ], :pointer
467
-
495
+
468
496
  #
469
497
  # Inbox
470
- #
498
+ #
471
499
  # @see http://developer.spotify.com/en/libspotify/docs/group__inbox.html
500
+
501
+ #
472
502
  attach_function :inbox_post_tracks, :sp_inbox_post_tracks, [ :pointer, :string, :pointer, :int, :string, callback([:pointer, :pointer], :void), :pointer ], :pointer
473
503
  attach_function :inbox_error, :sp_inbox_error, [ :pointer ], :error
474
504
  attach_function :inbox_add_ref, :sp_inbox_add_ref, [ :pointer ], :void
@@ -1,3 +1,3 @@
1
1
  module Spotify
2
- VERSION = [7, 0, 3].join('.')
2
+ VERSION = [7, 0, 4].join('.')
3
3
  end
@@ -0,0 +1,44 @@
1
+ class FFIHandler < YARD::Handlers::Ruby::Base
2
+ include YARD::Tags
3
+
4
+ handles method_call(:attach_function)
5
+
6
+ process do
7
+ # Extract parameters
8
+ parameters = statement.parameters.children
9
+
10
+ # Extract actual arguments
11
+ parameters.unshift parameters[0] if parameters[1].type == :array
12
+
13
+ # TODO: Resolve all arguments (if they are variables)
14
+
15
+ # Normalize all arguments to string values
16
+ literalizer = proc do |node|
17
+ case node.type
18
+ when :array # args: [:type, :type]
19
+ node[0].map(&literalizer)
20
+ when :fcall # callback([:type, :type], :type)
21
+ name = node.jump(:ident)[0]
22
+ args, rett = node.jump(:arg_paren)[0].children.map(&literalizer)
23
+ "%s(%s):%s" % [name, args.join(', '), rett]
24
+ else
25
+ node.jump(:tstring_content, :ident)[0].sub("void", "nil")
26
+ end
27
+ end
28
+ parameters.map!(&literalizer)
29
+
30
+ # Now, we have all we need!
31
+ name, cfunc, args, returns = parameters
32
+
33
+ # Register the newly created method
34
+ method = register MethodObject.new(namespace, name, :class)
35
+
36
+ # Construct the final docstring
37
+ overload = OverloadTag.new(:overload, "#{name}(#{args.join(', ')})")
38
+ method.docstring.add_tag overload
39
+ args.each do |type|
40
+ overload.docstring.add_tag Tag.new(:param, nil, type)
41
+ end
42
+ overload.docstring.add_tag Tag.new(:return, nil, returns)
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.3
4
+ version: 7.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-18 00:00:00.000000000 +02:00
12
+ date: 2011-04-20 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
17
- requirement: &2153189120 !ruby/object:Gem::Requirement
17
+ requirement: &2156760220 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153189120
25
+ version_requirements: *2156760220
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: yard
28
- requirement: &2153188700 !ruby/object:Gem::Requirement
28
+ requirement: &2156759800 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2153188700
36
+ version_requirements: *2156759800
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rbgccxml
39
- requirement: &2153188240 !ruby/object:Gem::Requirement
39
+ requirement: &2156759340 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2153188240
47
+ version_requirements: *2156759340
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: minitest
50
- requirement: &2153187740 !ruby/object:Gem::Requirement
50
+ requirement: &2156758780 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2153187740
58
+ version_requirements: *2156758780
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: bundler
61
- requirement: &2153187240 !ruby/object:Gem::Requirement
61
+ requirement: &2156758160 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: 1.0.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2153187240
69
+ version_requirements: *2156758160
70
70
  description:
71
71
  email:
72
72
  - kim@burgestrand.se
@@ -76,12 +76,14 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - .gemtest
78
78
  - .gitignore
79
+ - .yardopts
79
80
  - Gemfile
80
81
  - LICENSE
81
82
  - README.markdown
82
83
  - Rakefile
83
84
  - lib/spotify.rb
84
85
  - lib/spotify/version.rb
86
+ - lib/yard-ffi.rb
85
87
  - spec/api.h
86
88
  - spec/spotify_spec.rb
87
89
  - spotify.gemspec