Skip to content

Commit cf7d352

Browse files
committed
TreeEntry, Object, Commit, Signature, Time is now code-gen'd
1 parent 707675a commit cf7d352

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2235
-2791
lines changed

TODO

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- replace all argv crap with Wrap static methods for tighter instantiation
2+
- audit memory issues - explicit malloc and frees, copies
3+
- look into the v88 conversions crap
4+
- rename all async methods getXXX

binding.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
'src/error.cc',
1010
'src/oid.cc',
1111
'src/reference.cc',
12+
'src/object.cc',
1213
'src/repo.cc',
1314
'src/revwalk.cc',
1415
'src/signature.cc',
16+
'src/time.cc',
1517
'src/tree.cc',
1618
'src/tree_entry.cc',
1719
'src/diff_list.cc',

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"].indexOf(idef.jsClassName) > -1) {
11+
if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time"].indexOf(idef.jsClassName) > -1) {
1212
fs.writeFileSync(
1313
path.resolve("./include/" + idef.filename), headerTemplate(idef));
1414
fs.writeFileSync(

include/blob.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GitBlob : public ObjectWrap {
2828

2929
static Handle<Value> New(const Arguments& args);
3030

31+
3132
static Handle<Value> Lookup(const Arguments& args);
3233
static void LookupWork(uv_work_t* req);
3334
static void LookupAfterWork(uv_work_t* req);

include/commit.h

Lines changed: 39 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,79 @@
1-
/*
2-
* Copyright 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-
*/
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITCOMMIT_H
6+
#define GITCOMMIT_H
77

88
#include <v8.h>
99
#include <node.h>
10-
#include <vector>
10+
#include <string>
1111

1212
#include "git2.h"
1313

14-
#include "reference.h"
15-
#include "repo.h"
16-
#include "oid.h"
17-
#include "tree.h"
18-
1914
using namespace node;
2015
using namespace v8;
2116

22-
/**
23-
* Class wrapper for libgit2 git_commit
24-
*/
2517
class GitCommit : public ObjectWrap {
2618
public:
27-
/**
28-
* v8::FunctionTemplate used to create Node.js constructor
29-
*/
30-
static Persistent<Function> constructor_template;
3119

32-
/**
33-
* Used to intialize the EventEmitter from Node.js
34-
*
35-
* @param target v8::Object the Node.js module object
36-
*/
20+
static Persistent<Function> constructor_template;
3721
static void Initialize (Handle<v8::Object> target);
3822

39-
git_commit* GetValue();
40-
void SetValue(git_commit* commit);
41-
void SetOid(git_oid* oid);
23+
git_commit *GetValue();
4224

43-
protected:
44-
GitCommit() {}
45-
~GitCommit() {}
25+
private:
26+
GitCommit(git_commit *raw);
27+
~GitCommit();
4628

4729
static Handle<Value> New(const Arguments& args);
48-
static Handle<Value> Free(const Arguments& args);
30+
4931

5032
static Handle<Value> Lookup(const Arguments& args);
51-
static void LookupWork(uv_work_t *req);
52-
static void LookupAfterWork(uv_work_t *req);
33+
static void LookupWork(uv_work_t* req);
34+
static void LookupAfterWork(uv_work_t* req);
5335

36+
struct LookupBaton {
37+
uv_work_t request;
38+
const git_error* error;
39+
git_commit * commit;
40+
git_repository * repo;
41+
const git_oid * id;
42+
Persistent<Function> callback;
43+
};
5444
static Handle<Value> Oid(const Arguments& args);
55-
45+
static Handle<Value> MessageEncoding(const Arguments& args);
5646
static Handle<Value> Message(const Arguments& args);
57-
static void MessageWork(uv_work_t* req);
58-
static void MessageAfterWork(uv_work_t* req);
59-
6047
static Handle<Value> Time(const Arguments& args);
61-
static void TimeWork(uv_work_t* req);
62-
static void TimeAfterWork(uv_work_t* req);
63-
6448
static Handle<Value> Offset(const Arguments& args);
65-
static void OffsetWork(uv_work_t* req);
66-
static void OffsetAfterWork(uv_work_t* req);
67-
68-
static Handle<Value> Author(const Arguments& args);
69-
static void AuthorWork(uv_work_t* req);
70-
static void AuthorAfterWork(uv_work_t* req);
71-
7249
static Handle<Value> Committer(const Arguments& args);
73-
static void CommitterWork(uv_work_t* req);
74-
static void CommitterAfterWork(uv_work_t* req);
75-
50+
static Handle<Value> Author(const Arguments& args);
7651
static Handle<Value> Tree(const Arguments& args);
7752
static void TreeWork(uv_work_t* req);
7853
static void TreeAfterWork(uv_work_t* req);
7954

80-
static Handle<Value> Parents(const Arguments& args);
81-
static void ParentsWork(uv_work_t* req);
82-
static void ParentsAfterWork(uv_work_t* req);
83-
84-
private:
85-
git_commit* commit;
86-
git_oid* oid;
87-
88-
struct LookupBaton {
89-
uv_work_t request;
90-
const git_error* error;
91-
92-
git_repository* repo;
93-
git_oid rawOid;
94-
std::string sha;
95-
git_commit* rawCommit;
96-
97-
Persistent<Function> callback;
98-
};
99-
100-
struct MessageBaton {
101-
uv_work_t request;
102-
103-
git_commit* rawCommit;
104-
std::string message;
105-
106-
Persistent<Function> callback;
107-
};
108-
109-
struct TimeBaton {
110-
uv_work_t request;
111-
112-
git_commit* rawCommit;
113-
git_time_t time;
114-
115-
Persistent<Function> callback;
116-
};
117-
118-
struct SignatureBaton {
119-
uv_work_t request;
120-
121-
git_commit* rawCommit;
122-
const git_signature* rawSignature;
123-
124-
Persistent<Function> callback;
125-
};
126-
127-
struct OffsetBaton {
128-
uv_work_t request;
129-
130-
git_commit* rawCommit;
131-
int offset;
132-
133-
Persistent<Function> callback;
134-
};
135-
136-
13755
struct TreeBaton {
13856
uv_work_t request;
13957
const git_error* error;
140-
141-
git_commit* rawCommit;
142-
git_tree* rawTree;
143-
58+
git_tree * tree_out;
59+
const git_commit * commit;
14460
Persistent<Function> callback;
14561
};
62+
static Handle<Value> TreeId(const Arguments& args);
63+
static Handle<Value> ParentCount(const Arguments& args);
64+
static Handle<Value> Parent(const Arguments& args);
65+
static void ParentWork(uv_work_t* req);
66+
static void ParentAfterWork(uv_work_t* req);
14667

147-
struct Parent {
148-
const git_oid* rawOid;
149-
git_commit* rawCommit;
150-
};
151-
152-
struct ParentsBaton {
68+
struct ParentBaton {
15369
uv_work_t request;
15470
const git_error* error;
155-
156-
int index;
157-
git_commit* rawCommit;
158-
std::vector<Parent* > parents;
159-
71+
git_commit * out;
72+
git_commit * commit;
73+
unsigned int n;
16074
Persistent<Function> callback;
16175
};
76+
git_commit *raw;
16277
};
78+
79+
#endif

include/diff_list.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ class GitDiffList : public ObjectWrap {
3232
static void Initialize (Handle<v8::Object> target);
3333

3434
git_diff_list* GetValue();
35-
void SetValue(git_diff_list* diffList);
3635

3736
protected:
38-
GitDiffList() {}
39-
~GitDiffList() {}
37+
GitDiffList(git_diff_list *raw);
38+
~GitDiffList();
4039

4140
static Handle<Value> New(const Arguments& args);
42-
static Handle<Value> Free(const Arguments& args);
4341

4442
static Handle<Value> TreeToTree(const Arguments& args);
4543
static void TreeToTreeWork(uv_work_t *req);
@@ -72,7 +70,7 @@ class GitDiffList : public ObjectWrap {
7270
static void WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/);
7371

7472
private:
75-
git_diff_list* diffList;
73+
git_diff_list* raw;
7674

7775
struct TreeToTreeBaton {
7876
uv_work_t request;

include/object.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITOBJECT_H
6+
#define GITOBJECT_H
7+
8+
#include <v8.h>
9+
#include <node.h>
10+
#include <string>
11+
12+
#include "git2.h"
13+
14+
using namespace node;
15+
using namespace v8;
16+
17+
class GitObject : public ObjectWrap {
18+
public:
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_object *GetValue();
24+
25+
private:
26+
GitObject(git_object *raw);
27+
~GitObject();
28+
29+
static Handle<Value> New(const Arguments& args);
30+
31+
32+
static Handle<Value> Lookup(const Arguments& args);
33+
static void LookupWork(uv_work_t* req);
34+
static void LookupAfterWork(uv_work_t* req);
35+
36+
struct LookupBaton {
37+
uv_work_t request;
38+
const git_error* error;
39+
git_object * object;
40+
git_repository * repo;
41+
const git_oid * id;
42+
git_otype type;
43+
Persistent<Function> callback;
44+
};
45+
static Handle<Value> Oid(const Arguments& args);
46+
static Handle<Value> Type(const Arguments& args);
47+
static Handle<Value> Peel(const Arguments& args);
48+
static void PeelWork(uv_work_t* req);
49+
static void PeelAfterWork(uv_work_t* req);
50+
51+
struct PeelBaton {
52+
uv_work_t request;
53+
const git_error* error;
54+
git_object * peeled;
55+
const git_object * object;
56+
git_otype target_type;
57+
Persistent<Function> callback;
58+
};
59+
git_object *raw;
60+
};
61+
62+
#endif

include/oid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GitOid : public ObjectWrap {
2828

2929
static Handle<Value> New(const Arguments& args);
3030

31+
3132
static Handle<Value> FromString(const Arguments& args);
3233
static Handle<Value> Sha(const Arguments& args);
3334
git_oid *raw;

include/reference.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GitReference : public ObjectWrap {
2828

2929
static Handle<Value> New(const Arguments& args);
3030

31+
3132
static Handle<Value> Lookup(const Arguments& args);
3233
static void LookupWork(uv_work_t* req);
3334
static void LookupAfterWork(uv_work_t* req);

include/repo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GitRepo : public ObjectWrap {
2828

2929
static Handle<Value> New(const Arguments& args);
3030

31+
3132
static Handle<Value> Open(const Arguments& args);
3233
static void OpenWork(uv_work_t* req);
3334
static void OpenAfterWork(uv_work_t* req);

0 commit comments

Comments
 (0)