-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tag.cpp
86 lines (71 loc) · 2.66 KB
/
Tag.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "Tag.hpp"
#include "Arguments.hpp"
#include "TagVRDefinitions.hpp"
#include "imebra.hpp"
using namespace bindings;
Nan::Persistent<v8::Function> Tag::constructor;
NAN_METHOD(Tag::New) {
auto tag = new Tag();
tag->Wrap(info.This());
info.GetReturnValue().Set(info.This());
}
void Tag::Init(v8::Local<v8::Object> exports) {
auto tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Tag").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Nan::SetPrototypeMethod(tpl,"getDataType",GetDataType);
Nan::SetPrototypeMethod(tpl,"bufferExists",BufferExists);
Nan::SetPrototypeMethod(tpl,"getBufferSize",GetBufferSize);
Nan::SetPrototypeMethod(tpl,"getBuffersCount",GetBuffersCount);
// Nan::SetPrototypeMethod(tpl,"getSequenceItem",GetSequenceItem);
Nan::SetPrototypeMethod(tpl,"sequenceItemExists",SequenceItemExists);
constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(exports,Nan::New("Tag").ToLocalChecked(),Nan::GetFunction(tpl).ToLocalChecked());
}
NAN_METHOD(Tag::SequenceItemExists){
UNWRAP(info.This(),Tag,tag);
size_t dataSetId;
if(!Arguments::GetInt(info[0],dataSetId)){
Nan::ThrowError("First argument must be a valid integer");
return;
}
info.GetReturnValue().Set(Nan::New(tag->value->sequenceItemExists(dataSetId)));
}
NAN_METHOD(Tag::GetBufferSize){
UNWRAP(info.This(),Tag,tag);
size_t bufferId;
if(!Arguments::GetInt(info[0],bufferId)){
Nan::ThrowError("First argument must be a valid integer");
return;
}
info.GetReturnValue().Set(Nan::New<v8::Number>(tag->value->getBufferSize(bufferId)));
}
//NAN_METHOD(Tag::GetSequenceItem){
// UNWRAP(info.This(),Tag,tag);
// size_t dataSetId;
// if(!Arguments::GetInt(info[0],dataSetId)){
// Nan::ThrowError("First argument must be a valid integer");
// return;
// }
// auto dataSet = tag->value->getSequenceItem(dataSetId)
// info.GetReturnValue().Set(Nan::New<v8::Number>(tag->value->getBufferSize(bufferId)));
//}
NAN_METHOD(Tag::GetBuffersCount){
UNWRAP(info.This(),Tag,tag);
info.GetReturnValue().Set(Nan::New<v8::Number>(tag->value->getBuffersCount()));
}
NAN_METHOD(Tag::GetDataType) {
UNWRAP(info.This(),Tag,tag);
info.GetReturnValue().Set(TagVRDefinitions::Encode(tag->value->getDataType()));
}
NAN_METHOD(Tag::BufferExists) {
UNWRAP(info.This(),Tag,tag);
size_t bufferId;
if(!Arguments::GetInt(info[0],bufferId)) {
Nan::ThrowError("First argument must be a valid integer");
return;
}
info.GetReturnValue().Set(Nan::New(tag->value->bufferExists(bufferId)));
}
Tag::Tag() {
}