-
Notifications
You must be signed in to change notification settings - Fork 700
Expand file tree
/
Copy pathtree.h
More file actions
executable file
·143 lines (130 loc) · 3.35 KB
/
Copy pathtree.h
File metadata and controls
executable file
·143 lines (130 loc) · 3.35 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
*/
#ifndef GITTREE_H
#define GITTREE_H
#include <v8.h>
#include <node.h>
#include <string>
#include "../vendor/libgit2/include/git2.h"
#include "repo.h"
#include "tree_entry.h"
using namespace v8;
using namespace node;
/**
* Class wrapper for libgit2 git_tree
*/
class GitTree : public ObjectWrap {
public:
/**
* v8::FunctionTemplate used to create Node.js constructor
*/
static Persistent<FunctionTemplate> constructor_template;
/**
* Used to intialize the EventEmitter from Node.js
*
* @param target v8::Object the Node.js module object
*/
static void Initialize(Handle<v8::Object> target);
/**
* Accessor for GitTree
*
* @return the internal git_tree reference
*/
git_tree* GetValue();
/**
* Mutator for GitTree
*
* @param obj a git_tree object
*/
void SetValue(git_tree* tree);
/**
* Lookup a tree object from a repository.
*
* @param repo the repo to use when locating the tree.
* @param id identity of the tree to locate.
*
* @return 0 on success; error code otherwise
*/
int Lookup(git_repository* repo, const git_oid* id);
/**
* Get number of entries in the looked up tree.
*
* @return number of entries
*/
size_t EntryCount();
/**
* Get entry by index in the looked up tree.
*
* @param idx index of the entry
*
* @return git tree entry
*/
git_tree_entry* EntryByIndex(int idx);
git_tree_entry* EntryByName(const char* name);
int SortEntries();
void ClearEntries();
protected:
/**
* Constructor
*/
GitTree() {};
/**
* Deconstructor
*/
~GitTree() {};
/**
* Creates a new instance of GitTree to Node.js
*
* @param args v8::Arguments function call arguments from Node.js
*
* @return v8::Object args.This()
*/
static Handle<Value> New(const Arguments& args);
static Handle<Value> Lookup(const Arguments& args);
static void EIO_Lookup(uv_work_t *req);
static void EIO_AfterLookup(uv_work_t *req);
static Handle<Value> EntryCount(const Arguments& args);
static Handle<Value> EntryByIndex(const Arguments& args);
static void EIO_EntryByIndex(uv_work_t *req);
static void EIO_AfterEntryByIndex(uv_work_t *req);
static Handle<Value> EntryByName(const Arguments& args);
static void EIO_EntryByName(uv_work_t *req);
static void EIO_AfterEntryByName(uv_work_t *req);
static Handle<Value> SortEntries(const Arguments& args);
static Handle<Value> ClearEntries(const Arguments& args);
private:
/**
* Internal reference to git_tree object
*/
git_tree* tree;
/**
* Structure to handle async lookups
*/
struct lookup_request {
GitTree* tree;
GitRepo* repo;
GitOid* oid;
int err;
Persistent<Function> callback;
};
/**
* Structure to handle async entryByIndex
*/
struct entryindex_request {
GitTree* tree;
GitTreeEntry* entry;
int idx;
Persistent<Function> callback;
};
/**
* Structure to handle async entryByName
*/
struct entryname_request {
GitTree* tree;
GitTreeEntry* entry;
std::string name;
Persistent<Function> callback;
};
};
#endif