Permalink
Browse files

cpplint FTW

  • Loading branch information...
1 parent bf2223d commit 10e28a5bc76cb3c12ee3bc91899804ec67c451e0 @rsms rsms committed Jul 20, 2010
Showing with 230 additions and 133 deletions.
  1. +4 −2 cpplint.py
  2. +7 −4 src/album.cc
  3. +9 −6 src/album.h
  4. +7 −4 src/artist.cc
  5. +7 −5 src/artist.h
  6. +16 −8 src/atomic_queue.h
  7. +2 −1 src/index.cc
  8. +16 −3 src/index.h
  9. +20 −14 src/playlist.cc
  10. +1 −1 src/playlist.h
  11. +16 −12 src/playlistcontainer.cc
  12. +4 −4 src/playlistcontainer.h
  13. +18 −9 src/search.cc
  14. +19 −11 src/search.h
  15. +40 −25 src/session.cc
  16. +1 −1 src/session.h
  17. +2 −2 src/stub.h.in
  18. +21 −13 src/track.cc
  19. +11 −7 src/track.h
  20. +9 −1 wscript
View
@@ -562,7 +562,8 @@ def PrintErrorCounts(self):
for category, count in self.errors_by_category.iteritems():
sys.stderr.write('Category \'%s\' errors found: %d\n' %
(category, count))
- sys.stderr.write('Total errors found: %d\n' % self.error_count)
+ if self.verbose_level > 0:
+ sys.stderr.write('Total errors found: %d\n' % self.error_count)
_cpplint_state = _CppLintState()
@@ -3023,7 +3024,8 @@ def ProcessFile(filename, vlevel):
'One or more unexpected \\r (^M) found;'
'better to use only a \\n')
- sys.stderr.write('Done processing %s\n' % filename)
+ if vlevel > 0:
+ sys.stderr.write('Done processing %s\n' % filename)
def PrintUsage(message):
View
@@ -47,7 +47,7 @@ void Album::SetupBackingAlbum() {
// status check
if (!sp_album_is_loaded(album_)) {
- fprintf(stderr, "todo [%s:%d]: album is not yet loaded\n",__FILE__,__LINE__);
+ TODO("album is not yet loaded");
return;
}
@@ -61,15 +61,17 @@ void Album::SetupBackingAlbum() {
handle_->Set(String::New("_type"), Integer::New(sp_album_type(album_)));
}
-Handle<Value> Album::LoadedGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Album::LoadedGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
Album *p = Unwrap<Album>(info.This());
return p->album_
? scope.Close(Boolean::New(sp_album_is_loaded(p->album_)))
: Undefined();
}
-Handle<Value> Album::ArtistGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Album::ArtistGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
Album *p = Unwrap<Album>(info.This());
if (!p->album_ || !sp_album_is_loaded(p->album_))
@@ -78,7 +80,8 @@ Handle<Value> Album::ArtistGetter(Local<String> property, const AccessorInfo& in
scope.Close(artist);
}
-Handle<Value> Album::URIGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Album::URIGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
Album *p = Unwrap<Album>(info.This());
if (!p->album_ || !sp_album_is_loaded(p->album_))
View
@@ -4,18 +4,21 @@
#include "index.h"
class Album : public EventEmitter {
-public:
+ public:
static Persistent<FunctionTemplate> constructor_template;
static void Initialize(Handle<Object> target);
- Album(sp_album *album);
+ explicit Album(sp_album *album);
~Album();
static Handle<Value> New(const Arguments& args);
static Local<Object> New(sp_album *album);
- static Handle<Value> LoadedGetter(Local<String> property, const AccessorInfo& info);
- static Handle<Value> ArtistGetter(Local<String> property, const AccessorInfo& info);
- static Handle<Value> URIGetter(Local<String> property, const AccessorInfo& info);
-protected:
+ static Handle<Value> LoadedGetter(Local<String> property,
+ const AccessorInfo& info);
+ static Handle<Value> ArtistGetter(Local<String> property,
+ const AccessorInfo& info);
+ static Handle<Value> URIGetter(Local<String> property,
+ const AccessorInfo& info);
+ protected:
void SetupBackingAlbum();
sp_album* album_;
};
View
@@ -18,7 +18,8 @@ Artist::~Artist() {
Local<Object> Artist::New(sp_artist *artist) {
HandleScope scope;
- Local<Object> instance = constructor_template->GetFunction()->NewInstance(0, NULL);
+ Local<Object> instance =
+ constructor_template->GetFunction()->NewInstance(0, NULL);
Artist *p = ObjectWrap::Unwrap<Artist>(instance);
p->artist_ = artist;
if (p->artist_) {
@@ -40,23 +41,25 @@ void Artist::SetupBackingArtist() {
// status check
if (!sp_artist_is_loaded(artist_)) {
- fprintf(stderr, "todo [%s:%d]: artist is not yet loaded\n",__FILE__,__LINE__);
+ TODO("artist is not yet loaded");
return;
}
// todo: symbolize keys
handle_->Set(String::New("name"), String::New(sp_artist_name(artist_)));
}
-Handle<Value> Artist::LoadedGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Artist::LoadedGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
Artist *p = Unwrap<Artist>(info.This());
return p->artist_
? scope.Close(Boolean::New(sp_artist_is_loaded(p->artist_)))
: Undefined();
}
-Handle<Value> Artist::URIGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Artist::URIGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
Artist *p = Unwrap<Artist>(info.This());
if (!p->artist_ || !sp_artist_is_loaded(p->artist_))
View
@@ -4,17 +4,19 @@
#include "index.h"
class Artist : public EventEmitter {
-public:
+ public:
static Persistent<FunctionTemplate> constructor_template;
static void Initialize(Handle<Object> target);
- Artist(sp_artist *artist);
+ explicit Artist(sp_artist *artist);
~Artist();
static Handle<Value> New(const Arguments& args);
static Local<Object> New(sp_artist *artist);
- static Handle<Value> LoadedGetter(Local<String> property, const AccessorInfo& info);
- static Handle<Value> URIGetter(Local<String> property, const AccessorInfo& info);
-protected:
+ static Handle<Value> LoadedGetter(Local<String> property,
+ const AccessorInfo& info);
+ static Handle<Value> URIGetter(Local<String> property,
+ const AccessorInfo& info);
+ protected:
void SetupBackingArtist();
sp_artist* artist_;
};
View
@@ -80,27 +80,33 @@ inline void nt_atomic_queue_init(nt_atomic_queue *queue) {
void nt_atomic_enqueue64_mp(nt_atomic_queue *queue, void *elem, size_t offset);
void *nt_atomic_dequeue64_mp(nt_atomic_queue *queue, size_t offset);
-void *nt_atomic_dequeue_ifnexteq64_mp(nt_atomic_queue *queue, size_t offset, void *cmpptr);
+void *nt_atomic_dequeue_ifnexteq64_mp(nt_atomic_queue *queue, size_t offset,
+ void *cmpptr);
void nt_atomic_enqueue64_up(nt_atomic_queue *queue, void *elem, size_t offset);
void *nt_atomic_dequeue64_up(nt_atomic_queue *queue, size_t offset);
-void *nt_atomic_dequeue_ifnexteq64_up(nt_atomic_queue *queue, size_t offset, void *cmpptr);
+void *nt_atomic_dequeue_ifnexteq64_up(nt_atomic_queue *queue, size_t offset,
+ void *cmpptr);
#else
void nt_atomic_enqueue32_mp(nt_atomic_queue *queue, void *elem, size_t offset);
void *nt_atomic_dequeue32_mp(nt_atomic_queue *queue, size_t offset);
-void *nt_atomic_dequeue_ifnexteq32_mp(nt_atomic_queue *queue, size_t offset, void *cmpptr);
+void *nt_atomic_dequeue_ifnexteq32_mp(nt_atomic_queue *queue, size_t offset,
+ void *cmpptr);
void nt_atomic_enqueue32_up(nt_atomic_queue *queue, void *elem, size_t offset);
void *nt_atomic_dequeue32_up(nt_atomic_queue *queue, size_t offset);
-void *nt_atomic_dequeue_ifnexteq32_up(nt_atomic_queue *queue, size_t offset, void *cmpptr);
+void *nt_atomic_dequeue_ifnexteq32_up(nt_atomic_queue *queue, size_t offset,
+ void *cmpptr);
void *nt_atomic_dequeue32_on64_mp(nt_atomic_queue *queue, size_t offset);
-void *nt_atomic_dequeue_ifnexteq32_on64_mp(nt_atomic_queue *queue, size_t offset, void *cmpptr);
+void *nt_atomic_dequeue_ifnexteq32_on64_mp(nt_atomic_queue *queue,
+ size_t offset, void *cmpptr);
void *nt_atomic_dequeue32_on64_up(nt_atomic_queue *queue, size_t offset);
-void *nt_atomic_dequeue_ifnexteq32_on64_up(nt_atomic_queue *queue, size_t offset, void *cmpptr);
+void *nt_atomic_dequeue_ifnexteq32_on64_up(nt_atomic_queue *queue,
+ size_t offset, void *cmpptr);
#endif
@@ -112,7 +118,8 @@ void *nt_atomic_dequeue_ifnexteq32_on64_up(nt_atomic_queue *queue, size_t offset
@param offset offset in bytes to the link pointer of @elem. Usually
offsetof(my_struct, link_member).
*/
-inline void nt_atomic_enqueue(nt_atomic_queue *queue, void *elem, size_t offset) {
+inline void nt_atomic_enqueue(nt_atomic_queue *queue, void *elem,
+ size_t offset) {
#ifdef __LP64__
nt_atomic_enqueue64_mp(queue, elem, offset);
#else
@@ -150,7 +157,8 @@ inline void *nt_atomic_dequeue(nt_atomic_queue *queue, size_t offset) {
is returned.
@returns pointer to a dequeued element or NULL if the queue is empty.
*/
-inline void *nt_atomic_dequeue_ifnexteq(nt_atomic_queue *queue, size_t offset, void *cmpptr) {
+inline void *nt_atomic_dequeue_ifnexteq(nt_atomic_queue *queue, size_t offset,
+ void *cmpptr) {
#ifdef __LP64__
nt_atomic_dequeue_ifnexteq64_mp(queue, offset, cmpptr);
#else
View
@@ -17,5 +17,6 @@ extern "C" void init(Handle<Object> target) {
Album::Initialize(target);
Artist::Initialize(target);
target->Set(String::NewSymbol("version"), String::New("0.1"));
- target->Set(String::NewSymbol("spotifyAPIVersion"), Integer::New(SPOTIFY_API_VERSION));
+ target->Set(String::NewSymbol("spotifyAPIVersion"),
+ Integer::New(SPOTIFY_API_VERSION));
}
View
@@ -12,12 +12,25 @@
using namespace v8;
using namespace node;
-#define STRPTR(obj) (*String::Utf8Value((obj)->ToString()))
-#define STRSIZ(obj) ((obj)->ToString()->Utf8Length())
+// -----------------------------------------------------------------------------
+// Aiding construction of types
-// ----------------------------------------------------------------------------
+// Property getter interface boilerplate
+#define GETTER_H(name)\
+ static Handle<Value> name(Local<String> property, const AccessorInfo& info)
+
+// Property getter implementation boilerplate
+#define GETTER_C(name)\
+ Handle<Value> name(Local<String> property, const AccessorInfo& info)
+
+// -----------------------------------------------------------------------------
// Helpers
+// Emitting WIP/development notes
+#define TODO(tmpl, ...)\
+ fprintf(stderr, "TODO [node-spotify %s:%d]: " tmpl "\n", \
+ __FILE__, __LINE__, ##__VA_ARGS__)
+
// Throwing exceptions
#define JS_THROW(t, s) ThrowException(Exception::t(String::New(s)))
#define JS_THROWF(tmpl, ...) {\
View
@@ -17,9 +17,9 @@ static const char *_PlaylistURI(sp_playlist *pl) {
// -----------------------------------------------------------------------------
// libspotify callbacks
-static void TracksAdded(sp_playlist *playlist, sp_track *const *tracks, int count, int position, void *userdata) {
+static void TracksAdded(sp_playlist *playlist, sp_track *const *tracks,
+ int count, int position, void *userdata) {
// called on the main thread
- //printf("[%s] tracksAdded(<tracks*>, %d, %d)\n", _PlaylistURI(playlist), count, position);
Playlist* pl = static_cast<Playlist*>(userdata);
Handle<Value> argv[] = {
Integer::New(count),
@@ -29,9 +29,9 @@ static void TracksAdded(sp_playlist *playlist, sp_track *const *tracks, int coun
pl->Emit(String::New("tracksAdded"), 2, argv);
}
-static void TracksRemoved(sp_playlist *playlist, const int *tracks, int count, void *userdata) {
+static void TracksRemoved(sp_playlist *playlist, const int *tracks, int count,
+ void *userdata) {
// called on the main thread
- //printf("[%s] tracksRemoved(<track-indices*>, %d)\n", _PlaylistURI(playlist), count);
Playlist* pl = static_cast<Playlist*>(userdata);
Local<Array> array = Array::New(count);
for (int i = 0; i < count; i++) {
@@ -41,9 +41,9 @@ static void TracksRemoved(sp_playlist *playlist, const int *tracks, int count, v
pl->Emit(String::New("tracksRemoved"), 1, argv);
}
-static void TracksMoved(sp_playlist *playlist, const int *tracks, int count, int new_position, void *userdata) {
+static void TracksMoved(sp_playlist *playlist, const int *tracks, int count,
+ int new_position, void *userdata) {
// called on the main thread
- //printf("[%s] tracksMoved(<track-indices*>, %d, %d)\n", _PlaylistURI(playlist), count, new_position);
Playlist* pl = static_cast<Playlist*>(userdata);
Local<Array> array = Array::New(count);
for (int i = 0; i < count; i++) {
@@ -55,21 +55,23 @@ static void TracksMoved(sp_playlist *playlist, const int *tracks, int count, int
static void PlaylistRenamed(sp_playlist *playlist, void *userdata) {
// called on the main thread
- //printf("[%s] renamed -- name: %s\n", _PlaylistURI(playlist), sp_playlist_name(pl));
Playlist* pl = static_cast<Playlist*>(userdata);
pl->Emit(String::New("renamed"), 0, NULL);
}
static void PlaylistStateChanged(sp_playlist *playlist, void *userdata) {
// called on the main thread
// The "state" in this case are the flags like collaborative or pending.
- //printf("[%s] stateChanged -- colab: %d, pending: %d\n", _PlaylistURI(playlist),
- // sp_playlist_is_collaborative(playlist), sp_playlist_has_pending_changes(playlist));
+ //printf("[%s] stateChanged -- colab: %d, pending: %d\n",
+ // _PlaylistURI(playlist),
+ // sp_playlist_is_collaborative(playlist),
+ // sp_playlist_has_pending_changes(playlist));
Playlist* pl = static_cast<Playlist*>(userdata);
pl->Emit(String::New("stateChanged"), 0, NULL);
}
-static void PlaylistUpdateInProgress(sp_playlist *playlist, bool done, void *userdata) {
+static void PlaylistUpdateInProgress(sp_playlist *playlist, bool done,
+ void *userdata) {
// called on the main thread
//printf("[%s] updateInProgress -- done: %s\n",
// _PlaylistURI(playlist), done ? "true" : "false");
@@ -112,7 +114,8 @@ Playlist::~Playlist() {
}
Handle<Value> Playlist::New(sp_playlist *playlist) {
- Local<Object> instance = constructor_template->GetFunction()->NewInstance(0, NULL);
+ Local<Object> instance =
+ constructor_template->GetFunction()->NewInstance(0, NULL);
Playlist *pl = ObjectWrap::Unwrap<Playlist>(instance);
if (pl->playlist_) sp_playlist_release(pl->playlist_);
pl->playlist_ = playlist;
@@ -128,22 +131,25 @@ Handle<Value> Playlist::New(const Arguments& args) {
return args.This();
}
-Handle<Value> Playlist::LoadedGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Playlist::LoadedGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
sp_playlist* playlist = ObjectWrap::Unwrap<Playlist>(info.This())->playlist_;
if (!playlist) return Undefined();
return scope.Close(Boolean::New(sp_playlist_is_loaded(playlist)));
}
-Handle<Value> Playlist::NameGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Playlist::NameGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
sp_playlist* playlist = ObjectWrap::Unwrap<Playlist>(info.This())->playlist_;
if (!playlist || !sp_playlist_is_loaded(playlist))
return Undefined();
return scope.Close(String::New(sp_playlist_name(playlist)));
}
-Handle<Value> Playlist::URIGetter(Local<String> property, const AccessorInfo& info) {
+Handle<Value> Playlist::URIGetter(Local<String> property,
+ const AccessorInfo& info) {
HandleScope scope;
Playlist *p = Unwrap<Playlist>(info.This());
if (!p->playlist_ || !sp_playlist_is_loaded(p->playlist_))
View
@@ -7,7 +7,7 @@ class Playlist : public EventEmitter {
public:
static void Initialize(Handle<Object> target);
- Playlist(sp_playlist* playlist);
+ explicit Playlist(sp_playlist* playlist);
~Playlist();
static Handle<Value> New(const Arguments& args);
Oops, something went wrong.

0 comments on commit 10e28a5

Please sign in to comment.