From 086b66c1a7c45d1d974c4d682ec5ed9c1d237cf9 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Thu, 17 Jul 2014 21:30:57 -0400 Subject: [PATCH 1/5] Initial add of blame methods --- generate/descriptor.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/generate/descriptor.json b/generate/descriptor.json index 0131afbd1..9731f0fe4 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -30,6 +30,33 @@ }, "blame": { + "cType": null, + + "functions": { + "git_blame_init_options": { + "ignore": true + }, + + "git_blame_get_hunk_count": { + "ignore": true + }, + + "git_blame_get_hunk_byindex": { + "ignore": true + }, + + "git_blame_get_hunk_byline": { + "ignore": true + }, + + "git_blame_file": { + "ignore": false + }, + + "git_blame_buffer": { + "ignore": false + } + } }, "blob": { From 4ef34a3904ad4e45ede57641d469dab4542e2d0e Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 15 Oct 2014 12:36:55 -0400 Subject: [PATCH 2/5] Blame methods --- generate/descriptor.json | 5 +++-- generate/filters/cpp_to_v8.js | 4 ++++ generate/partials/convert_from_v8.cc | 8 ++++---- generate/partials/doc.cc | 20 ++++++++++---------- generate/templates/binding.gyp | 2 +- generate/templates/class_content.cc | 2 +- generate/templates/struct_content.cc | 2 +- generate/types.json | 12 ++++++++++++ 8 files changed, 36 insertions(+), 19 deletions(-) diff --git a/generate/descriptor.json b/generate/descriptor.json index 9731f0fe4..54110b698 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -30,7 +30,8 @@ }, "blame": { - "cType": null, + "cType": "git_blame", + "forwardDeclare": true, "functions": { "git_blame_init_options": { @@ -46,7 +47,7 @@ }, "git_blame_get_hunk_byline": { - "ignore": true + "ignore": false }, "git_blame_file": { diff --git a/generate/filters/cpp_to_v8.js b/generate/filters/cpp_to_v8.js index dcf017a4f..0f306fea6 100644 --- a/generate/filters/cpp_to_v8.js +++ b/generate/filters/cpp_to_v8.js @@ -1,5 +1,9 @@ var isV8Value = require("./is_v8_value"); module.exports = function(cppClassName) { + if (cppClassName === "Integer") { + cppClassName = "Number"; + } + return isV8Value(cppClassName) ? cppClassName : "Object"; }; diff --git a/generate/partials/convert_from_v8.cc b/generate/partials/convert_from_v8.cc index 0d0fabdd8..238b29495 100644 --- a/generate/partials/convert_from_v8.cc +++ b/generate/partials/convert_from_v8.cc @@ -4,11 +4,11 @@ if (args[{{ jsArg }}]->Is{{ cppClassName|cppToV8 }}()) { {%endif%} - {%if cppClassName == 'String' %} + {%if cppClassName == 'String'%} String::Utf8Value {{ name }}(args[{{ jsArg }}]->ToString()); from_{{ name }} = ({{ cType }}) strdup(*{{ name }}); - {%elsif cppClassName == 'Array' %} + {%elsif cppClassName == 'Array'%} Array *tmp_{{ name }} = Array::Cast(*args[{{ jsArg }}]); from_{{ name }} = ({{ cType }})malloc(tmp_{{ name }}->Length() * sizeof({{ cType|replace '**' '*' }})); @@ -18,8 +18,8 @@ --%} from_{{ name }}[i] = ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(tmp_{{ name }}->Get(NanNew(static_cast(i)))->ToObject())->GetValue(); } - {%elsif cppClassName == 'Function' %} - {%elsif cppClassName == 'Buffer' %} + {%elsif cppClassName == 'Function'%} + {%elsif cppClassName == 'Buffer'%} from_{{ name }} = Buffer::Data(args[{{ jsArg }}]->ToObject()); {%elsif cppClassName|isV8Value %} diff --git a/generate/partials/doc.cc b/generate/partials/doc.cc index dd01b6487..158a48113 100644 --- a/generate/partials/doc.cc +++ b/generate/partials/doc.cc @@ -1,15 +1,15 @@ /** - {%each args as arg %} - {%if not arg.isReturn %} - {%if not arg.isSelf %} +{%each args as arg %} + {%if not arg.isReturn %} + {%if not arg.isSelf %} * @param {{ arg.jsClassName }} {{ arg.name }} - {%endif%} - {%endif%} - {%endeach%}{%each .|returnsInfo as returnInfo %} - {%if isAsync %} + {%endif%} + {%endif%} +{%endeach%}{%each .|returnsInfo as returnInfo %} + {%if isAsync %} * @param {{ returnInfo.jsOrCppClassName }} callback - {%else%} + {%else%} * @return {{ returnInfo.jsOrCppClassName }} {%if returnInfo.name %}{{ returnInfo.name }}{%else%}result{%endif%} - {%endif%} - {%endeach%} + {%endif%} +{%endeach%} */ diff --git a/generate/templates/binding.gyp b/generate/templates/binding.gyp index 3959a26ed..dc2de328b 100644 --- a/generate/templates/binding.gyp +++ b/generate/templates/binding.gyp @@ -50,6 +50,6 @@ } ] ] - }, + } ] } diff --git a/generate/templates/class_content.cc b/generate/templates/class_content.cc index 36a3935b1..55d039c5b 100644 --- a/generate/templates/class_content.cc +++ b/generate/templates/class_content.cc @@ -1,4 +1,4 @@ -// This is a generated file, modify: generate/templates/class.cc. +// This is a generated file, modify: generate/templates/class_content.cc. #include #include diff --git a/generate/templates/struct_content.cc b/generate/templates/struct_content.cc index 1ce10417e..2856b7c55 100644 --- a/generate/templates/struct_content.cc +++ b/generate/templates/struct_content.cc @@ -1,4 +1,4 @@ -// This is a generated file, modify: generate/templates/class.cc. +// This is a generated file, modify: generate/templates/struct_content.cc. #include #include #include diff --git a/generate/types.json b/generate/types.json index 64e5bc003..ea5f7ae60 100644 --- a/generate/types.json +++ b/generate/types.json @@ -9239,5 +9239,17 @@ "const git_cred_acquire_cb *": { "cpp": "GitCredAcquireCb", "js": "CredAcquireCb" + }, + "git_blame_init_options": { + "cpp": "InitOptions", + "js": "initOptions" + }, + "git_blame_init_options *": { + "cpp": "InitOptions", + "js": "initOptions" + }, + "const git_blame_init_options *": { + "cpp": "InitOptions", + "js": "initOptions" } } \ No newline at end of file From e46a2c2fe1bff064daf2a9f8ff60d345db969595 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 15 Oct 2014 14:37:20 -0400 Subject: [PATCH 3/5] Fix byline shouldAlloc and some formatting adjustments --- generate/descriptor.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generate/descriptor.json b/generate/descriptor.json index 54110b698..c7c873bcb 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -47,7 +47,8 @@ }, "git_blame_get_hunk_byline": { - "ignore": false + "ignore": false, + "args": [{ "shouldAlloc": true }] }, "git_blame_file": { From 8abebf68682d56fec65cf43231f05c2361ee1a1f Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 15 Oct 2014 14:39:35 -0400 Subject: [PATCH 4/5] Enable remaining blame methods --- generate/descriptor.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/generate/descriptor.json b/generate/descriptor.json index c7c873bcb..f49eb98db 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -35,15 +35,17 @@ "functions": { "git_blame_init_options": { - "ignore": true + "ignore": false }, "git_blame_get_hunk_count": { - "ignore": true + "ignore": false, + "args": [{ "shouldAlloc": true }] }, "git_blame_get_hunk_byindex": { - "ignore": true + "ignore": false, + "args": [{ "shouldAlloc": true }] }, "git_blame_get_hunk_byline": { From f8a08791cda47e48ea5dec2e717b141e0c6c51cf Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 15 Oct 2014 21:16:38 -0400 Subject: [PATCH 5/5] Introduced an altType to shadow different cTypes Branch is just a Reference, but we infer based off of the cType, so I've added a way to provide an override. Might not be the most elegant, so I'm willing to change this behavior. --- generate/descriptor.json | 59 ++++++++++++++++- generate/setup.js | 2 +- generate/types.json | 136 +++++++++++++++++++-------------------- 3 files changed, 127 insertions(+), 70 deletions(-) diff --git a/generate/descriptor.json b/generate/descriptor.json index f49eb98db..d260176d6 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -116,7 +116,64 @@ }, "branch": { - "cType": null + "cType": "git_reference", + "altType": "git_branch", + + "dependencies": [ + "../include/wrapper.h", + "../include/commit.h", + "../include/refs.h", + "node_buffer.h" + ], + + "functions": { + "git_branch_create": { + "ignore": false, + "isConstructorMethod": true + }, + + "git_branch_delete": { + "ignore": false + }, + + "git_branch_is_head": { + "ignore": false + }, + + "git_branch_iterator_free": { + "ignore": true + }, + + "git_branch_iterator_new": { + "ignore": true + }, + + "git_branch_lookup": { + "ignore": false, + "isConstructorMethod": true, + "args": [{}, {}, {}, { "isSelf": false }] + }, + + "git_branch_move": { + "ignore": false + }, + + "git_branch_name": { + "ignore": false + }, + + "git_branch_next": { + "ignore": true + }, + + "git_branch_set_upstream": { + "ignore": false + }, + + "git_branch_upstream": { + "ignore": false + } + } }, "buffer": { diff --git a/generate/setup.js b/generate/setup.js index 72000e516..1db9a4c80 100644 --- a/generate/setup.js +++ b/generate/setup.js @@ -251,7 +251,7 @@ fileNames.forEach(function(fileName, index) { var funcDescriptor = libgit2.functions[functionName]; var descriptor = {}; - var cType = file.cType || "git_" + file.filename.slice(0, -2); + var cType = file.altType || file.cType || "git_" + file.filename.slice(0, -2); // From the hand maintained file. var functionDescriptor = functions ? functions[functionName] || ident : ident; diff --git a/generate/types.json b/generate/types.json index ea5f7ae60..508fd82c8 100644 --- a/generate/types.json +++ b/generate/types.json @@ -100,8 +100,8 @@ "js": "isBinary" }, "git_branch_create": { - "cpp": "BranchCreate", - "js": "branchCreate" + "cpp": "Create", + "js": "create" }, "git_reference **": { "js": "Reference", @@ -112,8 +112,8 @@ "js": "Commit" }, "git_branch_delete": { - "cpp": "BranchDelete", - "js": "branchDelete" + "cpp": "Delete", + "js": "delete" }, "git_reference *": { "js": "Reference", @@ -132,28 +132,28 @@ "cpp": "BranchForeachCb" }, "git_branch_move": { - "cpp": "BranchMove", - "js": "branchMove" + "cpp": "Move", + "js": "move" }, "git_branch_lookup": { - "cpp": "BranchLookup", - "js": "branchLookup" + "cpp": "Lookup", + "js": "lookup" }, "git_branch_t": { - "js": "BranchT", - "cpp": "BranchT" + "js": "Number", + "cpp": "Int32" }, "git_branch_name": { - "cpp": "BranchName", - "js": "branchName" + "cpp": "Name", + "js": "name" }, "git_branch_upstream": { - "cpp": "BranchUpstream", - "js": "branchUpstream" + "cpp": "Upstream", + "js": "upstream" }, "git_branch_set_upstream": { - "cpp": "BranchSetUpstream", - "js": "branchSetUpstream" + "cpp": "SetUpstream", + "js": "setUpstream" }, "git_branch_upstream_name": { "cpp": "BranchUpstreamName", @@ -164,8 +164,8 @@ "cpp": "String" }, "git_branch_is_head": { - "cpp": "BranchIsHead", - "js": "branchIsHead" + "cpp": "IsHead", + "js": "isHead" }, "git_branch_remote_name": { "cpp": "BranchRemoteName", @@ -2889,96 +2889,96 @@ "js": "Branch" }, "git_branch_create *": { - "cpp": "BranchCreate", - "js": "branchCreate" + "cpp": "Create", + "js": "create" }, "const git_branch_create *": { - "cpp": "BranchCreate", - "js": "branchCreate" + "cpp": "Create", + "js": "create" }, "git_branch_delete *": { - "cpp": "BranchDelete", - "js": "branchDelete" + "cpp": "Delete", + "js": "delete" }, "const git_branch_delete *": { - "cpp": "BranchDelete", - "js": "branchDelete" + "cpp": "Delete", + "js": "delete" }, "git_branch_iterator_new": { - "cpp": "BranchIteratorNew", - "js": "branchIteratorNew" + "cpp": "IteratorNew", + "js": "iteratorNew" }, "git_branch_iterator_new *": { - "cpp": "BranchIteratorNew", - "js": "branchIteratorNew" + "cpp": "IteratorNew", + "js": "iteratorNew" }, "const git_branch_iterator_new *": { - "cpp": "BranchIteratorNew", - "js": "branchIteratorNew" + "cpp": "IteratorNew", + "js": "iteratorNew" }, "git_branch_next": { - "cpp": "BranchNext", - "js": "branchNext" + "cpp": "Next", + "js": "next" }, "git_branch_next *": { - "cpp": "BranchNext", - "js": "branchNext" + "cpp": "Next", + "js": "next" }, "const git_branch_next *": { - "cpp": "BranchNext", - "js": "branchNext" + "cpp": "Next", + "js": "next" }, "git_branch_iterator_free": { - "cpp": "BranchIteratorFree", - "js": "branchIteratorFree" + "cpp": "IteratorFree", + "js": "iteratorFree" }, "git_branch_iterator_free *": { - "cpp": "BranchIteratorFree", - "js": "branchIteratorFree" + "cpp": "IteratorFree", + "js": "iteratorFree" }, "const git_branch_iterator_free *": { - "cpp": "BranchIteratorFree", - "js": "branchIteratorFree" + "cpp": "IteratorFree", + "js": "iteratorFree" }, "git_branch_move *": { - "cpp": "BranchMove", - "js": "branchMove" + "cpp": "Move", + "js": "move" }, "const git_branch_move *": { - "cpp": "BranchMove", - "js": "branchMove" + "cpp": "Move", + "js": "move" }, "git_branch_lookup *": { - "cpp": "BranchLookup", - "js": "branchLookup" + "cpp": "Lookup", + "js": "lookup" }, "const git_branch_lookup *": { - "cpp": "BranchLookup", - "js": "branchLookup" + "cpp": "Lookup", + "js": "lookup" }, "git_branch_name *": { - "cpp": "BranchName", - "js": "branchName" + "cpp": "Name", + "js": "name" }, "const git_branch_name *": { - "cpp": "BranchName", - "js": "branchName" + "cpp": "Name", + "js": "name" }, "git_branch_upstream *": { - "cpp": "BranchUpstream", - "js": "branchUpstream" + "cpp": "Upstream", + "js": "upstream" }, "const git_branch_upstream *": { - "cpp": "BranchUpstream", - "js": "branchUpstream" + "cpp": "Upstream", + "js": "upstream" }, "git_branch_set_upstream *": { - "cpp": "BranchSetUpstream", - "js": "branchSetUpstream" + "cpp": "SetUpstream", + "js": "setUpstream" }, "const git_branch_set_upstream *": { - "cpp": "BranchSetUpstream", - "js": "branchSetUpstream" + "cpp": "SetUpstream", + "js": "setUpstream" }, "git_branch_upstream_name *": { "cpp": "BranchUpstreamName", @@ -2989,12 +2989,12 @@ "js": "branchUpstreamName" }, "git_branch_is_head *": { - "cpp": "BranchIsHead", - "js": "branchIsHead" + "cpp": "IsHead", + "js": "isHead" }, "const git_branch_is_head *": { - "cpp": "BranchIsHead", - "js": "branchIsHead" + "cpp": "IsHead", + "js": "isHead" }, "git_branch_remote_name *": { "cpp": "BranchRemoteName",