-
Notifications
You must be signed in to change notification settings - Fork 66
/
artist.cc
65 lines (51 loc) · 1.71 KB
/
artist.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* =====================================================================================
*
* Filename: artist.cc
*
* Description: bindings for the artist subsystem
*
* Version: 1.0
* Created: 03/01/2013 15:18:14
* Revision: none
* Compiler: gcc
*
* Author: Florent Jaby (FJ), florent.jaby@gmail.com
* Company: Florent Jaby
*
* =====================================================================================
*/
#include "common.h"
using namespace v8;
using namespace nsp;
/**
* JS artist_is_loaded implementation. checks if a given artist is loaded
*/
static Handle<Value> Artist_Is_Loaded(const Arguments& args) {
HandleScope scope;
// test arguments sanity
assert(args.Length() == 1);
assert(args[0]->IsObject());
// gets sp_artist pointer from given object
ObjectHandle<sp_artist>* artist = ObjectHandle<sp_artist>::Unwrap(args[0]);
// actually call sp_artist_is_loaded
bool loaded = sp_artist_is_loaded(artist->pointer);
return scope.Close(Boolean::New(loaded));
}
/**
* JS artist_name implementation. checks if a given artist is loaded
*/
static Handle<Value> Artist_Name(const Arguments& args) {
HandleScope scope;
// test arguments sanity
assert(args.Length() == 1);
assert(args[0]->IsObject());
// gets sp_artist pointer from given object
ObjectHandle<sp_artist>* artist = ObjectHandle<sp_artist>::Unwrap(args[0]);
const char* name = sp_artist_name(artist->pointer);
return scope.Close(String::New(name));
}
void nsp::init_artist(Handle<Object> target) {
NODE_SET_METHOD(target, "artist_is_loaded", Artist_Is_Loaded);
NODE_SET_METHOD(target, "artist_name", Artist_Name);
}