@@ -5,6 +5,10 @@ var version = require("../package.json").libgit2.version;
55var descriptor = require ( "./descriptor.json" ) ;
66var libgit2 = require ( "./v" + version + ".json" ) ;
77
8+ var structs = libgit2 . types . reduce ( function ( memo , current ) {
9+ return memo [ current [ 0 ] ] = current [ 1 ] , memo ;
10+ } , { } ) ;
11+
812// Extracted types.
913var typeMap = require ( "./types.json" ) ;
1014
@@ -29,7 +33,15 @@ typeMap.__proto__ = {
2933 "git_branch_iterator **" : { cpp : "BranchIterator" , js : "Iterator" } ,
3034 "git_branch_t *" : { cpp : "GitBranch" , js : "Branch" } ,
3135 "const git_commit *[]" : { cpp : "Array" , js : "Array" } ,
32- "git_diff_file" : { cpp : "GitDiffFile" , js : "DiffFile" }
36+ "git_diff_file" : { cpp : "GitDiffFile" , js : "DiffFile" } ,
37+ "git_strarray" : { cpp : "Array" , js : "Array" } ,
38+ "git_diff_notify_cb" : { cpp : "GitDiffNotifyCb" , js : "DiffNotifyCb" } ,
39+ "unsigned char [20]" : { cpp : "Array" , js : "Array" } ,
40+ "git_filter_init_fn" : { cpp : "Function" , js : "Function" } ,
41+ "git_filter_shutdown_fn" : { cpp : "Function" , js : "Function" } ,
42+ "git_filter_check_fn" : { cpp : "Function" , js : "Function" } ,
43+ "git_filter_apply_fn" : { cpp : "Function" , js : "Function" } ,
44+ "git_filter_cleanup_fn" : { cpp : "Function" , js : "Function" } ,
3345} ;
3446
3547var files = [ ] ;
@@ -58,6 +70,7 @@ var fileNames = Object.keys(descriptor);
5870
5971fileNames . forEach ( function ( fileName , index ) {
6072 var file = descriptor [ fileName ] ;
73+ var structFile = structs [ "git_" + fileName ] ;
6174
6275 // Constants.
6376 file . filename = fileName + ".h" ;
@@ -90,6 +103,7 @@ fileNames.forEach(function(fileName, index) {
90103 // No functions.
91104 cFile = Object . create ( file ) ;
92105 cFile . functions = [ ] ;
106+ cFile . fields = descriptor [ fileName ] . fields || structFile . fields ;
93107 }
94108
95109 // Doesn't actually exist.
@@ -146,17 +160,18 @@ fileNames.forEach(function(fileName, index) {
146160 js : file . jsClassName
147161 } ;
148162
149- var fields = file . fields || [ ] ;
163+ var fields = file . fields || cFile . fields || ( structFile ? structFile . fields || [ ] : [ ] ) ;
150164
151165 // Decorate fields.
152166 file . fields = fields . map ( function ( field ) {
153167 try {
168+ field . cType = field . cType || field . type ;
154169 field . cppFunctionName = titleCase ( field . name ) ;
155170 field . jsFunctionName = camelCase ( field . name ) ;
156171 field . cppClassName = typeMap [ field . cType ] . cpp ;
157172 field . jsClassName = typeMap [ field . cType ] . js ;
158173 } catch ( ex ) {
159- console . error ( field . name + " is missing a definition." ) ;
174+ console . error ( file . filename , field . cType + " is missing a definition." ) ;
160175 }
161176
162177 return field ;
0 commit comments