-
Notifications
You must be signed in to change notification settings - Fork 700
Expand file tree
/
Copy pathdiff_range.cc
More file actions
110 lines (79 loc) · 2.61 KB
/
Copy pathdiff_range.cc
File metadata and controls
110 lines (79 loc) · 2.61 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* 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/diff_range.h"
using namespace v8;
using namespace node;
GitDiffRange::GitDiffRange(git_diff_range *raw) {
this->raw = raw;
}
GitDiffRange::~GitDiffRange() {
free(this->raw);
}
void GitDiffRange::Initialize(Handle<v8::Object> target) {
NanScope();
Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(New);
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->SetClassName(NanNew<String>("DiffRange"));
NODE_SET_PROTOTYPE_METHOD(tpl, "oldStart", OldStart);
NODE_SET_PROTOTYPE_METHOD(tpl, "oldLines", OldLines);
NODE_SET_PROTOTYPE_METHOD(tpl, "newStart", NewStart);
NODE_SET_PROTOTYPE_METHOD(tpl, "newLines", NewLines);
Local<Function> _constructor_template = tpl->GetFunction();
NanAssignPersistent(constructor_template, _constructor_template);
target->Set(NanNew<String>("DiffRange"), _constructor_template);
}
NAN_METHOD(GitDiffRange::New) {
NanScope();
if (args.Length() == 0 || !args[0]->IsExternal()) {
return NanThrowError("git_diff_range is required.");
}
GitDiffRange* object = new GitDiffRange(static_cast<git_diff_range *>(Handle<External>::Cast(args[0])->Value()));
object->Wrap(args.This());
NanReturnValue(args.This());
}
Handle<Value> GitDiffRange::New(void *raw) {
NanEscapableScope();
Handle<Value> argv[1] = { NanNew<External>((void *)raw) };
return NanEscapeScope(NanNew<Function>(GitDiffRange::constructor_template)->NewInstance(1, argv));
}
git_diff_range *GitDiffRange::GetValue() {
return this->raw;
}
NAN_METHOD(GitDiffRange::OldStart) {
NanScope();
Handle<Value> to;
int old_start =
ObjectWrap::Unwrap<GitDiffRange>(args.This())->GetValue()->old_start;
to = NanNew<Integer>(old_start);
NanReturnValue(to);
}
NAN_METHOD(GitDiffRange::OldLines) {
NanScope();
Handle<Value> to;
int old_lines =
ObjectWrap::Unwrap<GitDiffRange>(args.This())->GetValue()->old_lines;
to = NanNew<Integer>(old_lines);
NanReturnValue(to);
}
NAN_METHOD(GitDiffRange::NewStart) {
NanScope();
Handle<Value> to;
int new_start =
ObjectWrap::Unwrap<GitDiffRange>(args.This())->GetValue()->new_start;
to = NanNew<Integer>(new_start);
NanReturnValue(to);
}
NAN_METHOD(GitDiffRange::NewLines) {
NanScope();
Handle<Value> to;
int new_lines =
ObjectWrap::Unwrap<GitDiffRange>(args.This())->GetValue()->new_lines;
to = NanNew<Integer>(new_lines);
NanReturnValue(to);
}
Persistent<Function> GitDiffRange::constructor_template;