Skip to content

Commit f2404da

Browse files
committed
Started working on tree.
1 parent 6b6493b commit f2404da

File tree

13 files changed

+65
-40
lines changed

13 files changed

+65
-40
lines changed

binding.gyp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"src/threads.cc",
3030
"src/time.cc",
3131
"src/trace.cc",
32-
#"src/tree.cc",
33-
#"src/treebuilder.cc"
32+
"src/tree.cc",
33+
"src/tree_entry.cc",
3434
],
3535

3636
"include_dirs": [

generate/descriptor.json

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
"git_commit_message": {
7272
"ignore": false,
73-
"args": [{ "isSelf": true }]
73+
"args": [{ "shouldAlloc": true, "isSelf": true }]
7474
},
7575

7676
"git_commit_id": {
@@ -129,7 +129,14 @@
129129
},
130130

131131
"diff": {
132-
"ignore": true
132+
"ignore": true,
133+
134+
"functions": {
135+
"git_diff_tree_to_tree": {
136+
"ignore": false,
137+
"args": [{ "isReturn": true }, { "isSelf": true }]
138+
}
139+
}
133140
},
134141

135142
"errors": {
@@ -306,7 +313,7 @@
306313
"isAsync": false,
307314
"jsFunctionName": "createRevwalk",
308315
"cppFunctionName": "CreateRevwalk",
309-
"args": [{}, { "isSelf": true }]
316+
"args": [{ "shouldAlloc": true }, { "isSelf": true }]
310317
},
311318

312319
"git_revwalk_sorting": {
@@ -462,33 +469,25 @@
462469

463470
"treebuilder": {
464471
"ignore": false,
472+
473+
"isStruct": true,
465474
"cType": "git_treebuilder",
466475

467476
"dependencies": [
468477
"tree.h"
469-
],
470-
471-
"fields": [
472-
{
473-
"name": "entries",
474-
"cType": "git_vector"
475-
},
476-
{
477-
"name": "entrycount",
478-
"cType": "size_t"
479-
}
480478
]
481479
},
482480

483481
"tree_entry": {
484-
"ignore": true,
482+
"ignore": false,
485483

486484
"isStruct": true,
487485
"cType": "git_tree_entry",
488486

489487
"dependencies": [
490488
"../include/tree.h",
491-
"../include/types.h"
489+
"../include/types.h",
490+
"../include/oid.h"
492491
],
493492

494493
"fields": [
@@ -516,12 +515,7 @@
516515
},
517516

518517
"types": {
519-
"ignore": true,
520-
"cType": null
521-
},
522-
523-
"version": {
524-
"ignore": true,
518+
"ignore": false,
525519
"cType": null
526520
}
527521
}

generate/setup.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,29 @@ Object.keys(descriptor).forEach(function(fileName, index) {
7272
}
7373
});
7474

75+
var cFile = libgit2.files[index];
76+
7577
if (file.cType === undefined) {
76-
if (libgit2.files[index].functions.length) {
77-
file.cType = libgit2.files[index].functions[0].split("_").slice(0, 2).join("_");
78+
if (cFile.functions.length) {
79+
file.cType = cFile.functions[0].split("_").slice(0, 2).join("_");
7880
}
7981
}
8082

8183
if (file.cType) {
8284
file.freeFunctionName = "git_" + fileName + "_free";
8385
}
8486

85-
var cFile = libgit2.files[index];
86-
87-
if (!cFile || !cFile.functions) {
87+
if ((!cFile || !cFile.functions) && !file.isStruct) {
8888
return;
8989
}
9090

91+
// TODO Obsolete this.
92+
if (file.isStruct) {
93+
// No functions.
94+
cFile = file;
95+
cFile.functions = [];
96+
}
97+
9198
// Doesn't actually exist.
9299
if (cFile.functions.indexOf(file.freeFunctionName) === -1) {
93100
delete file.freeFunctionName;
@@ -159,7 +166,13 @@ Object.keys(descriptor).forEach(function(fileName, index) {
159166
// Used to identify a missing function descriptor later on.
160167
var ident = {};
161168

162-
file.functions = libgit2.files[index].functions.map(function(functionName, index) {
169+
//Object.keys(file.functions || {}).forEach(function(functionName) {
170+
// if (cFile.functions.indexOf(functionName) === -1 && functionName) {
171+
// cFile.functions.push(functionName);
172+
// }
173+
//});
174+
175+
file.functions = cFile.functions.map(function(functionName, index) {
163176
var funcDescriptor = libgit2.functions[functionName];
164177
var descriptor = legacyFile.functions ? legacyFile.functions[index] || {} : {};
165178
var cType = file.cType || "git";

generate/templates/class.cc.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void <%- cppClassName %>::Initialize(Handle<v8::Object> target) {
143143
var arg = functionInfo.args[i];
144144
if (arg.isReturn) returns.push(arg);
145145
}
146+
functionInfo.return = functionInfo.return || {};
146147
if (!returns.length && !functionInfo.return.isErrorCode && functionInfo.return.cType != "void") returns.push(functionInfo.return);
147148
-%>
148149

generate/templates/guardArguments.cc.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
var arg = functionInfo.args[cArg];
55
if (arg.isReturn || arg.isSelf || arg.isPayload) continue;
66
-%>
7-
<% if (!arg.isOptional) { -%>
7+
<% if (arg.isOptional == false) { -%>
88
if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) {
99
return NanThrowError("<%- arg.jsClassName %> <%- arg.name %> is required.");
1010
}

generate/templates/header.h.ejs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111
#include "git2.h"
1212

13+
<% if (typeof isStruct !== "undefined") { %>
14+
// Forward declaration.
15+
struct <%- cType %> {
16+
uint16_t removed;
17+
uint16_t attr;
18+
git_oid oid;
19+
size_t filename_len;
20+
char filename[1];
21+
};
22+
<% } %>
23+
1324
using namespace node;
1425
using namespace v8;
1526

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require('./lib/index.js');
2323
require('./lib/repository.js');
2424
require('./lib/reference.js');
2525
require('./lib/revwalk.js');
26-
//require('./lib/tree.js');
26+
require('./lib/tree.js');
2727

2828
// Set version
2929
exports.version = require('./package').version;

lib/commit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var git = require('../');
22
var Commit = git.Commit;
33
var Oid = git.Oid;
44
var events = require('events');
5-
//var Tree = require("./tree");
5+
var Tree = require("./tree");
66

77
// Backwards compatibility.
88
Object.defineProperties(Commit.prototype, {

lib/repository.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Commit = git.Commit;
55
var Revwalk = git.Revwalk;
66
var Repo = git.Repository;
77
var Blob = git.Blob;
8-
//var Tree = git.Tree;
8+
var Tree = git.Tree;
99
//var TreeBuilder = git.TreeBuilder;
1010
var Reference = git.Reference;
1111

@@ -18,7 +18,7 @@ Object.defineProperty(git, "Repo", {
1818
var oldGetReference = Reference.prototype.lookup,
1919
oldGetCommit = Commit.prototype.lookup,
2020
oldBlob = Blob.prototype.lookup,
21-
//oldGetTree = Tree.prototype.lookup,
21+
oldGetTree = Tree.prototype.lookup,
2222
oldGetTag = Repo.prototype.getTag,
2323
oldCreateRevwalk = Revwalk.prototype.createRevwalk,
2424
oldCreateCommit = Repo.prototype.createCommit,

lib/tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Tree.prototype.getEntry = function(path, callback) {
7575
* @return {[TreeEntry]} an array of TreeEntrys
7676
*/
7777
Tree.prototype.entries = function() {
78-
var size = this.size(),
78+
var size = this.entrycount(),
7979
result = [];
8080
for (var i = 0; i < size; i++) {
8181
result.push(this.entryByIndex(i));

0 commit comments

Comments
 (0)