Skip to content

Commit 002ed81

Browse files
committed
remove manually generated enums
1 parent bd4bf7e commit 002ed81

File tree

21 files changed

+180
-185
lines changed

21 files changed

+180
-185
lines changed

example/general.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
179179
oid = nodegit.Oid.fromString("e1b0c7ea57bfc5e30ec279402a98168a27838ac9");
180180
return repo.getTree(oid);
181181
}).then(function(tree) {
182-
console.log("Tree Size:", tree.size());
182+
console.log("Tree Size:", tree.entryCount());
183183

184184
function dfs(tree) {
185185
var promises = [];
@@ -248,7 +248,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
248248
// of `branch1`.
249249
var revWalk = repo.createRevWalk();
250250

251-
revWalk.sorting(nodegit.Revwalk.Sort.Topological, nodegit.Revwalk.Sort.Reverse);
251+
revWalk.sorting(nodegit.Revwalk.SORT.TOPOLOGICAL, nodegit.Revwalk.SORT.REVERSE);
252252

253253
revWalk.push(oid);
254254

example/walk-history.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var nodegit = require('../'),
2-
path = require('path'),
3-
sort = nodegit.Revwalk.Sort;
2+
path = require('path');
43

54
// This code walks the history of the master branch and prints results
65
// that look very similar to calling `git log` from the command line
@@ -9,7 +8,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git')).then(function(repo)
98
return repo.getMasterCommit();
109
}).then(function(firstCommitOnMaster){
1110
// History returns an event.
12-
var history = firstCommitOnMaster.history(sort.Time);
11+
var history = firstCommitOnMaster.history(nodegit.Revwalk.SORT.Time);
1312

1413
// History emits 'commit' event for each commit in the branch's history
1514
history.on('commit', function(commit) {

generate/descriptor.json

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
}
1313
}
1414
},
15+
"delta": {
16+
"owner": "Diff"
17+
},
1518
"error": {
1619
"JsName": "ERROR",
1720
"isMask": false
@@ -23,6 +26,57 @@
2326
}
2427
}
2528
},
29+
"filemode": {
30+
"owner": "TreeEntry",
31+
"values": {
32+
"GIT_FILEMODE_BLOB_EXECUTABLE": {
33+
"JsName": "EXECUTABLE"
34+
}
35+
}
36+
},
37+
"otype": {
38+
"JsName": "TYPE",
39+
"owner": "Object",
40+
"values": {
41+
"GIT_OBJ_ANY": {
42+
"JsName": "ANY"
43+
},
44+
"GIT_OBJ_BAD": {
45+
"JsName": "BAD"
46+
},
47+
"GIT_OBJ__EXT1": {
48+
"JsName": "EXT1"
49+
},
50+
"GIT_OBJ_COMMIT": {
51+
"JsName": "COMMIT"
52+
},
53+
"GIT_OBJ_TREE": {
54+
"JsName": "TREE"
55+
},
56+
"GIT_OBJ_BLOB": {
57+
"JsName": "BLOB"
58+
},
59+
"GIT_OBJ_TAG": {
60+
"JsName": "TAG"
61+
},
62+
"GIT_OBJ__EXT2": {
63+
"JsName": "EXT2"
64+
},
65+
"GIT_OBJ_OFS_DELTA": {
66+
"JsName": "OFS_DELTA"
67+
},
68+
"GIT_OBJ_REF_DELTA": {
69+
"JsName": "REF_DELTA"
70+
}
71+
}
72+
},
73+
"ref": {
74+
"owner": "Refs",
75+
"JsName": "TYPE"
76+
},
77+
"sort": {
78+
"owner": "Revwalk"
79+
},
2680
"status": {
2781
"JsName": "STATUS",
2882
"isMask": false
@@ -575,9 +629,6 @@
575629
"git_index_free": {
576630
"ignore": true
577631
},
578-
"git_index_get_byindex": {
579-
"jsFunctionName": "entry"
580-
},
581632
"git_index_new": {
582633
"ignore": true
583634
},
@@ -1222,6 +1273,12 @@
12221273
},
12231274
"tree": {
12241275
"functions": {
1276+
"git_tree_entry_byindex": {
1277+
"jsFunctionName": "_entryByIndex"
1278+
},
1279+
"git_tree_entrycount": {
1280+
"jsFunctionName": "entryCount"
1281+
},
12251282
"git_tree_walk": {
12261283
"ignore": true
12271284
}

generate/index.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
8888

8989

9090
// Write out all the classes.
91-
var enums = [];
9291
enabled.forEach(function(idef) {
9392
try {
94-
9593
if (idef.type == "struct") {
9694
file.write("../src/" + idef.filename + ".cc", templates.struct_content.render(idef));
9795
file.write("../include/" + idef.filename + ".h", templates.struct_header.render(idef));
@@ -100,29 +98,11 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
10098
file.write("../src/" + idef.filename + ".cc", templates.class_content.render(idef));
10199
file.write("../include/" + idef.filename + ".h", templates.class_header.render(idef));
102100
}
103-
else if (idef.type == "enum") {
104-
enums.push(idef);
105-
}
106101
}
107102
catch (e) {
108103
console.log(e);
109104
}
110105
});
111106

112-
enums = enums.reduce(function(memo, enumerable) {
113-
114-
memo[enumerable.owner] = memo[enumerable.owner] || [];
115-
116-
memo[enumerable.owner].push(enumerable);
117-
delete enumerable.owner;
118-
return memo;
119-
}, {});
120-
121-
122-
var output = [];
123-
Object.keys(enums).forEach(function(key) {
124-
output.push({owner: key, enums: enums[key]});
125-
});
126-
127-
file.write("../lib/enums.js", templates.enums.render(output));
107+
file.write("../lib/enums.js", templates.enums.render(enabled));
128108
});

