Skip to content

Commit 135104e

Browse files
committed
More work.
1 parent 7f451b3 commit 135104e

File tree

3 files changed

+51
-27
lines changed

3 files changed

+51
-27
lines changed

build/codegen/t.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ Object.keys(descriptor).forEach(function(fileName, index) {
119119
return "../include/" + file + ".h";
120120
});
121121

122-
/*
123122

124123
// Add to the type's list if it's new.
125124
typeMap["const " + "git_" + fileName + " *"] =
@@ -134,14 +133,19 @@ Object.keys(descriptor).forEach(function(fileName, index) {
134133
file.functions = libgit2.files[index].functions.map(function(functionName, index) {
135134
var funcDescriptor = libgit2.functions[functionName];
136135
var descriptor = legacyFile.functions ? legacyFile.functions[index] || {} : {};
137-
var cType = file.cType || "";
136+
var cType = file.cType || "git";
138137

139138
if (!functionName || !funcDescriptor) { return; }
140139

141140
descriptor.cFunctionName = functionName;
141+
descriptor.ignore = true;
142142

143143
var trimmedName = functionName.slice(cType.length + 1);
144144

145+
if (trimmedName === "new") {
146+
trimmedName = "new2";
147+
}
148+
145149
descriptor.cppFunctionName = titleCase(trimmedName);
146150
descriptor.jsFunctionName = camelCase(trimmedName);
147151

@@ -154,9 +158,9 @@ Object.keys(descriptor).forEach(function(fileName, index) {
154158
};
155159

156160
var retVal = descriptor.return = {};
157-
retVal.ctype = funcDescriptor.return.type;
161+
retVal.cType = funcDescriptor.return.type;
158162

159-
var type = typeMap[retVal.ctype];
163+
var type = typeMap[retVal.cType];
160164
retVal.cppClassName = type.cpp;
161165
retVal.jsClassName = type.js;
162166

@@ -185,9 +189,11 @@ Object.keys(descriptor).forEach(function(fileName, index) {
185189
return descriptor;
186190
});
187191

188-
*/
189192
files.push(file);
190193
});
191194

195+
fs.writeFileSync(path.join(__dirname, "types.json"),
196+
JSON.stringify(typeMap, null, 2));
197+
192198
fs.writeFileSync(path.join(__dirname, "compare.json"),
193199
JSON.stringify(files, null, 2));

build/codegen/templates/convertFromV8.cc.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<% } -%>
66
<% if (arg.cppClassName == 'String') { -%>
77
String::Utf8Value <%- arg.name %>(args[<%- jsArg %>]->ToString());
8-
from_<%- arg.name %> = strdup(*<%- arg.name %>);
8+
from_<%- arg.name %> = (<%- arg.cType %>) strdup(*<%- arg.name %>);
99
<% } else if (arg.cppClassName == 'Array') { -%>
1010
Array *tmp_<%- arg.name %> = Array::Cast(*args[<%- jsArg %>]);
1111
from_<%- arg.name %> = (<%- arg.cType %>)malloc(tmp_<%- arg.name %>->Length() * sizeof(<%- arg.cType.replace('**', '*') %>));

build/codegen/tmp.js

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
n = require("./new.json")
1+
//n = require("./new.json")
2+
//
3+
//lookup = {}
4+
//
5+
//n.forEach(function(a) {
6+
// a.functions = a.functions || []
7+
// a.functions.forEach(function(b) {
8+
// lookup[b.cFunctionName] = {
9+
// js: b.jsFunctionName,
10+
// cpp: b.cppFunctionName
11+
// }
12+
//
13+
// b.args.forEach(function(c) {
14+
// lookup[c.cType] = {
15+
// js: c.jsClassName,
16+
// cpp: c.cppClassName
17+
// };
18+
// })
19+
//
20+
// lookup[b.return.cType] = {
21+
// js: b.return.cppClassName,
22+
// cpp: b.return.jsClassName
23+
// }
24+
// })
25+
//})
26+
//
27+
//console.log(JSON.stringify(lookup, null, 2))
28+
//
229

3-
lookup = {}
30+
types = require("./types.json");
31+
fs = require("fs");
432

5-
n.forEach(function(a) {
6-
a.functions = a.functions || []
7-
a.functions.forEach(function(b) {
8-
lookup[b.cFunctionName] = {
9-
js: b.jsFunctionName,
10-
cpp: b.cppFunctionName
11-
}
33+
Object.keys(types).forEach(function(typeName) {
34+
var type = types[typeName];
1235

13-
b.args.forEach(function(c) {
14-
lookup[c.cType] = {
15-
js: c.jsClassName,
16-
cpp: c.cppClassName
17-
};
18-
})
36+
if (!type.cpp) { return; }
1937

20-
lookup[b.return.cType] = {
21-
js: b.return.cppClassName,
22-
cpp: b.return.jsClassName
38+
if (type.cpp.indexOf("Git") === -1) {
39+
if (type.cpp[0] === type.cpp[0].toUpperCase()) {
40+
type.cpp = "Git" + type.cpp;
2341
}
24-
})
25-
})
42+
}
43+
});
2644

27-
console.log(JSON.stringify(lookup, null, 2))
45+
fs.writeFileSync("./types.json", JSON.stringify(types, null, 2));

0 commit comments

Comments
 (0)