Skip to content

Commit 9277eb2

Browse files
committed
Enabled most of Git Clone support
1 parent 64ce4e8 commit 9277eb2

7 files changed

Lines changed: 231 additions & 174 deletions

File tree

generate/descriptor.json

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{
2-
"attr": {
1+
{ "attr": {
32
"cType": null,
43

54
"functions": {
@@ -117,19 +116,43 @@
117116
},
118117

119118
"git_checkout_init_options": {
120-
"ignore": false
119+
"ignore": true
121120
}
122121
}
123122
},
124123

125-
"checkout_options": {
126-
"isStruct": true,
127-
"cType": "git_checkout_options",
128-
"fields": []
124+
"clone": {
125+
"cType": null,
126+
127+
"dependencies": [
128+
"../include/clone_options.h",
129+
"../include/checkout_opts.h",
130+
"../include/repository.h",
131+
"../include/remote.h"
132+
],
133+
134+
"functions": {
135+
"git_clone": {
136+
"ignore": false,
137+
"isConstructorMethod": true,
138+
"args": [{}, {}, {}, { "isOptional": true }]
139+
},
140+
141+
"git_clone_into": {
142+
"ignore": false,
143+
"isConstructorMethod": true,
144+
"args": [{}, {}, { "isOptional": true }]
145+
}
146+
}
129147
},
130148

131-
"clone": {
132-
"cType": null
149+
"clone_options": {
150+
"cType": "git_clone_options",
151+
"isStruct": true,
152+
"dependencies": [
153+
"../include/checkout_opts.h",
154+
"../include/remote_callbacks.h"
155+
]
133156
},
134157

135158
"commit": {
@@ -627,6 +650,12 @@
627650
}
628651
},
629652

653+
"remote_callbacks": {
654+
"isStruct": true,
655+
"cType": "git_remote_callbacks",
656+
"fields": []
657+
},
658+
630659
"repository": {
631660
"dependencies": [
632661
"../include/functions/copy.h",

generate/partials/convert_to_v8.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ to = NanNew<External>((void *){{= parsedName =}});
2222
{%--
2323
// FIXME this is not general purpose enough.
2424
--%}
25+
{%if size%}
2526
Local<Array> tmpArray = NanNew<Array>({{= parsedName =}}->{{ size }});
2627
for (unsigned int i = 0; i < {{= parsedName =}}->{{ size }}; i++) {
2728
tmpArray->Set(NanNew<Number>(i), NanNew<String>({{= parsedName =}}->{{ key }}[i]));
2829
}
30+
{%else%}
31+
Local<Array> tmpArray = NanNew<Array>({{= parsedName =}});
32+
{%endif%}
2933
to = tmpArray;
3034
{%else%}
3135
{%if copy %}

generate/setup.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ typeMap.__proto__ = {
5050
"const git_merge_options *": { cpp: "GitMergeOptions", js: "MergeOptions" }
5151
};
5252

53+
typeMap["void *"] = { cpp: "Function", js: "Function" };
54+
5355
var files = [];
5456

5557
function titleCase(str) {
@@ -76,7 +78,7 @@ var fileNames = Object.keys(descriptor);
7678

7779
fileNames.forEach(function(fileName, index) {
7880
var file = descriptor[fileName];
79-
var structFile = structs["git_" + fileName];
81+
var structFile = structs["git_" + fileName] || {};
8082

8183
// Constants.
8284
file.filename = fileName + ".h";
@@ -110,7 +112,7 @@ fileNames.forEach(function(fileName, index) {
110112
// No functions.
111113
cFile = Object.create(file);
112114
cFile.functions = [];
113-
cFile.fields = descriptor[fileName].fields || structFile.fields;
115+
cFile.fields = descriptor[fileName].fields || structFile.fields || [];
114116
}
115117

116118
// Doesn't actually exist.
@@ -167,7 +169,12 @@ fileNames.forEach(function(fileName, index) {
167169
js: file.jsClassName
168170
};
169171

170-
var fields = file.fields || cFile.fields || (structFile ? structFile.fields || [] : []);
172+
var fields = file.fields || cFile.fields || (structFile ? structFile.fields || [] : []) || [];
173+
174+
// Ensure fields is actually an Array.
175+
if (!Array.isArray(fields)) {
176+
fields = [];
177+
}
171178

172179
// Decorate fields.
173180
file.fields = fields.map(function(field) {

0 commit comments

Comments
 (0)