generate/libgit2-supplement.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,40 @@
188188
"type": "enum"
189189
}
190190
],
191+
[
192+
"git_sort_t",
193+
{
194+
"type": "enum",
195+
"description": "Flags to specify the sorting which a revwalk should perform.",
196+
"fields": [
197+
{
198+
"type": "int",
199+
"name": "GIT_SORT_NONE",
200+
"comments": "Sort the repository contents in no particular ordering; this sorting is arbitrary, implementation-specific and subject to change at any time. This is the default sorting for new walkers.",
201+
"value": 0
202+
},
203+
{
204+
"type": "int",
205+
"name": "GIT_SORT_TOPOLOGICAL",
206+
"comments": "Sort the repository contents in topological order (parents before children); this sorting mode can be combined with time sorting.",
207+
"value": 1
208+
},
209+
{
210+
"type": "int",
211+
"name": "GIT_SORT_TIME",
212+
"comments": "Sort the repository contents by commit time; this sorting mode can be combined with topological sorting.",
213+
"value": 2
214+
},
215+
{
216+
"type": "int",
217+
"name": "GIT_SORT_REVERSE",
218+
"comments": "Iterate through the repository contents in reverse order; this sorting mode can be combined with any of the above.",
219+
"value": 4
220+
}
221+
],
222+
"comments": ""
223+
}
224+
],
191225
[
192226
"git_time_t",
193227
{

generate/setup.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ output.forEach(function (def) {
160160
def.name = path.basename(def.filename, ".h");
161161

162162
def.functions.forEach(function(fn) {
163-
if (fn) {
164-
fn.cppClassName = def.cppClassName;
165-
}
163+
fn.cppClassName = def.cppClassName;
166164
});
167165
});
168166

@@ -179,7 +177,7 @@ _(enums).forEach(function(enumerable) {
179177

180178
var override = descriptor.enums[enumerable.typeName] || {};
181179

182-
enumerable.owner = enumerable.owner || "Enums";
180+
enumerable.owner = override.owner || enumerable.owner || "Enums";
183181

184182
enumerable.JsName = enumerable.typeName
185183
.replace(new RegExp("^" + enumerable.owner.toLowerCase()), "")

generate/templates/enums.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ var NodeGit = require("../");
22
NodeGit.Enums = {};
33

44
/* jshint ignore:start */
5-
{% each %}
6-
var {{ owner }} = NodeGit.{{ owner }};
7-
8-
{% each enums as enumerable %}
9-
{% if enumerable.type == "enum" %}
10-
{{ owner }}.{{ enumerable.JsName }} = {
11-
{% each enumerable.values as value %}
5+
{% each . as enumerable %}
6+
{% if enumerable.type == "enum" %}
7+
NodeGit.{{ enumerable.owner }}.{{ enumerable.JsName }} = {
8+
{% each enumerable.values as value %}
129
{{ value.JsName }}: {{ value.value }},
13-
{% endeach %}
10+
{% endeach %}
1411
};
15-
{% endif %}
16-
{% endeach %}
1712

13+
{% endif %}
1814
{% endeach %}
15+
1916
/* jshint ignore:end */

lib/blob.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Blob.prototype.toString = function() {
2727
* @return {number} The filemode.
2828
*/
2929
Blob.prototype.filemode = function() {
30-
var FileMode = TreeEntry.FileMode;
30+
var FileMode = TreeEntry.FILEMODE;
3131

32-
return this.isBinary() ? FileMode.Executable : FileMode.Blob;
32+
return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
3333
};
3434

3535
module.exports = Blob;

lib/convenient_patch.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,71 +59,71 @@ ConvenientPatch.prototype.status = function() {
5959
* @return {Boolean}
6060
*/
6161
ConvenientPatch.prototype.isUnmodified = function() {
62-
return this.status() == Diff.Delta.Unmodified;
62+
return this.status() == Diff.DELTA.UNMODIFIED;
6363
};
6464

6565
/**
6666
* Is this an added patch?
6767
* @return {Boolean}
6868
*/
6969
ConvenientPatch.prototype.isAdded = function() {
70-
return this.status() == Diff.Delta.Added;
70+
return this.status() == Diff.DELTA.ADDED;
7171
};
7272

7373
/**
7474
* Is this a deleted patch?
7575
* @return {Boolean}
7676
*/
7777
ConvenientPatch.prototype.isDeleted = function() {
78-
return this.status() == Diff.Delta.Deleted;
78+
return this.status() == Diff.DELTA.DELETED;
7979
};
8080

8181
/**
8282
* Is this an modified patch?
8383
* @return {Boolean}
8484
*/
8585
ConvenientPatch.prototype.isModified = function() {
86-
return this.status() == Diff.Delta.Modified;
86+
return this.status() == Diff.DELTA.MODIFIED;
8787
};
8888

8989
/**
9090
* Is this a renamed patch?
9191
* @return {Boolean}
9292
*/
9393
ConvenientPatch.prototype.isRenamed = function() {
94-
return this.status() == Diff.Delta.Renamed;
94+
return this.status() == Diff.DELTA.RENAMED;
9595
};
9696

9797
/**
9898
* Is this a copied patch?
9999
* @return {Boolean}
100100
*/
101101
ConvenientPatch.prototype.isCopied = function() {
102-
return this.status() == Diff.Delta.Copied;
102+
return this.status() == Diff.DELTA.COPIED;
103103
};
104104

105105
/**
106106
* Is this an ignored patch?
107107
* @return {Boolean}
108108
*/
109109
ConvenientPatch.prototype.isIgnored = function() {
110-
return this.status() == Diff.Delta.Ignored;
110+
return this.status() == Diff.DELTA.IGNORED;
111111
};
112112

113113
/**
114114
* Is this an untracked patch?
115115
* @return {Boolean}
116116
*/
117117
ConvenientPatch.prototype.isUntracked = function() {
118-
return this.status() == Diff.Delta.Untracked;
118+
return this.status() == Diff.DELTA.UNTRACKED;
119119
};
120120

121121
/**
122122
* Is this a type change?
123123
* @return {Boolean}
124124
*/
125125
ConvenientPatch.prototype.isTypeChange = function() {
126-
return this.status() == Diff.Delta.TypeChange;
126+
return this.status() == Diff.DELTA.TYPECHANGE;
127127
};
128128

129129
module.exports = ConvenientPatch;

lib/diff.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,6 @@ var ConvenientPatch = require("./convenient_patch");
44

55
var Diff = NodeGit.Diff;
66

7-
/**
8-
* Refer to vendor/libgit2/include/git2/diff.h for delta type definitions.
9-
*
10-
* @readonly
11-
* @enum {Integer}
12-
*/
13-
Diff.Delta = {
14-
/** 0 */ Unmodified: 0,
15-
/** 1 */ Added: 1,
16-
/** 2 */ Deleted: 2,
17-
/** 3 */ Modified: 3,
18-
/** 4 */ Renamed: 4,
19-
/** 5 */ Copied: 5,
20-
/** 6 */ Ignored: 6,
21-
/** 7 */ Untracked: 7,
22-
/** 8 */ TypeChange: 8
23-
};
24-
25-
/**
26-
* Refer to vendor/libgit2/include/git2/diff.h for line origin type definitions.
27-
*
28-
* @readOnly
29-
* @enum {String}
30-
*/
31-
Diff.LineOrigin = {
32-
/** " " */ Context: 32,
33-
/** "+" */ Addition: 43,
34-
/** "-" */ Deletion: 45,
35-
/** "\n" */ AddEofNl: 13,
36-
/** "" */ DelEofNl: 0,
37-
/** "F" */ FileHdr: 106,
38-
/** "H" */ HunkHdr: 110,
39-
/** "B" */ Binary: 102
40-
};
41-
427
/**
438
* Retrieve patches in this difflist
449
*

0 commit comments

Comments
 (0)