Skip to content

Commit d9ea5a6

Browse files
committed
Diff is now code-gen'd
1 parent 607ed27 commit d9ea5a6

Some content is hidden

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

57 files changed

+3719
-1799
lines changed

TODO

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
- 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
42
- rename all async methods getXXX
3+
- convert to "ignore": true for all classes
4+
- reorder functions so the raw api is oo-like
5+
- rename files remove .h
6+
- remove stringArgToString invocation

binding.gyp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
'src/time.cc',
1919
'src/tree.cc',
2020
'src/tree_entry.cc',
21+
'src/diff_find_options.cc',
22+
'src/diff_options.cc',
2123
'src/diff_list.cc',
24+
'src/patch.cc',
25+
'src/delta.cc',
26+
'src/diff_file.cc',
27+
'src/diff_range.cc',
2228
'src/threads.cc',
2329
'src/wrapper.cc',
2430
'src/functions/string.cc',

gen.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ var fs = require('fs'),
33
path = require('path');
44

55
var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')),
6-
classTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/class.cc.ejs")).toString()),
7-
headerTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/header.h.ejs")).toString());
6+
classTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/class.cc.ejs")).toString(), {filename: 'class.cc'}),
7+
headerTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/header.h.ejs")).toString(), {filename: 'header.h'});
88

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

include/blob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class GitBlob : public ObjectWrap {
2222

2323
git_blob *GetValue();
2424

25+
static Handle<Value> New(void *raw);
26+
2527
private:
2628
GitBlob(git_blob *raw);
2729
~GitBlob();

include/commit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class GitCommit : public ObjectWrap {
2222

2323
git_commit *GetValue();
2424

25+
static Handle<Value> New(void *raw);
26+
2527
private:
2628
GitCommit(git_commit *raw);
2729
~GitCommit();

include/delta.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITDELTA_H
6+
#define GITDELTA_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 GitDelta : public ObjectWrap {
18+
public:
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_diff_delta *GetValue();
24+
25+
static Handle<Value> New(void *raw);
26+
27+
private:
28+
GitDelta(git_diff_delta *raw);
29+
~GitDelta();
30+
31+
static Handle<Value> New(const Arguments& args);
32+
33+
static Handle<Value> OldFile(const Arguments& args);
34+
static Handle<Value> NewFile(const Arguments& args);
35+
static Handle<Value> Status(const Arguments& args);
36+
static Handle<Value> Similarity(const Arguments& args);
37+
static Handle<Value> Flags(const Arguments& args);
38+
39+
git_diff_delta *raw;
40+
};
41+
42+
#endif

include/diff.h

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITDIFF_H
6+
#define GITDIFF_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 GitDiff : public ObjectWrap {
18+
public:
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_diff_list *GetValue();
24+
25+
private:
26+
GitDiff(git_diff_list *raw);
27+
~GitDiff();
28+
29+
static Handle<Value> New(const Arguments& args);
30+
31+
32+
static Handle<Value> TreeToTree(const Arguments& args);
33+
static void TreeToTreeWork(uv_work_t* req);
34+
static void TreeToTreeAfterWork(uv_work_t* req);
35+
36+
struct TreeToTreeBaton {
37+
uv_work_t request;
38+
const git_error* error;
39+
git_diff_list * diff;
40+
Persistent<Value> repoReference;
41+
git_repository * repo;
42+
Persistent<Value> old_treeReference;
43+
git_tree * old_tree;
44+
Persistent<Value> new_treeReference;
45+
git_tree * new_tree;
46+
Persistent<Value> optsReference;
47+
const git_diff_options * opts;
48+
Persistent<Function> callback;
49+
};
50+
static Handle<Value> TreeToIndex(const Arguments& args);
51+
static void TreeToIndexWork(uv_work_t* req);
52+
static void TreeToIndexAfterWork(uv_work_t* req);
53+
54+
struct TreeToIndexBaton {
55+
uv_work_t request;
56+
const git_error* error;
57+
git_diff_list * diff;
58+
Persistent<Value> repoReference;
59+
git_repository * repo;
60+
Persistent<Value> old_treeReference;
61+
git_tree * old_tree;
62+
Persistent<Value> indexReference;
63+
git_index * index;
64+
Persistent<Value> optsReference;
65+
const git_diff_options * opts;
66+
Persistent<Function> callback;
67+
};
68+
static Handle<Value> IndexToWorkdir(const Arguments& args);
69+
static void IndexToWorkdirWork(uv_work_t* req);
70+
static void IndexToWorkdirAfterWork(uv_work_t* req);
71+
72+
struct IndexToWorkdirBaton {
73+
uv_work_t request;
74+
const git_error* error;
75+
git_diff_list * diff;
76+
Persistent<Value> repoReference;
77+
git_repository * repo;
78+
Persistent<Value> indexReference;
79+
git_index * index;
80+
Persistent<Value> optsReference;
81+
const git_diff_options * opts;
82+
Persistent<Function> callback;
83+
};
84+
static Handle<Value> TreeToWorkdir(const Arguments& args);
85+
static void TreeToWorkdirWork(uv_work_t* req);
86+
static void TreeToWorkdirAfterWork(uv_work_t* req);
87+
88+
struct TreeToWorkdirBaton {
89+
uv_work_t request;
90+
const git_error* error;
91+
git_diff_list * diff;
92+
Persistent<Value> repoReference;
93+
git_repository * repo;
94+
Persistent<Value> old_treeReference;
95+
git_tree * old_tree;
96+
Persistent<Value> optsReference;
97+
const git_diff_options * opts;
98+
Persistent<Function> callback;
99+
};
100+
static Handle<Value> Merge(const Arguments& args);
101+
static Handle<Value> FindSimilar(const Arguments& args);
102+
static Handle<Value> StatusChar(const Arguments& args);
103+
static Handle<Value> NumDeltas(const Arguments& args);
104+
static Handle<Value> NumDeltasOfType(const Arguments& args);
105+
static Handle<Value> GetPatch(const Arguments& args);
106+
git_diff_list *raw;
107+
};
108+
109+
#endif

include/diff_file.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITDIFFFILE_H
6+
#define GITDIFFFILE_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 GitDiffFile : public ObjectWrap {
18+
public:
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_diff_file *GetValue();
24+
25+
static Handle<Value> New(void *raw);
26+
27+
private:
28+
GitDiffFile(git_diff_file *raw);
29+
~GitDiffFile();
30+
31+
static Handle<Value> New(const Arguments& args);
32+
33+
static Handle<Value> Oid(const Arguments& args);
34+
static Handle<Value> Path(const Arguments& args);
35+
static Handle<Value> Size(const Arguments& args);
36+
static Handle<Value> Flags(const Arguments& args);
37+
static Handle<Value> Mode(const Arguments& args);
38+
39+
git_diff_file *raw;
40+
};
41+
42+
#endif

include/diff_find_options.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITDIFFFINDOPTIONS_H
6+
#define GITDIFFFINDOPTIONS_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 GitDiffFindOptions : public ObjectWrap {
18+
public:
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_diff_find_options *GetValue();
24+
25+
static Handle<Value> New(void *raw);
26+
27+
private:
28+
GitDiffFindOptions(git_diff_find_options *raw);
29+
~GitDiffFindOptions();
30+
31+
static Handle<Value> New(const Arguments& args);
32+
33+
34+
git_diff_find_options *raw;
35+
};
36+
37+
#endif

0 commit comments

Comments
 (0)