Skip to content

Commit c20ee68

Browse files
committed
Index is now code-gen'd
1 parent cf7d352 commit c20ee68

19 files changed

Lines changed: 1371 additions & 214 deletions

gen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')),
88

99
for (var i in idefs) {
1010
var idef = idefs[i];
11-
if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time"].indexOf(idef.jsClassName) > -1) {
11+
if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index"].indexOf(idef.jsClassName) > -1) {
1212
fs.writeFileSync(
1313
path.resolve("./include/" + idef.filename), headerTemplate(idef));
1414
fs.writeFileSync(

include/blob.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class GitBlob : public ObjectWrap {
3737
uv_work_t request;
3838
const git_error* error;
3939
git_blob * blob;
40+
Persistent<Value> repoReference;
4041
git_repository * repo;
42+
Persistent<Value> idReference;
4143
const git_oid * id;
4244
Persistent<Function> callback;
4345
};
@@ -52,7 +54,9 @@ class GitBlob : public ObjectWrap {
5254
uv_work_t request;
5355
const git_error* error;
5456
git_oid * id;
57+
Persistent<Value> repoReference;
5558
git_repository * repo;
59+
Persistent<Value> pathReference;
5660
const char * path;
5761
Persistent<Function> callback;
5862
};
@@ -64,8 +68,11 @@ class GitBlob : public ObjectWrap {
6468
uv_work_t request;
6569
const git_error* error;
6670
git_oid * oid;
71+
Persistent<Value> repoReference;
6772
git_repository * repo;
73+
Persistent<Value> bufferReference;
6874
const void * buffer;
75+
Persistent<Value> lenReference;
6976
size_t len;
7077
Persistent<Function> callback;
7178
};

include/commit.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class GitCommit : public ObjectWrap {
3737
uv_work_t request;
3838
const git_error* error;
3939
git_commit * commit;
40+
Persistent<Value> repoReference;
4041
git_repository * repo;
42+
Persistent<Value> idReference;
4143
const git_oid * id;
4244
Persistent<Function> callback;
4345
};
@@ -56,6 +58,7 @@ class GitCommit : public ObjectWrap {
5658
uv_work_t request;
5759
const git_error* error;
5860
git_tree * tree_out;
61+
Persistent<Value> commitReference;
5962
const git_commit * commit;
6063
Persistent<Function> callback;
6164
};
@@ -69,10 +72,14 @@ class GitCommit : public ObjectWrap {
6972
uv_work_t request;
7073
const git_error* error;
7174
git_commit * out;
75+
Persistent<Value> commitReference;
7276
git_commit * commit;
77+
Persistent<Value> nReference;
7378
unsigned int n;
7479
Persistent<Function> callback;
7580
};
81+
static Handle<Value> ParentId(const Arguments& args);
82+
static Handle<Value> NthGenAncestor(const Arguments& args);
7683
git_commit *raw;
7784
};
7885

include/index.h

Lines changed: 103 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,118 @@
11
/**
2-
* Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
3-
* @author Michael Robinson @codeofinterest <mike@pagesofinterest.net>
4-
*
5-
* Dual licensed under the MIT and GPL licenses.
6-
*/
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
74

85
#ifndef INDEX_H
96
#define INDEX_H
107

8+
#include <v8.h>
119
#include <node.h>
10+
#include <string>
1211

1312
#include "git2.h"
1413

1514
using namespace node;
15+
using namespace v8;
1616

17-
/**
18-
* Class: GitIndex
19-
* Wrapper for libgit2 git_error.
20-
*/
21-
class GitIndex : public ObjectWrap {
17+
class Index : public ObjectWrap {
2218
public:
23-
/**
24-
* Variable: constructor_template
25-
* Used to create Node.js constructor.
26-
*/
27-
static v8::Persistent<v8::FunctionTemplate> constructor_template;
28-
/**
29-
* Function: Initialize
30-
* Used to intialize the EventEmitter from Node.js
31-
*
32-
* Parameters:
33-
* target - v8::Object the Node.js global module object
34-
*/
35-
static void Initialize(v8::Handle<v8::Object> target);
36-
37-
protected:
38-
/**
39-
* Constructor: GitIndex
40-
*/
41-
GitIndex() {};
42-
/**
43-
* Deconstructor: GitIndex
44-
*/
45-
~GitIndex() {};
46-
/**
47-
* Function: New
48-
*
49-
* Parameters:
50-
* args v8::Arguments function call
51-
*
52-
* Returns:
53-
* v8::Object args.This()
54-
*/
55-
static v8::Handle<v8::Value> New(const v8::Arguments& args);
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_index *GetValue();
24+
25+
private:
26+
Index(git_index *raw);
27+
~Index();
28+
29+
static Handle<Value> New(const Arguments& args);
30+
31+
32+
static Handle<Value> Open(const Arguments& args);
33+
static void OpenWork(uv_work_t* req);
34+
static void OpenAfterWork(uv_work_t* req);
35+
36+
struct OpenBaton {
37+
uv_work_t request;
38+
const git_error* error;
39+
git_index * out;
40+
Persistent<Value> index_pathReference;
41+
const char * index_path;
42+
Persistent<Function> callback;
43+
};
44+
static Handle<Value> New(const Arguments& args);
45+
static Handle<Value> Owner(const Arguments& args);
46+
static Handle<Value> Read(const Arguments& args);
47+
static void ReadWork(uv_work_t* req);
48+
static void ReadAfterWork(uv_work_t* req);
49+
50+
struct ReadBaton {
51+
uv_work_t request;
52+
const git_error* error;
53+
Persistent<Value> indexReference;
54+
git_index * index;
55+
Persistent<Function> callback;
56+
};
57+
static Handle<Value> Write(const Arguments& args);
58+
static void WriteWork(uv_work_t* req);
59+
static void WriteAfterWork(uv_work_t* req);
60+
61+
struct WriteBaton {
62+
uv_work_t request;
63+
const git_error* error;
64+
Persistent<Value> indexReference;
65+
git_index * index;
66+
Persistent<Function> callback;
67+
};
68+
static Handle<Value> ReadTree(const Arguments& args);
69+
static void ReadTreeWork(uv_work_t* req);
70+
static void ReadTreeAfterWork(uv_work_t* req);
71+
72+
struct ReadTreeBaton {
73+
uv_work_t request;
74+
const git_error* error;
75+
Persistent<Value> indexReference;
76+
git_index * index;
77+
Persistent<Value> treeReference;
78+
const git_tree * tree;
79+
Persistent<Function> callback;
80+
};
81+
static Handle<Value> WriteTree(const Arguments& args);
82+
static void WriteTreeWork(uv_work_t* req);
83+
static void WriteTreeAfterWork(uv_work_t* req);
84+
85+
struct WriteTreeBaton {
86+
uv_work_t request;
87+
const git_error* error;
88+
git_oid * out;
89+
Persistent<Value> indexReference;
90+
git_index * index;
91+
Persistent<Function> callback;
92+
};
93+
static Handle<Value> Entrycount(const Arguments& args);
94+
static Handle<Value> Clear(const Arguments& args);
95+
static Handle<Value> Remove(const Arguments& args);
96+
static Handle<Value> RemoveDirectory(const Arguments& args);
97+
static Handle<Value> AddBypath(const Arguments& args);
98+
static void AddBypathWork(uv_work_t* req);
99+
static void AddBypathAfterWork(uv_work_t* req);
100+
101+
struct AddBypathBaton {
102+
uv_work_t request;
103+
const git_error* error;
104+
Persistent<Value> indexReference;
105+
git_index * index;
106+
Persistent<Value> pathReference;
107+
const char * path;
108+
Persistent<Function> callback;
109+
};
110+
static Handle<Value> RemoveBypath(const Arguments& args);
111+
static Handle<Value> Find(const Arguments& args);
112+
static Handle<Value> ConflictRemove(const Arguments& args);
113+
static Handle<Value> ConflictCleanup(const Arguments& args);
114+
static Handle<Value> HasConflicts(const Arguments& args);
115+
git_index *raw;
56116
};
57117

58118
#endif

include/object.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ class GitObject : public ObjectWrap {
3737
uv_work_t request;
3838
const git_error* error;
3939
git_object * object;
40+
Persistent<Value> repoReference;
4041
git_repository * repo;
42+
Persistent<Value> idReference;
4143
const git_oid * id;
44+
Persistent<Value> typeReference;
4245
git_otype type;
4346
Persistent<Function> callback;
4447
};
4548
static Handle<Value> Oid(const Arguments& args);
4649
static Handle<Value> Type(const Arguments& args);
50+
static Handle<Value> Owner(const Arguments& args);
4751
static Handle<Value> Peel(const Arguments& args);
4852
static void PeelWork(uv_work_t* req);
4953
static void PeelAfterWork(uv_work_t* req);
@@ -52,7 +56,9 @@ class GitObject : public ObjectWrap {
5256
uv_work_t request;
5357
const git_error* error;
5458
git_object * peeled;
59+
Persistent<Value> objectReference;
5560
const git_object * object;
61+
Persistent<Value> target_typeReference;
5662
git_otype target_type;
5763
Persistent<Function> callback;
5864
};

include/reference.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class GitReference : public ObjectWrap {
3737
uv_work_t request;
3838
const git_error* error;
3939
git_reference * out;
40+
Persistent<Value> repoReference;
4041
git_repository * repo;
42+
Persistent<Value> nameReference;
4143
const char * name;
4244
Persistent<Function> callback;
4345
};
@@ -49,10 +51,14 @@ class GitReference : public ObjectWrap {
4951
uv_work_t request;
5052
const git_error* error;
5153
git_oid * out;
54+
Persistent<Value> repoReference;
5255
git_repository * repo;
56+
Persistent<Value> nameReference;
5357
const char * name;
5458
Persistent<Function> callback;
5559
};
60+
static Handle<Value> CreateSymbolic(const Arguments& args);
61+
static Handle<Value> Create(const Arguments& args);
5662
static Handle<Value> Oid(const Arguments& args);
5763
static Handle<Value> Name(const Arguments& args);
5864
static Handle<Value> Type(const Arguments& args);
@@ -64,9 +70,43 @@ class GitReference : public ObjectWrap {
6470
uv_work_t request;
6571
const git_error* error;
6672
git_reference * out;
73+
Persistent<Value> refReference;
6774
const git_reference * ref;
6875
Persistent<Function> callback;
6976
};
77+
static Handle<Value> SetSymbolicTarget(const Arguments& args);
78+
static Handle<Value> setTarget(const Arguments& args);
79+
static Handle<Value> Rename(const Arguments& args);
80+
static void RenameWork(uv_work_t* req);
81+
static void RenameAfterWork(uv_work_t* req);
82+
83+
struct RenameBaton {
84+
uv_work_t request;
85+
const git_error* error;
86+
git_reference * out;
87+
Persistent<Value> refReference;
88+
git_reference * ref;
89+
Persistent<Value> new_nameReference;
90+
const char * new_name;
91+
Persistent<Value> forceReference;
92+
int force;
93+
Persistent<Function> callback;
94+
};
95+
static Handle<Value> Delete(const Arguments& args);
96+
static void DeleteWork(uv_work_t* req);
97+
static void DeleteAfterWork(uv_work_t* req);
98+
99+
struct DeleteBaton {
100+
uv_work_t request;
101+
const git_error* error;
102+
Persistent<Value> refReference;
103+
git_reference * ref;
104+
Persistent<Function> callback;
105+
};
106+
static Handle<Value> IsBranch(const Arguments& args);
107+
static Handle<Value> IsRemote(const Arguments& args);
108+
static Handle<Value> Peel(const Arguments& args);
109+
static Handle<Value> IsValidName(const Arguments& args);
70110
git_reference *raw;
71111
};
72112

include/repo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class GitRepo : public ObjectWrap {
3737
uv_work_t request;
3838
const git_error* error;
3939
git_repository * out;
40+
Persistent<Value> pathReference;
4041
const char * path;
4142
Persistent<Function> callback;
4243
};
@@ -48,7 +49,9 @@ class GitRepo : public ObjectWrap {
4849
uv_work_t request;
4950
const git_error* error;
5051
git_repository * out;
52+
Persistent<Value> pathReference;
5153
const char * path;
54+
Persistent<Value> is_bareReference;
5255
unsigned is_bare;
5356
Persistent<Function> callback;
5457
};

include/tree_entry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class GitTreeEntry : public ObjectWrap {
4141
uv_work_t request;
4242
const git_error* error;
4343
git_object * object_out;
44+
Persistent<Value> repoReference;
4445
git_repository * repo;
46+
Persistent<Value> entryReference;
4547
const git_tree_entry * entry;
4648
Persistent<Function> callback;
4749
};

0 commit comments

Comments
 (0)