forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex_time.cc
More file actions
86 lines (61 loc) · 2.1 KB
/
Copy pathindex_time.cc
File metadata and controls
86 lines (61 loc) · 2.1 KB
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
86
/**
* This code is auto-generated; unless you know what you're doing, do not modify!
**/
#include <nan.h>
#include <string.h>
#include "git2.h"
#include "../include/functions/copy.h"
#include "../include/index_time.h"
using namespace v8;
using namespace node;
GitIndexTime::GitIndexTime(git_index_time *raw) {
this->raw = raw;
}
GitIndexTime::~GitIndexTime() {
free(this->raw);
}
void GitIndexTime::Initialize(Handle<v8::Object> target) {
NanScope();
Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(New);
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->SetClassName(NanNew<String>("IndexTime"));
NODE_SET_PROTOTYPE_METHOD(tpl, "seconds", Seconds);
NODE_SET_PROTOTYPE_METHOD(tpl, "nanoseconds", Nanoseconds);
Local<Function> _constructor_template = tpl->GetFunction();
NanAssignPersistent(constructor_template, _constructor_template);
target->Set(NanNew<String>("IndexTime"), _constructor_template);
}
NAN_METHOD(GitIndexTime::New) {
NanScope();
if (args.Length() == 0 || !args[0]->IsExternal()) {
return NanThrowError("git_index_time is required.");
}
GitIndexTime* object = new GitIndexTime(static_cast<git_index_time *>(Handle<External>::Cast(args[0])->Value()));
object->Wrap(args.This());
NanReturnValue(args.This());
}
Handle<Value> GitIndexTime::New(void *raw) {
NanEscapableScope();
Handle<Value> argv[1] = { NanNew<External>((void *)raw) };
return NanEscapeScope(NanNew<Function>(GitIndexTime::constructor_template)->NewInstance(1, argv));
}
git_index_time *GitIndexTime::GetValue() {
return this->raw;
}
NAN_METHOD(GitIndexTime::Seconds) {
NanScope();
Handle<Value> to;
git_time_t seconds =
ObjectWrap::Unwrap<GitIndexTime>(args.This())->GetValue()->seconds;
to = NanNew<Uint32>((uint32_t)seconds);
NanReturnValue(to);
}
NAN_METHOD(GitIndexTime::Nanoseconds) {
NanScope();
Handle<Value> to;
unsigned int nanoseconds =
ObjectWrap::Unwrap<GitIndexTime>(args.This())->GetValue()->nanoseconds;
to = NanNew<Uint32>((uint32_t)nanoseconds);
NanReturnValue(to);
}
Persistent<Function> GitIndexTime::constructor_template;