FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/src/tree_entry.cc at v0.0.2 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
src
/
tree_entry.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
101 lines (70 loc) · 2.53 KB
Breadcrumbs
nodegit
/
src
/
tree_entry.cc
Copy path
File metadata and controls
101 lines (70 loc) · 2.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
*/
#
include
<
v8.h
>
#
include
<
node.h
>
#
include
<
node_events.h
>
#
include
"
../vendor/libgit2/include/git2.h
"
#
include
"
repo.h
"
#
include
"
blob.h
"
#
include
"
tree.h
"
#
include
"
object.h
"
#
include
"
oid.h
"
#
include
"
tree_entry.h
"
using
namespace
v8
;
using
namespace
node
;
void
GitTreeEntry::Initialize
(Handle<v8::Object> target) {
Local<FunctionTemplate> t =
FunctionTemplate::New
(New);
constructor_template = Persistent<FunctionTemplate>::
New
(t);
constructor_template->
InstanceTemplate
()->
SetInternalFieldCount
(
1
);
constructor_template->
SetClassName
(
String::NewSymbol
(
"
TreeEntry
"
));
NODE_SET_PROTOTYPE_METHOD
(constructor_template,
"
name
"
, Name);
NODE_SET_PROTOTYPE_METHOD
(constructor_template,
"
toObject
"
, ToObject);
target->
Set
(
String::NewSymbol
(
"
TreeEntry
"
), constructor_template->
GetFunction
());
}
void
GitTreeEntry::SetValue
(git_tree_entry* entry) {
this
->
entry
= entry;
}
const
char
*
GitTreeEntry::Name
() {
return
git_tree_entry_name
(
this
->
entry
);
}
const
git_oid*
GitTreeEntry::Id
() {
return
git_tree_entry_id
(
this
->
entry
);
}
int
GitTreeEntry::ToObject
(git_object** obj) {
return
git_tree_entry_2object
(obj,
this
->
entry
);
}
Handle<Value>
GitTreeEntry::New
(
const
Arguments& args) {
HandleScope scope;
GitTreeEntry *entry =
new
GitTreeEntry
();
entry->
Wrap
(args.
This
());
return
args.
This
();
}
Handle<Value>
GitTreeEntry::Name
(
const
Arguments& args) {
HandleScope scope;
GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.
This
());
return
String::New
(entry->
Name
());
}
Handle<Value>
GitTreeEntry::Id
(
const
Arguments& args) {
HandleScope scope;
GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.
This
());
if
(args.
Length
() ==
0
|| !args[
0
]->
IsObject
()) {
return
ThrowException
(
Exception::Error
(
String::New
(
"
Oid is required and must be an Object.
"
)));
}
Oid* oid = ObjectWrap::Unwrap<Oid>(args[
0
]->
ToObject
());
oid->
SetValue
(
const_cast
<git_oid *>(entry->
Id
()));
return
Undefined
();
}
Handle<Value>
GitTreeEntry::ToObject
(
const
Arguments& args) {
HandleScope scope;
GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.
This
());
if
(args.
Length
() ==
0
|| !args[
0
]->
IsObject
()) {
return
ThrowException
(
Exception::Error
(
String::New
(
"
Blob is required and must be an Object.
"
)));
}
Blob* blob = ObjectWrap::Unwrap<Blob>(args[
0
]->
ToObject
());
git_object* out;
entry->
ToObject
(&out);
blob->
SetValue
((git_blob *)out);
return
Undefined
();
}
Persistent<FunctionTemplate> GitTreeEntry::constructor_template;
Back
|
FazBrowse Home
|
New Git URL