From 458e08079a8089ba9a75f5046fc4d2b173164f3e Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Tue, 18 Jun 2013 22:46:43 +0200 Subject: [PATCH 01/28] Using code-generation to implement libgit2 c++ bindings. The oid class is fully code-gen'd and all tests pass. --- gen.js | 15 + include/oid.h | 42 +- lib/commit.js | 108 +- lib/oid.js | 40 +- lib/tree_entry.js | 7 +- munge.js | 35 + package.json | 6 +- src/base.cc | 2 - src/commit.cc | 9 +- src/oid.cc | 103 +- src/reference.cc | 11 +- src/revwalk.cc | 11 +- src/tree_entry.cc | 10 +- templates/class.cc.ejs | 190 + templates/header.h.ejs | 55 + test/convenience-commit.js | 29 +- test/convenience-difflist.js | 58 +- test/convenience-oid.js | 20 +- test/npm-debug.log | 19 + test/raw-blob.js | 10 +- test/raw-commit.js | 49 +- test/raw-oid.js | 35 +- v0.18.0.json | 14468 +++++++++++++++++++++++++++++++++ 23 files changed, 14995 insertions(+), 337 deletions(-) create mode 100644 gen.js create mode 100644 munge.js create mode 100644 templates/class.cc.ejs create mode 100644 templates/header.h.ejs create mode 100644 test/npm-debug.log create mode 100644 v0.18.0.json diff --git a/gen.js b/gen.js new file mode 100644 index 000000000..a075782ea --- /dev/null +++ b/gen.js @@ -0,0 +1,15 @@ +var fs = require('fs'), + ejs = require('ejs'), + path = require('path'); + +var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), + classTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/class.cc.ejs")).toString()), + headerTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/header.h.ejs")).toString()); + +for (var i in idefs) { + var idef = idefs[i]; + if (idef.jsClassName != "Oid") continue; + + fs.writeFileSync(path.resolve("./include/" + idef.filename), headerTemplate(idef)); + fs.writeFileSync(path.resolve("./src/" + path.basename(idef.filename, '.h') + '.cc'), classTemplate(idef)); +} diff --git a/include/oid.h b/include/oid.h index 4f61e8665..cbd24e077 100755 --- a/include/oid.h +++ b/include/oid.h @@ -1,12 +1,9 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef OID_H -#define OID_H +#ifndef GITOID_H +#define GITOID_H #include #include @@ -21,36 +18,19 @@ class GitOid : public ObjectWrap { public: static Persistent constructor_template; - static void Initialize (Handle target); + git_oid GetValue(); - void SetValue(git_oid oid); - protected: - GitOid() {} - ~GitOid() {} + private: + GitOid(git_oid *raw); + ~GitOid(); static Handle New(const Arguments& args); - static Handle Sha(const Arguments& args); - static Handle FromString(const Arguments& args); - static void FromStringWork(uv_work_t* req); - static void FromStringAfterWork(uv_work_t* req); - - private: - git_oid oid; - - struct FromStringBaton { - uv_work_t request; - const git_error* error; - - std::string fromString; - GitOid* oid; - git_oid rawOid; - - Persistent callback; - }; + static Handle Sha(const Arguments& args); + git_oid *raw; }; #endif diff --git a/lib/commit.js b/lib/commit.js index 75f2fc18e..3a03ac043 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -54,37 +54,20 @@ Commit.prototype.lookup = function(oid, callback) { * * @param {Commit~oidCallback} callback */ -Commit.prototype.oid = function(callback) { +Commit.prototype.oid = function() { /** * @callback Commit~oidCallback Callback executed on OID retrieval. * @param {GitError|null} error An Error or null if successful. * @param {Oid|null} commit Retrieved OID object or null. */ - callback(null, new git.oid(this.rawCommit.oid())); + return new git.oid(this.rawCommit.oid()); }; /** * Retrieve the SHA. - * - * @param {Commit~shaCallback} callback */ -Commit.prototype.sha = function(callback) { - /** - * @callback Commit~shaCallback Callback executed on SHA retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} sha Retrieved SHA. - */ - this.oid(function(error, oid) { - if (!success(error, callback)) { - return; - } - oid.sha(function(error, sha) { - if (!success(error, callback)) { - return; - } - callback(null, sha); - }); - }); +Commit.prototype.sha = function() { + return this.oid().sha(); }; /** @@ -254,41 +237,39 @@ Commit.prototype.history = function() { var event = new events.EventEmitter(), self = this; - self.oid(function commitOid(error, oid) { - (new git.revwalk(self.rawRepo)).allocate(function createRevwalk(error, revwalk) { - var commits = []; - revwalk.walk(oid, function commitRevWalk(error, index, commit, noMoreCommits) { - if(error) { - event.emit('end', error, commits); - return false; - } + var oid = self.oid(); + (new git.revwalk(self.rawRepo)).allocate(function createRevwalk(error, revwalk) { + var commits = []; + revwalk.walk(oid, function commitRevWalk(error, index, commit, noMoreCommits) { + if(error) { + event.emit('end', error, commits); + return false; + } - if (noMoreCommits) { - /** - * End event. - * - * @event Commit#end - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Commit[]} commits The commits. - */ - event.emit('end', null, commits); - return; - } + if (noMoreCommits) { /** - * Commit event. + * End event. * - * @event Commit#commit + * @event Commit#end * * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Commit} commit The commit. + * @param {Commit[]} commits The commits. */ - event.emit('commit', null, commit); - commits.push(commit); - }); + event.emit('end', null, commits); + return; + } + /** + * Commit event. + * + * @event Commit#commit + * + * @param {GitError|null} error An error object if there was an issue, null otherwise. + * @param {Commit} commit The commit. + */ + event.emit('commit', null, commit); + commits.push(commit); }); }); - return event; }; @@ -328,27 +309,22 @@ Commit.prototype.parentsDiffTrees = function(callback) { * @param {DiffList[]|null} diffLists Array of DiffTrees showing changes between this commit and its parent(s) */ var self = this; - self.sha(function(error, commitSha) { + var commitSha = self.sha(); + self.parents(function commitParents(error, parents) { if (!success(error, callback)) { return; } - self.parents(function commitParents(error, parents) { - if (!success(error, callback)) { - return; - } - var parentDiffLists = []; - parents.forEach(function commitEachParent(parent) { - parent.sha(function commitParentSha(error, parentSha) { - (new git.diffList(self.rawRepo)).treeToTree(parentSha, commitSha, function walkDiffList(error, diffList) { - if (!success(error, callback)) { - return; - } - parentDiffLists.push(diffList); - if (parentDiffLists.length === parents.length) { - callback(null, parentDiffLists); - } - }); - }); + var parentDiffLists = []; + parents.forEach(function commitEachParent(parent) { + var parentSha = parent.sha(); + (new git.diffList(self.rawRepo)).treeToTree(parentSha, commitSha, function walkDiffList(error, diffList) { + if (!success(error, callback)) { + return; + } + parentDiffLists.push(diffList); + if (parentDiffLists.length === parents.length) { + callback(null, parentDiffLists); + } }); }); }); diff --git a/lib/oid.js b/lib/oid.js index c32b58a3c..6b7e35923 100644 --- a/lib/oid.js +++ b/lib/oid.js @@ -16,45 +16,27 @@ var Oid = function(rawOid) { }; /** - * @return {git.raw.Oid} The wrapped raw Oid object. + * Create Oid object from string. + * + * @param {String} sha */ -Oid.prototype.getRawOid = function() { - return this.rawOid; +Oid.fromString = function(sha) { + var rawOid = git.raw.Oid.fromString(sha); + return new Oid(rawOid); }; /** - * Create Oid object from string. - * - * @param {String} sha - * @param {Oid~fromStringCallback} callback + * @return {git.raw.Oid} The wrapped raw Oid object. */ -Oid.prototype.fromString = function(sha, callback) { - /** - * @callback Oid~fromStringCallback Callback executed after raw Oid is created. - * @param {GitError|null} error An Error or null if successful. - * @param {Oid|null} oid The new Oid object. - */ - var self = this; - self.rawOid.fromString(sha, function(error, rawOid) { - if (success(error, callback)) { - self.rawOid = rawOid; - callback(null, self); - } - }); +Oid.prototype.getRawOid = function() { + return this.rawOid; }; /** * Convert the raw Oid to a SHA - * - * @param {Oid~shaCallback} callback */ -Oid.prototype.sha = function(callback) { - /** - * @callback Oid~shaCallback Callback executed after SHA is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} sha The SHA. - */ - callback(null, this.rawOid.sha()); +Oid.prototype.sha = function() { + return this.rawOid.sha(); }; exports.oid = Oid; diff --git a/lib/tree_entry.js b/lib/tree_entry.js index a78de137b..5464b19c7 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -80,11 +80,8 @@ TreeEntry.prototype.sha = function(callback) { if (!success(error, callback)) { return; } - (new git.oid(oid)).sha(function(error, sha) { - if (success(error, callback)) { - callback(null, sha); - } - }); + var sha = new git.oid(oid).sha(); + callback(null, sha); }); }; diff --git a/munge.js b/munge.js new file mode 100644 index 000000000..8c29468c1 --- /dev/null +++ b/munge.js @@ -0,0 +1,35 @@ +var fs = require('fs'), + _ = require('underscore'), + path = require('path'); + +var DOUBLE_POINTER_RE = /\*\*$/; +var OUT_VAR_RE = /_out$/; +function isConstructorMethod(cType, functionInfo) { + if (!functionInfo.args.length) return false; + var firstArg = functionInfo.args[0]; + return RegExp(cType + " \\*\\*$").test(firstArg.cType) && !isPrototypeMethod(cType, functionInfo) && !/_free$/.test(functionInfo.cFunctionName); +} + +function isPrototypeMethod(cType, functionInfo) { + if (!functionInfo.args.length) return false; + + var firstArg = functionInfo.args[0]; + return RegExp(cType + " \\*$").test(firstArg.cType) && !/_free$/.test(functionInfo.cFunctionName); +} + +var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')); + +for (var i in idefs) { + var idef = idefs[i]; + + for (var j in idef.functions) { + var fn = idef.functions[j]; + var old1 = fn.isPrototypeMethod; + var old2 = fn.isConstructorMethod; + fn.isPrototypeMethod = isPrototypeMethod(idef.cType, fn); + fn.isConstructorMethod = isConstructorMethod(idef.cType, fn); + fn.isFree = /_free$/.test(fn.cFunctionName); + + } +} +console.log(JSON.stringify(idefs, null, 2)); diff --git a/package.json b/package.json index 314dd6df0..e84d6130a 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,12 @@ }, "devDependencies": { "nodeunit": "", - "rimraf": "1.0.x" + "rimraf": "1.0.x", + "ejs": "0.8.x" }, "scripts": { "install": "node install.js", - "test": "cd test && nodeunit *.js" + "test": "cd test && nodeunit *.js", + "gen": "node gen.js" } } diff --git a/src/base.cc b/src/base.cc index 725303bec..f1f01c726 100755 --- a/src/base.cc +++ b/src/base.cc @@ -24,8 +24,6 @@ #include "../include/threads.h" extern "C" void init(Handle target) { - HandleScope scope; - GitError::Initialize(target); GitReference::Initialize(target); diff --git a/src/commit.cc b/src/commit.cc index d4eecd555..7dc55d57a 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -155,11 +155,10 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; - Local oid = GitOid::constructor_template->NewInstance(); - GitOid *oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(*const_cast(ObjectWrap::Unwrap(args.This())->oid)); - - return scope.Close(oid); + git_oid *rawOid = (git_oid *)malloc(sizeof(git_oid)); + git_oid_cpy(rawOid, ObjectWrap::Unwrap(args.This())->oid); + Handle argv[1] = { External::New(rawOid) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } Handle GitCommit::Message(const Arguments& args) { diff --git a/src/oid.cc b/src/oid.cc index fc68b7dea..e382b6139 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -1,10 +1,6 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include #include @@ -19,7 +15,15 @@ using namespace v8; using namespace node; -void GitOid::Initialize(Handle target) { +GitOid::GitOid(git_oid *raw) { + this->raw = raw; +} + +GitOid::~GitOid() { + free(this->raw); +} + +void GitOid::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -27,93 +31,64 @@ void GitOid::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Oid")); + NODE_SET_METHOD(tpl, "fromString", FromString); NODE_SET_PROTOTYPE_METHOD(tpl, "sha", Sha); - NODE_SET_PROTOTYPE_METHOD(tpl, "fromString", FromString); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Oid"), constructor_template); } -git_oid GitOid::GetValue() { - return this->oid; -} -void GitOid::SetValue(git_oid oid) { - this->oid = oid; -} - Handle GitOid::New(const Arguments& args) { HandleScope scope; - GitOid* oid = new GitOid(); - oid->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_oid is required."))); + } + + GitOid* object = new GitOid((git_oid *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitOid::Sha(const Arguments& args) { - HandleScope scope; - - GitOid* oid = ObjectWrap::Unwrap(args.This()); - - char sha[GIT_OID_HEXSZ + 1]; - sha[GIT_OID_HEXSZ] = '\0'; - git_oid rawOid = oid->GetValue(); - git_oid_fmt(sha, const_cast(&rawOid)); - - return scope.Close(String::New(sha)); +git_oid GitOid::GetValue() { + return *this->raw; } + Handle GitOid::FromString(const Arguments& args) { HandleScope scope; if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required and must be a String."))); + return ThrowException(Exception::Error(String::New("String is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - FromStringBaton* baton = new FromStringBaton; - baton->request.data = baton; - baton->error = NULL; - baton->oid = ObjectWrap::Unwrap(args.This()); - baton->rawOid = baton->oid->GetValue(); - baton->fromString = stringArgToString(args[0]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[1])); + git_oid * out = (git_oid *)malloc(sizeof(git_oid)); - uv_queue_work(uv_default_loop(), &baton->request, FromStringWork, (uv_after_work_cb)FromStringAfterWork); + int result = git_oid_fromstr( + out, + stringArgToString(args[0]->ToString()).c_str() - return Undefined(); -} -void GitOid::FromStringWork(uv_work_t* req) { - FromStringBaton *baton = static_cast(req->data); + ); - int returnCode = git_oid_fromstr(&baton->rawOid, baton->fromString.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } + Handle argv[1] = { External::New(out) }; + return scope.Close(constructor_template->NewInstance(1, argv)); } -void GitOid::FromStringAfterWork(uv_work_t* req) { + +Handle GitOid::Sha(const Arguments& args) { HandleScope scope; - FromStringBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - baton->oid->SetValue(baton->rawOid); + git_oid in = ObjectWrap::Unwrap(args.This())->GetValue(); - Handle argv[2] = { - Local::New(Null()), - baton->oid->handle_ - }; + char * result = git_oid_allocfmt( + &in + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - delete req; + return scope.Close(String::New(result)); } Persistent GitOid::constructor_template; diff --git a/src/reference.cc b/src/reference.cc index a80628ca9..f520a24f6 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -98,17 +98,18 @@ void GitReference::OidAfterWork(uv_work_t* req) { OidBaton *baton = static_cast(req->data); if (success(baton->error, baton->callback)) { - Handle oid = GitOid::constructor_template->NewInstance(); - GitOid *oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(*const_cast(baton->rawOid)); + git_oid *rawOid = (git_oid *)malloc(sizeof(git_oid)); + git_oid_cpy(rawOid, baton->rawOid); + Handle argv[1] = { External::New((void *)rawOid) }; + Handle oid = GitOid::constructor_template->NewInstance(1, argv); - Handle argv[2] = { + Handle argv2[2] = { Local::New(Null()), oid }; TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); if (try_catch.HasCaught()) { node::FatalException(try_catch); } diff --git a/src/revwalk.cc b/src/revwalk.cc index c8817bfde..0252d31b9 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -235,18 +235,19 @@ void GitRevWalk::NextAfterWork(uv_work_t *req) { NextBaton *baton = static_cast(req->data); if (success(baton->error, baton->callback)) { - Local oid = GitOid::constructor_template->NewInstance(); - GitOid *oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(baton->rawOid); + git_oid *rawOid = (git_oid *)malloc(sizeof(git_oid)); + git_oid_cpy(rawOid, &baton->rawOid); + Handle argv[1] = { External::New(rawOid) }; + Local oid = GitOid::constructor_template->NewInstance(1, argv); - Local argv[3] = { + Local argv2[3] = { Local::New(Null()), oid, Local::New(Boolean::New(baton->walkOver)) }; TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 3, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 3, argv2); if(try_catch.HasCaught()) { FatalException(try_catch); } diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 78578cb4c..4ba4fb84d 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -205,18 +205,16 @@ void GitTreeEntry::OidWork(uv_work_t* req) { void GitTreeEntry::OidAfterWork(uv_work_t* req) { HandleScope scope; OidBaton *baton = static_cast(req->data); + Handle argv[1] = { External::New((void *) baton->rawOid) }; + Handle oid = GitOid::constructor_template->NewInstance(1, argv); - Handle oid = GitOid::constructor_template->NewInstance(); - GitOid* oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(*const_cast(baton->rawOid)); - - Handle argv[2] = { + Handle argv2[2] = { Local::New(Null()), oid }; TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); if (try_catch.HasCaught()) { node::FatalException(try_catch); } diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs new file mode 100644 index 000000000..0ba7eb19d --- /dev/null +++ b/templates/class.cc.ejs @@ -0,0 +1,190 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/<%= filename %>" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +<%- cppClassName %>::<%- cppClassName %>(<%- cType %> *raw) { + this->raw = raw; +} + +<%- cppClassName %>::~<%- cppClassName %>() { + <%- freeFunctionName %>(this->raw); +} + +void <%- cppClassName %>::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("<%- jsClassName %>")); + +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> +<% if (functionInfo.isConstructorMethod) { -%> + NODE_SET_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); +<% } else if (functionInfo.isPrototypeMethod) { -%> + NODE_SET_PROTOTYPE_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); +<% } -%> +<% } -%> + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("<%- jsClassName %>"), constructor_template); +} + +Handle <%- cppClassName %>::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("<%= cType %> is required."))); + } + + <%- cppClassName %>* object = new <%- cppClassName %>((<%= cType%> *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +<%- cType %> <%- cppClassName %>::GetValue() { + return *this->raw; +} + +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> + +<% if (functionInfo.isAsync) { -%> +Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + +<% + var offset = functionInfo.isPrototypeMethod || functionInfo.isConstructorMethod ? 1 : 0; + for (var i = 0; i < functionInfo.args.length - offset; i++) { + var arg = functionInfo.args[i + offset]; +-%> + if (args.Length() == <%- i %> || !args[<%- i %>]->IsObject()) { + return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); + } +<% } -%> + if (args.Length() == <%- i %> || !args[<%- i %>]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + +<%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; + baton->request.data = baton; + <%- cppClassName %> object = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This()); + object->Ref(); + baton-><%- functionInfo.args[0].name %> = object::GetValue(); +<% + for (var i = 1; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[i]->ToObject())->Value(); +<% } -%> + baton->callback = Persistent::New(Local::Cast(args[i])); + + uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); + + return Undefined(); +} +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t* req) { +<%- functionInfo.cppFunctionName %>Baton* baton = static_cast<<%- functionInfo.cppFunctionName %>Baton* >(req->data); +<%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>(<% for (var i in functionInfo.args) { var arg = functionInfo.args[i]; %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>,<% } %><% } %>); +<% if (functionInfo.return.isErrorCode) { -%> + if (result != GIT_OK) { + baton->error = giterr_last(); + } +<% } else { -%> + baton->result = result; +<% } -%> +} +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t* req) { + HandleScope scope; +<%- functionInfo.cppFunctionName %>Baton* baton = static_cast<<%- functionInfo.cppFunctionName %>Baton*>(req->data); + + if (success(baton->error, baton->callback)) { + Handle argv[2] = { + Local::New(Null()), + baton->result + }; + + TryCatch try_catch; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + } + +<%- cppClassName %> object = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This()); + object->Unref(); + baton->callback.Dispose(); + delete baton; + delete req; +} +<% } else { -%> +Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + +<% + var offset = functionInfo.isPrototypeMethod || functionInfo.isConstructorMethod ? 1 : 0; + for (var i = 0; i < functionInfo.args.length - offset; i++) { + var arg = functionInfo.args[i + offset]; +-%> + if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- arg.jsClassName %>()) { + return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); + } +<% } -%> + +<% if (functionInfo.isConstructorMethod) { -%> + <%- functionInfo.args[0].cType %> out = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); +<% } else if (functionInfo.isPrototypeMethod) { -%> + <%- cType %> in = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); +<% } -%> + + <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( + <% if (functionInfo.isConstructorMethod) { %>out<% } else if (functionInfo.isPrototypeMethod) { -%>&in<% } -%><% if (functionInfo.args.length - offset > 0) { %>,<% } %> +<% for (var i = offset; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> +<% if (arg.cppClassName == 'String') { %> + stringArgToString(args[<%- i - offset%>]->ToString()).c_str() +<% } else { -%> + ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->Value() +<% } -%> +<% if (i < functionInfo.args.length - 1) { %>, <% } -%> +<% } %> + ); + +<% if (functionInfo.return.isErrorCode) { -%> + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } +<% } -%> +<% if (functionInfo.isConstructorMethod) { -%> + Handle argv[1] = { External::New(out) }; + return scope.Close(constructor_template->NewInstance(1, argv)); +<% } else if (functionInfo.return.cType == "void") { -%> + return Undefined(); +<% } else { -%> + return scope.Close(<%- functionInfo.return.cppClassName %>::New(result)); +<% } -%> +<% } -%> +} +<% } -%> + +Persistent <%- cppClassName %>::constructor_template; diff --git a/templates/header.h.ejs b/templates/header.h.ejs new file mode 100644 index 000000000..caa2819bc --- /dev/null +++ b/templates/header.h.ejs @@ -0,0 +1,55 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef <%- cppClassName.toUpperCase() %>_H +#define <%- cppClassName.toUpperCase() %>_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class <%- cppClassName %> : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + <%- cType %> GetValue(); + + private: + <%- cppClassName %>(<%- cType %> *raw); + ~<%- cppClassName %>(); + + static Handle New(const Arguments& args); + +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> + static Handle <%- functionInfo.cppFunctionName %>(const Arguments& args); +<% if (functionInfo.isAsync) { -%> + static void <%- cppFunctionName %>Work(uv_work_t* req); + static void <%- cppFunctionName %>AfterWork(uv_work_t* req); + + struct <%- cppFunctionName %>Baton { + uv_work_t request; + const git_error* error; + +<% for (var i = 0 in functionInfo.args) { -%> + <%- functionInfo.args[i].cType %> <%- functionInfo.args[i].name %>; +<% } -%> + Persistent callback; + }; +<% } -%> +<% } -%> + <%- cType %> *raw; +}; + +#endif diff --git a/test/convenience-commit.js b/test/convenience-commit.js index 663ffe99d..0912731d7 100644 --- a/test/convenience-commit.js +++ b/test/convenience-commit.js @@ -52,12 +52,11 @@ exports.sha = function(test) { test.expect(3); git.repo('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.sha(function(error, sha) { - test.equals(error, null, 'There should be no error'); - test.notEqual(sha, null, 'SHA should not be null'); - test.equals(sha, historyCountKnownSHA, 'SHA should match expected value'); - test.done(); - }); + var sha = commit.sha(); + test.equals(error, null, 'There should be no error'); + test.notEqual(sha, null, 'SHA should not be null'); + test.equals(sha, historyCountKnownSHA, 'SHA should match expected value'); + test.done(); }); }); }; @@ -218,11 +217,10 @@ exports.masterHead = function(test) { git.repo('../.git', function(error, repository) { repository.branch('master', function(error, branch) { test.equals(error, null, 'Getting branch should not error'); - branch.sha(function(error, sha) { - repository.commit(sha, function(error, commit) { - test.equals(error, null, 'Getting latest branch commit should not error'); - test.done(); - }); + var sha = branch.sha(); + repository.commit(sha, function(error, commit) { + test.equals(error, null, 'Getting latest branch commit should not error'); + test.done(); }); }); }); @@ -239,11 +237,10 @@ exports.parents = function(test) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { test.equals(parents.length, 1, 'Commit should have exactly one parent'); - parents[0].sha(function parentSha(error, sha) { - test.equals(error, null, 'Getting parent SHA should not error'); - test.equals(sha, 'ecfd36c80a3e9081f200dfda2391acadb56dac27', 'Parent SHA should match expected value'); - test.done(); - }); + var sha = parents[0].sha(); + test.equals(error, null, 'Getting parent SHA should not error'); + test.equals(sha, 'ecfd36c80a3e9081f200dfda2391acadb56dac27', 'Parent SHA should match expected value'); + test.done(); }); }); }); diff --git a/test/convenience-difflist.js b/test/convenience-difflist.js index c010691c1..d43c31e7c 100644 --- a/test/convenience-difflist.js +++ b/test/convenience-difflist.js @@ -44,30 +44,29 @@ exports.walkingDiffs = function(test) { git.repo('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { - parents[0].sha(function(error, parentSha) { - (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { + var parentSha = parents[0].sha(); + (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { + test.equal(null, error, 'Should not error'); + diffList.walk().on('delta', function(error, delta) { test.equal(null, error, 'Should not error'); - diffList.walk().on('delta', function(error, delta) { - test.equal(null, error, 'Should not error'); - test.equal(delta.oldFile.path, 'README.md', 'Old file path should match expected'); - test.equal(delta.newFile.path, 'README.md', 'New file path should match expected'); - test.equal(delta.content.length, 5, 'Content array should be of known length'); - test.equal(delta.status, diffList.deltaTypes.GIT_DELTA_MODIFIED, 'Status should be known type'); - test.equal(delta.content[0].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'First content item should be context'); - test.equal(delta.content[1].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Second content item should be context'); - test.equal(delta.content[2].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Third content item should be context'); - - var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; - test.equal(delta.content[3].content, oldContent, 'Old content should match known value'); - test.equal(delta.content[3].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'Fourth content item should be deletion'); - test.equal(delta.content[3].contentLength, 90, 'Fourth content length should match known value'); - - var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; - test.equal(delta.content[4].content, newContent, 'New content should match known value'); - test.equal(delta.content[4].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'Fifth content item should be addition'); - test.equal(delta.content[4].contentLength, 162, 'Fifth content length should match known value'); - test.done(); - }); + test.equal(delta.oldFile.path, 'README.md', 'Old file path should match expected'); + test.equal(delta.newFile.path, 'README.md', 'New file path should match expected'); + test.equal(delta.content.length, 5, 'Content array should be of known length'); + test.equal(delta.status, diffList.deltaTypes.GIT_DELTA_MODIFIED, 'Status should be known type'); + test.equal(delta.content[0].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'First content item should be context'); + test.equal(delta.content[1].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Second content item should be context'); + test.equal(delta.content[2].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Third content item should be context'); + + var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; + test.equal(delta.content[3].content, oldContent, 'Old content should match known value'); + test.equal(delta.content[3].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'Fourth content item should be deletion'); + test.equal(delta.content[3].contentLength, 90, 'Fourth content length should match known value'); + + var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; + test.equal(delta.content[4].content, newContent, 'New content should match known value'); + test.equal(delta.content[4].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'Fifth content item should be addition'); + test.equal(delta.content[4].contentLength, 162, 'Fifth content length should match known value'); + test.done(); }); }); }); @@ -80,13 +79,12 @@ exports.walkingEnd = function(test) { git.repo('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { - parents[0].sha(function(error, parentSha) { - (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { - diffList.walk().on('end', function(error, diffs) { - test.equal(null, error, 'Should not error'); - test.equal(diffs.length, 1, 'Diffs array should be of known length'); - test.done(); - }); + var parentSha = parents[0].sha(); + (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { + diffList.walk().on('end', function(error, diffs) { + test.equal(null, error, 'Should not error'); + test.equal(diffs.length, 1, 'Diffs array should be of known length'); + test.done(); }); }); }); diff --git a/test/convenience-oid.js b/test/convenience-oid.js index 91f359370..408bce34c 100644 --- a/test/convenience-oid.js +++ b/test/convenience-oid.js @@ -29,21 +29,9 @@ exports.method = function(test){ var knownSha = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; -exports.fromString = function(test) { +exports.fromStringAndSha = function(test) { test.expect(1); - (new git.oid()).fromString(knownSha, function(error, oid) { - test.equal(error, null, 'Should not error'); - test.done(); - }); -}; - -exports.sha = function(test) { - test.expect(2); - (new git.oid()).fromString(knownSha, function(error, oid) { - oid.sha(function(error, sha) { - test.equal(error, null, 'Should not error'); - test.equal(sha, knownSha, 'SHA should match known value'); - test.done(); - }); - }); + var oid = git.oid.fromString(knownSha); + test.equal(oid.sha(), knownSha, 'SHA should match known value'); + test.done(); }; diff --git a/test/npm-debug.log b/test/npm-debug.log new file mode 100644 index 000000000..4db27521a --- /dev/null +++ b/test/npm-debug.log @@ -0,0 +1,19 @@ +0 info it worked if it ends with ok +1 verbose cli [ 'node', '/usr/local/bin/npm', 'test' ] +2 info using npm@1.2.28 +3 info using node@v0.10.10 +4 verbose read json /Users/nkallen/Workspace/nodegit/test/package.json +5 error Error: ENOENT, open '/Users/nkallen/Workspace/nodegit/test/package.json' +6 error If you need help, you may report this log at: +6 error +6 error or email it to: +6 error +7 error System Darwin 12.3.0 +8 error command "node" "/usr/local/bin/npm" "test" +9 error cwd /Users/nkallen/Workspace/nodegit/test +10 error node -v v0.10.10 +11 error npm -v 1.2.28 +12 error path /Users/nkallen/Workspace/nodegit/test/package.json +13 error code ENOENT +14 error errno 34 +15 verbose exit [ 34, true ] diff --git a/test/raw-blob.js b/test/raw-blob.js index 583c5bb14..06a552614 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -36,7 +36,7 @@ exports.constructor = function(test){ // Blob::Lookup exports.lookup = function(test) { - var testOid = new git.Oid(), + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), testRef = new git.Reference(testRepo), testBlob = new git.Blob(); @@ -68,7 +68,7 @@ exports.lookup = function(test) { // Blob::RawContent exports.rawContent = function(test) { - var testOid = new git.Oid(), + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), testBlob = new git.Blob(), testCommit = new git.Commit(); @@ -82,7 +82,7 @@ exports.rawContent = function(test) { // Blob::Free exports.free = function(test) { - var testOid = new git.Oid(), + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), testBlob = new git.Blob(); test.expect(2); @@ -95,7 +95,7 @@ exports.free = function(test) { // Blob::CreateFromFile exports.createFromFile = function(test) { - var testOid = new git.Oid(), + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), testBlob = new git.Blob(); test.expect(2); @@ -108,7 +108,7 @@ exports.createFromFile = function(test) { // Blob::CreateFromBuffer exports.createFromBuffer = function(test) { - var testOid = new git.Oid(), + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), testBlob = new git.Blob(); test.expect(2); diff --git a/test/raw-commit.js b/test/raw-commit.js index 058ed52eb..348c93ec8 100644 --- a/test/raw-commit.js +++ b/test/raw-commit.js @@ -45,42 +45,37 @@ exports.constructor = function(test){ exports.lookup = function(test) { test.expect(7); - var testOid = new git.Oid(), + var testOid = git.Oid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762'), testCommit = new git.Commit(); // Test for function helper.testFunction(test.equals, testCommit.lookup, 'Commit::Lookup'); - testOid.fromString('cb09e99e91d41705197e0fb60823fdc7df776691', function(error, testOid) { + // Test repo argument existence + helper.testException(test.ok, function() { + testCommit.lookup(); + }, 'Throw an exception if no repo'); - // Test repo argument existence - helper.testException(test.ok, function() { - testCommit.lookup(); - }, 'Throw an exception if no repo'); + // Test oid argument existence + helper.testException(test.ok, function() { + testCommit.lookup(testRepo); + }, 'Throw an exception if no oid'); - // Test oid argument existence - helper.testException(test.ok, function() { - testCommit.lookup(testRepo); - }, 'Throw an exception if no oid'); + // Test callback argument existence + helper.testException(test.ok, function() { + testCommit.lookup(testOid); + }, 'Throw an exception if no callback'); - // Test callback argument existence - helper.testException(test.ok, function() { - testCommit.lookup(testOid); - }, 'Throw an exception if no callback'); + // Test that all arguments result correctly + helper.testException(test.ifError, function() { + testCommit.lookup(testRepo, testOid, function() {}); + }, 'No exception is thrown with proper arguments'); - // Test that all arguments result correctly - helper.testException(test.ifError, function() { - testCommit.lookup(testRepo, testOid, function() {}); - }, 'No exception is thrown with proper arguments'); - - testRepo.open('../.git', function() { - // Test valid commit - testOid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762', function(error, testOid) { - testCommit.lookup(testRepo, testOid, function(err) { - test.equal(null, err, 'Valid commit'); - test.done(); - }); - }); + testRepo.open('../.git', function() { + // Test valid commit + testCommit.lookup(testRepo, testOid, function(err) { + test.equal(null, err, 'Valid commit'); + test.done(); }); }); }; diff --git a/test/raw-oid.js b/test/raw-oid.js index 126a6fd31..4b12e5c28 100644 --- a/test/raw-oid.js +++ b/test/raw-oid.js @@ -30,7 +30,7 @@ exports.constructor = function(test){ helper.testFunction(test.equals, git.Oid, 'Oid'); // Ensure we get an instance of Oid - test.ok(new git.Oid() instanceof git.Oid, 'Invocation returns an instance of Oid'); + test.throws(function() { new git.Oid(); }, 'Cannot instantiate an Oid directly'); test.done(); }; @@ -39,44 +39,33 @@ exports.constructor = function(test){ exports.fromString = function(test) { test.expect(6); - var testOid = new git.Oid(); - // Test for function - helper.testFunction(test.equals, testOid.fromString, 'Oid::FromString'); + helper.testFunction(test.equals, git.Oid.fromString, 'Oid::FromString'); // Test path argument existence helper.testException(test.ok, function() { - testOid.fromString(); + git.Oid.fromString(); }, 'Throw an exception if no hex String'); // Test that both arguments result correctly - helper.testException(test.ifError, function() { - testOid.fromString("somestr", function() {}); - }, 'No exception is thrown with proper arguments'); + test.throws(function() { git.Oid.fromString("somestr", function() {}); }); - // Test invalid hex id string - testOid.fromString('1392DLFJIOS', function(error, oid) { - test.notEqual(null, error, 'Invalid hex id String'); - testOid.fromString('1810DFF58D8A660512D4832E740F692884338CCD', function(error, oid) { - // Test valid hex id string - test.equal(null, error, 'Valid hex id String'); - test.done(); - }); - }); + // Test valid hex id string + test.throws(function() { git.Oid.fromString('1392DLFJIOS'); }); + test.doesNotThrow(function() { git.Oid.fromString('1810DFF58D8A660512D4832E740F692884338CCD'); }); + test.done(); }; // Oid::Sha exports.sha = function(test) { test.expect(3); - var testOid = new git.Oid(); + var sha = '1810DFF58D8A660512D4832E740F692884338CCD'; + var testOid = git.Oid.fromString(sha); // Test for function helper.testFunction(test.equals, testOid.sha, 'Oid::Sha'); // Test valid hex id string - var sha = '1810DFF58D8A660512D4832E740F692884338CCD'; - testOid.fromString(sha, function(error, rawOid) { - test.equals(sha, testOid.sha().toUpperCase(), 'Valid hex id String'); - test.done(); - }); + test.equals(sha, testOid.sha().toUpperCase(), 'Valid hex id String'); + test.done(); }; diff --git a/v0.18.0.json b/v0.18.0.json new file mode 100644 index 000000000..34aaef26a --- /dev/null +++ b/v0.18.0.json @@ -0,0 +1,14468 @@ +[ + { + "filename": "attr.h", + "jsClassName": "Attr", + "cppClassName": "Attr", + "cType": "git_attr", + "freeFunctionName": null, + "functions": [ + { + "cFunctionName": "git_attr_get", + "args": [ + { + "name": "value_out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "get", + "cppFunctionName": "Get", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_attr_get_many", + "args": [ + { + "name": "values_out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "num_attr", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "names", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getMany", + "cppFunctionName": "GetMany", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_attr_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "callback", + "cType": "git_attr_foreach_cb", + "cppClassName": "AttrForeachCb", + "jsClassName": "AttrForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_attr_cache_flush", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "cacheFlush", + "cppFunctionName": "CacheFlush", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_attr_add_macro", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "values", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "addMacro", + "cppFunctionName": "AddMacro", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "blob.h", + "jsClassName": "Blob", + "cppClassName": "Blob", + "cType": "git_blob", + "freeFunctionName": "git_blob_free", + "functions": [ + { + "cFunctionName": "git_blob_lookup", + "args": [ + { + "name": "blob", + "cType": "git_blob **", + "cppClassName": "Blob", + "jsClassName": "Blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_blob_lookup_prefix", + "args": [ + { + "name": "blob", + "cType": "git_blob **", + "cppClassName": "Blob", + "jsClassName": "Blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookupPrefix", + "cppFunctionName": "LookupPrefix", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_blob_free", + "args": [ + { + "name": "blob", + "cType": "git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_blob_id", + "args": [ + { + "name": "blob", + "cType": "const git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "id", + "cppFunctionName": "Id", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_blob_rawcontent", + "args": [ + { + "name": "blob", + "cType": "const git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "rawcontent", + "cppFunctionName": "Rawcontent", + "return": { + "cType": "const void *", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_blob_rawsize", + "args": [ + { + "name": "blob", + "cType": "const git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "rawsize", + "cppFunctionName": "Rawsize", + "return": { + "cType": "git_off_t", + "cppClassName": "OffT", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_blob_create_fromworkdir", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "relative_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createFromworkdir", + "cppFunctionName": "CreateFromworkdir", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_blob_create_fromdisk", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createFromdisk", + "cppFunctionName": "CreateFromdisk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_blob_create_fromchunks", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "hintpath", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "callback", + "cType": "git_blob_chunk_cb", + "cppClassName": "BlobChunkCb", + "jsClassName": "BlobChunkCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createFromchunks", + "cppFunctionName": "CreateFromchunks", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_blob_create_frombuffer", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "buffer", + "cType": "const void *", + "cppClassName": "void", + "jsClassName": "void" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createFrombuffer", + "cppFunctionName": "CreateFrombuffer", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_blob_is_binary", + "args": [ + { + "name": "blob", + "cType": "git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "isBinary", + "cppFunctionName": "IsBinary", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "branch.h", + "jsClassName": "Branch", + "cppClassName": "Branch", + "cType": "git_branch", + "freeFunctionName": "git_branch_free", + "functions": [ + { + "cFunctionName": "git_branch_create", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_delete", + "args": [ + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "branch_cb", + "cType": "git_branch_foreach_cb", + "cppClassName": "BranchForeachCb", + "jsClassName": "BranchForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_move", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "new_branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "move", + "cppFunctionName": "Move", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_lookup", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "branch_type", + "cType": "git_branch_t", + "cppClassName": "BranchT", + "jsClassName": "BranchT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_name", + "args": [ + { + "name": "out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_upstream", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "upstream", + "cppFunctionName": "Upstream", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_set_upstream", + "args": [ + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "upstream_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "setUpstream", + "cppFunctionName": "SetUpstream", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_upstream_name", + "args": [ + { + "name": "tracking_branch_name_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "buffer_size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "canonical_branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "upstreamName", + "cppFunctionName": "UpstreamName", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_is_head", + "args": [ + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "isHead", + "cppFunctionName": "IsHead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_branch_remote_name", + "args": [ + { + "name": "remote_name_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "buffer_size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "canonical_branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "remoteName", + "cppFunctionName": "RemoteName", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "checkout.h", + "jsClassName": "Checkout", + "cppClassName": "Checkout", + "cType": "git_checkout", + "freeFunctionName": "git_checkout_free", + "functions": [ + { + "cFunctionName": "git_checkout_head", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "opts", + "cType": "git_checkout_opts *", + "cppClassName": "CheckoutOpts", + "jsClassName": "CheckoutOpts" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "head", + "cppFunctionName": "Head", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_checkout_index", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "git_checkout_opts *", + "cppClassName": "CheckoutOpts", + "jsClassName": "CheckoutOpts" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "index", + "cppFunctionName": "Index", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_checkout_tree", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "treeish", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "opts", + "cType": "git_checkout_opts *", + "cppClassName": "CheckoutOpts", + "jsClassName": "CheckoutOpts" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "tree", + "cppFunctionName": "Tree", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "clone.h", + "jsClassName": "Clone", + "cppClassName": "Clone", + "cType": "git_clone", + "freeFunctionName": "git_clone_free", + "functions": [ + { + "cFunctionName": "git_clone", + "args": [ + { + "name": "out", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "local_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "options", + "cType": "const git_clone_options *", + "cppClassName": "CloneOptions", + "jsClassName": "CloneOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitClone", + "cppFunctionName": "GitClone", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "commit.h", + "jsClassName": "Commit", + "cppClassName": "Commit", + "cType": "git_commit", + "freeFunctionName": "git_commit_free", + "functions": [ + { + "cFunctionName": "git_commit_lookup", + "args": [ + { + "name": "commit", + "cType": "git_commit **", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_lookup_prefix", + "args": [ + { + "name": "commit", + "cType": "git_commit **", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookupPrefix", + "cppFunctionName": "LookupPrefix", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_free", + "args": [ + { + "name": "commit", + "cType": "git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_id", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "id", + "cppFunctionName": "Id", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_message_encoding", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "messageEncoding", + "cppFunctionName": "MessageEncoding", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_message", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "message", + "cppFunctionName": "Message", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_time", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "time", + "cppFunctionName": "Time", + "return": { + "cType": "git_time_t", + "cppClassName": "TimeT", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_time_offset", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "timeOffset", + "cppFunctionName": "TimeOffset", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_committer", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "committer", + "cppFunctionName": "Committer", + "return": { + "cType": "const git_signature *", + "cppClassName": "Signature", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_author", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "author", + "cppFunctionName": "Author", + "return": { + "cType": "const git_signature *", + "cppClassName": "Signature", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_tree", + "args": [ + { + "name": "tree_out", + "cType": "git_tree **", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "tree", + "cppFunctionName": "Tree", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_tree_id", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "treeId", + "cppFunctionName": "TreeId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_parentcount", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "parentcount", + "cppFunctionName": "Parentcount", + "return": { + "cType": "unsigned int", + "cppClassName": "unsigned", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_parent", + "args": [ + { + "name": "out", + "cType": "git_commit **", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "commit", + "cType": "git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "parent", + "cppFunctionName": "Parent", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_parent_id", + "args": [ + { + "name": "commit", + "cType": "git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "parentId", + "cppFunctionName": "ParentId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_commit_nth_gen_ancestor", + "args": [ + { + "name": "ancestor", + "cType": "git_commit **", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "Commit", + "jsClassName": "Commit" + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "nthGenAncestor", + "cppFunctionName": "NthGenAncestor", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_create", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "update_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "message_encoding", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "parent_count", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_create_v", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "update_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "message_encoding", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "parent_count", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createV", + "cppFunctionName": "CreateV", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "common.h", + "jsClassName": "Common", + "cppClassName": "Common", + "cType": "git_common", + "freeFunctionName": "git_common_free", + "functions": [ + { + "cFunctionName": "git_libgit2_version", + "args": [ + { + "name": "major", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "minor", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "rev", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitLibgit2Version", + "cppFunctionName": "GitLibgit2Version", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_libgit2_capabilities", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitLibgit2Capabilities", + "cppFunctionName": "GitLibgit2Capabilities", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_libgit2_opts", + "args": [ + { + "name": "option", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitLibgit2Opts", + "cppFunctionName": "GitLibgit2Opts", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "config.h", + "jsClassName": "Config", + "cppClassName": "Config", + "cType": "git_config", + "freeFunctionName": "git_config_free", + "functions": [ + { + "cFunctionName": "git_config_find_global", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "findGlobal", + "cppFunctionName": "FindGlobal", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_find_xdg", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "findXdg", + "cppFunctionName": "FindXdg", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_find_system", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "findSystem", + "cppFunctionName": "FindSystem", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_open_default", + "args": [ + { + "name": "out", + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "openDefault", + "cppFunctionName": "OpenDefault", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_new", + "args": [ + { + "name": "out", + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_add_backend", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "file", + "cType": "git_config_backend *", + "cppClassName": "ConfigBackend", + "jsClassName": "ConfigBackend" + }, + { + "name": "level", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addBackend", + "cppFunctionName": "AddBackend", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_add_file_ondisk", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "level", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addFileOndisk", + "cppFunctionName": "AddFileOndisk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_open_ondisk", + "args": [ + { + "name": "out", + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "openOndisk", + "cppFunctionName": "OpenOndisk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_open_level", + "args": [ + { + "name": "out", + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "parent", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "level", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "openLevel", + "cppFunctionName": "OpenLevel", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_refresh", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "refresh", + "cppFunctionName": "Refresh", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_free", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_config_get_entry", + "args": [ + { + "name": "out", + "cType": "const git_config_entry **", + "cppClassName": "ConfigEntry", + "jsClassName": "ConfigEntry" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getEntry", + "cppFunctionName": "GetEntry", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_get_int32", + "args": [ + { + "name": "out", + "cType": "int32_t *", + "cppClassName": "int32_t", + "jsClassName": "int32_t" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getInt32", + "cppFunctionName": "GetInt32", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_get_int64", + "args": [ + { + "name": "out", + "cType": "int64_t *", + "cppClassName": "int64_t", + "jsClassName": "int64_t" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getInt64", + "cppFunctionName": "GetInt64", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_get_bool", + "args": [ + { + "name": "out", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getBool", + "cppFunctionName": "GetBool", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_get_string", + "args": [ + { + "name": "out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getString", + "cppFunctionName": "GetString", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_get_multivar", + "args": [ + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "regexp", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "callback", + "cType": "git_config_foreach_cb", + "cppClassName": "ConfigForeachCb", + "jsClassName": "ConfigForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "getMultivar", + "cppFunctionName": "GetMultivar", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_set_int32", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "value", + "cType": "int32_t", + "cppClassName": "int32_t", + "jsClassName": "int32_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setInt32", + "cppFunctionName": "SetInt32", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_set_int64", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "value", + "cType": "int64_t", + "cppClassName": "int64_t", + "jsClassName": "int64_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setInt64", + "cppFunctionName": "SetInt64", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_set_bool", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "value", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setBool", + "cppFunctionName": "SetBool", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_set_string", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setString", + "cppFunctionName": "SetString", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_set_multivar", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "regexp", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setMultivar", + "cppFunctionName": "SetMultivar", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_delete_entry", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "deleteEntry", + "cppFunctionName": "DeleteEntry", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_foreach", + "args": [ + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "callback", + "cType": "git_config_foreach_cb", + "cppClassName": "ConfigForeachCb", + "jsClassName": "ConfigForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_foreach_match", + "args": [ + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "regexp", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "callback", + "cType": "git_config_foreach_cb", + "cppClassName": "ConfigForeachCb", + "jsClassName": "ConfigForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "foreachMatch", + "cppFunctionName": "ForeachMatch", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_get_mapped", + "args": [ + { + "name": "out", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "maps", + "cType": "const git_cvar_map *", + "cppClassName": "CvarMap", + "jsClassName": "CvarMap" + }, + { + "name": "map_n", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getMapped", + "cppFunctionName": "GetMapped", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_lookup_map_value", + "args": [ + { + "name": "out", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "maps", + "cType": "const git_cvar_map *", + "cppClassName": "CvarMap", + "jsClassName": "CvarMap" + }, + { + "name": "map_n", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookupMapValue", + "cppFunctionName": "LookupMapValue", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_parse_bool", + "args": [ + { + "name": "out", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "parseBool", + "cppFunctionName": "ParseBool", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_parse_int32", + "args": [ + { + "name": "out", + "cType": "int32_t *", + "cppClassName": "int32_t", + "jsClassName": "int32_t" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "parseInt32", + "cppFunctionName": "ParseInt32", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_config_parse_int64", + "args": [ + { + "name": "out", + "cType": "int64_t *", + "cppClassName": "int64_t", + "jsClassName": "int64_t" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "parseInt64", + "cppFunctionName": "ParseInt64", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "cred_helpers.h", + "jsClassName": "CredHelpers", + "cppClassName": "CredHelpers", + "cType": "git_cred_helpers", + "freeFunctionName": "git_cred_helpers_free", + "functions": [ + { + "cFunctionName": "git_cred_userpass", + "args": [ + { + "name": "cred", + "cType": "git_cred **", + "cppClassName": "Cred", + "jsClassName": "Cred" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "user_from_url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "allowed_types", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitCredUserpass", + "cppFunctionName": "GitCredUserpass", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "diff.h", + "jsClassName": "Diff", + "cppClassName": "Diff", + "cType": "git_diff", + "freeFunctionName": "git_diff_free", + "functions": [ + { + "cFunctionName": "git_diff_list_free", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "listFree", + "cppFunctionName": "ListFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_tree_to_tree", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "new_tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "DiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "treeToTree", + "cppFunctionName": "TreeToTree", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_tree_to_index", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "DiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "treeToIndex", + "cppFunctionName": "TreeToIndex", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_index_to_workdir", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "DiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "indexToWorkdir", + "cppFunctionName": "IndexToWorkdir", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_tree_to_workdir", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "DiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "treeToWorkdir", + "cppFunctionName": "TreeToWorkdir", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_merge", + "args": [ + { + "name": "onto", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "from", + "cType": "const git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "merge", + "cppFunctionName": "Merge", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_find_similar", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "options", + "cType": "git_diff_find_options *", + "cppClassName": "DiffFindOptions", + "jsClassName": "DiffFindOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "findSimilar", + "cppFunctionName": "FindSimilar", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_foreach", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb" + }, + { + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb" + }, + { + "name": "line_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_print_compact", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "printCompact", + "cppFunctionName": "PrintCompact", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_status_char", + "args": [ + { + "name": "status", + "cType": "git_delta_t", + "cppClassName": "DeltaT", + "jsClassName": "DeltaT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "statusChar", + "cppFunctionName": "StatusChar", + "return": { + "cType": "char", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_print_patch", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "printPatch", + "cppFunctionName": "PrintPatch", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_num_deltas", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "numDeltas", + "cppFunctionName": "NumDeltas", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_num_deltas_of_type", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "type", + "cType": "git_delta_t", + "cppClassName": "DeltaT", + "jsClassName": "DeltaT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "numDeltasOfType", + "cppFunctionName": "NumDeltasOfType", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_get_patch", + "args": [ + { + "name": "patch_out", + "cType": "git_diff_patch **", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + }, + { + "name": "delta_out", + "cType": "const git_diff_delta **", + "cppClassName": "DiffDelta", + "jsClassName": "DiffDelta" + }, + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "DiffList", + "jsClassName": "DiffList" + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "getPatch", + "cppFunctionName": "GetPatch", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_patch_free", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "patchFree", + "cppFunctionName": "PatchFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_patch_delta", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchDelta", + "cppFunctionName": "PatchDelta", + "return": { + "cType": "const git_diff_delta *", + "cppClassName": "DiffDelta", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_patch_num_hunks", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchNumHunks", + "cppFunctionName": "PatchNumHunks", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_diff_patch_line_stats", + "args": [ + { + "name": "total_context", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "total_additions", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "total_deletions", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "patch", + "cType": "const git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchLineStats", + "cppFunctionName": "PatchLineStats", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_patch_get_hunk", + "args": [ + { + "name": "range", + "cType": "const git_diff_range **", + "cppClassName": "DiffRange", + "jsClassName": "DiffRange" + }, + { + "name": "header", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "header_len", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "lines_in_hunk", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchGetHunk", + "cppFunctionName": "PatchGetHunk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_patch_num_lines_in_hunk", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchNumLinesInHunk", + "cppFunctionName": "PatchNumLinesInHunk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_patch_get_line_in_hunk", + "args": [ + { + "name": "line_origin", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "content", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "content_len", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "old_lineno", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "new_lineno", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "line_of_hunk", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchGetLineInHunk", + "cppFunctionName": "PatchGetLineInHunk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_patch_print", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + }, + { + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchPrint", + "cppFunctionName": "PatchPrint", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_patch_to_str", + "args": [ + { + "name": "string", + "cType": "char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "DiffPatch", + "jsClassName": "DiffPatch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "patchToStr", + "cppFunctionName": "PatchToStr", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_blobs", + "args": [ + { + "name": "old_blob", + "cType": "const git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + }, + { + "name": "new_blob", + "cType": "const git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + }, + { + "name": "options", + "cType": "const git_diff_options *", + "cppClassName": "DiffOptions", + "jsClassName": "DiffOptions" + }, + { + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb" + }, + { + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb" + }, + { + "name": "line_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "blobs", + "cppFunctionName": "Blobs", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_blob_to_buffer", + "args": [ + { + "name": "old_blob", + "cType": "const git_blob *", + "cppClassName": "Blob", + "jsClassName": "Blob" + }, + { + "name": "buffer", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "buffer_len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "options", + "cType": "const git_diff_options *", + "cppClassName": "DiffOptions", + "jsClassName": "DiffOptions" + }, + { + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb" + }, + { + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb" + }, + { + "name": "data_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "blobToBuffer", + "cppFunctionName": "BlobToBuffer", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "errors.h", + "jsClassName": "Errors", + "cppClassName": "Errors", + "cType": "git_errors", + "freeFunctionName": "git_errors_free", + "functions": [ + { + "cFunctionName": "giterr_last", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "giterrLast", + "cppFunctionName": "GiterrLast", + "return": { + "cType": "const git_error *", + "cppClassName": "Error", + "isErrorCode": false + } + }, + { + "cFunctionName": "giterr_clear", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "giterrClear", + "cppFunctionName": "GiterrClear", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "giterr_set_str", + "args": [ + { + "name": "error_class", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "string", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "giterrSetStr", + "cppFunctionName": "GiterrSetStr", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "giterr_set_oom", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "giterrSetOom", + "cppFunctionName": "GiterrSetOom", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "graph.h", + "jsClassName": "Graph", + "cppClassName": "Graph", + "cType": "git_graph", + "freeFunctionName": "git_graph_free", + "functions": [ + { + "cFunctionName": "git_graph_ahead_behind", + "args": [ + { + "name": "ahead", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "behind", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "local", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "upstream", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "aheadBehind", + "cppFunctionName": "AheadBehind", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "ignore.h", + "jsClassName": "Ignore", + "cppClassName": "Ignore", + "cType": "git_ignore", + "freeFunctionName": "git_ignore_free", + "functions": [ + { + "cFunctionName": "git_ignore_add_rule", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "rules", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "addRule", + "cppFunctionName": "AddRule", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_ignore_clear_internal_rules", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "clearInternalRules", + "cppFunctionName": "ClearInternalRules", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_ignore_path_is_ignored", + "args": [ + { + "name": "ignored", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "pathIsIgnored", + "cppFunctionName": "PathIsIgnored", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "index.h", + "jsClassName": "Index", + "cppClassName": "Index", + "cType": "git_index", + "freeFunctionName": "git_index_free", + "functions": [ + { + "cFunctionName": "git_index_open", + "args": [ + { + "name": "out", + "cType": "git_index **", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "index_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_new", + "args": [ + { + "name": "out", + "cType": "git_index **", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_free", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_owner", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "Repository", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_caps", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "caps", + "cppFunctionName": "Caps", + "return": { + "cType": "unsigned int", + "cppClassName": "unsigned", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_set_caps", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "caps", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setCaps", + "cppFunctionName": "SetCaps", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_read", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "read", + "cppFunctionName": "Read", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_write", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_read_tree", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "readTree", + "cppFunctionName": "ReadTree", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_write_tree", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "writeTree", + "cppFunctionName": "WriteTree", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_write_tree_to", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "writeTreeTo", + "cppFunctionName": "WriteTreeTo", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_entrycount", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entrycount", + "cppFunctionName": "Entrycount", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_clear", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "clear", + "cppFunctionName": "Clear", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_get_byindex", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "getByindex", + "cppFunctionName": "GetByindex", + "return": { + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_get_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "stage", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "getBypath", + "cppFunctionName": "GetBypath", + "return": { + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_remove", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "stage", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "remove", + "cppFunctionName": "Remove", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_remove_directory", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "dir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "stage", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "removeDirectory", + "cppFunctionName": "RemoveDirectory", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_add", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "source_entry", + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "add", + "cppFunctionName": "Add", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_entry_stage", + "args": [ + { + "name": "entry", + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryStage", + "cppFunctionName": "EntryStage", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_add_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addBypath", + "cppFunctionName": "AddBypath", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_remove_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "removeBypath", + "cppFunctionName": "RemoveBypath", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_find", + "args": [ + { + "name": "at_pos", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "find", + "cppFunctionName": "Find", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_conflict_add", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "ancestor_entry", + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + }, + { + "name": "our_entry", + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + }, + { + "name": "their_entry", + "cType": "const git_index_entry *", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "conflictAdd", + "cppFunctionName": "ConflictAdd", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_conflict_get", + "args": [ + { + "name": "ancestor_out", + "cType": "git_index_entry **", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + }, + { + "name": "our_out", + "cType": "git_index_entry **", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + }, + { + "name": "their_out", + "cType": "git_index_entry **", + "cppClassName": "IndexEntry", + "jsClassName": "IndexEntry" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "conflictGet", + "cppFunctionName": "ConflictGet", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_conflict_remove", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "conflictRemove", + "cppFunctionName": "ConflictRemove", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_conflict_cleanup", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "conflictCleanup", + "cppFunctionName": "ConflictCleanup", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_has_conflicts", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "hasConflicts", + "cppFunctionName": "HasConflicts", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_reuc_entrycount", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reucEntrycount", + "cppFunctionName": "ReucEntrycount", + "return": { + "cType": "unsigned int", + "cppClassName": "unsigned", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_reuc_find", + "args": [ + { + "name": "at_pos", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "reucFind", + "cppFunctionName": "ReucFind", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_reuc_get_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reucGetBypath", + "cppFunctionName": "ReucGetBypath", + "return": { + "cType": "const git_index_reuc_entry *", + "cppClassName": "IndexReucEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_reuc_get_byindex", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reucGetByindex", + "cppFunctionName": "ReucGetByindex", + "return": { + "cType": "const git_index_reuc_entry *", + "cppClassName": "IndexReucEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_index_reuc_add", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "ancestor_mode", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "ancestor_id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "our_mode", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "our_id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "their_mode", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "their_id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reucAdd", + "cppFunctionName": "ReucAdd", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_reuc_remove", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reucRemove", + "cppFunctionName": "ReucRemove", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_index_reuc_clear", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reucClear", + "cppFunctionName": "ReucClear", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "indexer.h", + "jsClassName": "Indexer", + "cppClassName": "Indexer", + "cType": "git_indexer", + "freeFunctionName": "git_indexer_free", + "functions": [ + { + "cFunctionName": "git_indexer_stream_new", + "args": [ + { + "name": "out", + "cType": "git_indexer_stream **", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "progress_cb", + "cType": "git_transfer_progress_callback", + "cppClassName": "TransferProgressCallback", + "jsClassName": "TransferProgressCallback" + }, + { + "name": "progress_cb_payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "streamNew", + "cppFunctionName": "StreamNew", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_indexer_stream_add", + "args": [ + { + "name": "idx", + "cType": "git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream" + }, + { + "name": "data", + "cType": "const void *", + "cppClassName": "void", + "jsClassName": "void" + }, + { + "name": "size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "stats", + "cType": "git_transfer_progress *", + "cppClassName": "TransferProgress", + "jsClassName": "TransferProgress" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "streamAdd", + "cppFunctionName": "StreamAdd", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_indexer_stream_finalize", + "args": [ + { + "name": "idx", + "cType": "git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream" + }, + { + "name": "stats", + "cType": "git_transfer_progress *", + "cppClassName": "TransferProgress", + "jsClassName": "TransferProgress" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "streamFinalize", + "cppFunctionName": "StreamFinalize", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_indexer_stream_hash", + "args": [ + { + "name": "idx", + "cType": "const git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "streamHash", + "cppFunctionName": "StreamHash", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_indexer_stream_free", + "args": [ + { + "name": "idx", + "cType": "git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "streamFree", + "cppFunctionName": "StreamFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "inttypes.h", + "jsClassName": "Inttypes", + "cppClassName": "Inttypes", + "cType": "git_inttypes", + "freeFunctionName": "git_inttypes_free", + "functions": [] + }, + { + "filename": "merge.h", + "jsClassName": "Merge", + "cppClassName": "Merge", + "cType": "git_merge", + "freeFunctionName": "git_merge_free", + "functions": [ + { + "cFunctionName": "git_merge_base", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "one", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "two", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "base", + "cppFunctionName": "Base", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_merge_base_many", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "baseMany", + "cppFunctionName": "BaseMany", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "message.h", + "jsClassName": "Message", + "cppClassName": "Message", + "cType": "git_message", + "freeFunctionName": "git_message_free", + "functions": [ + { + "cFunctionName": "git_message_prettify", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "out_size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "strip_comments", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "prettify", + "cppFunctionName": "Prettify", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "net.h", + "jsClassName": "Net", + "cppClassName": "Net", + "cType": "git_net", + "freeFunctionName": "git_net_free", + "functions": [] + }, + { + "filename": "notes.h", + "jsClassName": "Notes", + "cppClassName": "Notes", + "cType": "git_notes", + "freeFunctionName": "git_notes_free", + "functions": [ + { + "cFunctionName": "git_note_iterator_new", + "args": [ + { + "name": "out", + "cType": "git_note_iterator **", + "cppClassName": "NoteIterator", + "jsClassName": "NoteIterator" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteIteratorNew", + "cppFunctionName": "GitNoteIteratorNew", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_note_iterator_free", + "args": [ + { + "name": "it", + "cType": "git_note_iterator *", + "cppClassName": "NoteIterator", + "jsClassName": "NoteIterator" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitNoteIteratorFree", + "cppFunctionName": "GitNoteIteratorFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_note_next", + "args": [ + { + "name": "note_id", + "cType": "git_oid*", + "cppClassName": "Oid*", + "jsClassName": "Oid*" + }, + { + "name": "annotated_id", + "cType": "git_oid*", + "cppClassName": "Oid*", + "jsClassName": "Oid*" + }, + { + "name": "it", + "cType": "git_note_iterator *", + "cppClassName": "NoteIterator", + "jsClassName": "NoteIterator" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteNext", + "cppFunctionName": "GitNoteNext", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_note_read", + "args": [ + { + "name": "out", + "cType": "git_note **", + "cppClassName": "Note", + "jsClassName": "Note" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteRead", + "cppFunctionName": "GitNoteRead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_note_message", + "args": [ + { + "name": "note", + "cType": "const git_note *", + "cppClassName": "Note", + "jsClassName": "Note" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteMessage", + "cppFunctionName": "GitNoteMessage", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_note_oid", + "args": [ + { + "name": "note", + "cType": "const git_note *", + "cppClassName": "Note", + "jsClassName": "Note" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteOid", + "cppFunctionName": "GitNoteOid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_note_create", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "note", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteCreate", + "cppFunctionName": "GitNoteCreate", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_note_remove", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteRemove", + "cppFunctionName": "GitNoteRemove", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_note_free", + "args": [ + { + "name": "note", + "cType": "git_note *", + "cppClassName": "Note", + "jsClassName": "Note" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitNoteFree", + "cppFunctionName": "GitNoteFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_note_default_ref", + "args": [ + { + "name": "out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteDefaultRef", + "cppFunctionName": "GitNoteDefaultRef", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_note_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "note_cb", + "cType": "git_note_foreach_cb", + "cppClassName": "NoteForeachCb", + "jsClassName": "NoteForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitNoteForeach", + "cppFunctionName": "GitNoteForeach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "object.h", + "jsClassName": "Object", + "cppClassName": "Object", + "cType": "git_object", + "freeFunctionName": "git_object_free", + "functions": [ + { + "cFunctionName": "git_object_lookup", + "args": [ + { + "name": "object", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_object_lookup_prefix", + "args": [ + { + "name": "object_out", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookupPrefix", + "cppFunctionName": "LookupPrefix", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_object_id", + "args": [ + { + "name": "obj", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "id", + "cppFunctionName": "Id", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_type", + "args": [ + { + "name": "obj", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_otype", + "cppClassName": "Otype", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_owner", + "args": [ + { + "name": "obj", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "Repository", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_free", + "args": [ + { + "name": "object", + "cType": "git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_type2string", + "args": [ + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "type2string", + "cppFunctionName": "Type2string", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_string2type", + "args": [ + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "string2type", + "cppFunctionName": "String2type", + "return": { + "cType": "git_otype", + "cppClassName": "Otype", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_typeisloose", + "args": [ + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "typeisloose", + "cppFunctionName": "Typeisloose", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_object__size", + "args": [ + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "Size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_object_peel", + "args": [ + { + "name": "peeled", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "object", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "target_type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "peel", + "cppFunctionName": "Peel", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_object_dup", + "args": [ + { + "name": "dest", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "source", + "cType": "git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "dup", + "cppFunctionName": "Dup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "odb.h", + "jsClassName": "Odb", + "cppClassName": "Odb", + "cType": "git_odb", + "freeFunctionName": "git_odb_free", + "functions": [ + { + "cFunctionName": "git_odb_new", + "args": [ + { + "name": "out", + "cType": "git_odb **", + "cppClassName": "Odb", + "jsClassName": "Odb" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_open", + "args": [ + { + "name": "out", + "cType": "git_odb **", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "objects_dir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_add_backend", + "args": [ + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "backend", + "cType": "git_odb_backend *", + "cppClassName": "OdbBackend", + "jsClassName": "OdbBackend" + }, + { + "name": "priority", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addBackend", + "cppFunctionName": "AddBackend", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_add_alternate", + "args": [ + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "backend", + "cType": "git_odb_backend *", + "cppClassName": "OdbBackend", + "jsClassName": "OdbBackend" + }, + { + "name": "priority", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addAlternate", + "cppFunctionName": "AddAlternate", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_add_disk_alternate", + "args": [ + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addDiskAlternate", + "cppFunctionName": "AddDiskAlternate", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_free", + "args": [ + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_odb_read", + "args": [ + { + "name": "out", + "cType": "git_odb_object **", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "read", + "cppFunctionName": "Read", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_read_prefix", + "args": [ + { + "name": "out", + "cType": "git_odb_object **", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "short_id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "readPrefix", + "cppFunctionName": "ReadPrefix", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_read_header", + "args": [ + { + "name": "len_out", + "cType": "size_t *", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "type_out", + "cType": "git_otype *", + "cppClassName": "Otype", + "jsClassName": "Otype" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "readHeader", + "cppFunctionName": "ReadHeader", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_exists", + "args": [ + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "exists", + "cppFunctionName": "Exists", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_refresh", + "args": [ + { + "name": "db", + "cType": "struct git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "refresh", + "cppFunctionName": "Refresh", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_foreach", + "args": [ + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "cb", + "cType": "git_odb_foreach_cb", + "cppClassName": "OdbForeachCb", + "jsClassName": "OdbForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_write", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "data", + "cType": "const void *", + "cppClassName": "void", + "jsClassName": "void" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_open_wstream", + "args": [ + { + "name": "out", + "cType": "git_odb_stream **", + "cppClassName": "OdbStream", + "jsClassName": "OdbStream" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "openWstream", + "cppFunctionName": "OpenWstream", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_open_rstream", + "args": [ + { + "name": "out", + "cType": "git_odb_stream **", + "cppClassName": "OdbStream", + "jsClassName": "OdbStream" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "openRstream", + "cppFunctionName": "OpenRstream", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_write_pack", + "args": [ + { + "name": "out", + "cType": "git_odb_writepack **", + "cppClassName": "OdbWritepack", + "jsClassName": "OdbWritepack" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "progress_cb", + "cType": "git_transfer_progress_callback", + "cppClassName": "TransferProgressCallback", + "jsClassName": "TransferProgressCallback" + }, + { + "name": "progress_payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "writePack", + "cppFunctionName": "WritePack", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_hash", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "data", + "cType": "const void *", + "cppClassName": "void", + "jsClassName": "void" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "hash", + "cppFunctionName": "Hash", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_hashfile", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "hashfile", + "cppFunctionName": "Hashfile", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_odb_object_free", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "objectFree", + "cppFunctionName": "ObjectFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_odb_object_id", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "objectId", + "cppFunctionName": "ObjectId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_odb_object_data", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "objectData", + "cppFunctionName": "ObjectData", + "return": { + "cType": "const void *", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_odb_object_size", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "objectSize", + "cppFunctionName": "ObjectSize", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_odb_object_type", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "OdbObject", + "jsClassName": "OdbObject" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "objectType", + "cppFunctionName": "ObjectType", + "return": { + "cType": "git_otype", + "cppClassName": "Otype", + "isErrorCode": false + } + } + ] + }, + { + "filename": "odb_backend.h", + "jsClassName": "OdbBackend", + "cppClassName": "OdbBackend", + "cType": "git_odb_backend", + "freeFunctionName": "git_odb_backend_free", + "functions": [ + { + "cFunctionName": "git_odb_backend_pack", + "args": [ + { + "name": "out", + "cType": "git_odb_backend **", + "cppClassName": "OdbBackend", + "jsClassName": "OdbBackend" + }, + { + "name": "objects_dir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "pack", + "cppFunctionName": "Pack", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "oid.h", + "jsClassName": "Oid", + "cppClassName": "GitOid", + "cType": "git_oid", + "freeFunctionName": "free", + "functions": [ + { + "cFunctionName": "git_oid_fromstr", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fromString", + "cppFunctionName": "FromString", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_fromstrp", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fromstrp", + "cppFunctionName": "Fromstrp", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_fromstrn", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fromstrn", + "cppFunctionName": "Fromstrn", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_fromraw", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "raw", + "cType": "const unsigned char *", + "cppClassName": "const", + "jsClassName": "const" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fromraw", + "cppFunctionName": "Fromraw", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_fmt", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fmt", + "cppFunctionName": "Fmt", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_pathfmt", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "pathfmt", + "cppFunctionName": "Pathfmt", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_allocfmt", + "args": [ + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "sha", + "cppFunctionName": "Sha", + "return": { + "cType": "char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_tostr", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "sha", + "cppFunctionName": "Sha", + "return": { + "cType": "char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_cpy", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "src", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "cpy", + "cppFunctionName": "Cpy", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_cmp", + "args": [ + { + "name": "a", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "b", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "cmp", + "cppFunctionName": "Cmp", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_equal", + "args": [ + { + "name": "a", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "b", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "equal", + "cppFunctionName": "Equal", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_ncmp", + "args": [ + { + "name": "a", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "b", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "ncmp", + "cppFunctionName": "Ncmp", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_streq", + "args": [ + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "streq", + "cppFunctionName": "Streq", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_iszero", + "args": [ + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "iszero", + "cppFunctionName": "Iszero", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_shorten_new", + "args": [ + { + "name": "min_length", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "shortenNew", + "cppFunctionName": "ShortenNew", + "return": { + "cType": "git_oid_shorten *", + "cppClassName": "OidShorten", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_oid_shorten_add", + "args": [ + { + "name": "os", + "cType": "git_oid_shorten *", + "cppClassName": "OidShorten", + "jsClassName": "OidShorten" + }, + { + "name": "text_id", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "shortenAdd", + "cppFunctionName": "ShortenAdd", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_oid_shorten_free", + "args": [ + { + "name": "os", + "cType": "git_oid_shorten *", + "cppClassName": "OidShorten", + "jsClassName": "OidShorten" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "shortenFree", + "cppFunctionName": "ShortenFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "pack.h", + "jsClassName": "Pack", + "cppClassName": "Pack", + "cType": "git_pack", + "freeFunctionName": "git_pack_free", + "functions": [ + { + "cFunctionName": "git_packbuilder_new", + "args": [ + { + "name": "out", + "cType": "git_packbuilder **", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderNew", + "cppFunctionName": "GitPackbuilderNew", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_packbuilder_set_threads", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderSetThreads", + "cppFunctionName": "GitPackbuilderSetThreads", + "return": { + "cType": "unsigned int", + "cppClassName": "unsigned", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_packbuilder_insert", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderInsert", + "cppFunctionName": "GitPackbuilderInsert", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_packbuilder_insert_tree", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderInsertTree", + "cppFunctionName": "GitPackbuilderInsertTree", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_packbuilder_write", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + }, + { + "name": "file", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderWrite", + "cppFunctionName": "GitPackbuilderWrite", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_packbuilder_foreach", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + }, + { + "name": "cb", + "cType": "git_packbuilder_foreach_cb", + "cppClassName": "PackbuilderForeachCb", + "jsClassName": "PackbuilderForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderForeach", + "cppFunctionName": "GitPackbuilderForeach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_packbuilder_object_count", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderObjectCount", + "cppFunctionName": "GitPackbuilderObjectCount", + "return": { + "cType": "uint32_t", + "cppClassName": "Uint32", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_packbuilder_written", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitPackbuilderWritten", + "cppFunctionName": "GitPackbuilderWritten", + "return": { + "cType": "uint32_t", + "cppClassName": "Uint32", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_packbuilder_free", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitPackbuilderFree", + "cppFunctionName": "GitPackbuilderFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "push.h", + "jsClassName": "Push", + "cppClassName": "Push", + "cType": "git_push", + "freeFunctionName": "git_push_free", + "functions": [ + { + "cFunctionName": "git_push_new", + "args": [ + { + "name": "out", + "cType": "git_push **", + "cppClassName": "Push", + "jsClassName": "Push" + }, + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_set_options", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + }, + { + "name": "opts", + "cType": "const git_push_options *", + "cppClassName": "PushOptions", + "jsClassName": "PushOptions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setOptions", + "cppFunctionName": "SetOptions", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_add_refspec", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + }, + { + "name": "refspec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addRefspec", + "cppFunctionName": "AddRefspec", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_update_tips", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "updateTips", + "cppFunctionName": "UpdateTips", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_finish", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "finish", + "cppFunctionName": "Finish", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_unpack_ok", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "unpackOk", + "cppFunctionName": "UnpackOk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_status_foreach", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + }, + { + "name": "cb", + "cType": "int (*)(const char *ref, const char *msg, void *data)", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "data", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "statusForeach", + "cppFunctionName": "StatusForeach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_push_free", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "refdb.h", + "jsClassName": "Refdb", + "cppClassName": "Refdb", + "cType": "git_refdb", + "freeFunctionName": "git_refdb_free", + "functions": [ + { + "cFunctionName": "git_reference__alloc", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "symbolic", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "gitReference_Alloc", + "cppFunctionName": "GitReference_Alloc", + "return": { + "cType": "git_reference *", + "cppClassName": "Reference", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_refdb_new", + "args": [ + { + "name": "out", + "cType": "git_refdb **", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refdb_open", + "args": [ + { + "name": "out", + "cType": "git_refdb **", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refdb_compress", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "compress", + "cppFunctionName": "Compress", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refdb_free", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_refdb_set_backend", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + }, + { + "name": "backend", + "cType": "git_refdb_backend *", + "cppClassName": "RefdbBackend", + "jsClassName": "RefdbBackend" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setBackend", + "cppFunctionName": "SetBackend", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "refdb_backend.h", + "jsClassName": "RefdbBackend", + "cppClassName": "RefdbBackend", + "cType": "git_refdb_backend", + "freeFunctionName": "git_refdb_backend_free", + "functions": [ + { + "cFunctionName": "git_refdb_backend_fs", + "args": [ + { + "name": "backend_out", + "cType": "struct git_refdb_backend **", + "cppClassName": "RefdbBackend", + "jsClassName": "RefdbBackend" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "fs", + "cppFunctionName": "Fs", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "reflog.h", + "jsClassName": "Reflog", + "cppClassName": "Reflog", + "cType": "git_reflog", + "freeFunctionName": "git_reflog_free", + "functions": [ + { + "cFunctionName": "git_reflog_read", + "args": [ + { + "name": "out", + "cType": "git_reflog **", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + }, + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "read", + "cppFunctionName": "Read", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reflog_write", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reflog_append", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "msg", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "append", + "cppFunctionName": "Append", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reflog_rename", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "rename", + "cppFunctionName": "Rename", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reflog_delete", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reflog_entrycount", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entrycount", + "cppFunctionName": "Entrycount", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reflog_entry_byindex", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entryByindex", + "cppFunctionName": "EntryByindex", + "return": { + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reflog_drop", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "rewrite_previous_entry", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "drop", + "cppFunctionName": "Drop", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reflog_entry_id_old", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryIdOld", + "cppFunctionName": "EntryIdOld", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reflog_entry_id_new", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryIdNew", + "cppFunctionName": "EntryIdNew", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reflog_entry_committer", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryCommitter", + "cppFunctionName": "EntryCommitter", + "return": { + "cType": "const git_signature *", + "cppClassName": "Signature", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reflog_entry_message", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryMessage", + "cppFunctionName": "EntryMessage", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reflog_free", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "refs.h", + "jsClassName": "Refs", + "cppClassName": "Refs", + "cType": "git_refs", + "freeFunctionName": "git_refs_free", + "functions": [ + { + "cFunctionName": "git_reference_lookup", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceLookup", + "cppFunctionName": "GitReferenceLookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_name_to_id", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceNameToId", + "cppFunctionName": "GitReferenceNameToId", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_symbolic_create", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceSymbolicCreate", + "cppFunctionName": "GitReferenceSymbolicCreate", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_create", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceCreate", + "cppFunctionName": "GitReferenceCreate", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_target", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceTarget", + "cppFunctionName": "GitReferenceTarget", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reference_symbolic_target", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceSymbolicTarget", + "cppFunctionName": "GitReferenceSymbolicTarget", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reference_type", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceType", + "cppFunctionName": "GitReferenceType", + "return": { + "cType": "git_ref_t", + "cppClassName": "RefT", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reference_name", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceName", + "cppFunctionName": "GitReferenceName", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reference_resolve", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceResolve", + "cppFunctionName": "GitReferenceResolve", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_owner", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceOwner", + "cppFunctionName": "GitReferenceOwner", + "return": { + "cType": "git_repository *", + "cppClassName": "Repository", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reference_symbolic_set_target", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "target", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceSymbolicSetTarget", + "cppFunctionName": "GitReferenceSymbolicSetTarget", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_set_target", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceSetTarget", + "cppFunctionName": "GitReferenceSetTarget", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_rename", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "new_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceRename", + "cppFunctionName": "GitReferenceRename", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_delete", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceDelete", + "cppFunctionName": "GitReferenceDelete", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_list", + "args": [ + { + "name": "array", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceList", + "cppFunctionName": "GitReferenceList", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "callback", + "cType": "git_reference_foreach_cb", + "cppClassName": "ReferenceForeachCb", + "jsClassName": "ReferenceForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceForeach", + "cppFunctionName": "GitReferenceForeach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_free", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitReferenceFree", + "cppFunctionName": "GitReferenceFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_reference_cmp", + "args": [ + { + "name": "ref1", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "ref2", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceCmp", + "cppFunctionName": "GitReferenceCmp", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_foreach_glob", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "glob", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "callback", + "cType": "git_reference_foreach_cb", + "cppClassName": "ReferenceForeachCb", + "jsClassName": "ReferenceForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceForeachGlob", + "cppFunctionName": "GitReferenceForeachGlob", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_has_log", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceHasLog", + "cppFunctionName": "GitReferenceHasLog", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_is_branch", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceIsBranch", + "cppFunctionName": "GitReferenceIsBranch", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_is_remote", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceIsRemote", + "cppFunctionName": "GitReferenceIsRemote", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_normalize_name", + "args": [ + { + "name": "buffer_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "buffer_size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceNormalizeName", + "cppFunctionName": "GitReferenceNormalizeName", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_peel", + "args": [ + { + "name": "out", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferencePeel", + "cppFunctionName": "GitReferencePeel", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_is_valid_name", + "args": [ + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReferenceIsValidName", + "cppFunctionName": "GitReferenceIsValidName", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "refspec.h", + "jsClassName": "Refspec", + "cppClassName": "Refspec", + "cType": "git_refspec", + "freeFunctionName": "git_refspec_free", + "functions": [ + { + "cFunctionName": "git_refspec_src", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "src", + "cppFunctionName": "Src", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_refspec_dst", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "dst", + "cppFunctionName": "Dst", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_refspec_force", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "force", + "cppFunctionName": "Force", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refspec_src_matches", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "srcMatches", + "cppFunctionName": "SrcMatches", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refspec_dst_matches", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "dstMatches", + "cppFunctionName": "DstMatches", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refspec_transform", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "outlen", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "spec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "transform", + "cppFunctionName": "Transform", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refspec_rtransform", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "outlen", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "spec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "rtransform", + "cppFunctionName": "Rtransform", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "remote.h", + "jsClassName": "Remote", + "cppClassName": "Remote", + "cType": "git_remote", + "freeFunctionName": "git_remote_free", + "functions": [ + { + "cFunctionName": "git_remote_create", + "args": [ + { + "name": "out", + "cType": "git_remote **", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_create_inmemory", + "args": [ + { + "name": "out", + "cType": "git_remote **", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "fetch", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createInmemory", + "cppFunctionName": "CreateInmemory", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_load", + "args": [ + { + "name": "out", + "cType": "git_remote **", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "load", + "cppFunctionName": "Load", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_save", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "save", + "cppFunctionName": "Save", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_name", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_url", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "url", + "cppFunctionName": "Url", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_pushurl", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "pushurl", + "cppFunctionName": "Pushurl", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_set_url", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "url", + "cType": "const char*", + "cppClassName": "const", + "jsClassName": "const" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setUrl", + "cppFunctionName": "SetUrl", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_set_pushurl", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "url", + "cType": "const char*", + "cppClassName": "const", + "jsClassName": "const" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setPushurl", + "cppFunctionName": "SetPushurl", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_set_fetchspec", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setFetchspec", + "cppFunctionName": "SetFetchspec", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_fetchspec", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fetchspec", + "cppFunctionName": "Fetchspec", + "return": { + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_set_pushspec", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setPushspec", + "cppFunctionName": "SetPushspec", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_pushspec", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "pushspec", + "cppFunctionName": "Pushspec", + "return": { + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_connect", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "direction", + "cType": "git_direction", + "cppClassName": "Direction", + "jsClassName": "Direction" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "connect", + "cppFunctionName": "Connect", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_ls", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "list_cb", + "cType": "git_headlist_cb", + "cppClassName": "HeadlistCb", + "jsClassName": "HeadlistCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "ls", + "cppFunctionName": "Ls", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_download", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "progress_cb", + "cType": "git_transfer_progress_callback", + "cppClassName": "TransferProgressCallback", + "jsClassName": "TransferProgressCallback" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "download", + "cppFunctionName": "Download", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_connected", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "connected", + "cppFunctionName": "Connected", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_stop", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "stop", + "cppFunctionName": "Stop", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_disconnect", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "disconnect", + "cppFunctionName": "Disconnect", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_free", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_update_tips", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "updateTips", + "cppFunctionName": "UpdateTips", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_valid_url", + "args": [ + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "validUrl", + "cppFunctionName": "ValidUrl", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_supported_url", + "args": [ + { + "name": "url", + "cType": "const char*", + "cppClassName": "const", + "jsClassName": "const" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "supportedUrl", + "cppFunctionName": "SupportedUrl", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_list", + "args": [ + { + "name": "out", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "list", + "cppFunctionName": "List", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_check_cert", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "check", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "checkCert", + "cppFunctionName": "CheckCert", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_set_cred_acquire_cb", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "cred_acquire_cb", + "cType": "git_cred_acquire_cb", + "cppClassName": "CredAcquireCb", + "jsClassName": "CredAcquireCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setCredAcquireCb", + "cppFunctionName": "SetCredAcquireCb", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_set_transport", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "transport", + "cType": "git_transport *", + "cppClassName": "Transport", + "jsClassName": "Transport" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setTransport", + "cppFunctionName": "SetTransport", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_set_callbacks", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "callbacks", + "cType": "git_remote_callbacks *", + "cppClassName": "RemoteCallbacks", + "jsClassName": "RemoteCallbacks" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setCallbacks", + "cppFunctionName": "SetCallbacks", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_stats", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "stats", + "cppFunctionName": "Stats", + "return": { + "cType": "const git_transfer_progress *", + "cppClassName": "TransferProgress", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_autotag", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "autotag", + "cppFunctionName": "Autotag", + "return": { + "cType": "GIT_EXTERN(", + "cppClassName": "GIT_EXTERN(", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_set_autotag", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "value", + "cType": "git_remote_autotag_option_t", + "cppClassName": "RemoteAutotagOptionT", + "jsClassName": "RemoteAutotagOptionT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setAutotag", + "cppFunctionName": "SetAutotag", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_rename", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "new_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "callback", + "cType": "git_remote_rename_problem_cb", + "cppClassName": "RemoteRenameProblemCb", + "jsClassName": "RemoteRenameProblemCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "rename", + "cppFunctionName": "Rename", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_update_fetchhead", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "updateFetchhead", + "cppFunctionName": "UpdateFetchhead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_set_update_fetchhead", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "value", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setUpdateFetchhead", + "cppFunctionName": "SetUpdateFetchhead", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_remote_is_valid_name", + "args": [ + { + "name": "remote_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "isValidName", + "cppFunctionName": "IsValidName", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "repository.h", + "jsClassName": "Repository", + "cppClassName": "Repository", + "cType": "git_repository", + "freeFunctionName": "git_repository_free", + "functions": [ + { + "cFunctionName": "git_repository_open", + "args": [ + { + "name": "out", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_wrap_odb", + "args": [ + { + "name": "out", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "wrapOdb", + "cppFunctionName": "WrapOdb", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_discover", + "args": [ + { + "name": "path_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "path_size", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "start_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "across_fs", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "ceiling_dirs", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "discover", + "cppFunctionName": "Discover", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_open_ext", + "args": [ + { + "name": "out", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + }, + { + "name": "ceiling_dirs", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "openExt", + "cppFunctionName": "OpenExt", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_free", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_init", + "args": [ + { + "name": "out", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "is_bare", + "cType": "unsigned", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "init", + "cppFunctionName": "Init", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_init_ext", + "args": [ + { + "name": "out", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "repo_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "opts", + "cType": "git_repository_init_options *", + "cppClassName": "RepositoryInitOptions", + "jsClassName": "RepositoryInitOptions" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "initExt", + "cppFunctionName": "InitExt", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_head", + "args": [ + { + "name": "out", + "cType": "git_reference **", + "cppClassName": "Reference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "head", + "cppFunctionName": "Head", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_head_detached", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "headDetached", + "cppFunctionName": "HeadDetached", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_head_orphan", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "headOrphan", + "cppFunctionName": "HeadOrphan", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_is_empty", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "isEmpty", + "cppFunctionName": "IsEmpty", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_path", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "path", + "cppFunctionName": "Path", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_workdir", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "workdir", + "cppFunctionName": "Workdir", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_set_workdir", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "workdir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "update_gitlink", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setWorkdir", + "cppFunctionName": "SetWorkdir", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_is_bare", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "isBare", + "cppFunctionName": "IsBare", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_config", + "args": [ + { + "name": "out", + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "config", + "cppFunctionName": "Config", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_set_config", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "config", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setConfig", + "cppFunctionName": "SetConfig", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_odb", + "args": [ + { + "name": "out", + "cType": "git_odb **", + "cppClassName": "Odb", + "jsClassName": "Odb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "odb", + "cppFunctionName": "Odb", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_set_odb", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "Odb", + "jsClassName": "Odb" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setOdb", + "cppFunctionName": "SetOdb", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_refdb", + "args": [ + { + "name": "out", + "cType": "git_refdb **", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "refdb", + "cppFunctionName": "Refdb", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_set_refdb", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "Refdb", + "jsClassName": "Refdb" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setRefdb", + "cppFunctionName": "SetRefdb", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_index", + "args": [ + { + "name": "out", + "cType": "git_index **", + "cppClassName": "Index", + "jsClassName": "Index" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "index", + "cppFunctionName": "Index", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_set_index", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "Index", + "jsClassName": "Index" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setIndex", + "cppFunctionName": "SetIndex", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_repository_message", + "args": [ + { + "name": "out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "char" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "message", + "cppFunctionName": "Message", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_message_remove", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "messageRemove", + "cppFunctionName": "MessageRemove", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_merge_cleanup", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "mergeCleanup", + "cppFunctionName": "MergeCleanup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_fetchhead_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "git_repository_fetchhead_foreach_cb", + "cppClassName": "RepositoryFetchheadForeachCb", + "jsClassName": "RepositoryFetchheadForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fetchheadForeach", + "cppFunctionName": "FetchheadForeach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_mergehead_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "git_repository_mergehead_foreach_cb", + "cppClassName": "RepositoryMergeheadForeachCb", + "jsClassName": "RepositoryMergeheadForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "mergeheadForeach", + "cppFunctionName": "MergeheadForeach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_hashfile", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Otype", + "jsClassName": "Otype" + }, + { + "name": "as_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "hashfile", + "cppFunctionName": "Hashfile", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_set_head", + "args": [ + { + "name": "repo", + "cType": "git_repository*", + "cppClassName": "Repository*", + "jsClassName": "Repository*" + }, + { + "name": "refname", + "cType": "const char*", + "cppClassName": "const", + "jsClassName": "const" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "setHead", + "cppFunctionName": "SetHead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_set_head_detached", + "args": [ + { + "name": "repo", + "cType": "git_repository*", + "cppClassName": "Repository*", + "jsClassName": "Repository*" + }, + { + "name": "commitish", + "cType": "const git_oid*", + "cppClassName": "const", + "jsClassName": "const" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "setHeadDetached", + "cppFunctionName": "SetHeadDetached", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_detach_head", + "args": [ + { + "name": "repo", + "cType": "git_repository*", + "cppClassName": "Repository*", + "jsClassName": "Repository*" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "detachHead", + "cppFunctionName": "DetachHead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_repository_state", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "state", + "cppFunctionName": "State", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "reset.h", + "jsClassName": "Reset", + "cppClassName": "Reset", + "cType": "git_reset", + "freeFunctionName": "git_reset_free", + "functions": [ + { + "cFunctionName": "git_reset", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "target", + "cType": "git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "reset_type", + "cType": "git_reset_t", + "cppClassName": "ResetT", + "jsClassName": "ResetT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitReset", + "cppFunctionName": "GitReset", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reset_default", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "target", + "cType": "git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "pathspecs", + "cType": "git_strarray*", + "cppClassName": "Strarray*", + "jsClassName": "Strarray*" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "default", + "cppFunctionName": "Default", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "revparse.h", + "jsClassName": "Revparse", + "cppClassName": "Revparse", + "cType": "git_revparse", + "freeFunctionName": "git_revparse_free", + "functions": [ + { + "cFunctionName": "git_revparse_single", + "args": [ + { + "name": "out", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "single", + "cppFunctionName": "Single", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revparse", + "args": [ + { + "name": "revspec", + "cType": "git_revspec *", + "cppClassName": "Revspec", + "jsClassName": "Revspec" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitRevparse", + "cppFunctionName": "GitRevparse", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "revwalk.h", + "jsClassName": "Revwalk", + "cppClassName": "Revwalk", + "cType": "git_revwalk", + "freeFunctionName": "git_revwalk_free", + "functions": [ + { + "cFunctionName": "git_revwalk_new", + "args": [ + { + "name": "out", + "cType": "git_revwalk **", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_reset", + "args": [ + { + "name": "walker", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reset", + "cppFunctionName": "Reset", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_revwalk_push", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "push", + "cppFunctionName": "Push", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_push_glob", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "glob", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "pushGlob", + "cppFunctionName": "PushGlob", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_push_head", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "pushHead", + "cppFunctionName": "PushHead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_hide", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "commit_id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "hide", + "cppFunctionName": "Hide", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_hide_glob", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "glob", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "hideGlob", + "cppFunctionName": "HideGlob", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_hide_head", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "hideHead", + "cppFunctionName": "HideHead", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_push_ref", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "pushRef", + "cppFunctionName": "PushRef", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_hide_ref", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "hideRef", + "cppFunctionName": "HideRef", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_next", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "next", + "cppFunctionName": "Next", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_sorting", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "sort_mode", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "sorting", + "cppFunctionName": "Sorting", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_revwalk_push_range", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + }, + { + "name": "range", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "pushRange", + "cppFunctionName": "PushRange", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_free", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_revwalk_repository", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "Revwalk", + "jsClassName": "Revwalk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "repository", + "cppFunctionName": "Repository", + "return": { + "cType": "git_repository *", + "cppClassName": "Repository", + "isErrorCode": false + } + } + ] + }, + { + "filename": "signature.h", + "jsClassName": "Signature", + "cppClassName": "Signature", + "cType": "git_signature", + "freeFunctionName": "git_signature_free", + "functions": [ + { + "cFunctionName": "git_signature_new", + "args": [ + { + "name": "out", + "cType": "git_signature **", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "email", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "time", + "cType": "git_time_t", + "cppClassName": "TimeT", + "jsClassName": "TimeT" + }, + { + "name": "offset", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_signature_now", + "args": [ + { + "name": "out", + "cType": "git_signature **", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "email", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "now", + "cppFunctionName": "Now", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_signature_dup", + "args": [ + { + "name": "sig", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "dup", + "cppFunctionName": "Dup", + "return": { + "cType": "git_signature *", + "cppClassName": "Signature", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_signature_free", + "args": [ + { + "name": "sig", + "cType": "git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "stash.h", + "jsClassName": "Stash", + "cppClassName": "Stash", + "cType": "git_stash", + "freeFunctionName": "git_stash_free", + "functions": [ + { + "cFunctionName": "git_stash_save", + "args": [ + { + "name": "out", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "stasher", + "cType": "git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "flags", + "cType": "unsigned int", + "cppClassName": "unsigned", + "jsClassName": "unsigned" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "save", + "cppFunctionName": "Save", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_stash_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "git_stash_cb", + "cppClassName": "StashCb", + "jsClassName": "StashCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_stash_drop", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "index", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "drop", + "cppFunctionName": "Drop", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "status.h", + "jsClassName": "Status", + "cppClassName": "Status", + "cType": "git_status", + "freeFunctionName": "git_status_free", + "functions": [ + { + "cFunctionName": "git_status_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "git_status_cb", + "cppClassName": "StatusCb", + "jsClassName": "StatusCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_status_foreach_ext", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "opts", + "cType": "const git_status_options *", + "cppClassName": "StatusOptions", + "jsClassName": "StatusOptions" + }, + { + "name": "callback", + "cType": "git_status_cb", + "cppClassName": "StatusCb", + "jsClassName": "StatusCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreachExt", + "cppFunctionName": "ForeachExt", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_status_file", + "args": [ + { + "name": "status_flags", + "cType": "unsigned int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "file", + "cppFunctionName": "File", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_status_should_ignore", + "args": [ + { + "name": "ignored", + "cType": "int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "shouldIgnore", + "cppFunctionName": "ShouldIgnore", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "stdint.h", + "jsClassName": "Stdint", + "cppClassName": "Stdint", + "cType": "git_stdint", + "freeFunctionName": "git_stdint_free", + "functions": [] + }, + { + "filename": "strarray.h", + "jsClassName": "Strarray", + "cppClassName": "Strarray", + "cType": "git_strarray", + "freeFunctionName": "git_strarray_free", + "functions": [ + { + "cFunctionName": "git_strarray_free", + "args": [ + { + "name": "array", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_strarray_copy", + "args": [ + { + "name": "tgt", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + }, + { + "name": "src", + "cType": "const git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "copy", + "cppFunctionName": "Copy", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "submodule.h", + "jsClassName": "Submodule", + "cppClassName": "Submodule", + "cType": "git_submodule", + "freeFunctionName": "git_submodule_free", + "functions": [ + { + "cFunctionName": "git_submodule_lookup", + "args": [ + { + "name": "submodule", + "cType": "git_submodule **", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "int (*)(git_submodule *sm, const char *name, void *payload)", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_add_setup", + "args": [ + { + "name": "submodule", + "cType": "git_submodule **", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "use_gitlink", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "addSetup", + "cppFunctionName": "AddSetup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_add_finalize", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addFinalize", + "cppFunctionName": "AddFinalize", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_add_to_index", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "write_index", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "addToIndex", + "cppFunctionName": "AddToIndex", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_save", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "save", + "cppFunctionName": "Save", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_owner", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "Repository", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_name", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_path", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "path", + "cppFunctionName": "Path", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_url", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "url", + "cppFunctionName": "Url", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_set_url", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setUrl", + "cppFunctionName": "SetUrl", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_index_id", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "indexId", + "cppFunctionName": "IndexId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_head_id", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "headId", + "cppFunctionName": "HeadId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_wd_id", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "wdId", + "cppFunctionName": "WdId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_ignore", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "ignore", + "cppFunctionName": "Ignore", + "return": { + "cType": "GIT_EXTERN(", + "cppClassName": "GIT_EXTERN(", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_set_ignore", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "ignore", + "cType": "git_submodule_ignore_t", + "cppClassName": "SubmoduleIgnoreT", + "jsClassName": "SubmoduleIgnoreT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setIgnore", + "cppFunctionName": "SetIgnore", + "return": { + "cType": "git_submodule_ignore_t", + "cppClassName": "SubmoduleIgnoreT", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_update", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "update", + "cppFunctionName": "Update", + "return": { + "cType": "GIT_EXTERN(", + "cppClassName": "GIT_EXTERN(", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_set_update", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "update", + "cType": "git_submodule_update_t", + "cppClassName": "SubmoduleUpdateT", + "jsClassName": "SubmoduleUpdateT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setUpdate", + "cppFunctionName": "SetUpdate", + "return": { + "cType": "git_submodule_update_t", + "cppClassName": "SubmoduleUpdateT", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_submodule_fetch_recurse_submodules", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "fetchRecurseSubmodules", + "cppFunctionName": "FetchRecurseSubmodules", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_set_fetch_recurse_submodules", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "fetch_recurse_submodules", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "setFetchRecurseSubmodules", + "cppFunctionName": "SetFetchRecurseSubmodules", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_init", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + }, + { + "name": "overwrite", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "init", + "cppFunctionName": "Init", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_sync", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "sync", + "cppFunctionName": "Sync", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_open", + "args": [ + { + "name": "repo", + "cType": "git_repository **", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_reload", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "reload", + "cppFunctionName": "Reload", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_reload_all", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "reloadAll", + "cppFunctionName": "ReloadAll", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_status", + "args": [ + { + "name": "status", + "cType": "unsigned int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "status", + "cppFunctionName": "Status", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_location", + "args": [ + { + "name": "location_status", + "cType": "unsigned int *", + "cppClassName": "int", + "jsClassName": "int" + }, + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "Submodule", + "jsClassName": "Submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "location", + "cppFunctionName": "Location", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "tag.h", + "jsClassName": "Tag", + "cppClassName": "Tag", + "cType": "git_tag", + "freeFunctionName": "git_tag_free", + "functions": [ + { + "cFunctionName": "git_tag_lookup", + "args": [ + { + "name": "out", + "cType": "git_tag **", + "cppClassName": "Tag", + "jsClassName": "Tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_lookup_prefix", + "args": [ + { + "name": "out", + "cType": "git_tag **", + "cppClassName": "Tag", + "jsClassName": "Tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookupPrefix", + "cppFunctionName": "LookupPrefix", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_free", + "args": [ + { + "name": "tag", + "cType": "git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_id", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "id", + "cppFunctionName": "Id", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_target", + "args": [ + { + "name": "target_out", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "target", + "cppFunctionName": "Target", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_target_id", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "targetId", + "cppFunctionName": "TargetId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_target_type", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "targetType", + "cppFunctionName": "TargetType", + "return": { + "cType": "git_otype", + "cppClassName": "Otype", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_name", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_tagger", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "tagger", + "cppFunctionName": "Tagger", + "return": { + "cType": "const git_signature *", + "cppClassName": "Signature", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_message", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "message", + "cppFunctionName": "Message", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tag_create", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "tagger", + "cType": "const git_signature *", + "cppClassName": "Signature", + "jsClassName": "Signature" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_create_frombuffer", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "buffer", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createFrombuffer", + "cppFunctionName": "CreateFrombuffer", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_create_lightweight", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const git_object *", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "int", + "jsClassName": "int" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "createLightweight", + "cppFunctionName": "CreateLightweight", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_delete", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_list", + "args": [ + { + "name": "tag_names", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "list", + "cppFunctionName": "List", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_list_match", + "args": [ + { + "name": "tag_names", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray" + }, + { + "name": "pattern", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "listMatch", + "cppFunctionName": "ListMatch", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "git_tag_foreach_cb", + "cppClassName": "TagForeachCb", + "jsClassName": "TagForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_peel", + "args": [ + { + "name": "tag_target_out", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "Tag", + "jsClassName": "Tag" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "peel", + "cppFunctionName": "Peel", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "threads.h", + "jsClassName": "Threads", + "cppClassName": "Threads", + "cType": "git_threads", + "freeFunctionName": "git_threads_free", + "functions": [ + { + "cFunctionName": "git_threads_init", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "init", + "cppFunctionName": "Init", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_threads_shutdown", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "shutdown", + "cppFunctionName": "Shutdown", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + } + ] + }, + { + "filename": "trace.h", + "jsClassName": "Trace", + "cppClassName": "Trace", + "cType": "git_trace", + "freeFunctionName": "git_trace_free", + "functions": [ + { + "cFunctionName": "git_trace_set", + "args": [ + { + "name": "level", + "cType": "git_trace_level_t", + "cppClassName": "TraceLevelT", + "jsClassName": "TraceLevelT" + }, + { + "name": "cb", + "cType": "git_trace_callback", + "cppClassName": "TraceCallback", + "jsClassName": "TraceCallback" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "set", + "cppFunctionName": "Set", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "transport.h", + "jsClassName": "Transport", + "cppClassName": "Transport", + "cType": "git_transport", + "freeFunctionName": "git_transport_free", + "functions": [ + { + "cFunctionName": "git_cred_userpass_plaintext_new", + "args": [ + { + "name": "out", + "cType": "git_cred **", + "cppClassName": "Cred", + "jsClassName": "Cred" + }, + { + "name": "username", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "password", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitCredUserpassPlaintextNew", + "cppFunctionName": "GitCredUserpassPlaintextNew", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_transport_new", + "args": [ + { + "name": "out", + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_transport_dummy", + "args": [ + { + "name": "out", + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "dummy", + "cppFunctionName": "Dummy", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_transport_local", + "args": [ + { + "name": "out", + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "local", + "cppFunctionName": "Local", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_transport_smart", + "args": [ + { + "name": "out", + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "Remote", + "jsClassName": "Remote" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "smart", + "cppFunctionName": "Smart", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_smart_subtransport_http", + "args": [ + { + "name": "out", + "cType": "git_smart_subtransport **", + "cppClassName": "SmartSubtransport", + "jsClassName": "SmartSubtransport" + }, + { + "name": "owner", + "cType": "git_transport*", + "cppClassName": "Transport*", + "jsClassName": "Transport*" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitSmartSubtransportHttp", + "cppFunctionName": "GitSmartSubtransportHttp", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_smart_subtransport_git", + "args": [ + { + "name": "out", + "cType": "git_smart_subtransport **", + "cppClassName": "SmartSubtransport", + "jsClassName": "SmartSubtransport" + }, + { + "name": "owner", + "cType": "git_transport*", + "cppClassName": "Transport*", + "jsClassName": "Transport*" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitSmartSubtransportGit", + "cppFunctionName": "GitSmartSubtransportGit", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + }, + { + "filename": "tree.h", + "jsClassName": "Tree", + "cppClassName": "Tree", + "cType": "git_tree", + "freeFunctionName": "git_tree_free", + "functions": [ + { + "cFunctionName": "git_tree_lookup", + "args": [ + { + "name": "out", + "cType": "git_tree **", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_lookup_prefix", + "args": [ + { + "name": "out", + "cType": "git_tree **", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "lookupPrefix", + "cppFunctionName": "LookupPrefix", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_free", + "args": [ + { + "name": "tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_id", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "id", + "cppFunctionName": "Id", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_owner", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "Repository", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entrycount", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entrycount", + "cppFunctionName": "Entrycount", + "return": { + "cType": "size_t", + "cppClassName": "size_t", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_byname", + "args": [ + { + "name": "tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entryByname", + "cppFunctionName": "EntryByname", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_byindex", + "args": [ + { + "name": "tree", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "size_t", + "jsClassName": "size_t" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entryByindex", + "cppFunctionName": "EntryByindex", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_byoid", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "entryByoid", + "cppFunctionName": "EntryByoid", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_bypath", + "args": [ + { + "name": "out", + "cType": "git_tree_entry **", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + }, + { + "name": "root", + "cType": "git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryBypath", + "cppFunctionName": "EntryBypath", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_entry_dup", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryDup", + "cppFunctionName": "EntryDup", + "return": { + "cType": "git_tree_entry *", + "cppClassName": "TreeEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_free", + "args": [ + { + "name": "entry", + "cType": "git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "entryFree", + "cppFunctionName": "EntryFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_name", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryName", + "cppFunctionName": "EntryName", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_id", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryId", + "cppFunctionName": "EntryId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_type", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryType", + "cppFunctionName": "EntryType", + "return": { + "cType": "git_otype", + "cppClassName": "Otype", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_filemode", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryFilemode", + "cppFunctionName": "EntryFilemode", + "return": { + "cType": "git_filemode_t", + "cppClassName": "FilemodeT", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_cmp", + "args": [ + { + "name": "e1", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + }, + { + "name": "e2", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryCmp", + "cppFunctionName": "EntryCmp", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_entry_to_object", + "args": [ + { + "name": "object_out", + "cType": "git_object **", + "cppClassName": "Object", + "jsClassName": "Object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "entryToObject", + "cppFunctionName": "EntryToObject", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_treebuilder_create", + "args": [ + { + "name": "out", + "cType": "git_treebuilder **", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + }, + { + "name": "source", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderCreate", + "cppFunctionName": "GitTreebuilderCreate", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_treebuilder_clear", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderClear", + "cppFunctionName": "GitTreebuilderClear", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_treebuilder_entrycount", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderEntrycount", + "cppFunctionName": "GitTreebuilderEntrycount", + "return": { + "cType": "unsigned int", + "cppClassName": "unsigned", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_treebuilder_free", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitTreebuilderFree", + "cppFunctionName": "GitTreebuilderFree", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_treebuilder_get", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderGet", + "cppFunctionName": "GitTreebuilderGet", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_treebuilder_insert", + "args": [ + { + "name": "out", + "cType": "const git_tree_entry **", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + }, + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "filemode", + "cType": "git_filemode_t", + "cppClassName": "FilemodeT", + "jsClassName": "FilemodeT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderInsert", + "cppFunctionName": "GitTreebuilderInsert", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_treebuilder_remove", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderRemove", + "cppFunctionName": "GitTreebuilderRemove", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_treebuilder_filter", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + }, + { + "name": "filter", + "cType": "git_treebuilder_filter_cb", + "cppClassName": "TreebuilderFilterCb", + "jsClassName": "TreebuilderFilterCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderFilter", + "cppFunctionName": "GitTreebuilderFilter", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_treebuilder_write", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "Repository", + "jsClassName": "Repository" + }, + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "Treebuilder", + "jsClassName": "Treebuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": false, + "jsFunctionName": "gitTreebuilderWrite", + "cppFunctionName": "GitTreebuilderWrite", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_walk", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "Tree", + "jsClassName": "Tree" + }, + { + "name": "mode", + "cType": "git_treewalk_mode", + "cppClassName": "TreewalkMode", + "jsClassName": "TreewalkMode" + }, + { + "name": "callback", + "cType": "git_treewalk_cb", + "cppClassName": "TreewalkCb", + "jsClassName": "TreewalkCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": false, + "jsFunctionName": "walk", + "cppFunctionName": "Walk", + "return": { + "cType": "int", + "cppClassName": "int", + "isErrorCode": true + } + } + ] + } +] From 42c7fa76e467d1f1dd5a541d14759ddc931f6d8d Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Thu, 20 Jun 2013 18:39:56 +0200 Subject: [PATCH 02/28] Blob is now code-gen'd --- binding.gyp | 1 + gen.js | 10 +- include/blob.h | 111 +++++-------- include/oid.h | 2 +- include/wrapper.h | 31 ++++ lib/blob.js | 29 +--- lib/tree_entry.js | 7 +- src/base.cc | 5 + src/blob.cc | 370 +++++++++++++++++++++++------------------ src/commit.cc | 2 +- src/diff_list.cc | 4 +- src/oid.cc | 11 +- src/revwalk.cc | 2 +- src/tree.cc | 2 +- src/tree_entry.cc | 9 +- src/wrapper.cc | 72 ++++++++ templates/class.cc.ejs | 122 ++++++++++---- templates/header.h.ejs | 22 ++- test/npm-debug.log | 4 +- test/raw-blob.js | 58 +++---- v0.18.0.json | 318 ++++++++++++++++++----------------- 21 files changed, 673 insertions(+), 519 deletions(-) create mode 100644 include/wrapper.h create mode 100644 src/wrapper.cc diff --git a/binding.gyp b/binding.gyp index b683da9ea..e87a7f1d5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -16,6 +16,7 @@ 'src/tree_entry.cc', 'src/diff_list.cc', 'src/threads.cc', + 'src/wrapper.cc', 'src/functions/string.cc', 'src/functions/utilities.cc' ], diff --git a/gen.js b/gen.js index a075782ea..5ce919b19 100644 --- a/gen.js +++ b/gen.js @@ -8,8 +8,10 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (idef.jsClassName != "Oid") continue; - - fs.writeFileSync(path.resolve("./include/" + idef.filename), headerTemplate(idef)); - fs.writeFileSync(path.resolve("./src/" + path.basename(idef.filename, '.h') + '.cc'), classTemplate(idef)); + if (["Oid", "Blob"].indexOf(idef.jsClassName) > -1) { + fs.writeFileSync( + path.resolve("./include/" + idef.filename), headerTemplate(idef)); + fs.writeFileSync( + path.resolve("./src/" + path.basename(idef.filename, '.h') + '.cc'), classTemplate(idef)); + } } diff --git a/include/blob.h b/include/blob.h index f857d23e1..9628f5fd2 100755 --- a/include/blob.h +++ b/include/blob.h @@ -1,112 +1,75 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef BLOB_H -#define BLOB_H +#ifndef GITBLOB_H +#define GITBLOB_H #include #include -#include +#include #include "git2.h" -#include "repo.h" -#include "oid.h" - -using namespace v8; using namespace node; +using namespace v8; -/** - * Wrapper for libgit2 git_blob. - */ class GitBlob : public ObjectWrap { public: static Persistent constructor_template; + static void Initialize (Handle target); - static void Initialize(Handle target); - - git_blob* GetValue(); - void SetValue(git_blob* blob); + git_blob *GetValue(); - protected: - GitBlob() {}; - ~GitBlob() {}; + private: + GitBlob(git_blob *raw); + ~GitBlob(); static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); static Handle Lookup(const Arguments& args); static void LookupWork(uv_work_t* req); static void LookupAfterWork(uv_work_t* req); - static Handle RawContent(const Arguments& args); - static void RawContentWork(uv_work_t* req); - static void RawContentAfterWork(uv_work_t* req); - + struct LookupBaton { + uv_work_t request; + const git_error* error; + git_blob *out; + git_repository * repo; + const git_oid * id; + Persistent callback; + }; + static Handle Oid(const Arguments& args); + static Handle Content(const Arguments& args); + static Handle Size(const Arguments& args); static Handle CreateFromFile(const Arguments& args); static void CreateFromFileWork(uv_work_t* req); static void CreateFromFileAfterWork(uv_work_t* req); + struct CreateFromFileBaton { + uv_work_t request; + const git_error* error; + git_oid * id; + git_repository * repo; + const char * path; + Persistent callback; + }; static Handle CreateFromBuffer(const Arguments& args); static void CreateFromBufferWork(uv_work_t* req); static void CreateFromBufferAfterWork(uv_work_t* req); - private: - - git_blob* blob; - - struct LookupBaton { + struct CreateFromBufferBaton { uv_work_t request; const git_error* error; - - GitBlob* blob; - git_blob* rawBlob; - git_repository* rawRepo; - git_oid rawOid; - + git_oid * oid; + git_repository * repo; + const void * buffer; + size_t len; Persistent callback; }; - - struct RawContentBaton { - uv_work_t request; - - GitBlob* blob; - git_blob* rawBlob; - std::string rawContent; - int rawSize; - - Persistent callback; - }; - - struct CreateFromFileBaton { - uv_work_t request; - const git_error* error; - - GitBlob* blob; - git_blob* rawBlob; - git_repository* rawRepo; - std::string path; - - Persistent callback; - }; - - struct CreateFromBufferBaton { - uv_work_t request; - const git_error* error; - - GitBlob* blob; - git_blob* rawBlob; - git_repository* rawRepo; - const void* data; - size_t dataLength; - - Persistent callback; - }; + static Handle IsBinary(const Arguments& args); + git_blob *raw; }; #endif diff --git a/include/oid.h b/include/oid.h index cbd24e077..d4ca3d848 100755 --- a/include/oid.h +++ b/include/oid.h @@ -20,7 +20,7 @@ class GitOid : public ObjectWrap { static Persistent constructor_template; static void Initialize (Handle target); - git_oid GetValue(); + git_oid *GetValue(); private: GitOid(git_oid *raw); diff --git a/include/wrapper.h b/include/wrapper.h new file mode 100644 index 000000000..060699913 --- /dev/null +++ b/include/wrapper.h @@ -0,0 +1,31 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef WRAPPER_H +#define WRAPPER_H + +#include +#include + +using namespace node; +using namespace v8; + +class Wrapper : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + void *GetValue(); + + private: + Wrapper(void *raw); + + static Handle New(const Arguments& args); + static Handle ToBuffer(const Arguments& args); + + void *raw; +}; + +#endif diff --git a/lib/blob.js b/lib/blob.js index c3d368008..2dc8f3dbb 100644 --- a/lib/blob.js +++ b/lib/blob.js @@ -45,38 +45,17 @@ Blob.prototype.lookup = function(oid, callback) { /** * Retrieve the blob's raw content buffer. - * - * @param {Blob~rawContentCallback} callback */ -Blob.prototype.rawContent = function(callback) { - /** - * @callback Blob~rawContentCallback Callback executed after raw content is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Buffer|null} content The raw content of the blob or null. - */ - this.rawBlob.rawContent(function(error, content) { - if (success(error, callback)) { - callback(null, content); - } - }); +Blob.prototype.rawContent = function() { + return this.rawBlob.content().toBuffer(this.rawBlob.size()); }; /** * Retrieve the blob's content. - * - * @param {Blob~contentCallback} callback */ Blob.prototype.content = function(callback) { - /** - * @callback Blob~contentCallback Callback executed after content is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} content The content of the blob or null. - */ - this.rawContent(function(error, content) { - if (success(error, callback)) { - callback(null, content.toString()); - } - }); + var content = this.rawContent(); + return content.toString(); }; /** diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 5464b19c7..1bd23f2e7 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -208,11 +208,8 @@ TreeEntry.prototype.content = function(callback) { if (!success(error, callback)) { return; } - blob.content(function blobContent(error, content) { - if (success(error, callback)) { - callback(null, content); - } - }); + var content = blob.content(); + callback(null, content); }); }; diff --git a/src/base.cc b/src/base.cc index f1f01c726..0b1274a1b 100755 --- a/src/base.cc +++ b/src/base.cc @@ -10,6 +10,7 @@ #include "git2.h" +#include "../include/wrapper.h" #include "../include/reference.h" #include "../include/signature.h" #include "../include/error.h" @@ -24,6 +25,10 @@ #include "../include/threads.h" extern "C" void init(Handle target) { + HandleScope scope; + + Wrapper::Initialize(target); + GitError::Initialize(target); GitReference::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index 391e7534d..5365f5491 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -1,25 +1,34 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#include + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include #include "git2.h" -#include "../include/utils.h" -#include "../include/repo.h" #include "../include/blob.h" -#include "../include/functions/string.h" +#include "../include/repo.h" +#include "../include/oid.h" +#include "../include/wrapper.h" +#include "node_buffer.h" + #include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -void GitBlob::Initialize (Handle target) { +GitBlob::GitBlob(git_blob *raw) { + this->raw = raw; +} + +GitBlob::~GitBlob() { + git_blob_free(this->raw); +} + +void GitBlob::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -27,264 +36,305 @@ void GitBlob::Initialize (Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Blob")); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); - NODE_SET_PROTOTYPE_METHOD(tpl, "rawContent", RawContent); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - NODE_SET_PROTOTYPE_METHOD(tpl, "createFromFile", CreateFromFile); - NODE_SET_PROTOTYPE_METHOD(tpl, "createFromBuffer", CreateFromBuffer); + NODE_SET_METHOD(tpl, "lookup", Lookup); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "content", Content); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_METHOD(tpl, "createFromFile", CreateFromFile); + NODE_SET_METHOD(tpl, "createFromBuffer", CreateFromBuffer); + NODE_SET_PROTOTYPE_METHOD(tpl, "isBinary", IsBinary); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Blob"), constructor_template); } -git_blob* GitBlob::GetValue() { - return this->blob; -} -void GitBlob::SetValue(git_blob* blob) { - this->blob = blob; -} - Handle GitBlob::New(const Arguments& args) { HandleScope scope; - GitBlob* blob = new GitBlob(); - blob->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_blob is required."))); + } - return scope.Close( args.This() ); -} -Handle GitBlob::Free(const Arguments& args) { - HandleScope scope; + GitBlob* object = new GitBlob((git_blob *) External::Unwrap(args[0])); + object->Wrap(args.This()); - GitBlob* blob = ObjectWrap::Unwrap(args.This()); - git_blob_free(blob->blob); + return scope.Close(args.This()); +} - return scope.Close( Undefined() ); +git_blob *GitBlob::GetValue() { + return this->raw; } + Handle GitBlob::Lookup(const Arguments& args) { HandleScope scope; if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); + return ThrowException(Exception::Error(String::New("Repository is required."))); } - if(args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object."))); + return ThrowException(Exception::Error(String::New("Oid is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } LookupBaton* baton = new LookupBaton; + baton->error = NULL; baton->request.data = baton; - baton->blob = ObjectWrap::Unwrap(args.This()); - baton->blob->Ref(); - baton->rawBlob = baton->blob->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->rawOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); return Undefined(); } -void GitBlob::LookupWork(uv_work_t* req) { - LookupBaton* baton = static_cast(req->data); - int returnCode = git_blob_lookup(&baton->rawBlob, baton->rawRepo, &baton->rawOid); - if (returnCode != GIT_OK) { + +void GitBlob::LookupWork(uv_work_t *req) { + LookupBaton *baton = static_cast(req->data); + int result = git_blob_lookup( + &baton->out, + baton->repo, + baton->id + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitBlob::LookupAfterWork(uv_work_t* req) { + +void GitBlob::LookupAfterWork(uv_work_t *req) { HandleScope scope; - LookupBaton* baton = static_cast(req->data); + LookupBaton *baton = static_cast(req->data); + TryCatch try_catch; if (success(baton->error, baton->callback)) { - baton->blob->SetValue(baton->rawBlob); - - Handle argv[2] = { + Handle argv[1] = { External::New(baton->out) }; + Handle object = constructor_template->NewInstance(1, argv); + Handle argv2[2] = { Local::New(Null()), - baton->blob->handle_ + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[2] = { + Exception::Error(String::New(baton->error->message)), + Local::New(Null()) }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + + baton->callback.Dispose(); + delete baton; } -Handle GitBlob::RawContent(const Arguments& args) { +Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - RawContentBaton* baton = new RawContentBaton; - baton->request.data = baton; - baton->rawBlob = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - uv_queue_work(uv_default_loop(), &baton->request, RawContentWork, (uv_after_work_cb)RawContentAfterWork); + const git_oid * result = git_blob_id( + in + ); - return Undefined(); + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } -void GitBlob::RawContentWork(uv_work_t* req) { - RawContentBaton* baton = static_cast(req->data); - baton->rawContent = (const char *)const_cast(git_blob_rawcontent(baton->rawBlob)); - baton->rawSize = git_blob_rawsize(baton->rawBlob); +Handle GitBlob::Content(const Arguments& args) { + HandleScope scope; + + + git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); + + const void * result = git_blob_rawcontent( + in + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); } -void GitBlob::RawContentAfterWork(uv_work_t* req) { + +Handle GitBlob::Size(const Arguments& args) { HandleScope scope; - RawContentBaton* baton = static_cast(req->data); - Local fastBuffer; - Buffer* buffer = Buffer::New(const_cast(baton->rawContent.c_str()), baton->rawSize); - MAKE_FAST_BUFFER(buffer, fastBuffer); - Handle argv[2] = { - Local::New(Null()), - fastBuffer - }; + git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + git_off_t result = git_blob_rawsize( + in + ); + + return scope.Close(Number::New(result)); } Handle GitBlob::CreateFromFile(const Arguments& args) { HandleScope scope; if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); + return ThrowException(Exception::Error(String::New("Oid is required."))); } - - if(args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("Path is required and must be an String."))); + if(args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be an Function."))); + if(args.Length() == 2 || !args[2]->IsString()) { + return ThrowException(Exception::Error(String::New("String is required."))); + } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateFromFileBaton* baton = new CreateFromFileBaton; - baton->request.data = baton; baton->error = NULL; - baton->blob = ObjectWrap::Unwrap(args.This()); - baton->blob->Ref(); - baton->rawBlob = baton->blob->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->path = stringArgToString(args[1]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; + baton->id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + + baton->path = stringArgToString(args[2]->ToString()).c_str(); + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); return Undefined(); } -void GitBlob::CreateFromFileWork(uv_work_t* req) { - CreateFromFileBaton* baton = static_cast(req->data); - git_oid* rawOid = NULL; - int returnCode = git_blob_create_fromdisk(rawOid, baton->rawRepo, baton->path.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - - returnCode = git_blob_lookup(&baton->rawBlob, baton->rawRepo, rawOid); - if (returnCode != GIT_OK) { +void GitBlob::CreateFromFileWork(uv_work_t *req) { + CreateFromFileBaton *baton = static_cast(req->data); + int result = git_blob_create_fromdisk( + baton->id, + baton->repo, + baton->path + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitBlob::CreateFromFileAfterWork(uv_work_t* req) { - HandleScope scope; - CreateFromFileBaton* baton = static_cast(req->data); - - baton->blob->SetValue(baton->rawBlob); - Handle argv[2] = { - Local::New(Null()), - baton->blob->handle_ - }; +void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { + HandleScope scope; + CreateFromFileBaton *baton = static_cast(req->data); TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + if (success(baton->error, baton->callback)) { + Handle argv[1] = { External::New(baton->id) }; + Handle object = GitOid::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[2] = { + Exception::Error(String::New(baton->error->message)), + Local::New(Null()) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } + if (try_catch.HasCaught()) { node::FatalException(try_catch); } - delete req; + + baton->callback.Dispose(); + delete baton; } Handle GitBlob::CreateFromBuffer(const Arguments& args) { HandleScope scope; if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); + return ThrowException(Exception::Error(String::New("Oid is required."))); } - - if(args.Length() == 1 || !Buffer::HasInstance(args[1])) { - return ThrowException(Exception::Error(String::New("Buffer is required and must be an Buffer."))); + if(args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be an Function."))); + if(args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Buffer is required."))); + } + if(args.Length() == 3 || !args[3]->IsNumber()) { + return ThrowException(Exception::Error(String::New("Number is required."))); + } + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateFromBufferBaton* baton = new CreateFromBufferBaton; - baton->request.data = baton; baton->error = NULL; - baton->blob = ObjectWrap::Unwrap(args.This()); - baton->blob->Ref(); - baton->rawBlob = baton->blob->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - Local buffer = args[1]->ToObject(); - baton->data = Buffer::Data(buffer); - baton->dataLength = Buffer::Length(buffer); - baton->callback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; + baton->oid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[2]->ToObject())); + baton->len = ObjectWrap::Unwrap(args[3]->ToObject())->Value(); + baton->callback = Persistent::New(Local::Cast(args[4])); - uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, CreateFromBufferWork, (uv_after_work_cb)CreateFromBufferAfterWork); return Undefined(); } -void GitBlob::CreateFromBufferWork(uv_work_t* req) { - CreateFromBufferBaton* baton = static_cast(req->data); - git_oid* rawOid = NULL; - int returnCode = git_blob_create_frombuffer(rawOid, baton->rawRepo, baton->data, baton->dataLength); - if (returnCode != GIT_OK) { +void GitBlob::CreateFromBufferWork(uv_work_t *req) { + CreateFromBufferBaton *baton = static_cast(req->data); + int result = git_blob_create_frombuffer( + baton->oid, + baton->repo, + baton->buffer, + baton->len + ); + if (result != GIT_OK) { baton->error = giterr_last(); } +} - returnCode = git_blob_lookup(&baton->rawBlob, baton->rawRepo, rawOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); +void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { + HandleScope scope; + CreateFromBufferBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (success(baton->error, baton->callback)) { + Handle argv[1] = { External::New(baton->oid) }; + Handle object = GitOid::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[2] = { + Exception::Error(String::New(baton->error->message)), + Local::New(Null()) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } + + baton->callback.Dispose(); + delete baton; } -void GitBlob::CreateFromBufferAfterWork(uv_work_t* req) { + +Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; - CreateFromBufferBaton* baton = static_cast(req->data); - baton->blob->SetValue(baton->rawBlob); - Handle argv[2] = { - Local::New(Null()), - baton->blob->handle_ - }; + git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + int result = git_blob_is_binary( + in + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } - delete req; + return scope.Close(Boolean::New(result)); } Persistent GitBlob::constructor_template; diff --git a/src/commit.cc b/src/commit.cc index 7dc55d57a..7f9820da7 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -100,7 +100,7 @@ Handle GitCommit::Lookup(const Arguments& args) { baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); if (args[1]->IsObject()) { - baton->rawOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->rawOid = *ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); } else { baton->sha = stringArgToString(args[1]->ToString()); } diff --git a/src/diff_list.cc b/src/diff_list.cc index 1204f6399..018b9ff5c 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -152,13 +152,13 @@ Handle GitDiffList::TreeToTree(const Arguments& args) { baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); if (args[1]->IsObject()) { - baton->oldOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->oldOid = *ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); } else { baton->oldSha = stringArgToString(args[1]->ToString()); } if (args[2]->IsObject()) { - baton->newOid = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->newOid = *ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); } else { baton->newSha = stringArgToString(args[2]->ToString()); } diff --git a/src/oid.cc b/src/oid.cc index e382b6139..7c660e910 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -9,6 +9,7 @@ #include "../include/oid.h" + #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -51,8 +52,8 @@ Handle GitOid::New(const Arguments& args) { return scope.Close(args.This()); } -git_oid GitOid::GetValue() { - return *this->raw; +git_oid *GitOid::GetValue() { + return this->raw; } @@ -74,7 +75,7 @@ Handle GitOid::FromString(const Arguments& args) { if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } - Handle argv[1] = { External::New(out) }; + Handle argv[1] = { External::New((void *)out) }; return scope.Close(constructor_template->NewInstance(1, argv)); } @@ -82,10 +83,10 @@ Handle GitOid::Sha(const Arguments& args) { HandleScope scope; - git_oid in = ObjectWrap::Unwrap(args.This())->GetValue(); + git_oid *in = ObjectWrap::Unwrap(args.This())->GetValue(); char * result = git_oid_allocfmt( - &in + in ); return scope.Close(String::New(result)); diff --git a/src/revwalk.cc b/src/revwalk.cc index 0252d31b9..e53c408f4 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -162,7 +162,7 @@ Handle GitRevWalk::Push(const Arguments& args) { baton->request.data = baton; baton->error = NULL; baton->rawRevwalk = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawOid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->rawOid = *ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); diff --git a/src/tree.cc b/src/tree.cc index 915164e36..7211ddcd5 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -77,7 +77,7 @@ Handle GitTree::Lookup(const Arguments& args) { baton->request.data = baton; baton->error = NULL; baton->rawTree = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawOid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->rawOid = *ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->rawRepo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 4ba4fb84d..ff3d39e82 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -257,17 +257,16 @@ void GitTreeEntry::ToBlobAfterWork(uv_work_t *req) { ToBlobBaton* baton = static_cast(req->data); if (success(baton->error, baton->callback)) { - Handle blob = GitBlob::constructor_template->NewInstance(); - GitBlob *blobInstance = ObjectWrap::Unwrap(blob); - blobInstance->SetValue(baton->rawBlob); + Handle argv[1] = { External::New(baton->rawBlob) }; + Handle blob = GitBlob::constructor_template->NewInstance(1, argv); - Handle argv[2] = { + Handle argv2[2] = { Local::New(Null()), blob }; TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); if (try_catch.HasCaught()) { node::FatalException(try_catch); } diff --git a/src/wrapper.cc b/src/wrapper.cc new file mode 100644 index 000000000..1d3e602f9 --- /dev/null +++ b/src/wrapper.cc @@ -0,0 +1,72 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "../include/wrapper.h" +#include "node_buffer.h" + +using namespace v8; +using namespace node; + +Wrapper::Wrapper(void *raw) { + this->raw = raw; +} + +void Wrapper::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Wrapper")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "toBuffer", ToBuffer); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Wrapper"), constructor_template); +} + +Handle Wrapper::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("void * is required."))); + } + + Wrapper* object = new Wrapper(External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +void *Wrapper::GetValue() { + return this->raw; +} + +Handle Wrapper::ToBuffer(const Arguments& args) { + HandleScope scope; + + if(args.Length() == 0 || !args[0]->IsNumber()) { + return ThrowException(Exception::Error(String::New("Number is required."))); + } + + int len = args[0]->ToNumber()->Value(); + + Buffer *slowBuffer = Buffer::New( + const_cast(std::string((const char *)const_cast(ObjectWrap::Unwrap(args.This())->GetValue())).c_str()), + len); + + Local bufferConstructor = Local::Cast( + Context::GetCurrent()->Global()->Get(String::New("Buffer"))); + + Handle constructorArgs[3] = { slowBuffer->handle_, Integer::New(len), Integer::New(0) }; + Local fastBuffer = bufferConstructor->NewInstance(3, constructorArgs); + + return scope.Close(fastBuffer); +} + + +Persistent Wrapper::constructor_template; diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 0ba7eb19d..4292c9b53 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -1,3 +1,15 @@ +<% + function isPrimitive(cppClassName) { + return ["Boolean", "Number", "String"].indexOf(cppClassName) > -1; + } + + function jsClassName2v8ValueClassName(cppClassName) { + if (isPrimitive(cppClassName)) + return cppClassName; + else + return 'Object'; + } +-%> /** * This code is auto-generated; unless you know what you're doing, do not modify! **/ @@ -9,6 +21,10 @@ #include "../include/<%= filename %>" +<% for (d in dependencies) { -%> +#include "<%- dependencies[d] %>" +<% } -%> + #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -36,10 +52,10 @@ void <%- cppClassName %>::Initialize(Handle target) { var functionInfo = functions[i]; if (functionInfo.ignore) continue; -%> -<% if (functionInfo.isConstructorMethod) { -%> - NODE_SET_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); -<% } else if (functionInfo.isPrototypeMethod) { -%> +<% if (functionInfo.isPrototypeMethod) { -%> NODE_SET_PROTOTYPE_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); +<% } else { -%> + NODE_SET_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); <% } -%> <% } -%> @@ -60,8 +76,8 @@ Handle <%- cppClassName %>::New(const Arguments& args) { return scope.Close(args.This()); } -<%- cType %> <%- cppClassName %>::GetValue() { - return *this->raw; +<%- cType %> *<%- cppClassName %>::GetValue() { + return this->raw; } <% @@ -79,7 +95,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg for (var i = 0; i < functionInfo.args.length - offset; i++) { var arg = functionInfo.args[i + offset]; -%> - if (args.Length() == <%- i %> || !args[<%- i %>]->IsObject()) { + if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- jsClassName2v8ValueClassName(arg.cppClassName) %>()) { return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); } <% } -%> @@ -87,26 +103,47 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } -<%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; + <%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; + baton->error = NULL; baton->request.data = baton; +<% if (functionInfo.isConstructorMethod) { -%> +<% } else if (functionInfo.isPrototypeMethod) { -%> <%- cppClassName %> object = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This()); - object->Ref(); - baton-><%- functionInfo.args[0].name %> = object::GetValue(); + baton->in = object::GetValue(); +<% } -%> <% - for (var i = 1; i < functionInfo.args.length; i++) { + for (var i = offset; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> - baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[i]->ToObject())->Value(); +<% if (arg.cppClassName == 'String') { %> + baton-><%- arg.name %> = stringArgToString(args[<%- i - offset%>]->ToString()).c_str(); +<% } else if (arg.cppClassName == 'Buffer') { -%> + baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())); +<% } else if (arg.cppClassName == 'Number') { -%> + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->Value(); +<% } else { -%> + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->GetValue(); +<% } -%> <% } -%> - baton->callback = Persistent::New(Local::Cast(args[i])); + baton->callback = Persistent::New(Local::Cast(args[<%- i - offset %>])); uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); return Undefined(); } -void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t* req) { -<%- functionInfo.cppFunctionName %>Baton* baton = static_cast<<%- functionInfo.cppFunctionName %>Baton* >(req->data); -<%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>(<% for (var i in functionInfo.args) { var arg = functionInfo.args[i]; %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>,<% } %><% } %>); + +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { + <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); + <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( +<% if (functionInfo.isConstructorMethod) { -%> + &baton->out<% if (functionInfo.args.length - offset > 0) { %>,<% } %> +<% } else if (functionInfo.isPrototypeMethod) { -%> + baton->in<% if (functionInfo.args.length - offset > 0) { %>,<% } %> +<% } -%> +<% for (var i = offset; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> + baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> +<% } -%> + ); <% if (functionInfo.return.isErrorCode) { -%> if (result != GIT_OK) { baton->error = giterr_last(); @@ -115,28 +152,39 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t* req baton->result = result; <% } -%> } -void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t* req) { + +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t *req) { HandleScope scope; -<%- functionInfo.cppFunctionName %>Baton* baton = static_cast<<%- functionInfo.cppFunctionName %>Baton*>(req->data); + <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); + TryCatch try_catch; if (success(baton->error, baton->callback)) { - Handle argv[2] = { +<% if (functionInfo.isConstructorMethod) { -%> + Handle argv[1] = { External::New(baton->out) }; + Handle object = constructor_template->NewInstance(1, argv); +<% } else { -%> + Handle argv[1] = { External::New(baton-><%- functionInfo.args[0].name %>) }; + Handle object = <%- functionInfo.args[0].cppClassName %>::constructor_template->NewInstance(1, argv); +<% } -%> + Handle argv2[2] = { Local::New(Null()), - baton->result + object }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[2] = { + Exception::Error(String::New(baton->error->message)), + Local::New(Null()) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } -<%- cppClassName %> object = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This()); - object->Unref(); baton->callback.Dispose(); delete baton; - delete req; } <% } else { -%> Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { @@ -147,7 +195,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg for (var i = 0; i < functionInfo.args.length - offset; i++) { var arg = functionInfo.args[i + offset]; -%> - if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- arg.jsClassName %>()) { + if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- jsClassName2v8ValueClassName(arg.cppClassName) %>()) { return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); } <% } -%> @@ -155,16 +203,16 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <% if (functionInfo.isConstructorMethod) { -%> <%- functionInfo.args[0].cType %> out = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); <% } else if (functionInfo.isPrototypeMethod) { -%> - <%- cType %> in = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); + <%- cType %> *in = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); <% } -%> <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( - <% if (functionInfo.isConstructorMethod) { %>out<% } else if (functionInfo.isPrototypeMethod) { -%>&in<% } -%><% if (functionInfo.args.length - offset > 0) { %>,<% } %> + <% if (functionInfo.isConstructorMethod) { %>out<% } else if (functionInfo.isPrototypeMethod) { -%>in<% } -%><% if (functionInfo.args.length - offset > 0) { %>,<% } %> <% for (var i = offset; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> <% if (arg.cppClassName == 'String') { %> stringArgToString(args[<%- i - offset%>]->ToString()).c_str() <% } else { -%> - ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->Value() + ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->GetValue() <% } -%> <% if (i < functionInfo.args.length - 1) { %>, <% } -%> <% } %> @@ -176,15 +224,21 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg } <% } -%> <% if (functionInfo.isConstructorMethod) { -%> - Handle argv[1] = { External::New(out) }; + Handle argv[1] = { External::New((void *)out) }; return scope.Close(constructor_template->NewInstance(1, argv)); <% } else if (functionInfo.return.cType == "void") { -%> return Undefined(); -<% } else { -%> +<% } else if (isPrimitive(functionInfo.return.cppClassName)) { -%> return scope.Close(<%- functionInfo.return.cppClassName %>::New(result)); -<% } -%> +<% } else if (functionInfo.return.cppClassName == "External") { -%> + return scope.Close(External::New((void *)result)); +<% } else { -%> + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(<%- functionInfo.return.cppClassName %>::constructor_template->NewInstance(1, argv)); <% } -%> } <% } -%> +<% } -%> Persistent <%- cppClassName %>::constructor_template; diff --git a/templates/header.h.ejs b/templates/header.h.ejs index caa2819bc..a8cd94aee 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -20,7 +20,7 @@ class <%- cppClassName %> : public ObjectWrap { static Persistent constructor_template; static void Initialize (Handle target); - <%- cType %> GetValue(); + <%- cType %> *GetValue(); private: <%- cppClassName %>(<%- cType %> *raw); @@ -35,15 +35,23 @@ class <%- cppClassName %> : public ObjectWrap { -%> static Handle <%- functionInfo.cppFunctionName %>(const Arguments& args); <% if (functionInfo.isAsync) { -%> - static void <%- cppFunctionName %>Work(uv_work_t* req); - static void <%- cppFunctionName %>AfterWork(uv_work_t* req); + static void <%- functionInfo.cppFunctionName %>Work(uv_work_t* req); + static void <%- functionInfo.cppFunctionName %>AfterWork(uv_work_t* req); - struct <%- cppFunctionName %>Baton { + struct <%- functionInfo.cppFunctionName %>Baton { uv_work_t request; const git_error* error; - -<% for (var i = 0 in functionInfo.args) { -%> - <%- functionInfo.args[i].cType %> <%- functionInfo.args[i].name %>; +<% if (functionInfo.isConstructorMethod) { -%> + <%- cType %> *out; +<% } else if (functionInfo.isPrototypeMethod) { -%> + <%- cType %> *in; +<% } -%> +<% + var offset = functionInfo.isPrototypeMethod || functionInfo.isConstructorMethod ? 1 : 0; + for (var i = 0; i < functionInfo.args.length - offset; i++) { + var arg = functionInfo.args[i + offset]; +-%> + <%- arg.cType %> <%- arg.name %>; <% } -%> Persistent callback; }; diff --git a/test/npm-debug.log b/test/npm-debug.log index 4db27521a..b7d4604cd 100644 --- a/test/npm-debug.log +++ b/test/npm-debug.log @@ -1,5 +1,5 @@ 0 info it worked if it ends with ok -1 verbose cli [ 'node', '/usr/local/bin/npm', 'test' ] +1 verbose cli [ 'node', '/usr/local/bin/npm', 'run-script', 'gen' ] 2 info using npm@1.2.28 3 info using node@v0.10.10 4 verbose read json /Users/nkallen/Workspace/nodegit/test/package.json @@ -9,7 +9,7 @@ 6 error or email it to: 6 error 7 error System Darwin 12.3.0 -8 error command "node" "/usr/local/bin/npm" "test" +8 error command "node" "/usr/local/bin/npm" "run-script" "gen" 9 error cwd /Users/nkallen/Workspace/nodegit/test 10 error node -v v0.10.10 11 error npm -v 1.2.28 diff --git a/test/raw-blob.js b/test/raw-blob.js index 06a552614..4b8820fc1 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -30,34 +30,33 @@ var helper = { exports.constructor = function(test){ test.expect(3); helper.testFunction(test.equals, git.Blob, 'Blob'); - test.ok(new git.Blob() instanceof git.Blob, 'Invocation returns an instance of Blob'); + test.throws(function() { new git.Blob(); }); test.done(); }; // Blob::Lookup exports.lookup = function(test) { var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), - testRef = new git.Reference(testRepo), - testBlob = new git.Blob(); + testRef = new git.Reference(testRepo); test.expect(5); // Test for function - helper.testFunction(test.equals, testBlob.lookup, 'Blob::Lookup'); + helper.testFunction(test.equals, git.Blob.lookup, 'Blob::Lookup'); // Test repo argument existence helper.testException(test.ok, function() { - testBlob.lookup(); + git.Blob.lookup(); }, 'Throw an exception if no repo Object'); // Test Oid argument existence helper.testException(test.ok, function() { - testBlob.lookup(testRepo); + git.Blob.lookup(testRepo); }, 'Throw an exception if no oid Object'); // Test Callback argument existence helper.testException(test.ok, function() { - testBlob.lookup(testRepo, testOid); + git.Blob.lookup(testRepo, testOid); }, 'Throw an exception if no callback Object'); testRepo.open(path.resolve('../.git'), function() { @@ -68,53 +67,40 @@ exports.lookup = function(test) { // Blob::RawContent exports.rawContent = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), - testBlob = new git.Blob(), + // This shouldn't fail unless someone rewrites history: + var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'), testCommit = new git.Commit(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testBlob.rawContent, 'Blob::RawContent'); - - test.done(); -}; - -// Blob::Free -exports.free = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), - testBlob = new git.Blob(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testBlob.free, 'Blob::Free'); - - test.done(); + test.expect(3); + testRepo.open(path.resolve('../.git'), function(err, repo) { + git.Blob.lookup(repo, testOid, function(err, blob) { + // Test for function + helper.testFunction(test.equals, blob.content, 'Blob::RawContent'); + test.equals(blob.content().toBuffer(7).toString(), "@import"); + + test.done(); + }); + }); }; // Blob::CreateFromFile exports.createFromFile = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), - testBlob = new git.Blob(); + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); test.expect(2); // Test for function - helper.testFunction(test.equals, testBlob.createFromFile, 'Blob::CreateFromFile'); + helper.testFunction(test.equals, git.Blob.createFromFile, 'Blob::CreateFromFile'); test.done(); }; // Blob::CreateFromBuffer exports.createFromBuffer = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), - testBlob = new git.Blob(); - + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); test.expect(2); // Test for function - helper.testFunction(test.equals, testBlob.createFromBuffer, 'Blob::CreateFromBuffer'); + helper.testFunction(test.equals, git.Blob.createFromBuffer, 'Blob::CreateFromBuffer'); test.done(); }; diff --git a/v0.18.0.json b/v0.18.0.json index 34aaef26a..8f804466e 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -18,7 +18,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -64,7 +64,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -110,7 +110,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -156,7 +156,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -178,7 +178,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -210,8 +210,9 @@ }, { "filename": "blob.h", + "dependencies": ["../include/repo.h", "../include/oid.h", "../include/wrapper.h", "node_buffer.h"], "jsClassName": "Blob", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "cType": "git_blob", "freeFunctionName": "git_blob_free", "functions": [ @@ -221,13 +222,13 @@ { "name": "blob", "cType": "git_blob **", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" }, { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -237,7 +238,7 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "isFree": false, @@ -255,13 +256,13 @@ { "name": "blob", "cType": "git_blob **", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" }, { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -277,6 +278,7 @@ "jsClassName": "size_t" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -295,10 +297,11 @@ { "name": "blob", "cType": "git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -317,7 +320,7 @@ { "name": "blob", "cType": "const git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" } ], @@ -325,8 +328,8 @@ "isConstructorMethod": false, "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "id", - "cppFunctionName": "Id", + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", "cppClassName": "GitOid", @@ -339,7 +342,7 @@ { "name": "blob", "cType": "const git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" } ], @@ -347,11 +350,11 @@ "isConstructorMethod": false, "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "rawcontent", - "cppFunctionName": "Rawcontent", + "jsFunctionName": "content", + "cppFunctionName": "Content", "return": { "cType": "const void *", - "cppClassName": "void", + "cppClassName": "Wrapper", "isErrorCode": false } }, @@ -361,7 +364,7 @@ { "name": "blob", "cType": "const git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" } ], @@ -369,11 +372,11 @@ "isConstructorMethod": false, "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "rawsize", - "cppFunctionName": "Rawsize", + "jsFunctionName": "size", + "cppFunctionName": "Size", "return": { "cType": "git_off_t", - "cppClassName": "OffT", + "cppClassName": "Number", "isErrorCode": false } }, @@ -389,7 +392,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -399,6 +402,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -423,7 +427,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -433,12 +437,12 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "createFromdisk", - "cppFunctionName": "CreateFromdisk", + "jsFunctionName": "createFromFile", + "cppFunctionName": "CreateFromFile", "return": { "cType": "int", "cppClassName": "int", @@ -457,7 +461,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -479,6 +483,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -503,28 +508,28 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { "name": "buffer", "cType": "const void *", - "cppClassName": "void", - "jsClassName": "void" + "cppClassName": "Buffer", + "jsClassName": "Buffer" }, { "name": "len", "cType": "size_t", - "cppClassName": "size_t", - "jsClassName": "size_t" + "cppClassName": "Number", + "jsClassName": "Number" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "createFrombuffer", - "cppFunctionName": "CreateFrombuffer", + "jsFunctionName": "createFromBuffer", + "cppFunctionName": "CreateFromBuffer", "return": { "cType": "int", "cppClassName": "int", @@ -537,7 +542,7 @@ { "name": "blob", "cType": "git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" } ], @@ -549,7 +554,7 @@ "cppFunctionName": "IsBinary", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Boolean", "isErrorCode": true } } @@ -574,7 +579,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -636,7 +641,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -722,7 +727,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -852,7 +857,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -914,7 +919,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -951,7 +956,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -979,7 +984,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -1013,7 +1018,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -1056,7 +1061,7 @@ { "name": "out", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -1111,7 +1116,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -1145,7 +1150,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -1529,7 +1534,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -1599,7 +1604,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -2822,7 +2827,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -2868,7 +2873,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -2914,7 +2919,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -2954,7 +2959,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -3582,13 +3587,13 @@ { "name": "old_blob", "cType": "const git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" }, { "name": "new_blob", "cType": "const git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" }, { @@ -3640,7 +3645,7 @@ { "name": "old_blob", "cType": "const git_blob *", - "cppClassName": "Blob", + "cppClassName": "GitBlob", "jsClassName": "Blob" }, { @@ -3807,7 +3812,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -3850,7 +3855,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -3878,7 +3883,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -3906,7 +3911,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -4027,7 +4032,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "isErrorCode": false } }, @@ -4199,7 +4204,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -5103,7 +5108,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5143,7 +5148,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5243,7 +5248,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5333,7 +5338,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5417,7 +5422,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5475,7 +5480,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5549,7 +5554,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -5571,7 +5576,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5626,7 +5631,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5666,7 +5671,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -5762,7 +5767,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "isErrorCode": false } }, @@ -6698,6 +6703,7 @@ }, { "filename": "oid.h", + "dependencies": [], "jsClassName": "Oid", "cppClassName": "GitOid", "cType": "git_oid", @@ -6721,7 +6727,7 @@ ], "isAsync": false, "isConstructorMethod": true, - "isPrototypeMethod": true, + "isPrototypeMethod": false, "isFree": false, "jsFunctionName": "fromString", "cppFunctionName": "FromString", @@ -7209,7 +7215,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -7719,7 +7725,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -7747,7 +7753,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -7856,7 +7862,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8242,7 +8248,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8276,7 +8282,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8310,7 +8316,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8356,7 +8362,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8524,7 +8530,7 @@ "cppFunctionName": "GitReferenceOwner", "return": { "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "isErrorCode": false } }, @@ -8670,7 +8676,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8698,7 +8704,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -8788,7 +8794,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -9222,7 +9228,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -9262,7 +9268,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -9302,7 +9308,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -9830,7 +9836,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10146,7 +10152,7 @@ { "filename": "repository.h", "jsClassName": "Repository", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "cType": "git_repository", "freeFunctionName": "git_repository_free", "functions": [ @@ -10156,7 +10162,7 @@ { "name": "out", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10184,7 +10190,7 @@ { "name": "out", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10258,7 +10264,7 @@ { "name": "out", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10298,7 +10304,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10320,7 +10326,7 @@ { "name": "out", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10354,7 +10360,7 @@ { "name": "out", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10394,7 +10400,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10416,7 +10422,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10438,7 +10444,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10460,7 +10466,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10482,7 +10488,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10504,7 +10510,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10526,7 +10532,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10560,7 +10566,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10588,7 +10594,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10610,7 +10616,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10644,7 +10650,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10666,7 +10672,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10700,7 +10706,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10722,7 +10728,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10756,7 +10762,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10778,7 +10784,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10818,7 +10824,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10840,7 +10846,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10862,7 +10868,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -10884,7 +10890,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10918,7 +10924,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -10958,7 +10964,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11076,7 +11082,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -11107,7 +11113,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11141,7 +11147,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11190,7 +11196,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11224,7 +11230,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11267,7 +11273,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -11641,7 +11647,7 @@ "cppFunctionName": "Repository", "return": { "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "isErrorCode": false } } @@ -11799,7 +11805,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11839,7 +11845,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11873,7 +11879,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11910,7 +11916,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11944,7 +11950,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -11990,7 +11996,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12024,7 +12030,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12134,7 +12140,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12162,7 +12168,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12202,7 +12208,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12326,7 +12332,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "isErrorCode": false } }, @@ -12682,7 +12688,7 @@ { "name": "repo", "cType": "git_repository **", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12732,7 +12738,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -12825,7 +12831,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -12859,7 +12865,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13081,7 +13087,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13139,7 +13145,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13179,7 +13185,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13219,7 +13225,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13253,7 +13259,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -13287,7 +13293,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" } ], @@ -13309,7 +13315,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13697,7 +13703,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13731,7 +13737,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -13821,7 +13827,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "isErrorCode": false } }, @@ -14137,7 +14143,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { @@ -14401,7 +14407,7 @@ { "name": "repo", "cType": "git_repository *", - "cppClassName": "Repository", + "cppClassName": "GitRepo", "jsClassName": "Repository" }, { From 458d8719707bbd2e2cc5294a03c70a20fc396a58 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 21 Jun 2013 15:46:18 +0200 Subject: [PATCH 03/28] Repo is now code-gen'd --- gen.js | 2 +- include/repo.h | 58 ++++------ lib/index.js | 1 + lib/repo.js | 23 ++-- src/blob.cc | 34 +++--- src/repo.cc | 205 ++++++++++++++++++++--------------- templates/class.cc.ejs | 30 +++-- test/convenience-difflist.js | 46 ++++---- test/convenience-repo.js | 8 +- test/raw-blob.js | 40 +++---- test/raw-commit.js | 44 ++++---- test/raw-reference.js | 53 ++++----- test/raw-repo.js | 56 +++------- test/raw-revwalk.js | 4 +- v0.18.0.json | 42 ++++++- 15 files changed, 331 insertions(+), 315 deletions(-) diff --git a/gen.js b/gen.js index 5ce919b19..0cbdd4998 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/repo.h b/include/repo.h index 55eb04d38..2b3a6d70d 100755 --- a/include/repo.h +++ b/include/repo.h @@ -1,12 +1,9 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef REPO_H -#define REPO_H +#ifndef GITREPO_H +#define GITREPO_H #include #include @@ -19,55 +16,44 @@ using namespace v8; class GitRepo : public ObjectWrap { public: + static Persistent constructor_template; - static void Initialize(Handle target); + static void Initialize (Handle target); - git_repository* GetValue(); - void SetValue(git_repository* repo); + git_repository *GetValue(); - void Free(); + private: + GitRepo(git_repository *raw); + ~GitRepo(); - protected: - GitRepo() {} - ~GitRepo() {} static Handle New(const Arguments& args); static Handle Open(const Arguments& args); static void OpenWork(uv_work_t* req); static void OpenAfterWork(uv_work_t* req); - static Handle Free(const Arguments& args); - - static Handle Init(const Arguments& args); - static void InitWork(uv_work_t* req); - static void InitAfterWork(uv_work_t* req); - - private: - git_repository* repo; - struct OpenBaton { uv_work_t request; const git_error* error; - - git_repository* rawRepo; - GitRepo *repo; - - std::string path; - + git_repository *out; + const char * path; Persistent callback; }; + static Handle Init(const Arguments& args); + static void InitWork(uv_work_t* req); + static void InitAfterWork(uv_work_t* req); struct InitBaton { uv_work_t request; const git_error* error; - - GitRepo* repo; - git_repository* rawRepo; - std::string path; - bool isBare; - + git_repository *out; + const char * path; + unsigned is_bare; Persistent callback; }; + static Handle Path(const Arguments& args); + static Handle Workdir(const Arguments& args); + git_repository *raw; }; #endif diff --git a/lib/index.js b/lib/index.js index 197f77abb..d8dd19100 100755 --- a/lib/index.js +++ b/lib/index.js @@ -12,6 +12,7 @@ if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { // Import libraries exports.blob = require('./blob.js').blob; exports.repo = require('./repo.js').repo; +exports.init = require('./repo.js').init; exports.signature = require('./signature.js').signature; exports.oid = require('./oid.js').oid; exports.reference = require('./reference.js').reference; diff --git a/lib/repo.js b/lib/repo.js index 343af1dd4..f001991f0 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -6,8 +6,8 @@ var git = require('../'), * * @constructor */ -var Repo = function() { - this.rawRepo = new git.raw.Repo(); +var Repo = function(rawRepo) { + this.rawRepo = rawRepo; }; /** @@ -19,7 +19,7 @@ var Repo = function() { * @param {String} directory The .git directory for the repository to open. * @param {Repo~openCallback} callback */ -Repo.prototype.open = function(directory, callback) { +Repo.open = function(directory, callback) { /** * @callback Repo~openCallback Callback executed when repository is opened. * @param {GitError|null} error An Error or null if successful. @@ -28,11 +28,9 @@ Repo.prototype.open = function(directory, callback) { if (typeof callback !== 'function') { throw new git.error('Callback is required and must be a Function'); } - var self = this; - self.rawRepo.open(directory, function openRepository(error, rawRepo) { + git.raw.Repo.open(directory, function openRepository(error, rawRepo) { if (success(error, callback)) { - self.rawRepo = rawRepo; - callback(null, self); + callback(null, new Repo(rawRepo)); } }); }; @@ -94,17 +92,15 @@ Repo.prototype.commit = function(sha, callback) { * @param {Boolean} isBare True if the repository is to be bare, false otherwise. * @param {Repo~initCallback} callback */ -Repo.prototype.init = function(directory, isBare, callback) { +exports.init = function(directory, isBare, callback) { /** * @callback Repo~initCallback Callback executed when repository is initialized. * @param {GitError|null} error An Error or null if successful. * @param {Repo|null} repo Initialized repository. */ - var self = this; - self.rawRepo.init(directory, isBare, function(error, rawRepo) { + git.raw.Repo.init(directory, isBare, function(error, rawRepo) { if (success(error, callback)) { - self.rawRepo = rawRepo; - callback(null, self); + callback(null, new Repo(rawRepo)); } }); }; @@ -124,9 +120,8 @@ exports.repo = function(directory, callback) { * @param {GitError|null} error An Error or null if successful. * @param {Repo|null} repo Opened repository. */ - var repo = new Repo(); if (typeof directory === 'undefined') { return repo; } - repo.open(directory, callback); + Repo.open(directory, callback); }; diff --git a/src/blob.cc b/src/blob.cc index 5365f5491..5268df775 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -108,7 +108,7 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (success(baton->error, baton->callback)) { + if (!baton->error) { Handle argv[1] = { External::New(baton->out) }; Handle object = constructor_template->NewInstance(1, argv); Handle argv2[2] = { @@ -117,11 +117,10 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { - Handle argv2[2] = { - Exception::Error(String::New(baton->error->message)), - Local::New(Null()) + Handle argv2[1] = { + GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } if (try_catch.HasCaught()) { @@ -197,7 +196,8 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { baton->id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->repo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->path = stringArgToString(args[2]->ToString()).c_str(); + String::Utf8Value str2(args[2]->ToString()); + baton->path = strdup(*str2); baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); @@ -222,7 +222,7 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { CreateFromFileBaton *baton = static_cast(req->data); TryCatch try_catch; - if (success(baton->error, baton->callback)) { + if (!baton->error) { Handle argv[1] = { External::New(baton->id) }; Handle object = GitOid::constructor_template->NewInstance(1, argv); Handle argv2[2] = { @@ -231,11 +231,10 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { - Handle argv2[2] = { - Exception::Error(String::New(baton->error->message)), - Local::New(Null()) + Handle argv2[1] = { + GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } if (try_catch.HasCaught()) { @@ -243,6 +242,8 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { } baton->callback.Dispose(); + + delete baton->path; delete baton; } @@ -271,7 +272,7 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { baton->oid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->repo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[2]->ToObject())); - baton->len = ObjectWrap::Unwrap(args[3]->ToObject())->Value(); + baton->len = args[3]->ToNumber()->Value(); baton->callback = Persistent::New(Local::Cast(args[4])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromBufferWork, (uv_after_work_cb)CreateFromBufferAfterWork); @@ -297,7 +298,7 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { CreateFromBufferBaton *baton = static_cast(req->data); TryCatch try_catch; - if (success(baton->error, baton->callback)) { + if (!baton->error) { Handle argv[1] = { External::New(baton->oid) }; Handle object = GitOid::constructor_template->NewInstance(1, argv); Handle argv2[2] = { @@ -306,11 +307,10 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { - Handle argv2[2] = { - Exception::Error(String::New(baton->error->message)), - Local::New(Null()) + Handle argv2[1] = { + GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } if (try_catch.HasCaught()) { diff --git a/src/repo.cc b/src/repo.cc index 6644803a4..895d4d278 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -1,25 +1,30 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" #include "../include/repo.h" -#include "../include/commit.h" -#include "../include/error.h" + +#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; using namespace node; -void GitRepo::Initialize(Handle target) { +GitRepo::GitRepo(git_repository *raw) { + this->raw = raw; +} + +GitRepo::~GitRepo() { + git_repository_free(this->raw); +} + +void GitRepo::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -27,37 +32,30 @@ void GitRepo::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Repo")); - NODE_SET_PROTOTYPE_METHOD(tpl, "open", Open); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init); + NODE_SET_METHOD(tpl, "open", Open); + NODE_SET_METHOD(tpl, "init", Init); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + NODE_SET_PROTOTYPE_METHOD(tpl, "workdir", Workdir); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Repo"), constructor_template); } -git_repository* GitRepo::GetValue() { - return this->repo; -} -void GitRepo::SetValue(git_repository* repo) { - this->repo = repo; -} - Handle GitRepo::New(const Arguments& args) { HandleScope scope; - GitRepo *repo = new GitRepo(); - repo->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_repository is required."))); + } + + GitRepo* object = new GitRepo((git_repository *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitRepo::Free(const Arguments& args) { - HandleScope scope; - - GitRepo *repo = ObjectWrap::Unwrap(args.This()); - git_repository_free(repo->repo); - - return scope.Close( Undefined() ); +git_repository *GitRepo::GetValue() { + return this->raw; } @@ -65,21 +63,19 @@ Handle GitRepo::Open(const Arguments& args) { HandleScope scope; if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("Path is required and must be a String."))); + return ThrowException(Exception::Error(String::New("String is required."))); } - - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - OpenBaton *baton = new OpenBaton; - baton->request.data = baton; + OpenBaton* baton = new OpenBaton; baton->error = NULL; - baton->path = stringArgToString(args[0]->ToString());; - baton->repo = ObjectWrap::Unwrap(args.This()); - baton->callback = Persistent::New(Handle::Cast(args[1])); + baton->request.data = baton; - baton->repo->Ref(); + String::Utf8Value str0(args[0]->ToString()); + baton->path = strdup(*str0); + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); @@ -88,70 +84,65 @@ Handle GitRepo::Open(const Arguments& args) { void GitRepo::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); - - int returnCode = git_repository_open(&baton->rawRepo, baton->path.c_str()); - if (returnCode != GIT_OK) { + int result = git_repository_open( + &baton->out, + baton->path + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } void GitRepo::OpenAfterWork(uv_work_t *req) { HandleScope scope; - OpenBaton *baton = static_cast(req->data); - if (baton->error) { - Local argv[1] = { - GitError::WrapError(baton->error) + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle object = constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { - - baton->repo->SetValue(baton->rawRepo); - - Handle argv[2] = { - Local::New(Null()), - baton->repo->handle_ + Handle argv2[1] = { + GitError::WrapError(baton->error) }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; - baton->repo->Unref(); + + baton->callback.Dispose(); + + delete baton->path; + delete baton; } Handle GitRepo::Init(const Arguments& args) { HandleScope scope; if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("path is required and must be a String."))); + return ThrowException(Exception::Error(String::New("String is required."))); } - if(args.Length() == 1 || !args[1]->IsBoolean()) { - return ThrowException(Exception::Error(String::New("is_bare is required and must be a Boolean."))); + return ThrowException(Exception::Error(String::New("Boolean is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - InitBaton *baton = new InitBaton; - baton->request.data = baton; + InitBaton* baton = new InitBaton; baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This()); - baton->repo->Ref(); - baton->rawRepo = baton->repo->GetValue(); - baton->path = stringArgToString(args[0]->ToString());; - baton->isBare = args[1]->ToBoolean()->Value(); + baton->request.data = baton; + + String::Utf8Value str0(args[0]->ToString()); + baton->path = strdup(*str0); + baton->is_bare = args[1]->ToBoolean()->Value(); baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); @@ -161,32 +152,70 @@ Handle GitRepo::Init(const Arguments& args) { void GitRepo::InitWork(uv_work_t *req) { InitBaton *baton = static_cast(req->data); - - int returnCode = git_repository_init(&baton->rawRepo, baton->path.c_str(), baton->isBare); - if (returnCode != GIT_OK) { + int result = git_repository_init( + &baton->out, + baton->path, + baton->is_bare + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } void GitRepo::InitAfterWork(uv_work_t *req) { HandleScope scope; - InitBaton *baton = static_cast(req->data); - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle object = constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { - argv[0] = Local::New(Null()); + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (try_catch.HasCaught()) { - node::FatalException(try_catch); + node::FatalException(try_catch); } - delete req; - baton->repo->Unref(); + + baton->callback.Dispose(); + + delete baton->path; + delete baton; +} + +Handle GitRepo::Path(const Arguments& args) { + HandleScope scope; + + + git_repository *in = ObjectWrap::Unwrap(args.This())->GetValue(); + + const char * result = git_repository_path( + in + ); + + return scope.Close(String::New(result)); +} + +Handle GitRepo::Workdir(const Arguments& args) { + HandleScope scope; + + + git_repository *in = ObjectWrap::Unwrap(args.This())->GetValue(); + + const char * result = git_repository_workdir( + in + ); + + return scope.Close(String::New(result)); } Persistent GitRepo::constructor_template; diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 4292c9b53..939e1a0c6 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -3,7 +3,7 @@ return ["Boolean", "Number", "String"].indexOf(cppClassName) > -1; } - function jsClassName2v8ValueClassName(cppClassName) { + function cppClassName2v8ValueClassName(cppClassName) { if (isPrimitive(cppClassName)) return cppClassName; else @@ -95,7 +95,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg for (var i = 0; i < functionInfo.args.length - offset; i++) { var arg = functionInfo.args[i + offset]; -%> - if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- jsClassName2v8ValueClassName(arg.cppClassName) %>()) { + if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); } <% } -%> @@ -116,11 +116,12 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg var arg = functionInfo.args[i]; -%> <% if (arg.cppClassName == 'String') { %> - baton-><%- arg.name %> = stringArgToString(args[<%- i - offset%>]->ToString()).c_str(); + String::Utf8Value str<%- i - offset%>(args[<%- i - offset%>]->ToString()); + baton-><%- arg.name %> = strdup(*str<%- i - offset%>); <% } else if (arg.cppClassName == 'Buffer') { -%> baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())); -<% } else if (arg.cppClassName == 'Number') { -%> - baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->Value(); +<% } else if (isPrimitive(arg.cppClassName)) { -%> + baton-><%- arg.name %> = args[<%- i - offset%>]->To<%- arg.cppClassName %>()->Value(); <% } else { -%> baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->GetValue(); <% } -%> @@ -158,7 +159,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); TryCatch try_catch; - if (success(baton->error, baton->callback)) { + if (!baton->error) { <% if (functionInfo.isConstructorMethod) { -%> Handle argv[1] = { External::New(baton->out) }; Handle object = constructor_template->NewInstance(1, argv); @@ -172,11 +173,10 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { - Handle argv2[2] = { - Exception::Error(String::New(baton->error->message)), - Local::New(Null()) + Handle argv2[1] = { + GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } if (try_catch.HasCaught()) { @@ -184,6 +184,14 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t } baton->callback.Dispose(); +<% + for (var i = offset; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> +<% if (arg.cppClassName == 'String') { %> + delete baton-><%- arg.name %>; +<% } -%> +<% } -%> delete baton; } <% } else { -%> @@ -195,7 +203,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg for (var i = 0; i < functionInfo.args.length - offset; i++) { var arg = functionInfo.args[i + offset]; -%> - if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- jsClassName2v8ValueClassName(arg.cppClassName) %>()) { + if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); } <% } -%> diff --git a/test/convenience-difflist.js b/test/convenience-difflist.js index d43c31e7c..c9a1a4bef 100644 --- a/test/convenience-difflist.js +++ b/test/convenience-difflist.js @@ -94,29 +94,33 @@ exports.walkingEnd = function(test) { exports.deltaTypes = function(test) { test.expect(9); - var diffList = new git.diffList((new git.repo()).rawRepo); - test.equal(diffList.deltaTypes.GIT_DELTA_UNMODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNMODIFIED, 'GIT_DELTA_UNMODIFIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_ADDED, git.raw.DiffList.deltaTypes.GIT_DELTA_ADDED, 'GIT_DELTA_ADDED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_DELETED, git.raw.DiffList.deltaTypes.GIT_DELTA_DELETED, 'GIT_DELTA_DELETED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_MODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_MODIFIED, 'GIT_DELTA_MODIFIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_RENAMED, git.raw.DiffList.deltaTypes.GIT_DELTA_RENAMED, 'GIT_DELTA_RENAMED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_COPIED, git.raw.DiffList.deltaTypes.GIT_DELTA_COPIED, 'GIT_DELTA_COPIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_IGNORED, git.raw.DiffList.deltaTypes.GIT_DELTA_IGNORED, 'GIT_DELTA_IGNORED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_UNTRACKED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNTRACKED, 'GIT_DELTA_UNTRACKED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_TYPECHANGE, git.raw.DiffList.deltaTypes.GIT_DELTA_TYPECHANGE, 'GIT_DELTA_TYPECHANGE delta type should match expected value'); - test.done(); + git.repo('../.git', function(error, repo) { + var diffList = new git.diffList(repo.rawRepo); + test.equal(diffList.deltaTypes.GIT_DELTA_UNMODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNMODIFIED, 'GIT_DELTA_UNMODIFIED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_ADDED, git.raw.DiffList.deltaTypes.GIT_DELTA_ADDED, 'GIT_DELTA_ADDED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_DELETED, git.raw.DiffList.deltaTypes.GIT_DELTA_DELETED, 'GIT_DELTA_DELETED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_MODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_MODIFIED, 'GIT_DELTA_MODIFIED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_RENAMED, git.raw.DiffList.deltaTypes.GIT_DELTA_RENAMED, 'GIT_DELTA_RENAMED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_COPIED, git.raw.DiffList.deltaTypes.GIT_DELTA_COPIED, 'GIT_DELTA_COPIED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_IGNORED, git.raw.DiffList.deltaTypes.GIT_DELTA_IGNORED, 'GIT_DELTA_IGNORED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_UNTRACKED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNTRACKED, 'GIT_DELTA_UNTRACKED delta type should match expected value'); + test.equal(diffList.deltaTypes.GIT_DELTA_TYPECHANGE, git.raw.DiffList.deltaTypes.GIT_DELTA_TYPECHANGE, 'GIT_DELTA_TYPECHANGE delta type should match expected value'); + test.done(); + }); }; exports.lineOriginTypes = function(test) { test.expect(8); - var diffList = new git.diffList((new git.repo()).rawRepo); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'GIT_DIFF_LINE_CONTEXT line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'GIT_DIFF_LINE_ADDITION line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'GIT_DIFF_LINE_DELETION line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, 'GIT_DIFF_LINE_ADD_EOFNL line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, 'GIT_DIFF_LINE_DEL_EOFNL line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, 'GIT_DIFF_LINE_FILE_HDR line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, 'GIT_DIFF_LINE_HUNK_HDR line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, 'GIT_DIFF_LINE_BINARY line origin type should match expected value'); - test.done(); + git.repo('../.git', function(error, repo) { + var diffList = new git.diffList(repo.rawRepo); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'GIT_DIFF_LINE_CONTEXT line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'GIT_DIFF_LINE_ADDITION line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'GIT_DIFF_LINE_DELETION line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, 'GIT_DIFF_LINE_ADD_EOFNL line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, 'GIT_DIFF_LINE_DEL_EOFNL line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, 'GIT_DIFF_LINE_FILE_HDR line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, 'GIT_DIFF_LINE_HUNK_HDR line origin type should match expected value'); + test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, 'GIT_DIFF_LINE_BINARY line origin type should match expected value'); + test.done(); + }); }; diff --git a/test/convenience-repo.js b/test/convenience-repo.js index d01f7ec72..db1996686 100644 --- a/test/convenience-repo.js +++ b/test/convenience-repo.js @@ -55,9 +55,9 @@ exports.method = function(test){ exports.nonexistentDirectory = function(test) { test.expect(2); git.repo('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { - test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); - test.equals(repository, null, 'Non existent directory should result in null repository'); - test.done(); + test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); + test.equals(repository, null, 'Non existent directory should result in null repository'); + test.done(); }); }; @@ -71,7 +71,7 @@ exports.init = function(test) { // Cleanup, remove test repo directory - if it exists rimraf('./test.git', function() { // Create bare repo and test for creation - git.repo().init('./test.git', true, function(error, path, isBare) { + git.init('./test.git', true, function(error, path, isBare) { test.equals(null, error, 'Successfully created bare repository'); // Verify repo exists git.repo('./test.git', function(error, path, repo) { diff --git a/test/raw-blob.js b/test/raw-blob.js index 4b8820fc1..34824cb34 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -2,8 +2,6 @@ var git = require('../').raw, path = require('path'), rimraf = require('rimraf'); -var testRepo = new git.Repo(); - var helper = { // Test if obj is a true function testFunction: function(test, obj, label) { @@ -36,31 +34,29 @@ exports.constructor = function(test){ // Blob::Lookup exports.lookup = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'), - testRef = new git.Reference(testRepo); - test.expect(5); + var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); + git.Repo.open('../.git', function(error, repo) { + var testRef = new git.Reference(repo); - // Test for function - helper.testFunction(test.equals, git.Blob.lookup, 'Blob::Lookup'); + // Test for function + helper.testFunction(test.equals, git.Blob.lookup, 'Blob::Lookup'); - // Test repo argument existence - helper.testException(test.ok, function() { - git.Blob.lookup(); - }, 'Throw an exception if no repo Object'); + // Test repo argument existence + helper.testException(test.ok, function() { + git.Blob.lookup(); + }, 'Throw an exception if no repo Object'); - // Test Oid argument existence - helper.testException(test.ok, function() { - git.Blob.lookup(testRepo); - }, 'Throw an exception if no oid Object'); + // Test Oid argument existence + helper.testException(test.ok, function() { + git.Blob.lookup(repo); + }, 'Throw an exception if no oid Object'); - // Test Callback argument existence - helper.testException(test.ok, function() { - git.Blob.lookup(testRepo, testOid); - }, 'Throw an exception if no callback Object'); + // Test Callback argument existence + helper.testException(test.ok, function() { + git.Blob.lookup(repo, testOid); + }, 'Throw an exception if no callback Object'); - testRepo.open(path.resolve('../.git'), function() { - // @todo actually lookup test.done(); }); }; @@ -71,7 +67,7 @@ exports.rawContent = function(test) { var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'), testCommit = new git.Commit(); test.expect(3); - testRepo.open(path.resolve('../.git'), function(err, repo) { + git.Repo.open(path.resolve('../.git'), function(err, repo) { git.Blob.lookup(repo, testOid, function(err, blob) { // Test for function helper.testFunction(test.equals, blob.content, 'Blob::RawContent'); diff --git a/test/raw-commit.js b/test/raw-commit.js index 348c93ec8..fa4908eda 100644 --- a/test/raw-commit.js +++ b/test/raw-commit.js @@ -1,7 +1,5 @@ var git = require('../').raw; -var testRepo = new git.Repo(); - var helper = { // Test if obj is a true function testFunction: function(test, obj, label) { @@ -30,10 +28,9 @@ exports.constructor = function(test){ // Test for function helper.testFunction(test.equals, git.Commit, 'Commit'); - - testRepo.open('../.git', function(err) { + git.Repo.open('../.git', function(err, repo) { // Ensure we get an instance of Commit - test.ok(new git.Commit(testRepo) instanceof git.Commit, 'Invocation returns an instance of Commit'); + test.ok(new git.Commit(repo) instanceof git.Commit, 'Invocation returns an instance of Commit'); test.done(); }); @@ -51,29 +48,28 @@ exports.lookup = function(test) { // Test for function helper.testFunction(test.equals, testCommit.lookup, 'Commit::Lookup'); - // Test repo argument existence - helper.testException(test.ok, function() { - testCommit.lookup(); - }, 'Throw an exception if no repo'); - - // Test oid argument existence - helper.testException(test.ok, function() { - testCommit.lookup(testRepo); - }, 'Throw an exception if no oid'); + git.Repo.open('../.git', function(error, repo) { + // Test repo argument existence + helper.testException(test.ok, function() { + testCommit.lookup(); + }, 'Throw an exception if no repo'); - // Test callback argument existence - helper.testException(test.ok, function() { - testCommit.lookup(testOid); - }, 'Throw an exception if no callback'); + // Test oid argument existence + helper.testException(test.ok, function() { + testCommit.lookup(repo); + }, 'Throw an exception if no oid'); - // Test that all arguments result correctly - helper.testException(test.ifError, function() { - testCommit.lookup(testRepo, testOid, function() {}); - }, 'No exception is thrown with proper arguments'); + // Test callback argument existence + helper.testException(test.ok, function() { + testCommit.lookup(repo); + }, 'Throw an exception if no callback'); - testRepo.open('../.git', function() { + // Test that all arguments result correctly + helper.testException(test.ifError, function() { + testCommit.lookup(repo, testOid, function() {}); + }, 'No exception is thrown with proper arguments'); // Test valid commit - testCommit.lookup(testRepo, testOid, function(err) { + testCommit.lookup(repo, testOid, function(err) { test.equal(null, err, 'Valid commit'); test.done(); }); diff --git a/test/raw-reference.js b/test/raw-reference.js index e20662f60..dd520426c 100644 --- a/test/raw-reference.js +++ b/test/raw-reference.js @@ -38,8 +38,7 @@ exports.constructor = function(test){ // Ref::Lookup exports.lookup = function(test) { - var testRepo = new git.Repo(), - master = new git.Reference(); + var master = new git.Reference(); test.expect(5); @@ -51,33 +50,35 @@ exports.lookup = function(test) { master.lookup(); }, 'Throw an exception if no repo'); - // Test name argument existence - helper.testException(test.ok, function() { - master.lookup(testRepo); - }, 'Throw an exception if no name'); + git.Repo.open('../.git', function(error, repo) { + // Test name argument existence + helper.testException(test.ok, function() { + master.lookup(repo); + }, 'Throw an exception if no name'); - // Test callback argument existence - helper.testException(test.ok, function() { - master.lookup(testRepo, 'refs/heads/master'); - }, 'Throw an exception if no callback'); + // Test callback argument existence + helper.testException(test.ok, function() { + master.lookup(repo, 'refs/heads/master'); + }, 'Throw an exception if no callback'); - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // // Create bare repo and test for creation - // testRepo.init('./test.git', true, function(err, path, is_bare) { - // test.equals(0, err, 'Successfully created bare repository'); - // // Verify repo exists - // testRepo.open('./test.git', function(err, path) { - // test.equals(0, err, 'Valid repository created'); - // test.equals(true, is_bare, 'Returns valid is_bare value'); + // Cleanup, remove test repo directory - if it exists + rimraf('./test.git', function() { + // // Create bare repo and test for creation + // repo.init('./test.git', true, function(err, path, is_bare) { + // test.equals(0, err, 'Successfully created bare repository'); + // // Verify repo exists + // repo.open('./test.git', function(err, path) { + // test.equals(0, err, 'Valid repository created'); + // test.equals(true, is_bare, 'Returns valid is_bare value'); - // testRepo.free(); + // repo.free(); - // // Cleanup, remove test repo directory - // rimraf('./test.git', function() { - test.done(); - // }); - // }); - // }); + // // Cleanup, remove test repo directory + // rimraf('./test.git', function() { + test.done(); + // }); + // }); + // }); + }); }); }; diff --git a/test/raw-repo.js b/test/raw-repo.js index b6c475e21..734103d4f 100644 --- a/test/raw-repo.js +++ b/test/raw-repo.js @@ -25,97 +25,69 @@ var helper = { }; // Repo -exports.constructor = function(test){ - test.expect(3); +exports.open = function(test){ + test.expect(9); // Test for function helper.testFunction(test.equals, git.Repo, 'Repo'); - // Ensure we get an instance of Repo - test.ok(new git.Repo() instanceof git.Repo, 'Invocation returns an instance of Repo'); - - test.done(); -}; - -// Repo::Open -exports.open = function(test) { - var testRepo = new git.Repo(); - - test.expect(6); - // Test for function - helper.testFunction(test.equals, testRepo.open, 'Repo::Open'); + helper.testFunction(test.equals, git.Repo.open, 'Repo::Open'); // Test path argument existence helper.testException(test.ok, function() { - testRepo.open(); + git.Repo.open(); }, 'Throw an exception if no path'); // Test callback argument existence helper.testException(test.ok, function() { - testRepo.open('some/path'); + git.Repo.open('some/path'); }, 'Throw an exception if no callback'); // Test invalid repository - testRepo.open('/etc/hosts', function(error) { + git.Repo.open('/etc/hosts', function(error) { test.equals(git.Error.codes.GIT_ERROR, error.klass, 'Invalid repository error code'); // Test valid repository - testRepo.open(path.resolve('../.git'), function(error) { + git.Repo.open(path.resolve('../.git'), function(error, repo) { + test.ok(repo instanceof git.Repo, 'Invocation returns an instance of Repo'); test.equals(null, error, 'Valid repository error code'); test.done(); }); }); }; -// TODO: Figure out how write unit tests for free -// Repo::Free -exports.free = function(test) { - var testRepo = new git.Repo(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testRepo.free, 'Repo::Free'); - - test.done(); -}; - // Repo::Init exports.init = function(test) { - var testRepo = new git.Repo(); - test.expect(7); // Test for function - helper.testFunction(test.equals, testRepo.init, 'Repo::Init'); + helper.testFunction(test.equals, git.Repo.init, 'Repo::Init'); // Test path argument existence helper.testException(test.ok, function() { - testRepo.init(); + git.Repo.init(); }, 'Throw an exception if no path'); // Test is_bare argument existence helper.testException(test.ok, function() { - testRepo.init("some/path"); + git.Repo.init("some/path"); }, 'Throw an exception if no is_bare'); // Test callback argument existence helper.testException(test.ok, function() { - testRepo.init("some/path", true); + git.Repo.init("some/path", true); }, 'Throw an exception if no callback'); // Cleanup, remove test repo directory - if it exists rimraf('./test.git', function() { // Create bare repo and test for creation - testRepo.init('./test.git', true, function(error, path, is_bare) { + git.Repo.init('./test.git', true, function(error, path, is_bare) { test.equals(null, error, 'Successfully created bare repository'); // Verify repo exists - testRepo.open('./test.git', function(error, path) { + git.Repo.open('./test.git', function(error, path) { test.equals(null, error, 'Valid repository created'); - testRepo.free(); - // Cleanup, remove test repo directory rimraf('./test.git', function() { test.done(); diff --git a/test/raw-revwalk.js b/test/raw-revwalk.js index e7338fa32..9aa0bd250 100644 --- a/test/raw-revwalk.js +++ b/test/raw-revwalk.js @@ -2,8 +2,6 @@ var git = require('../').raw, path = require('path'), rimraf = require('rimraf'); -var testRepo = new git.Repo(); - // Helper functions var helper = { // Test if obj is a true function @@ -35,7 +33,7 @@ exports.constructor = function(test){ helper.testFunction(test.equals, git.RevWalk, 'RevWalk'); // Ensure we get an instance of Oid - testRepo.open('../.git', function(error, repository) { + git.Repo.open('../.git', function(error, repository) { test.ok(new git.RevWalk(repository) instanceof git.RevWalk, 'Invocation returns an instance of RevWalk'); test.done(); }); diff --git a/v0.18.0.json b/v0.18.0.json index 8f804466e..d5b1cb19e 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -10150,8 +10150,9 @@ ] }, { - "filename": "repository.h", - "jsClassName": "Repository", + "filename": "repo.h", + "dependencies": [], + "jsClassName": "Repo", "cppClassName": "GitRepo", "cType": "git_repository", "freeFunctionName": "git_repository_free", @@ -10172,7 +10173,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "isFree": false, @@ -10200,6 +10201,7 @@ "jsClassName": "Odb" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -10246,6 +10248,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10286,6 +10289,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -10308,6 +10312,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10338,11 +10343,11 @@ { "name": "is_bare", "cType": "unsigned", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Boolean", + "jsClassName": "Boolean" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "isFree": false, @@ -10376,6 +10381,7 @@ "jsClassName": "RepositoryInitOptions" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -10404,6 +10410,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10426,6 +10433,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10448,6 +10456,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10470,6 +10479,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10548,6 +10558,7 @@ "jsClassName": "int" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10570,6 +10581,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10598,6 +10610,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10626,6 +10639,7 @@ "jsClassName": "Config" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10654,6 +10668,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10682,6 +10697,7 @@ "jsClassName": "Odb" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10710,6 +10726,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10738,6 +10755,7 @@ "jsClassName": "Refdb" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10766,6 +10784,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10794,6 +10813,7 @@ "jsClassName": "Index" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10828,6 +10848,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -10850,6 +10871,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10872,6 +10894,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10906,6 +10929,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10940,6 +10964,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -10986,6 +11011,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -11014,6 +11040,7 @@ "jsClassName": "const" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -11042,6 +11069,7 @@ "jsClassName": "const" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -11064,6 +11092,7 @@ "jsClassName": "Repository*" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -11086,6 +11115,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, From 707675a296b1d1c833eefae8d99d8592b8573648 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sat, 22 Jun 2013 18:49:02 +0200 Subject: [PATCH 04/28] Reference is now code-gen'd --- gen.js | 2 +- include/blob.h | 2 +- include/reference.h | 70 +-- include/repo.h | 4 +- lib/reference.js | 48 +- lib/repo.js | 22 +- munge.js | 23 +- src/blob.cc | 88 ++-- src/oid.cc | 20 +- src/reference.cc | 309 +++++++++---- src/repo.cc | 39 +- templates/class.cc.ejs | 154 ++++--- templates/header.h.ejs | 14 +- test/raw-blob.js | 3 +- test/raw-reference.js | 15 +- v0.18.0.json | 996 +++++++++++++++++++++++++++-------------- 16 files changed, 1126 insertions(+), 683 deletions(-) diff --git a/gen.js b/gen.js index 0cbdd4998..128ec56bd 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/blob.h b/include/blob.h index 9628f5fd2..79b10f5ef 100755 --- a/include/blob.h +++ b/include/blob.h @@ -35,7 +35,7 @@ class GitBlob : public ObjectWrap { struct LookupBaton { uv_work_t request; const git_error* error; - git_blob *out; + git_blob * blob; git_repository * repo; const git_oid * id; Persistent callback; diff --git a/include/reference.h b/include/reference.h index 4f28bcca4..88b4c9d0e 100644 --- a/include/reference.h +++ b/include/reference.h @@ -1,12 +1,9 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef REF_H -#define REF_H +#ifndef GITREFERENCE_H +#define GITREFERENCE_H #include #include @@ -14,59 +11,62 @@ #include "git2.h" -#include "repo.h" -#include "oid.h" - using namespace node; using namespace v8; class GitReference : public ObjectWrap { public: - const git_oid* Oid(); + static Persistent constructor_template; - static void Initialize(Handle target); + static void Initialize (Handle target); - git_reference* GetValue(); - void SetValue(git_reference* ref); + git_reference *GetValue(); - protected: - GitReference() {} - ~GitReference() {} - static Handle New(const Arguments& args); + private: + GitReference(git_reference *raw); + ~GitReference(); - static Handle Oid(const Arguments& args); - static void OidWork(uv_work_t* req); - static void OidAfterWork(uv_work_t* req); + static Handle New(const Arguments& args); static Handle Lookup(const Arguments& args); static void LookupWork(uv_work_t* req); static void LookupAfterWork(uv_work_t* req); - - private: - git_reference *ref; - struct LookupBaton { uv_work_t request; const git_error* error; - - GitReference* ref; - git_reference* rawRef; - git_repository* rawRepo; - std::string name; - + git_reference * out; + git_repository * repo; + const char * name; Persistent callback; }; + static Handle OidForName(const Arguments& args); + static void OidForNameWork(uv_work_t* req); + static void OidForNameAfterWork(uv_work_t* req); - struct OidBaton { + struct OidForNameBaton { uv_work_t request; const git_error* error; + git_oid * out; + git_repository * repo; + const char * name; + Persistent callback; + }; + static Handle Oid(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Resolve(const Arguments& args); + static void ResolveWork(uv_work_t* req); + static void ResolveAfterWork(uv_work_t* req); - const git_oid* rawOid; - git_reference* rawRef; - + struct ResolveBaton { + uv_work_t request; + const git_error* error; + git_reference * out; + const git_reference * ref; Persistent callback; }; + git_reference *raw; }; #endif diff --git a/include/repo.h b/include/repo.h index 2b3a6d70d..36a47d546 100755 --- a/include/repo.h +++ b/include/repo.h @@ -35,7 +35,7 @@ class GitRepo : public ObjectWrap { struct OpenBaton { uv_work_t request; const git_error* error; - git_repository *out; + git_repository * out; const char * path; Persistent callback; }; @@ -46,7 +46,7 @@ class GitRepo : public ObjectWrap { struct InitBaton { uv_work_t request; const git_error* error; - git_repository *out; + git_repository * out; const char * path; unsigned is_bare; Persistent callback; diff --git a/lib/reference.js b/lib/reference.js index 51e7d5a2f..a2bb45e80 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -8,17 +8,16 @@ var git = require('../'), * @param {git.raw.Repo} rawRepo * @param {git.raw.Reference} [rawReference = new git.raw.Reference()] */ -var Reference = function(rawRepo, rawReference) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Reference must be a raw repo'); +var Reference = function(rawReference) { + if (!(rawReference instanceof git.raw.Reference)) { + throw new git.error('First parameter for Reference must be a raw reference'); } - this.rawRepo = rawRepo; + this.rawReference = rawReference; +}; - if (rawReference instanceof git.raw.Reference) { - this.rawReference = rawReference; - } else { - this.rawReference = new git.raw.Reference(this.rawRepo); - } +Reference.Type = { + Oid: 0, + Symbolic: 1 }; /** @@ -27,38 +26,31 @@ var Reference = function(rawRepo, rawReference) { * @param {String} name * @param {Reference~lookupCallback} callback */ -Reference.prototype.lookup = function(name, callback) { +Reference.lookup = function(rawRepo, name, callback) { /** * @callback Reference~lookupCallback Callback executed on lookup completion. * @param {GitError|null} error An Error or null if successful. * @param {Reference|null} reference Retrieved reference object or null. */ var self = this; - self.rawReference.lookup(self.rawRepo, name, function referenceLookup(error, rawReference) { - if (!success(error, callback)) { - return; + git.raw.Reference.lookup(rawRepo, name, function referenceLookup(error, rawReference) { + if (rawReference.type() == Reference.Type.Symbolic) { + rawReference.resolve(function referenceResolve(error, rawReference) { + if (!success(error, callback)) return; + callback(null, new Reference(rawReference)); + }); + } else { + if (!success(error, callback)) return; + callback(null, new Reference(rawReference)); } - self.rawReference = rawReference; - callback(null, self); }); }; /** * Get the Oid representing this reference. - * - * @param {Reference~oidCallback} callback */ -Reference.prototype.oid = function(callback) { - /** - * @callback Reference~oidCallback Callback executed on oid retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Oid|null} oid Retrieved Oid object or null. - */ - this.rawReference.oid(function referenceOid(error, rawOid) { - if (success(error, callback)) { - callback(null, new git.oid(rawOid)); - } - }); +Reference.prototype.oid = function() { + return this.rawReference.oid(); }; exports.reference = Reference; diff --git a/lib/repo.js b/lib/repo.js index f001991f0..8ad2156bd 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -48,20 +48,14 @@ Repo.prototype.branch = function(name, callback) { * @param {Commit|null} repo HEAD commit for the branch. */ var self = this; - (new git.reference(self.rawRepo)).lookup('refs/heads/' + name, function referenceLookupCallback(error, reference) { - if (!success(error, callback)) { - return; - } - reference.oid(function oidCallback(error, oid) { - if (!success(error, callback)) { - return; - } - self.commit(oid, function commitLookupCallback(error, commit) { - if (!success(error, callback)) { - return; - } - callback(null, commit); - }); + git.reference.lookup(this.rawRepo, 'refs/heads/' + name, function referenceLookupCallback(error, reference) { + if (!success(error, callback)) return; + + var oid = reference.oid(); + self.commit(oid, function commitLookupCallback(error, commit) { + if (!success(error, callback)) return; + + callback(null, commit); }); }); }; diff --git a/munge.js b/munge.js index 8c29468c1..97d76a3cd 100644 --- a/munge.js +++ b/munge.js @@ -2,21 +2,6 @@ var fs = require('fs'), _ = require('underscore'), path = require('path'); -var DOUBLE_POINTER_RE = /\*\*$/; -var OUT_VAR_RE = /_out$/; -function isConstructorMethod(cType, functionInfo) { - if (!functionInfo.args.length) return false; - var firstArg = functionInfo.args[0]; - return RegExp(cType + " \\*\\*$").test(firstArg.cType) && !isPrototypeMethod(cType, functionInfo) && !/_free$/.test(functionInfo.cFunctionName); -} - -function isPrototypeMethod(cType, functionInfo) { - if (!functionInfo.args.length) return false; - - var firstArg = functionInfo.args[0]; - return RegExp(cType + " \\*$").test(firstArg.cType) && !/_free$/.test(functionInfo.cFunctionName); -} - var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')); for (var i in idefs) { @@ -24,12 +9,8 @@ for (var i in idefs) { for (var j in idef.functions) { var fn = idef.functions[j]; - var old1 = fn.isPrototypeMethod; - var old2 = fn.isConstructorMethod; - fn.isPrototypeMethod = isPrototypeMethod(idef.cType, fn); - fn.isConstructorMethod = isConstructorMethod(idef.cType, fn); - fn.isFree = /_free$/.test(fn.cFunctionName); - + if (!fn.isConstructorMethod) continue; + fn.args[0].isReturn = true; } } console.log(JSON.stringify(idefs, null, 2)); diff --git a/src/blob.cc b/src/blob.cc index 5268df775..ebecae642 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -8,7 +8,6 @@ #include "git2.h" #include "../include/blob.h" - #include "../include/repo.h" #include "../include/oid.h" #include "../include/wrapper.h" @@ -69,10 +68,10 @@ git_blob *GitBlob::GetValue() { Handle GitBlob::Lookup(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository is required."))); } - if(args.Length() == 1 || !args[1]->IsObject()) { + if (args.Length() == 1 || !args[1]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { @@ -82,7 +81,12 @@ Handle GitBlob::Lookup(const Arguments& args) { LookupBaton* baton = new LookupBaton; baton->error = NULL; baton->request.data = baton; + + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -94,7 +98,7 @@ Handle GitBlob::Lookup(const Arguments& args) { void GitBlob::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); int result = git_blob_lookup( - &baton->out, + &baton->blob, baton->repo, baton->id ); @@ -109,8 +113,9 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle object = constructor_template->NewInstance(1, argv); + + Handle argv[1] = { External::New(baton->blob) }; + Handle object = GitBlob::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), object @@ -134,41 +139,32 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; - - git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * result = git_blob_id( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } Handle GitBlob::Content(const Arguments& args) { HandleScope scope; - - git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - const void * result = git_blob_rawcontent( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; - return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); + return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); } Handle GitBlob::Size(const Arguments& args) { HandleScope scope; - - git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - git_off_t result = git_blob_rawsize( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); return scope.Close(Number::New(result)); @@ -177,28 +173,27 @@ Handle GitBlob::Size(const Arguments& args) { Handle GitBlob::CreateFromFile(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required."))); - } - if(args.Length() == 1 || !args[1]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository is required."))); } - if(args.Length() == 2 || !args[2]->IsString()) { + if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String is required."))); } - if (args.Length() == 3 || !args[3]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateFromFileBaton* baton = new CreateFromFileBaton; baton->error = NULL; baton->request.data = baton; - baton->id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - String::Utf8Value str2(args[2]->ToString()); - baton->path = strdup(*str2); - baton->callback = Persistent::New(Local::Cast(args[3])); + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value path(args[1]->ToString()); + // XXX FIXME remove strdup and use std::string + baton->path = strdup(*path); + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); @@ -223,8 +218,10 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { + Handle argv[1] = { External::New(baton->id) }; Handle object = GitOid::constructor_template->NewInstance(1, argv); + // free((void *) baton->path); Handle argv2[2] = { Local::New(Null()), object @@ -250,30 +247,29 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { Handle GitBlob::CreateFromBuffer(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required."))); - } - if(args.Length() == 1 || !args[1]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository is required."))); } - if(args.Length() == 2 || !args[2]->IsObject()) { + if (args.Length() == 1 || !args[1]->IsObject()) { return ThrowException(Exception::Error(String::New("Buffer is required."))); } - if(args.Length() == 3 || !args[3]->IsNumber()) { + if (args.Length() == 2 || !args[2]->IsNumber()) { return ThrowException(Exception::Error(String::New("Number is required."))); } - if (args.Length() == 4 || !args[4]->IsFunction()) { + if (args.Length() == 3 || !args[3]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateFromBufferBaton* baton = new CreateFromBufferBaton; baton->error = NULL; baton->request.data = baton; - baton->oid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[2]->ToObject())); - baton->len = args[3]->ToNumber()->Value(); - baton->callback = Persistent::New(Local::Cast(args[4])); + + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[1]->ToObject())); + baton->len = args[2]->ToNumber()->Value(); + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromBufferWork, (uv_after_work_cb)CreateFromBufferAfterWork); @@ -299,6 +295,7 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { + Handle argv[1] = { External::New(baton->oid) }; Handle object = GitOid::constructor_template->NewInstance(1, argv); Handle argv2[2] = { @@ -324,11 +321,8 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; - - git_blob *in = ObjectWrap::Unwrap(args.This())->GetValue(); - int result = git_blob_is_binary( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { diff --git a/src/oid.cc b/src/oid.cc index 7c660e910..a93cbcca6 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -9,7 +9,6 @@ #include "../include/oid.h" - #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -60,33 +59,30 @@ git_oid *GitOid::GetValue() { Handle GitOid::FromString(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String is required."))); } - - git_oid * out = (git_oid *)malloc(sizeof(git_oid)); + git_oid * out; + out = (git_oid *)malloc(sizeof(git_oid)); int result = git_oid_fromstr( - out, - stringArgToString(args[0]->ToString()).c_str() - + out +, stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; - return scope.Close(constructor_template->NewInstance(1, argv)); + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } Handle GitOid::Sha(const Arguments& args) { HandleScope scope; - - git_oid *in = ObjectWrap::Unwrap(args.This())->GetValue(); - char * result = git_oid_allocfmt( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); return scope.Close(String::New(result)); diff --git a/src/reference.cc b/src/reference.cc index f520a24f6..2e17a8c7d 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -1,28 +1,31 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include -#include +#include #include "git2.h" -#include "../include/repo.h" #include "../include/reference.h" +#include "../include/repo.h" #include "../include/oid.h" -#include "../include/error.h" -#include "../include/functions/string.h" #include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -void GitReference::Initialize(Handle target) { +GitReference::GitReference(git_reference *raw) { + this->raw = raw; +} + +GitReference::~GitReference() { + git_reference_free(this->raw); +} + +void GitReference::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -30,152 +33,272 @@ void GitReference::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Reference")); + NODE_SET_METHOD(tpl, "lookup", Lookup); + NODE_SET_METHOD(tpl, "oidForName", OidForName); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "resolve", Resolve); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Reference"), constructor_template); } -git_reference* GitReference::GetValue() { - return this->ref; -} -void GitReference::SetValue(git_reference *ref) { - this->ref = ref; -} - Handle GitReference::New(const Arguments& args) { HandleScope scope; - GitReference *ref = new GitReference(); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_reference is required."))); + } + + GitReference* object = new GitReference((git_reference *) External::Unwrap(args[0])); + object->Wrap(args.This()); - ref->Wrap(args.This()); + return scope.Close(args.This()); +} - return args.This(); +git_reference *GitReference::GetValue() { + return this->raw; } -Handle GitReference::Oid(const Arguments& args) { + +Handle GitReference::Lookup(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String is required."))); + } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - OidBaton *baton = new OidBaton; - baton->request.data = baton; + LookupBaton* baton = new LookupBaton; baton->error = NULL; - baton->rawOid = NULL; - baton->rawRef = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + baton->request.data = baton; - uv_queue_work(uv_default_loop(), &baton->request, OidWork, (uv_after_work_cb)OidAfterWork); + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value name(args[1]->ToString()); + // XXX FIXME remove strdup and use std::string + baton->name = strdup(*name); + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); return Undefined(); } -void GitReference::OidWork(uv_work_t* req) { - OidBaton *baton = static_cast(req->data); - git_ref_t referenceType = git_reference_type(baton->rawRef); - - if (referenceType == GIT_REF_INVALID) { - giterr_set_str(GITERR_INVALID, "Invalid reference type"); +void GitReference::LookupWork(uv_work_t *req) { + LookupBaton *baton = static_cast(req->data); + int result = git_reference_lookup( + &baton->out, + baton->repo, + baton->name + ); + if (result != GIT_OK) { baton->error = giterr_last(); - return; } +} - if (referenceType == GIT_REF_SYMBOLIC) { - int returnCode = git_reference_resolve(&baton->rawRef, baton->rawRef); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } +void GitReference::LookupAfterWork(uv_work_t *req) { + HandleScope scope; + LookupBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle argv[1] = { External::New(baton->out) }; + Handle object = GitReference::constructor_template->NewInstance(1, argv); + // free((void *) baton->name); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - baton->rawOid = git_reference_target(baton->rawRef); + baton->callback.Dispose(); + + delete baton->name; + delete baton; } -void GitReference::OidAfterWork(uv_work_t* req) { + +Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; - OidBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - git_oid *rawOid = (git_oid *)malloc(sizeof(git_oid)); - git_oid_cpy(rawOid, baton->rawOid); - Handle argv[1] = { External::New((void *)rawOid) }; - Handle oid = GitOid::constructor_template->NewInstance(1, argv); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String is required."))); + } + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + OidForNameBaton* baton = new OidForNameBaton; + baton->error = NULL; + baton->request.data = baton; + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value name(args[1]->ToString()); + // XXX FIXME remove strdup and use std::string + baton->name = strdup(*name); + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, OidForNameWork, (uv_after_work_cb)OidForNameAfterWork); + + return Undefined(); +} + +void GitReference::OidForNameWork(uv_work_t *req) { + OidForNameBaton *baton = static_cast(req->data); + int result = git_reference_name_to_id( + baton->out, + baton->repo, + baton->name + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitReference::OidForNameAfterWork(uv_work_t *req) { + HandleScope scope; + OidForNameBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle argv[1] = { External::New(baton->out) }; + Handle object = GitOid::constructor_template->NewInstance(1, argv); + // free((void *) baton->name); Handle argv2[2] = { Local::New(Null()), - oid + object }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->callback.Dispose(); + + delete baton->name; + delete baton; } -Handle GitReference::Lookup(const Arguments& args) { +Handle GitReference::Oid(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be a Object."))); - } + const git_oid * result = git_reference_target( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - if(args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("Name is required and must be a String."))); - } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} + +Handle GitReference::Name(const Arguments& args) { + HandleScope scope; - if(args.Length() == 2 || !args[2]->IsFunction()) { + const char * result = git_reference_symbolic_target( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(String::New(result)); +} + +Handle GitReference::Type(const Arguments& args) { + HandleScope scope; + + git_ref_t result = git_reference_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(Number::New(result)); +} + +Handle GitReference::Resolve(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - LookupBaton *baton = new LookupBaton; - baton->request.data = baton; - baton->ref = ObjectWrap::Unwrap(args.This()); - baton->ref->Ref(); + ResolveBaton* baton = new ResolveBaton; baton->error = NULL; - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->name = stringArgToString(args[1]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); + baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ResolveWork, (uv_after_work_cb)ResolveAfterWork); return Undefined(); } -void GitReference::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - baton->rawRef = NULL; - int returnCode = git_reference_lookup(&baton->rawRef, baton->rawRepo, baton->name.c_str()); - if (returnCode != GIT_OK) { +void GitReference::ResolveWork(uv_work_t *req) { + ResolveBaton *baton = static_cast(req->data); + int result = git_reference_resolve( + &baton->out, + baton->ref + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitReference::LookupAfterWork(uv_work_t *req) { + +void GitReference::ResolveAfterWork(uv_work_t *req) { HandleScope scope; - LookupBaton *baton = static_cast(req->data); + ResolveBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - baton->ref->SetValue(baton->rawRef); + TryCatch try_catch; + if (!baton->error) { - Handle argv[2] = { + Handle argv[1] = { External::New(baton->out) }; + Handle object = GitReference::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { Local::New(Null()), - baton->ref->handle_ + object }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - baton->ref->Unref(); - delete req; + baton->callback.Dispose(); + delete baton; } Persistent GitReference::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 895d4d278..1fc60d3a4 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -9,7 +9,6 @@ #include "../include/repo.h" - #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -62,7 +61,7 @@ git_repository *GitRepo::GetValue() { Handle GitRepo::Open(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { @@ -73,8 +72,9 @@ Handle GitRepo::Open(const Arguments& args) { baton->error = NULL; baton->request.data = baton; - String::Utf8Value str0(args[0]->ToString()); - baton->path = strdup(*str0); + String::Utf8Value path(args[0]->ToString()); + // XXX FIXME remove strdup and use std::string + baton->path = strdup(*path); baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); @@ -85,7 +85,7 @@ Handle GitRepo::Open(const Arguments& args) { void GitRepo::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); int result = git_repository_open( - &baton->out, + &baton->out, baton->path ); if (result != GIT_OK) { @@ -99,8 +99,10 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; - Handle object = constructor_template->NewInstance(1, argv); + Handle object = GitRepo::constructor_template->NewInstance(1, argv); + // free((void *) baton->path); Handle argv2[2] = { Local::New(Null()), object @@ -126,10 +128,10 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { Handle GitRepo::Init(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String is required."))); } - if(args.Length() == 1 || !args[1]->IsBoolean()) { + if (args.Length() == 1 || !args[1]->IsBoolean()) { return ThrowException(Exception::Error(String::New("Boolean is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { @@ -140,8 +142,9 @@ Handle GitRepo::Init(const Arguments& args) { baton->error = NULL; baton->request.data = baton; - String::Utf8Value str0(args[0]->ToString()); - baton->path = strdup(*str0); + String::Utf8Value path(args[0]->ToString()); + // XXX FIXME remove strdup and use std::string + baton->path = strdup(*path); baton->is_bare = args[1]->ToBoolean()->Value(); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -153,7 +156,7 @@ Handle GitRepo::Init(const Arguments& args) { void GitRepo::InitWork(uv_work_t *req) { InitBaton *baton = static_cast(req->data); int result = git_repository_init( - &baton->out, + &baton->out, baton->path, baton->is_bare ); @@ -168,8 +171,10 @@ void GitRepo::InitAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; - Handle object = constructor_template->NewInstance(1, argv); + Handle object = GitRepo::constructor_template->NewInstance(1, argv); + // free((void *) baton->path); Handle argv2[2] = { Local::New(Null()), object @@ -195,11 +200,8 @@ void GitRepo::InitAfterWork(uv_work_t *req) { Handle GitRepo::Path(const Arguments& args) { HandleScope scope; - - git_repository *in = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * result = git_repository_path( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); return scope.Close(String::New(result)); @@ -208,11 +210,8 @@ Handle GitRepo::Path(const Arguments& args) { Handle GitRepo::Workdir(const Arguments& args) { HandleScope scope; - - git_repository *in = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * result = git_repository_workdir( - in + ObjectWrap::Unwrap(args.This())->GetValue() ); return scope.Close(String::New(result)); diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 939e1a0c6..52078561c 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -20,7 +20,6 @@ #include "git2.h" #include "../include/<%= filename %>" - <% for (d in dependencies) { -%> #include "<%- dependencies[d] %>" <% } -%> @@ -91,42 +90,50 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg HandleScope scope; <% - var offset = functionInfo.isPrototypeMethod || functionInfo.isConstructorMethod ? 1 : 0; - for (var i = 0; i < functionInfo.args.length - offset; i++) { - var arg = functionInfo.args[i + offset]; + for (var i = 0, j = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn || arg.isSelf) continue; -%> - if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { + if (args.Length() == <%- j %> || !args[<%- j %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); } -<% } -%> - if (args.Length() == <%- i %> || !args[<%- i %>]->IsFunction()) { +<% + j++; + } +-%> + if (args.Length() == <%- j %> || !args[<%- j %>]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } <%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; baton->error = NULL; baton->request.data = baton; -<% if (functionInfo.isConstructorMethod) { -%> -<% } else if (functionInfo.isPrototypeMethod) { -%> - <%- cppClassName %> object = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This()); - baton->in = object::GetValue(); -<% } -%> <% - for (var i = offset; i < functionInfo.args.length; i++) { + for (var i = 0, j = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> -<% if (arg.cppClassName == 'String') { %> - String::Utf8Value str<%- i - offset%>(args[<%- i - offset%>]->ToString()); - baton-><%- arg.name %> = strdup(*str<%- i - offset%>); +<% if (arg.isSelf) { -%> + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); +<% } else if (arg.isReturn) { -%> + +<% } else if (arg.cppClassName == 'String') { -%> + String::Utf8Value <%- arg.name %>(args[<%- j %>]->ToString()); + // XXX FIXME remove strdup and use std::string + baton-><%- arg.name %> = strdup(*<%- arg.name %>); <% } else if (arg.cppClassName == 'Buffer') { -%> - baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())); + baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())); <% } else if (isPrimitive(arg.cppClassName)) { -%> - baton-><%- arg.name %> = args[<%- i - offset%>]->To<%- arg.cppClassName %>()->Value(); + baton-><%- arg.name %> = args[<%- j %>]->To<%- arg.cppClassName %>()->Value(); <% } else { -%> - baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->GetValue(); + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())->GetValue(); <% } -%> -<% } -%> - baton->callback = Persistent::New(Local::Cast(args[<%- i - offset %>])); +<% + if (!(arg.isReturn || arg.isSelf)) j++; + } +-%> + baton->callback = Persistent::New(Local::Cast(args[<%- j %>])); uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); @@ -136,13 +143,11 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( -<% if (functionInfo.isConstructorMethod) { -%> - &baton->out<% if (functionInfo.args.length - offset > 0) { %>,<% } %> -<% } else if (functionInfo.isPrototypeMethod) { -%> - baton->in<% if (functionInfo.args.length - offset > 0) { %>,<% } %> -<% } -%> -<% for (var i = offset; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> - baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> + <% if (/\*\*/.test(arg.cType)) { %>&<% } %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> <% } -%> ); <% if (functionInfo.return.isErrorCode) { -%> @@ -160,12 +165,17 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t TryCatch try_catch; if (!baton->error) { -<% if (functionInfo.isConstructorMethod) { -%> - Handle argv[1] = { External::New(baton->out) }; - Handle object = constructor_template->NewInstance(1, argv); -<% } else { -%> - Handle argv[1] = { External::New(baton-><%- functionInfo.args[0].name %>) }; - Handle object = <%- functionInfo.args[0].cppClassName %>::constructor_template->NewInstance(1, argv); +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> +<% if (arg.cppClassName == 'String') { -%> + // free((void *) baton-><%- arg.name %>); +<% } -%> +<% if (arg.isReturn) { %> + Handle argv[1] = { External::New(baton-><%- arg.name %>) }; + Handle object = <%- arg.cppClassName %>::constructor_template->NewInstance(1, argv); +<% } -%> <% } -%> Handle argv2[2] = { Local::New(Null()), @@ -185,7 +195,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t baton->callback.Dispose(); <% - for (var i = offset; i < functionInfo.args.length; i++) { + for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> <% if (arg.cppClassName == 'String') { %> @@ -197,33 +207,49 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t <% } else { -%> Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; - <% - var offset = functionInfo.isPrototypeMethod || functionInfo.isConstructorMethod ? 1 : 0; - for (var i = 0; i < functionInfo.args.length - offset; i++) { - var arg = functionInfo.args[i + offset]; + for (var i = 0, j = 0; i < functionInfo.args.length ; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn || arg.isSelf) continue; -%> - if(args.Length() == <%- i %> || !args[<%- i %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { + + if (args.Length() == <%- j %> || !args[<%- j %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); } +<% + j++; + } +-%> +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (!arg.isReturn) continue; +-%> + <%- arg.cType %> <%- arg.name %>; +<% if (arg.shouldAlloc) { -%> + <%- arg.name %> = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); <% } -%> - -<% if (functionInfo.isConstructorMethod) { -%> - <%- functionInfo.args[0].cType %> out = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); -<% } else if (functionInfo.isPrototypeMethod) { -%> - <%- cType %> *in = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); <% } -%> <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( - <% if (functionInfo.isConstructorMethod) { %>out<% } else if (functionInfo.isPrototypeMethod) { -%>in<% } -%><% if (functionInfo.args.length - offset > 0) { %>,<% } %> -<% for (var i = offset; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> -<% if (arg.cppClassName == 'String') { %> - stringArgToString(args[<%- i - offset%>]->ToString()).c_str() +<% + for (var i = 0, j = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> +<% if (arg.isSelf) { -%> + ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() +<% } else if (arg.isReturn) { -%> + <%- arg.name %> +<% } else if (arg.cppClassName == 'String') { -%> + stringArgToString(args[<%- j %>]->ToString()).c_str() <% } else { -%> - ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- i - offset%>]->ToObject())->GetValue() + ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())->GetValue() <% } -%> <% if (i < functionInfo.args.length - 1) { %>, <% } -%> -<% } %> +<% + if (!(arg.isReturn || arg.isSelf)) j++; + } +-%> ); <% if (functionInfo.return.isErrorCode) { -%> @@ -231,19 +257,25 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg return ThrowException(Exception::Error(String::New(giterr_last()->message))); } <% } -%> -<% if (functionInfo.isConstructorMethod) { -%> - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(constructor_template->NewInstance(1, argv)); -<% } else if (functionInfo.return.cType == "void") { -%> +<% + var result = null; + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn) result = arg; + } + if (!result) result = functionInfo.return; + var resultName = result.name || 'result'; +-%> +<% if (result.cType == "void") { -%> return Undefined(); -<% } else if (isPrimitive(functionInfo.return.cppClassName)) { -%> - return scope.Close(<%- functionInfo.return.cppClassName %>::New(result)); -<% } else if (functionInfo.return.cppClassName == "External") { -%> - return scope.Close(External::New((void *)result)); +<% } else if (isPrimitive(result.cppClassName)) { -%> + return scope.Close(<%- result.cppClassName %>::New(<%- resultName %>)); +<% } else if (result.cppClassName == "External") { -%> + return scope.Close(External::New((void *)<%- resultName %>)); <% } else { -%> // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(<%- functionInfo.return.cppClassName %>::constructor_template->NewInstance(1, argv)); + Handle argv[1] = { External::New((void *)<%- resultName %>) }; + return scope.Close(<%- result.cppClassName %>::constructor_template->NewInstance(1, argv)); <% } -%> } <% } -%> diff --git a/templates/header.h.ejs b/templates/header.h.ejs index a8cd94aee..1118d28c3 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -41,17 +41,15 @@ class <%- cppClassName %> : public ObjectWrap { struct <%- functionInfo.cppFunctionName %>Baton { uv_work_t request; const git_error* error; -<% if (functionInfo.isConstructorMethod) { -%> - <%- cType %> *out; -<% } else if (functionInfo.isPrototypeMethod) { -%> - <%- cType %> *in; -<% } -%> <% - var offset = functionInfo.isPrototypeMethod || functionInfo.isConstructorMethod ? 1 : 0; - for (var i = 0; i < functionInfo.args.length - offset; i++) { - var arg = functionInfo.args[i + offset]; + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; -%> +<% if (arg.isReturn) { -%> + <%- arg.cType.replace('**', '*') %> <%- arg.name %>; +<% } else { -%> <%- arg.cType %> <%- arg.name %>; +<% } -%> <% } -%> Persistent callback; }; diff --git a/test/raw-blob.js b/test/raw-blob.js index 34824cb34..59b04dd79 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -36,9 +36,8 @@ exports.constructor = function(test){ exports.lookup = function(test) { test.expect(5); var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); - git.Repo.open('../.git', function(error, repo) { - var testRef = new git.Reference(repo); + git.Repo.open('../.git', function(error, repo) { // Test for function helper.testFunction(test.equals, git.Blob.lookup, 'Blob::Lookup'); diff --git a/test/raw-reference.js b/test/raw-reference.js index dd520426c..2d21ad4b3 100644 --- a/test/raw-reference.js +++ b/test/raw-reference.js @@ -24,41 +24,36 @@ var helper = { // Ref exports.constructor = function(test){ - test.expect(3); + test.expect(2); // Test for function helper.testFunction(test.equals, git.Reference, 'Reference'); - // Ensure we get an instance of Ref - test.ok(new git.Reference() instanceof git.Reference, 'Invocation returns an instance of Ref'); - test.done(); }; // Ref::Lookup exports.lookup = function(test) { - var master = new git.Reference(); - test.expect(5); // Test for function - helper.testFunction(test.equals, master.lookup, 'Ref::Lookup'); + helper.testFunction(test.equals, git.Reference.lookup, 'Ref::Lookup'); // Test repo argument existence helper.testException(test.ok, function() { - master.lookup(); + git.Reference.lookup(); }, 'Throw an exception if no repo'); git.Repo.open('../.git', function(error, repo) { // Test name argument existence helper.testException(test.ok, function() { - master.lookup(repo); + git.Reference.lookup(repo); }, 'Throw an exception if no name'); // Test callback argument existence helper.testException(test.ok, function() { - master.lookup(repo, 'refs/heads/master'); + git.Reference.lookup(repo, 'refs/heads/master'); }, 'Throw an exception if no callback'); // Cleanup, remove test repo directory - if it exists diff --git a/v0.18.0.json b/v0.18.0.json index d5b1cb19e..9a5163246 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -210,7 +210,12 @@ }, { "filename": "blob.h", - "dependencies": ["../include/repo.h", "../include/oid.h", "../include/wrapper.h", "node_buffer.h"], + "dependencies": [ + "../include/repo.h", + "../include/oid.h", + "../include/wrapper.h", + "node_buffer.h" + ], "jsClassName": "Blob", "cppClassName": "GitBlob", "cType": "git_blob", @@ -223,7 +228,8 @@ "name": "blob", "cType": "git_blob **", "cppClassName": "GitBlob", - "jsClassName": "Blob" + "jsClassName": "Blob", + "isReturn": true }, { "name": "repo", @@ -257,7 +263,8 @@ "name": "blob", "cType": "git_blob **", "cppClassName": "GitBlob", - "jsClassName": "Blob" + "jsClassName": "Blob", + "isReturn": true }, { "name": "repo", @@ -321,7 +328,8 @@ "name": "blob", "cType": "const git_blob *", "cppClassName": "GitBlob", - "jsClassName": "Blob" + "jsClassName": "Blob", + "isSelf": true } ], "isAsync": false, @@ -343,7 +351,8 @@ "name": "blob", "cType": "const git_blob *", "cppClassName": "GitBlob", - "jsClassName": "Blob" + "jsClassName": "Blob", + "isSelf": true } ], "isAsync": false, @@ -365,7 +374,8 @@ "name": "blob", "cType": "const git_blob *", "cppClassName": "GitBlob", - "jsClassName": "Blob" + "jsClassName": "Blob", + "isSelf": true } ], "isAsync": false, @@ -422,7 +432,8 @@ "name": "id", "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isReturn": true }, { "name": "repo", @@ -503,7 +514,8 @@ "name": "oid", "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isReturn": true }, { "name": "repo", @@ -543,7 +555,8 @@ "name": "blob", "cType": "git_blob *", "cppClassName": "GitBlob", - "jsClassName": "Blob" + "jsClassName": "Blob", + "isSelf": true } ], "isAsync": false, @@ -572,8 +585,9 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -619,7 +633,7 @@ { "name": "branch", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], @@ -680,14 +694,15 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { "name": "branch", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -720,8 +735,9 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -760,6 +776,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "const char **", "cppClassName": "String", "jsClassName": "char" @@ -767,7 +784,7 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], @@ -788,14 +805,15 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { "name": "branch", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], @@ -817,7 +835,7 @@ { "name": "branch", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -885,7 +903,7 @@ { "name": "branch", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], @@ -1060,6 +1078,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_repository **", "cppClassName": "GitRepo", "jsClassName": "Repository" @@ -1111,7 +1130,8 @@ "name": "commit", "cType": "git_commit **", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isReturn": true }, { "name": "repo", @@ -1145,7 +1165,8 @@ "name": "commit", "cType": "git_commit **", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isReturn": true }, { "name": "repo", @@ -1207,7 +1228,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1229,7 +1251,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1251,7 +1274,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1273,7 +1297,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1295,7 +1320,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1317,7 +1343,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1339,7 +1366,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1389,7 +1417,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1411,7 +1440,8 @@ "name": "commit", "cType": "const git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true } ], "isAsync": false, @@ -1431,6 +1461,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_commit **", "cppClassName": "Commit", "jsClassName": "Commit" @@ -1467,7 +1498,8 @@ "name": "commit", "cType": "git_commit *", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isSelf": true }, { "name": "n", @@ -1495,7 +1527,8 @@ "name": "ancestor", "cType": "git_commit **", "cppClassName": "Commit", - "jsClassName": "Commit" + "jsClassName": "Commit", + "isReturn": true }, { "name": "commit", @@ -1756,6 +1789,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -1784,6 +1818,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -1812,6 +1847,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -1840,6 +1876,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_config **", "cppClassName": "Config", "jsClassName": "Config" @@ -1862,6 +1899,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_config **", "cppClassName": "Config", "jsClassName": "Config" @@ -1886,7 +1924,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "file", @@ -1926,7 +1965,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "path", @@ -1964,6 +2004,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_config **", "cppClassName": "Config", "jsClassName": "Config" @@ -1992,6 +2033,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_config **", "cppClassName": "Config", "jsClassName": "Config" @@ -2028,7 +2070,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true } ], "isAsync": false, @@ -2070,6 +2113,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "const git_config_entry **", "cppClassName": "ConfigEntry", "jsClassName": "ConfigEntry" @@ -2104,6 +2148,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int32_t *", "cppClassName": "int32_t", "jsClassName": "int32_t" @@ -2138,6 +2183,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int64_t *", "cppClassName": "int64_t", "jsClassName": "int64_t" @@ -2172,6 +2218,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int *", "cppClassName": "int", "jsClassName": "int" @@ -2206,6 +2253,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "const char **", "cppClassName": "String", "jsClassName": "char" @@ -2242,7 +2290,8 @@ "name": "cfg", "cType": "const git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2288,7 +2337,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2322,7 +2372,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2356,7 +2407,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2390,7 +2442,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2424,7 +2477,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2464,7 +2518,8 @@ "name": "cfg", "cType": "git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "name", @@ -2492,7 +2547,8 @@ "name": "cfg", "cType": "const git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "callback", @@ -2526,7 +2582,8 @@ "name": "cfg", "cType": "const git_config *", "cppClassName": "Config", - "jsClassName": "Config" + "jsClassName": "Config", + "isSelf": true }, { "name": "regexp", @@ -2564,6 +2621,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int *", "cppClassName": "int", "jsClassName": "int" @@ -2610,6 +2668,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int *", "cppClassName": "int", "jsClassName": "int" @@ -2650,6 +2709,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int *", "cppClassName": "int", "jsClassName": "int" @@ -2678,6 +2738,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int32_t *", "cppClassName": "int32_t", "jsClassName": "int32_t" @@ -2706,6 +2767,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "int64_t *", "cppClassName": "int64_t", "jsClassName": "int64_t" @@ -3947,6 +4009,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_index **", "cppClassName": "Index", "jsClassName": "Index" @@ -3975,6 +4038,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_index **", "cppClassName": "Index", "jsClassName": "Index" @@ -4021,7 +4085,8 @@ "name": "index", "cType": "const git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4043,7 +4108,8 @@ "name": "index", "cType": "const git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4065,7 +4131,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "caps", @@ -4093,7 +4160,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4115,7 +4183,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4137,7 +4206,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "tree", @@ -4163,6 +4233,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -4191,6 +4262,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -4227,7 +4299,8 @@ "name": "index", "cType": "const git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4249,7 +4322,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4271,7 +4345,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "n", @@ -4299,7 +4374,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4333,7 +4409,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4367,7 +4444,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "dir", @@ -4401,7 +4479,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "source_entry", @@ -4451,7 +4530,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4479,7 +4559,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4541,7 +4622,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "ancestor_entry", @@ -4627,7 +4709,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4655,7 +4738,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4677,7 +4761,8 @@ "name": "index", "cType": "const git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4699,7 +4784,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4755,7 +4841,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4783,7 +4870,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "n", @@ -4811,7 +4899,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4875,7 +4964,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "n", @@ -4903,7 +4993,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], "isAsync": false, @@ -4932,6 +5023,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_indexer_stream **", "cppClassName": "IndexerStream", "jsClassName": "IndexerStream" @@ -5101,6 +5193,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -5141,6 +5234,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -5184,6 +5278,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -5241,6 +5336,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_note_iterator **", "cppClassName": "NoteIterator", "jsClassName": "NoteIterator" @@ -5331,6 +5427,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_note **", "cppClassName": "Note", "jsClassName": "Note" @@ -5415,6 +5512,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -5547,6 +5645,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "const char **", "cppClassName": "String", "jsClassName": "char" @@ -5626,7 +5725,8 @@ "name": "object", "cType": "git_object **", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isReturn": true }, { "name": "repo", @@ -5666,7 +5766,8 @@ "name": "object_out", "cType": "git_object **", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isReturn": true }, { "name": "repo", @@ -5712,7 +5813,8 @@ "name": "obj", "cType": "const git_object *", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isSelf": true } ], "isAsync": false, @@ -5734,7 +5836,8 @@ "name": "obj", "cType": "const git_object *", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isSelf": true } ], "isAsync": false, @@ -5756,7 +5859,8 @@ "name": "obj", "cType": "const git_object *", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isSelf": true } ], "isAsync": false, @@ -5888,7 +5992,8 @@ "name": "peeled", "cType": "git_object **", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isReturn": true }, { "name": "object", @@ -5922,7 +6027,8 @@ "name": "dest", "cType": "git_object **", "cppClassName": "Object", - "jsClassName": "Object" + "jsClassName": "Object", + "isReturn": true }, { "name": "source", @@ -5957,6 +6063,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb **", "cppClassName": "Odb", "jsClassName": "Odb" @@ -5979,6 +6086,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb **", "cppClassName": "Odb", "jsClassName": "Odb" @@ -6009,7 +6117,8 @@ "name": "odb", "cType": "git_odb *", "cppClassName": "Odb", - "jsClassName": "Odb" + "jsClassName": "Odb", + "isSelf": true }, { "name": "backend", @@ -6043,7 +6152,8 @@ "name": "odb", "cType": "git_odb *", "cppClassName": "Odb", - "jsClassName": "Odb" + "jsClassName": "Odb", + "isSelf": true }, { "name": "backend", @@ -6077,7 +6187,8 @@ "name": "odb", "cType": "git_odb *", "cppClassName": "Odb", - "jsClassName": "Odb" + "jsClassName": "Odb", + "isSelf": true }, { "name": "path", @@ -6125,6 +6236,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb_object **", "cppClassName": "OdbObject", "jsClassName": "OdbObject" @@ -6159,6 +6271,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb_object **", "cppClassName": "OdbObject", "jsClassName": "OdbObject" @@ -6241,7 +6354,8 @@ "name": "db", "cType": "git_odb *", "cppClassName": "Odb", - "jsClassName": "Odb" + "jsClassName": "Odb", + "isSelf": true }, { "name": "id", @@ -6269,7 +6383,8 @@ "name": "db", "cType": "struct git_odb *", "cppClassName": "Odb", - "jsClassName": "Odb" + "jsClassName": "Odb", + "isSelf": true } ], "isAsync": false, @@ -6291,7 +6406,8 @@ "name": "db", "cType": "git_odb *", "cppClassName": "Odb", - "jsClassName": "Odb" + "jsClassName": "Odb", + "isSelf": true }, { "name": "cb", @@ -6323,6 +6439,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6369,6 +6486,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb_stream **", "cppClassName": "OdbStream", "jsClassName": "OdbStream" @@ -6409,6 +6527,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb_stream **", "cppClassName": "OdbStream", "jsClassName": "OdbStream" @@ -6443,6 +6562,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb_writepack **", "cppClassName": "OdbWritepack", "jsClassName": "OdbWritepack" @@ -6483,6 +6603,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6523,6 +6644,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6676,6 +6798,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb_backend **", "cppClassName": "OdbBackend", "jsClassName": "OdbBackend" @@ -6714,6 +6837,8 @@ "args": [ { "name": "out", + "isReturn": true, + "shouldAlloc": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6742,6 +6867,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6755,8 +6881,8 @@ ], "ignore": true, "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, "isFree": false, "jsFunctionName": "fromstrp", "cppFunctionName": "Fromstrp", @@ -6771,6 +6897,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6790,8 +6917,8 @@ ], "ignore": true, "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, "isFree": false, "jsFunctionName": "fromstrn", "cppFunctionName": "Fromstrn", @@ -6806,6 +6933,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6819,8 +6947,8 @@ ], "ignore": true, "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, "isFree": false, "jsFunctionName": "fromraw", "cppFunctionName": "Fromraw", @@ -6835,6 +6963,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -6843,7 +6972,8 @@ "name": "id", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true } ], "ignore": true, @@ -6864,6 +6994,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -6895,7 +7026,8 @@ "name": "id", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true } ], "isAsync": false, @@ -6915,6 +7047,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -6950,6 +7083,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6958,7 +7092,8 @@ "name": "src", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true } ], "ignore": true, @@ -6981,7 +7116,8 @@ "name": "a", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true }, { "name": "b", @@ -7010,7 +7146,8 @@ "name": "a", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true }, { "name": "b", @@ -7039,7 +7176,8 @@ "name": "a", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true }, { "name": "b", @@ -7074,7 +7212,8 @@ "name": "id", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true }, { "name": "str", @@ -7103,7 +7242,8 @@ "name": "id", "cType": "const git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isSelf": true } ], "ignore": true, @@ -7208,6 +7348,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_packbuilder **", "cppClassName": "Packbuilder", "jsClassName": "Packbuilder" @@ -7463,6 +7604,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_push **", "cppClassName": "Push", "jsClassName": "Push" @@ -7493,7 +7635,8 @@ "name": "push", "cType": "git_push *", "cppClassName": "Push", - "jsClassName": "Push" + "jsClassName": "Push", + "isSelf": true }, { "name": "opts", @@ -7521,7 +7664,8 @@ "name": "push", "cType": "git_push *", "cppClassName": "Push", - "jsClassName": "Push" + "jsClassName": "Push", + "isSelf": true }, { "name": "refspec", @@ -7549,7 +7693,8 @@ "name": "push", "cType": "git_push *", "cppClassName": "Push", - "jsClassName": "Push" + "jsClassName": "Push", + "isSelf": true } ], "isAsync": false, @@ -7571,7 +7716,8 @@ "name": "push", "cType": "git_push *", "cppClassName": "Push", - "jsClassName": "Push" + "jsClassName": "Push", + "isSelf": true } ], "isAsync": false, @@ -7593,7 +7739,8 @@ "name": "push", "cType": "git_push *", "cppClassName": "Push", - "jsClassName": "Push" + "jsClassName": "Push", + "isSelf": true } ], "isAsync": false, @@ -7615,7 +7762,8 @@ "name": "push", "cType": "git_push *", "cppClassName": "Push", - "jsClassName": "Push" + "jsClassName": "Push", + "isSelf": true }, { "name": "cb", @@ -7680,7 +7828,8 @@ "name": "refdb", "cType": "git_refdb *", "cppClassName": "Refdb", - "jsClassName": "Refdb" + "jsClassName": "Refdb", + "isSelf": true }, { "name": "name", @@ -7709,7 +7858,7 @@ "cppFunctionName": "GitReference_Alloc", "return": { "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "isErrorCode": false } }, @@ -7718,6 +7867,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_refdb **", "cppClassName": "Refdb", "jsClassName": "Refdb" @@ -7746,6 +7896,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_refdb **", "cppClassName": "Refdb", "jsClassName": "Refdb" @@ -7776,7 +7927,8 @@ "name": "refdb", "cType": "git_refdb *", "cppClassName": "Refdb", - "jsClassName": "Refdb" + "jsClassName": "Refdb", + "isSelf": true } ], "isAsync": false, @@ -7820,7 +7972,8 @@ "name": "refdb", "cType": "git_refdb *", "cppClassName": "Refdb", - "jsClassName": "Refdb" + "jsClassName": "Refdb", + "isSelf": true }, { "name": "backend", @@ -7857,7 +8010,8 @@ "name": "backend_out", "cType": "struct git_refdb_backend **", "cppClassName": "RefdbBackend", - "jsClassName": "RefdbBackend" + "jsClassName": "RefdbBackend", + "isReturn": true }, { "name": "repo", @@ -7898,6 +8052,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reflog **", "cppClassName": "Reflog", "jsClassName": "Reflog" @@ -7905,7 +8060,7 @@ { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], @@ -7928,7 +8083,8 @@ "name": "reflog", "cType": "git_reflog *", "cppClassName": "Reflog", - "jsClassName": "Reflog" + "jsClassName": "Reflog", + "isSelf": true } ], "isAsync": false, @@ -7950,7 +8106,8 @@ "name": "reflog", "cType": "git_reflog *", "cppClassName": "Reflog", - "jsClassName": "Reflog" + "jsClassName": "Reflog", + "isSelf": true }, { "name": "id", @@ -7989,7 +8146,7 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -8017,7 +8174,7 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], @@ -8040,7 +8197,8 @@ "name": "reflog", "cType": "git_reflog *", "cppClassName": "Reflog", - "jsClassName": "Reflog" + "jsClassName": "Reflog", + "isSelf": true } ], "isAsync": false, @@ -8062,7 +8220,8 @@ "name": "reflog", "cType": "git_reflog *", "cppClassName": "Reflog", - "jsClassName": "Reflog" + "jsClassName": "Reflog", + "isSelf": true }, { "name": "idx", @@ -8090,7 +8249,8 @@ "name": "reflog", "cType": "git_reflog *", "cppClassName": "Reflog", - "jsClassName": "Reflog" + "jsClassName": "Reflog", + "isSelf": true }, { "name": "idx", @@ -8230,19 +8390,24 @@ ] }, { - "filename": "refs.h", - "jsClassName": "Refs", - "cppClassName": "Refs", - "cType": "git_refs", - "freeFunctionName": "git_refs_free", + "filename": "reference.h", + "dependencies": [ + "../include/repo.h", + "../include/oid.h" + ], + "jsClassName": "Reference", + "cppClassName": "GitReference", + "cType": "git_reference", + "freeFunctionName": "git_reference_free", "functions": [ { "cFunctionName": "git_reference_lookup", "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -8258,12 +8423,12 @@ "jsClassName": "String" } ], - "isAsync": false, - "isConstructorMethod": false, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceLookup", - "cppFunctionName": "GitReferenceLookup", + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", "return": { "cType": "int", "cppClassName": "int", @@ -8275,6 +8440,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -8292,12 +8458,12 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceNameToId", - "cppFunctionName": "GitReferenceNameToId", + "jsFunctionName": "oidForName", + "cppFunctionName": "OidForName", "return": { "cType": "int", "cppClassName": "int", @@ -8309,8 +8475,9 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -8338,12 +8505,13 @@ "jsClassName": "int" } ], + "ignore": true, "isAsync": false, - "isConstructorMethod": false, + "isConstructorMethod": true, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceSymbolicCreate", - "cppFunctionName": "GitReferenceSymbolicCreate", + "jsFunctionName": "createSymbolic", + "cppFunctionName": "CreateSymbolic", "return": { "cType": "int", "cppClassName": "int", @@ -8355,8 +8523,9 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -8384,12 +8553,13 @@ "jsClassName": "int" } ], + "ignore": true, "isAsync": false, - "isConstructorMethod": false, + "isConstructorMethod": true, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceCreate", - "cppFunctionName": "GitReferenceCreate", + "jsFunctionName": "create", + "cppFunctionName": "Create", "return": { "cType": "int", "cppClassName": "int", @@ -8402,16 +8572,17 @@ { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceTarget", - "cppFunctionName": "GitReferenceTarget", + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", "cppClassName": "GitOid", @@ -8424,16 +8595,17 @@ { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceSymbolicTarget", - "cppFunctionName": "GitReferenceSymbolicTarget", + "jsFunctionName": "name", + "cppFunctionName": "Name", "return": { "cType": "const char *", "cppClassName": "String", @@ -8446,19 +8618,20 @@ { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceType", - "cppFunctionName": "GitReferenceType", + "jsFunctionName": "type", + "cppFunctionName": "Type", "return": { "cType": "git_ref_t", - "cppClassName": "RefT", + "cppClassName": "Number", "isErrorCode": false } }, @@ -8468,16 +8641,18 @@ { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceName", - "cppFunctionName": "GitReferenceName", + "jsFunctionName": "name", + "cppFunctionName": "Name", "return": { "cType": "const char *", "cppClassName": "String", @@ -8489,23 +8664,25 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceResolve", - "cppFunctionName": "GitReferenceResolve", + "jsFunctionName": "resolve", + "cppFunctionName": "Resolve", "return": { "cType": "int", "cppClassName": "int", @@ -8518,16 +8695,18 @@ { "name": "ref", "cType": "const git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceOwner", - "cppFunctionName": "GitReferenceOwner", + "jsFunctionName": "owner", + "cppFunctionName": "owner", "return": { "cType": "git_repository *", "cppClassName": "GitRepo", @@ -8539,15 +8718,17 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true }, { "name": "target", @@ -8556,9 +8737,10 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, "jsFunctionName": "gitReferenceSymbolicSetTarget", "cppFunctionName": "GitReferenceSymbolicSetTarget", @@ -8573,15 +8755,17 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true }, { "name": "id", @@ -8590,12 +8774,13 @@ "jsClassName": "Oid" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceSetTarget", - "cppFunctionName": "GitReferenceSetTarget", + "jsFunctionName": "setTarget", + "cppFunctionName": "setTarget", "return": { "cType": "int", "cppClassName": "int", @@ -8607,15 +8792,17 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true }, { "name": "new_name", @@ -8630,12 +8817,13 @@ "jsClassName": "int" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceRename", - "cppFunctionName": "GitReferenceRename", + "jsFunctionName": "rename", + "cppFunctionName": "Rename", "return": { "cType": "int", "cppClassName": "int", @@ -8648,16 +8836,18 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceDelete", - "cppFunctionName": "GitReferenceDelete", + "jsFunctionName": "delete", + "cppFunctionName": "Delete", "return": { "cType": "int", "cppClassName": "int", @@ -8686,12 +8876,13 @@ "jsClassName": "unsigned" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceList", - "cppFunctionName": "GitReferenceList", + "jsFunctionName": "list", + "cppFunctionName": "List", "return": { "cType": "int", "cppClassName": "int", @@ -8726,12 +8917,13 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceForeach", - "cppFunctionName": "GitReferenceForeach", + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", "return": { "cType": "int", "cppClassName": "int", @@ -8744,10 +8936,11 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -8766,22 +8959,24 @@ { "name": "ref1", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true }, { "name": "ref2", "cType": "git_reference *", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceCmp", - "cppFunctionName": "GitReferenceCmp", + "jsFunctionName": "compare", + "cppFunctionName": "Compare", "return": { "cType": "int", "cppClassName": "int", @@ -8822,12 +9017,13 @@ "jsClassName": "void" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceForeachGlob", - "cppFunctionName": "GitReferenceForeachGlob", + "jsFunctionName": "foreachGlob", + "cppFunctionName": "ForeachGlob", "return": { "cType": "int", "cppClassName": "int", @@ -8840,16 +9036,18 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceHasLog", - "cppFunctionName": "GitReferenceHasLog", + "jsFunctionName": "hasLog", + "cppFunctionName": "HasLog", "return": { "cType": "int", "cppClassName": "int", @@ -8862,16 +9060,18 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceIsBranch", - "cppFunctionName": "GitReferenceIsBranch", + "jsFunctionName": "isBranch", + "cppFunctionName": "IsBranch", "return": { "cType": "int", "cppClassName": "int", @@ -8884,16 +9084,18 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceIsRemote", - "cppFunctionName": "GitReferenceIsRemote", + "jsFunctionName": "isRemote", + "cppFunctionName": "IsRemote", "return": { "cType": "int", "cppClassName": "int", @@ -8907,7 +9109,8 @@ "name": "buffer_out", "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "char", + "isSelf": true }, { "name": "buffer_size", @@ -8928,12 +9131,13 @@ "jsClassName": "unsigned" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferenceNormalizeName", - "cppFunctionName": "GitReferenceNormalizeName", + "jsFunctionName": "normalizeName", + "cppFunctionName": "NormalizeName", "return": { "cType": "int", "cppClassName": "int", @@ -8945,6 +9149,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_object **", "cppClassName": "Object", "jsClassName": "Object" @@ -8952,8 +9157,9 @@ { "name": "ref", "cType": "git_reference *", - "cppClassName": "Reference", - "jsClassName": "Reference" + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true }, { "name": "type", @@ -8962,12 +9168,13 @@ "jsClassName": "Otype" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": false, - "jsFunctionName": "gitReferencePeel", - "cppFunctionName": "GitReferencePeel", + "jsFunctionName": "peel", + "cppFunctionName": "Peel", "return": { "cType": "int", "cppClassName": "int", @@ -8984,12 +9191,13 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, "isFree": false, - "jsFunctionName": "gitReferenceIsValidName", - "cppFunctionName": "GitReferenceIsValidName", + "jsFunctionName": "isValidName", + "cppFunctionName": "IsValidName", "return": { "cType": "int", "cppClassName": "int", @@ -9012,7 +9220,8 @@ "name": "refspec", "cType": "const git_refspec *", "cppClassName": "Refspec", - "jsClassName": "Refspec" + "jsClassName": "Refspec", + "isSelf": true } ], "isAsync": false, @@ -9034,7 +9243,8 @@ "name": "refspec", "cType": "const git_refspec *", "cppClassName": "Refspec", - "jsClassName": "Refspec" + "jsClassName": "Refspec", + "isSelf": true } ], "isAsync": false, @@ -9056,7 +9266,8 @@ "name": "refspec", "cType": "const git_refspec *", "cppClassName": "Refspec", - "jsClassName": "Refspec" + "jsClassName": "Refspec", + "isSelf": true } ], "isAsync": false, @@ -9078,7 +9289,8 @@ "name": "refspec", "cType": "const git_refspec *", "cppClassName": "Refspec", - "jsClassName": "Refspec" + "jsClassName": "Refspec", + "isSelf": true }, { "name": "refname", @@ -9106,7 +9318,8 @@ "name": "refspec", "cType": "const git_refspec *", "cppClassName": "Refspec", - "jsClassName": "Refspec" + "jsClassName": "Refspec", + "isSelf": true }, { "name": "refname", @@ -9132,6 +9345,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -9172,6 +9386,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -9221,6 +9436,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_remote **", "cppClassName": "Remote", "jsClassName": "Remote" @@ -9261,6 +9477,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_remote **", "cppClassName": "Remote", "jsClassName": "Remote" @@ -9301,6 +9518,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_remote **", "cppClassName": "Remote", "jsClassName": "Remote" @@ -9337,7 +9555,8 @@ "name": "remote", "cType": "const git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9359,7 +9578,8 @@ "name": "remote", "cType": "const git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9381,7 +9601,8 @@ "name": "remote", "cType": "const git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9403,7 +9624,8 @@ "name": "remote", "cType": "const git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9425,7 +9647,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "url", @@ -9453,7 +9676,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "url", @@ -9481,7 +9705,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "spec", @@ -9509,7 +9734,8 @@ "name": "remote", "cType": "const git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9531,7 +9757,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "spec", @@ -9559,7 +9786,8 @@ "name": "remote", "cType": "const git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9581,7 +9809,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "direction", @@ -9609,7 +9838,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "list_cb", @@ -9643,7 +9873,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "progress_cb", @@ -9677,7 +9908,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9699,7 +9931,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9721,7 +9954,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9765,7 +9999,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -9829,6 +10064,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_strarray *", "cppClassName": "Strarray", "jsClassName": "Strarray" @@ -9859,7 +10095,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "check", @@ -9887,7 +10124,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "cred_acquire_cb", @@ -9921,7 +10159,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "transport", @@ -9949,7 +10188,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "callbacks", @@ -9977,7 +10217,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -10014,7 +10255,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "value", @@ -10042,7 +10284,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "new_name", @@ -10082,7 +10325,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true } ], "isAsync": false, @@ -10104,7 +10348,8 @@ "name": "remote", "cType": "git_remote *", "cppClassName": "Remote", - "jsClassName": "Remote" + "jsClassName": "Remote", + "isSelf": true }, { "name": "value", @@ -10162,6 +10407,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_repository **", "cppClassName": "GitRepo", "jsClassName": "Repository" @@ -10190,6 +10436,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_repository **", "cppClassName": "GitRepo", "jsClassName": "Repository" @@ -10266,6 +10513,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_repository **", "cppClassName": "GitRepo", "jsClassName": "Repository" @@ -10330,6 +10578,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_repository **", "cppClassName": "GitRepo", "jsClassName": "Repository" @@ -10364,6 +10613,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_repository **", "cppClassName": "GitRepo", "jsClassName": "Repository" @@ -10399,8 +10649,9 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_reference **", - "cppClassName": "Reference", + "cppClassName": "GitReference", "jsClassName": "Reference" }, { @@ -10430,7 +10681,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -10453,7 +10705,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -10476,7 +10729,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -10499,7 +10753,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "isAsync": false, @@ -10521,7 +10776,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "isAsync": false, @@ -10543,7 +10799,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "workdir", @@ -10578,7 +10835,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -10599,6 +10857,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_config **", "cppClassName": "Config", "jsClassName": "Config" @@ -10630,7 +10889,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "config", @@ -10657,6 +10917,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_odb **", "cppClassName": "Odb", "jsClassName": "Odb" @@ -10688,7 +10949,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "odb", @@ -10715,6 +10977,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_refdb **", "cppClassName": "Refdb", "jsClassName": "Refdb" @@ -10746,7 +11009,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "refdb", @@ -10773,6 +11037,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_index **", "cppClassName": "Index", "jsClassName": "Index" @@ -10804,7 +11069,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "index", @@ -10831,6 +11097,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "char *", "cppClassName": "String", "jsClassName": "char" @@ -10868,7 +11135,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -10891,7 +11159,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -10914,7 +11183,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "callback", @@ -10949,7 +11219,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { "name": "callback", @@ -10982,6 +11253,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -11112,7 +11384,8 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], "ignore": true, @@ -11219,6 +11492,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_object **", "cppClassName": "Object", "jsClassName": "Object" @@ -11296,6 +11570,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_revwalk **", "cppClassName": "Revwalk", "jsClassName": "Revwalk" @@ -11326,7 +11601,8 @@ "name": "walker", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true } ], "isAsync": false, @@ -11348,7 +11624,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "id", @@ -11376,7 +11653,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "glob", @@ -11404,7 +11682,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true } ], "isAsync": false, @@ -11426,7 +11705,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "commit_id", @@ -11454,7 +11734,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "glob", @@ -11482,7 +11763,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true } ], "isAsync": false, @@ -11504,7 +11786,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "refname", @@ -11532,7 +11815,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "refname", @@ -11558,6 +11842,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -11588,7 +11873,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "sort_mode", @@ -11616,7 +11902,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true }, { "name": "range", @@ -11666,7 +11953,8 @@ "name": "walk", "cType": "git_revwalk *", "cppClassName": "Revwalk", - "jsClassName": "Revwalk" + "jsClassName": "Revwalk", + "isSelf": true } ], "isAsync": false, @@ -11695,6 +11983,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_signature **", "cppClassName": "Signature", "jsClassName": "Signature" @@ -11741,6 +12030,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_signature **", "cppClassName": "Signature", "jsClassName": "Signature" @@ -11777,7 +12067,8 @@ "name": "sig", "cType": "const git_signature *", "cppClassName": "Signature", - "jsClassName": "Signature" + "jsClassName": "Signature", + "isSelf": true } ], "isAsync": false, @@ -11828,6 +12119,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -12128,7 +12420,8 @@ "name": "tgt", "cType": "git_strarray *", "cppClassName": "Strarray", - "jsClassName": "Strarray" + "jsClassName": "Strarray", + "isSelf": true }, { "name": "src", @@ -12165,7 +12458,8 @@ "name": "submodule", "cType": "git_submodule **", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isReturn": true }, { "name": "repo", @@ -12233,7 +12527,8 @@ "name": "submodule", "cType": "git_submodule **", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isReturn": true }, { "name": "repo", @@ -12279,7 +12574,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12301,7 +12597,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true }, { "name": "write_index", @@ -12329,7 +12626,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12351,7 +12649,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12373,7 +12672,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12395,7 +12695,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12417,7 +12718,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12439,7 +12741,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true }, { "name": "url", @@ -12467,7 +12770,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12489,7 +12793,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12511,7 +12816,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12548,7 +12854,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true }, { "name": "ignore", @@ -12591,7 +12898,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true }, { "name": "update", @@ -12619,7 +12927,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12641,7 +12950,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true }, { "name": "fetch_recurse_submodules", @@ -12669,7 +12979,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true }, { "name": "overwrite", @@ -12697,7 +13008,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12747,7 +13059,8 @@ "name": "submodule", "cType": "git_submodule *", "cppClassName": "Submodule", - "jsClassName": "Submodule" + "jsClassName": "Submodule", + "isSelf": true } ], "isAsync": false, @@ -12854,6 +13167,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_tag **", "cppClassName": "Tag", "jsClassName": "Tag" @@ -12888,6 +13202,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_tag **", "cppClassName": "Tag", "jsClassName": "Tag" @@ -12952,7 +13267,8 @@ "name": "tag", "cType": "const git_tag *", "cppClassName": "Tag", - "jsClassName": "Tag" + "jsClassName": "Tag", + "isSelf": true } ], "isAsync": false, @@ -13002,7 +13318,8 @@ "name": "tag", "cType": "const git_tag *", "cppClassName": "Tag", - "jsClassName": "Tag" + "jsClassName": "Tag", + "isSelf": true } ], "isAsync": false, @@ -13024,7 +13341,8 @@ "name": "tag", "cType": "const git_tag *", "cppClassName": "Tag", - "jsClassName": "Tag" + "jsClassName": "Tag", + "isSelf": true } ], "isAsync": false, @@ -13046,7 +13364,8 @@ "name": "tag", "cType": "const git_tag *", "cppClassName": "Tag", - "jsClassName": "Tag" + "jsClassName": "Tag", + "isSelf": true } ], "isAsync": false, @@ -13068,7 +13387,8 @@ "name": "tag", "cType": "const git_tag *", "cppClassName": "Tag", - "jsClassName": "Tag" + "jsClassName": "Tag", + "isSelf": true } ], "isAsync": false, @@ -13090,7 +13410,8 @@ "name": "tag", "cType": "const git_tag *", "cppClassName": "Tag", - "jsClassName": "Tag" + "jsClassName": "Tag", + "isSelf": true } ], "isAsync": false, @@ -13491,6 +13812,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_cred **", "cppClassName": "Cred", "jsClassName": "Cred" @@ -13525,6 +13847,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_transport **", "cppClassName": "Transport", "jsClassName": "Transport" @@ -13559,6 +13882,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_transport **", "cppClassName": "Transport", "jsClassName": "Transport" @@ -13593,6 +13917,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_transport **", "cppClassName": "Transport", "jsClassName": "Transport" @@ -13627,6 +13952,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_transport **", "cppClassName": "Transport", "jsClassName": "Transport" @@ -13661,6 +13987,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_smart_subtransport **", "cppClassName": "SmartSubtransport", "jsClassName": "SmartSubtransport" @@ -13689,6 +14016,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_smart_subtransport **", "cppClassName": "SmartSubtransport", "jsClassName": "SmartSubtransport" @@ -13726,6 +14054,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_tree **", "cppClassName": "Tree", "jsClassName": "Tree" @@ -13760,6 +14089,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_tree **", "cppClassName": "Tree", "jsClassName": "Tree" @@ -13824,7 +14154,8 @@ "name": "tree", "cType": "const git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true } ], "isAsync": false, @@ -13846,7 +14177,8 @@ "name": "tree", "cType": "const git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true } ], "isAsync": false, @@ -13868,7 +14200,8 @@ "name": "tree", "cType": "const git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true } ], "isAsync": false, @@ -13890,7 +14223,8 @@ "name": "tree", "cType": "git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true }, { "name": "filename", @@ -13918,7 +14252,8 @@ "name": "tree", "cType": "git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true }, { "name": "idx", @@ -13946,7 +14281,8 @@ "name": "tree", "cType": "const git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true }, { "name": "oid", @@ -13972,6 +14308,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_tree_entry **", "cppClassName": "TreeEntry", "jsClassName": "TreeEntry" @@ -14200,6 +14537,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "git_treebuilder **", "cppClassName": "Treebuilder", "jsClassName": "Treebuilder" @@ -14322,6 +14660,7 @@ "args": [ { "name": "out", + "isReturn": true, "cType": "const git_tree_entry **", "cppClassName": "TreeEntry", "jsClassName": "TreeEntry" @@ -14466,7 +14805,8 @@ "name": "tree", "cType": "const git_tree *", "cppClassName": "Tree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true }, { "name": "mode", From cf7d3520e3cb6c6c3e21f46851b6eebb8feaa0f1 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sat, 22 Jun 2013 23:22:34 +0200 Subject: [PATCH 05/28] TreeEntry, Object, Commit, Signature, Time is now code-gen'd --- TODO | 4 + binding.gyp | 2 + gen.js | 2 +- include/blob.h | 1 + include/commit.h | 161 +-- include/diff_list.h | 8 +- include/object.h | 62 + include/oid.h | 1 + include/reference.h | 1 + include/repo.h | 1 + include/signature.h | 38 +- include/time.h | 37 + include/tree.h | 7 +- include/tree_entry.h | 93 +- lib/blob.js | 45 +- lib/commit.js | 194 +-- lib/diff_list.js | 76 +- lib/oid.js | 6 +- lib/repo.js | 85 +- lib/revwalk.js | 15 +- lib/tree.js | 39 +- lib/tree_entry.js | 231 +--- src/base.cc | 4 + src/blob.cc | 24 +- src/commit.cc | 510 ++++---- src/diff_list.cc | 40 +- src/object.cc | 229 ++++ src/oid.cc | 12 +- src/reference.cc | 13 +- src/repo.cc | 12 +- src/revwalk.cc | 1 + src/signature.cc | 108 +- src/time.cc | 73 ++ src/tree.cc | 59 +- src/tree_entry.cc | 279 ++--- templates/class.cc.ejs | 54 +- templates/header.h.ejs | 12 + test/convenience-commit.js | 129 +- test/convenience-difflist.js | 53 +- test/convenience-entry.js | 84 +- test/convenience-error.js | 2 +- test/convenience-repo.js | 13 +- test/convenience-tree.js | 4 +- test/raw-blob.js | 3 +- test/raw-commit.js | 31 +- v0.18.0.json | 2168 ++++++++++++++-------------------- 46 files changed, 2235 insertions(+), 2791 deletions(-) create mode 100644 TODO create mode 100644 include/object.h create mode 100644 include/time.h create mode 100644 src/object.cc create mode 100644 src/time.cc diff --git a/TODO b/TODO new file mode 100644 index 000000000..4ea714371 --- /dev/null +++ b/TODO @@ -0,0 +1,4 @@ +- replace all argv crap with Wrap static methods for tighter instantiation +- audit memory issues - explicit malloc and frees, copies +- look into the v88 conversions crap +- rename all async methods getXXX diff --git a/binding.gyp b/binding.gyp index e87a7f1d5..3ccff0ec7 100644 --- a/binding.gyp +++ b/binding.gyp @@ -9,9 +9,11 @@ 'src/error.cc', 'src/oid.cc', 'src/reference.cc', + 'src/object.cc', 'src/repo.cc', 'src/revwalk.cc', 'src/signature.cc', + 'src/time.cc', 'src/tree.cc', 'src/tree_entry.cc', 'src/diff_list.cc', diff --git a/gen.js b/gen.js index 128ec56bd..f64aa6bfd 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/blob.h b/include/blob.h index 79b10f5ef..51f875fb6 100755 --- a/include/blob.h +++ b/include/blob.h @@ -28,6 +28,7 @@ class GitBlob : public ObjectWrap { static Handle New(const Arguments& args); + static Handle Lookup(const Arguments& args); static void LookupWork(uv_work_t* req); static void LookupAfterWork(uv_work_t* req); diff --git a/include/commit.h b/include/commit.h index 961d2ed82..ad348163c 100755 --- a/include/commit.h +++ b/include/commit.h @@ -1,162 +1,79 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITCOMMIT_H +#define GITCOMMIT_H #include #include -#include +#include #include "git2.h" -#include "reference.h" -#include "repo.h" -#include "oid.h" -#include "tree.h" - using namespace node; using namespace v8; -/** - * Class wrapper for libgit2 git_commit - */ class GitCommit : public ObjectWrap { public: - /** - * v8::FunctionTemplate used to create Node.js constructor - */ - static Persistent constructor_template; - /** - * Used to intialize the EventEmitter from Node.js - * - * @param target v8::Object the Node.js module object - */ + static Persistent constructor_template; static void Initialize (Handle target); - git_commit* GetValue(); - void SetValue(git_commit* commit); - void SetOid(git_oid* oid); + git_commit *GetValue(); - protected: - GitCommit() {} - ~GitCommit() {} + private: + GitCommit(git_commit *raw); + ~GitCommit(); static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); + static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t *req); - static void LookupAfterWork(uv_work_t *req); + static void LookupWork(uv_work_t* req); + static void LookupAfterWork(uv_work_t* req); + struct LookupBaton { + uv_work_t request; + const git_error* error; + git_commit * commit; + git_repository * repo; + const git_oid * id; + Persistent callback; + }; static Handle Oid(const Arguments& args); - + static Handle MessageEncoding(const Arguments& args); static Handle Message(const Arguments& args); - static void MessageWork(uv_work_t* req); - static void MessageAfterWork(uv_work_t* req); - static Handle Time(const Arguments& args); - static void TimeWork(uv_work_t* req); - static void TimeAfterWork(uv_work_t* req); - static Handle Offset(const Arguments& args); - static void OffsetWork(uv_work_t* req); - static void OffsetAfterWork(uv_work_t* req); - - static Handle Author(const Arguments& args); - static void AuthorWork(uv_work_t* req); - static void AuthorAfterWork(uv_work_t* req); - static Handle Committer(const Arguments& args); - static void CommitterWork(uv_work_t* req); - static void CommitterAfterWork(uv_work_t* req); - + static Handle Author(const Arguments& args); static Handle Tree(const Arguments& args); static void TreeWork(uv_work_t* req); static void TreeAfterWork(uv_work_t* req); - static Handle Parents(const Arguments& args); - static void ParentsWork(uv_work_t* req); - static void ParentsAfterWork(uv_work_t* req); - - private: - git_commit* commit; - git_oid* oid; - - struct LookupBaton { - uv_work_t request; - const git_error* error; - - git_repository* repo; - git_oid rawOid; - std::string sha; - git_commit* rawCommit; - - Persistent callback; - }; - - struct MessageBaton { - uv_work_t request; - - git_commit* rawCommit; - std::string message; - - Persistent callback; - }; - - struct TimeBaton { - uv_work_t request; - - git_commit* rawCommit; - git_time_t time; - - Persistent callback; - }; - - struct SignatureBaton { - uv_work_t request; - - git_commit* rawCommit; - const git_signature* rawSignature; - - Persistent callback; - }; - - struct OffsetBaton { - uv_work_t request; - - git_commit* rawCommit; - int offset; - - Persistent callback; - }; - - struct TreeBaton { uv_work_t request; const git_error* error; - - git_commit* rawCommit; - git_tree* rawTree; - + git_tree * tree_out; + const git_commit * commit; Persistent callback; }; + static Handle TreeId(const Arguments& args); + static Handle ParentCount(const Arguments& args); + static Handle Parent(const Arguments& args); + static void ParentWork(uv_work_t* req); + static void ParentAfterWork(uv_work_t* req); - struct Parent { - const git_oid* rawOid; - git_commit* rawCommit; - }; - - struct ParentsBaton { + struct ParentBaton { uv_work_t request; const git_error* error; - - int index; - git_commit* rawCommit; - std::vector parents; - + git_commit * out; + git_commit * commit; + unsigned int n; Persistent callback; }; + git_commit *raw; }; + +#endif diff --git a/include/diff_list.h b/include/diff_list.h index 58913866e..26fe09a36 100644 --- a/include/diff_list.h +++ b/include/diff_list.h @@ -32,14 +32,12 @@ class GitDiffList : public ObjectWrap { static void Initialize (Handle target); git_diff_list* GetValue(); - void SetValue(git_diff_list* diffList); protected: - GitDiffList() {} - ~GitDiffList() {} + GitDiffList(git_diff_list *raw); + ~GitDiffList(); static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); static Handle TreeToTree(const Arguments& args); static void TreeToTreeWork(uv_work_t *req); @@ -72,7 +70,7 @@ class GitDiffList : public ObjectWrap { static void WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/); private: - git_diff_list* diffList; + git_diff_list* raw; struct TreeToTreeBaton { uv_work_t request; diff --git a/include/object.h b/include/object.h new file mode 100644 index 000000000..875e43439 --- /dev/null +++ b/include/object.h @@ -0,0 +1,62 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITOBJECT_H +#define GITOBJECT_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitObject : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_object *GetValue(); + + private: + GitObject(git_object *raw); + ~GitObject(); + + static Handle New(const Arguments& args); + + + static Handle Lookup(const Arguments& args); + static void LookupWork(uv_work_t* req); + static void LookupAfterWork(uv_work_t* req); + + struct LookupBaton { + uv_work_t request; + const git_error* error; + git_object * object; + git_repository * repo; + const git_oid * id; + git_otype type; + Persistent callback; + }; + static Handle Oid(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Peel(const Arguments& args); + static void PeelWork(uv_work_t* req); + static void PeelAfterWork(uv_work_t* req); + + struct PeelBaton { + uv_work_t request; + const git_error* error; + git_object * peeled; + const git_object * object; + git_otype target_type; + Persistent callback; + }; + git_object *raw; +}; + +#endif diff --git a/include/oid.h b/include/oid.h index d4ca3d848..63107effa 100755 --- a/include/oid.h +++ b/include/oid.h @@ -28,6 +28,7 @@ class GitOid : public ObjectWrap { static Handle New(const Arguments& args); + static Handle FromString(const Arguments& args); static Handle Sha(const Arguments& args); git_oid *raw; diff --git a/include/reference.h b/include/reference.h index 88b4c9d0e..57ab38f17 100644 --- a/include/reference.h +++ b/include/reference.h @@ -28,6 +28,7 @@ class GitReference : public ObjectWrap { static Handle New(const Arguments& args); + static Handle Lookup(const Arguments& args); static void LookupWork(uv_work_t* req); static void LookupAfterWork(uv_work_t* req); diff --git a/include/repo.h b/include/repo.h index 36a47d546..9ac073c81 100755 --- a/include/repo.h +++ b/include/repo.h @@ -28,6 +28,7 @@ class GitRepo : public ObjectWrap { static Handle New(const Arguments& args); + static Handle Open(const Arguments& args); static void OpenWork(uv_work_t* req); static void OpenAfterWork(uv_work_t* req); diff --git a/include/signature.h b/include/signature.h index bc83ad529..bcabb51f2 100755 --- a/include/signature.h +++ b/include/signature.h @@ -1,45 +1,39 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef GitSignature_H -#define GitSignature_H +#ifndef GITSIGNATURE_H +#define GITSIGNATURE_H #include #include +#include #include "git2.h" -#include "repo.h" - -using namespace v8; using namespace node; +using namespace v8; class GitSignature : public ObjectWrap { public: - static Persistent constructor_template; - static void Initialize(Handle target); + static Persistent constructor_template; + static void Initialize (Handle target); - git_signature* GetValue(); - void SetValue(git_signature* signature); + git_signature *GetValue(); - protected: - GitSignature() {}; - ~GitSignature() {}; + private: + GitSignature(git_signature *raw); + ~GitSignature(); static Handle New(const Arguments& args); - static Handle Duplicate(const Arguments& args); - static Handle Free(const Arguments& args); static Handle Name(const Arguments& args); static Handle Email(const Arguments& args); + static Handle Time(const Arguments& args); - private: - git_signature* signature; + static Handle Now(const Arguments& args); + git_signature *raw; }; #endif diff --git a/include/time.h b/include/time.h new file mode 100644 index 000000000..bccd3e316 --- /dev/null +++ b/include/time.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITTIME_H +#define GITTIME_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitTime : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_time *GetValue(); + + private: + GitTime(git_time *raw); + ~GitTime(); + + static Handle New(const Arguments& args); + + static Handle Time(const Arguments& args); + static Handle Offset(const Arguments& args); + + git_time *raw; +}; + +#endif diff --git a/include/tree.h b/include/tree.h index 4cc84c457..0b922b177 100755 --- a/include/tree.h +++ b/include/tree.h @@ -34,11 +34,10 @@ class GitTree : public ObjectWrap { static void Initialize(Handle target); git_tree* GetValue(); - void SetValue(git_tree* tree); protected: - GitTree() {}; - ~GitTree() {}; + GitTree(git_tree *raw); + ~GitTree(); static Handle New(const Arguments& args); @@ -58,7 +57,7 @@ class GitTree : public ObjectWrap { private: - git_tree* tree; + git_tree* raw; struct LookupBaton { uv_work_t request; diff --git a/include/tree_entry.h b/include/tree_entry.h index eb97ad6a6..a076a3a8c 100755 --- a/include/tree_entry.h +++ b/include/tree_entry.h @@ -1,9 +1,6 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #ifndef GITTREEENTRY_H #define GITTREEENTRY_H @@ -14,89 +11,41 @@ #include "git2.h" -#include "repo.h" -#include "tree.h" -#include "oid.h" - -using namespace v8; using namespace node; +using namespace v8; -/** - * Class wrapper for libgit2 git_tree_entry - */ -class GitTreeEntry : ObjectWrap { +class GitTreeEntry : public ObjectWrap { public: static Persistent constructor_template; + static void Initialize (Handle target); + + git_tree_entry *GetValue(); - static void Initialize(Handle target); - git_tree_entry* GetValue(); - void SetValue(git_tree_entry* tree); - void SetRoot(std::string root); - std::string GetRoot(); + private: + GitTreeEntry(git_tree_entry *raw); + ~GitTreeEntry(); - protected: static Handle New(const Arguments& args); - static Handle Root(const Arguments& args); static Handle Name(const Arguments& args); - static void NameWork(uv_work_t* req); - static void NameAfterWork(uv_work_t* req); - - static Handle FileMode(const Arguments& args); - static void FileModeWork(uv_work_t* req); - static void FileModeAfterWork(uv_work_t* req); - static Handle Oid(const Arguments& args); - static void OidWork(uv_work_t* req); - static void OidAfterWork(uv_work_t* req); - - static Handle ToBlob(const Arguments& args); - static void ToBlobWork(uv_work_t *req); - static void ToBlobAfterWork(uv_work_t *req); - - private: - git_tree_entry* entry; - std::string root; - - struct NameBaton { - uv_work_t request; - - git_tree_entry* rawEntry; - const char* name; - - Persistent callback; - }; - - struct FileModeBaton { - uv_work_t request; - - git_tree_entry* rawEntry; - git_filemode_t fileMode; - - Persistent callback; - }; + static Handle Type(const Arguments& args); + static Handle filemode(const Arguments& args); + static Handle GetObject(const Arguments& args); + static void GetObjectWork(uv_work_t* req); + static void GetObjectAfterWork(uv_work_t* req); - struct OidBaton { - uv_work_t request; - - git_tree_entry* rawEntry; - const git_oid* rawOid; - - Persistent callback; - }; - - struct ToBlobBaton { + struct GetObjectBaton { uv_work_t request; const git_error* error; - - git_repository* rawRepo; - git_tree_entry* rawEntry; - git_blob* rawBlob; - + git_object * object_out; + git_repository * repo; + const git_tree_entry * entry; Persistent callback; }; + git_tree_entry *raw; }; #endif diff --git a/lib/blob.js b/lib/blob.js index 2dc8f3dbb..8f66519cb 100644 --- a/lib/blob.js +++ b/lib/blob.js @@ -5,49 +5,27 @@ var git = require('../'), * Blob convenience class constructor. * * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. * @param {git.raw.Blob} [rawBlob = new git.raw.Blob(rawRepo)] Raw blob object. */ -var Blob = function(rawRepo, rawBlob) { - if(!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Blob must be a raw repo'); - } - this.rawRepo = rawRepo; - - if(typeof rawBlob !== 'undefined' && - rawBlob instanceof git.raw.Blob) { - this.rawBlob = rawBlob; - } else { - this.rawBlob = new git.raw.Blob(this.rawRepo); +var Blob = function(rawBlob) { + if(!(rawBlob instanceof git.raw.Blob)) { + throw new git.error('First parameter for Blob must be a raw blob'); } + this.rawBlob = rawBlob; }; /** - * Retrieve the blob represented by the oid. - * - * @param {git.raw.Oid} oid The OID representing the blob to lookup. - * @param {Blob~lookupCallback} callback + * Retrieve the blob's raw content buffer. */ -Blob.prototype.lookup = function(oid, callback) { - /** - * @callback Blob~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob Retrieved blob object or null. - */ - var self = this; - self.rawBlob.lookup(self.rawRepo, oid, function blobLookup(error, rawBlob) { - if (success(error, callback)) { - self.rawBlob = rawBlob; - callback(null, self); - } - }); +Blob.prototype.rawContent = function() { + return this.rawBlob.content().toBuffer(this.size()); }; /** - * Retrieve the blob's raw content buffer. + * Retrieve the blob's length. */ -Blob.prototype.rawContent = function() { - return this.rawBlob.content().toBuffer(this.rawBlob.size()); +Blob.prototype.size = function() { + return this.rawBlob.size(); }; /** @@ -70,8 +48,7 @@ Blob.prototype.createFromFile = function(path, callback) { * @param {GitError|null} error An Error or null if successful. * @param {Blob|null} blob The new blob or null. */ - var self = this; - self.rawBlob.createFromFile(path, self.rawRepo, function blobCreateFromFileCallback(error, rawBlob) { + git.raw.Blob.createFromFile(path, self.rawRepo, function blobCreateFromFileCallback(error, rawBlob) { if (success(error, callback)) { self.rawBlob = rawBlob; callback(null, self); diff --git a/lib/commit.js b/lib/commit.js index 3a03ac043..ea69ad9f0 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -9,57 +9,22 @@ var git = require( '../' ), * @param {git.raw.Repo} rawRepo Raw repository object. * @param {git.raw.Commit} [rawCommit = new git.raw.Commit(rawRepo)] Raw commit object. */ -var Commit = function(rawRepo, rawCommit) { - if (!(rawRepo instanceof git.raw.Repo)) { +var Commit = function(repo, rawCommit) { + if (!(repo instanceof git.repo)) { throw new git.error('First parameter for Commit must be a raw repo'); } + this.repo = repo; - this.rawRepo = rawRepo; - - if (rawCommit instanceof git.raw.Commit) { - this.rawCommit = rawCommit; - } else { - this.rawCommit = new git.raw.Commit(); + if (!(rawCommit instanceof git.raw.Commit)) { + throw new git.error('Second parameter for Commit must be a raw commit'); } -}; - -/** - * Look up the commit referenced by oid, replace this.commit with the result. - * - * @param {Oid|git.raw.Oid|String} oid A representation of an OID used to lookup the commit. - * @param {Commit~lookupCallback} callback - */ -Commit.prototype.lookup = function(oid, callback) { - /** - * @callback Commit~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Commit|null} commit Retrieved commit object or null. - */ - if (typeof oid !== 'undefined' && - typeof oid !== 'string' && - !(oid instanceof git.raw.Oid)) { - oid = oid.getRawOid(); - } - var self = this; - self.rawCommit.lookup(self.rawRepo, oid, function commitLookup(error, rawCommit) { - if (success(error, callback)) { - self.rawCommit = rawCommit; - callback(null, self); - } - }); + this.rawCommit = rawCommit; }; /** * Retrieve the commit's OID. - * - * @param {Commit~oidCallback} callback */ Commit.prototype.oid = function() { - /** - * @callback Commit~oidCallback Callback executed on OID retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Oid|null} commit Retrieved OID object or null. - */ return new git.oid(this.rawCommit.oid()); }; @@ -72,129 +37,63 @@ Commit.prototype.sha = function() { /** * Retrieve the message - * - * @param {Commit~messageCallback} callback */ -Commit.prototype.message = function(callback) { - /** - * @callback Commit~messageCallback Callback executed on message retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} message Retrieved message. - */ - this.rawCommit.message(function(error, message) { - if (success(error, callback)) { - callback(null, message); - } - }); +Commit.prototype.message = function() { + return this.rawCommit.message(); }; /** * Retrieve the commit time as a unix timestamp. - * - * @param {Commit~timeCallback} callback */ -Commit.prototype.time = function(callback) { - /** - * @callback Commit~timeCallback Callback executed on time retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Integer|null} time Retrieved time in seconds. - */ - this.rawCommit.time(function(error, time) { - if (success(error, callback)) { - // git_commit_time returns timestamp in s, converting to ms here - callback(null, time * 1000); - } - }); +Commit.prototype.time = function() { + return this.rawCommit.time() * 1000; }; /** * Retrieve the commit time as a Date object. - * - * @param {Commit~dateCallback} callback */ -Commit.prototype.date = function(callback) { - /** - * @callback Commit~dateCallback Callback executed on date retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Date|null} time Retrieved time as a Date object. - */ - this.time(function(error, time) { - if (success(error, callback)) { - callback(null, new Date(time)); - } - }); +Commit.prototype.date = function() { + return new Date(this.time()); }; /** * Retrieve the commit's positive or negative timezone offset, in minutes from UTC. - * - * @param {Commit~offsetCallback} callback */ Commit.prototype.offset = function(callback) { - /** - * @callback Commit~offsetCallback Callback executed on offset retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Integer|null} offset Retrieved offset in in minutes from UTC. - */ - this.rawCommit.offset(function(error, offset) { - if (success(error, callback)) { - callback(null, offset); - } - }); + return this.rawCommit.offset(); }; /** * Retrieve the commit's author signature. - * - * @param {Commit~authorCallback} callback */ -Commit.prototype.author = function(callback) { - /** - * @callback Commit~authorCallback Callback executed on author retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Signature|null} author Retrieved author signature. - */ - this.rawCommit.author(function(error, rawSignature) { - if (success(error, callback)) { - callback(null, new git.signature(rawSignature)); - } - }); +Commit.prototype.author = function() { + return this.rawCommit.author(); }; /** * Retrieve the commit's committer. - * - * @param {Commit~committerCallback} callback */ -Commit.prototype.committer = function(callback) { - /** - * @callback Commit~committerCallback Callback executed on committer retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Signature|null} committer Retrieved committer signature. - */ - this.rawCommit.committer(function(error, rawSignature) { - if (success(error, callback)) { - callback(null, new git.signature(rawSignature)); - } - }); +Commit.prototype.committer = function() { + return this.rawCommit.committer(); }; /** * Retrieve the tree for this commit. * - * @param {Commit~treeCallback} callback + * @param {Commit~getTreeCallback} callback */ -Commit.prototype.tree = function(callback) { +Commit.prototype.getTree = function(callback) { /** - * @callback Commit~treeCallback Callback executed on tree retrieval. + * @callback Commit~getTreeCallback Callback executed on tree retrieval * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree Retrieved tree. + * @param {Tree|null} Tree */ + var self = this; - self.rawCommit.tree(function commitTree(error, rawTree) { - if (success(error, callback)) { - callback(null, new git.tree(self.rawRepo, rawTree)); - } + this.rawCommit.tree(function(error, rawTree) { + if (error) return callback(error); + + callback(null, new git.tree(self.repo, rawTree)); }); }; @@ -211,10 +110,8 @@ Commit.prototype.file = function(path, callback) { * @param {GitError|null} error An Error or null if successful. * @param {Entry|null} file Retrieved file entry. */ - this.tree(function commitFileCallback(error, tree) { - if (!success(error, callback)) { - return; - } + this.getTree(function (error, tree) { + if (error) return callback(error); tree.entry(path, function(error, entry) { if (success(error, callback)) { callback(null, entry); @@ -238,7 +135,7 @@ Commit.prototype.history = function() { self = this; var oid = self.oid(); - (new git.revwalk(self.rawRepo)).allocate(function createRevwalk(error, revwalk) { + (new git.revwalk(self.repo)).allocate(function createRevwalk(error, revwalk) { var commits = []; revwalk.walk(oid, function commitRevWalk(error, index, commit, noMoreCommits) { if(error) { @@ -285,15 +182,18 @@ Commit.prototype.parents = function(callback) { * @param {Commit[]|null} parents Commit's parent(s). */ var self = this; - self.rawCommit.parents(function processParent(error, rawParents) { - if (success(error, callback)) { - var parents = []; - rawParents.forEach(function eachParent(rawParent) { - parents.push(new Commit(self.rawRepo, rawParent)); - }); - callback(null, parents); - } - }); + + function processParents(rawCommit, n, acc, callback) { + if (n < 0) return callback(null, acc); + + rawCommit.parent(n, function nextParent(error, rawParentCommit) { + if (success(error, callback)) { + processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback) + } + }); + } + + processParents(this.rawCommit, this.rawCommit.parentCount() - 1, [], callback); }; /** @@ -311,16 +211,14 @@ Commit.prototype.parentsDiffTrees = function(callback) { var self = this; var commitSha = self.sha(); self.parents(function commitParents(error, parents) { - if (!success(error, callback)) { - return; - } + if (!success(error, callback)) return; + var parentDiffLists = []; parents.forEach(function commitEachParent(parent) { var parentSha = parent.sha(); - (new git.diffList(self.rawRepo)).treeToTree(parentSha, commitSha, function walkDiffList(error, diffList) { - if (!success(error, callback)) { - return; - } + git.diffList.treeToTree(self.repo, parentSha, commitSha, function walkDiffList(error, diffList) { + if (!success(error, callback)) return; + parentDiffLists.push(diffList); if (parentDiffLists.length === parents.length) { callback(null, parentDiffLists); diff --git a/lib/diff_list.js b/lib/diff_list.js index 56a269314..5cf30f913 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -5,20 +5,13 @@ var git = require('../'), * Convenience diff list class. * * @constructor - * @param {git.raw.Repo} rawRepo * @param {git.raw.DiffList} [rawDiffList = new git.raw.DiffList] */ -var DiffList = function(rawRepo, rawDiffList) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for DiffList must be a raw repo'); - } - this.rawRepo = rawRepo; - - if (rawDiffList instanceof git.raw.DiffList) { - this.rawDiffList = rawDiffList; - } else { - this.rawDiffList = new git.raw.DiffList(); +var DiffList = function(rawDiffList) { + if (!(rawDiffList instanceof git.raw.DiffList)) { + throw new git.error('Parameter for DiffList must be a raw difflist'); } + this.rawDiffList = rawDiffList; }; /** @@ -27,16 +20,16 @@ var DiffList = function(rawRepo, rawDiffList) { * @readonly * @enum {Integer} */ -DiffList.prototype.deltaTypes = { - /** 0 */ GIT_DELTA_UNMODIFIED: git.raw.DiffList.deltaTypes.GIT_DELTA_UNMODIFIED, - /** 1 */ GIT_DELTA_ADDED: git.raw.DiffList.deltaTypes.GIT_DELTA_ADDED, - /** 2 */ GIT_DELTA_DELETED: git.raw.DiffList.deltaTypes.GIT_DELTA_DELETED, - /** 3 */ GIT_DELTA_MODIFIED: git.raw.DiffList.deltaTypes.GIT_DELTA_MODIFIED, - /** 4 */ GIT_DELTA_RENAMED: git.raw.DiffList.deltaTypes.GIT_DELTA_RENAMED, - /** 5 */ GIT_DELTA_COPIED: git.raw.DiffList.deltaTypes.GIT_DELTA_COPIED, - /** 6 */ GIT_DELTA_IGNORED: git.raw.DiffList.deltaTypes.GIT_DELTA_IGNORED, - /** 7 */ GIT_DELTA_UNTRACKED: git.raw.DiffList.deltaTypes.GIT_DELTA_UNTRACKED, - /** 8 */ GIT_DELTA_TYPECHANGE: git.raw.DiffList.deltaTypes.GIT_DELTA_TYPECHANGE +DiffList.Delta = { + /** 0 */ Unmodified: 0, + /** 1 */ Added: 1, + /** 2 */ Deleted: 2, + /** 3 */ Modified: 3, + /** 4 */ Renamed: 4, + /** 5 */ Copied: 5, + /** 6 */ Ignored: 6, + /** 7 */ Untracked: 7, + /** 8 */ TypeChange: 8 }; /** @@ -45,17 +38,26 @@ DiffList.prototype.deltaTypes = { * @readOnly * @enum {String} */ -DiffList.prototype.lineOriginTypes = { - /** ' ' */ GIT_DIFF_LINE_CONTEXT: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, - /** '+' */ GIT_DIFF_LINE_ADDITION: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, - /** '-' */ GIT_DIFF_LINE_DELETION: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, - /** '\n' */ GIT_DIFF_LINE_ADD_EOFNL: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, - /** '' */ GIT_DIFF_LINE_DEL_EOFNL: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, - /** 'F' */ GIT_DIFF_LINE_FILE_HDR: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, - /** 'H' */ GIT_DIFF_LINE_HUNK_HDR: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, - /** 'B' */ GIT_DIFF_LINE_BINARY: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY +DiffList.LineOrigin = { + /** ' ' */ Context: ' ', + /** '+' */ Addition: '+', + /** '-' */ Deletion: '-', + /** '\n' */ AddEofNl: '\n', + /** '' */ DelEofNl: '', + /** 'F' */ FileHdr: 'F', + /** 'H' */ HunkHdr: 'H', + /** 'B' */ Binary: 'B' +}; + +DiffList.treeToTree = function(repo, oldSha, newSha, callback) { + git.raw.DiffList.treeToTree(repo.rawRepo, oldSha, newSha, function(error, rawDiffList) { + if (error) return callback(new git.error(error.message, error.code), null); + + callback(null, new DiffList(rawDiffList)); + }); }; + /** * Walk the current diff list tree. * @@ -68,7 +70,7 @@ DiffList.prototype.walk = function() { var event = new events.EventEmitter(), allFileDeltas = [], self = this; - + self.rawDiffList.walk(function fileCallback(error, fileDeltas) { if (error) { event.emit('end', new git.error(error.message, error.code), null); @@ -104,18 +106,6 @@ DiffList.prototype.walk = function() { return event; }; -DiffList.prototype.treeToTree = function(oldSha, newSha, callback) { - var self = this; - self.rawDiffList.treeToTree(self.rawRepo, oldSha, newSha, function(error, rawDifflist) { - if (error) { - callback(new git.error(error.message, error.code), null); - return; - } - self.rawDiffList = rawDifflist; - callback(null, self); - }); -}; - exports.diffList = DiffList; /** diff --git a/lib/oid.js b/lib/oid.js index 6b7e35923..a49d954ac 100644 --- a/lib/oid.js +++ b/lib/oid.js @@ -8,11 +8,7 @@ var git = require('../'), * @param {git.raw.Oid} [rawOid = new git.rawOid] Raw Oid object. */ var Oid = function(rawOid) { - if(rawOid instanceof git.raw.Oid) { - this.rawOid = rawOid; - } else { - this.rawOid = new git.raw.Oid(); - } + this.rawOid = rawOid; }; /** diff --git a/lib/repo.js b/lib/repo.js index 8ad2156bd..8d4a9e695 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -10,6 +10,26 @@ var Repo = function(rawRepo) { this.rawRepo = rawRepo; }; +/** + * Initialise a git repository at directory. + * + * @param {String} directory + * @param {Boolean} isBare True if the repository is to be bare, false otherwise. + * @param {Repo~initCallback} callback + */ +Repo.init = function(directory, isBare, callback) { + /** + * @callback Repo~initCallback Callback executed when repository is initialized. + * @param {GitError|null} error An Error or null if successful. + * @param {Repo|null} repo Initialized repository. + */ + git.raw.Repo.init(directory, isBare, function(error, rawRepo) { + if (success(error, callback)) { + callback(null, new Repo(rawRepo)); + } + }); +}; + /** * Open the git repository at directory. * @@ -63,59 +83,66 @@ Repo.prototype.branch = function(name, callback) { /** * Retrieve the commit identified by oid. * - * @param {String|Oid|git.raw.Oid} sha + * @param {String|Oid} String sha or Oid * @param {Repo~commitCallback} callback */ -Repo.prototype.commit = function(sha, callback) { +Repo.prototype.commit = function(oid, callback) { /** * @callback Repo~commitCallback Callback executed when the commit is looked up. * @param {GitError|null} error An Error or null if successful. * @param {Commit|null} commit Commit represented by sha. */ - (new git.commit(this.rawRepo)).lookup(sha, function(error, commit) { - if (success(error, callback)) { - callback(null, commit); - } - }); + var self = this; + try { + if (typeof oid === 'string') oid = git.raw.Oid.fromString(oid); + + git.raw.Commit.lookup(this.rawRepo, oid, function(error, rawCommit) { + if (success(error, callback)) { + callback(null, new git.commit(self, rawCommit)); + } + }); + } catch (e) { + callback(e); + } }; /** - * Initialise a git repository at directory. + * Retrieve the blob represented by the oid. * - * @param {String} directory - * @param {Boolean} isBare True if the repository is to be bare, false otherwise. - * @param {Repo~initCallback} callback + * @param {git.Oid} oid The OID representing the blob to lookup. + * @param {Blob~lookupCallback} callback */ -exports.init = function(directory, isBare, callback) { +Repo.prototype.blob = function(oid, callback) { /** - * @callback Repo~initCallback Callback executed when repository is initialized. + * @callback Blob~lookupCallback Callback executed on lookup completion. * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Initialized repository. + * @param {Blob|null} blob Retrieved blob object or null. */ - git.raw.Repo.init(directory, isBare, function(error, rawRepo) { + git.raw.Blob.lookup(this.rawRepo, oid.rawOid, function blobLookup(error, rawBlob) { if (success(error, callback)) { - callback(null, new Repo(rawRepo)); + callback(null, new git.blob(rawBlob)); } }); }; /** - * Create a new Repo object. If directory is not provided, simply return it. - * Otherwise open the repo asynchronously. + * Retrieve the raw tree identified by the given Oid. * - * @param {String|null} directory The directory for the git repo to open. Null - * if one does not want to open a repo. - * @param {repoCallback|null} callback - * @return {Repo|null} The Repo if no directory is provided, else undefined. + * @param {Oid} oid The Oid identifying a tree. + * @param {Tree~lookupCallback} callback */ -exports.repo = function(directory, callback) { +Repo.prototype.tree = function(oid, callback) { /** - * @callback repoCallback Callback executed if repository is opened. + * @callback Tree~lookupCallback Callback executed when the tree is retrieved. * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Opened repository. + * @param {Tree|null} tree The tree object or null. */ - if (typeof directory === 'undefined') { - return repo; - } - Repo.open(directory, callback); + var self = this; + git.raw.Tree.lookup(oid.rawOid, this.rawRepo, function(error, rawTree) { + if (success(error, callback)) { + callback(null, new git.tree(self, rawTree)); + } + }); }; + +exports.repo = Repo; diff --git a/lib/revwalk.js b/lib/revwalk.js index 30fc2b4b4..f0e9d4963 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -5,20 +5,20 @@ var git = require('../'), * Convenience revision walking class * * @constructor - * @param {git.raw.Repo} rawRepo + * @param {git.repo} repo * @param {git.raw.RevWalk|null} rawRevWalk */ -var RevWalk = function(rawRepo, rawRevWalk) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for RevWalk must be a raw repo'); +var RevWalk = function(repo, rawRevWalk) { + if (!(repo instanceof git.repo)) { + throw new git.error('First parameter for RevWalk must be a repo'); } - this.rawRepo = rawRepo; + this.repo = repo; if (typeof rawRevWalk !== 'undefined' && rawRevWalk instanceof git.raw.RevWalk) { this.rawRevWalk = rawRevWalk; } else { - this.rawRevWalk = new git.raw.RevWalk(rawRepo); + this.rawRevWalk = new git.raw.RevWalk(repo.rawRepo); } }; @@ -69,8 +69,7 @@ RevWalk.prototype.walk = function(oid, callback) { callback(null, index, null, walkOver); return; } - - (new git.commit(self.rawRepo)).lookup(oid, function revWalkCommitLookup(error, commit) { + self.repo.commit(oid, function revWalkCommitLookup(error, commit) { if(error) { callback(new git.error(error.message, error.code), index, commit); return; diff --git a/lib/tree.js b/lib/tree.js index d56d11eff..a85718010 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -6,41 +6,20 @@ var git = require('../'), * Tree convenience class constructor. * * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. + * @param {git.Repo} repo repository object. * @param {git.raw.Tree} [rawTree = new git.raw.Tree(rawRepo)] Raw tree object. */ -var Tree = function(rawRepo, rawTree) { - if(!(rawRepo instanceof git.raw.Repo)) { +var Tree = function(repo, rawTree) { + if(!(repo instanceof git.repo)) { throw new git.error('First parameter for Tree must be a raw repo'); } - this.rawRepo = rawRepo; - if(rawTree instanceof git.raw.Tree) { - this.rawTree = rawTree; - } else { - this.rawTree = new git.raw.Tree(rawRepo); + if(!(rawTree instanceof git.raw.Tree)) { + throw new git.error('Second parameter for Tree must be a raw tree'); } -}; -/** - * Retrieve the raw tree identified by the given Oid. - * - * @param {Oid} oid The Oid identifying a tree. - * @param {Tree~lookupCallback} callback - */ -Tree.prototype.lookup = function(oid, callback) { - /** - * @callback Tree~lookupCallback Callback executed when the tree is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree The tree object or null. - */ - var self = this; - self.rawTree.lookup(oid.getRawOid(), self.rawRepo, function(error, rawTree) { - if (success(error, callback)) { - self.rawTree = rawTree; - callback(null, self); - } - }); + this.repo = repo; + this.rawTree = rawTree; }; /** @@ -58,7 +37,7 @@ Tree.prototype.entry = function(path, callback) { var self = this; self.rawTree.entryByPath(path, function(error, rawEntry) { if (success(error, callback)) { - callback(null, new git.entry(self.rawRepo, rawEntry)); + callback(null, new git.entry(self.repo, rawEntry)); } }); }; @@ -84,7 +63,7 @@ Tree.prototype.walk = function(blobsOnly) { self.rawTree.walk(blobsOnly, function treeWalkEntries(error, rawEntries) { rawEntries.forEach(function treeWalkEntryEmitter(rawEntry) { - var entry = new git.entry(self.rawRepo, rawEntry); + var entry = new git.entry(self.repo, rawEntry); entries.push(entry); /** * Entry event. diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 1bd23f2e7..3b04783d1 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -2,34 +2,24 @@ var git = require('../'), path = require('path'), success = require('./utilities').success; -var fileModeIsFile = function(fileMode, instance) { - return fileMode === instance.fileModes.GIT_FILEMODE_BLOB || - fileMode === instance.fileModes.GIT_FILEMODE_BLOB_EXECUTABLE; -}; - -var fileModeIsDirectory = function(fileMode, instance) { - return fileMode === instance.fileModes.GIT_FILEMODE_TREE; -}; - /** * Convenience tree entry constructor. * * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. + * @param {git.Repo} repo Repo object. * @param {git.raw.TreeEntry} rawTreeEntry Raw tree entry object. */ -var TreeEntry = function(rawRepo, rawTreeEntry) { - if(!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Tree Entry must be a raw repo', 0); +var TreeEntry = function(repo, rawTreeEntry) { + if(!(repo instanceof git.repo)) { + throw new git.error('First parameter for Tree Entry must be a repo', 0); } if(!(rawTreeEntry instanceof git.raw.TreeEntry)) { throw new git.error('Second parameter for Tree Entry must be a raw tree entry', 0); } - this.rawRepo = rawRepo; + this.repo = repo; this.rawEntry = rawTreeEntry; - this._cache = {}; }; /** @@ -38,179 +28,50 @@ var TreeEntry = function(rawRepo, rawTreeEntry) { * @readonly * @enum {Integer} */ -TreeEntry.prototype.fileModes = { - /** 0 (0000000) */ GIT_FILEMODE_NEW: git.raw.TreeEntry.fileModes.GIT_FILEMODE_NEW, - /** 16384 (0040000) */ GIT_FILEMODE_TREE: git.raw.TreeEntry.fileModes.GIT_FILEMODE_TREE, - /** 33188 (0100644) */ GIT_FILEMODE_BLOB: git.raw.TreeEntry.fileModes.GIT_FILEMODE_BLOB, - /** 33261 (0100755) */ GIT_FILEMODE_BLOB_EXECUTABLE: git.raw.TreeEntry.fileModes.GIT_FILEMODE_BLOB_EXECUTABLE, - /** 40960 (0120000) */ GIT_FILEMODE_LINK: git.raw.TreeEntry.fileModes.GIT_FILEMODE_LINK, - /** 57344 (0160000) */ GIT_FILEMODE_COMMIT: git.raw.TreeEntry.fileModes.GIT_FILEMODE_COMMIT +TreeEntry.FileMode = { + /** 0000000 */ New: 0, + /** 0040000 */ Tree: 16384, + /** 0100644 */ Blob: 33188, + /** 0100755 */ Executable: 33261, + /** 0120000 */ Link: 40960, + /** 0160000 */ Commit: 57344 }; -/** - * Retrieve the Oid for this TreeEntry. - * - * @param {TreeEntry~oidCallback} callback - */ -TreeEntry.prototype.oid = function(callback) { - /** - * @callback TreeEntry~oidCallback Callback executed after the Oid is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {TreeEntry|null} oid The Oid object or null. - */ - this.rawEntry.oid(function(error, rawOid) { - if (success(error, callback)) { - callback(null, new git.oid(rawOid)); - } - }); +TreeEntry.prototype.isFile = function() { + return this.filemode() === TreeEntry.FileMode.Blob || + this.filemode() === TreeEntry.FileMode.Executable; }; -/** - * Retrieve the SHA for this TreeEntry. - * - * @param {TreeEntry~shaCallback} callback - */ -TreeEntry.prototype.sha = function(callback) { - /** - * @callback TreeEntry~shaCallback Callback executed after the SHA is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} sha The SHA object or null. - */ - this.rawEntry.oid(function(error, oid) { - if (!success(error, callback)) { - return; - } - var sha = new git.oid(oid).sha(); - callback(null, sha); - }); +TreeEntry.prototype.isDirectory = function() { + return this.filemode() === TreeEntry.FileMode.Tree; }; /** - * Determine whether this TreeEntry is a file (blob or blob executable). - * - * @param {TreeEntry~isFileCallback} callback - */ -TreeEntry.prototype.isFile = function(callback) { - /** - * @callback TreeEntry~isFileCallback Callback executed after type is determined. - * @param {GitError|null} error An Error or null if successful. - * @param {Boolean|null} content True if the entry is a blob or blob executable, false otherwise. - */ - var self = this; - if (typeof self._cache.fileMode !== 'undefined') { - callback(null, fileModeIsFile(self._cache.fileMode, self)); - return; - } - self.rawEntry.fileMode(function(error, fileMode) { - if (success(error, callback)) { - self._cache.fileMode = fileMode; - callback(null, fileModeIsFile(self._cache.fileMode, self)); - } - }); -}; - -/** - * Determine whether this Tree Entry is a directory. - * - * @param {TreeEntry~isDirectoryCallback} callback - */ -TreeEntry.prototype.isDirectory = function(callback) { - /** - * @callback TreeEntry~isDirectoryCallback Callback executed after type is determined. - * @param {GitError|null} error An Error or null if successful. - * @param {Boolean|null} content True if the entry is a directory, false otherwise. - */ - var self = this; - if (typeof self._cache.fileMode !== 'undefined') { - callback(null, fileModeIsDirectory(self._cache.fileMode, self)); - return; - } - self.rawEntry.fileMode(function(error, fileMode) { - if (success(error, callback)) { - self._cache.fileMode = fileMode; - callback(null, fileModeIsDirectory(self._cache.fileMode, self)); - } - }); -}; - -/** - * Retrieve the name for this TreeEntry. - * - * @param {TreeEntry~nameCallback} callback + * Retrieve the Oid for this TreeEntry. */ -TreeEntry.prototype.name = function(callback) { - /** - * @callback TreeEntry~nameCallback Callback executed after name is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} name the entry's name. - */ - this.rawEntry.name(function treeEntryName(error, name) { - if (success(error, callback)) { - callback(null, name); - } - }); +TreeEntry.prototype.oid = function(callback) { + return new git.oid(this.rawEntry.oid()); }; /** - * Retrieve the entry's root path. - * - * @param {TreeEntry~rootCallback} callback + * Retrieve the SHA for this TreeEntry. */ -TreeEntry.prototype.root = function(callback) { - /** - * @callback TreeEntry~rootCallback Callback executed after root path is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} root the entry's root path, relative to repository. - */ - this.rawEntry.root(function treeEntryRoot(error, root) { - if (success(error, callback)) { - callback(null, root); - } - }); +TreeEntry.prototype.sha = function() { + return this.oid().sha(); }; /** - * Retrieve the path relative to the repository root for this TreeEntry. - * - * @param {TreeEntry~pathCallback} callback + * Retrieve the SHA for this TreeEntry. */ -TreeEntry.prototype.path = function(callback) { - /** - * @callback TreeEntry~pathCallback Callback executed after path is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} path the entry's full path relative to repository. - */ - var self = this; - self.root(function treeEntryRoot(error, root) { - if (!success(error, callback)) { - return; - } - self.rawEntry.name(function treeEntryName(error, name) { - if (success(error, callback)) { - callback(null, path.join(root, name)); - } - }); - }); +TreeEntry.prototype.filemode = function() { + return this.rawEntry.filemode(); }; /** - * Retrieve the TreeEntry's content. - * - * @param {TreeEntry~contentCallback} callback + * Retrieve the name for this TreeEntry. */ -TreeEntry.prototype.content = function(callback) { - /** - * @callback TreeEntry~contentCallback Callback executed after content is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} content the entry's content. - */ - this.toBlob(function convertBlob(error, blob) { - if (!success(error, callback)) { - return; - } - var content = blob.content(); - callback(null, content); - }); +TreeEntry.prototype.name = function() { + return this.rawEntry.name(); }; /** @@ -218,43 +79,31 @@ TreeEntry.prototype.content = function(callback) { * * @param {TreeEntry~blobCallback} callback */ -TreeEntry.prototype.toBlob = function(callback) { +TreeEntry.prototype.getBlob = function(callback) { + if (!this.isFile()) return callback(new git.error('Not a blob/file', 0)); + /** * @callback TreeEntry~blobCallback Callback executed after blob is retrieved. * @param {GitError|null} error An Error or null if successful. * @param {Blob|null} blob the blob representation of the entry. */ - var self = this; - self.rawEntry.toBlob(self.rawRepo, function blobCallback(error, rawBlob) { - if (success(error, callback)) { - callback(null, new git.blob(self.rawRepo, rawBlob)); - } - }); + this.repo.blob(this.oid(), callback); }; /** - * Retrieve the TreeEntry's Tree. + * Convert the TreeEntry to a tree. * * @param {TreeEntry~treeCallback} callback */ -TreeEntry.prototype.tree = function(callback) { +TreeEntry.prototype.getTree = function(callback) { + if (!this.isDirectory()) return callback(new git.error('Not a tree/directory', 0)); + /** - * @callback TreeEntry~treeCallback Callback executed after tree is retrieved. + * @callback TreeEntry~treeCallback Callback executed after blob is retrieved. * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree the entry's tree. + * @param {Tree|null} blob the blob representation of the entry. */ - var self = this; - self.oid(function treeEntryOid(error, oid) { - if (!success(error, callback)) { - return; - } - (new git.tree(self.rawRepo)).lookup(oid, function(error, tree) { - if (!success(error, callback)) { - return; - } - callback(null, tree); - }); - }); + this.repo.tree(this.oid(), callback); }; exports.entry = TreeEntry; diff --git a/src/base.cc b/src/base.cc index 0b1274a1b..504d64a1f 100755 --- a/src/base.cc +++ b/src/base.cc @@ -13,10 +13,12 @@ #include "../include/wrapper.h" #include "../include/reference.h" #include "../include/signature.h" +#include "../include/time.h" #include "../include/error.h" #include "../include/blob.h" #include "../include/repo.h" #include "../include/oid.h" +#include "../include/object.h" #include "../include/commit.h" #include "../include/revwalk.h" #include "../include/tree.h" @@ -33,8 +35,10 @@ extern "C" void init(Handle target) { GitReference::Initialize(target); GitSignature::Initialize(target); + GitTime::Initialize(target); GitBlob::Initialize(target); GitOid::Initialize(target); + GitObject::Initialize(target); GitRepo::Initialize(target); GitCommit::Initialize(target); GitRevWalk::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index ebecae642..1832ef8b3 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -43,6 +43,7 @@ void GitBlob::Initialize(Handle target) { NODE_SET_METHOD(tpl, "createFromBuffer", CreateFromBuffer); NODE_SET_PROTOTYPE_METHOD(tpl, "isBinary", IsBinary); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Blob"), constructor_template); } @@ -69,10 +70,10 @@ Handle GitBlob::Lookup(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required."))); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required."))); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -140,6 +141,7 @@ Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; const git_oid * result = git_blob_id( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -152,6 +154,7 @@ Handle GitBlob::Content(const Arguments& args) { HandleScope scope; const void * result = git_blob_rawcontent( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -164,6 +167,7 @@ Handle GitBlob::Size(const Arguments& args) { HandleScope scope; git_off_t result = git_blob_rawsize( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -174,10 +178,10 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required."))); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required."))); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -248,13 +252,13 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required."))); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Buffer is required."))); + return ThrowException(Exception::Error(String::New("Buffer buffer is required."))); } if (args.Length() == 2 || !args[2]->IsNumber()) { - return ThrowException(Exception::Error(String::New("Number is required."))); + return ThrowException(Exception::Error(String::New("Number len is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -268,7 +272,7 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { // Either ref the argument or copy? baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[1]->ToObject())); - baton->len = args[2]->ToNumber()->Value(); + baton->len = (size_t) args[2]->ToNumber()->Value(); baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromBufferWork, (uv_after_work_cb)CreateFromBufferAfterWork); @@ -322,13 +326,15 @@ Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; int result = git_blob_is_binary( + ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); + return ThrowException(GitError::WrapError(giterr_last())); } return scope.Close(Boolean::New(result)); } + Persistent GitBlob::constructor_template; diff --git a/src/commit.cc b/src/commit.cc index 7f9820da7..f9bad26f2 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -1,33 +1,33 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include #include #include "git2.h" -#include "cvv8/v8-convert.hpp" -#include "../include/reference.h" -#include "../include/signature.h" -#include "../include/repo.h" +#include "../include/commit.h" #include "../include/oid.h" +#include "../include/repo.h" +#include "../include/signature.h" #include "../include/tree.h" -#include "../include/commit.h" -#include "../include/error.h" #include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; -using namespace cvv8; using namespace node; -void GitCommit::Initialize(Handle target) { +GitCommit::GitCommit(git_commit *raw) { + this->raw = raw; +} + +GitCommit::~GitCommit() { + git_commit_free(this->raw); +} + +void GitCommit::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -35,452 +35,342 @@ void GitCommit::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Commit")); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); + NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "messageEncoding", MessageEncoding); NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); - NODE_SET_PROTOTYPE_METHOD(tpl, "author", Author); NODE_SET_PROTOTYPE_METHOD(tpl, "committer", Committer); + NODE_SET_PROTOTYPE_METHOD(tpl, "author", Author); NODE_SET_PROTOTYPE_METHOD(tpl, "tree", Tree); - NODE_SET_PROTOTYPE_METHOD(tpl, "parents", Parents); + NODE_SET_PROTOTYPE_METHOD(tpl, "treeId", TreeId); + NODE_SET_PROTOTYPE_METHOD(tpl, "parentCount", ParentCount); + NODE_SET_PROTOTYPE_METHOD(tpl, "parent", Parent); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Commit"), constructor_template); } -git_commit* GitCommit::GetValue() { - return this->commit; -} -void GitCommit::SetValue(git_commit* commit) { - this->commit = commit; -} -void GitCommit::SetOid(git_oid* oid) { - this->oid = oid; -} - Handle GitCommit::New(const Arguments& args) { HandleScope scope; - GitCommit *commit = new GitCommit(); - commit->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_commit is required."))); + } + + GitCommit* object = new GitCommit((git_commit *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitCommit::Free(const Arguments& args) { - HandleScope scope; - - GitCommit *commit = ObjectWrap::Unwrap(args.This()); - git_commit_free(commit->commit); - commit->commit = NULL; - return Undefined(); +git_commit *GitCommit::GetValue() { + return this->raw; } + Handle GitCommit::Lookup(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - - if(args.Length() == 1 || !(args[1]->IsObject() || args[1]->IsString())) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object or String"))); + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - LookupBaton *baton = new LookupBaton; - baton->request.data = baton; + LookupBaton* baton = new LookupBaton; baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - if (args[1]->IsObject()) { - baton->rawOid = *ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - baton->sha = stringArgToString(args[1]->ToString()); - } + baton->request.data = baton; + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); return Undefined(); } + void GitCommit::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - - if (!baton->sha.empty()) { - int returnCode = git_oid_fromstr(&baton->rawOid, baton->sha.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - } - - baton->rawCommit = NULL; - int returnCode = git_commit_lookup(&baton->rawCommit, baton->repo, &baton->rawOid); - if (returnCode != GIT_OK) { + int result = git_commit_lookup( + &baton->commit, + baton->repo, + baton->id + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } + void GitCommit::LookupAfterWork(uv_work_t *req) { HandleScope scope; LookupBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Local commit = GitCommit::constructor_template->NewInstance(); - GitCommit *commitInstance = ObjectWrap::Unwrap(commit); - commitInstance->SetValue(baton->rawCommit); - commitInstance->SetOid(&baton->rawOid); + TryCatch try_catch; + if (!baton->error) { - Handle argv[2] = { + Handle argv[1] = { External::New(baton->commit) }; + Handle object = GitCommit::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { Local::New(Null()), - commit + object }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + + baton->callback.Dispose(); + delete baton; } Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; - git_oid *rawOid = (git_oid *)malloc(sizeof(git_oid)); - git_oid_cpy(rawOid, ObjectWrap::Unwrap(args.This())->oid); - Handle argv[1] = { External::New(rawOid) }; + const git_oid * result = git_commit_id( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } -Handle GitCommit::Message(const Arguments& args) { +Handle GitCommit::MessageEncoding(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - MessageBaton* baton = new MessageBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + const char * result = git_commit_message_encoding( - uv_queue_work(uv_default_loop(), &baton->request, MessageWork, (uv_after_work_cb)MessageAfterWork); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + return scope.Close(String::New(result)); } -void GitCommit::MessageWork(uv_work_t* req) { - MessageBaton *baton = static_cast(req->data); - baton->message = git_commit_message(baton->rawCommit); -} -void GitCommit::MessageAfterWork(uv_work_t* req) { +Handle GitCommit::Message(const Arguments& args) { HandleScope scope; - MessageBaton *baton = static_cast(req->data); - Handle argv[2] = { - Local::New(Null()), - String::New(baton->message.c_str()) - }; + const char * result = git_commit_message( - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(String::New(result)); } Handle GitCommit::Time(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TimeBaton* baton = new TimeBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + git_time_t result = git_commit_time( - uv_queue_work(uv_default_loop(), &baton->request, TimeWork, (uv_after_work_cb)TimeAfterWork); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + return scope.Close(Number::New(result)); } -void GitCommit::TimeWork(uv_work_t* req) { - TimeBaton *baton = static_cast(req->data); - baton->time = git_commit_time(baton->rawCommit); -} -void GitCommit::TimeAfterWork(uv_work_t* req) { +Handle GitCommit::Offset(const Arguments& args) { HandleScope scope; - TimeBaton *baton = static_cast(req->data); - Handle argv[2] = { - Local::New(Null()), - Integer::New(baton->time) - }; + int result = git_commit_time_offset( - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(Integer::New(result)); } -Handle GitCommit::Offset(const Arguments& args) { +Handle GitCommit::Committer(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - OffsetBaton* baton = new OffsetBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + const git_signature * result = git_commit_committer( - uv_queue_work(uv_default_loop(), &baton->request, OffsetWork, (uv_after_work_cb)OffsetAfterWork); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); } -void GitCommit::OffsetWork(uv_work_t* req) { - OffsetBaton *baton = static_cast(req->data); - baton->offset = git_commit_time_offset(baton->rawCommit); -} -void GitCommit::OffsetAfterWork(uv_work_t* req) { +Handle GitCommit::Author(const Arguments& args) { HandleScope scope; - OffsetBaton *baton = static_cast(req->data); - Handle argv[2] = { - Local::New(Null()), - Integer::New(baton->offset) - }; + const git_signature * result = git_commit_author( - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); } -Handle GitCommit::Author(const Arguments& args) { +Handle GitCommit::Tree(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - SignatureBaton* baton = new SignatureBaton; + TreeBaton* baton = new TreeBaton; + baton->error = NULL; baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); + + baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); - uv_queue_work(uv_default_loop(), &baton->request, AuthorWork, (uv_after_work_cb)AuthorAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, TreeWork, (uv_after_work_cb)TreeAfterWork); return Undefined(); } -void GitCommit::AuthorWork(uv_work_t* req) { - SignatureBaton *baton = static_cast(req->data); - baton->rawSignature = git_commit_author(baton->rawCommit); +void GitCommit::TreeWork(uv_work_t *req) { + TreeBaton *baton = static_cast(req->data); + int result = git_commit_tree( + &baton->tree_out, + baton->commit + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } } -void GitCommit::AuthorAfterWork(uv_work_t* req) { + +void GitCommit::TreeAfterWork(uv_work_t *req) { HandleScope scope; - SignatureBaton *baton = static_cast(req->data); + TreeBaton *baton = static_cast(req->data); - Local signature = GitSignature::constructor_template->NewInstance(); - GitSignature *signatureInstance = ObjectWrap::Unwrap(signature); - signatureInstance->SetValue(const_cast(baton->rawSignature)); + TryCatch try_catch; + if (!baton->error) { - Handle argv[2] = { - Local::New(Null()), - signature - }; + Handle argv[1] = { External::New(baton->tree_out) }; + Handle object = GitTree::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); if (try_catch.HasCaught()) { node::FatalException(try_catch); } - delete req; + + baton->callback.Dispose(); + delete baton; } -Handle GitCommit::Committer(const Arguments& args) { +Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - SignatureBaton* baton = new SignatureBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + const git_oid * result = git_commit_tree_id( - uv_queue_work(uv_default_loop(), &baton->request, CommitterWork, (uv_after_work_cb)CommitterAfterWork); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } -void GitCommit::CommitterWork(uv_work_t* req) { - SignatureBaton *baton = static_cast(req->data); - baton->rawSignature = git_commit_committer(baton->rawCommit); -} -void GitCommit::CommitterAfterWork(uv_work_t* req) { +Handle GitCommit::ParentCount(const Arguments& args) { HandleScope scope; - SignatureBaton *baton = static_cast(req->data); - Local signature = GitSignature::constructor_template->NewInstance(); - GitSignature *signatureInstance = ObjectWrap::Unwrap(signature); - signatureInstance->SetValue(const_cast(baton->rawSignature)); + unsigned int result = git_commit_parentcount( - Handle argv[2] = { - Local::New(Null()), - signature - }; + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + return scope.Close(Uint32::New(result)); } -Handle GitCommit::Tree(const Arguments& args) { +Handle GitCommit::Parent(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); + } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - TreeBaton* baton = new TreeBaton; - baton->request.data = baton; + ParentBaton* baton = new ParentBaton; baton->error = NULL; - baton->rawTree = NULL; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + baton->request.data = baton; - uv_queue_work(uv_default_loop(), &baton->request, TreeWork, (uv_after_work_cb)TreeAfterWork); + baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->n = (unsigned int) args[0]->ToUint32()->Value(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, ParentWork, (uv_after_work_cb)ParentAfterWork); return Undefined(); } -void GitCommit::TreeWork(uv_work_t* req) { - TreeBaton* baton = static_cast(req->data); - int returnCode = git_commit_tree(&baton->rawTree, baton->rawCommit); - if (returnCode != GIT_OK) { +void GitCommit::ParentWork(uv_work_t *req) { + ParentBaton *baton = static_cast(req->data); + int result = git_commit_parent( + &baton->out, + baton->commit, + baton->n + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitCommit::TreeAfterWork(uv_work_t* req) { + +void GitCommit::ParentAfterWork(uv_work_t *req) { HandleScope scope; - TreeBaton* baton = static_cast(req->data); + ParentBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Local tree = GitTree::constructor_template->NewInstance(); - GitTree *treeInstance = ObjectWrap::Unwrap(tree); - treeInstance->SetValue(baton->rawTree); + TryCatch try_catch; + if (!baton->error) { - Handle argv[2] = { + Handle argv[1] = { External::New(baton->out) }; + Handle object = GitCommit::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { Local::New(Null()), - tree + object }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } - delete req; -} -Handle GitCommit::Parents(const Arguments& args) { - HandleScope scope; - - if(args.Length() == 0 && !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - ParentsBaton* baton = new ParentsBaton; - baton->request.data = baton; - baton->error = NULL; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, ParentsWork, (uv_after_work_cb)ParentsAfterWork); - - return Undefined(); -} -void GitCommit::ParentsWork(uv_work_t* req) { - ParentsBaton* baton = static_cast(req->data); - - int parentCount = git_commit_parentcount(baton->rawCommit); - while (parentCount > 0) { - git_commit* rawParentCommit = NULL; - - int parentIndex = parentCount -1; - int returnCode = git_commit_parent(&rawParentCommit, baton->rawCommit, parentIndex); - - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - - const git_oid* rawParentOid = git_commit_id(rawParentCommit); - - Parent* parent = new Parent; - parent->rawCommit = rawParentCommit; - parent->rawOid = rawParentOid; - - baton->parents.push_back(parent); - - parentCount--; - } + baton->callback.Dispose(); + delete baton; } -void GitCommit::ParentsAfterWork(uv_work_t* req) { - HandleScope scope; - ParentsBaton* baton = static_cast(req->data); - - if (success(baton->error, baton->callback)) { - std::vector > parents; - - for(std::vector::iterator parentIterator = baton->parents.begin(); parentIterator != baton->parents.end(); ++parentIterator) { - Parent *parentData = (*parentIterator); - - Local parent = GitCommit::constructor_template->NewInstance(); - GitCommit *parentInstance = ObjectWrap::Unwrap(parent); - parentInstance->SetValue(parentData->rawCommit); - parentInstance->SetOid(const_cast(parentData->rawOid)); - - parents.push_back(parent); - } - Handle argv[2] = { - Local::New(Null()), - cvv8::CastToJS(parents) - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - delete req; -} Persistent GitCommit::constructor_template; diff --git a/src/diff_list.cc b/src/diff_list.cc index 018b9ff5c..38607dcf2 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -21,6 +21,14 @@ using namespace v8; using namespace node; using namespace cvv8; +GitDiffList::GitDiffList(git_diff_list *raw) { + this->raw = raw; +} + +GitDiffList::~GitDiffList() { + git_diff_list_free(this->raw); +} + namespace cvv8 { template <> struct NativeToJS : NativeToJS {}; @@ -34,9 +42,8 @@ void GitDiffList::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("DiffList")); - NODE_SET_PROTOTYPE_METHOD(tpl, "treeToTree", TreeToTree); + NODE_SET_METHOD(tpl, "treeToTree", TreeToTree); NODE_SET_PROTOTYPE_METHOD(tpl, "walk", Walk); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); // Add libgit2 delta types to diff_list object Local libgit2DeltaTypes = Object::New(); @@ -101,29 +108,20 @@ void GitDiffList::Initialize(Handle target) { } git_diff_list* GitDiffList::GetValue() { - return this->diffList; -} - -void GitDiffList::SetValue(git_diff_list* diffList) { - this->diffList = diffList; + return this->raw; } Handle GitDiffList::New(const Arguments& args) { HandleScope scope; - GitDiffList *diffList = new GitDiffList(); - diffList->Wrap(args.This()); - - return scope.Close(args.This()); -} -Handle GitDiffList::Free(const Arguments& args) { - HandleScope scope; + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_list is required."))); + } - GitDiffList *diffList = ObjectWrap::Unwrap(args.This()); - git_diff_list_free(diffList->diffList); - diffList->diffList = NULL; + GitDiffList* object = new GitDiffList((git_diff_list *) External::Unwrap(args[0])); + object->Wrap(args.This()); - return scope.Close(Undefined()); + return scope.Close(args.This()); } Handle GitDiffList::TreeToTree(const Arguments& args) { @@ -148,7 +146,6 @@ Handle GitDiffList::TreeToTree(const Arguments& args) { TreeToTreeBaton *baton = new TreeToTreeBaton; baton->request.data = baton; baton->error = NULL; - baton->diffList = ObjectWrap::Unwrap(args.This()); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); if (args[1]->IsObject()) { @@ -242,8 +239,11 @@ void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { node::FatalException(try_catch); } } else { + Handle argv2[1] = { + External::New(baton->rawDiffList) + }; - baton->diffList->SetValue(baton->rawDiffList); + baton->diffList = ObjectWrap::Unwrap(GitDiffList::constructor_template->NewInstance(1, argv2)); Handle argv[2] = { Local::New(Null()), diff --git a/src/object.cc b/src/object.cc new file mode 100644 index 000000000..ae048138a --- /dev/null +++ b/src/object.cc @@ -0,0 +1,229 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/object.h" +#include "../include/oid.h" +#include "../include/repo.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitObject::GitObject(git_object *raw) { + this->raw = raw; +} + +GitObject::~GitObject() { + git_object_free(this->raw); +} + +void GitObject::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Object")); + + NODE_SET_METHOD(tpl, "lookup", Lookup); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Object"), constructor_template); +} + +Handle GitObject::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_object is required."))); + } + + GitObject* object = new GitObject((git_object *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +git_object *GitObject::GetValue() { + return this->raw; +} + + +Handle GitObject::Lookup(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + LookupBaton* baton = new LookupBaton; + baton->error = NULL; + baton->request.data = baton; + + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->type = (git_otype) args[2]->ToInt32()->Value(); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); + + return Undefined(); +} + +void GitObject::LookupWork(uv_work_t *req) { + LookupBaton *baton = static_cast(req->data); + int result = git_object_lookup( + &baton->object, + baton->repo, + baton->id, + baton->type + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitObject::LookupAfterWork(uv_work_t *req) { + HandleScope scope; + LookupBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle argv[1] = { External::New(baton->object) }; + Handle object = GitObject::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + + baton->callback.Dispose(); + delete baton; +} + +Handle GitObject::Oid(const Arguments& args) { + HandleScope scope; + + const git_oid * result = git_object_id( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} + +Handle GitObject::Type(const Arguments& args) { + HandleScope scope; + + git_otype result = git_object_type( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(Number::New(result)); +} + +Handle GitObject::Peel(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number target_type is required."))); + } + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + PeelBaton* baton = new PeelBaton; + baton->error = NULL; + baton->request.data = baton; + + baton->object = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->target_type = (git_otype) args[0]->ToInt32()->Value(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, PeelWork, (uv_after_work_cb)PeelAfterWork); + + return Undefined(); +} + +void GitObject::PeelWork(uv_work_t *req) { + PeelBaton *baton = static_cast(req->data); + int result = git_object_peel( + &baton->peeled, + baton->object, + baton->target_type + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitObject::PeelAfterWork(uv_work_t *req) { + HandleScope scope; + PeelBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle argv[1] = { External::New(baton->peeled) }; + Handle object = GitObject::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + object + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + + baton->callback.Dispose(); + delete baton; +} + + +Persistent GitObject::constructor_template; diff --git a/src/oid.cc b/src/oid.cc index a93cbcca6..15d5d4480 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -20,7 +20,6 @@ GitOid::GitOid(git_oid *raw) { } GitOid::~GitOid() { - free(this->raw); } void GitOid::Initialize(Handle target) { @@ -34,6 +33,7 @@ void GitOid::Initialize(Handle target) { NODE_SET_METHOD(tpl, "fromString", FromString); NODE_SET_PROTOTYPE_METHOD(tpl, "sha", Sha); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Oid"), constructor_template); } @@ -60,18 +60,20 @@ Handle GitOid::FromString(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required."))); + return ThrowException(Exception::Error(String::New("String str is required."))); } git_oid * out; out = (git_oid *)malloc(sizeof(git_oid)); int result = git_oid_fromstr( + out -, stringArgToString(args[0]->ToString()).c_str() +, + stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); + return ThrowException(GitError::WrapError(giterr_last())); } // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; @@ -82,10 +84,12 @@ Handle GitOid::Sha(const Arguments& args) { HandleScope scope; char * result = git_oid_allocfmt( + ObjectWrap::Unwrap(args.This())->GetValue() ); return scope.Close(String::New(result)); } + Persistent GitOid::constructor_template; diff --git a/src/reference.cc b/src/reference.cc index 2e17a8c7d..1ee822471 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -40,6 +40,7 @@ void GitReference::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "resolve", Resolve); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Reference"), constructor_template); } @@ -66,10 +67,10 @@ Handle GitReference::Lookup(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required."))); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required."))); + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -140,10 +141,10 @@ Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required."))); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required."))); + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -214,6 +215,7 @@ Handle GitReference::Oid(const Arguments& args) { HandleScope scope; const git_oid * result = git_reference_target( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -226,6 +228,7 @@ Handle GitReference::Name(const Arguments& args) { HandleScope scope; const char * result = git_reference_symbolic_target( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -236,6 +239,7 @@ Handle GitReference::Type(const Arguments& args) { HandleScope scope; git_ref_t result = git_reference_type( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -301,4 +305,5 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { delete baton; } + Persistent GitReference::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 1fc60d3a4..ea7285ddc 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -36,6 +36,7 @@ void GitRepo::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); NODE_SET_PROTOTYPE_METHOD(tpl, "workdir", Workdir); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Repo"), constructor_template); } @@ -62,7 +63,7 @@ Handle GitRepo::Open(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required."))); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -129,10 +130,10 @@ Handle GitRepo::Init(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required."))); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsBoolean()) { - return ThrowException(Exception::Error(String::New("Boolean is required."))); + return ThrowException(Exception::Error(String::New("Boolean is_bare is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); @@ -145,7 +146,7 @@ Handle GitRepo::Init(const Arguments& args) { String::Utf8Value path(args[0]->ToString()); // XXX FIXME remove strdup and use std::string baton->path = strdup(*path); - baton->is_bare = args[1]->ToBoolean()->Value(); + baton->is_bare = (unsigned) args[1]->ToBoolean()->Value(); baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); @@ -201,6 +202,7 @@ Handle GitRepo::Path(const Arguments& args) { HandleScope scope; const char * result = git_repository_path( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -211,10 +213,12 @@ Handle GitRepo::Workdir(const Arguments& args) { HandleScope scope; const char * result = git_repository_workdir( + ObjectWrap::Unwrap(args.This())->GetValue() ); return scope.Close(String::New(result)); } + Persistent GitRepo::constructor_template; diff --git a/src/revwalk.cc b/src/revwalk.cc index e53c408f4..97b10981f 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -10,6 +10,7 @@ #include "git2.h" +#include "../include/oid.h" #include "../include/revwalk.h" #include "../include/repo.h" #include "../include/commit.h" diff --git a/src/signature.cc b/src/signature.cc index 49b775403..38f0d9bf0 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -1,90 +1,112 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" -#include "../include/repo.h" #include "../include/signature.h" +#include "../include/time.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; +GitSignature::GitSignature(git_signature *raw) { + this->raw = raw; +} + +GitSignature::~GitSignature() { +} + void GitSignature::Initialize(Handle target) { + HandleScope scope; + Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Signature")); - NODE_SET_PROTOTYPE_METHOD(tpl, "duplicate", Duplicate); + NODE_SET_METHOD(tpl, "now", Now); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "email", Email); - - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); + NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Signature"), constructor_template); } -git_signature* GitSignature::GetValue() { - return this->signature; -} - -void GitSignature::SetValue(git_signature* signature) { - this->signature = signature; -} - Handle GitSignature::New(const Arguments& args) { HandleScope scope; - GitSignature *signature = new GitSignature(); - signature->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_signature is required."))); + } + + GitSignature* object = new GitSignature((git_signature *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitSignature::Free(const Arguments& args) { - HandleScope scope; - - GitSignature *signature = ObjectWrap::Unwrap(args.This()); - git_signature_free(signature->signature); - signature->signature = NULL; - - return Undefined(); +git_signature *GitSignature::GetValue() { + return this->raw; } -Handle GitSignature::Duplicate(const Arguments& args) { - HandleScope scope; - - Local duplicateSignature = GitSignature::constructor_template->NewInstance(); - GitSignature *duplicateSignatureInstance = ObjectWrap::Unwrap(duplicateSignature); - GitSignature* signature = ObjectWrap::Unwrap(args.This()); - duplicateSignatureInstance->SetValue(git_signature_dup(signature->GetValue())); +Handle GitSignature::Now(const Arguments& args) { + HandleScope scope; - return duplicateSignature; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String email is required."))); + } + git_signature * out; + + int result = git_signature_now( +& + out +, + stringArgToString(args[0]->ToString()).c_str() +, + stringArgToString(args[1]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); } Handle GitSignature::Name(const Arguments& args) { HandleScope scope; + const char * field = ObjectWrap::Unwrap(args.This())->GetValue()->name; - GitSignature *signature = ObjectWrap::Unwrap(args.This()); - - return scope.Close(String::New(signature->GetValue()->name)); + return scope.Close(String::New(field)); } - Handle GitSignature::Email(const Arguments& args) { HandleScope scope; + const char * field = ObjectWrap::Unwrap(args.This())->GetValue()->email; - GitSignature *signature = ObjectWrap::Unwrap(args.This()); + return scope.Close(String::New(field)); +} +Handle GitSignature::Time(const Arguments& args) { + HandleScope scope; + git_time field = ObjectWrap::Unwrap(args.This())->GetValue()->when; - return scope.Close(String::New(signature->GetValue()->email)); + // XXX need to copy object? + Handle argv[1] = { External::New((void *)&field) }; + return scope.Close(GitTime::constructor_template->NewInstance(1, argv)); } Persistent GitSignature::constructor_template; diff --git a/src/time.cc b/src/time.cc new file mode 100644 index 000000000..d5f7a1ac6 --- /dev/null +++ b/src/time.cc @@ -0,0 +1,73 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/time.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitTime::GitTime(git_time *raw) { + this->raw = raw; +} + +GitTime::~GitTime() { + free(this->raw); +} + +void GitTime::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Time")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); + NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Time"), constructor_template); +} + +Handle GitTime::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_time is required."))); + } + + GitTime* object = new GitTime((git_time *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +git_time *GitTime::GetValue() { + return this->raw; +} + + +Handle GitTime::Time(const Arguments& args) { + HandleScope scope; + git_time_t field = ObjectWrap::Unwrap(args.This())->GetValue()->time; + + return scope.Close(Integer::New(field)); +} +Handle GitTime::Offset(const Arguments& args) { + HandleScope scope; + int field = ObjectWrap::Unwrap(args.This())->GetValue()->offset; + + return scope.Close(Int32::New(field)); +} + +Persistent GitTime::constructor_template; diff --git a/src/tree.cc b/src/tree.cc index 7211ddcd5..72cb7fddc 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -25,6 +25,14 @@ using namespace v8; using namespace node; using namespace cvv8; +GitTree::GitTree(git_tree *raw) { + this->raw = raw; +} + +GitTree::~GitTree() { + git_tree_free(this->raw); +} + void GitTree::Initialize (Handle target) { HandleScope scope; @@ -33,7 +41,7 @@ void GitTree::Initialize (Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Tree")); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); + NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "walk", Walk); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByPath", EntryByPath); @@ -42,18 +50,18 @@ void GitTree::Initialize (Handle target) { } git_tree* GitTree::GetValue() { - return this->tree; -} -void GitTree::SetValue(git_tree* tree) { - this->tree = tree; + return this->raw; } Handle GitTree::New(const Arguments& args) { HandleScope scope; - GitTree *tree = new GitTree(); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_tree is required."))); + } - tree->Wrap(args.This()); + GitTree* object = new GitTree((git_tree *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } @@ -76,7 +84,6 @@ Handle GitTree::Lookup(const Arguments& args) { LookupBaton* baton = new LookupBaton; baton->request.data = baton; baton->error = NULL; - baton->rawTree = ObjectWrap::Unwrap(args.This())->GetValue(); baton->rawOid = *ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->rawRepo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -98,17 +105,18 @@ void GitTree::LookupAfterWork(uv_work_t* req) { LookupBaton* baton = static_cast(req->data); if (success(baton->error, baton->callback)) { - Local tree = GitTree::constructor_template->NewInstance(); - GitTree *treeInstance = ObjectWrap::Unwrap(tree); - treeInstance->SetValue(baton->rawTree); + Handle argv[1] = { + External::New(baton->rawTree) + }; + Local tree = GitTree::constructor_template->NewInstance(1, argv); - Handle argv[2] = { + Handle argv2[2] = { Local::New(Null()), tree }; TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); if (try_catch.HasCaught()) { node::FatalException(try_catch); } @@ -219,24 +227,25 @@ void GitTree::WalkWorkSendEntry(uv_async_t *handle, int status /*UNUSED*/) { for(std::vector::iterator treeEntriesIterator = baton->rawTreeEntries.begin(); treeEntriesIterator != baton->rawTreeEntries.end(); ++treeEntriesIterator) { WalkEntry* walkEntry = (*treeEntriesIterator); + + Handle argv[1] = { + External::New(walkEntry->rawEntry) + }; - Local entry = GitTreeEntry::constructor_template->NewInstance(); - GitTreeEntry *entryInstance = ObjectWrap::Unwrap(entry); - entryInstance->SetValue(walkEntry->rawEntry); - entryInstance->SetRoot(walkEntry->root); + Local entry = GitTreeEntry::constructor_template->NewInstance(1, argv); treeEntries.push_back(entry); } baton->rawTreeEntries.clear(); - Handle argv[2] = { + Handle argv2[2] = { Local::New(Null()), CastToJS(treeEntries) }; TryCatch try_catch; - baton->entryCallback->Call(Context::GetCurrent()->Global(), 2, argv); + baton->entryCallback->Call(Context::GetCurrent()->Global(), 2, argv2); if (try_catch.HasCaught()) { node::FatalException(try_catch); } @@ -304,18 +313,18 @@ void GitTree::EntryByPathAfterWork(uv_work_t *req) { EntryByPathBaton *baton = static_cast(req->data); if (success(baton->error, baton->callback)) { - Local entry = GitTreeEntry::constructor_template->NewInstance(); - GitTreeEntry *entryInstance = ObjectWrap::Unwrap(entry); - entryInstance->SetValue(baton->rawEntry); - entryInstance->SetRoot(baton->path.substr(0, baton->path.find_last_of("\\/"))); + Handle argv[1] = { + External::New(baton->rawEntry) + }; + Local entry = GitTreeEntry::constructor_template->NewInstance(1, argv); - Handle argv[2] = { + Handle argv2[2] = { Local::New(Null()), entry }; TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); if (try_catch.HasCaught()) { node::FatalException(try_catch); } diff --git a/src/tree_entry.cc b/src/tree_entry.cc index ff3d39e82..0e147636a 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -1,278 +1,179 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include - -#include "cvv8/v8-convert.hpp" +#include #include "git2.h" -#include "../include/repo.h" -#include "../include/blob.h" -#include "../include/tree.h" -#include "../include/oid.h" #include "../include/tree_entry.h" -#include "../include/error.h" +#include "../include/oid.h" +#include "../include/repo.h" +#include "../include/object.h" #include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -using namespace cvv8; -namespace cvv8 { - template <> - struct NativeToJS : NativeToJS {}; +GitTreeEntry::GitTreeEntry(git_tree_entry *raw) { + this->raw = raw; +} + +GitTreeEntry::~GitTreeEntry() { + git_tree_entry_free(this->raw); } void GitTreeEntry::Initialize(Handle target) { + HandleScope scope; + Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("TreeEntry")); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); - NODE_SET_PROTOTYPE_METHOD(tpl, "root", Root); - NODE_SET_PROTOTYPE_METHOD(tpl, "fileMode", FileMode); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "toBlob", ToBlob); - - // Add libgit2 file modes to entry object - Local libgit2FileModes = Object::New(); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "filemode", filemode); + NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_NEW"), CastToJS(GIT_FILEMODE_NEW), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_TREE"), CastToJS(GIT_FILEMODE_TREE), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_BLOB"), CastToJS(GIT_FILEMODE_BLOB), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_BLOB_EXECUTABLE"), CastToJS(GIT_FILEMODE_BLOB_EXECUTABLE), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_LINK"), CastToJS(GIT_FILEMODE_LINK), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_COMMIT"), CastToJS(GIT_FILEMODE_COMMIT), ReadOnly); constructor_template = Persistent::New(tpl->GetFunction()); - constructor_template->Set(String::NewSymbol("fileModes"), libgit2FileModes, ReadOnly); target->Set(String::NewSymbol("TreeEntry"), constructor_template); } -git_tree_entry* GitTreeEntry::GetValue() { - return this->entry; -} -void GitTreeEntry::SetValue(git_tree_entry* entry) { - this->entry = entry; -} -void GitTreeEntry::SetRoot(std::string root) { - this->root = root; -} -std::string GitTreeEntry::GetRoot() { - return this->root; -} - Handle GitTreeEntry::New(const Arguments& args) { HandleScope scope; - GitTreeEntry *entry = new GitTreeEntry(); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_tree_entry is required."))); + } - entry->Wrap(args.This()); + GitTreeEntry* object = new GitTreeEntry((git_tree_entry *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitTreeEntry::Root(const Arguments& args) { - HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - GitTreeEntry *entry = ObjectWrap::Unwrap(args.This()); - - Handle argv[2] = { - Local::New(Null()), - String::New(entry->GetRoot().c_str()) - }; - - TryCatch try_catch; - Local::Cast(args[0])->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - - return Undefined(); +git_tree_entry *GitTreeEntry::GetValue() { + return this->raw; } + Handle GitTreeEntry::Name(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - NameBaton *baton = new NameBaton; - baton->request.data = baton; - - GitTreeEntry *treeEntry = ObjectWrap::Unwrap(args.This()); - baton->rawEntry = treeEntry->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, NameWork, (uv_after_work_cb)NameAfterWork); + const char * result = git_tree_entry_name( - return Undefined(); -} -void GitTreeEntry::NameWork(uv_work_t* req) { - NameBaton *baton = static_cast(req->data); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - baton->name = git_tree_entry_name(baton->rawEntry); -} -void GitTreeEntry::NameAfterWork(uv_work_t* req) { - HandleScope scope; - NameBaton *baton = static_cast(req->data); - - Handle argv[2] = { - Local::New(Null()), - String::New(baton->name) - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + return scope.Close(String::New(result)); } -Handle GitTreeEntry::FileMode(const Arguments& args) { +Handle GitTreeEntry::Oid(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - FileModeBaton *baton = new FileModeBaton; - baton->request.data = baton; - baton->rawEntry = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + const git_oid * result = git_tree_entry_id( - uv_queue_work(uv_default_loop(), &baton->request, FileModeWork, (uv_after_work_cb)FileModeAfterWork); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } -void GitTreeEntry::FileModeWork(uv_work_t* req) { - FileModeBaton *baton = static_cast(req->data); - baton->fileMode = git_tree_entry_filemode(baton->rawEntry); -} -void GitTreeEntry::FileModeAfterWork(uv_work_t* req) { +Handle GitTreeEntry::Type(const Arguments& args) { HandleScope scope; - FileModeBaton *baton = static_cast(req->data); - Handle argv[2] = { - Local::New(Null()), - Integer::New(baton->fileMode) - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; -} - -Handle GitTreeEntry::Oid(const Arguments& args) { - HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - OidBaton* baton = new OidBaton; - baton->request.data = baton; - baton->rawEntry = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + git_otype result = git_tree_entry_type( - uv_queue_work(uv_default_loop(), &baton->request, OidWork, (uv_after_work_cb)OidAfterWork); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + return scope.Close(Number::New(result)); } -void GitTreeEntry::OidWork(uv_work_t* req) { - OidBaton *baton = static_cast(req->data); - baton->rawOid = git_tree_entry_id(const_cast(baton->rawEntry)); -} -void GitTreeEntry::OidAfterWork(uv_work_t* req) { +Handle GitTreeEntry::filemode(const Arguments& args) { HandleScope scope; - OidBaton *baton = static_cast(req->data); - Handle argv[1] = { External::New((void *) baton->rawOid) }; - Handle oid = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { - Local::New(Null()), - oid - }; + git_filemode_t result = git_tree_entry_filemode( - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(Number::New(result)); } -Handle GitTreeEntry::ToBlob(const Arguments& args) { +Handle GitTreeEntry::GetObject(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required and must be an Object."))); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - ToBlobBaton* baton = new ToBlobBaton; - baton->request.data = baton; + GetObjectBaton* baton = new GetObjectBaton; baton->error = NULL; - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->rawEntry = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawBlob = NULL; + baton->request.data = baton; + + // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. + // Either ref the argument or copy? + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->entry = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, ToBlobWork, (uv_after_work_cb)ToBlobAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetObjectWork, (uv_after_work_cb)GetObjectAfterWork); return Undefined(); } -void GitTreeEntry::ToBlobWork(uv_work_t *req) { - ToBlobBaton* baton = static_cast(req->data); - int returnCode = git_tree_entry_to_object((git_object**)&baton->rawBlob, baton->rawRepo, baton->rawEntry); - if (returnCode != GIT_OK) { +void GitTreeEntry::GetObjectWork(uv_work_t *req) { + GetObjectBaton *baton = static_cast(req->data); + int result = git_tree_entry_to_object( + &baton->object_out, + baton->repo, + baton->entry + ); + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitTreeEntry::ToBlobAfterWork(uv_work_t *req) { + +void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { HandleScope scope; - ToBlobBaton* baton = static_cast(req->data); + GetObjectBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Handle argv[1] = { External::New(baton->rawBlob) }; - Handle blob = GitBlob::constructor_template->NewInstance(1, argv); + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->object_out) }; + Handle object = GitObject::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - blob + object }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } - delete req; + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + + baton->callback.Dispose(); + delete baton; } -Persistent GitTreeEntry::constructor_template; +Persistent GitTreeEntry::constructor_template; diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 52078561c..15b25f2d4 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -1,6 +1,6 @@ <% function isPrimitive(cppClassName) { - return ["Boolean", "Number", "String"].indexOf(cppClassName) > -1; + return ["Boolean", "Number", "String", "Integer", "Int32", "Uint32"].indexOf(cppClassName) > -1; } function cppClassName2v8ValueClassName(cppClassName) { @@ -20,9 +20,11 @@ #include "git2.h" #include "../include/<%= filename %>" +<% if (typeof dependencies != 'undefined') { -%> <% for (d in dependencies) { -%> #include "<%- dependencies[d] %>" <% } -%> +<% } -%> #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -35,7 +37,9 @@ using namespace node; } <%- cppClassName %>::~<%- cppClassName %>() { +<% if (typeof freeFunctionName != 'undefined') { -%> <%- freeFunctionName %>(this->raw); +<% } -%> } void <%- cppClassName %>::Initialize(Handle target) { @@ -46,6 +50,7 @@ void <%- cppClassName %>::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("<%- jsClassName %>")); +<% if (typeof functions != 'undefined') { -%> <% for (var i in functions) { var functionInfo = functions[i]; @@ -56,6 +61,17 @@ void <%- cppClassName %>::Initialize(Handle target) { <% } else { -%> NODE_SET_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); <% } -%> +<% } -%> +<% } -%> + +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> + NODE_SET_PROTOTYPE_METHOD(tpl, "<%- fieldInfo.jsFunctionName %>", <%- fieldInfo.cppFunctionName %>); +<% } -%> <% } -%> constructor_template = Persistent::New(tpl->GetFunction()); @@ -79,6 +95,7 @@ Handle <%- cppClassName %>::New(const Arguments& args) { return this->raw; } +<% if (typeof functions != 'undefined') { -%> <% for (var i in functions) { var functionInfo = functions[i]; @@ -95,7 +112,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg if (arg.isReturn || arg.isSelf) continue; -%> if (args.Length() == <%- j %> || !args[<%- j %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { - return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); + return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> <%- arg.name %> is required."))); } <% j++; @@ -123,7 +140,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <% } else if (arg.cppClassName == 'Buffer') { -%> baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())); <% } else if (isPrimitive(arg.cppClassName)) { -%> - baton-><%- arg.name %> = args[<%- j %>]->To<%- arg.cppClassName %>()->Value(); + baton-><%- arg.name %> = (<%- arg.cType %>) args[<%- j %>]->To<%- arg.cppClassName %>()->Value(); <% } else { -%> // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. // Either ref the argument or copy? @@ -214,7 +231,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg -%> if (args.Length() == <%- j %> || !args[<%- j %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { - return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> is required."))); + return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> <%- arg.name %> is required."))); } <% j++; @@ -225,7 +242,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg var arg = functionInfo.args[i]; if (!arg.isReturn) continue; -%> - <%- arg.cType %> <%- arg.name %>; + <%- arg.cType.replace('**', '*') %> <%- arg.name %>; <% if (arg.shouldAlloc) { -%> <%- arg.name %> = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); <% } -%> @@ -236,6 +253,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg for (var i = 0, j = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> +<% if (/\*\*/.test(arg.cType)) { %>&<% } %> <% if (arg.isSelf) { -%> ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() <% } else if (arg.isReturn) { -%> @@ -254,7 +272,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <% if (functionInfo.return.isErrorCode) { -%> if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); + return ThrowException(GitError::WrapError(giterr_last())); } <% } -%> <% @@ -280,5 +298,29 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg } <% } -%> <% } -%> +<% } -%> + +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> +Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <%- fieldInfo.cType %> field = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; + +<% if (isPrimitive(fieldInfo.cppClassName)) { -%> + return scope.Close(<%- fieldInfo.cppClassName %>::New(field)); +<% } else if (fieldInfo.cppClassName == "External") { -%> + return scope.Close(External::New((void *)<% if (!/\*/.test(fieldInfo.cType)) { %>&<% } %>field)); +<% } else { -%> + // XXX need to copy object? + Handle argv[1] = { External::New((void *)<% if (!/\*/.test(fieldInfo.cType)) { %>&<% } %>field) }; + return scope.Close(<%- fieldInfo.cppClassName %>::constructor_template->NewInstance(1, argv)); +<% } -%> +} +<% } -%> +<% } -%> Persistent <%- cppClassName %>::constructor_template; diff --git a/templates/header.h.ejs b/templates/header.h.ejs index 1118d28c3..92c1d6db0 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -28,6 +28,17 @@ class <%- cppClassName %> : public ObjectWrap { static Handle New(const Arguments& args); +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> + static Handle <%- fieldInfo.cppFunctionName %>(const Arguments& args); +<% } -%> +<% } -%> + +<% if (typeof functions != 'undefined') { -%> <% for (var i in functions) { var functionInfo = functions[i]; @@ -54,6 +65,7 @@ class <%- cppClassName %> : public ObjectWrap { Persistent callback; }; <% } -%> +<% } -%> <% } -%> <%- cType %> *raw; }; diff --git a/test/convenience-commit.js b/test/convenience-commit.js index 0912731d7..8159f04f2 100644 --- a/test/convenience-commit.js +++ b/test/convenience-commit.js @@ -36,21 +36,20 @@ exports.method = function(test){ exports.message = function(test) { test.expect(3); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.message(function(error, message) { - test.equals(error, null, 'There should be no error'); - test.notEqual(message, null, 'Message should not be null'); - test.equals(message, 'Update README.md', 'Message should match expected value'); - test.done(); - }); + var message = commit.message(); + test.equals(error, null, 'There should be no error'); + test.notEqual(message, null, 'Message should not be null'); + test.equals(message, 'Update README.md', 'Message should match expected value'); + test.done(); }); }); }; exports.sha = function(test) { test.expect(3); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { var sha = commit.sha(); test.equals(error, null, 'There should be no error'); @@ -63,112 +62,100 @@ exports.sha = function(test) { exports.time = function(test) { test.expect(3); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.time(function(error, time) { - test.equals(error, null, 'There should be no error'); - test.notEqual(time, null, 'Time should not be null'); - test.equals(time, 1362012884000, 'Time should match expected value'); - test.done(); - }); + var time = commit.time(); + test.equals(error, null, 'There should be no error'); + test.notEqual(time, null, 'Time should not be null'); + test.equals(time, 1362012884000, 'Time should match expected value'); + test.done(); }); }); }; exports.date = function(test) { test.expect(4); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.date(function(error, date) { - test.equals(error, null, 'There should be no error'); - test.notEqual(date, null, 'Date should not be null'); - test.equal(date instanceof Date, true, 'Date should be a date object'); - test.equals(date.getTime(), 1362012884000, 'Date should match expected value'); - test.done(); - }); + var date = commit.date(); + test.equals(error, null, 'There should be no error'); + test.notEqual(date, null, 'Date should not be null'); + test.equal(date instanceof Date, true, 'Date should be a date object'); + test.equals(date.getTime(), 1362012884000, 'Date should match expected value'); + test.done(); }); }); }; exports.offset = function(test) { test.expect(3); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.offset(function(error, offset) { - test.equals(error, null, 'There should be no error'); - test.notEqual(offset, null, 'Offset should not be null'); - test.equals(offset, 780, 'Offset should match expected value'); - test.done(); - }); + var offset = commit.offset(); + test.equals(error, null, 'There should be no error'); + test.notEqual(offset, null, 'Offset should not be null'); + test.equals(offset, 780, 'Offset should match expected value'); + test.done(); }); }); }; exports.author = function(test) { test.expect(2); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.author(function(error, author) { - test.equals(error, null, 'There should be no error'); - test.notEqual(author, null, 'Author should not be null'); - test.done(); - }); + var author = commit.author(); + test.equals(error, null, 'There should be no error'); + test.notEqual(author, null, 'Author should not be null'); + test.done(); }); }); }; exports.authorName = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.author(function commitAuthor(error, author) { - author.name(function authorName(error, name) { - test.equals(name, 'Michael Robinson', 'The author name should match expected value'); - test.done(); - }); - }); + var author = commit.author(); + var name = author.name(); + test.equals(name, 'Michael Robinson', 'The author name should match expected value'); + test.done(); }); }); }; exports.authorEmail = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.author(function commitAuthor(error, author) { - author.email(function authorName(error, email) { - test.equals(email, 'mike@panmedia.co.nz', 'The author email should match expected value'); - test.done(); - }); - }); + var author = commit.author(); + var email = author.email(); + test.equals(email, 'mike@panmedia.co.nz', 'The author email should match expected value'); + test.done(); }); }); }; exports.committerName = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.committer(function commitCommitter(error, committer) { - committer.name(function committerName(error, name) { - test.equals(name, 'Michael Robinson', 'The author name should match expected value'); - test.done(); - }); - }); + var committer = commit.committer(); + var name = committer.name(); + test.equals(name, 'Michael Robinson', 'The author name should match expected value'); + test.done(); }); }); }; exports.committerEmail = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { - commit.committer(function commitCommitter(error, committer) { - committer.email(function committerName(error, email) { - test.equals(email, 'mike@panmedia.co.nz', 'The committer email should match expected value'); - test.done(); - }); - }); + var committer = commit.committer(); + var email = committer.email(); + test.equals(email, 'mike@panmedia.co.nz', 'The committer email should match expected value'); + test.done(); }); }); }; @@ -178,7 +165,7 @@ exports.committerEmail = function(test) { */ exports.improperCommitId = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit('not a proper commit sha', function(error, commit) { test.notEqual(error, null, 'Error should occur'); test.done(); @@ -191,7 +178,7 @@ exports.improperCommitId = function(test) { */ exports.history = function(test) { test.expect(368); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { test.equals(null, error, 'Getting latest branch commit should not error'); var historyCount = 0; @@ -214,7 +201,7 @@ exports.history = function(test) { */ exports.masterHead = function(test) { test.expect(2); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.branch('master', function(error, branch) { test.equals(error, null, 'Getting branch should not error'); var sha = branch.sha(); @@ -233,7 +220,7 @@ exports.masterHead = function(test) { */ exports.parents = function(test) { test.expect(3); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { test.equals(parents.length, 1, 'Commit should have exactly one parent'); @@ -251,14 +238,14 @@ exports.parents = function(test) { */ exports.tree = function(test) { test.expect(2); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { test.equals(error, null, 'Getting latest branch commit should not error'); var commitTreeEntryCount = 0; var expectedCommitTreeEntryCount = 198; - commit.tree(function commitTree(error, tree) { + commit.getTree(function(error, tree) { tree.walk().on('entry', function(error, entry) { commitTreeEntryCount++; }).on('end', function(error, entries) { @@ -275,7 +262,7 @@ exports.tree = function(test) { */ exports.parentsDiffTrees = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parentsDiffTrees(function(error, parentsDiffTrees) { test.equals(parentsDiffTrees.length, 1, 'Should be one item in parents diff trees'); diff --git a/test/convenience-difflist.js b/test/convenience-difflist.js index c9a1a4bef..a8d77ffbe 100644 --- a/test/convenience-difflist.js +++ b/test/convenience-difflist.js @@ -41,30 +41,30 @@ exports.method = function(test){ */ exports.walkingDiffs = function(test) { test.expect(15); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { var parentSha = parents[0].sha(); - (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { + git.diffList.treeToTree(commit.repo, parentSha, historyCountKnownSHA, function(error, diffList) { test.equal(null, error, 'Should not error'); diffList.walk().on('delta', function(error, delta) { test.equal(null, error, 'Should not error'); test.equal(delta.oldFile.path, 'README.md', 'Old file path should match expected'); test.equal(delta.newFile.path, 'README.md', 'New file path should match expected'); test.equal(delta.content.length, 5, 'Content array should be of known length'); - test.equal(delta.status, diffList.deltaTypes.GIT_DELTA_MODIFIED, 'Status should be known type'); - test.equal(delta.content[0].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'First content item should be context'); - test.equal(delta.content[1].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Second content item should be context'); - test.equal(delta.content[2].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Third content item should be context'); + test.equal(delta.status, git.diffList.Delta.Modified, 'Status should be known type'); + test.equal(delta.content[0].lineOrigin, git.diffList.LineOrigin.Context, 'First content item should be context'); + test.equal(delta.content[1].lineOrigin, git.diffList.LineOrigin.Context, 'Second content item should be context'); + test.equal(delta.content[2].lineOrigin, git.diffList.LineOrigin.Context, 'Third content item should be context'); var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; test.equal(delta.content[3].content, oldContent, 'Old content should match known value'); - test.equal(delta.content[3].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'Fourth content item should be deletion'); + test.equal(delta.content[3].lineOrigin, git.diffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); test.equal(delta.content[3].contentLength, 90, 'Fourth content length should match known value'); var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; test.equal(delta.content[4].content, newContent, 'New content should match known value'); - test.equal(delta.content[4].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'Fifth content item should be addition'); + test.equal(delta.content[4].lineOrigin, git.diffList.LineOrigin.Addition, 'Fifth content item should be addition'); test.equal(delta.content[4].contentLength, 162, 'Fifth content length should match known value'); test.done(); }); @@ -76,11 +76,11 @@ exports.walkingDiffs = function(test) { exports.walkingEnd = function(test) { test.expect(2); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { var parentSha = parents[0].sha(); - (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { + git.diffList.treeToTree(commit.repo, parentSha, historyCountKnownSHA, function(error, diffList) { diffList.walk().on('end', function(error, diffs) { test.equal(null, error, 'Should not error'); test.equal(diffs.length, 1, 'Diffs array should be of known length'); @@ -91,36 +91,3 @@ exports.walkingEnd = function(test) { }); }); }; - -exports.deltaTypes = function(test) { - test.expect(9); - git.repo('../.git', function(error, repo) { - var diffList = new git.diffList(repo.rawRepo); - test.equal(diffList.deltaTypes.GIT_DELTA_UNMODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNMODIFIED, 'GIT_DELTA_UNMODIFIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_ADDED, git.raw.DiffList.deltaTypes.GIT_DELTA_ADDED, 'GIT_DELTA_ADDED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_DELETED, git.raw.DiffList.deltaTypes.GIT_DELTA_DELETED, 'GIT_DELTA_DELETED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_MODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_MODIFIED, 'GIT_DELTA_MODIFIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_RENAMED, git.raw.DiffList.deltaTypes.GIT_DELTA_RENAMED, 'GIT_DELTA_RENAMED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_COPIED, git.raw.DiffList.deltaTypes.GIT_DELTA_COPIED, 'GIT_DELTA_COPIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_IGNORED, git.raw.DiffList.deltaTypes.GIT_DELTA_IGNORED, 'GIT_DELTA_IGNORED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_UNTRACKED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNTRACKED, 'GIT_DELTA_UNTRACKED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_TYPECHANGE, git.raw.DiffList.deltaTypes.GIT_DELTA_TYPECHANGE, 'GIT_DELTA_TYPECHANGE delta type should match expected value'); - test.done(); - }); -}; - -exports.lineOriginTypes = function(test) { - test.expect(8); - git.repo('../.git', function(error, repo) { - var diffList = new git.diffList(repo.rawRepo); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'GIT_DIFF_LINE_CONTEXT line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'GIT_DIFF_LINE_ADDITION line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'GIT_DIFF_LINE_DELETION line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, 'GIT_DIFF_LINE_ADD_EOFNL line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, 'GIT_DIFF_LINE_DEL_EOFNL line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, 'GIT_DIFF_LINE_FILE_HDR line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, 'GIT_DIFF_LINE_HUNK_HDR line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, 'GIT_DIFF_LINE_BINARY line origin type should match expected value'); - test.done(); - }); -}; diff --git a/test/convenience-entry.js b/test/convenience-entry.js index f24068a7a..d68165755 100644 --- a/test/convenience-entry.js +++ b/test/convenience-entry.js @@ -3,7 +3,7 @@ var git = require('../'); var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; var getEntry = function(path, callback) { - git.repo('../.git', function(error, repo) { + git.repo.open('../.git', function(error, repo) { repo.commit(sha, function(error, commit) { commit.file(path, function(error, entry) { callback(error, entry); @@ -24,24 +24,21 @@ exports.missingFile = function(test) { exports.sha = function(test) { test.expect(1); getEntry('README.md', function(error, entry) { - entry.sha(function(error, sha) { - test.equal(sha, '6cb45ba5d32532bf0d1310dc31ca4f20f59964bc', 'Entry SHA should match expected value'); - test.done(); - }); + var sha = entry.sha(); + test.equal(sha, '6cb45ba5d32532bf0d1310dc31ca4f20f59964bc', 'Entry SHA should match expected value'); + test.done(); }); }; exports.isFile = function(test) { test.expect(2); getEntry('README.md', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, true, 'Entry is a file'); - getEntry('example', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, false, 'Entry is a directory'); - test.done(); - }); - }); + var isFile = entry.isFile(); + test.equal(isFile, true, 'Entry is a file'); + getEntry('example', function(error, entry) { + var isFile = entry.isFile(); + test.equal(isFile, false, 'Entry is a directory'); + test.done(); }); }); }; @@ -49,14 +46,12 @@ exports.isFile = function(test) { exports.isDirectory = function(test) { test.expect(2); getEntry('example', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, false, 'Entry is a directory'); - getEntry('README.md', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, true, 'Entry is a file'); - test.done(); - }); - }); + var isFile = entry.isFile(); + test.equal(isFile, false, 'Entry is a directory'); + getEntry('README.md', function(error, entry) { + var isFile = entry.isFile() + test.equal(isFile, true, 'Entry is a file'); + test.done(); }); }); }; @@ -65,57 +60,26 @@ exports.name = function(test) { test.expect(2); getEntry('test/raw-commit.js', function(error, entry) { test.equal(error, null, 'Should not error'); - entry.name(function(error, name) { - test.equal(name, 'raw-commit.js', 'Name should match expected value'); - test.done(); - }); - }); -}; - -exports.root = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.root(function(error, root) { - test.equal(root, 'test', 'Root should match expected value'); - test.done(); - }); - }); -}; - -exports.path = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.path(function(error, path) { - test.equal(path, 'test/raw-commit.js', 'Path should match expected value'); - test.done(); - }); - }); -}; - -exports.content = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.content(function(error, content) { - test.equal(content.length, 2736, 'Content length should match expected value'); - test.done(); - }); + var name = entry.name(); + test.equal(name, 'raw-commit.js', 'Name should match expected value'); + test.done(); }); }; -exports.toBlob = function(test) { +exports.getBlob = function(test) { test.expect(1); getEntry('test/raw-commit.js', function(error, entry) { - entry.toBlob(function(error, blob) { - test.equal(blob instanceof git.blob, true, 'Expected instance of Blob'); + entry.getBlob(function(error, blob) { + test.equal(blob.size(), 2736, 'Content length should match expected value'); test.done(); }); }); }; -exports.tree = function(test) { +exports.getTree = function(test) { test.expect(1); getEntry('test', function(error, entry) { - entry.tree(function(error, tree) { + entry.getTree(function(error, tree) { test.equal(tree instanceof git.tree, true, 'Expected instance of Tree'); test.done(); }); diff --git a/test/convenience-error.js b/test/convenience-error.js index 38393dffa..327ad2761 100644 --- a/test/convenience-error.js +++ b/test/convenience-error.js @@ -75,7 +75,7 @@ exports.returnCodes = function(test) { */ exports.improperCommitId = function(test) { test.expect(1); - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { repository.commit('not a proper commit sha', function(error, commit) { test.notEqual(error.code, git.error.GIT_SUCCESS, 'Attempting to get commit by invalid SHA should error'); test.done(); diff --git a/test/convenience-repo.js b/test/convenience-repo.js index db1996686..2b39768e1 100644 --- a/test/convenience-repo.js +++ b/test/convenience-repo.js @@ -34,15 +34,15 @@ exports.method = function(test){ // Test callback argument existence helper.testException(test.ok, function() { - git.repo('some/path'); + git.repo.open('some/path'); }, 'Throw an exception if no callback'); // Test invalid repository - git.repo('/etc/hosts', function(error, repository) { + git.repo.open('/etc/hosts', function(error, repository) { test.equals(error.code, error.codes.GITERR_REPOSITORY, error.message, 'Invalid repository error code'); // Test valid repository - git.repo('../.git', function(error, repository) { + git.repo.open('../.git', function(error, repository) { test.equals(null, error, 'Valid repository error code'); test.done(); }); @@ -54,7 +54,7 @@ exports.method = function(test){ */ exports.nonexistentDirectory = function(test) { test.expect(2); - git.repo('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { + git.repo.open('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); test.equals(repository, null, 'Non existent directory should result in null repository'); test.done(); @@ -67,14 +67,13 @@ exports.nonexistentDirectory = function(test) { */ exports.init = function(test) { test.expect(2); - // Cleanup, remove test repo directory - if it exists rimraf('./test.git', function() { // Create bare repo and test for creation - git.init('./test.git', true, function(error, path, isBare) { + git.repo.init('./test.git', true, function(error, path, isBare) { test.equals(null, error, 'Successfully created bare repository'); // Verify repo exists - git.repo('./test.git', function(error, path, repo) { + git.repo.open('./test.git', function(error, path, repo) { test.equals(null, error, 'Valid repository created'); // Cleanup, remove test repo directory diff --git a/test/convenience-tree.js b/test/convenience-tree.js index 813fa3d8c..df1aa8d6b 100644 --- a/test/convenience-tree.js +++ b/test/convenience-tree.js @@ -8,10 +8,10 @@ var fileCount = 512; // Number of blob & blob executabless exports.walk = function(test) { test.expect(515); - git.repo('../.git', function(error, repo) { + git.repo.open('../.git', function(error, repo) { repo.commit(sha, function(error, commit) { var entryCount = 0; - commit.tree(function(error, tree) { + commit.getTree(function(error, tree) { tree.walk().on('entry', function(error, index, entry) { test.equals(error, null, 'There should be no error'); entryCount++; diff --git a/test/raw-blob.js b/test/raw-blob.js index 59b04dd79..ccd4ea282 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -63,8 +63,7 @@ exports.lookup = function(test) { // Blob::RawContent exports.rawContent = function(test) { // This shouldn't fail unless someone rewrites history: - var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'), - testCommit = new git.Commit(); + var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'); test.expect(3); git.Repo.open(path.resolve('../.git'), function(err, repo) { git.Blob.lookup(repo, testOid, function(err, blob) { diff --git a/test/raw-commit.js b/test/raw-commit.js index fa4908eda..4e1d4cf32 100644 --- a/test/raw-commit.js +++ b/test/raw-commit.js @@ -20,56 +20,39 @@ var helper = { } }; -/** - * Commit - */ -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Commit, 'Commit'); - git.Repo.open('../.git', function(err, repo) { - // Ensure we get an instance of Commit - test.ok(new git.Commit(repo) instanceof git.Commit, 'Invocation returns an instance of Commit'); - - test.done(); - }); -}; - /** * Commit::Lookup */ exports.lookup = function(test) { test.expect(7); - var testOid = git.Oid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762'), - testCommit = new git.Commit(); + var testOid = git.Oid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762'); // Test for function - helper.testFunction(test.equals, testCommit.lookup, 'Commit::Lookup'); + helper.testFunction(test.equals, git.Commit.lookup, 'Commit::Lookup'); git.Repo.open('../.git', function(error, repo) { // Test repo argument existence helper.testException(test.ok, function() { - testCommit.lookup(); + git.Commit.lookup(); }, 'Throw an exception if no repo'); // Test oid argument existence helper.testException(test.ok, function() { - testCommit.lookup(repo); + git.Commit.lookup(repo); }, 'Throw an exception if no oid'); // Test callback argument existence helper.testException(test.ok, function() { - testCommit.lookup(repo); + git.Commit.lookup(repo); }, 'Throw an exception if no callback'); // Test that all arguments result correctly helper.testException(test.ifError, function() { - testCommit.lookup(repo, testOid, function() {}); + git.Commit.lookup(repo, testOid, function() {}); }, 'No exception is thrown with proper arguments'); // Test valid commit - testCommit.lookup(repo, testOid, function(err) { + git.Commit.lookup(repo, testOid, function(err) { test.equal(null, err, 'Valid commit'); test.done(); }); diff --git a/v0.18.0.json b/v0.18.0.json index 9a5163246..2d453aa01 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -43,12 +43,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "get", "cppFunctionName": "Get", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -95,12 +94,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getMany", "cppFunctionName": "GetMany", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -141,12 +139,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -163,7 +160,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "cacheFlush", "cppFunctionName": "CacheFlush", "return": { @@ -197,12 +193,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "addMacro", "cppFunctionName": "AddMacro", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -247,12 +242,11 @@ "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -289,12 +283,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookupPrefix", "cppFunctionName": "LookupPrefix", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -335,7 +328,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "oid", "cppFunctionName": "Oid", "return": { @@ -358,7 +350,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "content", "cppFunctionName": "Content", "return": { @@ -381,7 +372,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "size", "cppFunctionName": "Size", "return": { @@ -416,12 +406,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createFromworkdir", "cppFunctionName": "CreateFromworkdir", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -451,12 +440,11 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createFromFile", "cppFunctionName": "CreateFromFile", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -498,12 +486,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createFromchunks", "cppFunctionName": "CreateFromchunks", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -539,12 +526,11 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createFromBuffer", "cppFunctionName": "CreateFromBuffer", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -562,7 +548,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "isBinary", "cppFunctionName": "IsBinary", "return": { @@ -605,25 +590,24 @@ { "name": "target", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit" }, { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "create", "cppFunctionName": "Create", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -640,12 +624,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "delete", "cppFunctionName": "Delete", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -661,8 +644,8 @@ { "name": "list_flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "branch_cb", @@ -680,12 +663,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -714,19 +696,18 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "move", "cppFunctionName": "Move", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -762,12 +743,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -791,12 +771,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "name", "cppFunctionName": "Name", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -820,12 +799,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "upstream", "cppFunctionName": "Upstream", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -848,12 +826,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "setUpstream", "cppFunctionName": "SetUpstream", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -888,12 +865,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "upstreamName", "cppFunctionName": "UpstreamName", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -910,12 +886,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "isHead", "cppFunctionName": "IsHead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -950,12 +925,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "remoteName", "cppFunctionName": "RemoteName", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -987,12 +961,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "head", "cppFunctionName": "Head", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1021,12 +994,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "index", "cppFunctionName": "Index", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1042,7 +1014,7 @@ { "name": "treeish", "cType": "const git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -1055,12 +1027,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "tree", "cppFunctionName": "Tree", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -1105,12 +1076,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitClone", "cppFunctionName": "GitClone", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -1118,8 +1088,9 @@ }, { "filename": "commit.h", + "dependencies": ["../include/oid.h", "../include/repo.h", "../include/signature.h", "../include/tree.h"], "jsClassName": "Commit", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "cType": "git_commit", "freeFunctionName": "git_commit_free", "functions": [ @@ -1129,7 +1100,7 @@ { "name": "commit", "cType": "git_commit **", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isReturn": true }, @@ -1146,15 +1117,14 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1164,7 +1134,7 @@ { "name": "commit", "cType": "git_commit **", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isReturn": true }, @@ -1187,15 +1157,15 @@ "jsClassName": "size_t" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookupPrefix", "cppFunctionName": "LookupPrefix", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1205,13 +1175,15 @@ { "name": "commit", "cType": "git_commit *", - "cppClassName": "Commit", - "jsClassName": "Commit" + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": true, "jsFunctionName": "free", "cppFunctionName": "Free", @@ -1227,7 +1199,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1235,9 +1207,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, - "jsFunctionName": "id", - "cppFunctionName": "Id", + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", "cppClassName": "GitOid", @@ -1250,7 +1221,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1258,7 +1229,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "messageEncoding", "cppFunctionName": "MessageEncoding", "return": { @@ -1273,7 +1243,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1281,7 +1251,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "message", "cppFunctionName": "Message", "return": { @@ -1296,7 +1265,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1304,12 +1273,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "time", "cppFunctionName": "Time", "return": { "cType": "git_time_t", - "cppClassName": "TimeT", + "cppClassName": "Number", "isErrorCode": false } }, @@ -1319,7 +1287,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1327,13 +1295,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, - "jsFunctionName": "timeOffset", - "cppFunctionName": "TimeOffset", + "jsFunctionName": "offset", + "cppFunctionName": "Offset", "return": { "cType": "int", - "cppClassName": "int", - "isErrorCode": true + "cppClassName": "Integer" } }, { @@ -1342,7 +1308,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1350,12 +1316,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "committer", "cppFunctionName": "Committer", "return": { "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "isErrorCode": false } }, @@ -1365,7 +1330,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1373,12 +1338,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "author", "cppFunctionName": "Author", "return": { "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "isErrorCode": false } }, @@ -1388,25 +1352,26 @@ { "name": "tree_out", "cType": "git_tree **", - "cppClassName": "Tree", - "jsClassName": "Tree" + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isReturn": true }, { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", - "jsClassName": "Commit" + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, + "isPrototypeMethod": true, "jsFunctionName": "tree", "cppFunctionName": "Tree", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1416,7 +1381,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1424,7 +1389,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "treeId", "cppFunctionName": "TreeId", "return": { @@ -1439,7 +1403,7 @@ { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true } @@ -1447,12 +1411,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, - "jsFunctionName": "parentcount", - "cppFunctionName": "Parentcount", + "jsFunctionName": "parentCount", + "cppFunctionName": "ParentCount", "return": { "cType": "unsigned int", - "cppClassName": "unsigned", + "cppClassName": "Uint32", "isErrorCode": false } }, @@ -1463,31 +1426,32 @@ "name": "out", "isReturn": true, "cType": "git_commit **", - "cppClassName": "Commit", - "jsClassName": "Commit" + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isReturn": true }, { "name": "commit", "cType": "git_commit *", - "cppClassName": "Commit", - "jsClassName": "Commit" + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true }, { "name": "n", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "isFree": false, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "parent", "cppFunctionName": "Parent", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1497,21 +1461,21 @@ { "name": "commit", "cType": "git_commit *", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isSelf": true }, { "name": "n", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "parentId", "cppFunctionName": "ParentId", "return": { @@ -1526,32 +1490,33 @@ { "name": "ancestor", "cType": "git_commit **", - "cppClassName": "Commit", + "cppClassName": "GitCommit", "jsClassName": "Commit", "isReturn": true }, { "name": "commit", "cType": "const git_commit *", - "cppClassName": "Commit", - "jsClassName": "Commit" + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true }, { "name": "n", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "isFree": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "nthGenAncestor", "cppFunctionName": "NthGenAncestor", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1562,7 +1527,8 @@ "name": "id", "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isReturn": true }, { "name": "repo", @@ -1579,13 +1545,13 @@ { "name": "author", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { "name": "committer", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -1603,25 +1569,31 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { "name": "parent_count", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" + }, + { + "name": "parents", + "cType": "(const git_commit *)[]", + "cppClassName": "Array", + "jsClassName": "Array" } ], - "isAsync": false, - "isConstructorMethod": false, + "ignore": true, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "create", "cppFunctionName": "Create", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1632,7 +1604,8 @@ "name": "id", "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isReturn": true }, { "name": "repo", @@ -1649,13 +1622,13 @@ { "name": "author", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { "name": "committer", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -1673,25 +1646,25 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { "name": "parent_count", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createV", "cppFunctionName": "CreateV", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -1710,26 +1683,25 @@ { "name": "major", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "minor", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "rev", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitLibgit2Version", "cppFunctionName": "GitLibgit2Version", "return": { @@ -1744,12 +1716,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitLibgit2Capabilities", "cppFunctionName": "GitLibgit2Capabilities", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1759,19 +1730,18 @@ { "name": "option", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitLibgit2Opts", "cppFunctionName": "GitLibgit2Opts", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -1804,12 +1774,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "findGlobal", "cppFunctionName": "FindGlobal", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1833,12 +1802,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "findXdg", "cppFunctionName": "FindXdg", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1862,12 +1830,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "findSystem", "cppFunctionName": "FindSystem", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1885,12 +1852,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "openDefault", "cppFunctionName": "OpenDefault", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1908,12 +1874,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1936,25 +1901,24 @@ { "name": "level", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addBackend", "cppFunctionName": "AddBackend", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -1977,25 +1941,24 @@ { "name": "level", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addFileOndisk", "cppFunctionName": "AddFileOndisk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2019,12 +1982,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "openOndisk", "cppFunctionName": "OpenOndisk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2047,19 +2009,18 @@ { "name": "level", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "openLevel", "cppFunctionName": "OpenLevel", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2077,12 +2038,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "refresh", "cppFunctionName": "Refresh", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2134,12 +2094,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getEntry", "cppFunctionName": "GetEntry", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2169,12 +2128,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getInt32", "cppFunctionName": "GetInt32", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2204,12 +2162,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getInt64", "cppFunctionName": "GetInt64", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2220,8 +2177,8 @@ "name": "out", "isReturn": true, "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "cfg", @@ -2239,12 +2196,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getBool", "cppFunctionName": "GetBool", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2274,12 +2230,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getString", "cppFunctionName": "GetString", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2321,12 +2276,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "getMultivar", "cppFunctionName": "GetMultivar", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2356,12 +2310,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setInt32", "cppFunctionName": "SetInt32", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2391,12 +2344,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setInt64", "cppFunctionName": "SetInt64", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2419,19 +2371,18 @@ { "name": "value", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setBool", "cppFunctionName": "SetBool", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2461,12 +2412,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setString", "cppFunctionName": "SetString", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2502,12 +2452,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setMultivar", "cppFunctionName": "SetMultivar", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2531,12 +2480,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "deleteEntry", "cppFunctionName": "DeleteEntry", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2566,12 +2514,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2607,12 +2554,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "foreachMatch", "cppFunctionName": "ForeachMatch", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2623,8 +2569,8 @@ "name": "out", "isReturn": true, "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "cfg", @@ -2654,12 +2600,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getMapped", "cppFunctionName": "GetMapped", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2670,8 +2615,8 @@ "name": "out", "isReturn": true, "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "maps", @@ -2695,12 +2640,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookupMapValue", "cppFunctionName": "LookupMapValue", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2711,8 +2655,8 @@ "name": "out", "isReturn": true, "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "value", @@ -2724,12 +2668,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "parseBool", "cppFunctionName": "ParseBool", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2753,12 +2696,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "parseInt32", "cppFunctionName": "ParseInt32", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2782,12 +2724,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "parseInt64", "cppFunctionName": "ParseInt64", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -2824,8 +2765,8 @@ { "name": "allowed_types", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "payload", @@ -2837,12 +2778,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitCredUserpass", "cppFunctionName": "GitCredUserpass", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -2895,13 +2835,13 @@ { "name": "old_tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { "name": "new_tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { @@ -2914,12 +2854,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "treeToTree", "cppFunctionName": "TreeToTree", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -2941,7 +2880,7 @@ { "name": "old_tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { @@ -2960,12 +2899,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "treeToIndex", "cppFunctionName": "TreeToIndex", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3000,12 +2938,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "indexToWorkdir", "cppFunctionName": "IndexToWorkdir", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3027,7 +2964,7 @@ { "name": "old_tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { @@ -3040,12 +2977,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "treeToWorkdir", "cppFunctionName": "TreeToWorkdir", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3068,12 +3004,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "merge", "cppFunctionName": "Merge", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3096,12 +3031,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "findSimilar", "cppFunctionName": "FindSimilar", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3142,12 +3076,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3176,12 +3109,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "printCompact", "cppFunctionName": "PrintCompact", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3198,7 +3130,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "statusChar", "cppFunctionName": "StatusChar", "return": { @@ -3232,12 +3163,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "printPatch", "cppFunctionName": "PrintPatch", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3254,7 +3184,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "numDeltas", "cppFunctionName": "NumDeltas", "return": { @@ -3282,7 +3211,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "numDeltasOfType", "cppFunctionName": "NumDeltasOfType", "return": { @@ -3322,12 +3250,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "getPatch", "cppFunctionName": "GetPatch", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3366,7 +3293,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchDelta", "cppFunctionName": "PatchDelta", "return": { @@ -3388,7 +3314,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchNumHunks", "cppFunctionName": "PatchNumHunks", "return": { @@ -3428,12 +3353,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchLineStats", "cppFunctionName": "PatchLineStats", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3480,12 +3404,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchGetHunk", "cppFunctionName": "PatchGetHunk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3508,12 +3431,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchNumLinesInHunk", "cppFunctionName": "PatchNumLinesInHunk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3541,14 +3463,14 @@ { "name": "old_lineno", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "new_lineno", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "patch", @@ -3572,12 +3494,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchGetLineInHunk", "cppFunctionName": "PatchGetLineInHunk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3606,12 +3527,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchPrint", "cppFunctionName": "PatchPrint", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3634,12 +3554,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "patchToStr", "cppFunctionName": "PatchToStr", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3692,12 +3611,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "blobs", "cppFunctionName": "Blobs", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3756,12 +3674,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "blobToBuffer", "cppFunctionName": "BlobToBuffer", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -3780,7 +3697,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "giterrLast", "cppFunctionName": "GiterrLast", "return": { @@ -3795,7 +3711,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "giterrClear", "cppFunctionName": "GiterrClear", "return": { @@ -3810,8 +3725,8 @@ { "name": "error_class", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "string", @@ -3823,7 +3738,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "giterrSetStr", "cppFunctionName": "GiterrSetStr", "return": { @@ -3838,7 +3752,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "giterrSetOom", "cppFunctionName": "GiterrSetOom", "return": { @@ -3893,12 +3806,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "aheadBehind", "cppFunctionName": "AheadBehind", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -3930,12 +3842,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "addRule", "cppFunctionName": "AddRule", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3952,12 +3863,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "clearInternalRules", "cppFunctionName": "ClearInternalRules", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -3967,8 +3877,8 @@ { "name": "ignored", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "repo", @@ -3986,12 +3896,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "pathIsIgnored", "cppFunctionName": "PathIsIgnored", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -4024,12 +3933,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "open", "cppFunctionName": "Open", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4047,12 +3955,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4092,7 +3999,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "owner", "cppFunctionName": "Owner", "return": { @@ -4115,12 +4021,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "caps", "cppFunctionName": "Caps", "return": { "cType": "unsigned int", - "cppClassName": "unsigned", + "cppClassName": "Uint32", "isErrorCode": false } }, @@ -4137,19 +4042,18 @@ { "name": "caps", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setCaps", "cppFunctionName": "SetCaps", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4167,12 +4071,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "read", "cppFunctionName": "Read", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4190,12 +4093,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "write", "cppFunctionName": "Write", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4212,19 +4114,18 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "readTree", "cppFunctionName": "ReadTree", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4248,12 +4149,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "writeTree", "cppFunctionName": "WriteTree", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4283,12 +4183,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "writeTreeTo", "cppFunctionName": "WriteTreeTo", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4306,7 +4205,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entrycount", "cppFunctionName": "Entrycount", "return": { @@ -4329,7 +4227,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "clear", "cppFunctionName": "Clear", "return": { @@ -4358,7 +4255,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "getByindex", "cppFunctionName": "GetByindex", "return": { @@ -4386,14 +4282,13 @@ { "name": "stage", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "getBypath", "cppFunctionName": "GetBypath", "return": { @@ -4421,19 +4316,18 @@ { "name": "stage", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "remove", "cppFunctionName": "Remove", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4456,19 +4350,18 @@ { "name": "stage", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "removeDirectory", "cppFunctionName": "RemoveDirectory", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4492,12 +4385,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "add", "cppFunctionName": "Add", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4514,12 +4406,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "entryStage", "cppFunctionName": "EntryStage", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4543,12 +4434,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addBypath", "cppFunctionName": "AddBypath", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4572,12 +4462,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "removeBypath", "cppFunctionName": "RemoveBypath", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4606,12 +4495,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "find", "cppFunctionName": "Find", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4647,12 +4535,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "conflictAdd", "cppFunctionName": "ConflictAdd", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4693,12 +4580,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "conflictGet", "cppFunctionName": "ConflictGet", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4722,12 +4608,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "conflictRemove", "cppFunctionName": "ConflictRemove", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4745,7 +4630,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "conflictCleanup", "cppFunctionName": "ConflictCleanup", "return": { @@ -4768,12 +4652,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "hasConflicts", "cppFunctionName": "HasConflicts", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4791,12 +4674,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reucEntrycount", "cppFunctionName": "ReucEntrycount", "return": { "cType": "unsigned int", - "cppClassName": "unsigned", + "cppClassName": "Uint32", "isErrorCode": false } }, @@ -4825,12 +4707,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "reucFind", "cppFunctionName": "ReucFind", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4854,7 +4735,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reucGetBypath", "cppFunctionName": "ReucGetBypath", "return": { @@ -4883,7 +4763,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reucGetByindex", "cppFunctionName": "ReucGetByindex", "return": { @@ -4911,8 +4790,8 @@ { "name": "ancestor_mode", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "ancestor_id", @@ -4923,8 +4802,8 @@ { "name": "our_mode", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "our_id", @@ -4935,8 +4814,8 @@ { "name": "their_mode", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "their_id", @@ -4948,12 +4827,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reucAdd", "cppFunctionName": "ReucAdd", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -4977,12 +4855,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reucRemove", "cppFunctionName": "ReucRemove", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5000,7 +4877,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reucClear", "cppFunctionName": "ReucClear", "return": { @@ -5050,12 +4926,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "streamNew", "cppFunctionName": "StreamNew", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5090,12 +4965,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "streamAdd", "cppFunctionName": "StreamAdd", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5118,12 +4992,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "streamFinalize", "cppFunctionName": "StreamFinalize", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5140,7 +5013,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "streamHash", "cppFunctionName": "StreamHash", "return": { @@ -5220,12 +5092,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "base", "cppFunctionName": "Base", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5255,12 +5126,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "baseMany", "cppFunctionName": "BaseMany", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -5298,19 +5168,18 @@ { "name": "strip_comments", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "prettify", "cppFunctionName": "Prettify", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -5357,12 +5226,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteIteratorNew", "cppFunctionName": "GitNoteIteratorNew", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5413,12 +5281,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteNext", "cppFunctionName": "GitNoteNext", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5454,12 +5321,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteRead", "cppFunctionName": "GitNoteRead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5476,7 +5342,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteMessage", "cppFunctionName": "GitNoteMessage", "return": { @@ -5498,7 +5363,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteOid", "cppFunctionName": "GitNoteOid", "return": { @@ -5526,13 +5390,13 @@ { "name": "author", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { "name": "committer", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -5556,19 +5420,18 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteCreate", "cppFunctionName": "GitNoteCreate", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5590,13 +5453,13 @@ { "name": "author", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { "name": "committer", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -5609,12 +5472,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteRemove", "cppFunctionName": "GitNoteRemove", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5660,12 +5522,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteDefaultRef", "cppFunctionName": "GitNoteDefaultRef", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5700,12 +5561,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitNoteForeach", "cppFunctionName": "GitNoteForeach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -5713,8 +5573,9 @@ }, { "filename": "object.h", + "dependencies": ["../include/oid.h", "../include/repo.h"], "jsClassName": "Object", - "cppClassName": "Object", + "cppClassName": "GitObject", "cType": "git_object", "freeFunctionName": "git_object_free", "functions": [ @@ -5724,7 +5585,7 @@ { "name": "object", "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isReturn": true }, @@ -5743,19 +5604,18 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5765,7 +5625,7 @@ { "name": "object_out", "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isReturn": true }, @@ -5790,19 +5650,19 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Number", + "jsClassName": "Number" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookupPrefix", "cppFunctionName": "LookupPrefix", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5812,7 +5672,7 @@ { "name": "obj", "cType": "const git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isSelf": true } @@ -5820,9 +5680,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, - "jsFunctionName": "id", - "cppFunctionName": "Id", + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", "cppClassName": "GitOid", @@ -5835,7 +5694,7 @@ { "name": "obj", "cType": "const git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isSelf": true } @@ -5843,12 +5702,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "type", "cppFunctionName": "Type", "return": { "cType": "git_otype", - "cppClassName": "Otype", + "cppClassName": "Number", "isErrorCode": false } }, @@ -5858,15 +5716,15 @@ { "name": "obj", "cType": "const git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "owner", "cppFunctionName": "Owner", "return": { @@ -5881,10 +5739,11 @@ { "name": "object", "cType": "git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -5903,14 +5762,14 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Number", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "type2string", "cppFunctionName": "Type2string", "return": { @@ -5929,15 +5788,15 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "string2type", "cppFunctionName": "String2type", "return": { "cType": "git_otype", - "cppClassName": "Otype", + "cppClassName": "Number", "isErrorCode": false } }, @@ -5947,19 +5806,19 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Number", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "typeisloose", "cppFunctionName": "Typeisloose", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -5969,14 +5828,14 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "Size", "cppFunctionName": "Size", "return": { @@ -5991,32 +5850,32 @@ { "name": "peeled", "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isReturn": true }, { "name": "object", "cType": "const git_object *", - "cppClassName": "Object", - "jsClassName": "Object" + "cppClassName": "GitObject", + "jsClassName": "Object", + "isSelf": true }, { "name": "target_type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "isFree": false, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "peel", "cppFunctionName": "Peel", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6026,26 +5885,28 @@ { "name": "dest", "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object", "isReturn": true }, { "name": "source", "cType": "git_object *", - "cppClassName": "Object", - "jsClassName": "Object" + "cppClassName": "GitObject", + "jsClassName": "Object", + "ignore": true, + "isSelf": true } ], + "ignore": true, "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "isFree": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "dup", "cppFunctionName": "Dup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -6072,12 +5933,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6101,12 +5961,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "open", "cppFunctionName": "Open", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6129,19 +5988,18 @@ { "name": "priority", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addBackend", "cppFunctionName": "AddBackend", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6164,19 +6022,18 @@ { "name": "priority", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addAlternate", "cppFunctionName": "AddAlternate", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6200,12 +6057,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addDiskAlternate", "cppFunctionName": "AddDiskAlternate", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6257,12 +6113,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "read", "cppFunctionName": "Read", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6298,12 +6153,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "readPrefix", "cppFunctionName": "ReadPrefix", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6319,8 +6173,8 @@ { "name": "type_out", "cType": "git_otype *", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "db", @@ -6338,12 +6192,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "readHeader", "cppFunctionName": "ReadHeader", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6367,12 +6220,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "exists", "cppFunctionName": "Exists", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6390,12 +6242,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "refresh", "cppFunctionName": "Refresh", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6425,12 +6276,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6465,19 +6315,18 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "write", "cppFunctionName": "Write", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6506,19 +6355,18 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "openWstream", "cppFunctionName": "OpenWstream", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6548,12 +6396,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "openRstream", "cppFunctionName": "OpenRstream", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6589,12 +6436,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "writePack", "cppFunctionName": "WritePack", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6623,19 +6469,18 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "hash", "cppFunctionName": "Hash", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6658,19 +6503,18 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "hashfile", "cppFunctionName": "Hashfile", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6709,7 +6553,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "objectId", "cppFunctionName": "ObjectId", "return": { @@ -6731,7 +6574,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "objectData", "cppFunctionName": "ObjectData", "return": { @@ -6753,7 +6595,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "objectSize", "cppFunctionName": "ObjectSize", "return": { @@ -6775,12 +6616,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "objectType", "cppFunctionName": "ObjectType", "return": { "cType": "git_otype", - "cppClassName": "Otype", + "cppClassName": "Int32", "isErrorCode": false } } @@ -6813,12 +6653,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "pack", "cppFunctionName": "Pack", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -6830,7 +6669,6 @@ "jsClassName": "Oid", "cppClassName": "GitOid", "cType": "git_oid", - "freeFunctionName": "free", "functions": [ { "cFunctionName": "git_oid_fromstr", @@ -6853,12 +6691,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "fromString", "cppFunctionName": "FromString", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6883,12 +6720,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "fromstrp", "cppFunctionName": "Fromstrp", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6919,12 +6755,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "fromstrn", "cppFunctionName": "Fromstrn", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -6949,7 +6784,6 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "fromraw", "cppFunctionName": "Fromraw", "return": { @@ -6980,7 +6814,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "fmt", "cppFunctionName": "Fmt", "return": { @@ -7010,7 +6843,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "pathfmt", "cppFunctionName": "Pathfmt", "return": { @@ -7033,7 +6865,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "sha", "cppFunctionName": "Sha", "return": { @@ -7069,7 +6900,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "sha", "cppFunctionName": "Sha", "return": { @@ -7100,7 +6930,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "cpy", "cppFunctionName": "Cpy", "return": { @@ -7130,12 +6959,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "cmp", "cppFunctionName": "Cmp", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7160,12 +6988,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "equal", "cppFunctionName": "Equal", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7196,12 +7023,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "ncmp", "cppFunctionName": "Ncmp", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7226,12 +7052,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "streq", "cppFunctionName": "Streq", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7250,12 +7075,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "iszero", "cppFunctionName": "Iszero", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7273,7 +7097,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "shortenNew", "cppFunctionName": "ShortenNew", "return": { @@ -7302,12 +7125,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "shortenAdd", "cppFunctionName": "ShortenAdd", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7363,12 +7185,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderNew", "cppFunctionName": "GitPackbuilderNew", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7384,19 +7205,18 @@ { "name": "n", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderSetThreads", "cppFunctionName": "GitPackbuilderSetThreads", "return": { "cType": "unsigned int", - "cppClassName": "unsigned", + "cppClassName": "Uint32", "isErrorCode": false } }, @@ -7425,12 +7245,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderInsert", "cppFunctionName": "GitPackbuilderInsert", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7453,12 +7272,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderInsertTree", "cppFunctionName": "GitPackbuilderInsertTree", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7481,12 +7299,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderWrite", "cppFunctionName": "GitPackbuilderWrite", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7515,12 +7332,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderForeach", "cppFunctionName": "GitPackbuilderForeach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7537,7 +7353,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderObjectCount", "cppFunctionName": "GitPackbuilderObjectCount", "return": { @@ -7559,7 +7374,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitPackbuilderWritten", "cppFunctionName": "GitPackbuilderWritten", "return": { @@ -7619,12 +7433,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7648,12 +7461,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setOptions", "cppFunctionName": "SetOptions", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7677,12 +7489,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addRefspec", "cppFunctionName": "AddRefspec", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7700,12 +7511,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "updateTips", "cppFunctionName": "UpdateTips", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7723,12 +7533,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "finish", "cppFunctionName": "Finish", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7746,12 +7555,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "unpackOk", "cppFunctionName": "UnpackOk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7768,8 +7576,8 @@ { "name": "cb", "cType": "int (*)(const char *ref, const char *msg, void *data)", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "data", @@ -7781,12 +7589,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "statusForeach", "cppFunctionName": "StatusForeach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7853,7 +7660,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "gitReference_Alloc", "cppFunctionName": "GitReference_Alloc", "return": { @@ -7882,12 +7688,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7911,12 +7716,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "open", "cppFunctionName": "Open", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7934,12 +7738,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "compress", "cppFunctionName": "Compress", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -7985,12 +7788,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setBackend", "cppFunctionName": "SetBackend", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -8029,12 +7831,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "fs", "cppFunctionName": "Fs", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -8067,12 +7868,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "read", "cppFunctionName": "Read", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8090,12 +7890,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "write", "cppFunctionName": "Write", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8118,7 +7917,7 @@ { "name": "committer", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -8131,12 +7930,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "append", "cppFunctionName": "Append", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8159,12 +7957,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "rename", "cppFunctionName": "Rename", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8181,12 +7978,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "delete", "cppFunctionName": "Delete", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8204,7 +8000,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entrycount", "cppFunctionName": "Entrycount", "return": { @@ -8233,7 +8028,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entryByindex", "cppFunctionName": "EntryByindex", "return": { @@ -8261,19 +8055,18 @@ { "name": "rewrite_previous_entry", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "drop", "cppFunctionName": "Drop", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8290,7 +8083,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "entryIdOld", "cppFunctionName": "EntryIdOld", "return": { @@ -8312,7 +8104,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "entryIdNew", "cppFunctionName": "EntryIdNew", "return": { @@ -8334,12 +8125,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "entryCommitter", "cppFunctionName": "EntryCommitter", "return": { "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "isErrorCode": false } }, @@ -8356,7 +8146,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "entryMessage", "cppFunctionName": "EntryMessage", "return": { @@ -8426,12 +8215,11 @@ "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8461,12 +8249,11 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "oidForName", "cppFunctionName": "OidForName", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8501,20 +8288,19 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createSymbolic", "cppFunctionName": "CreateSymbolic", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8549,20 +8335,19 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "create", "cppFunctionName": "Create", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8580,7 +8365,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "oid", "cppFunctionName": "Oid", "return": { @@ -8603,7 +8387,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "name", "cppFunctionName": "Name", "return": { @@ -8626,7 +8409,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "type", "cppFunctionName": "Type", "return": { @@ -8650,7 +8432,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "name", "cppFunctionName": "Name", "return": { @@ -8680,12 +8461,11 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "resolve", "cppFunctionName": "Resolve", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8704,7 +8484,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "owner", "cppFunctionName": "owner", "return": { @@ -8741,12 +8520,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "gitReferenceSymbolicSetTarget", "cppFunctionName": "GitReferenceSymbolicSetTarget", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8778,12 +8556,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setTarget", "cppFunctionName": "setTarget", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8813,20 +8590,19 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "rename", "cppFunctionName": "Rename", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8845,12 +8621,11 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "delete", "cppFunctionName": "Delete", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8872,20 +8647,19 @@ { "name": "list_flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "list", "cppFunctionName": "List", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8901,8 +8675,8 @@ { "name": "list_flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "callback", @@ -8921,12 +8695,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -8974,12 +8747,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "compare", "cppFunctionName": "Compare", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9001,8 +8773,8 @@ { "name": "list_flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "callback", @@ -9021,12 +8793,11 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreachGlob", "cppFunctionName": "ForeachGlob", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9045,12 +8816,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "hasLog", "cppFunctionName": "HasLog", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9069,12 +8839,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "isBranch", "cppFunctionName": "IsBranch", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9093,12 +8862,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "isRemote", "cppFunctionName": "IsRemote", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9127,20 +8895,19 @@ { "name": "flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "normalizeName", "cppFunctionName": "NormalizeName", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9151,7 +8918,7 @@ "name": "out", "isReturn": true, "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -9172,12 +8939,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "peel", "cppFunctionName": "Peel", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9195,12 +8961,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "isValidName", "cppFunctionName": "IsValidName", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -9227,7 +8992,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "src", "cppFunctionName": "Src", "return": { @@ -9250,7 +9014,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "dst", "cppFunctionName": "Dst", "return": { @@ -9273,12 +9036,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "force", "cppFunctionName": "Force", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9302,12 +9064,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "srcMatches", "cppFunctionName": "SrcMatches", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9331,12 +9092,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "dstMatches", "cppFunctionName": "DstMatches", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9372,12 +9132,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "transform", "cppFunctionName": "Transform", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9413,12 +9172,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "rtransform", "cppFunctionName": "Rtransform", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -9463,12 +9221,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "create", "cppFunctionName": "Create", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9504,12 +9261,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createInmemory", "cppFunctionName": "CreateInmemory", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9539,12 +9295,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "load", "cppFunctionName": "Load", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9562,12 +9317,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "save", "cppFunctionName": "Save", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9585,7 +9339,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "name", "cppFunctionName": "Name", "return": { @@ -9608,7 +9361,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "url", "cppFunctionName": "Url", "return": { @@ -9631,7 +9383,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "pushurl", "cppFunctionName": "Pushurl", "return": { @@ -9660,12 +9411,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setUrl", "cppFunctionName": "SetUrl", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9689,12 +9439,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setPushurl", "cppFunctionName": "SetPushurl", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9718,12 +9467,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setFetchspec", "cppFunctionName": "SetFetchspec", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9741,7 +9489,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "fetchspec", "cppFunctionName": "Fetchspec", "return": { @@ -9770,12 +9517,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setPushspec", "cppFunctionName": "SetPushspec", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9793,7 +9539,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "pushspec", "cppFunctionName": "Pushspec", "return": { @@ -9822,12 +9567,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "connect", "cppFunctionName": "Connect", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9857,12 +9601,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "ls", "cppFunctionName": "Ls", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9892,12 +9635,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "download", "cppFunctionName": "Download", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9915,12 +9657,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "connected", "cppFunctionName": "Connected", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -9938,7 +9679,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "stop", "cppFunctionName": "Stop", "return": { @@ -9961,7 +9701,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "disconnect", "cppFunctionName": "Disconnect", "return": { @@ -10006,12 +9745,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "updateTips", "cppFunctionName": "UpdateTips", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10028,12 +9766,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "validUrl", "cppFunctionName": "ValidUrl", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10050,12 +9787,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "supportedUrl", "cppFunctionName": "SupportedUrl", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10079,12 +9815,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "list", "cppFunctionName": "List", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10101,14 +9836,13 @@ { "name": "check", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "checkCert", "cppFunctionName": "CheckCert", "return": { @@ -10143,7 +9877,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setCredAcquireCb", "cppFunctionName": "SetCredAcquireCb", "return": { @@ -10172,12 +9905,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setTransport", "cppFunctionName": "SetTransport", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10201,12 +9933,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setCallbacks", "cppFunctionName": "SetCallbacks", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10224,7 +9955,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "stats", "cppFunctionName": "Stats", "return": { @@ -10239,7 +9969,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "autotag", "cppFunctionName": "Autotag", "return": { @@ -10268,7 +9997,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setAutotag", "cppFunctionName": "SetAutotag", "return": { @@ -10309,12 +10037,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "rename", "cppFunctionName": "Rename", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10332,12 +10059,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "updateFetchhead", "cppFunctionName": "UpdateFetchhead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10354,14 +10080,13 @@ { "name": "value", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setUpdateFetchhead", "cppFunctionName": "SetUpdateFetchhead", "return": { @@ -10383,12 +10108,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "isValidName", "cppFunctionName": "IsValidName", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -10422,12 +10146,11 @@ "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "open", "cppFunctionName": "Open", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10452,12 +10175,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "wrapOdb", "cppFunctionName": "WrapOdb", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10485,8 +10207,8 @@ { "name": "across_fs", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "ceiling_dirs", @@ -10499,12 +10221,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "discover", "cppFunctionName": "Discover", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10527,8 +10248,8 @@ { "name": "flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" }, { "name": "ceiling_dirs", @@ -10541,12 +10262,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "openExt", "cppFunctionName": "OpenExt", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10599,12 +10319,11 @@ "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "init", "cppFunctionName": "Init", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10635,12 +10354,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "initExt", "cppFunctionName": "InitExt", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10665,12 +10383,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "head", "cppFunctionName": "Head", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10689,12 +10406,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "headDetached", "cppFunctionName": "HeadDetached", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10713,12 +10429,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "headOrphan", "cppFunctionName": "HeadOrphan", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10737,12 +10452,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "isEmpty", "cppFunctionName": "IsEmpty", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10760,7 +10474,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "path", "cppFunctionName": "Path", "return": { @@ -10783,7 +10496,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "workdir", "cppFunctionName": "Workdir", "return": { @@ -10811,20 +10523,19 @@ { "name": "update_gitlink", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setWorkdir", "cppFunctionName": "SetWorkdir", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10843,12 +10554,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "isBare", "cppFunctionName": "IsBare", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10873,12 +10583,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "config", "cppFunctionName": "Config", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10903,7 +10612,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setConfig", "cppFunctionName": "SetConfig", "return": { @@ -10933,12 +10641,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "odb", "cppFunctionName": "Odb", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -10963,7 +10670,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setOdb", "cppFunctionName": "SetOdb", "return": { @@ -10993,12 +10699,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "refdb", "cppFunctionName": "Refdb", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11023,7 +10728,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setRefdb", "cppFunctionName": "SetRefdb", "return": { @@ -11053,12 +10757,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "index", "cppFunctionName": "Index", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11083,7 +10786,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setIndex", "cppFunctionName": "SetIndex", "return": { @@ -11119,12 +10821,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "message", "cppFunctionName": "Message", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11143,12 +10844,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "messageRemove", "cppFunctionName": "MessageRemove", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11167,12 +10867,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "mergeCleanup", "cppFunctionName": "MergeCleanup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11203,12 +10902,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "fetchheadForeach", "cppFunctionName": "FetchheadForeach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11239,12 +10937,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "mergeheadForeach", "cppFunctionName": "MergeheadForeach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11287,12 +10984,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "hashfile", "cppFunctionName": "Hashfile", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11316,12 +11012,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "setHead", "cppFunctionName": "SetHead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11345,12 +11040,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "setHeadDetached", "cppFunctionName": "SetHeadDetached", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11368,12 +11062,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "detachHead", "cppFunctionName": "DetachHead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11392,12 +11085,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "state", "cppFunctionName": "State", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -11422,7 +11114,7 @@ { "name": "target", "cType": "git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -11435,12 +11127,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitReset", "cppFunctionName": "GitReset", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11456,7 +11147,7 @@ { "name": "target", "cType": "git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -11469,12 +11160,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "default", "cppFunctionName": "Default", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -11494,7 +11184,7 @@ "name": "out", "isReturn": true, "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -11513,12 +11203,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "single", "cppFunctionName": "Single", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11547,12 +11236,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitRevparse", "cppFunctionName": "GitRevparse", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -11585,12 +11273,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11608,7 +11295,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reset", "cppFunctionName": "Reset", "return": { @@ -11637,12 +11323,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "push", "cppFunctionName": "Push", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11666,12 +11351,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "pushGlob", "cppFunctionName": "PushGlob", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11689,12 +11373,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "pushHead", "cppFunctionName": "PushHead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11718,12 +11401,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "hide", "cppFunctionName": "Hide", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11747,12 +11429,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "hideGlob", "cppFunctionName": "HideGlob", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11770,12 +11451,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "hideHead", "cppFunctionName": "HideHead", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11799,12 +11479,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "pushRef", "cppFunctionName": "PushRef", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11828,12 +11507,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "hideRef", "cppFunctionName": "HideRef", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11857,12 +11535,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "next", "cppFunctionName": "Next", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11879,14 +11556,13 @@ { "name": "sort_mode", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "sorting", "cppFunctionName": "Sorting", "return": { @@ -11915,12 +11591,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "pushRange", "cppFunctionName": "PushRange", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -11960,7 +11635,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "repository", "cppFunctionName": "Repository", "return": { @@ -11971,12 +11645,64 @@ } ] }, + { + "filename": "time.h", + "dependencies": [], + "jsClassName": "Time", + "cppClassName": "GitTime", + "cType": "git_time", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "time", + "cppFunctionName": "Time", + "name": "time", + "cType": "git_time_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "offset", + "cppFunctionName": "Offset", + "name": "offset", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ] + }, { "filename": "signature.h", + "dependencies": ["../include/time.h"], "jsClassName": "Signature", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "cType": "git_signature", - "freeFunctionName": "git_signature_free", + "fields": [ + { + "jsFunctionName": "name", + "cppFunctionName": "Name", + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "jsFunctionName": "email", + "cppFunctionName": "Email", + "name": "email", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "jsFunctionName": "time", + "cppFunctionName": "Time", + "name": "when", + "cType": "git_time", + "cppClassName": "GitTime", + "jsClassName": "Time" + } + ], "functions": [ { "cFunctionName": "git_signature_new", @@ -11985,7 +11711,7 @@ "name": "out", "isReturn": true, "cType": "git_signature **", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -12003,25 +11729,25 @@ { "name": "time", "cType": "git_time_t", - "cppClassName": "TimeT", - "jsClassName": "TimeT" + "cppClassName": "Integer", + "jsClassName": "Number" }, { "name": "offset", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12032,8 +11758,9 @@ "name": "out", "isReturn": true, "cType": "git_signature **", - "cppClassName": "Signature", - "jsClassName": "Signature" + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "isReturn": true }, { "name": "name", @@ -12051,12 +11778,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "now", "cppFunctionName": "Now", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12066,20 +11792,20 @@ { "name": "sig", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature", "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "dup", "cppFunctionName": "Dup", "return": { "cType": "git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "isErrorCode": false } }, @@ -12089,10 +11815,11 @@ { "name": "sig", "cType": "git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -12133,7 +11860,7 @@ { "name": "stasher", "cType": "git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -12145,19 +11872,18 @@ { "name": "flags", "cType": "unsigned int", - "cppClassName": "unsigned", - "jsClassName": "unsigned" + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "save", "cppFunctionName": "Save", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12186,12 +11912,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12214,12 +11939,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "drop", "cppFunctionName": "Drop", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -12257,12 +11981,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12297,12 +12020,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreachExt", "cppFunctionName": "ForeachExt", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12312,8 +12034,8 @@ { "name": "status_flags", "cType": "unsigned int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "repo", @@ -12331,12 +12053,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "file", "cppFunctionName": "File", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12346,8 +12067,8 @@ { "name": "ignored", "cType": "int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "repo", @@ -12365,12 +12086,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "shouldIgnore", "cppFunctionName": "ShouldIgnore", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -12433,12 +12153,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "copy", "cppFunctionName": "Copy", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -12477,12 +12196,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12498,8 +12216,8 @@ { "name": "callback", "cType": "int (*)(git_submodule *sm, const char *name, void *payload)", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "payload", @@ -12511,12 +12229,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12551,19 +12268,18 @@ { "name": "use_gitlink", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "addSetup", "cppFunctionName": "AddSetup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12581,12 +12297,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addFinalize", "cppFunctionName": "AddFinalize", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12603,19 +12318,18 @@ { "name": "write_index", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "addToIndex", "cppFunctionName": "AddToIndex", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12633,12 +12347,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "save", "cppFunctionName": "Save", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12656,7 +12369,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "owner", "cppFunctionName": "Owner", "return": { @@ -12679,7 +12391,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "name", "cppFunctionName": "Name", "return": { @@ -12702,7 +12413,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "path", "cppFunctionName": "Path", "return": { @@ -12725,7 +12435,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "url", "cppFunctionName": "Url", "return": { @@ -12754,12 +12463,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setUrl", "cppFunctionName": "SetUrl", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12777,7 +12485,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "indexId", "cppFunctionName": "IndexId", "return": { @@ -12800,7 +12507,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "headId", "cppFunctionName": "HeadId", "return": { @@ -12823,7 +12529,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "wdId", "cppFunctionName": "WdId", "return": { @@ -12838,7 +12543,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "ignore", "cppFunctionName": "Ignore", "return": { @@ -12867,7 +12571,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setIgnore", "cppFunctionName": "SetIgnore", "return": { @@ -12882,7 +12585,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "update", "cppFunctionName": "Update", "return": { @@ -12911,7 +12613,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setUpdate", "cppFunctionName": "SetUpdate", "return": { @@ -12934,12 +12635,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "fetchRecurseSubmodules", "cppFunctionName": "FetchRecurseSubmodules", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12956,19 +12656,18 @@ { "name": "fetch_recurse_submodules", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "setFetchRecurseSubmodules", "cppFunctionName": "SetFetchRecurseSubmodules", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -12985,19 +12684,18 @@ { "name": "overwrite", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "init", "cppFunctionName": "Init", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13015,12 +12713,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "sync", "cppFunctionName": "Sync", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13043,12 +12740,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "open", "cppFunctionName": "Open", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13066,12 +12762,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "reload", "cppFunctionName": "Reload", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13088,12 +12783,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "reloadAll", "cppFunctionName": "ReloadAll", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13103,8 +12797,8 @@ { "name": "status", "cType": "unsigned int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "submodule", @@ -13116,12 +12810,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "status", "cppFunctionName": "Status", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13131,8 +12824,8 @@ { "name": "location_status", "cType": "unsigned int *", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" }, { "name": "submodule", @@ -13144,12 +12837,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "location", "cppFunctionName": "Location", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -13188,12 +12880,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13229,12 +12920,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookupPrefix", "cppFunctionName": "LookupPrefix", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13274,9 +12964,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, - "jsFunctionName": "id", - "cppFunctionName": "Id", + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", "cppClassName": "GitOid", @@ -13289,7 +12978,7 @@ { "name": "target_out", "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -13302,12 +12991,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "target", "cppFunctionName": "Target", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13325,7 +13013,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "targetId", "cppFunctionName": "TargetId", "return": { @@ -13348,7 +13035,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "targetType", "cppFunctionName": "TargetType", "return": { @@ -13371,7 +13057,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "name", "cppFunctionName": "Name", "return": { @@ -13394,12 +13079,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "tagger", "cppFunctionName": "Tagger", "return": { "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "isErrorCode": false } }, @@ -13417,7 +13101,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "message", "cppFunctionName": "Message", "return": { @@ -13450,13 +13133,13 @@ { "name": "target", "cType": "const git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { "name": "tagger", "cType": "const git_signature *", - "cppClassName": "Signature", + "cppClassName": "GitSignature", "jsClassName": "Signature" }, { @@ -13468,19 +13151,18 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "create", "cppFunctionName": "Create", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13508,19 +13190,18 @@ { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createFrombuffer", "cppFunctionName": "CreateFrombuffer", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13548,25 +13229,24 @@ { "name": "target", "cType": "const git_object *", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { "name": "force", "cType": "int", - "cppClassName": "int", - "jsClassName": "int" + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "createLightweight", "cppFunctionName": "CreateLightweight", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13589,12 +13269,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "delete", "cppFunctionName": "Delete", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13617,12 +13296,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "list", "cppFunctionName": "List", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13651,12 +13329,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "listMatch", "cppFunctionName": "ListMatch", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13685,12 +13362,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "foreach", "cppFunctionName": "Foreach", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13700,7 +13376,7 @@ { "name": "tag_target_out", "cType": "git_object **", - "cppClassName": "Object", + "cppClassName": "GitObject", "jsClassName": "Object" }, { @@ -13713,12 +13389,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "peel", "cppFunctionName": "Peel", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -13726,10 +13401,10 @@ }, { "filename": "threads.h", + "dependencies": [], "jsClassName": "Threads", - "cppClassName": "Threads", + "cppClassName": "GitThreads", "cType": "git_threads", - "freeFunctionName": "git_threads_free", "functions": [ { "cFunctionName": "git_threads_init", @@ -13737,12 +13412,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "init", "cppFunctionName": "Init", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13752,7 +13426,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "shutdown", "cppFunctionName": "Shutdown", "return": { @@ -13789,12 +13462,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "set", "cppFunctionName": "Set", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } @@ -13833,12 +13505,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitCredUserpassPlaintextNew", "cppFunctionName": "GitCredUserpassPlaintextNew", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13868,12 +13539,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "new", "cppFunctionName": "New", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13903,12 +13573,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "dummy", "cppFunctionName": "Dummy", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13938,12 +13607,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "local", "cppFunctionName": "Local", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -13973,12 +13641,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "smart", "cppFunctionName": "Smart", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14002,12 +13669,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitSmartSubtransportHttp", "cppFunctionName": "GitSmartSubtransportHttp", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14031,22 +13697,230 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitSmartSubtransportGit", "cppFunctionName": "GitSmartSubtransportGit", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } ] }, { - "filename": "tree.h", - "jsClassName": "Tree", - "cppClassName": "Tree", - "cType": "git_tree", + "filename": "tree_entry.h", + "dependencies": ["../include/oid.h", "../include/repo.h", "../include/object.h"], + "jsClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", + "cType": "git_tree_entry", + "freeFunctionName": "git_tree_entry_free", + "functions": [ + { + "cFunctionName": "git_tree_entry_dup", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "dup", + "cppFunctionName": "Dup", + "return": { + "cType": "git_tree_entry *", + "cppClassName": "TreeEntry", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_free", + "args": [ + { + "name": "entry", + "cType": "git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_name", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_id", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_type", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_otype", + "cppClassName": "Number", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_filemode", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "filemode", + "cppFunctionName": "filemode", + "return": { + "cType": "git_filemode_t", + "cppClassName": "Number", + "isErrorCode": false + } + }, + { + "cFunctionName": "git_tree_entry_cmp", + "args": [ + { + "name": "e1", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + }, + { + "name": "e2", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "compare", + "cppFunctionName": "Compare", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_entry_to_object", + "args": [ + { + "name": "object_out", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "TreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getObject", + "cppFunctionName": "GetObject", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + } + ] + }, + { + "filename": "tree.h", + "jsClassName": "Tree", + "cppClassName": "GitTree", + "cType": "git_tree", "freeFunctionName": "git_tree_free", "functions": [ { @@ -14056,7 +13930,7 @@ "name": "out", "isReturn": true, "cType": "git_tree **", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { @@ -14075,12 +13949,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookup", "cppFunctionName": "Lookup", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14091,7 +13964,7 @@ "name": "out", "isReturn": true, "cType": "git_tree **", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { @@ -14116,12 +13989,11 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "lookupPrefix", "cppFunctionName": "LookupPrefix", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14131,7 +14003,7 @@ { "name": "tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" } ], @@ -14153,7 +14025,7 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true } @@ -14161,9 +14033,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, - "jsFunctionName": "id", - "cppFunctionName": "Id", + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", "cppClassName": "GitOid", @@ -14176,7 +14047,7 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true } @@ -14184,7 +14055,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "owner", "cppFunctionName": "Owner", "return": { @@ -14199,7 +14069,7 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true } @@ -14207,7 +14077,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entrycount", "cppFunctionName": "Entrycount", "return": { @@ -14222,7 +14091,7 @@ { "name": "tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true }, @@ -14236,7 +14105,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entryByname", "cppFunctionName": "EntryByname", "return": { @@ -14251,7 +14119,7 @@ { "name": "tree", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true }, @@ -14265,7 +14133,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entryByindex", "cppFunctionName": "EntryByindex", "return": { @@ -14280,7 +14147,7 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true }, @@ -14294,7 +14161,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "entryByoid", "cppFunctionName": "EntryByoid", "return": { @@ -14316,7 +14182,7 @@ { "name": "root", "cType": "git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" }, { @@ -14329,206 +14195,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "entryBypath", "cppFunctionName": "EntryBypath", "return": { "cType": "int", - "cppClassName": "int", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tree_entry_dup", - "args": [ - { - "name": "entry", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryDup", - "cppFunctionName": "EntryDup", - "return": { - "cType": "git_tree_entry *", - "cppClassName": "TreeEntry", - "isErrorCode": false - } - }, - { - "cFunctionName": "git_tree_entry_free", - "args": [ - { - "name": "entry", - "cType": "git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": true, - "jsFunctionName": "entryFree", - "cppFunctionName": "EntryFree", - "return": { - "cType": "void", - "cppClassName": "void", - "isErrorCode": false - } - }, - { - "cFunctionName": "git_tree_entry_name", - "args": [ - { - "name": "entry", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryName", - "cppFunctionName": "EntryName", - "return": { - "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false - } - }, - { - "cFunctionName": "git_tree_entry_id", - "args": [ - { - "name": "entry", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryId", - "cppFunctionName": "EntryId", - "return": { - "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false - } - }, - { - "cFunctionName": "git_tree_entry_type", - "args": [ - { - "name": "entry", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryType", - "cppFunctionName": "EntryType", - "return": { - "cType": "git_otype", - "cppClassName": "Otype", - "isErrorCode": false - } - }, - { - "cFunctionName": "git_tree_entry_filemode", - "args": [ - { - "name": "entry", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryFilemode", - "cppFunctionName": "EntryFilemode", - "return": { - "cType": "git_filemode_t", - "cppClassName": "FilemodeT", - "isErrorCode": false - } - }, - { - "cFunctionName": "git_tree_entry_cmp", - "args": [ - { - "name": "e1", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - }, - { - "name": "e2", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryCmp", - "cppFunctionName": "EntryCmp", - "return": { - "cType": "int", - "cppClassName": "int", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tree_entry_to_object", - "args": [ - { - "name": "object_out", - "cType": "git_object **", - "cppClassName": "Object", - "jsClassName": "Object" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "entry", - "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "jsClassName": "TreeEntry" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": false, - "jsFunctionName": "entryToObject", - "cppFunctionName": "EntryToObject", - "return": { - "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14545,19 +14216,18 @@ { "name": "source", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderCreate", "cppFunctionName": "GitTreebuilderCreate", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14574,7 +14244,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderClear", "cppFunctionName": "GitTreebuilderClear", "return": { @@ -14596,12 +14265,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderEntrycount", "cppFunctionName": "GitTreebuilderEntrycount", "return": { "cType": "unsigned int", - "cppClassName": "unsigned", + "cppClassName": "Uint32", "isErrorCode": false } }, @@ -14646,7 +14314,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderGet", "cppFunctionName": "GitTreebuilderGet", "return": { @@ -14693,12 +14360,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderInsert", "cppFunctionName": "GitTreebuilderInsert", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14721,12 +14387,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderRemove", "cppFunctionName": "GitTreebuilderRemove", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14755,7 +14420,6 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderFilter", "cppFunctionName": "GitTreebuilderFilter", "return": { @@ -14789,12 +14453,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "isFree": false, "jsFunctionName": "gitTreebuilderWrite", "cppFunctionName": "GitTreebuilderWrite", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } }, @@ -14804,7 +14467,7 @@ { "name": "tree", "cType": "const git_tree *", - "cppClassName": "Tree", + "cppClassName": "GitTree", "jsClassName": "Tree", "isSelf": true }, @@ -14830,12 +14493,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "isFree": false, "jsFunctionName": "walk", "cppFunctionName": "Walk", "return": { "cType": "int", - "cppClassName": "int", + "cppClassName": "Int32", "isErrorCode": true } } From c20ee681af51b5ce9a093291b902438d7292843f Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 24 Jun 2013 16:18:50 +0200 Subject: [PATCH 06/28] Index is now code-gen'd --- gen.js | 2 +- include/blob.h | 7 + include/commit.h | 7 + include/index.h | 146 ++++++--- include/object.h | 6 + include/reference.h | 40 +++ include/repo.h | 3 + include/tree_entry.h | 2 + src/blob.cc | 46 ++- src/commit.cc | 81 +++-- src/index.cc | 632 +++++++++++++++++++++++++++++++++++++ src/object.cc | 38 ++- src/reference.cc | 382 ++++++++++++++++++++-- src/repo.cc | 26 +- src/tree_entry.cc | 13 +- templates/class.cc.ejs | 66 ++-- templates/header.h.ejs | 1 + test/convenience-commit.js | 3 + v0.18.0.json | 84 ++--- 19 files changed, 1371 insertions(+), 214 deletions(-) create mode 100644 src/index.cc diff --git a/gen.js b/gen.js index f64aa6bfd..0aace8700 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/blob.h b/include/blob.h index 51f875fb6..058508ece 100755 --- a/include/blob.h +++ b/include/blob.h @@ -37,7 +37,9 @@ class GitBlob : public ObjectWrap { uv_work_t request; const git_error* error; git_blob * blob; + Persistent repoReference; git_repository * repo; + Persistent idReference; const git_oid * id; Persistent callback; }; @@ -52,7 +54,9 @@ class GitBlob : public ObjectWrap { uv_work_t request; const git_error* error; git_oid * id; + Persistent repoReference; git_repository * repo; + Persistent pathReference; const char * path; Persistent callback; }; @@ -64,8 +68,11 @@ class GitBlob : public ObjectWrap { uv_work_t request; const git_error* error; git_oid * oid; + Persistent repoReference; git_repository * repo; + Persistent bufferReference; const void * buffer; + Persistent lenReference; size_t len; Persistent callback; }; diff --git a/include/commit.h b/include/commit.h index ad348163c..55520a11b 100755 --- a/include/commit.h +++ b/include/commit.h @@ -37,7 +37,9 @@ class GitCommit : public ObjectWrap { uv_work_t request; const git_error* error; git_commit * commit; + Persistent repoReference; git_repository * repo; + Persistent idReference; const git_oid * id; Persistent callback; }; @@ -56,6 +58,7 @@ class GitCommit : public ObjectWrap { uv_work_t request; const git_error* error; git_tree * tree_out; + Persistent commitReference; const git_commit * commit; Persistent callback; }; @@ -69,10 +72,14 @@ class GitCommit : public ObjectWrap { uv_work_t request; const git_error* error; git_commit * out; + Persistent commitReference; git_commit * commit; + Persistent nReference; unsigned int n; Persistent callback; }; + static Handle ParentId(const Arguments& args); + static Handle NthGenAncestor(const Arguments& args); git_commit *raw; }; diff --git a/include/index.h b/include/index.h index cf58288e2..8704e79f8 100755 --- a/include/index.h +++ b/include/index.h @@ -1,58 +1,118 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #ifndef INDEX_H #define INDEX_H +#include #include +#include #include "git2.h" using namespace node; +using namespace v8; -/** - * Class: GitIndex - * Wrapper for libgit2 git_error. - */ -class GitIndex : public ObjectWrap { +class Index : public ObjectWrap { public: - /** - * Variable: constructor_template - * Used to create Node.js constructor. - */ - static v8::Persistent constructor_template; - /** - * Function: Initialize - * Used to intialize the EventEmitter from Node.js - * - * Parameters: - * target - v8::Object the Node.js global module object - */ - static void Initialize(v8::Handle target); - - protected: - /** - * Constructor: GitIndex - */ - GitIndex() {}; - /** - * Deconstructor: GitIndex - */ - ~GitIndex() {}; - /** - * Function: New - * - * Parameters: - * args v8::Arguments function call - * - * Returns: - * v8::Object args.This() - */ - static v8::Handle New(const v8::Arguments& args); + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_index *GetValue(); + + private: + Index(git_index *raw); + ~Index(); + + static Handle New(const Arguments& args); + + + static Handle Open(const Arguments& args); + static void OpenWork(uv_work_t* req); + static void OpenAfterWork(uv_work_t* req); + + struct OpenBaton { + uv_work_t request; + const git_error* error; + git_index * out; + Persistent index_pathReference; + const char * index_path; + Persistent callback; + }; + static Handle New(const Arguments& args); + static Handle Owner(const Arguments& args); + static Handle Read(const Arguments& args); + static void ReadWork(uv_work_t* req); + static void ReadAfterWork(uv_work_t* req); + + struct ReadBaton { + uv_work_t request; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent callback; + }; + static Handle Write(const Arguments& args); + static void WriteWork(uv_work_t* req); + static void WriteAfterWork(uv_work_t* req); + + struct WriteBaton { + uv_work_t request; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent callback; + }; + static Handle ReadTree(const Arguments& args); + static void ReadTreeWork(uv_work_t* req); + static void ReadTreeAfterWork(uv_work_t* req); + + struct ReadTreeBaton { + uv_work_t request; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent treeReference; + const git_tree * tree; + Persistent callback; + }; + static Handle WriteTree(const Arguments& args); + static void WriteTreeWork(uv_work_t* req); + static void WriteTreeAfterWork(uv_work_t* req); + + struct WriteTreeBaton { + uv_work_t request; + const git_error* error; + git_oid * out; + Persistent indexReference; + git_index * index; + Persistent callback; + }; + static Handle Entrycount(const Arguments& args); + static Handle Clear(const Arguments& args); + static Handle Remove(const Arguments& args); + static Handle RemoveDirectory(const Arguments& args); + static Handle AddBypath(const Arguments& args); + static void AddBypathWork(uv_work_t* req); + static void AddBypathAfterWork(uv_work_t* req); + + struct AddBypathBaton { + uv_work_t request; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent pathReference; + const char * path; + Persistent callback; + }; + static Handle RemoveBypath(const Arguments& args); + static Handle Find(const Arguments& args); + static Handle ConflictRemove(const Arguments& args); + static Handle ConflictCleanup(const Arguments& args); + static Handle HasConflicts(const Arguments& args); + git_index *raw; }; #endif diff --git a/include/object.h b/include/object.h index 875e43439..f313a806b 100644 --- a/include/object.h +++ b/include/object.h @@ -37,13 +37,17 @@ class GitObject : public ObjectWrap { uv_work_t request; const git_error* error; git_object * object; + Persistent repoReference; git_repository * repo; + Persistent idReference; const git_oid * id; + Persistent typeReference; git_otype type; Persistent callback; }; static Handle Oid(const Arguments& args); static Handle Type(const Arguments& args); + static Handle Owner(const Arguments& args); static Handle Peel(const Arguments& args); static void PeelWork(uv_work_t* req); static void PeelAfterWork(uv_work_t* req); @@ -52,7 +56,9 @@ class GitObject : public ObjectWrap { uv_work_t request; const git_error* error; git_object * peeled; + Persistent objectReference; const git_object * object; + Persistent target_typeReference; git_otype target_type; Persistent callback; }; diff --git a/include/reference.h b/include/reference.h index 57ab38f17..fa644ba46 100644 --- a/include/reference.h +++ b/include/reference.h @@ -37,7 +37,9 @@ class GitReference : public ObjectWrap { uv_work_t request; const git_error* error; git_reference * out; + Persistent repoReference; git_repository * repo; + Persistent nameReference; const char * name; Persistent callback; }; @@ -49,10 +51,14 @@ class GitReference : public ObjectWrap { uv_work_t request; const git_error* error; git_oid * out; + Persistent repoReference; git_repository * repo; + Persistent nameReference; const char * name; Persistent callback; }; + static Handle CreateSymbolic(const Arguments& args); + static Handle Create(const Arguments& args); static Handle Oid(const Arguments& args); static Handle Name(const Arguments& args); static Handle Type(const Arguments& args); @@ -64,9 +70,43 @@ class GitReference : public ObjectWrap { uv_work_t request; const git_error* error; git_reference * out; + Persistent refReference; const git_reference * ref; Persistent callback; }; + static Handle SetSymbolicTarget(const Arguments& args); + static Handle setTarget(const Arguments& args); + static Handle Rename(const Arguments& args); + static void RenameWork(uv_work_t* req); + static void RenameAfterWork(uv_work_t* req); + + struct RenameBaton { + uv_work_t request; + const git_error* error; + git_reference * out; + Persistent refReference; + git_reference * ref; + Persistent new_nameReference; + const char * new_name; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle Delete(const Arguments& args); + static void DeleteWork(uv_work_t* req); + static void DeleteAfterWork(uv_work_t* req); + + struct DeleteBaton { + uv_work_t request; + const git_error* error; + Persistent refReference; + git_reference * ref; + Persistent callback; + }; + static Handle IsBranch(const Arguments& args); + static Handle IsRemote(const Arguments& args); + static Handle Peel(const Arguments& args); + static Handle IsValidName(const Arguments& args); git_reference *raw; }; diff --git a/include/repo.h b/include/repo.h index 9ac073c81..a50978b6a 100755 --- a/include/repo.h +++ b/include/repo.h @@ -37,6 +37,7 @@ class GitRepo : public ObjectWrap { uv_work_t request; const git_error* error; git_repository * out; + Persistent pathReference; const char * path; Persistent callback; }; @@ -48,7 +49,9 @@ class GitRepo : public ObjectWrap { uv_work_t request; const git_error* error; git_repository * out; + Persistent pathReference; const char * path; + Persistent is_bareReference; unsigned is_bare; Persistent callback; }; diff --git a/include/tree_entry.h b/include/tree_entry.h index a076a3a8c..fb2ca4c74 100755 --- a/include/tree_entry.h +++ b/include/tree_entry.h @@ -41,7 +41,9 @@ class GitTreeEntry : public ObjectWrap { uv_work_t request; const git_error* error; git_object * object_out; + Persistent repoReference; git_repository * repo; + Persistent entryReference; const git_tree_entry * entry; Persistent callback; }; diff --git a/src/blob.cc b/src/blob.cc index 1832ef8b3..500fc7361 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -82,12 +82,9 @@ Handle GitBlob::Lookup(const Arguments& args) { LookupBaton* baton = new LookupBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->idReference = Persistent::New(args[1]); baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -114,12 +111,11 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->blob) }; - Handle object = GitBlob::constructor_template->NewInstance(1, argv); + Handle blob = GitBlob::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + blob }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -132,7 +128,8 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->idReference.Dispose(); baton->callback.Dispose(); delete baton; } @@ -190,12 +187,10 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { CreateFromFileBaton* baton = new CreateFromFileBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->pathReference = Persistent::New(args[1]); String::Utf8Value path(args[1]->ToString()); - // XXX FIXME remove strdup and use std::string baton->path = strdup(*path); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -222,13 +217,11 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->id) }; - Handle object = GitOid::constructor_template->NewInstance(1, argv); - // free((void *) baton->path); + Handle id = GitOid::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + id }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -241,9 +234,9 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->pathReference.Dispose(); baton->callback.Dispose(); - delete baton->path; delete baton; } @@ -267,11 +260,11 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { CreateFromBufferBaton* baton = new CreateFromBufferBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->bufferReference = Persistent::New(args[1]); baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[1]->ToObject())); + baton->lenReference = Persistent::New(args[2]); baton->len = (size_t) args[2]->ToNumber()->Value(); baton->callback = Persistent::New(Local::Cast(args[3])); @@ -299,12 +292,11 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->oid) }; - Handle object = GitOid::constructor_template->NewInstance(1, argv); + Handle oid = GitOid::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + oid }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -317,7 +309,9 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->bufferReference.Dispose(); + baton->lenReference.Dispose(); baton->callback.Dispose(); delete baton; } diff --git a/src/commit.cc b/src/commit.cc index f9bad26f2..116a690b2 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -47,6 +47,8 @@ void GitCommit::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "treeId", TreeId); NODE_SET_PROTOTYPE_METHOD(tpl, "parentCount", ParentCount); NODE_SET_PROTOTYPE_METHOD(tpl, "parent", Parent); + NODE_SET_PROTOTYPE_METHOD(tpl, "parentId", ParentId); + NODE_SET_PROTOTYPE_METHOD(tpl, "nthGenAncestor", NthGenAncestor); constructor_template = Persistent::New(tpl->GetFunction()); @@ -87,12 +89,9 @@ Handle GitCommit::Lookup(const Arguments& args) { LookupBaton* baton = new LookupBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->idReference = Persistent::New(args[1]); baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -119,12 +118,11 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->commit) }; - Handle object = GitCommit::constructor_template->NewInstance(1, argv); + Handle commit = GitCommit::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + commit }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -137,7 +135,8 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->idReference.Dispose(); baton->callback.Dispose(); delete baton; } @@ -235,7 +234,7 @@ Handle GitCommit::Tree(const Arguments& args) { TreeBaton* baton = new TreeBaton; baton->error = NULL; baton->request.data = baton; - + baton->commitReference = Persistent::New(args.This()); baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); @@ -261,12 +260,11 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->tree_out) }; - Handle object = GitTree::constructor_template->NewInstance(1, argv); + Handle tree_out = GitTree::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + tree_out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -279,7 +277,7 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->commitReference.Dispose(); baton->callback.Dispose(); delete baton; } @@ -321,8 +319,9 @@ Handle GitCommit::Parent(const Arguments& args) { ParentBaton* baton = new ParentBaton; baton->error = NULL; baton->request.data = baton; - + baton->commitReference = Persistent::New(args.This()); baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->nReference = Persistent::New(args[0]); baton->n = (unsigned int) args[0]->ToUint32()->Value(); baton->callback = Persistent::New(Local::Cast(args[1])); @@ -349,12 +348,11 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle object = GitCommit::constructor_template->NewInstance(1, argv); + Handle out = GitCommit::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -367,10 +365,55 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->commitReference.Dispose(); + baton->nReference.Dispose(); baton->callback.Dispose(); delete baton; } +Handle GitCommit::ParentId(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); + } + + const git_oid * result = git_commit_parent_id( + + ObjectWrap::Unwrap(args.This())->GetValue() +, + (unsigned int) args[0]->ToUint32()->Value() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} + +Handle GitCommit::NthGenAncestor(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); + } + git_commit * ancestor; + + int result = git_commit_nth_gen_ancestor( +& + ancestor +, + ObjectWrap::Unwrap(args.This())->GetValue() +, + (unsigned int) args[0]->ToUint32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)ancestor) }; + return scope.Close(GitCommit::constructor_template->NewInstance(1, argv)); +} + Persistent GitCommit::constructor_template; diff --git a/src/index.cc b/src/index.cc new file mode 100644 index 000000000..dd9f925d8 --- /dev/null +++ b/src/index.cc @@ -0,0 +1,632 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/index.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +Index::Index(git_index *raw) { + this->raw = raw; +} + +Index::~Index() { + git_index_free(this->raw); +} + +void Index::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Index")); + + NODE_SET_METHOD(tpl, "open", Open); + NODE_SET_METHOD(tpl, "new", New); + NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner); + NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); + NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); + NODE_SET_PROTOTYPE_METHOD(tpl, "readTree", ReadTree); + NODE_SET_PROTOTYPE_METHOD(tpl, "writeTree", WriteTree); + NODE_SET_PROTOTYPE_METHOD(tpl, "entrycount", Entrycount); + NODE_SET_PROTOTYPE_METHOD(tpl, "clear", Clear); + NODE_SET_PROTOTYPE_METHOD(tpl, "remove", Remove); + NODE_SET_PROTOTYPE_METHOD(tpl, "removeDirectory", RemoveDirectory); + NODE_SET_PROTOTYPE_METHOD(tpl, "addByPath", AddBypath); + NODE_SET_PROTOTYPE_METHOD(tpl, "removeByPath", RemoveBypath); + NODE_SET_PROTOTYPE_METHOD(tpl, "find", Find); + NODE_SET_PROTOTYPE_METHOD(tpl, "conflictRemove", ConflictRemove); + NODE_SET_PROTOTYPE_METHOD(tpl, "conflictCleanup", ConflictCleanup); + NODE_SET_PROTOTYPE_METHOD(tpl, "hasConflicts", HasConflicts); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Index"), constructor_template); +} + +Handle Index::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_index is required."))); + } + + Index* object = new Index((git_index *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +git_index *Index::GetValue() { + return this->raw; +} + + +Handle Index::Open(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String index_path is required."))); + } + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + OpenBaton* baton = new OpenBaton; + baton->error = NULL; + baton->request.data = baton; + baton->index_pathReference = Persistent::New(args[0]); + String::Utf8Value index_path(args[0]->ToString()); + baton->index_path = strdup(*index_path); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); + + return Undefined(); +} + +void Index::OpenWork(uv_work_t *req) { + OpenBaton *baton = static_cast(req->data); + int result = git_index_open( + &baton->out, + baton->index_path + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Index::OpenAfterWork(uv_work_t *req) { + HandleScope scope; + OpenBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle out = Index::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + out + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->index_pathReference.Dispose(); + baton->callback.Dispose(); + delete baton->index_path; + delete baton; +} + +Handle Index::New(const Arguments& args) { + HandleScope scope; + git_index * out; + + int result = git_index_new( +& + out + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(Index::constructor_template->NewInstance(1, argv)); +} + +Handle Index::Owner(const Arguments& args) { + HandleScope scope; + + git_repository * result = git_index_owner( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); +} + +Handle Index::Read(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReadBaton* baton = new ReadBaton; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); + + return Undefined(); +} + +void Index::ReadWork(uv_work_t *req) { + ReadBaton *baton = static_cast(req->data); + int result = git_index_read( + baton->index + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Index::ReadAfterWork(uv_work_t *req) { + HandleScope scope; + ReadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle result = Local::New(Undefined()); + Handle argv2[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle Index::Write(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteBaton* baton = new WriteBaton; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); + + return Undefined(); +} + +void Index::WriteWork(uv_work_t *req) { + WriteBaton *baton = static_cast(req->data); + int result = git_index_write( + baton->index + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Index::WriteAfterWork(uv_work_t *req) { + HandleScope scope; + WriteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle result = Local::New(Undefined()); + Handle argv2[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle Index::ReadTree(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree tree is required."))); + } + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReadTreeBaton* baton = new ReadTreeBaton; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->treeReference = Persistent::New(args[0]); + baton->tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, ReadTreeWork, (uv_after_work_cb)ReadTreeAfterWork); + + return Undefined(); +} + +void Index::ReadTreeWork(uv_work_t *req) { + ReadTreeBaton *baton = static_cast(req->data); + int result = git_index_read_tree( + baton->index, + baton->tree + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Index::ReadTreeAfterWork(uv_work_t *req) { + HandleScope scope; + ReadTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle result = Local::New(Undefined()); + Handle argv2[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->treeReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle Index::WriteTree(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteTreeBaton* baton = new WriteTreeBaton; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteTreeWork, (uv_after_work_cb)WriteTreeAfterWork); + + return Undefined(); +} + +void Index::WriteTreeWork(uv_work_t *req) { + WriteTreeBaton *baton = static_cast(req->data); + int result = git_index_write_tree( + baton->out, + baton->index + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Index::WriteTreeAfterWork(uv_work_t *req) { + HandleScope scope; + WriteTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle out = GitOid::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + out + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle Index::Entrycount(const Arguments& args) { + HandleScope scope; + + size_t result = git_index_entrycount( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(size_t::constructor_template->NewInstance(1, argv)); +} + +Handle Index::Clear(const Arguments& args) { + HandleScope scope; + + void result = git_index_clear( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return Undefined(); +} + +Handle Index::Remove(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number stage is required."))); + } + + int result = git_index_remove( + + ObjectWrap::Unwrap(args.This())->GetValue() +, + stringArgToString(args[0]->ToString()).c_str() +, + (int) args[1]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + +Handle Index::RemoveDirectory(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String dir is required."))); + } + + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number stage is required."))); + } + + int result = git_index_remove_directory( + + ObjectWrap::Unwrap(args.This())->GetValue() +, + stringArgToString(args[0]->ToString()).c_str() +, + (int) args[1]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + +Handle Index::AddBypath(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddBypathBaton* baton = new AddBypathBaton; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->pathReference = Persistent::New(args[0]); + String::Utf8Value path(args[0]->ToString()); + baton->path = strdup(*path); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, AddBypathWork, (uv_after_work_cb)AddBypathAfterWork); + + return Undefined(); +} + +void Index::AddBypathWork(uv_work_t *req) { + AddBypathBaton *baton = static_cast(req->data); + int result = git_index_add_bypath( + baton->index, + baton->path + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Index::AddBypathAfterWork(uv_work_t *req) { + HandleScope scope; + AddBypathBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + + Handle result = Local::New(Undefined()); + Handle argv2[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->pathReference.Dispose(); + baton->callback.Dispose(); + delete baton->path; + delete baton; +} + +Handle Index::RemoveBypath(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + int result = git_index_remove_bypath( + + ObjectWrap::Unwrap(args.This())->GetValue() +, + stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + +Handle Index::Find(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("size_t at_pos is required."))); + } + + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + int result = git_index_find( + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + ObjectWrap::Unwrap(args.This())->GetValue() +, + stringArgToString(args[1]->ToString()).c_str() + ); + + return scope.Close(Int32::New(result)); +} + +Handle Index::ConflictRemove(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + int result = git_index_conflict_remove( + + ObjectWrap::Unwrap(args.This())->GetValue() +, + stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + +Handle Index::ConflictCleanup(const Arguments& args) { + HandleScope scope; + + void result = git_index_conflict_cleanup( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return Undefined(); +} + +Handle Index::HasConflicts(const Arguments& args) { + HandleScope scope; + + int result = git_index_has_conflicts( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return scope.Close(Int32::New(result)); +} + + +Persistent Index::constructor_template; diff --git a/src/object.cc b/src/object.cc index ae048138a..648dc22ed 100644 --- a/src/object.cc +++ b/src/object.cc @@ -36,6 +36,7 @@ void GitObject::Initialize(Handle target) { NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner); NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); @@ -80,13 +81,11 @@ Handle GitObject::Lookup(const Arguments& args) { LookupBaton* baton = new LookupBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->idReference = Persistent::New(args[1]); baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->typeReference = Persistent::New(args[2]); baton->type = (git_otype) args[2]->ToInt32()->Value(); baton->callback = Persistent::New(Local::Cast(args[3])); @@ -114,7 +113,6 @@ void GitObject::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->object) }; Handle object = GitObject::constructor_template->NewInstance(1, argv); Handle argv2[2] = { @@ -132,7 +130,9 @@ void GitObject::LookupAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->typeReference.Dispose(); baton->callback.Dispose(); delete baton; } @@ -161,6 +161,19 @@ Handle GitObject::Type(const Arguments& args) { return scope.Close(Number::New(result)); } +Handle GitObject::Owner(const Arguments& args) { + HandleScope scope; + + git_repository * result = git_object_owner( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); +} + Handle GitObject::Peel(const Arguments& args) { HandleScope scope; @@ -174,8 +187,9 @@ Handle GitObject::Peel(const Arguments& args) { PeelBaton* baton = new PeelBaton; baton->error = NULL; baton->request.data = baton; - + baton->objectReference = Persistent::New(args.This()); baton->object = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->target_typeReference = Persistent::New(args[0]); baton->target_type = (git_otype) args[0]->ToInt32()->Value(); baton->callback = Persistent::New(Local::Cast(args[1])); @@ -202,12 +216,11 @@ void GitObject::PeelAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->peeled) }; - Handle object = GitObject::constructor_template->NewInstance(1, argv); + Handle peeled = GitObject::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + peeled }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -220,7 +233,8 @@ void GitObject::PeelAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->objectReference.Dispose(); + baton->target_typeReference.Dispose(); baton->callback.Dispose(); delete baton; } diff --git a/src/reference.cc b/src/reference.cc index 1ee822471..771d1fc23 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -10,6 +10,7 @@ #include "../include/reference.h" #include "../include/repo.h" #include "../include/oid.h" +#include "../include/object.h" #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -35,10 +36,20 @@ void GitReference::Initialize(Handle target) { NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_METHOD(tpl, "oidForName", OidForName); + NODE_SET_METHOD(tpl, "createSymbolic", CreateSymbolic); + NODE_SET_METHOD(tpl, "create", Create); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "resolve", Resolve); + NODE_SET_PROTOTYPE_METHOD(tpl, "setSymbolicTarget", SetSymbolicTarget); + NODE_SET_PROTOTYPE_METHOD(tpl, "setTarget", setTarget); + NODE_SET_PROTOTYPE_METHOD(tpl, "rename", Rename); + NODE_SET_PROTOTYPE_METHOD(tpl, "delete", Delete); + NODE_SET_PROTOTYPE_METHOD(tpl, "isBranch", IsBranch); + NODE_SET_PROTOTYPE_METHOD(tpl, "isRemote", IsRemote); + NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); + NODE_SET_METHOD(tpl, "isValidName", IsValidName); constructor_template = Persistent::New(tpl->GetFunction()); @@ -79,12 +90,10 @@ Handle GitReference::Lookup(const Arguments& args) { LookupBaton* baton = new LookupBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->nameReference = Persistent::New(args[1]); String::Utf8Value name(args[1]->ToString()); - // XXX FIXME remove strdup and use std::string baton->name = strdup(*name); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -111,13 +120,11 @@ void GitReference::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle object = GitReference::constructor_template->NewInstance(1, argv); - // free((void *) baton->name); + Handle out = GitReference::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -130,9 +137,9 @@ void GitReference::LookupAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); baton->callback.Dispose(); - delete baton->name; delete baton; } @@ -153,12 +160,10 @@ Handle GitReference::OidForName(const Arguments& args) { OidForNameBaton* baton = new OidForNameBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->nameReference = Persistent::New(args[1]); String::Utf8Value name(args[1]->ToString()); - // XXX FIXME remove strdup and use std::string baton->name = strdup(*name); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -185,13 +190,11 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle object = GitOid::constructor_template->NewInstance(1, argv); - // free((void *) baton->name); + Handle out = GitOid::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -204,13 +207,95 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); baton->callback.Dispose(); - delete baton->name; delete baton; } +Handle GitReference::CreateSymbolic(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + if (args.Length() == 2 || !args[2]->IsString()) { + return ThrowException(Exception::Error(String::New("String target is required."))); + } + + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + git_reference * out; + + int result = git_reference_symbolic_create( +& + out +, + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + stringArgToString(args[1]->ToString()).c_str() +, + stringArgToString(args[2]->ToString()).c_str() +, + (int) args[3]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); +} + +Handle GitReference::Create(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + git_reference * out; + + int result = git_reference_create( +& + out +, + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + stringArgToString(args[1]->ToString()).c_str() +, + ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() +, + (int) args[3]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); +} + Handle GitReference::Oid(const Arguments& args) { HandleScope scope; @@ -256,7 +341,7 @@ Handle GitReference::Resolve(const Arguments& args) { ResolveBaton* baton = new ResolveBaton; baton->error = NULL; baton->request.data = baton; - + baton->refReference = Persistent::New(args.This()); baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); @@ -282,12 +367,132 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle out = GitReference::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + out + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->refReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitReference::SetSymbolicTarget(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String target is required."))); + } + git_reference * out; + + int result = git_reference_symbolic_set_target( +& + out +, + ObjectWrap::Unwrap(args.This())->GetValue() +, + stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); +} + +Handle GitReference::setTarget(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + git_reference * out; + + int result = git_reference_set_target( +& + out +, + ObjectWrap::Unwrap(args.This())->GetValue() +, + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); +} + +Handle GitReference::Rename(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String new_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + RenameBaton* baton = new RenameBaton; + baton->error = NULL; + baton->request.data = baton; + baton->refReference = Persistent::New(args.This()); + baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->new_nameReference = Persistent::New(args[0]); + String::Utf8Value new_name(args[0]->ToString()); + baton->new_name = strdup(*new_name); + baton->forceReference = Persistent::New(args[1]); + baton->force = (int) args[1]->ToInt32()->Value(); + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, RenameWork, (uv_after_work_cb)RenameAfterWork); + + return Undefined(); +} + +void GitReference::RenameWork(uv_work_t *req) { + RenameBaton *baton = static_cast(req->data); + int result = git_reference_rename( + &baton->out, + baton->ref, + baton->new_name, + baton->force + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitReference::RenameAfterWork(uv_work_t *req) { + HandleScope scope; + RenameBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { Handle argv[1] = { External::New(baton->out) }; - Handle object = GitReference::constructor_template->NewInstance(1, argv); + Handle out = GitReference::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -300,10 +505,141 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } + baton->refReference.Dispose(); + baton->new_nameReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + delete baton->new_name; + delete baton; +} + +Handle GitReference::Delete(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DeleteBaton* baton = new DeleteBaton; + baton->error = NULL; + baton->request.data = baton; + baton->refReference = Persistent::New(args.This()); + baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, DeleteWork, (uv_after_work_cb)DeleteAfterWork); + + return Undefined(); +} + +void GitReference::DeleteWork(uv_work_t *req) { + DeleteBaton *baton = static_cast(req->data); + int result = git_reference_delete( + baton->ref + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitReference::DeleteAfterWork(uv_work_t *req) { + HandleScope scope; + DeleteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle result = Local::New(Undefined()); + Handle argv2[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->refReference.Dispose(); baton->callback.Dispose(); delete baton; } +Handle GitReference::IsBranch(const Arguments& args) { + HandleScope scope; + + int result = git_reference_is_branch( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + +Handle GitReference::IsRemote(const Arguments& args) { + HandleScope scope; + + int result = git_reference_is_remote( + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + +Handle GitReference::Peel(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + git_object * out; + + int result = git_reference_peel( +& + out +, + ObjectWrap::Unwrap(args.This())->GetValue() +, + (git_otype) args[0]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)out) }; + return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); +} + +Handle GitReference::IsValidName(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); + } + + int result = git_reference_is_valid_name( + + stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + return scope.Close(Int32::New(result)); +} + Persistent GitReference::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index ea7285ddc..00bf15ba7 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -72,9 +72,8 @@ Handle GitRepo::Open(const Arguments& args) { OpenBaton* baton = new OpenBaton; baton->error = NULL; baton->request.data = baton; - + baton->pathReference = Persistent::New(args[0]); String::Utf8Value path(args[0]->ToString()); - // XXX FIXME remove strdup and use std::string baton->path = strdup(*path); baton->callback = Persistent::New(Local::Cast(args[1])); @@ -100,13 +99,11 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle object = GitRepo::constructor_template->NewInstance(1, argv); - // free((void *) baton->path); + Handle out = GitRepo::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -119,9 +116,8 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->pathReference.Dispose(); baton->callback.Dispose(); - delete baton->path; delete baton; } @@ -142,10 +138,10 @@ Handle GitRepo::Init(const Arguments& args) { InitBaton* baton = new InitBaton; baton->error = NULL; baton->request.data = baton; - + baton->pathReference = Persistent::New(args[0]); String::Utf8Value path(args[0]->ToString()); - // XXX FIXME remove strdup and use std::string baton->path = strdup(*path); + baton->is_bareReference = Persistent::New(args[1]); baton->is_bare = (unsigned) args[1]->ToBoolean()->Value(); baton->callback = Persistent::New(Local::Cast(args[2])); @@ -172,13 +168,11 @@ void GitRepo::InitAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle object = GitRepo::constructor_template->NewInstance(1, argv); - // free((void *) baton->path); + Handle out = GitRepo::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -191,9 +185,9 @@ void GitRepo::InitAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->pathReference.Dispose(); + baton->is_bareReference.Dispose(); baton->callback.Dispose(); - delete baton->path; delete baton; } diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 0e147636a..973586ffa 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -122,10 +122,9 @@ Handle GitTreeEntry::GetObject(const Arguments& args) { GetObjectBaton* baton = new GetObjectBaton; baton->error = NULL; baton->request.data = baton; - - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->entryReference = Persistent::New(args.This()); baton->entry = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[1])); @@ -152,12 +151,11 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->object_out) }; - Handle object = GitObject::constructor_template->NewInstance(1, argv); + Handle object_out = GitObject::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - object + object_out }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -170,7 +168,8 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { if (try_catch.HasCaught()) { node::FatalException(try_catch); } - + baton->repoReference.Dispose(); + baton->entryReference.Dispose(); baton->callback.Dispose(); delete baton; } diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 15b25f2d4..92e60e8ee 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -1,10 +1,10 @@ <% - function isPrimitive(cppClassName) { - return ["Boolean", "Number", "String", "Integer", "Int32", "Uint32"].indexOf(cppClassName) > -1; + function isV8Value(cppClassName) { + return ["Boolean", "Number", "String", "Integer", "Int32", "Uint32", "Array", "Date", "Function"].indexOf(cppClassName) > -1; } function cppClassName2v8ValueClassName(cppClassName) { - if (isPrimitive(cppClassName)) + if (isV8Value(cppClassName)) return cppClassName; else return 'Object'; @@ -129,27 +129,28 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg for (var i = 0, j = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> +<% if (!arg.isReturn) { -%> <% if (arg.isSelf) { -%> + baton-><%- arg.name %>Reference = Persistent::New(args.This()); baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); -<% } else if (arg.isReturn) { -%> - -<% } else if (arg.cppClassName == 'String') { -%> +<% } else { -%> + baton-><%- arg.name %>Reference = Persistent::New(args[<%- j %>]); +<% if (arg.cppClassName == 'String') { -%> String::Utf8Value <%- arg.name %>(args[<%- j %>]->ToString()); - // XXX FIXME remove strdup and use std::string baton-><%- arg.name %> = strdup(*<%- arg.name %>); +<% } else if (arg.cppClassName == 'Array') { -%> + baton-><%- arg.name %> = Array::Cast(*args[<%- j %>]); <% } else if (arg.cppClassName == 'Buffer') { -%> baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())); -<% } else if (isPrimitive(arg.cppClassName)) { -%> +<% } else if (isV8Value(arg.cppClassName)) { -%> baton-><%- arg.name %> = (<%- arg.cType %>) args[<%- j %>]->To<%- arg.cppClassName %>()->Value(); <% } else { -%> - // XXX FIXME potential GC issue: if the argument gets GCd, the destructor could null out this object. - // Either ref the argument or copy? baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())->GetValue(); <% } -%> -<% - if (!(arg.isReturn || arg.isSelf)) j++; - } --%> +<% } -%> +<% if (!(arg.isReturn || arg.isSelf)) j++ -%> +<% } -%> +<% } -%> baton->callback = Persistent::New(Local::Cast(args[<%- j %>])); uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); @@ -164,7 +165,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> - <% if (/\*\*/.test(arg.cType)) { %>&<% } %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> + <% if (arg.isReturn && /\*\*/.test(arg.cType)) { %>&<% } %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> <% } -%> ); <% if (functionInfo.return.isErrorCode) { -%> @@ -183,20 +184,23 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t TryCatch try_catch; if (!baton->error) { <% + var result = null; for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; + if (arg.isReturn) result = arg; + } + if (!result) result = functionInfo.return; + var resultName = result.name || 'result'; -%> -<% if (arg.cppClassName == 'String') { -%> - // free((void *) baton-><%- arg.name %>); -<% } -%> -<% if (arg.isReturn) { %> - Handle argv[1] = { External::New(baton-><%- arg.name %>) }; - Handle object = <%- arg.cppClassName %>::constructor_template->NewInstance(1, argv); -<% } -%> +<% if (result.isErrorCode) { %> + Handle <%- resultName %> = Local::New(Undefined()); +<% } else { -%> + Handle argv[1] = { External::New(baton-><%- result.name %>) }; + Handle <%- resultName %> = <%- result.cppClassName %>::constructor_template->NewInstance(1, argv); <% } -%> Handle argv2[2] = { Local::New(Null()), - object + <%- resultName %> }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); } else { @@ -209,13 +213,19 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t if (try_catch.HasCaught()) { node::FatalException(try_catch); } - +<% + for (var i = 0, j = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn) continue; +-%> + baton-><%- arg.name %>Reference.Dispose(); +<% } -%> baton->callback.Dispose(); <% for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> -<% if (arg.cppClassName == 'String') { %> +<% if (arg.cppClassName == 'String') { -%> delete baton-><%- arg.name %>; <% } -%> <% } -%> @@ -260,6 +270,8 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <%- arg.name %> <% } else if (arg.cppClassName == 'String') { -%> stringArgToString(args[<%- j %>]->ToString()).c_str() +<% } else if (isV8Value(arg.cppClassName)) { -%> + (<%- arg.cType %>) args[<%- j %>]->To<%- arg.cppClassName %>()->Value() <% } else { -%> ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())->GetValue() <% } -%> @@ -286,7 +298,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg -%> <% if (result.cType == "void") { -%> return Undefined(); -<% } else if (isPrimitive(result.cppClassName)) { -%> +<% } else if (isV8Value(result.cppClassName)) { -%> return scope.Close(<%- result.cppClassName %>::New(<%- resultName %>)); <% } else if (result.cppClassName == "External") { -%> return scope.Close(External::New((void *)<%- resultName %>)); @@ -310,7 +322,7 @@ Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Argume HandleScope scope; <%- fieldInfo.cType %> field = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; -<% if (isPrimitive(fieldInfo.cppClassName)) { -%> +<% if (isV8Value(fieldInfo.cppClassName)) { -%> return scope.Close(<%- fieldInfo.cppClassName %>::New(field)); <% } else if (fieldInfo.cppClassName == "External") { -%> return scope.Close(External::New((void *)<% if (!/\*/.test(fieldInfo.cType)) { %>&<% } %>field)); diff --git a/templates/header.h.ejs b/templates/header.h.ejs index 92c1d6db0..5431550fa 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -59,6 +59,7 @@ class <%- cppClassName %> : public ObjectWrap { <% if (arg.isReturn) { -%> <%- arg.cType.replace('**', '*') %> <%- arg.name %>; <% } else { -%> + Persistent <%- arg.name %>Reference; <%- arg.cType %> <%- arg.name %>; <% } -%> <% } -%> diff --git a/test/convenience-commit.js b/test/convenience-commit.js index 8159f04f2..011eb8408 100644 --- a/test/convenience-commit.js +++ b/test/convenience-commit.js @@ -36,8 +36,11 @@ exports.method = function(test){ exports.message = function(test) { test.expect(3); + console.log(1) git.repo.open('../.git', function(error, repository) { + console.log(2, error, repository) repository.commit(historyCountKnownSHA, function(error, commit) { + console.log(3) var message = commit.message(); test.equals(error, null, 'There should be no error'); test.notEqual(message, null, 'Message should not be null'); diff --git a/v0.18.0.json b/v0.18.0.json index 2d453aa01..4ef8b4c82 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -1472,7 +1472,6 @@ "jsClassName": "Number" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -1508,7 +1507,6 @@ "jsClassName": "Number" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -1580,7 +1578,7 @@ }, { "name": "parents", - "cType": "(const git_commit *)[]", + "cType": "const git_commit **", "cppClassName": "Array", "jsClassName": "Array" } @@ -1675,7 +1673,6 @@ "jsClassName": "Common", "cppClassName": "Common", "cType": "git_common", - "freeFunctionName": "git_common_free", "functions": [ { "cFunctionName": "git_libgit2_version", @@ -3930,7 +3927,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "open", @@ -3973,6 +3970,7 @@ "jsClassName": "Index" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -4018,6 +4016,7 @@ "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4046,6 +4045,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4068,7 +4068,7 @@ "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "read", @@ -4090,7 +4090,7 @@ "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "write", @@ -4118,7 +4118,7 @@ "jsClassName": "Tree" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "readTree", @@ -4143,12 +4143,13 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "writeTree", "cppFunctionName": "WriteTree", "return": { @@ -4180,6 +4181,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -4252,6 +4254,7 @@ "jsClassName": "size_t" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4286,6 +4289,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4382,6 +4386,7 @@ "jsClassName": "IndexEntry" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4403,6 +4408,7 @@ "jsClassName": "IndexEntry" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -4431,10 +4437,10 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "addBypath", + "jsFunctionName": "addByPath", "cppFunctionName": "AddBypath", "return": { "cType": "int", @@ -4462,7 +4468,7 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "removeBypath", + "jsFunctionName": "removeByPath", "cppFunctionName": "RemoveBypath", "return": { "cType": "int", @@ -4483,7 +4489,8 @@ "name": "index", "cType": "git_index *", "cppClassName": "Index", - "jsClassName": "Index" + "jsClassName": "Index", + "isSelf": true }, { "name": "path", @@ -4494,13 +4501,12 @@ ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "find", "cppFunctionName": "Find", "return": { "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cppClassName": "Int32" } }, { @@ -4532,6 +4538,7 @@ "jsClassName": "IndexEntry" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4577,6 +4584,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -4656,8 +4664,7 @@ "cppFunctionName": "HasConflicts", "return": { "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cppClassName": "Int32" } }, { @@ -4671,6 +4678,7 @@ "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4704,6 +4712,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -4732,6 +4741,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4760,6 +4770,7 @@ "jsClassName": "size_t" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4824,6 +4835,7 @@ "jsClassName": "Oid" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4852,6 +4864,7 @@ "jsClassName": "size_t" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4874,6 +4887,7 @@ "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -5721,7 +5735,6 @@ "isSelf": true } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8182,7 +8195,8 @@ "filename": "reference.h", "dependencies": [ "../include/repo.h", - "../include/oid.h" + "../include/oid.h", + "../include/object.h" ], "jsClassName": "Reference", "cppClassName": "GitReference", @@ -8292,7 +8306,6 @@ "jsClassName": "Number" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -8339,7 +8352,6 @@ "jsClassName": "Number" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -8516,12 +8528,11 @@ "jsClassName": "String" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "gitReferenceSymbolicSetTarget", - "cppFunctionName": "GitReferenceSymbolicSetTarget", + "jsFunctionName": "setSymbolicTarget", + "cppFunctionName": "SetSymbolicTarget", "return": { "cType": "int", "cppClassName": "Int32", @@ -8552,7 +8563,6 @@ "jsClassName": "Oid" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8594,7 +8604,6 @@ "jsClassName": "Number" } ], - "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8617,7 +8626,6 @@ "isSelf": true } ], - "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8835,7 +8843,6 @@ "isSelf": true } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8858,7 +8865,6 @@ "isSelf": true } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8877,14 +8883,14 @@ "name": "buffer_out", "cType": "char *", "cppClassName": "String", - "jsClassName": "char", + "jsClassName": "String", "isSelf": true }, { "name": "buffer_size", "cType": "size_t", - "cppClassName": "size_t", - "jsClassName": "size_t" + "cppClassName": "Integer", + "jsClassName": "Number" }, { "name": "name", @@ -8931,11 +8937,10 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", - "jsClassName": "Otype" + "cppClassName": "Int32", + "jsClassName": "Number" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8957,7 +8962,6 @@ "jsClassName": "String" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -9218,7 +9222,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "create", From 2d3b9b6e5851e2a0db17cf20493830413d536dc1 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 24 Jun 2013 17:57:42 +0200 Subject: [PATCH 07/28] Tag now code-gen'd --- binding.gyp | 2 + gen.js | 2 +- include/index.h | 11 +- include/odb.h | 58 ---- include/tag.h | 139 +++++--- src/base.cc | 4 + src/blob.cc | 28 +- src/commit.cc | 59 +++- src/index.cc | 185 ++++++----- src/object.cc | 20 +- src/oid.cc | 9 +- src/reference.cc | 74 +++-- src/repo.cc | 16 +- src/signature.cc | 6 +- src/tag.cc | 522 ++++++++++++++++++++++++++++++ src/tree_entry.cc | 20 +- templates/class.cc.ejs | 36 +-- v0.18.0.json | 710 +++++++++++++++++------------------------ 18 files changed, 1190 insertions(+), 711 deletions(-) delete mode 100755 include/odb.h create mode 100644 src/tag.cc diff --git a/binding.gyp b/binding.gyp index 3ccff0ec7..d46bb9327 100644 --- a/binding.gyp +++ b/binding.gyp @@ -11,6 +11,8 @@ 'src/reference.cc', 'src/object.cc', 'src/repo.cc', + 'src/index.cc', + 'src/tag.cc', 'src/revwalk.cc', 'src/signature.cc', 'src/time.cc', diff --git a/gen.js b/gen.js index 0aace8700..6c2c4f6d7 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/index.h b/include/index.h index 8704e79f8..0b1a5a99a 100755 --- a/include/index.h +++ b/include/index.h @@ -2,8 +2,8 @@ * This code is auto-generated; unless you know what you're doing, do not modify! **/ -#ifndef INDEX_H -#define INDEX_H +#ifndef GITINDEX_H +#define GITINDEX_H #include #include @@ -14,7 +14,7 @@ using namespace node; using namespace v8; -class Index : public ObjectWrap { +class GitIndex : public ObjectWrap { public: static Persistent constructor_template; @@ -23,8 +23,8 @@ class Index : public ObjectWrap { git_index *GetValue(); private: - Index(git_index *raw); - ~Index(); + GitIndex(git_index *raw); + ~GitIndex(); static Handle New(const Arguments& args); @@ -41,7 +41,6 @@ class Index : public ObjectWrap { const char * index_path; Persistent callback; }; - static Handle New(const Arguments& args); static Handle Owner(const Arguments& args); static Handle Read(const Arguments& args); static void ReadWork(uv_work_t* req); diff --git a/include/odb.h b/include/odb.h deleted file mode 100755 index 19c07e900..000000000 --- a/include/odb.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#ifndef ODB_H -#define ODB_H - -#include - -#include "git2.h" - -using namespace node; - -/** - * Class: GitOdb - * Wrapper for libgit2 git_error. - */ -class GitOdb : public ObjectWrap { - public: - /** - * Variable: constructor_template - * Used to create Node.js constructor. - */ - static v8::Persistent constructor_template; - /** - * Function: Initialize - * Used to intialize the EventEmitter from Node.js - * - * Parameters: - * target - v8::Object the Node.js global module object - */ - static void Initialize(v8::Handle target); - - protected: - /** - * Constructor: GitOdb - */ - GitOdb() {}; - /** - * Deconstructor: GitOdb - */ - ~GitOdb() {}; - /** - * Function: New - * - * Parameters: - * args v8::Arguments function call - * - * Returns: - * v8::Object args.This() - */ - static v8::Handle New(const v8::Arguments& args); -}; - -#endif diff --git a/include/tag.h b/include/tag.h index f75b28f90..2e56151ef 100755 --- a/include/tag.h +++ b/include/tag.h @@ -1,58 +1,109 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef TAG_H -#define TAG_H +#ifndef GITTAG_H +#define GITTAG_H +#include #include +#include #include "git2.h" using namespace node; +using namespace v8; -/** - * Class: GitTag - * Wrapper for libgit2 git_error. - */ class GitTag : public ObjectWrap { public: - /** - * Variable: constructor_template - * Used to create Node.js constructor. - */ - static v8::Persistent constructor_template; - /** - * Function: Initialize - * Used to intialize the EventEmitter from Node.js - * - * Parameters: - * target - v8::Object the Node.js global module object - */ - static void Initialize(v8::Handle target); - - protected: - /** - * Constructor: GitTag - */ - GitTag() {}; - /** - * Deconstructor: GitTag - */ - ~GitTag() {}; - /** - * Function: New - * - * Parameters: - * args v8::Arguments function call - * - * Returns: - * v8::Object args.This() - */ - static v8::Handle New(const v8::Arguments& args); + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_tag *GetValue(); + + private: + GitTag(git_tag *raw); + ~GitTag(); + + static Handle New(const Arguments& args); + + + static Handle Lookup(const Arguments& args); + static void LookupWork(uv_work_t* req); + static void LookupAfterWork(uv_work_t* req); + + struct LookupBaton { + uv_work_t request; + const git_error* error; + git_tag * out; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle Oid(const Arguments& args); + static Handle Target(const Arguments& args); + static void TargetWork(uv_work_t* req); + static void TargetAfterWork(uv_work_t* req); + + struct TargetBaton { + uv_work_t request; + const git_error* error; + git_object * target_out; + Persistent tagReference; + const git_tag * tag; + Persistent callback; + }; + static Handle TargetId(const Arguments& args); + static Handle TargetType(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Tagger(const Arguments& args); + static Handle Message(const Arguments& args); + static Handle Create(const Arguments& args); + static void CreateWork(uv_work_t* req); + static void CreateAfterWork(uv_work_t* req); + + struct CreateBaton { + uv_work_t request; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent targetReference; + const git_object * target; + Persistent taggerReference; + const git_signature * tagger; + Persistent messageReference; + const char * message; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle CreateLightweight(const Arguments& args); + static void CreateLightweightWork(uv_work_t* req); + static void CreateLightweightAfterWork(uv_work_t* req); + + struct CreateLightweightBaton { + uv_work_t request; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent targetReference; + const git_object * target; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle Delete(const Arguments& args); + static Handle Peel(const Arguments& args); + git_tag *raw; }; #endif diff --git a/src/base.cc b/src/base.cc index 504d64a1f..7fa7da0cb 100755 --- a/src/base.cc +++ b/src/base.cc @@ -25,6 +25,8 @@ #include "../include/tree_entry.h" #include "../include/diff_list.h" #include "../include/threads.h" +#include "../include/index.h" +#include "../include/tag.h" extern "C" void init(Handle target) { HandleScope scope; @@ -34,6 +36,8 @@ extern "C" void init(Handle target) { GitError::Initialize(target); GitReference::Initialize(target); + GitIndex::Initialize(target); + GitTag::Initialize(target); GitSignature::Initialize(target); GitTime::Initialize(target); GitBlob::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index 500fc7361..17a290611 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -95,12 +95,12 @@ Handle GitBlob::Lookup(const Arguments& args) { void GitBlob::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int result = git_blob_lookup( + int blob = git_blob_lookup( &baton->blob, baton->repo, baton->id ); - if (result != GIT_OK) { + if (blob != GIT_OK) { baton->error = giterr_last(); } } @@ -137,11 +137,13 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; - const git_oid * result = git_blob_id( +const git_oid * result = git_blob_id( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -150,11 +152,13 @@ Handle GitBlob::Oid(const Arguments& args) { Handle GitBlob::Content(const Arguments& args) { HandleScope scope; - const void * result = git_blob_rawcontent( +const void * result = git_blob_rawcontent( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); @@ -163,11 +167,13 @@ Handle GitBlob::Content(const Arguments& args) { Handle GitBlob::Size(const Arguments& args) { HandleScope scope; - git_off_t result = git_blob_rawsize( +git_off_t result = git_blob_rawsize( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Number::New(result)); } @@ -201,12 +207,12 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { void GitBlob::CreateFromFileWork(uv_work_t *req) { CreateFromFileBaton *baton = static_cast(req->data); - int result = git_blob_create_fromdisk( + int id = git_blob_create_fromdisk( baton->id, baton->repo, baton->path ); - if (result != GIT_OK) { + if (id != GIT_OK) { baton->error = giterr_last(); } } @@ -275,13 +281,13 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { void GitBlob::CreateFromBufferWork(uv_work_t *req) { CreateFromBufferBaton *baton = static_cast(req->data); - int result = git_blob_create_frombuffer( + int oid = git_blob_create_frombuffer( baton->oid, baton->repo, baton->buffer, baton->len ); - if (result != GIT_OK) { + if (oid != GIT_OK) { baton->error = giterr_last(); } } @@ -319,7 +325,8 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; - int result = git_blob_is_binary( +int result = git_blob_is_binary( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -327,6 +334,7 @@ Handle GitBlob::IsBinary(const Arguments& args) { if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Boolean::New(result)); } diff --git a/src/commit.cc b/src/commit.cc index 116a690b2..4445fddc4 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -102,12 +102,12 @@ Handle GitCommit::Lookup(const Arguments& args) { void GitCommit::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int result = git_commit_lookup( + int commit = git_commit_lookup( &baton->commit, baton->repo, baton->id ); - if (result != GIT_OK) { + if (commit != GIT_OK) { baton->error = giterr_last(); } } @@ -144,11 +144,13 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; - const git_oid * result = git_commit_id( +const git_oid * result = git_commit_id( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -157,55 +159,65 @@ Handle GitCommit::Oid(const Arguments& args) { Handle GitCommit::MessageEncoding(const Arguments& args) { HandleScope scope; - const char * result = git_commit_message_encoding( +const char * result = git_commit_message_encoding( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } Handle GitCommit::Message(const Arguments& args) { HandleScope scope; - const char * result = git_commit_message( +const char * result = git_commit_message( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } Handle GitCommit::Time(const Arguments& args) { HandleScope scope; - git_time_t result = git_commit_time( +git_time_t result = git_commit_time( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Number::New(result)); } Handle GitCommit::Offset(const Arguments& args) { HandleScope scope; - int result = git_commit_time_offset( +int result = git_commit_time_offset( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Integer::New(result)); } Handle GitCommit::Committer(const Arguments& args) { HandleScope scope; - const git_signature * result = git_commit_committer( +const git_signature * result = git_commit_committer( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); @@ -214,11 +226,13 @@ Handle GitCommit::Committer(const Arguments& args) { Handle GitCommit::Author(const Arguments& args) { HandleScope scope; - const git_signature * result = git_commit_author( +const git_signature * result = git_commit_author( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); @@ -245,11 +259,11 @@ Handle GitCommit::Tree(const Arguments& args) { void GitCommit::TreeWork(uv_work_t *req) { TreeBaton *baton = static_cast(req->data); - int result = git_commit_tree( + int tree_out = git_commit_tree( &baton->tree_out, baton->commit ); - if (result != GIT_OK) { + if (tree_out != GIT_OK) { baton->error = giterr_last(); } } @@ -285,11 +299,13 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; - const git_oid * result = git_commit_tree_id( +const git_oid * result = git_commit_tree_id( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -298,11 +314,13 @@ Handle GitCommit::TreeId(const Arguments& args) { Handle GitCommit::ParentCount(const Arguments& args) { HandleScope scope; - unsigned int result = git_commit_parentcount( +unsigned int result = git_commit_parentcount( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Uint32::New(result)); } @@ -332,12 +350,12 @@ Handle GitCommit::Parent(const Arguments& args) { void GitCommit::ParentWork(uv_work_t *req) { ParentBaton *baton = static_cast(req->data); - int result = git_commit_parent( + int out = git_commit_parent( &baton->out, baton->commit, baton->n ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -378,13 +396,16 @@ Handle GitCommit::ParentId(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number n is required."))); } - const git_oid * result = git_commit_parent_id( +const git_oid * result = git_commit_parent_id( + ObjectWrap::Unwrap(args.This())->GetValue() , + (unsigned int) args[0]->ToUint32()->Value() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -398,18 +419,22 @@ Handle GitCommit::NthGenAncestor(const Arguments& args) { } git_commit * ancestor; - int result = git_commit_nth_gen_ancestor( +int result = git_commit_nth_gen_ancestor( + & ancestor , + ObjectWrap::Unwrap(args.This())->GetValue() , + (unsigned int) args[0]->ToUint32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)ancestor) }; return scope.Close(GitCommit::constructor_template->NewInstance(1, argv)); diff --git a/src/index.cc b/src/index.cc index dd9f925d8..051e070d0 100644 --- a/src/index.cc +++ b/src/index.cc @@ -8,6 +8,9 @@ #include "git2.h" #include "../include/index.h" +#include "../include/oid.h" +#include "../include/repo.h" +#include "../include/tree.h" #include "../include/functions/utilities.h" #include "../include/functions/string.h" @@ -15,15 +18,15 @@ using namespace v8; using namespace node; -Index::Index(git_index *raw) { +GitIndex::GitIndex(git_index *raw) { this->raw = raw; } -Index::~Index() { +GitIndex::~GitIndex() { git_index_free(this->raw); } -void Index::Initialize(Handle target) { +void GitIndex::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -32,7 +35,6 @@ void Index::Initialize(Handle target) { tpl->SetClassName(String::NewSymbol("Index")); NODE_SET_METHOD(tpl, "open", Open); - NODE_SET_METHOD(tpl, "new", New); NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner); NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); @@ -54,25 +56,25 @@ void Index::Initialize(Handle target) { target->Set(String::NewSymbol("Index"), constructor_template); } -Handle Index::New(const Arguments& args) { +Handle GitIndex::New(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { return ThrowException(Exception::Error(String::New("git_index is required."))); } - Index* object = new Index((git_index *) External::Unwrap(args[0])); + GitIndex* object = new GitIndex((git_index *) External::Unwrap(args[0])); object->Wrap(args.This()); return scope.Close(args.This()); } -git_index *Index::GetValue() { +git_index *GitIndex::GetValue() { return this->raw; } -Handle Index::Open(const Arguments& args) { +Handle GitIndex::Open(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -95,25 +97,25 @@ Handle Index::Open(const Arguments& args) { return Undefined(); } -void Index::OpenWork(uv_work_t *req) { +void GitIndex::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); - int result = git_index_open( + int out = git_index_open( &baton->out, baton->index_path ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } -void Index::OpenAfterWork(uv_work_t *req) { +void GitIndex::OpenAfterWork(uv_work_t *req) { HandleScope scope; OpenBaton *baton = static_cast(req->data); TryCatch try_catch; if (!baton->error) { Handle argv[1] = { External::New(baton->out) }; - Handle out = Index::constructor_template->NewInstance(1, argv); + Handle out = GitIndex::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), out @@ -135,37 +137,22 @@ void Index::OpenAfterWork(uv_work_t *req) { delete baton; } -Handle Index::New(const Arguments& args) { +Handle GitIndex::Owner(const Arguments& args) { HandleScope scope; - git_index * out; - int result = git_index_new( -& - out - ); +git_repository * result = git_index_owner( - if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); - } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(Index::constructor_template->NewInstance(1, argv)); -} - -Handle Index::Owner(const Arguments& args) { - HandleScope scope; - git_repository * result = git_index_owner( - - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); } -Handle Index::Read(const Arguments& args) { +Handle GitIndex::Read(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { @@ -176,7 +163,7 @@ Handle Index::Read(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); @@ -184,7 +171,7 @@ Handle Index::Read(const Arguments& args) { return Undefined(); } -void Index::ReadWork(uv_work_t *req) { +void GitIndex::ReadWork(uv_work_t *req) { ReadBaton *baton = static_cast(req->data); int result = git_index_read( baton->index @@ -194,7 +181,7 @@ void Index::ReadWork(uv_work_t *req) { } } -void Index::ReadAfterWork(uv_work_t *req) { +void GitIndex::ReadAfterWork(uv_work_t *req) { HandleScope scope; ReadBaton *baton = static_cast(req->data); @@ -222,7 +209,7 @@ void Index::ReadAfterWork(uv_work_t *req) { delete baton; } -Handle Index::Write(const Arguments& args) { +Handle GitIndex::Write(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { @@ -233,7 +220,7 @@ Handle Index::Write(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); @@ -241,7 +228,7 @@ Handle Index::Write(const Arguments& args) { return Undefined(); } -void Index::WriteWork(uv_work_t *req) { +void GitIndex::WriteWork(uv_work_t *req) { WriteBaton *baton = static_cast(req->data); int result = git_index_write( baton->index @@ -251,7 +238,7 @@ void Index::WriteWork(uv_work_t *req) { } } -void Index::WriteAfterWork(uv_work_t *req) { +void GitIndex::WriteAfterWork(uv_work_t *req) { HandleScope scope; WriteBaton *baton = static_cast(req->data); @@ -279,7 +266,7 @@ void Index::WriteAfterWork(uv_work_t *req) { delete baton; } -Handle Index::ReadTree(const Arguments& args) { +Handle GitIndex::ReadTree(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -293,7 +280,7 @@ Handle Index::ReadTree(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->treeReference = Persistent::New(args[0]); baton->tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[1])); @@ -303,7 +290,7 @@ Handle Index::ReadTree(const Arguments& args) { return Undefined(); } -void Index::ReadTreeWork(uv_work_t *req) { +void GitIndex::ReadTreeWork(uv_work_t *req) { ReadTreeBaton *baton = static_cast(req->data); int result = git_index_read_tree( baton->index, @@ -314,7 +301,7 @@ void Index::ReadTreeWork(uv_work_t *req) { } } -void Index::ReadTreeAfterWork(uv_work_t *req) { +void GitIndex::ReadTreeAfterWork(uv_work_t *req) { HandleScope scope; ReadTreeBaton *baton = static_cast(req->data); @@ -343,7 +330,7 @@ void Index::ReadTreeAfterWork(uv_work_t *req) { delete baton; } -Handle Index::WriteTree(const Arguments& args) { +Handle GitIndex::WriteTree(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { @@ -354,7 +341,7 @@ Handle Index::WriteTree(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, WriteTreeWork, (uv_after_work_cb)WriteTreeAfterWork); @@ -362,18 +349,18 @@ Handle Index::WriteTree(const Arguments& args) { return Undefined(); } -void Index::WriteTreeWork(uv_work_t *req) { +void GitIndex::WriteTreeWork(uv_work_t *req) { WriteTreeBaton *baton = static_cast(req->data); - int result = git_index_write_tree( + int out = git_index_write_tree( baton->out, baton->index ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } -void Index::WriteTreeAfterWork(uv_work_t *req) { +void GitIndex::WriteTreeAfterWork(uv_work_t *req) { HandleScope scope; WriteTreeBaton *baton = static_cast(req->data); @@ -401,31 +388,33 @@ void Index::WriteTreeAfterWork(uv_work_t *req) { delete baton; } -Handle Index::Entrycount(const Arguments& args) { +Handle GitIndex::Entrycount(const Arguments& args) { HandleScope scope; - size_t result = git_index_entrycount( +size_t result = git_index_entrycount( + - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(size_t::constructor_template->NewInstance(1, argv)); + + return scope.Close(Uint32::New(result)); } -Handle Index::Clear(const Arguments& args) { +Handle GitIndex::Clear(const Arguments& args) { HandleScope scope; - void result = git_index_clear( +git_index_clear( - ObjectWrap::Unwrap(args.This())->GetValue() + + ObjectWrap::Unwrap(args.This())->GetValue() ); + return Undefined(); } -Handle Index::Remove(const Arguments& args) { +Handle GitIndex::Remove(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -436,22 +425,26 @@ Handle Index::Remove(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } - int result = git_index_remove( +int result = git_index_remove( + - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , + stringArgToString(args[0]->ToString()).c_str() , + (int) args[1]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } -Handle Index::RemoveDirectory(const Arguments& args) { +Handle GitIndex::RemoveDirectory(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -462,22 +455,26 @@ Handle Index::RemoveDirectory(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } - int result = git_index_remove_directory( +int result = git_index_remove_directory( + - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , + stringArgToString(args[0]->ToString()).c_str() , + (int) args[1]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } -Handle Index::AddBypath(const Arguments& args) { +Handle GitIndex::AddBypath(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -491,7 +488,7 @@ Handle Index::AddBypath(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->pathReference = Persistent::New(args[0]); String::Utf8Value path(args[0]->ToString()); baton->path = strdup(*path); @@ -502,7 +499,7 @@ Handle Index::AddBypath(const Arguments& args) { return Undefined(); } -void Index::AddBypathWork(uv_work_t *req) { +void GitIndex::AddBypathWork(uv_work_t *req) { AddBypathBaton *baton = static_cast(req->data); int result = git_index_add_bypath( baton->index, @@ -513,7 +510,7 @@ void Index::AddBypathWork(uv_work_t *req) { } } -void Index::AddBypathAfterWork(uv_work_t *req) { +void GitIndex::AddBypathAfterWork(uv_work_t *req) { HandleScope scope; AddBypathBaton *baton = static_cast(req->data); @@ -543,30 +540,33 @@ void Index::AddBypathAfterWork(uv_work_t *req) { delete baton; } -Handle Index::RemoveBypath(const Arguments& args) { +Handle GitIndex::RemoveBypath(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } - int result = git_index_remove_bypath( +int result = git_index_remove_bypath( - ObjectWrap::Unwrap(args.This())->GetValue() + + ObjectWrap::Unwrap(args.This())->GetValue() , + stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } -Handle Index::Find(const Arguments& args) { +Handle GitIndex::Find(const Arguments& args) { HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("size_t at_pos is required."))); } @@ -574,59 +574,70 @@ Handle Index::Find(const Arguments& args) { return ThrowException(Exception::Error(String::New("String path is required."))); } - int result = git_index_find( +int result = git_index_find( + - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + (size_t *) args[0]->ToUint32()->Value() , - ObjectWrap::Unwrap(args.This())->GetValue() + + ObjectWrap::Unwrap(args.This())->GetValue() , + stringArgToString(args[1]->ToString()).c_str() ); + return scope.Close(Int32::New(result)); } -Handle Index::ConflictRemove(const Arguments& args) { +Handle GitIndex::ConflictRemove(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } - int result = git_index_conflict_remove( +int result = git_index_conflict_remove( - ObjectWrap::Unwrap(args.This())->GetValue() + + ObjectWrap::Unwrap(args.This())->GetValue() , + stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } -Handle Index::ConflictCleanup(const Arguments& args) { +Handle GitIndex::ConflictCleanup(const Arguments& args) { HandleScope scope; - void result = git_index_conflict_cleanup( +git_index_conflict_cleanup( + - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); + return Undefined(); } -Handle Index::HasConflicts(const Arguments& args) { +Handle GitIndex::HasConflicts(const Arguments& args) { HandleScope scope; - int result = git_index_has_conflicts( +int result = git_index_has_conflicts( - ObjectWrap::Unwrap(args.This())->GetValue() + + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Int32::New(result)); } -Persistent Index::constructor_template; +Persistent GitIndex::constructor_template; diff --git a/src/object.cc b/src/object.cc index 648dc22ed..48589948a 100644 --- a/src/object.cc +++ b/src/object.cc @@ -96,13 +96,13 @@ Handle GitObject::Lookup(const Arguments& args) { void GitObject::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int result = git_object_lookup( + int object = git_object_lookup( &baton->object, baton->repo, baton->id, baton->type ); - if (result != GIT_OK) { + if (object != GIT_OK) { baton->error = giterr_last(); } } @@ -140,11 +140,13 @@ void GitObject::LookupAfterWork(uv_work_t *req) { Handle GitObject::Oid(const Arguments& args) { HandleScope scope; - const git_oid * result = git_object_id( +const git_oid * result = git_object_id( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -153,22 +155,26 @@ Handle GitObject::Oid(const Arguments& args) { Handle GitObject::Type(const Arguments& args) { HandleScope scope; - git_otype result = git_object_type( +git_otype result = git_object_type( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Number::New(result)); } Handle GitObject::Owner(const Arguments& args) { HandleScope scope; - git_repository * result = git_object_owner( +git_repository * result = git_object_owner( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); @@ -200,12 +206,12 @@ Handle GitObject::Peel(const Arguments& args) { void GitObject::PeelWork(uv_work_t *req) { PeelBaton *baton = static_cast(req->data); - int result = git_object_peel( + int peeled = git_object_peel( &baton->peeled, baton->object, baton->target_type ); - if (result != GIT_OK) { + if (peeled != GIT_OK) { baton->error = giterr_last(); } } diff --git a/src/oid.cc b/src/oid.cc index 15d5d4480..f8f1acd0d 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -65,16 +65,19 @@ Handle GitOid::FromString(const Arguments& args) { git_oid * out; out = (git_oid *)malloc(sizeof(git_oid)); - int result = git_oid_fromstr( +int result = git_oid_fromstr( + out , + stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -83,11 +86,13 @@ Handle GitOid::FromString(const Arguments& args) { Handle GitOid::Sha(const Arguments& args) { HandleScope scope; - char * result = git_oid_allocfmt( +char * result = git_oid_allocfmt( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } diff --git a/src/reference.cc b/src/reference.cc index 771d1fc23..67199c1f8 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -104,12 +104,12 @@ Handle GitReference::Lookup(const Arguments& args) { void GitReference::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int result = git_reference_lookup( + int out = git_reference_lookup( &baton->out, baton->repo, baton->name ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -174,12 +174,12 @@ Handle GitReference::OidForName(const Arguments& args) { void GitReference::OidForNameWork(uv_work_t *req) { OidForNameBaton *baton = static_cast(req->data); - int result = git_reference_name_to_id( + int out = git_reference_name_to_id( baton->out, baton->repo, baton->name ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -234,22 +234,28 @@ Handle GitReference::CreateSymbolic(const Arguments& args) { } git_reference * out; - int result = git_reference_symbolic_create( +int result = git_reference_symbolic_create( + & out , + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() , + stringArgToString(args[1]->ToString()).c_str() , + stringArgToString(args[2]->ToString()).c_str() , + (int) args[3]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); @@ -275,22 +281,28 @@ Handle GitReference::Create(const Arguments& args) { } git_reference * out; - int result = git_reference_create( +int result = git_reference_create( + & out , + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() , + stringArgToString(args[1]->ToString()).c_str() , + ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() , + (int) args[3]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); @@ -299,11 +311,13 @@ Handle GitReference::Create(const Arguments& args) { Handle GitReference::Oid(const Arguments& args) { HandleScope scope; - const git_oid * result = git_reference_target( +const git_oid * result = git_reference_target( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -312,22 +326,26 @@ Handle GitReference::Oid(const Arguments& args) { Handle GitReference::Name(const Arguments& args) { HandleScope scope; - const char * result = git_reference_symbolic_target( +const char * result = git_reference_symbolic_target( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } Handle GitReference::Type(const Arguments& args) { HandleScope scope; - git_ref_t result = git_reference_type( +git_ref_t result = git_reference_type( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Number::New(result)); } @@ -352,11 +370,11 @@ Handle GitReference::Resolve(const Arguments& args) { void GitReference::ResolveWork(uv_work_t *req) { ResolveBaton *baton = static_cast(req->data); - int result = git_reference_resolve( + int out = git_reference_resolve( &baton->out, baton->ref ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -397,18 +415,22 @@ Handle GitReference::SetSymbolicTarget(const Arguments& args) { } git_reference * out; - int result = git_reference_symbolic_set_target( +int result = git_reference_symbolic_set_target( + & out , + ObjectWrap::Unwrap(args.This())->GetValue() , + stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); @@ -422,18 +444,22 @@ Handle GitReference::setTarget(const Arguments& args) { } git_reference * out; - int result = git_reference_set_target( +int result = git_reference_set_target( + & out , + ObjectWrap::Unwrap(args.This())->GetValue() , + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); @@ -471,13 +497,13 @@ Handle GitReference::Rename(const Arguments& args) { void GitReference::RenameWork(uv_work_t *req) { RenameBaton *baton = static_cast(req->data); - int result = git_reference_rename( + int out = git_reference_rename( &baton->out, baton->ref, baton->new_name, baton->force ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -573,7 +599,8 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { Handle GitReference::IsBranch(const Arguments& args) { HandleScope scope; - int result = git_reference_is_branch( +int result = git_reference_is_branch( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -581,13 +608,15 @@ Handle GitReference::IsBranch(const Arguments& args) { if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } Handle GitReference::IsRemote(const Arguments& args) { HandleScope scope; - int result = git_reference_is_remote( +int result = git_reference_is_remote( + ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -595,6 +624,7 @@ Handle GitReference::IsRemote(const Arguments& args) { if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } @@ -606,18 +636,22 @@ Handle GitReference::Peel(const Arguments& args) { } git_object * out; - int result = git_reference_peel( +int result = git_reference_peel( + & out , + ObjectWrap::Unwrap(args.This())->GetValue() , + (git_otype) args[0]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); @@ -630,7 +664,8 @@ Handle GitReference::IsValidName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String refname is required."))); } - int result = git_reference_is_valid_name( +int result = git_reference_is_valid_name( + stringArgToString(args[0]->ToString()).c_str() ); @@ -638,6 +673,7 @@ Handle GitReference::IsValidName(const Arguments& args) { if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + return scope.Close(Int32::New(result)); } diff --git a/src/repo.cc b/src/repo.cc index 00bf15ba7..398aa2b16 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -84,11 +84,11 @@ Handle GitRepo::Open(const Arguments& args) { void GitRepo::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); - int result = git_repository_open( + int out = git_repository_open( &baton->out, baton->path ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -152,12 +152,12 @@ Handle GitRepo::Init(const Arguments& args) { void GitRepo::InitWork(uv_work_t *req) { InitBaton *baton = static_cast(req->data); - int result = git_repository_init( + int out = git_repository_init( &baton->out, baton->path, baton->is_bare ); - if (result != GIT_OK) { + if (out != GIT_OK) { baton->error = giterr_last(); } } @@ -195,22 +195,26 @@ void GitRepo::InitAfterWork(uv_work_t *req) { Handle GitRepo::Path(const Arguments& args) { HandleScope scope; - const char * result = git_repository_path( +const char * result = git_repository_path( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } Handle GitRepo::Workdir(const Arguments& args) { HandleScope scope; - const char * result = git_repository_workdir( +const char * result = git_repository_workdir( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } diff --git a/src/signature.cc b/src/signature.cc index 38f0d9bf0..76344686f 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -71,18 +71,22 @@ Handle GitSignature::Now(const Arguments& args) { } git_signature * out; - int result = git_signature_now( +int result = git_signature_now( + & out , + stringArgToString(args[0]->ToString()).c_str() , + stringArgToString(args[1]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } + // XXX need to copy object? Handle argv[1] = { External::New((void *)out) }; return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); diff --git a/src/tag.cc b/src/tag.cc new file mode 100644 index 000000000..8b195734f --- /dev/null +++ b/src/tag.cc @@ -0,0 +1,522 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/tag.h" +#include "../include/oid.h" +#include "../include/repo.h" +#include "../include/object.h" +#include "../include/signature.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitTag::GitTag(git_tag *raw) { + this->raw = raw; +} + +GitTag::~GitTag() { + git_tag_free(this->raw); +} + +void GitTag::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Tag")); + + NODE_SET_METHOD(tpl, "lookup", Lookup); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "target", Target); + NODE_SET_PROTOTYPE_METHOD(tpl, "targetId", TargetId); + NODE_SET_PROTOTYPE_METHOD(tpl, "targetType", TargetType); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "tagger", Tagger); + NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); + NODE_SET_METHOD(tpl, "create", Create); + NODE_SET_METHOD(tpl, "createLightweight", CreateLightweight); + NODE_SET_METHOD(tpl, "delete", Delete); + NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Tag"), constructor_template); +} + +Handle GitTag::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_tag is required."))); + } + + GitTag* object = new GitTag((git_tag *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +git_tag *GitTag::GetValue() { + return this->raw; +} + + +Handle GitTag::Lookup(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + LookupBaton* baton = new LookupBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->idReference = Persistent::New(args[1]); + baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); + + return Undefined(); +} + +void GitTag::LookupWork(uv_work_t *req) { + LookupBaton *baton = static_cast(req->data); + int out = git_tag_lookup( + &baton->out, + baton->repo, + baton->id + ); + if (out != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTag::LookupAfterWork(uv_work_t *req) { + HandleScope scope; + LookupBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle out = GitTag::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + out + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitTag::Oid(const Arguments& args) { + HandleScope scope; + +const git_oid * result = git_tag_id( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} + +Handle GitTag::Target(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TargetBaton* baton = new TargetBaton; + baton->error = NULL; + baton->request.data = baton; + baton->tagReference = Persistent::New(args.This()); + baton->tag = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, TargetWork, (uv_after_work_cb)TargetAfterWork); + + return Undefined(); +} + +void GitTag::TargetWork(uv_work_t *req) { + TargetBaton *baton = static_cast(req->data); + int target_out = git_tag_target( + &baton->target_out, + baton->tag + ); + if (target_out != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTag::TargetAfterWork(uv_work_t *req) { + HandleScope scope; + TargetBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->target_out) }; + Handle target_out = GitObject::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + target_out + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->tagReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitTag::TargetId(const Arguments& args) { + HandleScope scope; + +const git_oid * result = git_tag_target_id( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} + +Handle GitTag::TargetType(const Arguments& args) { + HandleScope scope; + +git_otype result = git_tag_target_type( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return scope.Close(Int32::New(result)); +} + +Handle GitTag::Name(const Arguments& args) { + HandleScope scope; + +const char * result = git_tag_name( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return scope.Close(String::New(result)); +} + +Handle GitTag::Tagger(const Arguments& args) { + HandleScope scope; + +const git_signature * result = git_tag_tagger( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); +} + +Handle GitTag::Message(const Arguments& args) { + HandleScope scope; + +const char * result = git_tag_message( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return scope.Close(String::New(result)); +} + +Handle GitTag::Create(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Object target is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature tagger is required."))); + } + if (args.Length() == 4 || !args[4]->IsString()) { + return ThrowException(Exception::Error(String::New("String message is required."))); + } + if (args.Length() == 5 || !args[5]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + if (args.Length() == 6 || !args[6]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateBaton* baton = new CreateBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->tag_nameReference = Persistent::New(args[1]); + String::Utf8Value tag_name(args[1]->ToString()); + baton->tag_name = strdup(*tag_name); + baton->targetReference = Persistent::New(args[2]); + baton->target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->taggerReference = Persistent::New(args[3]); + baton->tagger = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->messageReference = Persistent::New(args[4]); + String::Utf8Value message(args[4]->ToString()); + baton->message = strdup(*message); + baton->forceReference = Persistent::New(args[5]); + baton->force = (int) args[5]->ToInt32()->Value(); + baton->callback = Persistent::New(Local::Cast(args[6])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateWork, (uv_after_work_cb)CreateAfterWork); + + return Undefined(); +} + +void GitTag::CreateWork(uv_work_t *req) { + CreateBaton *baton = static_cast(req->data); + int oid = git_tag_create( + baton->oid, + baton->repo, + baton->tag_name, + baton->target, + baton->tagger, + baton->message, + baton->force + ); + if (oid != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTag::CreateAfterWork(uv_work_t *req) { + HandleScope scope; + CreateBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->oid) }; + Handle oid = GitOid::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + oid + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->targetReference.Dispose(); + baton->taggerReference.Dispose(); + baton->messageReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + delete baton->tag_name; + delete baton->message; + delete baton; +} + +Handle GitTag::CreateLightweight(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Object target is required."))); + } + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateLightweightBaton* baton = new CreateLightweightBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->tag_nameReference = Persistent::New(args[1]); + String::Utf8Value tag_name(args[1]->ToString()); + baton->tag_name = strdup(*tag_name); + baton->targetReference = Persistent::New(args[2]); + baton->target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->forceReference = Persistent::New(args[3]); + baton->force = (int) args[3]->ToInt32()->Value(); + baton->callback = Persistent::New(Local::Cast(args[4])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateLightweightWork, (uv_after_work_cb)CreateLightweightAfterWork); + + return Undefined(); +} + +void GitTag::CreateLightweightWork(uv_work_t *req) { + CreateLightweightBaton *baton = static_cast(req->data); + int oid = git_tag_create_lightweight( + baton->oid, + baton->repo, + baton->tag_name, + baton->target, + baton->force + ); + if (oid != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTag::CreateLightweightAfterWork(uv_work_t *req) { + HandleScope scope; + CreateLightweightBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->oid) }; + Handle oid = GitOid::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + oid + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->targetReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + delete baton->tag_name; + delete baton; +} + +Handle GitTag::Delete(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + +int result = git_tag_delete( + + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + + stringArgToString(args[1]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + return scope.Close(Int32::New(result)); +} + +Handle GitTag::Peel(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tag tag is required."))); + } + git_object * tag_target_out; + +int result = git_tag_peel( + +& + tag_target_out +, + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)tag_target_out) }; + return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); +} + + +Persistent GitTag::constructor_template; diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 973586ffa..acb546da8 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -66,22 +66,26 @@ git_tree_entry *GitTreeEntry::GetValue() { Handle GitTreeEntry::Name(const Arguments& args) { HandleScope scope; - const char * result = git_tree_entry_name( +const char * result = git_tree_entry_name( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(String::New(result)); } Handle GitTreeEntry::Oid(const Arguments& args) { HandleScope scope; - const git_oid * result = git_tree_entry_id( +const git_oid * result = git_tree_entry_id( + ObjectWrap::Unwrap(args.This())->GetValue() ); + // XXX need to copy object? Handle argv[1] = { External::New((void *)result) }; return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); @@ -90,22 +94,26 @@ Handle GitTreeEntry::Oid(const Arguments& args) { Handle GitTreeEntry::Type(const Arguments& args) { HandleScope scope; - git_otype result = git_tree_entry_type( +git_otype result = git_tree_entry_type( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Number::New(result)); } Handle GitTreeEntry::filemode(const Arguments& args) { HandleScope scope; - git_filemode_t result = git_tree_entry_filemode( +git_filemode_t result = git_tree_entry_filemode( + ObjectWrap::Unwrap(args.This())->GetValue() ); + return scope.Close(Number::New(result)); } @@ -135,12 +143,12 @@ Handle GitTreeEntry::GetObject(const Arguments& args) { void GitTreeEntry::GetObjectWork(uv_work_t *req) { GetObjectBaton *baton = static_cast(req->data); - int result = git_tree_entry_to_object( + int object_out = git_tree_entry_to_object( &baton->object_out, baton->repo, baton->entry ); - if (result != GIT_OK) { + if (object_out != GIT_OK) { baton->error = giterr_last(); } } diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 92e60e8ee..28f5ea06d 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -100,6 +100,14 @@ Handle <%- cppClassName %>::New(const Arguments& args) { for (var i in functions) { var functionInfo = functions[i]; if (functionInfo.ignore) continue; + + var result = null; + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn) result = arg; + } + if (!result) result = functionInfo.return; + var resultName = result.name || 'result'; -%> <% if (functionInfo.isAsync) { -%> @@ -160,7 +168,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); - <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( + <%- functionInfo.return.cType %> <%- resultName %> = <%- functionInfo.cFunctionName %>( <% for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; @@ -169,11 +177,11 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req <% } -%> ); <% if (functionInfo.return.isErrorCode) { -%> - if (result != GIT_OK) { + if (<%- resultName %> != GIT_OK) { baton->error = giterr_last(); } <% } else { -%> - baton->result = result; + baton->result = <%- resultName %>; <% } -%> } @@ -183,15 +191,6 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t TryCatch try_catch; if (!baton->error) { -<% - var result = null; - for (var i = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; - if (arg.isReturn) result = arg; - } - if (!result) result = functionInfo.return; - var resultName = result.name || 'result'; --%> <% if (result.isErrorCode) { %> Handle <%- resultName %> = Local::New(Undefined()); <% } else { -%> @@ -258,11 +257,12 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <% } -%> <% } -%> - <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( +<% if (result.cType != "void") { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( <% for (var i = 0, j = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> + <% if (/\*\*/.test(arg.cType)) { %>&<% } %> <% if (arg.isSelf) { -%> ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() @@ -287,15 +287,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg return ThrowException(GitError::WrapError(giterr_last())); } <% } -%> -<% - var result = null; - for (var i = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; - if (arg.isReturn) result = arg; - } - if (!result) result = functionInfo.return; - var resultName = result.name || 'result'; --%> + <% if (result.cType == "void") { -%> return Undefined(); <% } else if (isV8Value(result.cppClassName)) { -%> diff --git a/v0.18.0.json b/v0.18.0.json index 4ef8b4c82..28b6a43c8 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -81,7 +81,7 @@ { "name": "num_attr", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -164,8 +164,7 @@ "cppFunctionName": "CacheFlush", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -275,7 +274,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -310,8 +309,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -332,8 +330,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -354,8 +351,7 @@ "cppFunctionName": "Content", "return": { "cType": "const void *", - "cppClassName": "Wrapper", - "isErrorCode": false + "cppClassName": "Wrapper" } }, { @@ -376,8 +372,7 @@ "cppFunctionName": "Size", "return": { "cType": "git_off_t", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -846,7 +841,7 @@ { "name": "buffer_size", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -906,7 +901,7 @@ { "name": "buffer_size", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -981,7 +976,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -1153,7 +1148,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -1189,8 +1184,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -1211,8 +1205,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -1233,8 +1226,7 @@ "cppFunctionName": "MessageEncoding", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -1255,8 +1247,7 @@ "cppFunctionName": "Message", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -1277,8 +1268,7 @@ "cppFunctionName": "Time", "return": { "cType": "git_time_t", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -1320,8 +1310,7 @@ "cppFunctionName": "Committer", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature", - "isErrorCode": false + "cppClassName": "GitSignature" } }, { @@ -1342,8 +1331,7 @@ "cppFunctionName": "Author", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature", - "isErrorCode": false + "cppClassName": "GitSignature" } }, { @@ -1393,8 +1381,7 @@ "cppFunctionName": "TreeId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -1415,8 +1402,7 @@ "cppFunctionName": "ParentCount", "return": { "cType": "unsigned int", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -1479,8 +1465,7 @@ "cppFunctionName": "ParentId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -1703,8 +1688,7 @@ "cppFunctionName": "GitLibgit2Version", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -1764,7 +1748,7 @@ { "name": "length", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -1792,7 +1776,7 @@ { "name": "length", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -1820,7 +1804,7 @@ { "name": "length", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -2061,8 +2045,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -2590,7 +2573,7 @@ { "name": "map_n", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -2624,7 +2607,7 @@ { "name": "map_n", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -2810,8 +2793,7 @@ "cppFunctionName": "ListFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -2883,7 +2865,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -2922,7 +2904,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -3131,8 +3113,7 @@ "cppFunctionName": "StatusChar", "return": { "cType": "char", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -3185,8 +3166,7 @@ "cppFunctionName": "NumDeltas", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -3212,8 +3192,7 @@ "cppFunctionName": "NumDeltasOfType", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -3240,7 +3219,7 @@ { "name": "idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -3273,8 +3252,7 @@ "cppFunctionName": "PatchFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -3294,8 +3272,7 @@ "cppFunctionName": "PatchDelta", "return": { "cType": "const git_diff_delta *", - "cppClassName": "DiffDelta", - "isErrorCode": false + "cppClassName": "DiffDelta" } }, { @@ -3315,8 +3292,7 @@ "cppFunctionName": "PatchNumHunks", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -3325,19 +3301,19 @@ { "name": "total_context", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "total_additions", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "total_deletions", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -3376,13 +3352,13 @@ { "name": "header_len", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "lines_in_hunk", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -3394,7 +3370,7 @@ { "name": "hunk_idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -3421,7 +3397,7 @@ { "name": "hunk_idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -3454,7 +3430,7 @@ { "name": "content_len", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -3478,13 +3454,13 @@ { "name": "hunk_idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "line_of_hunk", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -3634,7 +3610,7 @@ { "name": "buffer_len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -3698,8 +3674,7 @@ "cppFunctionName": "GiterrLast", "return": { "cType": "const git_error *", - "cppClassName": "Error", - "isErrorCode": false + "cppClassName": "Error" } }, { @@ -3712,8 +3687,7 @@ "cppFunctionName": "GiterrClear", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -3739,8 +3713,7 @@ "cppFunctionName": "GiterrSetStr", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -3753,8 +3726,7 @@ "cppFunctionName": "GiterrSetOom", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -3772,13 +3744,13 @@ { "name": "ahead", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "behind", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -3905,8 +3877,9 @@ }, { "filename": "index.h", + "dependencies": ["../include/oid.h", "../include/repo.h", "../include/tree.h"], "jsClassName": "Index", - "cppClassName": "Index", + "cppClassName": "GitIndex", "cType": "git_index", "freeFunctionName": "git_index_free", "functions": [ @@ -3917,7 +3890,7 @@ "name": "out", "isReturn": true, "cType": "git_index **", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -3945,10 +3918,11 @@ "name": "out", "isReturn": true, "cType": "git_index **", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -3966,7 +3940,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" } ], @@ -3979,8 +3953,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -3989,7 +3962,7 @@ { "name": "index", "cType": "const git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4001,8 +3974,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "GitRepo", - "isErrorCode": false + "cppClassName": "GitRepo" } }, { @@ -4011,7 +3983,7 @@ { "name": "index", "cType": "const git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4024,8 +3996,7 @@ "cppFunctionName": "Caps", "return": { "cType": "unsigned int", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -4034,7 +4005,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4063,7 +4034,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4085,7 +4056,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4107,7 +4078,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4142,7 +4113,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4171,7 +4142,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -4199,7 +4170,7 @@ { "name": "index", "cType": "const git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4211,8 +4182,7 @@ "cppFunctionName": "Entrycount", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -4221,7 +4191,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4233,8 +4203,7 @@ "cppFunctionName": "Clear", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -4243,14 +4212,14 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, { "name": "n", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -4262,8 +4231,7 @@ "cppFunctionName": "GetByindex", "return": { "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", - "isErrorCode": false + "cppClassName": "IndexEntry" } }, { @@ -4272,7 +4240,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4297,8 +4265,7 @@ "cppFunctionName": "GetBypath", "return": { "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", - "isErrorCode": false + "cppClassName": "IndexEntry" } }, { @@ -4307,7 +4274,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4341,7 +4308,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4375,7 +4342,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4426,7 +4393,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4454,7 +4421,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4482,13 +4449,13 @@ { "name": "at_pos", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4515,7 +4482,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4574,7 +4541,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -4602,7 +4569,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4630,7 +4597,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4642,8 +4609,7 @@ "cppFunctionName": "ConflictCleanup", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -4652,7 +4618,7 @@ { "name": "index", "cType": "const git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4673,7 +4639,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4686,8 +4652,7 @@ "cppFunctionName": "ReucEntrycount", "return": { "cType": "unsigned int", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -4696,13 +4661,13 @@ { "name": "at_pos", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -4730,7 +4695,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4749,8 +4714,7 @@ "cppFunctionName": "ReucGetBypath", "return": { "cType": "const git_index_reuc_entry *", - "cppClassName": "IndexReucEntry", - "isErrorCode": false + "cppClassName": "IndexReucEntry" } }, { @@ -4759,14 +4723,14 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, { "name": "n", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -4778,8 +4742,7 @@ "cppFunctionName": "ReucGetByindex", "return": { "cType": "const git_index_reuc_entry *", - "cppClassName": "IndexReucEntry", - "isErrorCode": false + "cppClassName": "IndexReucEntry" } }, { @@ -4788,7 +4751,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, @@ -4853,14 +4816,14 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true }, { "name": "n", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -4882,7 +4845,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index", "isSelf": true } @@ -4895,8 +4858,7 @@ "cppFunctionName": "ReucClear", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -4966,7 +4928,7 @@ { "name": "size", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -5031,8 +4993,7 @@ "cppFunctionName": "StreamHash", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -5053,8 +5014,7 @@ "cppFunctionName": "StreamFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -5133,7 +5093,7 @@ { "name": "length", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -5170,7 +5130,7 @@ { "name": "out_size", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -5266,8 +5226,7 @@ "cppFunctionName": "GitNoteIteratorFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -5360,8 +5319,7 @@ "cppFunctionName": "GitNoteMessage", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -5381,8 +5339,7 @@ "cppFunctionName": "GitNoteOid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -5512,8 +5469,7 @@ "cppFunctionName": "GitNoteFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -5658,7 +5614,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -5698,8 +5654,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -5720,8 +5675,7 @@ "cppFunctionName": "Type", "return": { "cType": "git_otype", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -5742,8 +5696,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "GitRepo", - "isErrorCode": false + "cppClassName": "GitRepo" } }, { @@ -5765,8 +5718,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -5787,8 +5739,7 @@ "cppFunctionName": "Type2string", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -5809,8 +5760,7 @@ "cppFunctionName": "String2type", "return": { "cType": "git_otype", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -5853,8 +5803,7 @@ "cppFunctionName": "Size", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -6096,8 +6045,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -6159,7 +6107,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -6180,7 +6128,7 @@ { "name": "len_out", "cType": "size_t *", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -6322,7 +6270,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -6362,7 +6310,7 @@ { "name": "size", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -6476,7 +6424,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -6549,8 +6497,7 @@ "cppFunctionName": "ObjectFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -6570,8 +6517,7 @@ "cppFunctionName": "ObjectId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -6591,8 +6537,7 @@ "cppFunctionName": "ObjectData", "return": { "cType": "const void *", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -6612,8 +6557,7 @@ "cppFunctionName": "ObjectSize", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -6633,8 +6577,7 @@ "cppFunctionName": "ObjectType", "return": { "cType": "git_otype", - "cppClassName": "Int32", - "isErrorCode": false + "cppClassName": "Int32" } } ] @@ -6760,7 +6703,7 @@ { "name": "length", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -6801,8 +6744,7 @@ "cppFunctionName": "Fromraw", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -6831,8 +6773,7 @@ "cppFunctionName": "Fmt", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -6860,8 +6801,7 @@ "cppFunctionName": "Pathfmt", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -6882,8 +6822,7 @@ "cppFunctionName": "Sha", "return": { "cType": "char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -6899,7 +6838,7 @@ { "name": "n", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -6917,8 +6856,7 @@ "cppFunctionName": "Sha", "return": { "cType": "char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -6947,8 +6885,7 @@ "cppFunctionName": "Cpy", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -7028,7 +6965,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -7102,7 +7039,7 @@ { "name": "min_length", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -7114,8 +7051,7 @@ "cppFunctionName": "ShortenNew", "return": { "cType": "git_oid_shorten *", - "cppClassName": "OidShorten", - "isErrorCode": false + "cppClassName": "OidShorten" } }, { @@ -7165,8 +7101,7 @@ "cppFunctionName": "ShortenFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -7229,8 +7164,7 @@ "cppFunctionName": "GitPackbuilderSetThreads", "return": { "cType": "unsigned int", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -7370,8 +7304,7 @@ "cppFunctionName": "GitPackbuilderObjectCount", "return": { "cType": "uint32_t", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -7391,8 +7324,7 @@ "cppFunctionName": "GitPackbuilderWritten", "return": { "cType": "uint32_t", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -7413,8 +7345,7 @@ "cppFunctionName": "GitPackbuilderFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -7628,8 +7559,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -7677,8 +7607,7 @@ "cppFunctionName": "GitReference_Alloc", "return": { "cType": "git_reference *", - "cppClassName": "GitReference", - "isErrorCode": false + "cppClassName": "GitReference" } }, { @@ -7777,8 +7706,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -8017,8 +7945,7 @@ "cppFunctionName": "Entrycount", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -8034,7 +7961,7 @@ { "name": "idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -8045,8 +7972,7 @@ "cppFunctionName": "EntryByindex", "return": { "cType": "const git_reflog_entry *", - "cppClassName": "ReflogEntry", - "isErrorCode": false + "cppClassName": "ReflogEntry" } }, { @@ -8062,7 +7988,7 @@ { "name": "idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -8100,8 +8026,7 @@ "cppFunctionName": "EntryIdOld", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -8121,8 +8046,7 @@ "cppFunctionName": "EntryIdNew", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -8142,8 +8066,7 @@ "cppFunctionName": "EntryCommitter", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature", - "isErrorCode": false + "cppClassName": "GitSignature" } }, { @@ -8163,8 +8086,7 @@ "cppFunctionName": "EntryMessage", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -8185,8 +8107,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -8381,8 +8302,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -8403,8 +8323,7 @@ "cppFunctionName": "Name", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -8425,8 +8344,7 @@ "cppFunctionName": "Type", "return": { "cType": "git_ref_t", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -8448,8 +8366,7 @@ "cppFunctionName": "Name", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -8500,8 +8417,7 @@ "cppFunctionName": "owner", "return": { "cType": "git_repository *", - "cppClassName": "GitRepo", - "isErrorCode": false + "cppClassName": "GitRepo" } }, { @@ -8730,8 +8646,7 @@ "cppFunctionName": "GitReferenceFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -9000,8 +8915,7 @@ "cppFunctionName": "Src", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -9022,8 +8936,7 @@ "cppFunctionName": "Dst", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -9117,7 +9030,7 @@ { "name": "outlen", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -9157,7 +9070,7 @@ { "name": "outlen", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -9347,8 +9260,7 @@ "cppFunctionName": "Name", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -9369,8 +9281,7 @@ "cppFunctionName": "Url", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -9391,8 +9302,7 @@ "cppFunctionName": "Pushurl", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -9497,8 +9407,7 @@ "cppFunctionName": "Fetchspec", "return": { "cType": "const git_refspec *", - "cppClassName": "Refspec", - "isErrorCode": false + "cppClassName": "Refspec" } }, { @@ -9547,8 +9456,7 @@ "cppFunctionName": "Pushspec", "return": { "cType": "const git_refspec *", - "cppClassName": "Refspec", - "isErrorCode": false + "cppClassName": "Refspec" } }, { @@ -9687,8 +9595,7 @@ "cppFunctionName": "Stop", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -9709,8 +9616,7 @@ "cppFunctionName": "Disconnect", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -9731,8 +9637,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -9851,8 +9756,7 @@ "cppFunctionName": "CheckCert", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -9885,8 +9789,7 @@ "cppFunctionName": "SetCredAcquireCb", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -9963,8 +9866,7 @@ "cppFunctionName": "Stats", "return": { "cType": "const git_transfer_progress *", - "cppClassName": "TransferProgress", - "isErrorCode": false + "cppClassName": "TransferProgress" } }, { @@ -9977,8 +9879,7 @@ "cppFunctionName": "Autotag", "return": { "cType": "GIT_EXTERN(", - "cppClassName": "GIT_EXTERN(", - "isErrorCode": false + "cppClassName": "GIT_EXTERN(" } }, { @@ -10005,8 +9906,7 @@ "cppFunctionName": "SetAutotag", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10095,8 +9995,7 @@ "cppFunctionName": "SetUpdateFetchhead", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10199,7 +10098,7 @@ { "name": "path_size", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -10293,8 +10192,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10482,8 +10380,7 @@ "cppFunctionName": "Path", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -10504,8 +10401,7 @@ "cppFunctionName": "Workdir", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -10620,8 +10516,7 @@ "cppFunctionName": "SetConfig", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10678,8 +10573,7 @@ "cppFunctionName": "SetOdb", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10736,8 +10630,7 @@ "cppFunctionName": "SetRefdb", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10747,7 +10640,7 @@ "name": "out", "isReturn": true, "cType": "git_index **", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" }, { @@ -10782,7 +10675,7 @@ { "name": "index", "cType": "git_index *", - "cppClassName": "Index", + "cppClassName": "GitIndex", "jsClassName": "Index" } ], @@ -10794,8 +10687,7 @@ "cppFunctionName": "SetIndex", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -10811,7 +10703,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" }, { @@ -10974,7 +10866,7 @@ { "name": "type", "cType": "git_otype", - "cppClassName": "Otype", + "cppClassName": "Int32", "jsClassName": "Otype" }, { @@ -11303,8 +11195,7 @@ "cppFunctionName": "Reset", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -11571,8 +11462,7 @@ "cppFunctionName": "Sorting", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -11621,8 +11511,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -11643,8 +11532,7 @@ "cppFunctionName": "Repository", "return": { "cType": "git_repository *", - "cppClassName": "GitRepo", - "isErrorCode": false + "cppClassName": "GitRepo" } } ] @@ -11809,8 +11697,7 @@ "cppFunctionName": "Dup", "return": { "cType": "git_signature *", - "cppClassName": "GitSignature", - "isErrorCode": false + "cppClassName": "GitSignature" } }, { @@ -11832,8 +11719,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -11936,7 +11822,7 @@ { "name": "index", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -12133,8 +12019,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -12377,8 +12262,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "GitRepo", - "isErrorCode": false + "cppClassName": "GitRepo" } }, { @@ -12399,8 +12283,7 @@ "cppFunctionName": "Name", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -12421,8 +12304,7 @@ "cppFunctionName": "Path", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -12443,8 +12325,7 @@ "cppFunctionName": "Url", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -12493,8 +12374,7 @@ "cppFunctionName": "IndexId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -12515,8 +12395,7 @@ "cppFunctionName": "HeadId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -12537,8 +12416,7 @@ "cppFunctionName": "WdId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -12551,8 +12429,7 @@ "cppFunctionName": "Ignore", "return": { "cType": "GIT_EXTERN(", - "cppClassName": "GIT_EXTERN(", - "isErrorCode": false + "cppClassName": "GIT_EXTERN(" } }, { @@ -12579,8 +12456,7 @@ "cppFunctionName": "SetIgnore", "return": { "cType": "git_submodule_ignore_t", - "cppClassName": "SubmoduleIgnoreT", - "isErrorCode": false + "cppClassName": "SubmoduleIgnoreT" } }, { @@ -12593,8 +12469,7 @@ "cppFunctionName": "Update", "return": { "cType": "GIT_EXTERN(", - "cppClassName": "GIT_EXTERN(", - "isErrorCode": false + "cppClassName": "GIT_EXTERN(" } }, { @@ -12621,8 +12496,7 @@ "cppFunctionName": "SetUpdate", "return": { "cType": "git_submodule_update_t", - "cppClassName": "SubmoduleUpdateT", - "isErrorCode": false + "cppClassName": "SubmoduleUpdateT" } }, { @@ -12853,8 +12727,9 @@ }, { "filename": "tag.h", + "dependencies": ["../include/oid.h", "../include/repo.h", "../include/object.h", "../include/signature.h"], "jsClassName": "Tag", - "cppClassName": "Tag", + "cppClassName": "GitTag", "cType": "git_tag", "freeFunctionName": "git_tag_free", "functions": [ @@ -12865,7 +12740,7 @@ "name": "out", "isReturn": true, "cType": "git_tag **", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag" }, { @@ -12881,7 +12756,7 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "lookup", @@ -12899,7 +12774,7 @@ "name": "out", "isReturn": true, "cType": "git_tag **", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag" }, { @@ -12917,10 +12792,11 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -12938,10 +12814,11 @@ { "name": "tag", "cType": "git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -12950,8 +12827,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -12960,7 +12836,7 @@ { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag", "isSelf": true } @@ -12972,8 +12848,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -12983,18 +12858,20 @@ "name": "target_out", "cType": "git_object **", "cppClassName": "GitObject", - "jsClassName": "Object" + "jsClassName": "Object", + "isReturn": true }, { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", - "jsClassName": "Tag" + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "target", "cppFunctionName": "Target", "return": { @@ -13009,7 +12886,7 @@ { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag", "isSelf": true } @@ -13021,8 +12898,7 @@ "cppFunctionName": "TargetId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -13031,7 +12907,7 @@ { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag", "isSelf": true } @@ -13043,8 +12919,7 @@ "cppFunctionName": "TargetType", "return": { "cType": "git_otype", - "cppClassName": "Otype", - "isErrorCode": false + "cppClassName": "Int32" } }, { @@ -13053,7 +12928,7 @@ { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag", "isSelf": true } @@ -13065,8 +12940,7 @@ "cppFunctionName": "Name", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -13075,7 +12949,7 @@ { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag", "isSelf": true } @@ -13087,8 +12961,7 @@ "cppFunctionName": "Tagger", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature", - "isErrorCode": false + "cppClassName": "GitSignature" } }, { @@ -13097,7 +12970,7 @@ { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag", "isSelf": true } @@ -13109,8 +12982,7 @@ "cppFunctionName": "Message", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -13120,7 +12992,8 @@ "name": "oid", "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isReturn": true }, { "name": "repo", @@ -13159,8 +13032,8 @@ "jsClassName": "Number" } ], - "isAsync": false, - "isConstructorMethod": false, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "create", "cppFunctionName": "Create", @@ -13198,6 +13071,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -13216,7 +13090,8 @@ "name": "oid", "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "isReturn": true }, { "name": "repo", @@ -13243,8 +13118,8 @@ "jsClassName": "Number" } ], - "isAsync": false, - "isConstructorMethod": false, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "createLightweight", "cppFunctionName": "CreateLightweight", @@ -13297,6 +13172,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -13330,6 +13206,7 @@ "jsClassName": "Repository" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -13363,6 +13240,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -13381,18 +13259,19 @@ "name": "tag_target_out", "cType": "git_object **", "cppClassName": "GitObject", - "jsClassName": "Object" + "jsClassName": "Object", + "isReturn": true }, { "name": "tag", "cType": "const git_tag *", - "cppClassName": "Tag", + "cppClassName": "GitTag", "jsClassName": "Tag" } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "peel", "cppFunctionName": "Peel", "return": { @@ -13434,8 +13313,7 @@ "cppFunctionName": "Shutdown", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } } ] @@ -13738,8 +13616,7 @@ "cppFunctionName": "Dup", "return": { "cType": "git_tree_entry *", - "cppClassName": "TreeEntry", - "isErrorCode": false + "cppClassName": "TreeEntry" } }, { @@ -13762,8 +13639,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -13784,8 +13660,7 @@ "cppFunctionName": "Name", "return": { "cType": "const char *", - "cppClassName": "String", - "isErrorCode": false + "cppClassName": "String" } }, { @@ -13806,8 +13681,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -13828,8 +13702,7 @@ "cppFunctionName": "Type", "return": { "cType": "git_otype", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -13850,8 +13723,7 @@ "cppFunctionName": "filemode", "return": { "cType": "git_filemode_t", - "cppClassName": "Number", - "isErrorCode": false + "cppClassName": "Number" } }, { @@ -13986,7 +13858,7 @@ { "name": "len", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -14019,8 +13891,7 @@ "cppFunctionName": "Free", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -14041,8 +13912,7 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid", - "isErrorCode": false + "cppClassName": "GitOid" } }, { @@ -14063,8 +13933,7 @@ "cppFunctionName": "Owner", "return": { "cType": "git_repository *", - "cppClassName": "GitRepo", - "isErrorCode": false + "cppClassName": "GitRepo" } }, { @@ -14085,8 +13954,7 @@ "cppFunctionName": "Entrycount", "return": { "cType": "size_t", - "cppClassName": "size_t", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -14113,8 +13981,7 @@ "cppFunctionName": "EntryByname", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "isErrorCode": false + "cppClassName": "TreeEntry" } }, { @@ -14130,7 +13997,7 @@ { "name": "idx", "cType": "size_t", - "cppClassName": "size_t", + "cppClassName": "Uint32", "jsClassName": "size_t" } ], @@ -14141,8 +14008,7 @@ "cppFunctionName": "EntryByindex", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "isErrorCode": false + "cppClassName": "TreeEntry" } }, { @@ -14169,8 +14035,7 @@ "cppFunctionName": "EntryByoid", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "isErrorCode": false + "cppClassName": "TreeEntry" } }, { @@ -14252,8 +14117,7 @@ "cppFunctionName": "GitTreebuilderClear", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -14273,8 +14137,7 @@ "cppFunctionName": "GitTreebuilderEntrycount", "return": { "cType": "unsigned int", - "cppClassName": "Uint32", - "isErrorCode": false + "cppClassName": "Uint32" } }, { @@ -14295,8 +14158,7 @@ "cppFunctionName": "GitTreebuilderFree", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { @@ -14322,8 +14184,7 @@ "cppFunctionName": "GitTreebuilderGet", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", - "isErrorCode": false + "cppClassName": "TreeEntry" } }, { @@ -14428,8 +14289,7 @@ "cppFunctionName": "GitTreebuilderFilter", "return": { "cType": "void", - "cppClassName": "void", - "isErrorCode": false + "cppClassName": "void" } }, { From 552fae76481b86862469c5bb26b08f4b22ed3c9a Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 24 Jun 2013 18:49:54 +0200 Subject: [PATCH 08/28] Threads & Tree now codgen'd --- gen.js | 2 +- include/threads.h | 36 ++-- include/tree.h | 97 +++-------- lib/index.js | 2 +- lib/repo.js | 2 +- lib/tree.js | 75 +++++--- lib/tree_entry.js | 7 +- src/blob.cc | 8 +- src/commit.cc | 22 +-- src/index.cc | 22 +-- src/object.cc | 6 +- src/oid.cc | 4 +- src/reference.cc | 22 +-- src/repo.cc | 4 +- src/signature.cc | 2 +- src/tag.cc | 16 +- src/threads.cc | 55 +++--- src/tree.cc | 349 +++++++++++++++++-------------------- src/tree_entry.cc | 8 +- templates/class.cc.ejs | 24 ++- templates/header.h.ejs | 6 + test/convenience-commit.js | 13 +- test/convenience-tree.js | 8 +- v0.18.0.json | 186 +++++++++++--------- 24 files changed, 476 insertions(+), 500 deletions(-) diff --git a/gen.js b/gen.js index 6c2c4f6d7..0a19608d4 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag", "Threads", "Tree"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/threads.h b/include/threads.h index bf9f8c392..7a67b0295 100755 --- a/include/threads.h +++ b/include/threads.h @@ -1,41 +1,33 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITTHREADS_H +#define GITTHREADS_H #include #include +#include #include "git2.h" using namespace node; using namespace v8; -/** - * Class wrapper for libgit2 git_threads_* - */ class GitThreads : public ObjectWrap { public: - /** - * v8::FunctionTemplate used to create Node.js constructor - */ - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); - /** - * Calls git_threads_init synchronously. This is called one time - * on initialization, and is required for libgit2 to run correctly. - */ - static Handle Init(const Arguments& args); - - protected: - GitThreads() {} - ~GitThreads() {} + private: static Handle New(const Arguments& args); + + static Handle Init(const Arguments& args); + static Handle Shutdown(const Arguments& args); }; + +#endif diff --git a/include/tree.h b/include/tree.h index 0b922b177..c60aae9f0 100755 --- a/include/tree.h +++ b/include/tree.h @@ -1,9 +1,6 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #ifndef GITTREE_H #define GITTREE_H @@ -11,97 +8,61 @@ #include #include #include -#include #include "git2.h" -#include "repo.h" -#include "tree_entry.h" - -using namespace v8; using namespace node; +using namespace v8; -/** - * Class wrapper for libgit2 git_tree - */ class GitTree : public ObjectWrap { public: static Persistent constructor_template; + static void Initialize (Handle target); - static const int WALK_ENTRY_SEND_THRESHOLD = 10; - - static void Initialize(Handle target); - - git_tree* GetValue(); + git_tree *GetValue(); - protected: + private: GitTree(git_tree *raw); ~GitTree(); static Handle New(const Arguments& args); + static Handle Lookup(const Arguments& args); static void LookupWork(uv_work_t* req); static void LookupAfterWork(uv_work_t* req); - static Handle Walk(const Arguments& args); - static void WalkWork(void* payload); - static int WalkWorkEntry(const char *root, const git_tree_entry *entry, void *payload); - static void WalkWorkSendEntry(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/); - - static Handle EntryByPath(const Arguments& args); - static void EntryByPathWork(uv_work_t *req); - static void EntryByPathAfterWork(uv_work_t *req); - - private: - - git_tree* raw; - struct LookupBaton { uv_work_t request; const git_error* error; - - git_oid rawOid; - git_repository* rawRepo; - git_tree* rawTree; - + git_tree * out; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; Persistent callback; }; - - struct WalkEntry { - git_tree_entry* rawEntry; - std::string root; - }; - - struct WalkBaton { - uv_thread_t threadId; - uv_mutex_t mutex; - uv_async_t asyncEntry; - uv_async_t asyncEnd; - - const git_error* error; - - std::vector rawTreeEntries; - - git_tree* rawTree; - bool blobsOnly; - - Persistent entryCallback; - Persistent endCallback; - }; - - struct EntryByPathBaton { + static Handle Oid(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle EntryByName(const Arguments& args); + static Handle EntryByIndex(const Arguments& args); + static Handle EntryByOid(const Arguments& args); + static Handle GetEntryByPath(const Arguments& args); + static void GetEntryByPathWork(uv_work_t* req); + static void GetEntryByPathAfterWork(uv_work_t* req); + + struct GetEntryByPathBaton { uv_work_t request; const git_error* error; - - git_tree* rawTree; - std::string path; - git_tree_entry* rawEntry; - + git_tree_entry * out; + Persistent rootReference; + git_tree * root; + Persistent pathReference; + const char * path; Persistent callback; }; + git_tree *raw; }; #endif diff --git a/lib/index.js b/lib/index.js index d8dd19100..432860a29 100755 --- a/lib/index.js +++ b/lib/index.js @@ -36,4 +36,4 @@ exports.entry = require('./tree_entry.js').entry; exports.version = require('../package').version; // Initialize threads -(new exports.raw.Threads()).init(); +exports.raw.Threads.init(); diff --git a/lib/repo.js b/lib/repo.js index 8d4a9e695..4f7f7d552 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -138,7 +138,7 @@ Repo.prototype.tree = function(oid, callback) { * @param {Tree|null} tree The tree object or null. */ var self = this; - git.raw.Tree.lookup(oid.rawOid, this.rawRepo, function(error, rawTree) { + git.raw.Tree.lookup(this.rawRepo, oid.rawOid, function(error, rawTree) { if (success(error, callback)) { callback(null, new git.tree(self, rawTree)); } diff --git a/lib/tree.js b/lib/tree.js index a85718010..65ff3ad55 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -35,13 +35,20 @@ Tree.prototype.entry = function(path, callback) { * @param {Entry|null} entry The tree entry object or null. */ var self = this; - self.rawTree.entryByPath(path, function(error, rawEntry) { + self.rawTree.getEntryByPath(path, function(error, rawEntry) { if (success(error, callback)) { callback(null, new git.entry(self.repo, rawEntry)); } }); }; +/** + * Retrieve the number of entries in this tree. + */ +Tree.prototype.size = function() { + return self.rawTree.size(); +}; + /** * Walk the tree. * @@ -53,39 +60,49 @@ Tree.prototype.entry = function(path, callback) { * @return {EventEmitter} */ Tree.prototype.walk = function(blobsOnly) { - blobsOnly = typeof blobsOnly === 'undefined' ? true : blobsOnly; + if (typeof blobsOnly == 'undefined') blobsOnly = true; var self = this, event = new events.EventEmitter(), - entries = []; + entries = [], + errors = []; - var total = 0; + var total = 1; - self.rawTree.walk(blobsOnly, function treeWalkEntries(error, rawEntries) { - rawEntries.forEach(function treeWalkEntryEmitter(rawEntry) { - var entry = new git.entry(self.repo, rawEntry); - entries.push(entry); - /** - * Entry event. - * - * @event Tree#entry - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Entry} entry The tree entry. - */ - event.emit('entry', null, entry); - }); - }, function treeWalkEnd(error) { - /** - * End event. - * - * @event Tree#end - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Entry[]} entries The tree entries. - */ - event.emit('end', error ? new git.error(error.message, error.code) : null, entries); - }); + function dfs(error, tree) { + total--; + + var size = tree.rawTree.size(); + if (error) return errors.push(error); + + for (var i = 0; i < size; i ++) { + var rawEntry = tree.rawTree.entryByIndex(i), + entry = new git.entry(tree.repo, rawEntry); + if (!blobsOnly || entry.isFile()) { + /** + * Entry event. + * + * @event Tree#entry + * + * @param {GitError|null} error An error object if there was an issue, null otherwise. + * @param {Entry} entry The tree entry. + */ + event.emit('entry', entry); + entries.push(entry); + } + + if (entry.isTree()) { + total++; + entry.getTree(dfs); + } + } + if (total === 0) + event.emit('end', errors.length ? errors : null, entries); + } + + event.start = function(e) { + dfs(null, self); + }; return event; }; diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 3b04783d1..84c5b1147 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -42,10 +42,12 @@ TreeEntry.prototype.isFile = function() { this.filemode() === TreeEntry.FileMode.Executable; }; -TreeEntry.prototype.isDirectory = function() { +TreeEntry.prototype.isTree = function() { return this.filemode() === TreeEntry.FileMode.Tree; }; +TreeEntry.prototype.isDirectory = TreeEntry.prototype.isTree; + /** * Retrieve the Oid for this TreeEntry. */ @@ -96,8 +98,7 @@ TreeEntry.prototype.getBlob = function(callback) { * @param {TreeEntry~treeCallback} callback */ TreeEntry.prototype.getTree = function(callback) { - if (!this.isDirectory()) return callback(new git.error('Not a tree/directory', 0)); - + if (!this.isTree()) return callback(new git.error('Not a tree/directory', 0)); /** * @callback TreeEntry~treeCallback Callback executed after blob is retrieved. * @param {GitError|null} error An Error or null if successful. diff --git a/src/blob.cc b/src/blob.cc index 17a290611..74ceb30a5 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -137,7 +137,7 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; -const git_oid * result = git_blob_id( + const git_oid * result = git_blob_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -152,7 +152,7 @@ const git_oid * result = git_blob_id( Handle GitBlob::Content(const Arguments& args) { HandleScope scope; -const void * result = git_blob_rawcontent( + const void * result = git_blob_rawcontent( ObjectWrap::Unwrap(args.This())->GetValue() @@ -167,7 +167,7 @@ const void * result = git_blob_rawcontent( Handle GitBlob::Size(const Arguments& args) { HandleScope scope; -git_off_t result = git_blob_rawsize( + git_off_t result = git_blob_rawsize( ObjectWrap::Unwrap(args.This())->GetValue() @@ -325,7 +325,7 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; -int result = git_blob_is_binary( + int result = git_blob_is_binary( ObjectWrap::Unwrap(args.This())->GetValue() diff --git a/src/commit.cc b/src/commit.cc index 4445fddc4..15a2323b3 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -144,7 +144,7 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; -const git_oid * result = git_commit_id( + const git_oid * result = git_commit_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -159,7 +159,7 @@ const git_oid * result = git_commit_id( Handle GitCommit::MessageEncoding(const Arguments& args) { HandleScope scope; -const char * result = git_commit_message_encoding( + const char * result = git_commit_message_encoding( ObjectWrap::Unwrap(args.This())->GetValue() @@ -172,7 +172,7 @@ const char * result = git_commit_message_encoding( Handle GitCommit::Message(const Arguments& args) { HandleScope scope; -const char * result = git_commit_message( + const char * result = git_commit_message( ObjectWrap::Unwrap(args.This())->GetValue() @@ -185,7 +185,7 @@ const char * result = git_commit_message( Handle GitCommit::Time(const Arguments& args) { HandleScope scope; -git_time_t result = git_commit_time( + git_time_t result = git_commit_time( ObjectWrap::Unwrap(args.This())->GetValue() @@ -198,7 +198,7 @@ git_time_t result = git_commit_time( Handle GitCommit::Offset(const Arguments& args) { HandleScope scope; -int result = git_commit_time_offset( + int result = git_commit_time_offset( ObjectWrap::Unwrap(args.This())->GetValue() @@ -211,7 +211,7 @@ int result = git_commit_time_offset( Handle GitCommit::Committer(const Arguments& args) { HandleScope scope; -const git_signature * result = git_commit_committer( + const git_signature * result = git_commit_committer( ObjectWrap::Unwrap(args.This())->GetValue() @@ -226,7 +226,7 @@ const git_signature * result = git_commit_committer( Handle GitCommit::Author(const Arguments& args) { HandleScope scope; -const git_signature * result = git_commit_author( + const git_signature * result = git_commit_author( ObjectWrap::Unwrap(args.This())->GetValue() @@ -299,7 +299,7 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; -const git_oid * result = git_commit_tree_id( + const git_oid * result = git_commit_tree_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -314,7 +314,7 @@ const git_oid * result = git_commit_tree_id( Handle GitCommit::ParentCount(const Arguments& args) { HandleScope scope; -unsigned int result = git_commit_parentcount( + unsigned int result = git_commit_parentcount( ObjectWrap::Unwrap(args.This())->GetValue() @@ -396,7 +396,7 @@ Handle GitCommit::ParentId(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number n is required."))); } -const git_oid * result = git_commit_parent_id( + const git_oid * result = git_commit_parent_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -419,7 +419,7 @@ Handle GitCommit::NthGenAncestor(const Arguments& args) { } git_commit * ancestor; -int result = git_commit_nth_gen_ancestor( + int result = git_commit_nth_gen_ancestor( & ancestor diff --git a/src/index.cc b/src/index.cc index 051e070d0..48e4e69f8 100644 --- a/src/index.cc +++ b/src/index.cc @@ -140,7 +140,7 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { Handle GitIndex::Owner(const Arguments& args) { HandleScope scope; -git_repository * result = git_index_owner( + git_repository * result = git_index_owner( ObjectWrap::Unwrap(args.This())->GetValue() @@ -391,7 +391,7 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { Handle GitIndex::Entrycount(const Arguments& args) { HandleScope scope; -size_t result = git_index_entrycount( + size_t result = git_index_entrycount( ObjectWrap::Unwrap(args.This())->GetValue() @@ -404,7 +404,7 @@ size_t result = git_index_entrycount( Handle GitIndex::Clear(const Arguments& args) { HandleScope scope; -git_index_clear( + git_index_clear( ObjectWrap::Unwrap(args.This())->GetValue() @@ -425,7 +425,7 @@ Handle GitIndex::Remove(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } -int result = git_index_remove( + int result = git_index_remove( ObjectWrap::Unwrap(args.This())->GetValue() @@ -455,7 +455,7 @@ Handle GitIndex::RemoveDirectory(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } -int result = git_index_remove_directory( + int result = git_index_remove_directory( ObjectWrap::Unwrap(args.This())->GetValue() @@ -547,7 +547,7 @@ Handle GitIndex::RemoveBypath(const Arguments& args) { return ThrowException(Exception::Error(String::New("String path is required."))); } -int result = git_index_remove_bypath( + int result = git_index_remove_bypath( ObjectWrap::Unwrap(args.This())->GetValue() @@ -567,14 +567,14 @@ Handle GitIndex::Find(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return ThrowException(Exception::Error(String::New("size_t at_pos is required."))); + return ThrowException(Exception::Error(String::New("Number at_pos is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } -int result = git_index_find( + int result = git_index_find( (size_t *) args[0]->ToUint32()->Value() @@ -597,7 +597,7 @@ Handle GitIndex::ConflictRemove(const Arguments& args) { return ThrowException(Exception::Error(String::New("String path is required."))); } -int result = git_index_conflict_remove( + int result = git_index_conflict_remove( ObjectWrap::Unwrap(args.This())->GetValue() @@ -616,7 +616,7 @@ int result = git_index_conflict_remove( Handle GitIndex::ConflictCleanup(const Arguments& args) { HandleScope scope; -git_index_conflict_cleanup( + git_index_conflict_cleanup( ObjectWrap::Unwrap(args.This())->GetValue() @@ -629,7 +629,7 @@ git_index_conflict_cleanup( Handle GitIndex::HasConflicts(const Arguments& args) { HandleScope scope; -int result = git_index_has_conflicts( + int result = git_index_has_conflicts( ObjectWrap::Unwrap(args.This())->GetValue() diff --git a/src/object.cc b/src/object.cc index 48589948a..e3de4ca48 100644 --- a/src/object.cc +++ b/src/object.cc @@ -140,7 +140,7 @@ void GitObject::LookupAfterWork(uv_work_t *req) { Handle GitObject::Oid(const Arguments& args) { HandleScope scope; -const git_oid * result = git_object_id( + const git_oid * result = git_object_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -155,7 +155,7 @@ const git_oid * result = git_object_id( Handle GitObject::Type(const Arguments& args) { HandleScope scope; -git_otype result = git_object_type( + git_otype result = git_object_type( ObjectWrap::Unwrap(args.This())->GetValue() @@ -168,7 +168,7 @@ git_otype result = git_object_type( Handle GitObject::Owner(const Arguments& args) { HandleScope scope; -git_repository * result = git_object_owner( + git_repository * result = git_object_owner( ObjectWrap::Unwrap(args.This())->GetValue() diff --git a/src/oid.cc b/src/oid.cc index f8f1acd0d..458bfc270 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -65,7 +65,7 @@ Handle GitOid::FromString(const Arguments& args) { git_oid * out; out = (git_oid *)malloc(sizeof(git_oid)); -int result = git_oid_fromstr( + int result = git_oid_fromstr( out @@ -86,7 +86,7 @@ int result = git_oid_fromstr( Handle GitOid::Sha(const Arguments& args) { HandleScope scope; -char * result = git_oid_allocfmt( + char * result = git_oid_allocfmt( ObjectWrap::Unwrap(args.This())->GetValue() diff --git a/src/reference.cc b/src/reference.cc index 67199c1f8..40459d88e 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -234,7 +234,7 @@ Handle GitReference::CreateSymbolic(const Arguments& args) { } git_reference * out; -int result = git_reference_symbolic_create( + int result = git_reference_symbolic_create( & out @@ -281,7 +281,7 @@ Handle GitReference::Create(const Arguments& args) { } git_reference * out; -int result = git_reference_create( + int result = git_reference_create( & out @@ -311,7 +311,7 @@ int result = git_reference_create( Handle GitReference::Oid(const Arguments& args) { HandleScope scope; -const git_oid * result = git_reference_target( + const git_oid * result = git_reference_target( ObjectWrap::Unwrap(args.This())->GetValue() @@ -326,7 +326,7 @@ const git_oid * result = git_reference_target( Handle GitReference::Name(const Arguments& args) { HandleScope scope; -const char * result = git_reference_symbolic_target( + const char * result = git_reference_symbolic_target( ObjectWrap::Unwrap(args.This())->GetValue() @@ -339,7 +339,7 @@ const char * result = git_reference_symbolic_target( Handle GitReference::Type(const Arguments& args) { HandleScope scope; -git_ref_t result = git_reference_type( + git_ref_t result = git_reference_type( ObjectWrap::Unwrap(args.This())->GetValue() @@ -415,7 +415,7 @@ Handle GitReference::SetSymbolicTarget(const Arguments& args) { } git_reference * out; -int result = git_reference_symbolic_set_target( + int result = git_reference_symbolic_set_target( & out @@ -444,7 +444,7 @@ Handle GitReference::setTarget(const Arguments& args) { } git_reference * out; -int result = git_reference_set_target( + int result = git_reference_set_target( & out @@ -599,7 +599,7 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { Handle GitReference::IsBranch(const Arguments& args) { HandleScope scope; -int result = git_reference_is_branch( + int result = git_reference_is_branch( ObjectWrap::Unwrap(args.This())->GetValue() @@ -615,7 +615,7 @@ int result = git_reference_is_branch( Handle GitReference::IsRemote(const Arguments& args) { HandleScope scope; -int result = git_reference_is_remote( + int result = git_reference_is_remote( ObjectWrap::Unwrap(args.This())->GetValue() @@ -636,7 +636,7 @@ Handle GitReference::Peel(const Arguments& args) { } git_object * out; -int result = git_reference_peel( + int result = git_reference_peel( & out @@ -664,7 +664,7 @@ Handle GitReference::IsValidName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String refname is required."))); } -int result = git_reference_is_valid_name( + int result = git_reference_is_valid_name( stringArgToString(args[0]->ToString()).c_str() diff --git a/src/repo.cc b/src/repo.cc index 398aa2b16..2ff77d42f 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -195,7 +195,7 @@ void GitRepo::InitAfterWork(uv_work_t *req) { Handle GitRepo::Path(const Arguments& args) { HandleScope scope; -const char * result = git_repository_path( + const char * result = git_repository_path( ObjectWrap::Unwrap(args.This())->GetValue() @@ -208,7 +208,7 @@ const char * result = git_repository_path( Handle GitRepo::Workdir(const Arguments& args) { HandleScope scope; -const char * result = git_repository_workdir( + const char * result = git_repository_workdir( ObjectWrap::Unwrap(args.This())->GetValue() diff --git a/src/signature.cc b/src/signature.cc index 76344686f..10e01a8dd 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -71,7 +71,7 @@ Handle GitSignature::Now(const Arguments& args) { } git_signature * out; -int result = git_signature_now( + int result = git_signature_now( & out diff --git a/src/tag.cc b/src/tag.cc index 8b195734f..ede9668f0 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -142,7 +142,7 @@ void GitTag::LookupAfterWork(uv_work_t *req) { Handle GitTag::Oid(const Arguments& args) { HandleScope scope; -const git_oid * result = git_tag_id( + const git_oid * result = git_tag_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -215,7 +215,7 @@ void GitTag::TargetAfterWork(uv_work_t *req) { Handle GitTag::TargetId(const Arguments& args) { HandleScope scope; -const git_oid * result = git_tag_target_id( + const git_oid * result = git_tag_target_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -230,7 +230,7 @@ const git_oid * result = git_tag_target_id( Handle GitTag::TargetType(const Arguments& args) { HandleScope scope; -git_otype result = git_tag_target_type( + git_otype result = git_tag_target_type( ObjectWrap::Unwrap(args.This())->GetValue() @@ -243,7 +243,7 @@ git_otype result = git_tag_target_type( Handle GitTag::Name(const Arguments& args) { HandleScope scope; -const char * result = git_tag_name( + const char * result = git_tag_name( ObjectWrap::Unwrap(args.This())->GetValue() @@ -256,7 +256,7 @@ const char * result = git_tag_name( Handle GitTag::Tagger(const Arguments& args) { HandleScope scope; -const git_signature * result = git_tag_tagger( + const git_signature * result = git_tag_tagger( ObjectWrap::Unwrap(args.This())->GetValue() @@ -271,7 +271,7 @@ const git_signature * result = git_tag_tagger( Handle GitTag::Message(const Arguments& args) { HandleScope scope; -const char * result = git_tag_message( + const char * result = git_tag_message( ObjectWrap::Unwrap(args.This())->GetValue() @@ -476,7 +476,7 @@ Handle GitTag::Delete(const Arguments& args) { return ThrowException(Exception::Error(String::New("String tag_name is required."))); } -int result = git_tag_delete( + int result = git_tag_delete( ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() @@ -500,7 +500,7 @@ Handle GitTag::Peel(const Arguments& args) { } git_object * tag_target_out; -int result = git_tag_peel( + int result = git_tag_peel( & tag_target_out diff --git a/src/threads.cc b/src/threads.cc index 847e38e3a..c1ecd9640 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -1,54 +1,53 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#include +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" #include "../include/threads.h" -#include "../include/error.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -void GitThreads::Initialize(Handle target) { +void GitThreads::Initialize(Handle target) { HandleScope scope; - Local tpl = FunctionTemplate::New(New); + Persistent object = Persistent::New(Object::New()); - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(String::NewSymbol("Threads")); + object->Set(String::NewSymbol("init"), FunctionTemplate::New(Init)->GetFunction()); + object->Set(String::NewSymbol("shutdown"), FunctionTemplate::New(Shutdown)->GetFunction()); - NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init); - - constructor_template = Persistent::New(tpl->GetFunction()); - target->Set(String::NewSymbol("Threads"), constructor_template); + target->Set(String::NewSymbol("Threads"), object); } -Handle GitThreads::New(const Arguments& args) { + +Handle GitThreads::Init(const Arguments& args) { HandleScope scope; - GitThreads *threads = new GitThreads(); + int result = git_threads_init( + ); - threads->Wrap(args.This()); + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } - return scope.Close(args.This()); + return scope.Close(Int32::New(result)); } -Handle GitThreads::Init(const Arguments& args) { +Handle GitThreads::Shutdown(const Arguments& args) { HandleScope scope; - int returnCode = git_threads_init(); - if (returnCode) { - return GitError::WrapError(giterr_last()); - } - return True(); + git_threads_shutdown( + ); + + + return Undefined(); } -Persistent GitThreads::constructor_template; + diff --git a/src/tree.cc b/src/tree.cc index 72cb7fddc..ecca7d113 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -1,29 +1,22 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include -#include +#include -#include "cvv8/v8-convert.hpp" #include "git2.h" +#include "../include/tree.h" #include "../include/repo.h" #include "../include/oid.h" -#include "../include/tree.h" #include "../include/tree_entry.h" -#include "../include/error.h" -#include "../include/functions/string.h" #include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -using namespace cvv8; GitTree::GitTree(git_tree *raw) { this->raw = raw; @@ -33,7 +26,7 @@ GitTree::~GitTree() { git_tree_free(this->raw); } -void GitTree::Initialize (Handle target) { +void GitTree::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -42,17 +35,18 @@ void GitTree::Initialize (Handle target) { tpl->SetClassName(String::NewSymbol("Tree")); NODE_SET_METHOD(tpl, "lookup", Lookup); - NODE_SET_PROTOTYPE_METHOD(tpl, "walk", Walk); - NODE_SET_PROTOTYPE_METHOD(tpl, "entryByPath", EntryByPath); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "entryByName", EntryByName); + NODE_SET_PROTOTYPE_METHOD(tpl, "entryByIndex", EntryByIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "entryByOid", EntryByOid); + NODE_SET_PROTOTYPE_METHOD(tpl, "getEntryByPath", GetEntryByPath); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Tree"), constructor_template); } -git_tree* GitTree::GetValue() { - return this->raw; -} - Handle GitTree::New(const Arguments& args) { HandleScope scope; @@ -66,270 +60,239 @@ Handle GitTree::New(const Arguments& args) { return scope.Close(args.This()); } +git_tree *GitTree::GetValue() { + return this->raw; +} + + Handle GitTree::Lookup(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be a Object."))); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - - if(args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required and must be a Object."))); + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } LookupBaton* baton = new LookupBaton; - baton->request.data = baton; baton->error = NULL; - baton->rawOid = *ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->idReference = Persistent::New(args[1]); + baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); return Undefined(); } -void GitTree::LookupWork(uv_work_t* req) { - LookupBaton* baton = static_cast(req->data); - int returnCode = git_tree_lookup(&baton->rawTree, baton->rawRepo, &baton->rawOid); - if (returnCode != GIT_OK) { +void GitTree::LookupWork(uv_work_t *req) { + LookupBaton *baton = static_cast(req->data); + int out = git_tree_lookup( + &baton->out, + baton->repo, + baton->id + ); + if (out != GIT_OK) { baton->error = giterr_last(); } } -void GitTree::LookupAfterWork(uv_work_t* req) { - HandleScope scope; - LookupBaton* baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Handle argv[1] = { - External::New(baton->rawTree) - }; - Local tree = GitTree::constructor_template->NewInstance(1, argv); +void GitTree::LookupAfterWork(uv_work_t *req) { + HandleScope scope; + LookupBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle out = GitTree::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - tree + out }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -Handle GitTree::Walk(const Arguments& args) { +Handle GitTree::Oid(const Arguments& args) { HandleScope scope; - GitTree* tree = ObjectWrap::Unwrap(args.This()); + const git_oid * result = git_tree_id( - if (tree->GetValue() == NULL) { - return ThrowException(Exception::Error(String::New("No tree list to Walk."))); - } - if(args.Length() == 0 || !args[0]->IsBoolean()) { - return ThrowException(Exception::Error(String::New("Blobs only flag is required and must be a Boolean."))); - } + ObjectWrap::Unwrap(args.This())->GetValue() + ); - if(args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Entry callback is required and must be a Function."))); - } - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("End callback is required and must be a Function."))); - } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} - WalkBaton* baton = new WalkBaton; - uv_async_init(uv_default_loop(), &baton->asyncEntry, WalkWorkSendEntry); - uv_async_init(uv_default_loop(), &baton->asyncEnd, WalkWorkSendEnd); +Handle GitTree::Size(const Arguments& args) { + HandleScope scope; - uv_mutex_init(&baton->mutex); + size_t result = git_tree_entrycount( - baton->rawTree = tree->GetValue(); - baton->error = NULL; - baton->blobsOnly = CastFromJS(args[0]->ToBoolean()); - baton->entryCallback = Persistent::New(Local::Cast(args[1])); - baton->endCallback = Persistent::New(Local::Cast(args[2])); - uv_thread_create(&baton->threadId, WalkWork, baton); + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); -} -void GitTree::WalkWork(void* payload) { - WalkBaton *baton = static_cast(payload); - int returnCode = git_tree_walk(baton->rawTree, GIT_TREEWALK_PRE, WalkWorkEntry, payload); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); - return; - } + return scope.Close(Uint32::New(result)); +} - baton->asyncEntry.data = baton; - uv_async_send(&baton->asyncEntry); +Handle GitTree::EntryByName(const Arguments& args) { + HandleScope scope; - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); -} -int GitTree::WalkWorkEntry(const char* root, const git_tree_entry* entry, - void* payload) { - WalkBaton *baton = static_cast(payload); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String filename is required."))); + } - uv_mutex_lock(&baton->mutex); + const git_tree_entry * result = git_tree_entry_byname( - if (!baton->blobsOnly) { - GitTree::WalkEntry* walkEntry = new WalkEntry; - walkEntry->rawEntry = git_tree_entry_dup(entry); - walkEntry->root = root; - baton->rawTreeEntries.push_back(walkEntry); + ObjectWrap::Unwrap(args.This())->GetValue() +, - } else { - git_tree_entry* rawEntry = git_tree_entry_dup(entry); - git_filemode_t fileMode = git_tree_entry_filemode(rawEntry); + stringArgToString(args[0]->ToString()).c_str() + ); - if (fileMode == GIT_FILEMODE_BLOB || - fileMode == GIT_FILEMODE_BLOB_EXECUTABLE) { - GitTree::WalkEntry* walkEntry = new WalkEntry; - walkEntry->rawEntry = rawEntry; - walkEntry->root = root; - baton->rawTreeEntries.push_back(walkEntry); - } - } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); +} - uv_mutex_unlock(&baton->mutex); +Handle GitTree::EntryByIndex(const Arguments& args) { + HandleScope scope; - if ((unsigned int)baton->rawTreeEntries.size() == (unsigned int)GitTree::WALK_ENTRY_SEND_THRESHOLD) { - baton->asyncEntry.data = baton; - uv_async_send(&baton->asyncEntry); + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number idx is required."))); } - return GIT_OK; -} -void GitTree::WalkWorkSendEntry(uv_async_t *handle, int status /*UNUSED*/) { - HandleScope scope; + const git_tree_entry * result = git_tree_entry_byindex( - WalkBaton *baton = static_cast(handle->data); - uv_mutex_lock(&baton->mutex); + ObjectWrap::Unwrap(args.This())->GetValue() +, - if (success(baton->error, baton->entryCallback)) { + (size_t) args[0]->ToUint32()->Value() + ); - std::vector > treeEntries; - for(std::vector::iterator treeEntriesIterator = baton->rawTreeEntries.begin(); treeEntriesIterator != baton->rawTreeEntries.end(); ++treeEntriesIterator) { - WalkEntry* walkEntry = (*treeEntriesIterator); - - Handle argv[1] = { - External::New(walkEntry->rawEntry) - }; + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); +} - Local entry = GitTreeEntry::constructor_template->NewInstance(1, argv); +Handle GitTree::EntryByOid(const Arguments& args) { + HandleScope scope; - treeEntries.push_back(entry); - } + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid oid is required."))); + } - baton->rawTreeEntries.clear(); + const git_tree_entry * result = git_tree_entry_byoid( - Handle argv2[2] = { - Local::New(Null()), - CastToJS(treeEntries) - }; - TryCatch try_catch; - baton->entryCallback->Call(Context::GetCurrent()->Global(), 2, argv2); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - uv_mutex_unlock(&baton->mutex); -} -void GitTree::WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/) { - WalkBaton *baton = static_cast(handle->data); + ObjectWrap::Unwrap(args.This())->GetValue() +, - uv_mutex_destroy(&baton->mutex); - uv_close((uv_handle_t*) &baton->asyncEnd, NULL); - uv_close((uv_handle_t*) &baton->asyncEntry, NULL); + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); - } else { - argv[0] = Local::New(Null()); - } - TryCatch try_catch; - baton->endCallback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + // XXX need to copy object? + Handle argv[1] = { External::New((void *)result) }; + return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); } -Handle GitTree::EntryByPath(const Arguments& args) { +Handle GitTree::GetEntryByPath(const Arguments& args) { HandleScope scope; - if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("Path is required and must be a String."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); } - - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - EntryByPathBaton *baton = new EntryByPathBaton; - baton->request.data = baton; + GetEntryByPathBaton* baton = new GetEntryByPathBaton; baton->error = NULL; - baton->rawEntry = NULL; - - GitTree *tree = ObjectWrap::Unwrap(args.This()); - tree->Ref(); - - baton->rawTree = tree->GetValue(); - baton->path = stringArgToString(args[0]->ToString()); + baton->request.data = baton; + baton->rootReference = Persistent::New(args.This()); + baton->root = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->pathReference = Persistent::New(args[0]); + String::Utf8Value path(args[0]->ToString()); + baton->path = strdup(*path); baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, EntryByPathWork, (uv_after_work_cb)EntryByPathAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetEntryByPathWork, (uv_after_work_cb)GetEntryByPathAfterWork); return Undefined(); } -void GitTree::EntryByPathWork(uv_work_t *req) { - EntryByPathBaton *baton = static_cast(req->data); - int returnCode = git_tree_entry_bypath(&baton->rawEntry, baton->rawTree, baton->path.c_str()); - if (returnCode != GIT_OK) { +void GitTree::GetEntryByPathWork(uv_work_t *req) { + GetEntryByPathBaton *baton = static_cast(req->data); + int out = git_tree_entry_bypath( + &baton->out, + baton->root, + baton->path + ); + if (out != GIT_OK) { baton->error = giterr_last(); } } -void GitTree::EntryByPathAfterWork(uv_work_t *req) { - HandleScope scope; - EntryByPathBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Handle argv[1] = { - External::New(baton->rawEntry) - }; - Local entry = GitTreeEntry::constructor_template->NewInstance(1, argv); +void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { + HandleScope scope; + GetEntryByPathBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->out) }; + Handle out = GitTreeEntry::constructor_template->NewInstance(1, argv); Handle argv2[2] = { Local::New(Null()), - entry + out }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); } - delete req; + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->rootReference.Dispose(); + baton->pathReference.Dispose(); + baton->callback.Dispose(); + delete baton->path; + delete baton; } + Persistent GitTree::constructor_template; diff --git a/src/tree_entry.cc b/src/tree_entry.cc index acb546da8..31bfe8731 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -66,7 +66,7 @@ git_tree_entry *GitTreeEntry::GetValue() { Handle GitTreeEntry::Name(const Arguments& args) { HandleScope scope; -const char * result = git_tree_entry_name( + const char * result = git_tree_entry_name( ObjectWrap::Unwrap(args.This())->GetValue() @@ -79,7 +79,7 @@ const char * result = git_tree_entry_name( Handle GitTreeEntry::Oid(const Arguments& args) { HandleScope scope; -const git_oid * result = git_tree_entry_id( + const git_oid * result = git_tree_entry_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -94,7 +94,7 @@ const git_oid * result = git_tree_entry_id( Handle GitTreeEntry::Type(const Arguments& args) { HandleScope scope; -git_otype result = git_tree_entry_type( + git_otype result = git_tree_entry_type( ObjectWrap::Unwrap(args.This())->GetValue() @@ -107,7 +107,7 @@ git_otype result = git_tree_entry_type( Handle GitTreeEntry::filemode(const Arguments& args) { HandleScope scope; -git_filemode_t result = git_tree_entry_filemode( + git_filemode_t result = git_tree_entry_filemode( ObjectWrap::Unwrap(args.This())->GetValue() diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 28f5ea06d..7af24ac88 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -32,6 +32,7 @@ using namespace v8; using namespace node; +<% if (typeof cType != 'undefined') { -%> <%- cppClassName %>::<%- cppClassName %>(<%- cType %> *raw) { this->raw = raw; } @@ -94,6 +95,25 @@ Handle <%- cppClassName %>::New(const Arguments& args) { <%- cType %> *<%- cppClassName %>::GetValue() { return this->raw; } +<% } else { -%> +void <%- cppClassName %>::Initialize(Handle target) { + HandleScope scope; + + Persistent object = Persistent::New(Object::New()); + +<% if (typeof functions != 'undefined') { -%> +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> + object->Set(String::NewSymbol("<%- functionInfo.jsFunctionName %>"), FunctionTemplate::New(<%- functionInfo.cppFunctionName %>)->GetFunction()); +<% } -%> +<% } -%> + + target->Set(String::NewSymbol("<%- jsClassName %>"), object); +} +<% } -%> <% if (typeof functions != 'undefined') { -%> <% @@ -257,7 +277,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <% } -%> <% } -%> -<% if (result.cType != "void") { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( + <% if (result.cType != "void") { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( <% for (var i = 0, j = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; @@ -327,4 +347,6 @@ Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Argume <% } -%> <% } -%> +<% if (typeof cType != 'undefined') { -%> Persistent <%- cppClassName %>::constructor_template; +<% } -%> diff --git a/templates/header.h.ejs b/templates/header.h.ejs index 5431550fa..5fd02fc2c 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -20,11 +20,15 @@ class <%- cppClassName %> : public ObjectWrap { static Persistent constructor_template; static void Initialize (Handle target); +<% if (typeof cType != 'undefined') { -%> <%- cType %> *GetValue(); +<% } -%> private: +<% if (typeof cType != 'undefined') { -%> <%- cppClassName %>(<%- cType %> *raw); ~<%- cppClassName %>(); +<% } -%> static Handle New(const Arguments& args); @@ -68,7 +72,9 @@ class <%- cppClassName %> : public ObjectWrap { <% } -%> <% } -%> <% } -%> +<% if (typeof cType != 'undefined') { -%> <%- cType %> *raw; +<% } -%> }; #endif diff --git a/test/convenience-commit.js b/test/convenience-commit.js index 011eb8408..15cd9b79d 100644 --- a/test/convenience-commit.js +++ b/test/convenience-commit.js @@ -36,11 +36,8 @@ exports.method = function(test){ exports.message = function(test) { test.expect(3); - console.log(1) git.repo.open('../.git', function(error, repository) { - console.log(2, error, repository) repository.commit(historyCountKnownSHA, function(error, commit) { - console.log(3) var message = commit.message(); test.equals(error, null, 'There should be no error'); test.notEqual(message, null, 'Message should not be null'); @@ -247,14 +244,13 @@ exports.tree = function(test) { var commitTreeEntryCount = 0; var expectedCommitTreeEntryCount = 198; - commit.getTree(function(error, tree) { - tree.walk().on('entry', function(error, entry) { + tree.walk().on('entry', function(entry) { commitTreeEntryCount++; }).on('end', function(error, entries) { test.equals(commitTreeEntryCount, expectedCommitTreeEntryCount, 'Commit tree entry count does not match expected'); test.done(); - }); + }).start(); }); }); }); @@ -274,3 +270,8 @@ exports.parentsDiffTrees = function(test) { }); }); }; + +process.on('uncaughtException', function(err) { + console.log(err); +}); + diff --git a/test/convenience-tree.js b/test/convenience-tree.js index df1aa8d6b..f91d6ad34 100644 --- a/test/convenience-tree.js +++ b/test/convenience-tree.js @@ -12,15 +12,15 @@ exports.walk = function(test) { repo.commit(sha, function(error, commit) { var entryCount = 0; commit.getTree(function(error, tree) { - tree.walk().on('entry', function(error, index, entry) { + tree.walk().on('entry', function(index, entry) { test.equals(error, null, 'There should be no error'); entryCount++; - }).on('end', function(error, entries) { - test.equals(error, null, 'There should be no error'); + }).on('end', function(errors, entries) { + test.equals(errors, null, 'There should be no error'); test.equals(entryCount, fileCount, 'The manual tree entry count and the "end" tree entry count do not match'); test.equals(entries.length, fileCount, 'The end entries count and the manual entry count do not match'); test.done(); - }); + }).start(); }); }); }); diff --git a/v0.18.0.json b/v0.18.0.json index 28b6a43c8..ff1a59d0b 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -82,7 +82,7 @@ "name": "num_attr", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "names", @@ -275,7 +275,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -842,7 +842,7 @@ "name": "buffer_size", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "repo", @@ -902,7 +902,7 @@ "name": "buffer_size", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "repo", @@ -1149,7 +1149,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -1749,7 +1749,7 @@ "name": "length", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -1777,7 +1777,7 @@ "name": "length", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -1805,7 +1805,7 @@ "name": "length", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -2574,7 +2574,7 @@ "name": "map_n", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -2608,7 +2608,7 @@ "name": "map_n", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "value", @@ -3220,7 +3220,7 @@ "name": "idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -3302,19 +3302,19 @@ "name": "total_context", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "total_additions", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "total_deletions", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "patch", @@ -3353,13 +3353,13 @@ "name": "header_len", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "lines_in_hunk", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "patch", @@ -3371,7 +3371,7 @@ "name": "hunk_idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -3398,7 +3398,7 @@ "name": "hunk_idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -3431,7 +3431,7 @@ "name": "content_len", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "old_lineno", @@ -3455,13 +3455,13 @@ "name": "hunk_idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "line_of_hunk", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -3611,7 +3611,7 @@ "name": "buffer_len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "options", @@ -3745,13 +3745,13 @@ "name": "ahead", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "behind", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "repo", @@ -4220,7 +4220,7 @@ "name": "n", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -4450,7 +4450,7 @@ "name": "at_pos", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "index", @@ -4662,7 +4662,7 @@ "name": "at_pos", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "index", @@ -4731,7 +4731,7 @@ "name": "n", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -4824,7 +4824,7 @@ "name": "n", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -4929,7 +4929,7 @@ "name": "size", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "stats", @@ -5094,7 +5094,7 @@ "name": "length", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -5131,7 +5131,7 @@ "name": "out_size", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "message", @@ -5615,7 +5615,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "type", @@ -6108,7 +6108,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -6129,7 +6129,7 @@ "name": "len_out", "cType": "size_t *", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "type_out", @@ -6271,7 +6271,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "type", @@ -6311,7 +6311,7 @@ "name": "size", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "type", @@ -6425,7 +6425,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "type", @@ -6704,7 +6704,7 @@ "name": "length", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -6839,7 +6839,7 @@ "name": "n", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "id", @@ -6966,7 +6966,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -7040,7 +7040,7 @@ "name": "min_length", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -7962,7 +7962,7 @@ "name": "idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -7989,7 +7989,7 @@ "name": "idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "rewrite_previous_entry", @@ -9031,7 +9031,7 @@ "name": "outlen", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "spec", @@ -9071,7 +9071,7 @@ "name": "outlen", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "spec", @@ -10099,7 +10099,7 @@ "name": "path_size", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "start_path", @@ -10704,7 +10704,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" }, { "name": "repo", @@ -11823,7 +11823,7 @@ "name": "index", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, @@ -12793,7 +12793,7 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "ignore": true, @@ -13287,7 +13287,6 @@ "dependencies": [], "jsClassName": "Threads", "cppClassName": "GitThreads", - "cType": "git_threads", "functions": [ { "cFunctionName": "git_threads_init", @@ -13603,7 +13602,7 @@ { "name": "entry", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13616,7 +13615,7 @@ "cppFunctionName": "Dup", "return": { "cType": "git_tree_entry *", - "cppClassName": "TreeEntry" + "cppClassName": "GitTreeEntry" } }, { @@ -13625,7 +13624,7 @@ { "name": "entry", "cType": "git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13648,7 +13647,7 @@ { "name": "entry", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13669,7 +13668,7 @@ { "name": "entry", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13690,7 +13689,7 @@ { "name": "entry", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13711,7 +13710,7 @@ { "name": "entry", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13732,14 +13731,14 @@ { "name": "e1", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true }, { "name": "e2", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry" } ], @@ -13774,7 +13773,7 @@ { "name": "entry", "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry", "isSelf": true } @@ -13794,6 +13793,7 @@ }, { "filename": "tree.h", + "dependencies": ["../include/repo.h", "../include/oid.h", "../include/tree_entry.h"], "jsClassName": "Tree", "cppClassName": "GitTree", "cType": "git_tree", @@ -13822,7 +13822,7 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "lookup", @@ -13859,10 +13859,11 @@ "name": "len", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": true, "isPrototypeMethod": false, "jsFunctionName": "lookupPrefix", @@ -13883,6 +13884,7 @@ "jsClassName": "Tree" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -13926,6 +13928,7 @@ "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -13950,8 +13953,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "entrycount", - "cppFunctionName": "Entrycount", + "jsFunctionName": "size", + "cppFunctionName": "Size", "return": { "cType": "size_t", "cppClassName": "Uint32" @@ -13977,11 +13980,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "entryByname", - "cppFunctionName": "EntryByname", + "jsFunctionName": "entryByName", + "cppFunctionName": "EntryByName", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry" + "cppClassName": "GitTreeEntry" } }, { @@ -13998,17 +14001,17 @@ "name": "idx", "cType": "size_t", "cppClassName": "Uint32", - "jsClassName": "size_t" + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "entryByindex", - "cppFunctionName": "EntryByindex", + "jsFunctionName": "entryByIndex", + "cppFunctionName": "EntryByIndex", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry" + "cppClassName": "GitTreeEntry" } }, { @@ -14031,11 +14034,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "entryByoid", - "cppFunctionName": "EntryByoid", + "jsFunctionName": "entryByOid", + "cppFunctionName": "EntryByOid", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry" + "cppClassName": "GitTreeEntry" } }, { @@ -14045,14 +14048,15 @@ "name": "out", "isReturn": true, "cType": "git_tree_entry **", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry" }, { "name": "root", "cType": "git_tree *", "cppClassName": "GitTree", - "jsClassName": "Tree" + "jsClassName": "Tree", + "isSelf": true }, { "name": "path", @@ -14061,11 +14065,11 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "entryBypath", - "cppFunctionName": "EntryBypath", + "isPrototypeMethod": true, + "jsFunctionName": "getEntryByPath", + "cppFunctionName": "GetEntryByPath", "return": { "cType": "int", "cppClassName": "Int32", @@ -14089,6 +14093,7 @@ "jsClassName": "Tree" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14110,6 +14115,7 @@ "jsClassName": "Treebuilder" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14130,6 +14136,7 @@ "jsClassName": "Treebuilder" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14150,6 +14157,7 @@ "jsClassName": "Treebuilder" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14177,6 +14185,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14184,7 +14193,7 @@ "cppFunctionName": "GitTreebuilderGet", "return": { "cType": "const git_tree_entry *", - "cppClassName": "TreeEntry" + "cppClassName": "GitTreeEntry" } }, { @@ -14194,7 +14203,7 @@ "name": "out", "isReturn": true, "cType": "const git_tree_entry **", - "cppClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", "jsClassName": "TreeEntry" }, { @@ -14222,6 +14231,7 @@ "jsClassName": "FilemodeT" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14249,6 +14259,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14282,6 +14293,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -14314,7 +14326,8 @@ "jsClassName": "Treebuilder" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "jsFunctionName": "gitTreebuilderWrite", @@ -14354,7 +14367,8 @@ "jsClassName": "void" } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "walk", From 607ed27968f58d1e96d037b332662d5371874fea Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 24 Jun 2013 23:49:13 +0200 Subject: [PATCH 09/28] Typos --- example/raw-revwalk.js | 2 +- lib/tree.js | 5 ++--- v0.18.0.json | 33 +++++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/example/raw-revwalk.js b/example/raw-revwalk.js index 4a07747d6..25d6930d5 100644 --- a/example/raw-revwalk.js +++ b/example/raw-revwalk.js @@ -12,7 +12,7 @@ repo.open( path.resolve( '../.git' ), function( err ) { commit = new git.Commit( repo ); if( err ) { console.log( error.strError( err ) ); return; } - + oid.mkstr( '2a900f56b6dc6cc285b4d25b2407d9a3dfe76002' ); commit.lookup( repo, oid, function( err ) { diff --git a/lib/tree.js b/lib/tree.js index 65ff3ad55..78b0225ab 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -71,10 +71,9 @@ Tree.prototype.walk = function(blobsOnly) { function dfs(error, tree) { total--; - - var size = tree.rawTree.size(); if (error) return errors.push(error); + var size = tree.rawTree.size(); for (var i = 0; i < size; i ++) { var rawEntry = tree.rawTree.entryByIndex(i), entry = new git.entry(tree.repo, rawEntry); @@ -100,7 +99,7 @@ Tree.prototype.walk = function(blobsOnly) { event.emit('end', errors.length ? errors : null, entries); } - event.start = function(e) { + event.start = function() { dfs(null, self); }; diff --git a/v0.18.0.json b/v0.18.0.json index ff1a59d0b..cd581cbf9 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -11145,7 +11145,7 @@ { "filename": "revwalk.h", "jsClassName": "Revwalk", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "cType": "git_revwalk", "freeFunctionName": "git_revwalk_free", "functions": [ @@ -11156,7 +11156,7 @@ "name": "out", "isReturn": true, "cType": "git_revwalk **", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk" }, { @@ -11166,6 +11166,7 @@ "jsClassName": "Repository" } ], + "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, @@ -11183,7 +11184,7 @@ { "name": "walker", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true } @@ -11204,7 +11205,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11232,7 +11233,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11260,7 +11261,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true } @@ -11282,7 +11283,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11310,7 +11311,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11338,7 +11339,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true } @@ -11360,7 +11361,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11388,7 +11389,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11423,7 +11424,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk" } ], @@ -11444,7 +11445,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11471,7 +11472,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true }, @@ -11499,7 +11500,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk" } ], @@ -11520,7 +11521,7 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "Revwalk", + "cppClassName": "GitRevwalk", "jsClassName": "Revwalk", "isSelf": true } From d9ea5a6123736566593a52e726498f2ebf89393c Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Tue, 25 Jun 2013 15:38:46 +0200 Subject: [PATCH 10/28] Diff is now code-gen'd --- TODO | 6 +- binding.gyp | 6 + gen.js | 6 +- include/blob.h | 2 + include/commit.h | 2 + include/delta.h | 42 ++ include/diff.h | 109 +++ include/diff_file.h | 42 ++ include/diff_find_options.h | 37 + include/diff_list.h | 157 ++--- include/diff_options.h | 37 + include/diff_range.h | 41 ++ include/index.h | 2 + include/object.h | 2 + include/oid.h | 2 + include/patch.h | 44 ++ include/reference.h | 2 + include/repo.h | 2 + include/signature.h | 2 + include/tag.h | 2 + include/time.h | 2 + include/tree.h | 2 + include/tree_entry.h | 2 + include/wrapper.h | 1 + lib/commit.js | 24 +- lib/diff_list.js | 72 +- lib/patch.js | 11 + src/base.cc | 12 + src/blob.cc | 109 +-- src/commit.cc | 188 ++--- src/delta.cc | 124 ++++ src/diff.cc | 519 ++++++++++++++ src/diff_file.cc | 124 ++++ src/diff_find_options.cc | 64 ++ src/diff_list.cc | 726 ++++++++++---------- src/diff_options.cc | 64 ++ src/diff_range.cc | 112 +++ src/index.cc | 209 +++--- src/object.cc | 80 ++- src/oid.cc | 33 +- src/patch.cc | 261 +++++++ src/reference.cc | 295 ++++---- src/repo.cc | 69 +- src/signature.cc | 59 +- src/tag.cc | 182 ++--- src/threads.cc | 5 +- src/time.cc | 23 +- src/tree.cc | 119 ++-- src/tree_entry.cc | 61 +- src/wrapper.cc | 7 + templates/class.cc.ejs | 178 ++--- templates/convertToV8.cc.ejs | 10 + templates/guardArguments.cc.ejs | 13 + templates/header.h.ejs | 2 + test/convenience-commit.js | 2 +- test/convenience-difflist.js | 69 +- v0.18.0.json | 1140 ++++++++++++++++++------------- 57 files changed, 3719 insertions(+), 1799 deletions(-) create mode 100644 include/delta.h create mode 100644 include/diff.h create mode 100644 include/diff_file.h create mode 100644 include/diff_find_options.h create mode 100644 include/diff_options.h create mode 100644 include/diff_range.h create mode 100644 include/patch.h create mode 100644 lib/patch.js create mode 100644 src/delta.cc create mode 100644 src/diff.cc create mode 100644 src/diff_file.cc create mode 100644 src/diff_find_options.cc create mode 100644 src/diff_options.cc create mode 100644 src/diff_range.cc create mode 100644 src/patch.cc create mode 100644 templates/convertToV8.cc.ejs create mode 100644 templates/guardArguments.cc.ejs diff --git a/TODO b/TODO index 4ea714371..6bb651bb8 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,6 @@ - replace all argv crap with Wrap static methods for tighter instantiation -- audit memory issues - explicit malloc and frees, copies -- look into the v88 conversions crap - rename all async methods getXXX +- convert to "ignore": true for all classes +- reorder functions so the raw api is oo-like +- rename files remove .h +- remove stringArgToString invocation diff --git a/binding.gyp b/binding.gyp index d46bb9327..c843a8eed 100644 --- a/binding.gyp +++ b/binding.gyp @@ -18,7 +18,13 @@ 'src/time.cc', 'src/tree.cc', 'src/tree_entry.cc', + 'src/diff_find_options.cc', + 'src/diff_options.cc', 'src/diff_list.cc', + 'src/patch.cc', + 'src/delta.cc', + 'src/diff_file.cc', + 'src/diff_range.cc', 'src/threads.cc', 'src/wrapper.cc', 'src/functions/string.cc', diff --git a/gen.js b/gen.js index 0a19608d4..fb22567eb 100644 --- a/gen.js +++ b/gen.js @@ -3,12 +3,12 @@ var fs = require('fs'), path = require('path'); var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), - classTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/class.cc.ejs")).toString()), - headerTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/header.h.ejs")).toString()); + classTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/class.cc.ejs")).toString(), {filename: 'class.cc'}), + headerTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/header.h.ejs")).toString(), {filename: 'header.h'}); for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag", "Threads", "Tree"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag", "Threads", "Tree", "DiffList", "Patch", "Delta", "DiffOptions", "DiffFindOptions", "DiffFile", "DiffRange"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/blob.h b/include/blob.h index 058508ece..22455e8a0 100755 --- a/include/blob.h +++ b/include/blob.h @@ -22,6 +22,8 @@ class GitBlob : public ObjectWrap { git_blob *GetValue(); + static Handle New(void *raw); + private: GitBlob(git_blob *raw); ~GitBlob(); diff --git a/include/commit.h b/include/commit.h index 55520a11b..d09db5254 100755 --- a/include/commit.h +++ b/include/commit.h @@ -22,6 +22,8 @@ class GitCommit : public ObjectWrap { git_commit *GetValue(); + static Handle New(void *raw); + private: GitCommit(git_commit *raw); ~GitCommit(); diff --git a/include/delta.h b/include/delta.h new file mode 100644 index 000000000..e06f6283c --- /dev/null +++ b/include/delta.h @@ -0,0 +1,42 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDELTA_H +#define GITDELTA_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDelta : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_delta *GetValue(); + + static Handle New(void *raw); + + private: + GitDelta(git_diff_delta *raw); + ~GitDelta(); + + static Handle New(const Arguments& args); + + static Handle OldFile(const Arguments& args); + static Handle NewFile(const Arguments& args); + static Handle Status(const Arguments& args); + static Handle Similarity(const Arguments& args); + static Handle Flags(const Arguments& args); + + git_diff_delta *raw; +}; + +#endif diff --git a/include/diff.h b/include/diff.h new file mode 100644 index 000000000..677f22b50 --- /dev/null +++ b/include/diff.h @@ -0,0 +1,109 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFF_H +#define GITDIFF_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiff : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_list *GetValue(); + + private: + GitDiff(git_diff_list *raw); + ~GitDiff(); + + static Handle New(const Arguments& args); + + + static Handle TreeToTree(const Arguments& args); + static void TreeToTreeWork(uv_work_t* req); + static void TreeToTreeAfterWork(uv_work_t* req); + + struct TreeToTreeBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent new_treeReference; + git_tree * new_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle TreeToIndex(const Arguments& args); + static void TreeToIndexWork(uv_work_t* req); + static void TreeToIndexAfterWork(uv_work_t* req); + + struct TreeToIndexBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle IndexToWorkdir(const Arguments& args); + static void IndexToWorkdirWork(uv_work_t* req); + static void IndexToWorkdirAfterWork(uv_work_t* req); + + struct IndexToWorkdirBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle TreeToWorkdir(const Arguments& args); + static void TreeToWorkdirWork(uv_work_t* req); + static void TreeToWorkdirAfterWork(uv_work_t* req); + + struct TreeToWorkdirBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle Merge(const Arguments& args); + static Handle FindSimilar(const Arguments& args); + static Handle StatusChar(const Arguments& args); + static Handle NumDeltas(const Arguments& args); + static Handle NumDeltasOfType(const Arguments& args); + static Handle GetPatch(const Arguments& args); + git_diff_list *raw; +}; + +#endif diff --git a/include/diff_file.h b/include/diff_file.h new file mode 100644 index 000000000..f7f8210d0 --- /dev/null +++ b/include/diff_file.h @@ -0,0 +1,42 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFFILE_H +#define GITDIFFFILE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffFile : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_file *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffFile(git_diff_file *raw); + ~GitDiffFile(); + + static Handle New(const Arguments& args); + + static Handle Oid(const Arguments& args); + static Handle Path(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Flags(const Arguments& args); + static Handle Mode(const Arguments& args); + + git_diff_file *raw; +}; + +#endif diff --git a/include/diff_find_options.h b/include/diff_find_options.h new file mode 100644 index 000000000..3500d1b23 --- /dev/null +++ b/include/diff_find_options.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFFINDOPTIONS_H +#define GITDIFFFINDOPTIONS_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffFindOptions : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_find_options *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffFindOptions(git_diff_find_options *raw); + ~GitDiffFindOptions(); + + static Handle New(const Arguments& args); + + + git_diff_find_options *raw; +}; + +#endif diff --git a/include/diff_list.h b/include/diff_list.h index 26fe09a36..215ea0de5 100644 --- a/include/diff_list.h +++ b/include/diff_list.h @@ -1,121 +1,110 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFLIST_H +#define GITDIFFLIST_H #include #include -#include #include -#include #include "git2.h" -#include "repo.h" -#include "oid.h" - using namespace node; using namespace v8; -/** - * Class wrapper for libgit2 git_diff_list - */ class GitDiffList : public ObjectWrap { public: static Persistent constructor_template; - - static const int WALK_DELTA_SEND_THRESHHOLD = 10; - static void Initialize (Handle target); - git_diff_list* GetValue(); + git_diff_list *GetValue(); + + static Handle New(void *raw); - protected: + private: GitDiffList(git_diff_list *raw); ~GitDiffList(); static Handle New(const Arguments& args); - static Handle TreeToTree(const Arguments& args); - static void TreeToTreeWork(uv_work_t *req); - static void TreeToTreeAfterWork(uv_work_t *req); - - /** - * Walk the current git_diff_list - */ - static Handle Walk(const Arguments& args); - static void WalkWork(void *payload); - static int WalkWorkFile(const git_diff_delta *delta, float progress, - void *payload); - static int WalkWorkHunk(const git_diff_delta *delta, const git_diff_range *range, - const char *header, size_t header_len, void *payload); - static int WalkWorkData(const git_diff_delta *delta, /** delta that contains this data */ - const git_diff_range *range, /** range of lines containing this data */ - char line_origin, /** git_diff_list_t value from above */ - const char *content, /** diff data - not NUL terminated */ - size_t content_len, /** number of bytes of diff data */ - void *payload); /** user reference data */ - /** - * Called when WalkWorkFile reaches its cache - * thresholds. Passes data back to main thread - * - * @param payload The WalkBaton - */ - static void WalkWorkSendFile(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendHunk(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendData(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/); - private: - git_diff_list* raw; + static Handle TreeToTree(const Arguments& args); + static void TreeToTreeWork(uv_work_t* req); + static void TreeToTreeAfterWork(uv_work_t* req); struct TreeToTreeBaton { uv_work_t request; const git_error* error; - - GitDiffList *diffList; - git_repository* repo; - git_oid oldOid; - std::string oldSha; - git_oid newOid; - std::string newSha; - - git_diff_list* rawDiffList; - + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent new_treeReference; + git_tree * new_tree; + Persistent optsReference; + const git_diff_options * opts; Persistent callback; }; + static Handle TreeToIndex(const Arguments& args); + static void TreeToIndexWork(uv_work_t* req); + static void TreeToIndexAfterWork(uv_work_t* req); - struct DeltaContent { - git_diff_range *range; - char lineOrigin; - size_t contentLength; - std::string content; + struct TreeToIndexBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; }; + static Handle IndexToWorkdir(const Arguments& args); + static void IndexToWorkdirWork(uv_work_t* req); + static void IndexToWorkdirAfterWork(uv_work_t* req); - struct Delta { - git_diff_delta *raw; - std::vector contents; + struct IndexToWorkdirBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; }; + static Handle TreeToWorkdir(const Arguments& args); + static void TreeToWorkdirWork(uv_work_t* req); + static void TreeToWorkdirAfterWork(uv_work_t* req); - struct WalkBaton { - uv_thread_t threadId; - uv_mutex_t mutex; - uv_async_t asyncFile; - uv_async_t asyncHunk; - uv_async_t asyncData; - uv_async_t asyncEnd; - + struct TreeToWorkdirBaton { + uv_work_t request; const git_error* error; - - std::map fileDeltas; - - git_diff_list* rawDiffList; - Persistent fileCallback; - Persistent hunkCallback; - Persistent lineCallback; - Persistent endCallback; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; }; + static Handle Merge(const Arguments& args); + static Handle FindSimilar(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle NumDeltasOfType(const Arguments& args); + static Handle Patch(const Arguments& args); + git_diff_list *raw; }; + +#endif diff --git a/include/diff_options.h b/include/diff_options.h new file mode 100644 index 000000000..6dd93a0b8 --- /dev/null +++ b/include/diff_options.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFOPTIONS_H +#define GITDIFFOPTIONS_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffOptions : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_options *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffOptions(git_diff_options *raw); + ~GitDiffOptions(); + + static Handle New(const Arguments& args); + + + git_diff_options *raw; +}; + +#endif diff --git a/include/diff_range.h b/include/diff_range.h new file mode 100644 index 000000000..bb44337b4 --- /dev/null +++ b/include/diff_range.h @@ -0,0 +1,41 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFRANGE_H +#define GITDIFFRANGE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffRange : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_range *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffRange(git_diff_range *raw); + ~GitDiffRange(); + + static Handle New(const Arguments& args); + + static Handle OldStart(const Arguments& args); + static Handle OldLines(const Arguments& args); + static Handle NewStart(const Arguments& args); + static Handle NewLines(const Arguments& args); + + git_diff_range *raw; +}; + +#endif diff --git a/include/index.h b/include/index.h index 0b1a5a99a..1c5a925f8 100755 --- a/include/index.h +++ b/include/index.h @@ -22,6 +22,8 @@ class GitIndex : public ObjectWrap { git_index *GetValue(); + static Handle New(void *raw); + private: GitIndex(git_index *raw); ~GitIndex(); diff --git a/include/object.h b/include/object.h index f313a806b..a39873366 100644 --- a/include/object.h +++ b/include/object.h @@ -22,6 +22,8 @@ class GitObject : public ObjectWrap { git_object *GetValue(); + static Handle New(void *raw); + private: GitObject(git_object *raw); ~GitObject(); diff --git a/include/oid.h b/include/oid.h index 63107effa..2ce3a9e5c 100755 --- a/include/oid.h +++ b/include/oid.h @@ -22,6 +22,8 @@ class GitOid : public ObjectWrap { git_oid *GetValue(); + static Handle New(void *raw); + private: GitOid(git_oid *raw); ~GitOid(); diff --git a/include/patch.h b/include/patch.h new file mode 100644 index 000000000..7a4d408ff --- /dev/null +++ b/include/patch.h @@ -0,0 +1,44 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITPATCH_H +#define GITPATCH_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitPatch : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_patch *GetValue(); + + static Handle New(void *raw); + + private: + GitPatch(git_diff_patch *raw); + ~GitPatch(); + + static Handle New(const Arguments& args); + + + static Handle Delta(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Stats(const Arguments& args); + static Handle Hunk(const Arguments& args); + static Handle Lines(const Arguments& args); + static Handle Line(const Arguments& args); + static Handle ToString(const Arguments& args); + git_diff_patch *raw; +}; + +#endif diff --git a/include/reference.h b/include/reference.h index fa644ba46..d6a56c4d7 100644 --- a/include/reference.h +++ b/include/reference.h @@ -22,6 +22,8 @@ class GitReference : public ObjectWrap { git_reference *GetValue(); + static Handle New(void *raw); + private: GitReference(git_reference *raw); ~GitReference(); diff --git a/include/repo.h b/include/repo.h index a50978b6a..638323a48 100755 --- a/include/repo.h +++ b/include/repo.h @@ -22,6 +22,8 @@ class GitRepo : public ObjectWrap { git_repository *GetValue(); + static Handle New(void *raw); + private: GitRepo(git_repository *raw); ~GitRepo(); diff --git a/include/signature.h b/include/signature.h index bcabb51f2..de5883796 100755 --- a/include/signature.h +++ b/include/signature.h @@ -22,6 +22,8 @@ class GitSignature : public ObjectWrap { git_signature *GetValue(); + static Handle New(void *raw); + private: GitSignature(git_signature *raw); ~GitSignature(); diff --git a/include/tag.h b/include/tag.h index 2e56151ef..d0ad30fdb 100755 --- a/include/tag.h +++ b/include/tag.h @@ -22,6 +22,8 @@ class GitTag : public ObjectWrap { git_tag *GetValue(); + static Handle New(void *raw); + private: GitTag(git_tag *raw); ~GitTag(); diff --git a/include/time.h b/include/time.h index bccd3e316..b742a88b0 100644 --- a/include/time.h +++ b/include/time.h @@ -22,6 +22,8 @@ class GitTime : public ObjectWrap { git_time *GetValue(); + static Handle New(void *raw); + private: GitTime(git_time *raw); ~GitTime(); diff --git a/include/tree.h b/include/tree.h index c60aae9f0..6d0885a5e 100755 --- a/include/tree.h +++ b/include/tree.h @@ -22,6 +22,8 @@ class GitTree : public ObjectWrap { git_tree *GetValue(); + static Handle New(void *raw); + private: GitTree(git_tree *raw); ~GitTree(); diff --git a/include/tree_entry.h b/include/tree_entry.h index fb2ca4c74..49be3f46e 100755 --- a/include/tree_entry.h +++ b/include/tree_entry.h @@ -22,6 +22,8 @@ class GitTreeEntry : public ObjectWrap { git_tree_entry *GetValue(); + static Handle New(void *raw); + private: GitTreeEntry(git_tree_entry *raw); ~GitTreeEntry(); diff --git a/include/wrapper.h b/include/wrapper.h index 060699913..668a64465 100644 --- a/include/wrapper.h +++ b/include/wrapper.h @@ -18,6 +18,7 @@ class Wrapper : public ObjectWrap { static void Initialize (Handle target); void *GetValue(); + static Handle New(void *raw); private: Wrapper(void *raw); diff --git a/lib/commit.js b/lib/commit.js index ea69ad9f0..4fdf30c3a 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -209,20 +209,26 @@ Commit.prototype.parentsDiffTrees = function(callback) { * @param {DiffList[]|null} diffLists Array of DiffTrees showing changes between this commit and its parent(s) */ var self = this; - var commitSha = self.sha(); self.parents(function commitParents(error, parents) { if (!success(error, callback)) return; var parentDiffLists = []; parents.forEach(function commitEachParent(parent) { - var parentSha = parent.sha(); - git.diffList.treeToTree(self.repo, parentSha, commitSha, function walkDiffList(error, diffList) { - if (!success(error, callback)) return; - - parentDiffLists.push(diffList); - if (parentDiffLists.length === parents.length) { - callback(null, parentDiffLists); - } + parent.getTree(function(error, parentTree) { + if (!success(error, callback)) return; + + self.getTree(function(error, thisTree) { + if (!success(error, callback)) return; + + git.diffList.treeToTree(self.repo, parentTree, thisTree, function walkDiffList(error, diffList) { + if (!success(error, callback)) return; + + parentDiffLists.push(diffList); + if (parentDiffLists.length === parents.length) { + callback(null, parentDiffLists); + } + }); + }); }); }); }); diff --git a/lib/diff_list.js b/lib/diff_list.js index 5cf30f913..9e7de0f72 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -39,18 +39,18 @@ DiffList.Delta = { * @enum {String} */ DiffList.LineOrigin = { - /** ' ' */ Context: ' ', - /** '+' */ Addition: '+', - /** '-' */ Deletion: '-', - /** '\n' */ AddEofNl: '\n', - /** '' */ DelEofNl: '', - /** 'F' */ FileHdr: 'F', - /** 'H' */ HunkHdr: 'H', - /** 'B' */ Binary: 'B' + /** ' ' */ Context: 32, + /** '+' */ Addition: 43, + /** '-' */ Deletion: 45, + /** '\n' */ AddEofNl: 13, + /** '' */ DelEofNl: 0, + /** 'F' */ FileHdr: 106, + /** 'H' */ HunkHdr: 110, + /** 'B' */ Binary: 102 }; -DiffList.treeToTree = function(repo, oldSha, newSha, callback) { - git.raw.DiffList.treeToTree(repo.rawRepo, oldSha, newSha, function(error, rawDiffList) { +DiffList.treeToTree = function(repo, oldTree, newTree, callback) { + git.raw.DiffList.treeToTree(repo.rawRepo, oldTree.rawTree, newTree.rawTree, null, function(error, rawDiffList) { if (error) return callback(new git.error(error.message, error.code), null); callback(null, new DiffList(rawDiffList)); @@ -59,51 +59,17 @@ DiffList.treeToTree = function(repo, oldSha, newSha, callback) { /** - * Walk the current diff list tree. + * Retrieve patches * - * @fires DiffList#delta - * @fires DiffList#end - * - * @return {EventEmitter} diffListWalkEmitter + * @return {Array} patches */ -DiffList.prototype.walk = function() { - var event = new events.EventEmitter(), - allFileDeltas = [], - self = this; - - self.rawDiffList.walk(function fileCallback(error, fileDeltas) { - if (error) { - event.emit('end', new git.error(error.message, error.code), null); - } - fileDeltas.forEach(function(fileDelta) { - /** - * Delta event. - * - * @event DiffList#delta - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {FileDelta} fileDelta The file delta object. - */ - event.emit('delta', null, fileDelta); - allFileDeltas.push(fileDelta); - }); - }, function hunkCallback(error, diffHunk) { - /** TO BE IMPLEMENTED */ - }, function lineCallback(error, diffLine) { - /** TO BE IMPLEMENTED */ - }, function endCallback(error) { - /** - * End event. - * - * @event DiffList#end - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {FileDelta[]} fileDeltas The file delta objects. - */ - event.emit('end', error ? new git.error(error.message, error.code) : null, allFileDeltas); - }); - - return event; +DiffList.prototype.patches = function() { + var size = this.rawDiffList.size(); + result = []; + for (var i = 0; i < size; i++) { + result.push(this.rawDiffList.patch(i)); + } + return result; }; exports.diffList = DiffList; diff --git a/lib/patch.js b/lib/patch.js new file mode 100644 index 000000000..b6db577fb --- /dev/null +++ b/lib/patch.js @@ -0,0 +1,11 @@ +var git = require('../'), + success = require('./utilities').success; + +/** + * Convenience patch class. + * + * @constructor + */ +var Patch = function(rawPatch) { + this.rawPatch = rawPatch; +}; diff --git a/src/base.cc b/src/base.cc index 7fa7da0cb..ac49bd008 100755 --- a/src/base.cc +++ b/src/base.cc @@ -23,7 +23,13 @@ #include "../include/revwalk.h" #include "../include/tree.h" #include "../include/tree_entry.h" +#include "../include/diff_find_options.h" +#include "../include/diff_options.h" #include "../include/diff_list.h" +#include "../include/diff_range.h" +#include "../include/diff_file.h" +#include "../include/patch.h" +#include "../include/delta.h" #include "../include/threads.h" #include "../include/index.h" #include "../include/tag.h" @@ -50,7 +56,13 @@ extern "C" void init(Handle target) { GitTree::Initialize(target); GitTreeEntry::Initialize(target); + GitDiffRange::Initialize(target); + GitDiffFindOptions::Initialize(target); + GitDiffOptions::Initialize(target); GitDiffList::Initialize(target); + GitPatch::Initialize(target); + GitDiffFile::Initialize(target); + GitDelta::Initialize(target); GitThreads::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index 74ceb30a5..169322fdb 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -61,6 +61,12 @@ Handle GitBlob::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitBlob::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitBlob::constructor_template->NewInstance(1, argv)); +} + git_blob *GitBlob::GetValue() { return this->raw; } @@ -68,13 +74,14 @@ git_blob *GitBlob::GetValue() { Handle GitBlob::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -95,12 +102,12 @@ Handle GitBlob::Lookup(const Arguments& args) { void GitBlob::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int blob = git_blob_lookup( + int result = git_blob_lookup( &baton->blob, baton->repo, baton->id ); - if (blob != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -111,18 +118,19 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->blob) }; - Handle blob = GitBlob::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitBlob::New((void *)baton->blob); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - blob + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -136,56 +144,56 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_blob_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitBlob::Content(const Arguments& args) { HandleScope scope; + const void * result = git_blob_rawcontent( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); + Handle to; + to = Wrapper::New((void *)result); + return scope.Close(to); } Handle GitBlob::Size(const Arguments& args) { HandleScope scope; + git_off_t result = git_blob_rawsize( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Number::New(result)); + Handle to; + to = Number::New(result); + return scope.Close(to); } Handle GitBlob::CreateFromFile(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -207,12 +215,12 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { void GitBlob::CreateFromFileWork(uv_work_t *req) { CreateFromFileBaton *baton = static_cast(req->data); - int id = git_blob_create_fromdisk( + int result = git_blob_create_fromdisk( baton->id, baton->repo, baton->path ); - if (id != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -223,18 +231,19 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->id) }; - Handle id = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitOid::New((void *)baton->id); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - id + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -249,8 +258,8 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { Handle GitBlob::CreateFromBuffer(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -259,6 +268,7 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { if (args.Length() == 2 || !args[2]->IsNumber()) { return ThrowException(Exception::Error(String::New("Number len is required."))); } + if (args.Length() == 3 || !args[3]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -281,13 +291,13 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { void GitBlob::CreateFromBufferWork(uv_work_t *req) { CreateFromBufferBaton *baton = static_cast(req->data); - int oid = git_blob_create_frombuffer( + int result = git_blob_create_frombuffer( baton->oid, baton->repo, baton->buffer, baton->len ); - if (oid != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -298,18 +308,19 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->oid) }; - Handle oid = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitOid::New((void *)baton->oid); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - oid + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -324,10 +335,9 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; + int result = git_blob_is_binary( - - ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -335,8 +345,7 @@ Handle GitBlob::IsBinary(const Arguments& args) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Boolean::New(result)); + return Undefined(); } - Persistent GitBlob::constructor_template; diff --git a/src/commit.cc b/src/commit.cc index 15a2323b3..7d931c645 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -68,6 +68,12 @@ Handle GitCommit::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitCommit::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitCommit::constructor_template->NewInstance(1, argv)); +} + git_commit *GitCommit::GetValue() { return this->raw; } @@ -75,13 +81,14 @@ git_commit *GitCommit::GetValue() { Handle GitCommit::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -102,12 +109,12 @@ Handle GitCommit::Lookup(const Arguments& args) { void GitCommit::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int commit = git_commit_lookup( + int result = git_commit_lookup( &baton->commit, baton->repo, baton->id ); - if (commit != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -118,18 +125,19 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->commit) }; - Handle commit = GitCommit::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitCommit::New((void *)baton->commit); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - commit + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -143,104 +151,106 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_commit_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitCommit::MessageEncoding(const Arguments& args) { HandleScope scope; + const char * result = git_commit_message_encoding( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitCommit::Message(const Arguments& args) { HandleScope scope; + const char * result = git_commit_message( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitCommit::Time(const Arguments& args) { HandleScope scope; + git_time_t result = git_commit_time( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Number::New(result)); + Handle to; + to = Number::New(result); + return scope.Close(to); } Handle GitCommit::Offset(const Arguments& args) { HandleScope scope; + int result = git_commit_time_offset( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Integer::New(result)); + Handle to; + to = Integer::New(result); + return scope.Close(to); } Handle GitCommit::Committer(const Arguments& args) { HandleScope scope; + const git_signature * result = git_commit_committer( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitSignature::New((void *)result); + return scope.Close(to); } Handle GitCommit::Author(const Arguments& args) { HandleScope scope; + const git_signature * result = git_commit_author( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitSignature::New((void *)result); + return scope.Close(to); } Handle GitCommit::Tree(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -259,11 +269,11 @@ Handle GitCommit::Tree(const Arguments& args) { void GitCommit::TreeWork(uv_work_t *req) { TreeBaton *baton = static_cast(req->data); - int tree_out = git_commit_tree( + int result = git_commit_tree( &baton->tree_out, baton->commit ); - if (tree_out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -274,18 +284,19 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->tree_out) }; - Handle tree_out = GitTree::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitTree::New((void *)baton->tree_out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - tree_out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -298,38 +309,39 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; + const git_oid * result = git_commit_tree_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitCommit::ParentCount(const Arguments& args) { HandleScope scope; + unsigned int result = git_commit_parentcount( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Uint32::New(result)); + Handle to; + to = Uint32::New(result); + return scope.Close(to); } Handle GitCommit::Parent(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsUint32()) { + + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number n is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -350,12 +362,12 @@ Handle GitCommit::Parent(const Arguments& args) { void GitCommit::ParentWork(uv_work_t *req) { ParentBaton *baton = static_cast(req->data); - int out = git_commit_parent( + int result = git_commit_parent( &baton->out, baton->commit, baton->n ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -366,18 +378,19 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitCommit::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitCommit::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -391,54 +404,43 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { Handle GitCommit::ParentId(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsUint32()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number n is required."))); } - const git_oid * result = git_commit_parent_id( - + const git_oid * result = git_commit_parent_id( ObjectWrap::Unwrap(args.This())->GetValue() -, - - (unsigned int) args[0]->ToUint32()->Value() + , (unsigned int) args[0]->ToUint32()->Value() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitCommit::NthGenAncestor(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsUint32()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number n is required."))); } - git_commit * ancestor; - - int result = git_commit_nth_gen_ancestor( -& - ancestor -, + git_commit *ancestor = NULL; - ObjectWrap::Unwrap(args.This())->GetValue() -, - - (unsigned int) args[0]->ToUint32()->Value() + int result = git_commit_nth_gen_ancestor( + &ancestor + , ObjectWrap::Unwrap(args.This())->GetValue() + , (unsigned int) args[0]->ToUint32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)ancestor) }; - return scope.Close(GitCommit::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitCommit::New((void *)ancestor); + return scope.Close(to); } - Persistent GitCommit::constructor_template; diff --git a/src/delta.cc b/src/delta.cc new file mode 100644 index 000000000..7aad77a5a --- /dev/null +++ b/src/delta.cc @@ -0,0 +1,124 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/delta.h" +#include "../include/diff_file.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDelta::GitDelta(git_diff_delta *raw) { + this->raw = raw; +} + +GitDelta::~GitDelta() { +} + +void GitDelta::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Delta")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "oldFile", OldFile); + NODE_SET_PROTOTYPE_METHOD(tpl, "newFile", NewFile); + NODE_SET_PROTOTYPE_METHOD(tpl, "status", Status); + NODE_SET_PROTOTYPE_METHOD(tpl, "similarity", Similarity); + NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Delta"), constructor_template); +} + +Handle GitDelta::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_delta is required."))); + } + + GitDelta* object = new GitDelta((git_diff_delta *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDelta::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDelta::constructor_template->NewInstance(1, argv)); +} + +git_diff_delta *GitDelta::GetValue() { + return this->raw; +} + + +Handle GitDelta::OldFile(const Arguments& args) { + HandleScope scope; + Handle to; + + git_diff_file *old_file = + &ObjectWrap::Unwrap(args.This())->GetValue()->old_file; + + to = GitDiffFile::New((void *)old_file); + return scope.Close(to); +} + +Handle GitDelta::NewFile(const Arguments& args) { + HandleScope scope; + Handle to; + + git_diff_file *new_file = + &ObjectWrap::Unwrap(args.This())->GetValue()->new_file; + + to = GitDiffFile::New((void *)new_file); + return scope.Close(to); +} + +Handle GitDelta::Status(const Arguments& args) { + HandleScope scope; + Handle to; + + git_delta_t status = + ObjectWrap::Unwrap(args.This())->GetValue()->status; + + to = Integer::New(status); + return scope.Close(to); +} + +Handle GitDelta::Similarity(const Arguments& args) { + HandleScope scope; + Handle to; + + uint32_t similarity = + ObjectWrap::Unwrap(args.This())->GetValue()->similarity; + + to = Integer::New(similarity); + return scope.Close(to); +} + +Handle GitDelta::Flags(const Arguments& args) { + HandleScope scope; + Handle to; + + uint32_t flags = + ObjectWrap::Unwrap(args.This())->GetValue()->flags; + + to = Integer::New(flags); + return scope.Close(to); +} + +Persistent GitDelta::constructor_template; diff --git a/src/diff.cc b/src/diff.cc new file mode 100644 index 000000000..2573941ef --- /dev/null +++ b/src/diff.cc @@ -0,0 +1,519 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/diff.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDiff::GitDiff(git_diff_list *raw) { + this->raw = raw; +} + +GitDiff::~GitDiff() { + git_diff_list_free(this->raw); +} + +void GitDiff::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Diff")); + + NODE_SET_METHOD(tpl, "treeToTree", TreeToTree); + NODE_SET_METHOD(tpl, "treeToIndex", TreeToIndex); + NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); + NODE_SET_METHOD(tpl, "treeToWorkdir", TreeToWorkdir); + NODE_SET_PROTOTYPE_METHOD(tpl, "merge", Merge); + NODE_SET_PROTOTYPE_METHOD(tpl, "findSimilar", FindSimilar); + NODE_SET_METHOD(tpl, "statusChar", StatusChar); + NODE_SET_PROTOTYPE_METHOD(tpl, "numDeltas", NumDeltas); + NODE_SET_METHOD(tpl, "numDeltasOfType", NumDeltasOfType); + NODE_SET_PROTOTYPE_METHOD(tpl, "getPatch", GetPatch); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Diff"), constructor_template); +} + +Handle GitDiff::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_list is required."))); + } + + GitDiff* object = new GitDiff((git_diff_list *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +git_diff_list *GitDiff::GetValue() { + return this->raw; +} + + +Handle GitDiff::TreeToTree(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TreeToTreeBaton* baton = new TreeToTreeBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->new_treeReference = Persistent::New(args[2]); + baton->new_tree = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[3]); + baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[4])); + + uv_queue_work(uv_default_loop(), &baton->request, TreeToTreeWork, (uv_after_work_cb)TreeToTreeAfterWork); + + return Undefined(); +} + +void GitDiff::TreeToTreeWork(uv_work_t *req) { + TreeToTreeBaton *baton = static_cast(req->data); + int diff = git_diff_tree_to_tree( + &baton->diff, + baton->repo, + baton->old_tree, + baton->new_tree, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::TreeToTreeAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->new_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::TreeToIndex(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TreeToIndexBaton* baton = new TreeToIndexBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->indexReference = Persistent::New(args[2]); + baton->index = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[3]); + baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[4])); + + uv_queue_work(uv_default_loop(), &baton->request, TreeToIndexWork, (uv_after_work_cb)TreeToIndexAfterWork); + + return Undefined(); +} + +void GitDiff::TreeToIndexWork(uv_work_t *req) { + TreeToIndexBaton *baton = static_cast(req->data); + int diff = git_diff_tree_to_index( + &baton->diff, + baton->repo, + baton->old_tree, + baton->index, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::TreeToIndexAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::IndexToWorkdir(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->indexReference = Persistent::New(args[1]); + baton->index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[2]); + baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); + + return Undefined(); +} + +void GitDiff::IndexToWorkdirWork(uv_work_t *req) { + IndexToWorkdirBaton *baton = static_cast(req->data); + int diff = git_diff_index_to_workdir( + &baton->diff, + baton->repo, + baton->index, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::IndexToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + IndexToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::TreeToWorkdir(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TreeToWorkdirBaton* baton = new TreeToWorkdirBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[2]); + baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, TreeToWorkdirWork, (uv_after_work_cb)TreeToWorkdirAfterWork); + + return Undefined(); +} + +void GitDiff::TreeToWorkdirWork(uv_work_t *req) { + TreeToWorkdirBaton *baton = static_cast(req->data); + int diff = git_diff_tree_to_workdir( + &baton->diff, + baton->repo, + baton->old_tree, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::TreeToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::Merge(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList from is required."))); + } + + int result = git_diff_merge( + + + ObjectWrap::Unwrap(args.This())->GetValue() +, + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + return scope.Close(Int32::New(result)); +} + +Handle GitDiff::FindSimilar(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffFindOptions options is required."))); + } + + int result = git_diff_find_similar( + + + ObjectWrap::Unwrap(args.This())->GetValue() +, + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + return scope.Close(Int32::New(result)); +} + +Handle GitDiff::StatusChar(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number status is required."))); + } + + char result = git_diff_status_char( + + + (git_delta_t) args[0]->ToInt32()->Value() + ); + + + return scope.Close(String::New(result)); +} + +Handle GitDiff::NumDeltas(const Arguments& args) { + HandleScope scope; + + size_t result = git_diff_num_deltas( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return scope.Close(Uint32::New(result)); +} + +Handle GitDiff::NumDeltasOfType(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList diff is required."))); + } + + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + size_t result = git_diff_num_deltas_of_type( + + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + + (git_delta_t) args[1]->ToInt32()->Value() + ); + + + return scope.Close(Uint32::New(result)); +} + +Handle GitDiff::GetPatch(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffDelta delta_out is required."))); + } + + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number idx is required."))); + } + git_diff_patch * patch_out; + + int result = git_diff_get_patch( + +& + patch_out +, +& + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + + ObjectWrap::Unwrap(args.This())->GetValue() +, + + (size_t) args[1]->ToUint32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)patch_out) }; + return scope.Close(DiffPatch::constructor_template->NewInstance(1, argv)); +} + + +Persistent GitDiff::constructor_template; diff --git a/src/diff_file.cc b/src/diff_file.cc new file mode 100644 index 000000000..b3e5f589a --- /dev/null +++ b/src/diff_file.cc @@ -0,0 +1,124 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/diff_file.h" +#include "../include/oid.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDiffFile::GitDiffFile(git_diff_file *raw) { + this->raw = raw; +} + +GitDiffFile::~GitDiffFile() { +} + +void GitDiffFile::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffFile")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); + NODE_SET_PROTOTYPE_METHOD(tpl, "mode", Mode); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffFile"), constructor_template); +} + +Handle GitDiffFile::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_file is required."))); + } + + GitDiffFile* object = new GitDiffFile((git_diff_file *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffFile::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffFile::constructor_template->NewInstance(1, argv)); +} + +git_diff_file *GitDiffFile::GetValue() { + return this->raw; +} + + +Handle GitDiffFile::Oid(const Arguments& args) { + HandleScope scope; + Handle to; + + git_oid *oid = + &ObjectWrap::Unwrap(args.This())->GetValue()->oid; + + to = GitOid::New((void *)oid); + return scope.Close(to); +} + +Handle GitDiffFile::Path(const Arguments& args) { + HandleScope scope; + Handle to; + + const char * path = + ObjectWrap::Unwrap(args.This())->GetValue()->path; + + to = String::New(path); + return scope.Close(to); +} + +Handle GitDiffFile::Size(const Arguments& args) { + HandleScope scope; + Handle to; + + git_off_t size = + ObjectWrap::Unwrap(args.This())->GetValue()->size; + + to = Integer::New(size); + return scope.Close(to); +} + +Handle GitDiffFile::Flags(const Arguments& args) { + HandleScope scope; + Handle to; + + uint32_t flags = + ObjectWrap::Unwrap(args.This())->GetValue()->flags; + + to = Integer::New(flags); + return scope.Close(to); +} + +Handle GitDiffFile::Mode(const Arguments& args) { + HandleScope scope; + Handle to; + + uint16_t mode = + ObjectWrap::Unwrap(args.This())->GetValue()->mode; + + to = Integer::New(mode); + return scope.Close(to); +} + +Persistent GitDiffFile::constructor_template; diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc new file mode 100644 index 000000000..d4cebc759 --- /dev/null +++ b/src/diff_find_options.cc @@ -0,0 +1,64 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/diff_find_options.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDiffFindOptions::GitDiffFindOptions(git_diff_find_options *raw) { + this->raw = raw; +} + +GitDiffFindOptions::~GitDiffFindOptions() { + free(this->raw); +} + +void GitDiffFindOptions::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffFindOptions")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffFindOptions"), constructor_template); +} + +Handle GitDiffFindOptions::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_find_options is required."))); + } + + GitDiffFindOptions* object = new GitDiffFindOptions((git_diff_find_options *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffFindOptions::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffFindOptions::constructor_template->NewInstance(1, argv)); +} + +git_diff_find_options *GitDiffFindOptions::GetValue() { + return this->raw; +} + + +Persistent GitDiffFindOptions::constructor_template; diff --git a/src/diff_list.cc b/src/diff_list.cc index 38607dcf2..1870baf93 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -1,25 +1,26 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include -#include "cvv8/v8-convert.hpp" #include "git2.h" #include "../include/diff_list.h" -#include "../include/error.h" +#include "../include/diff_options.h" +#include "../include/diff_find_options.h" +#include "../include/repo.h" +#include "../include/tree.h" +#include "../include/index.h" +#include "../include/patch.h" +#include "../include/delta.h" -#include "../include/functions/string.h" #include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -using namespace cvv8; GitDiffList::GitDiffList(git_diff_list *raw) { this->raw = raw; @@ -29,12 +30,7 @@ GitDiffList::~GitDiffList() { git_diff_list_free(this->raw); } -namespace cvv8 { - template <> - struct NativeToJS : NativeToJS {}; -} - -void GitDiffList::Initialize(Handle target) { +void GitDiffList::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -43,74 +39,20 @@ void GitDiffList::Initialize(Handle target) { tpl->SetClassName(String::NewSymbol("DiffList")); NODE_SET_METHOD(tpl, "treeToTree", TreeToTree); - NODE_SET_PROTOTYPE_METHOD(tpl, "walk", Walk); - - // Add libgit2 delta types to diff_list object - Local libgit2DeltaTypes = Object::New(); - - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_UNMODIFIED"), cvv8::CastToJS(GIT_DELTA_UNMODIFIED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_ADDED"), cvv8::CastToJS(GIT_DELTA_ADDED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_DELETED"), cvv8::CastToJS(GIT_DELTA_DELETED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_MODIFIED"), cvv8::CastToJS(GIT_DELTA_MODIFIED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_RENAMED"), cvv8::CastToJS(GIT_DELTA_RENAMED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_COPIED"), cvv8::CastToJS(GIT_DELTA_COPIED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_IGNORED"), cvv8::CastToJS(GIT_DELTA_IGNORED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_UNTRACKED"), cvv8::CastToJS(GIT_DELTA_UNTRACKED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_TYPECHANGE"), cvv8::CastToJS(GIT_DELTA_TYPECHANGE), ReadOnly); - - Local libgit2LineOriginConstants = Object::New(); - - // @todo refactor this into something sane - char _GIT_DIFF_LINE_CONTEXT[2]; - _GIT_DIFF_LINE_CONTEXT[0] = GIT_DIFF_LINE_CONTEXT; - _GIT_DIFF_LINE_CONTEXT[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_CONTEXT"), cvv8::CastToJS(_GIT_DIFF_LINE_CONTEXT), ReadOnly); - - char _GIT_DIFF_LINE_ADDITION[2]; - _GIT_DIFF_LINE_ADDITION[0] = GIT_DIFF_LINE_ADDITION; - _GIT_DIFF_LINE_ADDITION[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_ADDITION"), cvv8::CastToJS(_GIT_DIFF_LINE_ADDITION), ReadOnly); - - char _GIT_DIFF_LINE_DELETION[2]; - _GIT_DIFF_LINE_DELETION[0] = GIT_DIFF_LINE_DELETION; - _GIT_DIFF_LINE_DELETION[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_DELETION"), cvv8::CastToJS(_GIT_DIFF_LINE_DELETION), ReadOnly); - - char _GIT_DIFF_LINE_ADD_EOFNL[2]; - _GIT_DIFF_LINE_ADD_EOFNL[0] = GIT_DIFF_LINE_ADD_EOFNL; - _GIT_DIFF_LINE_ADD_EOFNL[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_ADD_EOFNL"), cvv8::CastToJS(_GIT_DIFF_LINE_ADD_EOFNL), ReadOnly); - - char _GIT_DIFF_LINE_DEL_EOFNL[2]; - _GIT_DIFF_LINE_DEL_EOFNL[0] = GIT_DIFF_LINE_DEL_EOFNL; - _GIT_DIFF_LINE_DEL_EOFNL[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_DEL_EOFNL"), cvv8::CastToJS(_GIT_DIFF_LINE_DEL_EOFNL), ReadOnly); - - char _GIT_DIFF_LINE_FILE_HDR[2]; - _GIT_DIFF_LINE_FILE_HDR[0] = GIT_DIFF_LINE_FILE_HDR; - _GIT_DIFF_LINE_FILE_HDR[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_FILE_HDR"), cvv8::CastToJS(_GIT_DIFF_LINE_FILE_HDR), ReadOnly); - - char _GIT_DIFF_LINE_HUNK_HDR[2]; - _GIT_DIFF_LINE_HUNK_HDR[0] = GIT_DIFF_LINE_HUNK_HDR; - _GIT_DIFF_LINE_HUNK_HDR[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_HUNK_HDR"), cvv8::CastToJS(_GIT_DIFF_LINE_HUNK_HDR), ReadOnly); - - char _GIT_DIFF_LINE_BINARY[2]; - _GIT_DIFF_LINE_BINARY[0] = GIT_DIFF_LINE_BINARY; - _GIT_DIFF_LINE_BINARY[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_BINARY"), cvv8::CastToJS(_GIT_DIFF_LINE_BINARY), ReadOnly); + NODE_SET_METHOD(tpl, "treeToIndex", TreeToIndex); + NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); + NODE_SET_METHOD(tpl, "treeToWorkdir", TreeToWorkdir); + NODE_SET_PROTOTYPE_METHOD(tpl, "merge", Merge); + NODE_SET_PROTOTYPE_METHOD(tpl, "findSimilar", FindSimilar); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_METHOD(tpl, "numDeltasOfType", NumDeltasOfType); + NODE_SET_PROTOTYPE_METHOD(tpl, "patch", Patch); + constructor_template = Persistent::New(tpl->GetFunction()); - constructor_template->Set(String::NewSymbol("deltaTypes"), libgit2DeltaTypes, ReadOnly); - constructor_template->Set(String::NewSymbol("lineOriginTypes"), libgit2LineOriginConstants, ReadOnly); target->Set(String::NewSymbol("DiffList"), constructor_template); } -git_diff_list* GitDiffList::GetValue() { - return this->raw; -} - Handle GitDiffList::New(const Arguments& args) { HandleScope scope; @@ -124,43 +66,50 @@ Handle GitDiffList::New(const Arguments& args) { return scope.Close(args.This()); } -Handle GitDiffList::TreeToTree(const Arguments& args) { +Handle GitDiffList::New(void *raw) { HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffList::constructor_template->NewInstance(1, argv)); +} - if(args.Length() == 0 || !(args[0]->IsObject() || args[0]->IsString())) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object or String"))); - } +git_diff_list *GitDiffList::GetValue() { + return this->raw; +} - if(args.Length() == 1 || !(args[1]->IsObject() || args[1]->IsString())) { - return ThrowException(Exception::Error(String::New("Old Oid/SHA is required and must be an Object or String"))); - } - if(args.Length() == 2 || !(args[2]->IsObject() || args[2]->IsString())) { - return ThrowException(Exception::Error(String::New("New Oid/SHA is required and must be an Object or String"))); +Handle GitDiffList::TreeToTree(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); } - if(args.Length() == 3 || !args[3]->IsFunction()) { + if (args.Length() == 4 || !args[4]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - TreeToTreeBaton *baton = new TreeToTreeBaton; - baton->request.data = baton; + TreeToTreeBaton* baton = new TreeToTreeBaton; baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - if (args[1]->IsObject()) { - baton->oldOid = *ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->new_treeReference = Persistent::New(args[2]); + baton->new_tree = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[3]); + if (args[3]->IsObject()) { + baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); } else { - baton->oldSha = stringArgToString(args[1]->ToString()); + baton->opts = NULL; } - - if (args[2]->IsObject()) { - baton->newOid = *ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - baton->newSha = stringArgToString(args[2]->ToString()); - } - - baton->callback = Persistent::New(Local::Cast(args[3])); + baton->callback = Persistent::New(Local::Cast(args[4])); uv_queue_work(uv_default_loop(), &baton->request, TreeToTreeWork, (uv_after_work_cb)TreeToTreeAfterWork); @@ -169,331 +118,390 @@ Handle GitDiffList::TreeToTree(const Arguments& args) { void GitDiffList::TreeToTreeWork(uv_work_t *req) { TreeToTreeBaton *baton = static_cast(req->data); - - // Prepare git_oid's - git_oid *oldOid = &baton->oldOid; - if (!baton->oldSha.empty()) { - int returnCode = git_oid_fromstr(oldOid, baton->oldSha.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - } - git_oid *newOid = &baton->newOid; - if (!baton->newSha.empty()) { - int returnCode = git_oid_fromstr(newOid, baton->newSha.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - } - - // Get commits - git_commit* oldCommit = NULL; - int returnCode = git_commit_lookup(&oldCommit, baton->repo, oldOid); - if (returnCode != GIT_OK) { + int result = git_diff_tree_to_tree( + &baton->diff, + baton->repo, + baton->old_tree, + baton->new_tree, + baton->opts + ); + if (result != GIT_OK) { baton->error = giterr_last(); - return; } +} - git_commit* newCommit = NULL; - returnCode = git_commit_lookup(&newCommit, baton->repo, newOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } +void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToTreeBaton *baton = static_cast(req->data); - // Prepare trees - git_tree* oldTree = NULL; - returnCode = git_commit_tree(&oldTree, oldCommit); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - git_tree* newTree = NULL; - returnCode = git_commit_tree(&newTree, newCommit); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; + TryCatch try_catch; + if (!baton->error) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } - baton->rawDiffList = NULL; - returnCode = git_diff_tree_to_tree(&baton->rawDiffList, baton->repo, oldTree, newTree, NULL); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->new_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { +Handle GitDiffList::TreeToIndex(const Arguments& args) { HandleScope scope; - TreeToTreeBaton *baton = static_cast(req->data); + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } - if (baton->error) { - Local argv[1] = { - GitError::WrapError(baton->error) - }; + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } else { - Handle argv2[1] = { - External::New(baton->rawDiffList) - }; + TreeToIndexBaton* baton = new TreeToIndexBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->indexReference = Persistent::New(args[2]); + baton->index = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[3]); + baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[4])); - baton->diffList = ObjectWrap::Unwrap(GitDiffList::constructor_template->NewInstance(1, argv2)); + uv_queue_work(uv_default_loop(), &baton->request, TreeToIndexWork, (uv_after_work_cb)TreeToIndexAfterWork); - Handle argv[2] = { - Local::New(Null()), - baton->diffList->handle_ - }; + return Undefined(); +} - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } +void GitDiffList::TreeToIndexWork(uv_work_t *req) { + TreeToIndexBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_index( + &baton->diff, + baton->repo, + baton->old_tree, + baton->index, + baton->opts + ); + if (result != GIT_OK) { + baton->error = giterr_last(); } - delete req; } -Handle GitDiffList::Walk(const Arguments& args) { +void GitDiffList::TreeToIndexAfterWork(uv_work_t *req) { HandleScope scope; + TreeToIndexBaton *baton = static_cast(req->data); - GitDiffList* diffList = ObjectWrap::Unwrap(args.This()); + TryCatch try_catch; + if (!baton->error) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } - if (diffList->GetValue() == NULL) { - return ThrowException(Exception::Error(String::New("No diff list to Walk."))); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Diff callback is required and must be a Function."))); +Handle GitDiffList::IndexToWorkdir(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Hunk callback is required and must be a Function."))); + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Line callback is required and must be a Function."))); + IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->indexReference = Persistent::New(args[1]); + baton->index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[2]); + baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); + + return Undefined(); +} + +void GitDiffList::IndexToWorkdirWork(uv_work_t *req) { + IndexToWorkdirBaton *baton = static_cast(req->data); + int result = git_diff_index_to_workdir( + &baton->diff, + baton->repo, + baton->index, + baton->opts + ); + if (result != GIT_OK) { + baton->error = giterr_last(); } +} - if(args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("End callback is required and must be a Function."))); +void GitDiffList::IndexToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + IndexToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} - WalkBaton* baton = new WalkBaton; - uv_async_init(uv_default_loop(), &baton->asyncFile, WalkWorkSendFile); - uv_async_init(uv_default_loop(), &baton->asyncHunk, WalkWorkSendHunk); - uv_async_init(uv_default_loop(), &baton->asyncData, WalkWorkSendData); - uv_async_init(uv_default_loop(), &baton->asyncEnd, WalkWorkSendEnd); +Handle GitDiffList::TreeToWorkdir(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } - uv_mutex_init(&baton->mutex); + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } - baton->rawDiffList = diffList->GetValue(); - diffList->Ref(); + TreeToWorkdirBaton* baton = new TreeToWorkdirBaton; baton->error = NULL; - baton->fileCallback = Persistent::New(Local::Cast(args[0])); - baton->hunkCallback = Persistent::New(Local::Cast(args[1])); - baton->lineCallback = Persistent::New(Local::Cast(args[2])); - baton->endCallback = Persistent::New(Local::Cast(args[3])); + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[2]); + baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[3])); - uv_thread_create(&baton->threadId, WalkWork, baton); + uv_queue_work(uv_default_loop(), &baton->request, TreeToWorkdirWork, (uv_after_work_cb)TreeToWorkdirAfterWork); return Undefined(); } -void GitDiffList::WalkWork(void *payload) { - WalkBaton *baton = static_cast(payload); - - int returnCode = git_diff_foreach(baton->rawDiffList, WalkWorkFile, WalkWorkHunk, WalkWorkData, payload); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); - return; - } - - baton->asyncFile.data = baton; - uv_async_send(&baton->asyncFile); - - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); -} -int GitDiffList::WalkWorkFile(const git_diff_delta *delta, float progress, - void *payload) { - WalkBaton *baton = static_cast(payload); - - /* - diff_file_delta - git_diff_file old_file - git_oid oid - const char *path - git_off_t size - uint32_t flags - uint16_t mode - - git_diff_file new_file - git_delta_t status - uint32_t similarity - uint32_t flags - */ - - uv_mutex_lock(&baton->mutex); - - Delta* newDelta = new Delta; - newDelta->raw = (git_diff_delta*)malloc(sizeof(git_diff_delta)); - memcpy(newDelta->raw, delta, sizeof(git_diff_delta)); - - // @todo use combined OID or another less stupid way to index deltas - std::string key(newDelta->raw->old_file.path); - key.append(newDelta->raw->new_file.path); - baton->fileDeltas[key] = newDelta; - uv_mutex_unlock(&baton->mutex); - - if ((unsigned int)baton->fileDeltas.size() == (unsigned int)GitDiffList::WALK_DELTA_SEND_THRESHHOLD) { - baton->asyncFile.data = baton; - uv_async_send(&baton->asyncFile); - } - - return GIT_OK; -} -int GitDiffList::WalkWorkHunk(const git_diff_delta *delta, const git_diff_range *range, const char *header, size_t header_len, void *payload) { - return GIT_OK; + +void GitDiffList::TreeToWorkdirWork(uv_work_t *req) { + TreeToWorkdirBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_workdir( + &baton->diff, + baton->repo, + baton->old_tree, + baton->opts + ); + if (result != GIT_OK) { + baton->error = giterr_last(); + } } -int GitDiffList::WalkWorkData(const git_diff_delta *delta, const git_diff_range *range, - char line_origin, const char *content, size_t content_len, - void *payload) { - WalkBaton *baton = static_cast(payload); - uv_mutex_lock(&baton->mutex); - GitDiffList::DeltaContent *deltaContent = new GitDiffList::DeltaContent; +void GitDiffList::TreeToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } - deltaContent->range = (git_diff_range*)malloc(sizeof(git_diff_range)); - memcpy(deltaContent->range, range, sizeof(git_diff_range)); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} - deltaContent->lineOrigin = line_origin; +Handle GitDiffList::Merge(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList from is required."))); + } - deltaContent->contentLength = content_len; - deltaContent->content = content; - std::string key(delta->old_file.path); - key.append(delta->new_file.path); - baton->fileDeltas[key]->contents.push_back(deltaContent); + int result = git_diff_merge( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); - uv_mutex_unlock(&baton->mutex); + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } - return GIT_OK; + return Undefined(); } -void GitDiffList::WalkWorkSendFile(uv_async_t *handle, int status /*UNUSED*/) { - HandleScope scope; - WalkBaton *baton = static_cast(handle->data); - - uv_mutex_lock(&baton->mutex); - if (success(baton->error, baton->fileCallback)) { +Handle GitDiffList::FindSimilar(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffFindOptions options is required."))); + } - std::vector > fileDeltasArray; - for(std::map::iterator iterator = baton->fileDeltas.begin(); iterator != baton->fileDeltas.end(); ++iterator) { + int result = git_diff_find_similar( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); - Local fileDelta = Object::New(); - GitDiffList::Delta* delta = iterator->second; + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } - Local oldFile = Object::New(); - oldFile->Set(String::NewSymbol("path"), String::New(delta->raw->old_file.path)); - fileDelta->Set(String::NewSymbol("oldFile"), oldFile); + return Undefined(); +} - Local newFile = Object::New(); - newFile->Set(String::NewSymbol("path"), String::New(delta->raw->new_file.path)); - fileDelta->Set(String::NewSymbol("newFile"), newFile); +Handle GitDiffList::Size(const Arguments& args) { + HandleScope scope; + - std::vector > deltaContent; - for(std::vector::iterator contentIterator = delta->contents.begin(); contentIterator != delta->contents.end(); ++contentIterator) { - DeltaContent* rawContent = (*contentIterator); - Local content = Object::New(); + size_t result = git_diff_num_deltas( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - Local range = Object::New(); - /* - int old_start - int old_lines - int new_start - int new_lines - */ - Local oldRange = Object::New(); - oldRange->Set(String::New("start"), Integer::New(rawContent->range->old_start)); - oldRange->Set(String::New("lines"), Integer::New(rawContent->range->old_lines)); - range->Set(String::New("old"), oldRange); - Local newRange = Object::New(); - newRange->Set(String::New("start"), Integer::New(rawContent->range->new_start)); - newRange->Set(String::New("lines"), Integer::New(rawContent->range->new_lines)); - range->Set(String::New("new"), newRange); + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} - content->Set(String::New("range"), range); - content->Set(String::New("content"), String::New(rawContent->content.c_str())); +Handle GitDiffList::NumDeltasOfType(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList diff is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } - // char lineOrigin[2]; - // strncpy(lineOrigin, &rawContent->lineOrigin, 1); - char lineOrigin[2]; - lineOrigin[0] = rawContent->lineOrigin; - lineOrigin[1] = '\0'; - // std::string lineOrigin(rawContent->lineOrigin); - content->Set(String::New("lineOrigin"), String::New(lineOrigin)); - content->Set(String::New("contentLength"), Integer::New(rawContent->contentLength)); - deltaContent.push_back(content); - } + size_t result = git_diff_num_deltas_of_type( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , (git_delta_t) args[1]->ToInt32()->Value() + ); - fileDelta->Set(String::NewSymbol("content"), cvv8::CastToJS(deltaContent)); - fileDelta->Set(String::NewSymbol("status"), cvv8::CastToJS(delta->raw->status)); - fileDeltasArray.push_back(fileDelta); - } + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} - baton->fileDeltas.clear(); +Handle GitDiffList::Patch(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number idx is required."))); + } + git_diff_patch *patch_out = NULL; + const git_diff_delta *delta_out = NULL; - Handle argv[2] = { - Local::New(Null()), - cvv8::CastToJS(fileDeltasArray) - }; + int result = git_diff_get_patch( + &patch_out + , &delta_out + , ObjectWrap::Unwrap(args.This())->GetValue() + , (size_t) args[0]->ToUint32()->Value() + ); - TryCatch try_catch; - baton->fileCallback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - uv_mutex_unlock(&baton->mutex); -} -void GitDiffList::WalkWorkSendHunk(uv_async_t *handle, int status /*UNUSED*/) { } -void GitDiffList::WalkWorkSendData(uv_async_t *handle, int status /*UNUSED*/) { } -void GitDiffList::WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/) { - WalkBaton *baton = static_cast(handle->data); - - uv_mutex_destroy(&baton->mutex); - uv_close((uv_handle_t*) &baton->asyncFile, NULL); - uv_close((uv_handle_t*) &baton->asyncHunk, NULL); - uv_close((uv_handle_t*) &baton->asyncData, NULL); - uv_close((uv_handle_t*) &baton->asyncEnd, NULL); - - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); - } else { - argv[0] = Local::New(Null()); + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); } - TryCatch try_catch; + Handle toReturn = Object::New(); + Handle to; + to = GitPatch::New((void *)patch_out); + toReturn->Set(String::NewSymbol("patch"), to); - baton->endCallback->Call(Context::GetCurrent()->Global(), 1, argv); + to = GitDelta::New((void *)delta_out); + toReturn->Set(String::NewSymbol("delta"), to); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + return scope.Close(toReturn); } Persistent GitDiffList::constructor_template; diff --git a/src/diff_options.cc b/src/diff_options.cc new file mode 100644 index 000000000..aadd012f4 --- /dev/null +++ b/src/diff_options.cc @@ -0,0 +1,64 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/diff_options.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDiffOptions::GitDiffOptions(git_diff_options *raw) { + this->raw = raw; +} + +GitDiffOptions::~GitDiffOptions() { + free(this->raw); +} + +void GitDiffOptions::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffOptions")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffOptions"), constructor_template); +} + +Handle GitDiffOptions::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_options is required."))); + } + + GitDiffOptions* object = new GitDiffOptions((git_diff_options *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffOptions::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffOptions::constructor_template->NewInstance(1, argv)); +} + +git_diff_options *GitDiffOptions::GetValue() { + return this->raw; +} + + +Persistent GitDiffOptions::constructor_template; diff --git a/src/diff_range.cc b/src/diff_range.cc new file mode 100644 index 000000000..fcf986369 --- /dev/null +++ b/src/diff_range.cc @@ -0,0 +1,112 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/diff_range.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDiffRange::GitDiffRange(git_diff_range *raw) { + this->raw = raw; +} + +GitDiffRange::~GitDiffRange() { + free(this->raw); +} + +void GitDiffRange::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffRange")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "oldStart", OldStart); + NODE_SET_PROTOTYPE_METHOD(tpl, "oldLines", OldLines); + NODE_SET_PROTOTYPE_METHOD(tpl, "newStart", NewStart); + NODE_SET_PROTOTYPE_METHOD(tpl, "newLines", NewLines); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffRange"), constructor_template); +} + +Handle GitDiffRange::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_range is required."))); + } + + GitDiffRange* object = new GitDiffRange((git_diff_range *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffRange::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffRange::constructor_template->NewInstance(1, argv)); +} + +git_diff_range *GitDiffRange::GetValue() { + return this->raw; +} + + +Handle GitDiffRange::OldStart(const Arguments& args) { + HandleScope scope; + Handle to; + + int old_start = + ObjectWrap::Unwrap(args.This())->GetValue()->old_start; + + to = Integer::New(old_start); + return scope.Close(to); +} + +Handle GitDiffRange::OldLines(const Arguments& args) { + HandleScope scope; + Handle to; + + int old_lines = + ObjectWrap::Unwrap(args.This())->GetValue()->old_lines; + + to = Integer::New(old_lines); + return scope.Close(to); +} + +Handle GitDiffRange::NewStart(const Arguments& args) { + HandleScope scope; + Handle to; + + int new_start = + ObjectWrap::Unwrap(args.This())->GetValue()->new_start; + + to = Integer::New(new_start); + return scope.Close(to); +} + +Handle GitDiffRange::NewLines(const Arguments& args) { + HandleScope scope; + Handle to; + + int new_lines = + ObjectWrap::Unwrap(args.This())->GetValue()->new_lines; + + to = Integer::New(new_lines); + return scope.Close(to); +} + +Persistent GitDiffRange::constructor_template; diff --git a/src/index.cc b/src/index.cc index 48e4e69f8..e503aa1be 100644 --- a/src/index.cc +++ b/src/index.cc @@ -69,6 +69,12 @@ Handle GitIndex::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitIndex::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitIndex::constructor_template->NewInstance(1, argv)); +} + git_index *GitIndex::GetValue() { return this->raw; } @@ -76,10 +82,11 @@ git_index *GitIndex::GetValue() { Handle GitIndex::Open(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String index_path is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -99,11 +106,11 @@ Handle GitIndex::Open(const Arguments& args) { void GitIndex::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); - int out = git_index_open( + int result = git_index_open( &baton->out, baton->index_path ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -114,18 +121,19 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitIndex::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitIndex::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -139,22 +147,22 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { Handle GitIndex::Owner(const Arguments& args) { HandleScope scope; + git_repository * result = git_index_owner( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitRepo::New((void *)result); + return scope.Close(to); } Handle GitIndex::Read(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -189,16 +197,16 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { if (!baton->error) { Handle result = Local::New(Undefined()); - Handle argv2[2] = { + Handle argv[2] = { Local::New(Null()), result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -211,7 +219,8 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { Handle GitIndex::Write(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -246,16 +255,16 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { if (!baton->error) { Handle result = Local::New(Undefined()); - Handle argv2[2] = { + Handle argv[2] = { Local::New(Null()), result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -268,10 +277,11 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { Handle GitIndex::ReadTree(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Tree tree is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -309,16 +319,16 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { if (!baton->error) { Handle result = Local::New(Undefined()); - Handle argv2[2] = { + Handle argv[2] = { Local::New(Null()), result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -332,7 +342,8 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { Handle GitIndex::WriteTree(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -351,11 +362,11 @@ Handle GitIndex::WriteTree(const Arguments& args) { void GitIndex::WriteTreeWork(uv_work_t *req) { WriteTreeBaton *baton = static_cast(req->data); - int out = git_index_write_tree( + int result = git_index_write_tree( baton->out, baton->index ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -366,18 +377,19 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitOid::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -390,23 +402,23 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { Handle GitIndex::Entrycount(const Arguments& args) { HandleScope scope; + size_t result = git_index_entrycount( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Uint32::New(result)); + Handle to; + to = Uint32::New(result); + return scope.Close(to); } Handle GitIndex::Clear(const Arguments& args) { HandleScope scope; + git_index_clear( - - ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -416,70 +428,57 @@ Handle GitIndex::Clear(const Arguments& args) { Handle GitIndex::Remove(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } - if (args.Length() == 1 || !args[1]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } - int result = git_index_remove( - + int result = git_index_remove( ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[0]->ToString()).c_str() -, - - (int) args[1]->ToInt32()->Value() + , stringArgToString(args[0]->ToString()).c_str() + , (int) args[1]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitIndex::RemoveDirectory(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String dir is required."))); } - if (args.Length() == 1 || !args[1]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } - int result = git_index_remove_directory( - + int result = git_index_remove_directory( ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[0]->ToString()).c_str() -, - - (int) args[1]->ToInt32()->Value() + , stringArgToString(args[0]->ToString()).c_str() + , (int) args[1]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitIndex::AddBypath(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -518,16 +517,16 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { if (!baton->error) { Handle result = Local::New(Undefined()); - Handle argv2[2] = { + Handle argv[2] = { Local::New(Null()), result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -542,83 +541,69 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { Handle GitIndex::RemoveBypath(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } - int result = git_index_remove_bypath( - + int result = git_index_remove_bypath( ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[0]->ToString()).c_str() + , stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitIndex::Find(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsUint32()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number at_pos is required."))); } - if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } - int result = git_index_find( - - (size_t *) args[0]->ToUint32()->Value() -, - - ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[1]->ToString()).c_str() + int result = git_index_find( + (size_t *) args[0]->ToUint32()->Value() + , ObjectWrap::Unwrap(args.This())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() ); - return scope.Close(Int32::New(result)); + Handle to; + to = Int32::New(result); + return scope.Close(to); } Handle GitIndex::ConflictRemove(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } - int result = git_index_conflict_remove( - + int result = git_index_conflict_remove( ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[0]->ToString()).c_str() + , stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitIndex::ConflictCleanup(const Arguments& args) { HandleScope scope; + git_index_conflict_cleanup( - - ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -628,16 +613,16 @@ Handle GitIndex::ConflictCleanup(const Arguments& args) { Handle GitIndex::HasConflicts(const Arguments& args) { HandleScope scope; + int result = git_index_has_conflicts( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Int32::New(result)); + Handle to; + to = Int32::New(result); + return scope.Close(to); } - Persistent GitIndex::constructor_template; diff --git a/src/object.cc b/src/object.cc index e3de4ca48..ea79accd6 100644 --- a/src/object.cc +++ b/src/object.cc @@ -57,6 +57,12 @@ Handle GitObject::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitObject::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); +} + git_object *GitObject::GetValue() { return this->raw; } @@ -64,8 +70,8 @@ git_object *GitObject::GetValue() { Handle GitObject::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -74,6 +80,7 @@ Handle GitObject::Lookup(const Arguments& args) { if (args.Length() == 2 || !args[2]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number type is required."))); } + if (args.Length() == 3 || !args[3]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -96,13 +103,13 @@ Handle GitObject::Lookup(const Arguments& args) { void GitObject::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int object = git_object_lookup( + int result = git_object_lookup( &baton->object, baton->repo, baton->id, baton->type ); - if (object != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -113,18 +120,19 @@ void GitObject::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->object) }; - Handle object = GitObject::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitObject::New((void *)baton->object); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - object + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -139,53 +147,53 @@ void GitObject::LookupAfterWork(uv_work_t *req) { Handle GitObject::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_object_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitObject::Type(const Arguments& args) { HandleScope scope; + git_otype result = git_object_type( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Number::New(result)); + Handle to; + to = Number::New(result); + return scope.Close(to); } Handle GitObject::Owner(const Arguments& args) { HandleScope scope; + git_repository * result = git_object_owner( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitRepo::New((void *)result); + return scope.Close(to); } Handle GitObject::Peel(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsInt32()) { + + if (args.Length() == 0 || !args[0]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number target_type is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -206,12 +214,12 @@ Handle GitObject::Peel(const Arguments& args) { void GitObject::PeelWork(uv_work_t *req) { PeelBaton *baton = static_cast(req->data); - int peeled = git_object_peel( + int result = git_object_peel( &baton->peeled, baton->object, baton->target_type ); - if (peeled != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -222,18 +230,19 @@ void GitObject::PeelAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->peeled) }; - Handle peeled = GitObject::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitObject::New((void *)baton->peeled); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - peeled + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -245,5 +254,4 @@ void GitObject::PeelAfterWork(uv_work_t *req) { delete baton; } - Persistent GitObject::constructor_template; diff --git a/src/oid.cc b/src/oid.cc index 458bfc270..11b7edb52 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -51,6 +51,12 @@ Handle GitOid::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitOid::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} + git_oid *GitOid::GetValue() { return this->raw; } @@ -58,43 +64,38 @@ git_oid *GitOid::GetValue() { Handle GitOid::FromString(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String str is required."))); } - git_oid * out; - out = (git_oid *)malloc(sizeof(git_oid)); - - int result = git_oid_fromstr( + git_oid *out = (git_oid *)malloc(sizeof(git_oid)); + int result = git_oid_fromstr( out -, - - stringArgToString(args[0]->ToString()).c_str() + , stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)out); + return scope.Close(to); } Handle GitOid::Sha(const Arguments& args) { HandleScope scope; + char * result = git_oid_allocfmt( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } - Persistent GitOid::constructor_template; diff --git a/src/patch.cc b/src/patch.cc new file mode 100644 index 000000000..96d6fb00c --- /dev/null +++ b/src/patch.cc @@ -0,0 +1,261 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/patch.h" +#include "../include/delta.h" +#include "../include/diff_range.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitPatch::GitPatch(git_diff_patch *raw) { + this->raw = raw; +} + +GitPatch::~GitPatch() { + git_diff_patch_free(this->raw); +} + +void GitPatch::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Patch")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "delta", Delta); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "stats", Stats); + NODE_SET_PROTOTYPE_METHOD(tpl, "hunk", Hunk); + NODE_SET_PROTOTYPE_METHOD(tpl, "lines", Lines); + NODE_SET_PROTOTYPE_METHOD(tpl, "line", Line); + NODE_SET_METHOD(tpl, "toString", ToString); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Patch"), constructor_template); +} + +Handle GitPatch::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_patch is required."))); + } + + GitPatch* object = new GitPatch((git_diff_patch *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitPatch::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitPatch::constructor_template->NewInstance(1, argv)); +} + +git_diff_patch *GitPatch::GetValue() { + return this->raw; +} + + +Handle GitPatch::Delta(const Arguments& args) { + HandleScope scope; + + + const git_diff_delta * result = git_diff_patch_delta( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = GitDelta::New((void *)result); + return scope.Close(to); +} + +Handle GitPatch::Size(const Arguments& args) { + HandleScope scope; + + + size_t result = git_diff_patch_num_hunks( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +Handle GitPatch::Stats(const Arguments& args) { + HandleScope scope; + + size_t total_context = NULL; + size_t total_additions = NULL; + size_t total_deletions = NULL; + + int result = git_diff_patch_line_stats( + &total_context + , &total_additions + , &total_deletions + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + Handle toReturn = Object::New(); + Handle to; + to = Integer::New(total_context); + toReturn->Set(String::NewSymbol("total_context"), to); + + to = Integer::New(total_additions); + toReturn->Set(String::NewSymbol("total_additions"), to); + + to = Integer::New(total_deletions); + toReturn->Set(String::NewSymbol("total_deletions"), to); + + return scope.Close(toReturn); +} + +Handle GitPatch::Hunk(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); + } + + const git_diff_range *range = NULL; + const char *header = NULL; + size_t header_len = NULL; + size_t lines_in_hunk = NULL; + + int result = git_diff_patch_get_hunk( + &range + , &header + , &header_len + , &lines_in_hunk + , ObjectWrap::Unwrap(args.This())->GetValue() + , (size_t) args[0]->ToUint32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + Handle toReturn = Object::New(); + Handle to; + to = GitDiffRange::New((void *)range); + toReturn->Set(String::NewSymbol("range"), to); + + to = String::New(header); + toReturn->Set(String::NewSymbol("header"), to); + + to = Uint32::New(header_len); + toReturn->Set(String::NewSymbol("headerLength"), to); + + to = Uint32::New(lines_in_hunk); + toReturn->Set(String::NewSymbol("lines"), to); + + return scope.Close(toReturn); +} + +Handle GitPatch::Lines(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); + } + + + int result = git_diff_patch_num_lines_in_hunk( + ObjectWrap::Unwrap(args.This())->GetValue() + , (size_t) args[0]->ToUint32()->Value() + ); + + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +Handle GitPatch::Line(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number line_of_hunk is required."))); + } + + char line_origin = NULL; + const char *content = NULL; + size_t content_len = NULL; + int old_lineno = NULL; + int new_lineno = NULL; + + int result = git_diff_patch_get_line_in_hunk( + &line_origin + , &content + , &content_len + , &old_lineno + , &new_lineno + , ObjectWrap::Unwrap(args.This())->GetValue() + , (size_t) args[0]->ToUint32()->Value() + , (size_t) args[1]->ToUint32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + Handle toReturn = Object::New(); + Handle to; + to = Integer::New(line_origin); + toReturn->Set(String::NewSymbol("lineOrigin"), to); + + to = String::New(content); + toReturn->Set(String::NewSymbol("content"), to); + + to = Uint32::New(content_len); + toReturn->Set(String::NewSymbol("length"), to); + + to = Int32::New(old_lineno); + toReturn->Set(String::NewSymbol("oldLineNumber"), to); + + to = Int32::New(new_lineno); + toReturn->Set(String::NewSymbol("newLineNumber"), to); + + return scope.Close(toReturn); +} + +Handle GitPatch::ToString(const Arguments& args) { + HandleScope scope; + + char *string = NULL; + + int result = git_diff_patch_to_str( + &string + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + Handle to; + to = String::New(string); + return scope.Close(to); +} + +Persistent GitPatch::constructor_template; diff --git a/src/reference.cc b/src/reference.cc index 40459d88e..628711746 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -69,6 +69,12 @@ Handle GitReference::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitReference::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); +} + git_reference *GitReference::GetValue() { return this->raw; } @@ -76,13 +82,14 @@ git_reference *GitReference::GetValue() { Handle GitReference::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String name is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -104,12 +111,12 @@ Handle GitReference::Lookup(const Arguments& args) { void GitReference::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int out = git_reference_lookup( + int result = git_reference_lookup( &baton->out, baton->repo, baton->name ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -120,18 +127,19 @@ void GitReference::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitReference::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitReference::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -146,13 +154,14 @@ void GitReference::LookupAfterWork(uv_work_t *req) { Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String name is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -174,12 +183,12 @@ Handle GitReference::OidForName(const Arguments& args) { void GitReference::OidForNameWork(uv_work_t *req) { OidForNameBaton *baton = static_cast(req->data); - int out = git_reference_name_to_id( + int result = git_reference_name_to_id( baton->out, baton->repo, baton->name ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -190,18 +199,19 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitOid::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -216,142 +226,118 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { Handle GitReference::CreateSymbolic(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String name is required."))); } - if (args.Length() == 2 || !args[2]->IsString()) { return ThrowException(Exception::Error(String::New("String target is required."))); } - if (args.Length() == 3 || !args[3]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number force is required."))); } - git_reference * out; - - int result = git_reference_symbolic_create( - -& - out -, - - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() -, - - stringArgToString(args[1]->ToString()).c_str() -, - stringArgToString(args[2]->ToString()).c_str() -, + git_reference *out = NULL; - (int) args[3]->ToInt32()->Value() + int result = git_reference_symbolic_create( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + , stringArgToString(args[2]->ToString()).c_str() + , (int) args[3]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); } Handle GitReference::Create(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String name is required."))); } - if (args.Length() == 2 || !args[2]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } - if (args.Length() == 3 || !args[3]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number force is required."))); } - git_reference * out; - - int result = git_reference_create( - -& - out -, - - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() -, - stringArgToString(args[1]->ToString()).c_str() -, + git_reference *out = NULL; - ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() -, - - (int) args[3]->ToInt32()->Value() + int result = git_reference_create( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , (int) args[3]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); } Handle GitReference::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_reference_target( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitReference::Name(const Arguments& args) { HandleScope scope; + const char * result = git_reference_symbolic_target( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitReference::Type(const Arguments& args) { HandleScope scope; + git_ref_t result = git_reference_type( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Number::New(result)); + Handle to; + to = Number::New(result); + return scope.Close(to); } Handle GitReference::Resolve(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -370,11 +356,11 @@ Handle GitReference::Resolve(const Arguments& args) { void GitReference::ResolveWork(uv_work_t *req) { ResolveBaton *baton = static_cast(req->data); - int out = git_reference_resolve( + int result = git_reference_resolve( &baton->out, baton->ref ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -385,18 +371,19 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitReference::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitReference::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -409,71 +396,60 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { Handle GitReference::SetSymbolicTarget(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String target is required."))); } - git_reference * out; - - int result = git_reference_symbolic_set_target( -& - out -, + git_reference *out = NULL; - ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[0]->ToString()).c_str() + int result = git_reference_symbolic_set_target( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , stringArgToString(args[0]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); } Handle GitReference::setTarget(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } - git_reference * out; - - int result = git_reference_set_target( -& - out -, - - ObjectWrap::Unwrap(args.This())->GetValue() -, + git_reference *out = NULL; - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + int result = git_reference_set_target( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); } Handle GitReference::Rename(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String new_name is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number force is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -497,13 +473,13 @@ Handle GitReference::Rename(const Arguments& args) { void GitReference::RenameWork(uv_work_t *req) { RenameBaton *baton = static_cast(req->data); - int out = git_reference_rename( + int result = git_reference_rename( &baton->out, baton->ref, baton->new_name, baton->force ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -514,18 +490,19 @@ void GitReference::RenameAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitReference::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitReference::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -541,7 +518,8 @@ void GitReference::RenameAfterWork(uv_work_t *req) { Handle GitReference::Delete(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -576,16 +554,16 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { if (!baton->error) { Handle result = Local::New(Undefined()); - Handle argv2[2] = { + Handle argv[2] = { Local::New(Null()), result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -598,10 +576,9 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { Handle GitReference::IsBranch(const Arguments& args) { HandleScope scope; + int result = git_reference_is_branch( - - ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -609,15 +586,14 @@ Handle GitReference::IsBranch(const Arguments& args) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitReference::IsRemote(const Arguments& args) { HandleScope scope; + int result = git_reference_is_remote( - - ObjectWrap::Unwrap(args.This())->GetValue() ); @@ -625,48 +601,40 @@ Handle GitReference::IsRemote(const Arguments& args) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitReference::Peel(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsInt32()) { + if (args.Length() == 0 || !args[0]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number type is required."))); } - git_object * out; - - int result = git_reference_peel( - -& - out -, - ObjectWrap::Unwrap(args.This())->GetValue() -, + git_object *out = NULL; - (git_otype) args[0]->ToInt32()->Value() + int result = git_reference_peel( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , (git_otype) args[0]->ToInt32()->Value() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitObject::New((void *)out); + return scope.Close(to); } Handle GitReference::IsValidName(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String refname is required."))); } - int result = git_reference_is_valid_name( - + int result = git_reference_is_valid_name( stringArgToString(args[0]->ToString()).c_str() ); @@ -674,8 +642,7 @@ Handle GitReference::IsValidName(const Arguments& args) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } - Persistent GitReference::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 2ff77d42f..2f761ba09 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -54,6 +54,12 @@ Handle GitRepo::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitRepo::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); +} + git_repository *GitRepo::GetValue() { return this->raw; } @@ -61,10 +67,11 @@ git_repository *GitRepo::GetValue() { Handle GitRepo::Open(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -84,11 +91,11 @@ Handle GitRepo::Open(const Arguments& args) { void GitRepo::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); - int out = git_repository_open( + int result = git_repository_open( &baton->out, baton->path ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -99,18 +106,19 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitRepo::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitRepo::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -124,13 +132,14 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { Handle GitRepo::Init(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsBoolean()) { return ThrowException(Exception::Error(String::New("Boolean is_bare is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -152,12 +161,12 @@ Handle GitRepo::Init(const Arguments& args) { void GitRepo::InitWork(uv_work_t *req) { InitBaton *baton = static_cast(req->data); - int out = git_repository_init( + int result = git_repository_init( &baton->out, baton->path, baton->is_bare ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -168,18 +177,19 @@ void GitRepo::InitAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitRepo::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitRepo::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -194,29 +204,30 @@ void GitRepo::InitAfterWork(uv_work_t *req) { Handle GitRepo::Path(const Arguments& args) { HandleScope scope; + const char * result = git_repository_path( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitRepo::Workdir(const Arguments& args) { HandleScope scope; + const char * result = git_repository_workdir( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } - Persistent GitRepo::constructor_template; diff --git a/src/signature.cc b/src/signature.cc index 10e01a8dd..cc80fd715 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -54,6 +54,12 @@ Handle GitSignature::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitSignature::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); +} + git_signature *GitSignature::GetValue() { return this->raw; } @@ -61,56 +67,61 @@ git_signature *GitSignature::GetValue() { Handle GitSignature::Now(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String name is required."))); } - if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String email is required."))); } - git_signature * out; - - int result = git_signature_now( -& - out -, + git_signature *out = NULL; - stringArgToString(args[0]->ToString()).c_str() -, - - stringArgToString(args[1]->ToString()).c_str() + int result = git_signature_now( + &out + , stringArgToString(args[0]->ToString()).c_str() + , stringArgToString(args[1]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)out) }; - return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitSignature::New((void *)out); + return scope.Close(to); } Handle GitSignature::Name(const Arguments& args) { HandleScope scope; - const char * field = ObjectWrap::Unwrap(args.This())->GetValue()->name; + Handle to; + + const char * name = + ObjectWrap::Unwrap(args.This())->GetValue()->name; - return scope.Close(String::New(field)); + to = String::New(name); + return scope.Close(to); } + Handle GitSignature::Email(const Arguments& args) { HandleScope scope; - const char * field = ObjectWrap::Unwrap(args.This())->GetValue()->email; + Handle to; + + const char * email = + ObjectWrap::Unwrap(args.This())->GetValue()->email; - return scope.Close(String::New(field)); + to = String::New(email); + return scope.Close(to); } + Handle GitSignature::Time(const Arguments& args) { HandleScope scope; - git_time field = ObjectWrap::Unwrap(args.This())->GetValue()->when; + Handle to; + + git_time *when = + &ObjectWrap::Unwrap(args.This())->GetValue()->when; - // XXX need to copy object? - Handle argv[1] = { External::New((void *)&field) }; - return scope.Close(GitTime::constructor_template->NewInstance(1, argv)); + to = GitTime::New((void *)when); + return scope.Close(to); } Persistent GitSignature::constructor_template; diff --git a/src/tag.cc b/src/tag.cc index ede9668f0..c9fb7b2f4 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -66,6 +66,12 @@ Handle GitTag::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitTag::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTag::constructor_template->NewInstance(1, argv)); +} + git_tag *GitTag::GetValue() { return this->raw; } @@ -73,13 +79,14 @@ git_tag *GitTag::GetValue() { Handle GitTag::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -100,12 +107,12 @@ Handle GitTag::Lookup(const Arguments& args) { void GitTag::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int out = git_tag_lookup( + int result = git_tag_lookup( &baton->out, baton->repo, baton->id ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -116,18 +123,19 @@ void GitTag::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitTag::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitTag::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -141,22 +149,22 @@ void GitTag::LookupAfterWork(uv_work_t *req) { Handle GitTag::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_tag_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitTag::Target(const Arguments& args) { HandleScope scope; - + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -175,11 +183,11 @@ Handle GitTag::Target(const Arguments& args) { void GitTag::TargetWork(uv_work_t *req) { TargetBaton *baton = static_cast(req->data); - int target_out = git_tag_target( + int result = git_tag_target( &baton->target_out, baton->tag ); - if (target_out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -190,18 +198,19 @@ void GitTag::TargetAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->target_out) }; - Handle target_out = GitObject::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitObject::New((void *)baton->target_out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - target_out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -214,77 +223,78 @@ void GitTag::TargetAfterWork(uv_work_t *req) { Handle GitTag::TargetId(const Arguments& args) { HandleScope scope; + const git_oid * result = git_tag_target_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitTag::TargetType(const Arguments& args) { HandleScope scope; + git_otype result = git_tag_target_type( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Int32::New(result)); + Handle to; + to = Int32::New(result); + return scope.Close(to); } Handle GitTag::Name(const Arguments& args) { HandleScope scope; + const char * result = git_tag_name( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitTag::Tagger(const Arguments& args) { HandleScope scope; + const git_signature * result = git_tag_tagger( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitSignature::New((void *)result); + return scope.Close(to); } Handle GitTag::Message(const Arguments& args) { HandleScope scope; + const char * result = git_tag_message( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitTag::Create(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -302,6 +312,7 @@ Handle GitTag::Create(const Arguments& args) { if (args.Length() == 5 || !args[5]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number force is required."))); } + if (args.Length() == 6 || !args[6]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -332,7 +343,7 @@ Handle GitTag::Create(const Arguments& args) { void GitTag::CreateWork(uv_work_t *req) { CreateBaton *baton = static_cast(req->data); - int oid = git_tag_create( + int result = git_tag_create( baton->oid, baton->repo, baton->tag_name, @@ -341,7 +352,7 @@ void GitTag::CreateWork(uv_work_t *req) { baton->message, baton->force ); - if (oid != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -352,18 +363,19 @@ void GitTag::CreateAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->oid) }; - Handle oid = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitOid::New((void *)baton->oid); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - oid + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -383,8 +395,8 @@ void GitTag::CreateAfterWork(uv_work_t *req) { Handle GitTag::CreateLightweight(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -396,6 +408,7 @@ Handle GitTag::CreateLightweight(const Arguments& args) { if (args.Length() == 3 || !args[3]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number force is required."))); } + if (args.Length() == 4 || !args[4]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -421,14 +434,14 @@ Handle GitTag::CreateLightweight(const Arguments& args) { void GitTag::CreateLightweightWork(uv_work_t *req) { CreateLightweightBaton *baton = static_cast(req->data); - int oid = git_tag_create_lightweight( + int result = git_tag_create_lightweight( baton->oid, baton->repo, baton->tag_name, baton->target, baton->force ); - if (oid != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -439,18 +452,19 @@ void GitTag::CreateLightweightAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->oid) }; - Handle oid = GitOid::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitOid::New((void *)baton->oid); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - oid + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -467,56 +481,46 @@ void GitTag::CreateLightweightAfterWork(uv_work_t *req) { Handle GitTag::Delete(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - if (args.Length() == 1 || !args[1]->IsString()) { return ThrowException(Exception::Error(String::New("String tag_name is required."))); } - int result = git_tag_delete( - + int result = git_tag_delete( ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() -, - - stringArgToString(args[1]->ToString()).c_str() + , stringArgToString(args[1]->ToString()).c_str() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitTag::Peel(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Tag tag is required."))); } - git_object * tag_target_out; - int result = git_tag_peel( - -& - tag_target_out -, + git_object *tag_target_out = NULL; - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + int result = git_tag_peel( + &tag_target_out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() ); if (result != GIT_OK) { return ThrowException(GitError::WrapError(giterr_last())); } - // XXX need to copy object? - Handle argv[1] = { External::New((void *)tag_target_out) }; - return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitObject::New((void *)tag_target_out); + return scope.Close(to); } - Persistent GitTag::constructor_template; diff --git a/src/threads.cc b/src/threads.cc index c1ecd9640..de1eb583b 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -29,6 +29,7 @@ void GitThreads::Initialize(Handle target) { Handle GitThreads::Init(const Arguments& args) { HandleScope scope; + int result = git_threads_init( ); @@ -37,11 +38,12 @@ Handle GitThreads::Init(const Arguments& args) { return ThrowException(GitError::WrapError(giterr_last())); } - return scope.Close(Int32::New(result)); + return Undefined(); } Handle GitThreads::Shutdown(const Arguments& args) { HandleScope scope; + git_threads_shutdown( ); @@ -50,4 +52,3 @@ Handle GitThreads::Shutdown(const Arguments& args) { return Undefined(); } - diff --git a/src/time.cc b/src/time.cc index d5f7a1ac6..25849c7fb 100644 --- a/src/time.cc +++ b/src/time.cc @@ -52,6 +52,12 @@ Handle GitTime::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitTime::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTime::constructor_template->NewInstance(1, argv)); +} + git_time *GitTime::GetValue() { return this->raw; } @@ -59,15 +65,24 @@ git_time *GitTime::GetValue() { Handle GitTime::Time(const Arguments& args) { HandleScope scope; - git_time_t field = ObjectWrap::Unwrap(args.This())->GetValue()->time; + Handle to; - return scope.Close(Integer::New(field)); + git_time_t time = + ObjectWrap::Unwrap(args.This())->GetValue()->time; + + to = Integer::New(time); + return scope.Close(to); } + Handle GitTime::Offset(const Arguments& args) { HandleScope scope; - int field = ObjectWrap::Unwrap(args.This())->GetValue()->offset; + Handle to; + + int offset = + ObjectWrap::Unwrap(args.This())->GetValue()->offset; - return scope.Close(Int32::New(field)); + to = Int32::New(offset); + return scope.Close(to); } Persistent GitTime::constructor_template; diff --git a/src/tree.cc b/src/tree.cc index ecca7d113..bc8864472 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -60,6 +60,12 @@ Handle GitTree::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitTree::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTree::constructor_template->NewInstance(1, argv)); +} + git_tree *GitTree::GetValue() { return this->raw; } @@ -67,13 +73,14 @@ git_tree *GitTree::GetValue() { Handle GitTree::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -94,12 +101,12 @@ Handle GitTree::Lookup(const Arguments& args) { void GitTree::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - int out = git_tree_lookup( + int result = git_tree_lookup( &baton->out, baton->repo, baton->id ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -110,18 +117,19 @@ void GitTree::LookupAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitTree::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitTree::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -135,104 +143,93 @@ void GitTree::LookupAfterWork(uv_work_t *req) { Handle GitTree::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_tree_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitTree::Size(const Arguments& args) { HandleScope scope; + size_t result = git_tree_entrycount( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Uint32::New(result)); + Handle to; + to = Uint32::New(result); + return scope.Close(to); } Handle GitTree::EntryByName(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String filename is required."))); } - const git_tree_entry * result = git_tree_entry_byname( - + const git_tree_entry * result = git_tree_entry_byname( ObjectWrap::Unwrap(args.This())->GetValue() -, - - stringArgToString(args[0]->ToString()).c_str() + , stringArgToString(args[0]->ToString()).c_str() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitTreeEntry::New((void *)result); + return scope.Close(to); } Handle GitTree::EntryByIndex(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsUint32()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number idx is required."))); } - const git_tree_entry * result = git_tree_entry_byindex( - + const git_tree_entry * result = git_tree_entry_byindex( ObjectWrap::Unwrap(args.This())->GetValue() -, - - (size_t) args[0]->ToUint32()->Value() + , (size_t) args[0]->ToUint32()->Value() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitTreeEntry::New((void *)result); + return scope.Close(to); } Handle GitTree::EntryByOid(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid oid is required."))); } - const git_tree_entry * result = git_tree_entry_byoid( - + const git_tree_entry * result = git_tree_entry_byoid( ObjectWrap::Unwrap(args.This())->GetValue() -, - - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitTreeEntry::New((void *)result); + return scope.Close(to); } Handle GitTree::GetEntryByPath(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -254,12 +251,12 @@ Handle GitTree::GetEntryByPath(const Arguments& args) { void GitTree::GetEntryByPathWork(uv_work_t *req) { GetEntryByPathBaton *baton = static_cast(req->data); - int out = git_tree_entry_bypath( + int result = git_tree_entry_bypath( &baton->out, baton->root, baton->path ); - if (out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -270,18 +267,19 @@ void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->out) }; - Handle out = GitTreeEntry::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitTreeEntry::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -294,5 +292,4 @@ void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { delete baton; } - Persistent GitTree::constructor_template; diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 31bfe8731..1b7eb4d1a 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -58,6 +58,12 @@ Handle GitTreeEntry::New(const Arguments& args) { return scope.Close(args.This()); } +Handle GitTreeEntry::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); +} + git_tree_entry *GitTreeEntry::GetValue() { return this->raw; } @@ -65,64 +71,67 @@ git_tree_entry *GitTreeEntry::GetValue() { Handle GitTreeEntry::Name(const Arguments& args) { HandleScope scope; + const char * result = git_tree_entry_name( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(String::New(result)); + Handle to; + to = String::New(result); + return scope.Close(to); } Handle GitTreeEntry::Oid(const Arguments& args) { HandleScope scope; + const git_oid * result = git_tree_entry_id( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - // XXX need to copy object? - Handle argv[1] = { External::New((void *)result) }; - return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); } Handle GitTreeEntry::Type(const Arguments& args) { HandleScope scope; + git_otype result = git_tree_entry_type( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Number::New(result)); + Handle to; + to = Number::New(result); + return scope.Close(to); } Handle GitTreeEntry::filemode(const Arguments& args) { HandleScope scope; + git_filemode_t result = git_tree_entry_filemode( - - ObjectWrap::Unwrap(args.This())->GetValue() ); - return scope.Close(Number::New(result)); + Handle to; + to = Number::New(result); + return scope.Close(to); } Handle GitTreeEntry::GetObject(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -143,12 +152,12 @@ Handle GitTreeEntry::GetObject(const Arguments& args) { void GitTreeEntry::GetObjectWork(uv_work_t *req) { GetObjectBaton *baton = static_cast(req->data); - int object_out = git_tree_entry_to_object( + int result = git_tree_entry_to_object( &baton->object_out, baton->repo, baton->entry ); - if (object_out != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } } @@ -159,18 +168,19 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { TryCatch try_catch; if (!baton->error) { - Handle argv[1] = { External::New(baton->object_out) }; - Handle object_out = GitObject::constructor_template->NewInstance(1, argv); - Handle argv2[2] = { + Handle to; + to = GitObject::New((void *)baton->object_out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - object_out + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -182,5 +192,4 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { delete baton; } - Persistent GitTreeEntry::constructor_template; diff --git a/src/wrapper.cc b/src/wrapper.cc index 1d3e602f9..e77c10183 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -42,6 +42,13 @@ Handle Wrapper::New(const Arguments& args) { return scope.Close(args.This()); } +Handle Wrapper::New(void *raw) { + HandleScope scope; + + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); +} + void *Wrapper::GetValue() { return this->raw; } diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 7af24ac88..5adb6b269 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -92,6 +92,12 @@ Handle <%- cppClassName %>::New(const Arguments& args) { return scope.Close(args.This()); } +Handle <%- cppClassName %>::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(<%- cppClassName %>::constructor_template->NewInstance(1, argv)); +} + <%- cType %> *<%- cppClassName %>::GetValue() { return this->raw; } @@ -121,32 +127,21 @@ void <%- cppClassName %>::Initialize(Handle target) { var functionInfo = functions[i]; if (functionInfo.ignore) continue; - var result = null; + var returns = []; for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; - if (arg.isReturn) result = arg; + if (arg.isReturn) returns.push(arg); } - if (!result) result = functionInfo.return; - var resultName = result.name || 'result'; + if (!returns.length && !functionInfo.return.isErrorCode && functionInfo.return.cType != "void") returns.push(functionInfo.return); -%> <% if (functionInfo.isAsync) { -%> Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; + <% var jsArg; %> + <% include templates/guardArguments.cc.ejs -%> -<% - for (var i = 0, j = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; - if (arg.isReturn || arg.isSelf) continue; --%> - if (args.Length() == <%- j %> || !args[<%- j %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { - return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> <%- arg.name %> is required."))); - } -<% - j++; - } --%> - if (args.Length() == <%- j %> || !args[<%- j %>]->IsFunction()) { + if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -154,32 +149,40 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg baton->error = NULL; baton->request.data = baton; <% - for (var i = 0, j = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; -%> <% if (!arg.isReturn) { -%> <% if (arg.isSelf) { -%> baton-><%- arg.name %>Reference = Persistent::New(args.This()); baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); <% } else { -%> - baton-><%- arg.name %>Reference = Persistent::New(args[<%- j %>]); + baton-><%- arg.name %>Reference = Persistent::New(args[<%- jsArg %>]); +<% if (arg.isOptional) { -%> + if (args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { + <% } -%> <% if (arg.cppClassName == 'String') { -%> - String::Utf8Value <%- arg.name %>(args[<%- j %>]->ToString()); + String::Utf8Value <%- arg.name %>(args[<%- jsArg %>]->ToString()); baton-><%- arg.name %> = strdup(*<%- arg.name %>); <% } else if (arg.cppClassName == 'Array') { -%> - baton-><%- arg.name %> = Array::Cast(*args[<%- j %>]); + baton-><%- arg.name %> = Array::Cast(*args[<%- jsArg %>]); <% } else if (arg.cppClassName == 'Buffer') { -%> - baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())); + baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())); <% } else if (isV8Value(arg.cppClassName)) { -%> - baton-><%- arg.name %> = (<%- arg.cType %>) args[<%- j %>]->To<%- arg.cppClassName %>()->Value(); + baton-><%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value(); <% } else { -%> - baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())->GetValue(); + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue(); +<% } -%> +<% if (arg.isOptional) { -%> + } else { + baton-><%- arg.name %> = NULL; + } <% } -%> <% } -%> -<% if (!(arg.isReturn || arg.isSelf)) j++ -%> +<% if (!(arg.isReturn || arg.isSelf)) jsArg++; -%> <% } -%> <% } -%> - baton->callback = Persistent::New(Local::Cast(args[<%- j %>])); + baton->callback = Persistent::New(Local::Cast(args[<%- jsArg %>])); uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); @@ -188,7 +191,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); - <%- functionInfo.return.cType %> <%- resultName %> = <%- functionInfo.cFunctionName %>( + <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( <% for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; @@ -197,11 +200,11 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req <% } -%> ); <% if (functionInfo.return.isErrorCode) { -%> - if (<%- resultName %> != GIT_OK) { + if (result != GIT_OK) { baton->error = giterr_last(); } <% } else { -%> - baton->result = <%- resultName %>; + baton->result = result; <% } -%> } @@ -211,22 +214,35 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t TryCatch try_catch; if (!baton->error) { -<% if (result.isErrorCode) { %> - Handle <%- resultName %> = Local::New(Undefined()); +<% if (!returns.length) { %> + Handle result = Local::New(Undefined()); +<% } else if (returns.length == 1) { -%> +<% var to = returns[0]; to.name = "baton->" + to.name; -%> + Handle to; + <% include templates/convertToV8.cc.ejs -%> + Handle result = to; <% } else { -%> - Handle argv[1] = { External::New(baton-><%- result.name %>) }; - Handle <%- resultName %> = <%- result.cppClassName %>::constructor_template->NewInstance(1, argv); + Handle result = Object::New(); + Handle to; +<% + for (r in returns) { + var to = returns[r]; +-%> + <% include templates/convertToV8.cc.ejs -%> + result->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); + +<% } -%> <% } -%> - Handle argv2[2] = { + Handle argv[2] = { Local::New(Null()), - <%- resultName %> + result }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - Handle argv2[1] = { + Handle argv[1] = { GitError::WrapError(baton->error) }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } if (try_catch.HasCaught()) { @@ -253,51 +269,39 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t <% } else { -%> Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; -<% - for (var i = 0, j = 0; i < functionInfo.args.length ; i++) { - var arg = functionInfo.args[i]; - if (arg.isReturn || arg.isSelf) continue; --%> + <% include templates/guardArguments.cc.ejs -%> - if (args.Length() == <%- j %> || !args[<%- j %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { - return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> <%- arg.name %> is required."))); - } -<% - j++; - } --%> <% for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; if (!arg.isReturn) continue; -%> - <%- arg.cType.replace('**', '*') %> <%- arg.name %>; <% if (arg.shouldAlloc) { -%> - <%- arg.name %> = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); + <%- arg.cType %><%- arg.name %> = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); +<% } else { -%> + <%- arg.cType.replace('*', '') %><%- arg.name %> = NULL; <% } -%> <% } -%> - <% if (result.cType != "void") { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( + <% if (returns.length || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( <% - for (var i = 0, j = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; -%> - -<% if (/\*\*/.test(arg.cType)) { %>&<% } %> + <% if (cArg > 0) { %>, <% } -%><% if (arg.isReturn && !arg.shouldAlloc) { %>&<% } -%> <% if (arg.isSelf) { -%> - ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() +ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() <% } else if (arg.isReturn) { -%> - <%- arg.name %> +<%- arg.name %> <% } else if (arg.cppClassName == 'String') { -%> - stringArgToString(args[<%- j %>]->ToString()).c_str() +stringArgToString(args[<%- jsArg %>]->ToString()).c_str() <% } else if (isV8Value(arg.cppClassName)) { -%> - (<%- arg.cType %>) args[<%- j %>]->To<%- arg.cppClassName %>()->Value() +(<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value() <% } else { -%> - ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- j %>]->ToObject())->GetValue() +ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue() <% } -%> -<% if (i < functionInfo.args.length - 1) { %>, <% } -%> <% - if (!(arg.isReturn || arg.isSelf)) j++; + if (!(arg.isReturn || arg.isSelf)) jsArg++; } -%> ); @@ -308,41 +312,47 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg } <% } -%> -<% if (result.cType == "void") { -%> +<% if (!returns.length) { -%> return Undefined(); -<% } else if (isV8Value(result.cppClassName)) { -%> - return scope.Close(<%- result.cppClassName %>::New(<%- resultName %>)); -<% } else if (result.cppClassName == "External") { -%> - return scope.Close(External::New((void *)<%- resultName %>)); +<% } else if (returns.length == 1) { -%> +<% var to = returns[0]; -%> + Handle to; + <% include templates/convertToV8.cc.ejs -%> + return scope.Close(to); <% } else { -%> - // XXX need to copy object? - Handle argv[1] = { External::New((void *)<%- resultName %>) }; - return scope.Close(<%- result.cppClassName %>::constructor_template->NewInstance(1, argv)); + Handle toReturn = Object::New(); + Handle to; +<% + for (r in returns) { + var to = returns[r]; +-%> + <% include templates/convertToV8.cc.ejs -%> + toReturn->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); + +<% } -%> + return scope.Close(toReturn); <% } -%> } <% } -%> <% } -%> <% } -%> - <% if (typeof fields != 'undefined') { -%> <% for (var i in fields) { var fieldInfo = fields[i]; if (fieldInfo.ignore) continue; -%> + Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; - <%- fieldInfo.cType %> field = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; + <% var to = fieldInfo; -%> + Handle to; -<% if (isV8Value(fieldInfo.cppClassName)) { -%> - return scope.Close(<%- fieldInfo.cppClassName %>::New(field)); -<% } else if (fieldInfo.cppClassName == "External") { -%> - return scope.Close(External::New((void *)<% if (!/\*/.test(fieldInfo.cType)) { %>&<% } %>field)); -<% } else { -%> - // XXX need to copy object? - Handle argv[1] = { External::New((void *)<% if (!/\*/.test(fieldInfo.cType)) { %>&<% } %>field) }; - return scope.Close(<%- fieldInfo.cppClassName %>::constructor_template->NewInstance(1, argv)); -<% } -%> + <%- fieldInfo.cType %> <% if (!isV8Value(fieldInfo.cppClassName)) { %>*<% } %><%- fieldInfo.name %> = + <% if (!isV8Value(fieldInfo.cppClassName)) { %>&<% } %>ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; + + <% include templates/convertToV8.cc.ejs -%> + return scope.Close(to); } <% } -%> <% } -%> diff --git a/templates/convertToV8.cc.ejs b/templates/convertToV8.cc.ejs new file mode 100644 index 000000000..40a970743 --- /dev/null +++ b/templates/convertToV8.cc.ejs @@ -0,0 +1,10 @@ +<% toName = to.name || 'result' -%> +<% if (to.cppClassName == "String") { -%> + to = <%- to.cppClassName %>::New(<%- toName %>); +<% } else if (isV8Value(to.cppClassName)) { -%> + to = <%- to.cppClassName %>::New(<%- toName %>); +<% } else if (to.cppClassName == "External") { -%> + to = External::New((void *)<%- toName %>); +<% } else { -%> + to = <%- to.cppClassName %>::New((void *)<%- toName %>); +<% } -%> diff --git a/templates/guardArguments.cc.ejs b/templates/guardArguments.cc.ejs new file mode 100644 index 000000000..6674b26dd --- /dev/null +++ b/templates/guardArguments.cc.ejs @@ -0,0 +1,13 @@ +<% + var cArg = 0; + for (cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; + if (arg.isReturn || arg.isSelf) continue; +-%> +<% if (!arg.isOptional) { -%> + if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { + return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> <%- arg.name %> is required."))); + } +<% } -%> +<% jsArg++; -%> +<% } -%> diff --git a/templates/header.h.ejs b/templates/header.h.ejs index 5fd02fc2c..6cd6f1f43 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -22,6 +22,8 @@ class <%- cppClassName %> : public ObjectWrap { <% if (typeof cType != 'undefined') { -%> <%- cType %> *GetValue(); + + static Handle New(void *raw); <% } -%> private: diff --git a/test/convenience-commit.js b/test/convenience-commit.js index 15cd9b79d..cf492a1d7 100644 --- a/test/convenience-commit.js +++ b/test/convenience-commit.js @@ -272,6 +272,6 @@ exports.parentsDiffTrees = function(test) { }; process.on('uncaughtException', function(err) { - console.log(err); + console.log(err.stack); }); diff --git a/test/convenience-difflist.js b/test/convenience-difflist.js index a8d77ffbe..5a6628b04 100644 --- a/test/convenience-difflist.js +++ b/test/convenience-difflist.js @@ -40,51 +40,42 @@ exports.method = function(test){ * @param {Object} test */ exports.walkingDiffs = function(test) { - test.expect(15); + test.expect(16); git.repo.open('../.git', function(error, repository) { repository.commit(historyCountKnownSHA, function(error, commit) { commit.parents(function(error, parents) { - var parentSha = parents[0].sha(); - git.diffList.treeToTree(commit.repo, parentSha, historyCountKnownSHA, function(error, diffList) { - test.equal(null, error, 'Should not error'); - diffList.walk().on('delta', function(error, delta) { - test.equal(null, error, 'Should not error'); - test.equal(delta.oldFile.path, 'README.md', 'Old file path should match expected'); - test.equal(delta.newFile.path, 'README.md', 'New file path should match expected'); - test.equal(delta.content.length, 5, 'Content array should be of known length'); - test.equal(delta.status, git.diffList.Delta.Modified, 'Status should be known type'); - test.equal(delta.content[0].lineOrigin, git.diffList.LineOrigin.Context, 'First content item should be context'); - test.equal(delta.content[1].lineOrigin, git.diffList.LineOrigin.Context, 'Second content item should be context'); - test.equal(delta.content[2].lineOrigin, git.diffList.LineOrigin.Context, 'Third content item should be context'); + parents[0].getTree(function(error, parentTree) { + commit.getTree(function(error, commitTree) { + git.diffList.treeToTree(commit.repo, parentTree, commitTree, function(error, diffList) { + test.equal(null, error, 'Should not error'); - var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; - test.equal(delta.content[3].content, oldContent, 'Old content should match known value'); - test.equal(delta.content[3].lineOrigin, git.diffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); - test.equal(delta.content[3].contentLength, 90, 'Fourth content length should match known value'); + diffList.patches().forEach(function(patch) { + var delta = patch.delta, patch = patch.patch; + test.equal(null, error, 'Should not error'); + test.equal(delta.oldFile().path(), 'README.md', 'Old file path should match expected'); + test.equal(delta.newFile().path(), 'README.md', 'New file path should match expected'); + test.equal(patch.size(), 1, 'Content array should be of known length'); + var hunk = patch.hunk(0); - var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; - test.equal(delta.content[4].content, newContent, 'New content should match known value'); - test.equal(delta.content[4].lineOrigin, git.diffList.LineOrigin.Addition, 'Fifth content item should be addition'); - test.equal(delta.content[4].contentLength, 162, 'Fifth content length should match known value'); - test.done(); - }); - }); - }); - }); - }); -}; + test.equal(hunk.lines, 5, 'Content array should be of known length'); + test.equal(delta.status(), git.diffList.Delta.Modified, 'Status should be known type'); -exports.walkingEnd = function(test) { - test.expect(2); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parents(function(error, parents) { - var parentSha = parents[0].sha(); - git.diffList.treeToTree(commit.repo, parentSha, historyCountKnownSHA, function(error, diffList) { - diffList.walk().on('end', function(error, diffs) { - test.equal(null, error, 'Should not error'); - test.equal(diffs.length, 1, 'Diffs array should be of known length'); - test.done(); + test.equal(patch.line(0, 0).lineOrigin, git.diffList.LineOrigin.Context, 'First content item should be context'); + test.equal(patch.line(0, 1).lineOrigin, git.diffList.LineOrigin.Context, 'Second content item should be context'); + test.equal(patch.line(0, 2).lineOrigin, git.diffList.LineOrigin.Context, 'Third content item should be context'); + + var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; + test.equal(patch.line(0, 3).content, oldContent, 'Old content should match known value'); + test.equal(patch.line(0, 3).lineOrigin, git.diffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); + test.equal(patch.line(0, 3).length, 90, 'Fourth content length should match known value'); + + var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; + test.equal(patch.line(0, 4).content, newContent, 'New content should match known value'); + test.equal(patch.line(0, 4).lineOrigin, git.diffList.LineOrigin.Addition, 'Fifth content item should be addition'); + test.equal(patch.line(0, 4).length, 162, 'Fifth content length should match known value'); + test.done(); + }); + }); }); }); }); diff --git a/v0.18.0.json b/v0.18.0.json index cd581cbf9..0b8e76b8b 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -13,7 +13,7 @@ "name": "value_out", "cType": "const char **", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "repo", @@ -58,7 +58,7 @@ "name": "values_out", "cType": "const char **", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "repo", @@ -88,7 +88,7 @@ "name": "names", "cType": "const char **", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" } ], "isAsync": false, @@ -754,7 +754,7 @@ "isReturn": true, "cType": "const char **", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "ref", @@ -836,7 +836,7 @@ "name": "tracking_branch_name_out", "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "buffer_size", @@ -896,7 +896,7 @@ "name": "remote_name_out", "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "buffer_size", @@ -1743,7 +1743,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "length", @@ -1771,7 +1771,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "length", @@ -1799,7 +1799,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "length", @@ -2192,7 +2192,7 @@ "isReturn": true, "cType": "const char **", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "cfg", @@ -2769,156 +2769,115 @@ ] }, { - "filename": "diff.h", - "jsClassName": "Diff", - "cppClassName": "Diff", - "cType": "git_diff", - "freeFunctionName": "git_diff_free", + "filename": "patch.h", + "dependencies": ["../include/delta.h", "../include/diff_range.h"], + "jsClassName": "Patch", + "cppClassName": "GitPatch", + "cType": "git_diff_patch", + "freeFunctionName": "git_diff_patch_free", "functions": [ { - "cFunctionName": "git_diff_list_free", + "cFunctionName": "git_diff_patch_free", "args": [ { - "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": true, - "jsFunctionName": "listFree", - "cppFunctionName": "ListFree", + "jsFunctionName": "patchFree", + "cppFunctionName": "PatchFree", "return": { "cType": "void", "cppClassName": "void" } }, { - "cFunctionName": "git_diff_tree_to_tree", + "cFunctionName": "git_diff_patch_delta", "args": [ { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "DiffList", - "jsClassName": "DiffList" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "old_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "new_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "DiffOptions", - "jsClassName": "DiffOptions" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "treeToTree", - "cppFunctionName": "TreeToTree", + "isPrototypeMethod": true, + "jsFunctionName": "delta", + "cppFunctionName": "Delta", "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cType": "const git_diff_delta *", + "cppClassName": "GitDelta" } }, { - "cFunctionName": "git_diff_tree_to_index", + "cFunctionName": "git_diff_patch_num_hunks", "args": [ { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "DiffList", - "jsClassName": "DiffList" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "old_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "index", - "cType": "git_index *", - "cppClassName": "GitIndex", - "jsClassName": "Index" - }, - { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "DiffOptions", - "jsClassName": "DiffOptions" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "treeToIndex", - "cppFunctionName": "TreeToIndex", + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cType": "size_t", + "cppClassName": "Uint32" } }, { - "cFunctionName": "git_diff_index_to_workdir", + "cFunctionName": "git_diff_patch_line_stats", "args": [ { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "total_context", + "cType": "size_t *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true }, { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" + "name": "total_additions", + "cType": "size_t *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true }, { - "name": "index", - "cType": "git_index *", - "cppClassName": "GitIndex", - "jsClassName": "Index" + "name": "total_deletions", + "cType": "size_t *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true }, { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "DiffOptions", - "jsClassName": "DiffOptions" + "name": "patch", + "cType": "const git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "indexToWorkdir", - "cppFunctionName": "IndexToWorkdir", + "isPrototypeMethod": true, + "jsFunctionName": "stats", + "cppFunctionName": "Stats", "return": { "cType": "int", "cppClassName": "Int32", @@ -2926,65 +2885,59 @@ } }, { - "cFunctionName": "git_diff_tree_to_workdir", + "cFunctionName": "git_diff_patch_get_hunk", "args": [ { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "range", + "jsName": "range", + "cType": "const git_diff_range **", + "cppClassName": "GitDiffRange", + "jsClassName": "DiffRange", + "isReturn": true }, { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" + "name": "header", + "jsName": "header", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "isReturn": true }, { - "name": "old_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" + "name": "header_len", + "jsName": "headerLength", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isReturn": true }, { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "DiffOptions", - "jsClassName": "DiffOptions" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "treeToWorkdir", - "cppFunctionName": "TreeToWorkdir", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_diff_merge", - "args": [ + "name": "lines_in_hunk", + "jsName": "lines", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isReturn": true + }, { - "name": "onto", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true }, { - "name": "from", - "cType": "const git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "merge", - "cppFunctionName": "Merge", + "isPrototypeMethod": true, + "jsFunctionName": "hunk", + "cppFunctionName": "Hunk", "return": { "cType": "int", "cppClassName": "Int32", @@ -2992,71 +2945,100 @@ } }, { - "cFunctionName": "git_diff_find_similar", + "cFunctionName": "git_diff_patch_num_lines_in_hunk", "args": [ { - "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true }, { - "name": "options", - "cType": "git_diff_find_options *", - "cppClassName": "DiffFindOptions", - "jsClassName": "DiffFindOptions" + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "findSimilar", - "cppFunctionName": "FindSimilar", + "isPrototypeMethod": true, + "jsFunctionName": "lines", + "cppFunctionName": "Lines", "return": { "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cppClassName": "Int32" } }, { - "cFunctionName": "git_diff_foreach", + "cFunctionName": "git_diff_patch_get_line_in_hunk", "args": [ { - "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" - }, - { - "name": "file_cb", - "cType": "git_diff_file_cb", - "cppClassName": "DiffFileCb", - "jsClassName": "DiffFileCb" + "name": "line_origin", + "jsName": "lineOrigin", + "cType": "char *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true }, { - "name": "hunk_cb", - "cType": "git_diff_hunk_cb", - "cppClassName": "DiffHunkCb", - "jsClassName": "DiffHunkCb" + "name": "content", + "jsName": "content", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "isReturn": true }, { - "name": "line_cb", - "cType": "git_diff_data_cb", - "cppClassName": "DiffDataCb", - "jsClassName": "DiffDataCb" + "name": "content_len", + "jsName": "length", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isReturn": true }, { - "name": "payload", - "cType": "void *", - "cppClassName": "void", - "jsClassName": "void" + "name": "old_lineno", + "jsName": "oldLineNumber", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "isReturn": true + }, + { + "name": "new_lineno", + "jsName": "newLineNumber", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "isReturn": true + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "name": "line_of_hunk", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "foreach", - "cppFunctionName": "Foreach", + "isPrototypeMethod": true, + "jsFunctionName": "line", + "cppFunctionName": "Line", "return": { "cType": "int", "cppClassName": "Int32", @@ -3064,13 +3046,14 @@ } }, { - "cFunctionName": "git_diff_print_compact", + "cFunctionName": "git_diff_patch_print", "args": [ { - "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true }, { "name": "print_cb", @@ -3085,11 +3068,12 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "printCompact", - "cppFunctionName": "PrintCompact", + "isPrototypeMethod": true, + "jsFunctionName": "patchPrint", + "cppFunctionName": "PatchPrint", "return": { "cType": "int", "cppClassName": "Int32", @@ -3097,137 +3081,311 @@ } }, { - "cFunctionName": "git_diff_status_char", - "args": [ - { - "name": "status", - "cType": "git_delta_t", - "cppClassName": "DeltaT", - "jsClassName": "DeltaT" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "statusChar", - "cppFunctionName": "StatusChar", - "return": { - "cType": "char", - "cppClassName": "String" - } - }, - { - "cFunctionName": "git_diff_print_patch", + "cFunctionName": "git_diff_patch_to_str", "args": [ { - "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" - }, - { - "name": "print_cb", - "cType": "git_diff_data_cb", - "cppClassName": "DiffDataCb", - "jsClassName": "DiffDataCb" + "name": "string", + "cType": "char **", + "cppClassName": "String", + "jsClassName": "String", + "isReturn": true }, { - "name": "payload", - "cType": "void *", - "cppClassName": "void", - "jsClassName": "void" + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "printPatch", - "cppFunctionName": "PrintPatch", + "jsFunctionName": "toString", + "cppFunctionName": "ToString", "return": { "cType": "int", "cppClassName": "Int32", "isErrorCode": true } + } + ] + }, + { + "filename": "diff_options.h", + "dependencies": [], + "jsClassName": "DiffOptions", + "cppClassName": "GitDiffOptions", + "cType": "git_diff_options", + "freeFunctionName": "free", + "fields": [] + }, + { + "filename": "diff_find_options.h", + "dependencies": [], + "jsClassName": "DiffFindOptions", + "cppClassName": "GitDiffFindOptions", + "cType": "git_diff_find_options", + "freeFunctionName": "free", + "fields": [] + }, + { + "filename": "diff_range.h", + "dependencies": [], + "jsClassName": "DiffRange", + "cppClassName": "GitDiffRange", + "cType": "git_diff_range", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "oldStart", + "cppFunctionName": "OldStart", + "name": "old_start", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" }, { - "cFunctionName": "git_diff_num_deltas", + "jsFunctionName": "oldLines", + "cppFunctionName": "OldLines", + "name": "old_lines", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "newStart", + "cppFunctionName": "NewStart", + "name": "new_start", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "newLines", + "cppFunctionName": "NewLines", + "name": "new_lines", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + } + ] + }, + { + "filename": "diff_file.h", + "dependencies": ["../include/oid.h"], + "jsClassName": "DiffFile", + "cppClassName": "GitDiffFile", + "cType": "git_diff_file", + "fields": [ + { + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "name": "oid", + "cType": "git_oid", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "jsFunctionName": "path", + "cppFunctionName": "Path", + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "jsFunctionName": "size", + "cppFunctionName": "Size", + "name": "size", + "cType": "git_off_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "flags", + "cppFunctionName": "Flags", + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "mode", + "cppFunctionName": "Mode", + "name": "mode", + "cType": "uint16_t", + "cppClassName": "Integer", + "jsClassName": "Number" + } + ] + }, + { + "filename": "delta.h", + "dependencies": ["../include/diff_file.h"], + "jsClassName": "Delta", + "cppClassName": "GitDelta", + "cType": "git_diff_delta", + "fields": [ + { + "jsFunctionName": "oldFile", + "cppFunctionName": "OldFile", + "name": "old_file", + "cType": "git_diff_file", + "cppClassName": "GitDiffFile", + "jsClassName": "DiffFile" + }, + { + "jsFunctionName": "newFile", + "cppFunctionName": "NewFile", + "name": "new_file", + "cType": "git_diff_file", + "cppClassName": "GitDiffFile", + "jsClassName": "DiffFile" + }, + { + "jsFunctionName": "status", + "cppFunctionName": "Status", + "name": "status", + "cType": "git_delta_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "similarity", + "cppFunctionName": "Similarity", + "name": "similarity", + "cType": "uint32_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "flags", + "cppFunctionName": "Flags", + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Integer", + "jsClassName": "Number" + } + ] + }, + { + "filename": "diff_list.h", + "dependencies": ["../include/diff_options.h", "../include/diff_find_options.h", "../include/repo.h", "../include/tree.h", "../include/index.h", "../include/patch.h", "../include/delta.h"], + "jsClassName": "DiffList", + "cppClassName": "GitDiffList", + "cType": "git_diff_list", + "freeFunctionName": "git_diff_list_free", + "functions": [ + { + "cFunctionName": "git_diff_list_free", "args": [ { "name": "diff", "cType": "git_diff_list *", - "cppClassName": "DiffList", + "cppClassName": "GitDiffList", "jsClassName": "DiffList" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "numDeltas", - "cppFunctionName": "NumDeltas", + "isFree": true, + "jsFunctionName": "listFree", + "cppFunctionName": "ListFree", "return": { - "cType": "size_t", - "cppClassName": "Uint32" + "cType": "void", + "cppClassName": "void" } }, { - "cFunctionName": "git_diff_num_deltas_of_type", + "cFunctionName": "git_diff_tree_to_tree", "args": [ { "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true }, { - "name": "type", - "cType": "git_delta_t", - "cppClassName": "DeltaT", - "jsClassName": "DeltaT" + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "new_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions", + "isOptional": true } ], - "isAsync": false, - "isConstructorMethod": false, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, - "jsFunctionName": "numDeltasOfType", - "cppFunctionName": "NumDeltasOfType", + "jsFunctionName": "treeToTree", + "cppFunctionName": "TreeToTree", "return": { - "cType": "size_t", - "cppClassName": "Uint32" + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true } }, { - "cFunctionName": "git_diff_get_patch", + "cFunctionName": "git_diff_tree_to_index", "args": [ { - "name": "patch_out", - "cType": "git_diff_patch **", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true }, { - "name": "delta_out", - "cType": "const git_diff_delta **", - "cppClassName": "DiffDelta", - "jsClassName": "DiffDelta" + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" }, { - "name": "diff", - "cType": "git_diff_list *", - "cppClassName": "DiffList", - "jsClassName": "DiffList" + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" }, { - "name": "idx", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" } ], - "isAsync": false, - "isConstructorMethod": false, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, - "jsFunctionName": "getPatch", - "cppFunctionName": "GetPatch", + "jsFunctionName": "treeToIndex", + "cppFunctionName": "TreeToIndex", "return": { "cType": "int", "cppClassName": "Int32", @@ -3235,99 +3393,135 @@ } }, { - "cFunctionName": "git_diff_patch_free", + "cFunctionName": "git_diff_index_to_workdir", "args": [ { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" } ], - "isAsync": false, - "isConstructorMethod": false, + "isAsync": true, + "isConstructorMethod": true, "isPrototypeMethod": false, - "isFree": true, - "jsFunctionName": "patchFree", - "cppFunctionName": "PatchFree", + "jsFunctionName": "indexToWorkdir", + "cppFunctionName": "IndexToWorkdir", "return": { - "cType": "void", - "cppClassName": "void" + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true } }, { - "cFunctionName": "git_diff_patch_delta", + "cFunctionName": "git_diff_tree_to_workdir", "args": [ { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "patchDelta", - "cppFunctionName": "PatchDelta", + "jsFunctionName": "treeToWorkdir", + "cppFunctionName": "TreeToWorkdir", "return": { - "cType": "const git_diff_delta *", - "cppClassName": "DiffDelta" + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true } }, { - "cFunctionName": "git_diff_patch_num_hunks", + "cFunctionName": "git_diff_merge", "args": [ { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "onto", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true + }, + { + "name": "from", + "cType": "const git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList" } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "patchNumHunks", - "cppFunctionName": "PatchNumHunks", + "isPrototypeMethod": true, + "jsFunctionName": "merge", + "cppFunctionName": "Merge", "return": { - "cType": "size_t", - "cppClassName": "Uint32" + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true } }, { - "cFunctionName": "git_diff_patch_line_stats", + "cFunctionName": "git_diff_find_similar", "args": [ { - "name": "total_context", - "cType": "size_t *", - "cppClassName": "Uint32", - "jsClassName": "Number" - }, - { - "name": "total_additions", - "cType": "size_t *", - "cppClassName": "Uint32", - "jsClassName": "Number" - }, - { - "name": "total_deletions", - "cType": "size_t *", - "cppClassName": "Uint32", - "jsClassName": "Number" + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true }, { - "name": "patch", - "cType": "const git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "options", + "cType": "git_diff_find_options *", + "cppClassName": "GitDiffFindOptions", + "jsClassName": "DiffFindOptions" } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "patchLineStats", - "cppFunctionName": "PatchLineStats", + "isPrototypeMethod": true, + "jsFunctionName": "findSimilar", + "cppFunctionName": "FindSimilar", "return": { "cType": "int", "cppClassName": "Int32", @@ -3335,50 +3529,45 @@ } }, { - "cFunctionName": "git_diff_patch_get_hunk", + "cFunctionName": "git_diff_foreach", "args": [ { - "name": "range", - "cType": "const git_diff_range **", - "cppClassName": "DiffRange", - "jsClassName": "DiffRange" - }, - { - "name": "header", - "cType": "const char **", - "cppClassName": "String", - "jsClassName": "char" + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList" }, { - "name": "header_len", - "cType": "size_t *", - "cppClassName": "Uint32", - "jsClassName": "Number" + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb" }, { - "name": "lines_in_hunk", - "cType": "size_t *", - "cppClassName": "Uint32", - "jsClassName": "Number" + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb" }, { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "line_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" }, { - "name": "hunk_idx", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "patchGetHunk", - "cppFunctionName": "PatchGetHunk", + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", "return": { "cType": "int", "cppClassName": "Int32", @@ -3386,26 +3575,33 @@ } }, { - "cFunctionName": "git_diff_patch_num_lines_in_hunk", + "cFunctionName": "git_diff_print_compact", "args": [ { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList" }, { - "name": "hunk_idx", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "patchNumLinesInHunk", - "cppFunctionName": "PatchNumLinesInHunk", + "jsFunctionName": "printCompact", + "cppFunctionName": "PrintCompact", "return": { "cType": "int", "cppClassName": "Int32", @@ -3413,76 +3609,35 @@ } }, { - "cFunctionName": "git_diff_patch_get_line_in_hunk", + "cFunctionName": "git_diff_status_char", "args": [ { - "name": "line_origin", - "cType": "char *", - "cppClassName": "String", - "jsClassName": "char" - }, - { - "name": "content", - "cType": "const char **", - "cppClassName": "String", - "jsClassName": "char" - }, - { - "name": "content_len", - "cType": "size_t *", - "cppClassName": "Uint32", - "jsClassName": "Number" - }, - { - "name": "old_lineno", - "cType": "int *", - "cppClassName": "Int32", - "jsClassName": "Number" - }, - { - "name": "new_lineno", - "cType": "int *", + "name": "status", + "cType": "git_delta_t", "cppClassName": "Int32", "jsClassName": "Number" - }, - { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" - }, - { - "name": "hunk_idx", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" - }, - { - "name": "line_of_hunk", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "patchGetLineInHunk", - "cppFunctionName": "PatchGetLineInHunk", + "jsFunctionName": "statusChar", + "cppFunctionName": "StatusChar", "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cType": "char", + "cppClassName": "String" } }, { - "cFunctionName": "git_diff_patch_print", + "cFunctionName": "git_diff_print_patch", "args": [ { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true }, { "name": "print_cb", @@ -3497,11 +3652,12 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "patchPrint", - "cppFunctionName": "PatchPrint", + "isPrototypeMethod": true, + "jsFunctionName": "printPatch", + "cppFunctionName": "PrintPatch", "return": { "cType": "int", "cppClassName": "Int32", @@ -3509,26 +3665,90 @@ } }, { - "cFunctionName": "git_diff_patch_to_str", + "cFunctionName": "git_diff_num_deltas", "args": [ { - "name": "string", - "cType": "char **", - "cppClassName": "String", - "jsClassName": "char" + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32" + } + }, + { + "cFunctionName": "git_diff_num_deltas_of_type", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList" }, { - "name": "patch", - "cType": "git_diff_patch *", - "cppClassName": "DiffPatch", - "jsClassName": "DiffPatch" + "name": "type", + "cType": "git_delta_t", + "cppClassName": "Int32", + "jsClassName": "Number" } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "patchToStr", - "cppFunctionName": "PatchToStr", + "jsFunctionName": "numDeltasOfType", + "cppFunctionName": "NumDeltasOfType", + "return": { + "cType": "size_t", + "cppClassName": "Uint32" + } + }, + { + "cFunctionName": "git_diff_get_patch", + "args": [ + { + "name": "patch_out", + "jsName": "patch", + "cType": "git_diff_patch **", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isReturn": true + }, + { + "name": "delta_out", + "jsName": "delta", + "cType": "const git_diff_delta **", + "cppClassName": "GitDelta", + "jsClassName": "Delta", + "isReturn": true + }, + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "patch", + "cppFunctionName": "Patch", "return": { "cType": "int", "cppClassName": "Int32", @@ -3553,7 +3773,7 @@ { "name": "options", "cType": "const git_diff_options *", - "cppClassName": "DiffOptions", + "cppClassName": "GitDiffOptions", "jsClassName": "DiffOptions" }, { @@ -3581,6 +3801,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -3616,7 +3837,7 @@ { "name": "options", "cType": "const git_diff_options *", - "cppClassName": "DiffOptions", + "cppClassName": "GitDiffOptions", "jsClassName": "DiffOptions" }, { @@ -3644,6 +3865,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -5125,7 +5347,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "out_size", @@ -5480,7 +5702,7 @@ "isReturn": true, "cType": "const char **", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "repo", @@ -6755,7 +6977,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "id", @@ -6784,7 +7006,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "id", @@ -6833,7 +7055,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "n", @@ -9025,7 +9247,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "outlen", @@ -9065,7 +9287,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "outlen", @@ -10093,7 +10315,7 @@ "name": "path_out", "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "path_size", @@ -10698,7 +10920,7 @@ "isReturn": true, "cType": "char *", "cppClassName": "String", - "jsClassName": "char" + "jsClassName": "String" }, { "name": "len", From 0c6547222d5d27a607da31930de8e0c1c5493ca0 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Thu, 27 Jun 2013 21:27:38 +0200 Subject: [PATCH 11/28] RevWalk now code-gen'd --- TODO | 1 - gen.js | 2 +- include/blob.h | 3 + include/commit.h | 3 + include/diff_list.h | 4 + include/index.h | 6 + include/object.h | 2 + include/reference.h | 5 + include/repo.h | 2 + include/revwalk.h | 164 ++++++--- include/tag.h | 4 + include/tree.h | 2 + include/tree_entry.h | 1 + lib/commit.js | 23 +- lib/revwalk.js | 61 +--- src/blob.cc | 24 +- src/commit.cc | 24 +- src/diff_list.cc | 32 +- src/error.cc | 2 +- src/index.cc | 48 ++- src/object.cc | 16 +- src/oid.cc | 2 +- src/reference.cc | 40 ++- src/repo.cc | 16 +- src/revwalk.cc | 720 ++++++++++++++++++++++++++++++------- src/tag.cc | 32 +- src/tree.cc | 16 +- src/tree_entry.cc | 8 +- templates/class.cc.ejs | 15 +- templates/header.h.ejs | 1 + test/convenience-commit.js | 6 +- test/raw-revwalk.js | 16 - v0.18.0.json | 96 ++--- 33 files changed, 1037 insertions(+), 360 deletions(-) diff --git a/TODO b/TODO index 6bb651bb8..b00e5712f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -- replace all argv crap with Wrap static methods for tighter instantiation - rename all async methods getXXX - convert to "ignore": true for all classes - reorder functions so the raw api is oo-like diff --git a/gen.js b/gen.js index fb22567eb..0526992ce 100644 --- a/gen.js +++ b/gen.js @@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag", "Threads", "Tree", "DiffList", "Patch", "Delta", "DiffOptions", "DiffFindOptions", "DiffFile", "DiffRange"].indexOf(idef.jsClassName) > -1) { + if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag", "Threads", "Tree", "DiffList", "Patch", "Delta", "DiffOptions", "DiffFindOptions", "DiffFile", "DiffRange", "RevWalk"].indexOf(idef.jsClassName) > -1) { fs.writeFileSync( path.resolve("./include/" + idef.filename), headerTemplate(idef)); fs.writeFileSync( diff --git a/include/blob.h b/include/blob.h index 22455e8a0..ddd714667 100755 --- a/include/blob.h +++ b/include/blob.h @@ -37,6 +37,7 @@ class GitBlob : public ObjectWrap { struct LookupBaton { uv_work_t request; + int error_code; const git_error* error; git_blob * blob; Persistent repoReference; @@ -54,6 +55,7 @@ class GitBlob : public ObjectWrap { struct CreateFromFileBaton { uv_work_t request; + int error_code; const git_error* error; git_oid * id; Persistent repoReference; @@ -68,6 +70,7 @@ class GitBlob : public ObjectWrap { struct CreateFromBufferBaton { uv_work_t request; + int error_code; const git_error* error; git_oid * oid; Persistent repoReference; diff --git a/include/commit.h b/include/commit.h index d09db5254..6c28a080c 100755 --- a/include/commit.h +++ b/include/commit.h @@ -37,6 +37,7 @@ class GitCommit : public ObjectWrap { struct LookupBaton { uv_work_t request; + int error_code; const git_error* error; git_commit * commit; Persistent repoReference; @@ -58,6 +59,7 @@ class GitCommit : public ObjectWrap { struct TreeBaton { uv_work_t request; + int error_code; const git_error* error; git_tree * tree_out; Persistent commitReference; @@ -72,6 +74,7 @@ class GitCommit : public ObjectWrap { struct ParentBaton { uv_work_t request; + int error_code; const git_error* error; git_commit * out; Persistent commitReference; diff --git a/include/diff_list.h b/include/diff_list.h index 215ea0de5..177ff350f 100644 --- a/include/diff_list.h +++ b/include/diff_list.h @@ -37,6 +37,7 @@ class GitDiffList : public ObjectWrap { struct TreeToTreeBaton { uv_work_t request; + int error_code; const git_error* error; git_diff_list * diff; Persistent repoReference; @@ -55,6 +56,7 @@ class GitDiffList : public ObjectWrap { struct TreeToIndexBaton { uv_work_t request; + int error_code; const git_error* error; git_diff_list * diff; Persistent repoReference; @@ -73,6 +75,7 @@ class GitDiffList : public ObjectWrap { struct IndexToWorkdirBaton { uv_work_t request; + int error_code; const git_error* error; git_diff_list * diff; Persistent repoReference; @@ -89,6 +92,7 @@ class GitDiffList : public ObjectWrap { struct TreeToWorkdirBaton { uv_work_t request; + int error_code; const git_error* error; git_diff_list * diff; Persistent repoReference; diff --git a/include/index.h b/include/index.h index 1c5a925f8..a74610e7d 100755 --- a/include/index.h +++ b/include/index.h @@ -37,6 +37,7 @@ class GitIndex : public ObjectWrap { struct OpenBaton { uv_work_t request; + int error_code; const git_error* error; git_index * out; Persistent index_pathReference; @@ -50,6 +51,7 @@ class GitIndex : public ObjectWrap { struct ReadBaton { uv_work_t request; + int error_code; const git_error* error; Persistent indexReference; git_index * index; @@ -61,6 +63,7 @@ class GitIndex : public ObjectWrap { struct WriteBaton { uv_work_t request; + int error_code; const git_error* error; Persistent indexReference; git_index * index; @@ -72,6 +75,7 @@ class GitIndex : public ObjectWrap { struct ReadTreeBaton { uv_work_t request; + int error_code; const git_error* error; Persistent indexReference; git_index * index; @@ -85,6 +89,7 @@ class GitIndex : public ObjectWrap { struct WriteTreeBaton { uv_work_t request; + int error_code; const git_error* error; git_oid * out; Persistent indexReference; @@ -101,6 +106,7 @@ class GitIndex : public ObjectWrap { struct AddBypathBaton { uv_work_t request; + int error_code; const git_error* error; Persistent indexReference; git_index * index; diff --git a/include/object.h b/include/object.h index a39873366..8f63fb5de 100644 --- a/include/object.h +++ b/include/object.h @@ -37,6 +37,7 @@ class GitObject : public ObjectWrap { struct LookupBaton { uv_work_t request; + int error_code; const git_error* error; git_object * object; Persistent repoReference; @@ -56,6 +57,7 @@ class GitObject : public ObjectWrap { struct PeelBaton { uv_work_t request; + int error_code; const git_error* error; git_object * peeled; Persistent objectReference; diff --git a/include/reference.h b/include/reference.h index d6a56c4d7..6f36a6a6c 100644 --- a/include/reference.h +++ b/include/reference.h @@ -37,6 +37,7 @@ class GitReference : public ObjectWrap { struct LookupBaton { uv_work_t request; + int error_code; const git_error* error; git_reference * out; Persistent repoReference; @@ -51,6 +52,7 @@ class GitReference : public ObjectWrap { struct OidForNameBaton { uv_work_t request; + int error_code; const git_error* error; git_oid * out; Persistent repoReference; @@ -70,6 +72,7 @@ class GitReference : public ObjectWrap { struct ResolveBaton { uv_work_t request; + int error_code; const git_error* error; git_reference * out; Persistent refReference; @@ -84,6 +87,7 @@ class GitReference : public ObjectWrap { struct RenameBaton { uv_work_t request; + int error_code; const git_error* error; git_reference * out; Persistent refReference; @@ -100,6 +104,7 @@ class GitReference : public ObjectWrap { struct DeleteBaton { uv_work_t request; + int error_code; const git_error* error; Persistent refReference; git_reference * ref; diff --git a/include/repo.h b/include/repo.h index 638323a48..9682e5c9c 100755 --- a/include/repo.h +++ b/include/repo.h @@ -37,6 +37,7 @@ class GitRepo : public ObjectWrap { struct OpenBaton { uv_work_t request; + int error_code; const git_error* error; git_repository * out; Persistent pathReference; @@ -49,6 +50,7 @@ class GitRepo : public ObjectWrap { struct InitBaton { uv_work_t request; + int error_code; const git_error* error; git_repository * out; Persistent pathReference; diff --git a/include/revwalk.h b/include/revwalk.h index 46ef8db07..47e5900ed 100755 --- a/include/revwalk.h +++ b/include/revwalk.h @@ -1,91 +1,161 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ -#ifndef REVWALK_H -#define REVWALK_H +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITREVWALK_H +#define GITREVWALK_H #include #include +#include #include "git2.h" -#include "repo.h" - using namespace node; using namespace v8; class GitRevWalk : public ObjectWrap { public: + static Persistent constructor_template; - static void Initialize(Handle target); + static void Initialize (Handle target); - git_revwalk* GetValue(); - void SetValue(git_revwalk* revwalk); - git_repository* GetRepo(); - void SetRepo(git_repository* repository); + git_revwalk *GetValue(); - protected: - GitRevWalk() {} - ~GitRevWalk() {} + static Handle New(void *raw); - static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); + private: + GitRevWalk(git_revwalk *raw); + ~GitRevWalk(); - static Handle Reset(const Arguments& args); + static Handle New(const Arguments& args); - static Handle Allocate(const Arguments& args); - static void AllocateWork(uv_work_t *req); - static void AllocateAfterWork(uv_work_t *req); + static Handle Make(const Arguments& args); + static Handle Reset(const Arguments& args); static Handle Push(const Arguments& args); - static void PushWork(uv_work_t *req); - static void PushAfterWork(uv_work_t *req); - - static Handle Next(const Arguments& args); - static void NextWork(uv_work_t* req); - static void NextAfterWork(uv_work_t* req); + static void PushWork(uv_work_t* req); + static void PushAfterWork(uv_work_t* req); - static Handle Sorting(const Arguments& args); + struct PushBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle PushGlob(const Arguments& args); + static void PushGlobWork(uv_work_t* req); + static void PushGlobAfterWork(uv_work_t* req); - private: - git_revwalk* revwalk; - git_repository* repo; + struct PushGlobBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent globReference; + const char * glob; + Persistent callback; + }; + static Handle PushHead(const Arguments& args); + static void PushHeadWork(uv_work_t* req); + static void PushHeadAfterWork(uv_work_t* req); - struct AllocateBaton { + struct PushHeadBaton { uv_work_t request; + int error_code; const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent callback; + }; + static Handle Hide(const Arguments& args); + static void HideWork(uv_work_t* req); + static void HideAfterWork(uv_work_t* req); - GitRevWalk* revwalk; - git_revwalk *rawRevwalk; - git_repository* rawRepo; + struct HideBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent commit_idReference; + const git_oid * commit_id; + Persistent callback; + }; + static Handle HideGlob(const Arguments& args); + static void HideGlobWork(uv_work_t* req); + static void HideGlobAfterWork(uv_work_t* req); + struct HideGlobBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent globReference; + const char * glob; Persistent callback; }; + static Handle HideHead(const Arguments& args); + static void HideHeadWork(uv_work_t* req); + static void HideHeadAfterWork(uv_work_t* req); - struct PushBaton { + struct HideHeadBaton { uv_work_t request; + int error_code; const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent callback; + }; + static Handle PushRef(const Arguments& args); + static void PushRefWork(uv_work_t* req); + static void PushRefAfterWork(uv_work_t* req); - git_revwalk *rawRevwalk; - git_oid rawOid; + struct PushRefBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent refnameReference; + const char * refname; + Persistent callback; + }; + static Handle HideRef(const Arguments& args); + static void HideRefWork(uv_work_t* req); + static void HideRefAfterWork(uv_work_t* req); + struct HideRefBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent refnameReference; + const char * refname; Persistent callback; }; + static Handle Next(const Arguments& args); + static void NextWork(uv_work_t* req); + static void NextAfterWork(uv_work_t* req); struct NextBaton { uv_work_t request; - + int error_code; const git_error* error; - bool walkOver; - - git_revwalk *rawRevwalk; - git_oid rawOid; - + git_oid * out; + Persistent walkReference; + git_revwalk * walk; Persistent callback; }; + static Handle Sorting(const Arguments& args); + git_revwalk *raw; }; #endif diff --git a/include/tag.h b/include/tag.h index d0ad30fdb..9d9bb624c 100755 --- a/include/tag.h +++ b/include/tag.h @@ -37,6 +37,7 @@ class GitTag : public ObjectWrap { struct LookupBaton { uv_work_t request; + int error_code; const git_error* error; git_tag * out; Persistent repoReference; @@ -52,6 +53,7 @@ class GitTag : public ObjectWrap { struct TargetBaton { uv_work_t request; + int error_code; const git_error* error; git_object * target_out; Persistent tagReference; @@ -69,6 +71,7 @@ class GitTag : public ObjectWrap { struct CreateBaton { uv_work_t request; + int error_code; const git_error* error; git_oid * oid; Persistent repoReference; @@ -91,6 +94,7 @@ class GitTag : public ObjectWrap { struct CreateLightweightBaton { uv_work_t request; + int error_code; const git_error* error; git_oid * oid; Persistent repoReference; diff --git a/include/tree.h b/include/tree.h index 6d0885a5e..200ef555a 100755 --- a/include/tree.h +++ b/include/tree.h @@ -37,6 +37,7 @@ class GitTree : public ObjectWrap { struct LookupBaton { uv_work_t request; + int error_code; const git_error* error; git_tree * out; Persistent repoReference; @@ -56,6 +57,7 @@ class GitTree : public ObjectWrap { struct GetEntryByPathBaton { uv_work_t request; + int error_code; const git_error* error; git_tree_entry * out; Persistent rootReference; diff --git a/include/tree_entry.h b/include/tree_entry.h index 49be3f46e..7c78ec1e9 100755 --- a/include/tree_entry.h +++ b/include/tree_entry.h @@ -41,6 +41,7 @@ class GitTreeEntry : public ObjectWrap { struct GetObjectBaton { uv_work_t request; + int error_code; const git_error* error; git_object * object_out; Persistent repoReference; diff --git a/lib/commit.js b/lib/commit.js index 4fdf30c3a..224883099 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -131,19 +131,16 @@ Commit.prototype.file = function(path, callback) { * @return {EventEmitter} historyWalkEmitter */ Commit.prototype.history = function() { - var event = new events.EventEmitter(), - self = this; - - var oid = self.oid(); - (new git.revwalk(self.repo)).allocate(function createRevwalk(error, revwalk) { - var commits = []; - revwalk.walk(oid, function commitRevWalk(error, index, commit, noMoreCommits) { - if(error) { - event.emit('end', error, commits); - return false; - } + var event = new events.EventEmitter(); + + var oid = this.oid(); + var revwalk = git.revwalk.make(this.repo); + var commits = []; + event.start = function() { + revwalk.walk(oid, function commitRevWalk(error, commit) { + if (error) return event.emit('end', error, commits); - if (noMoreCommits) { + if (!commit) { /** * End event. * @@ -166,7 +163,7 @@ Commit.prototype.history = function() { event.emit('commit', null, commit); commits.push(commit); }); - }); + } return event; }; diff --git a/lib/revwalk.js b/lib/revwalk.js index f0e9d4963..b4eb69ab4 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -12,29 +12,20 @@ var RevWalk = function(repo, rawRevWalk) { if (!(repo instanceof git.repo)) { throw new git.error('First parameter for RevWalk must be a repo'); } - this.repo = repo; - if (typeof rawRevWalk !== 'undefined' && - rawRevWalk instanceof git.raw.RevWalk) { - this.rawRevWalk = rawRevWalk; - } else { - this.rawRevWalk = new git.raw.RevWalk(repo.rawRepo); + if (!(rawRevWalk instanceof git.raw.RevWalk)) { + throw new git.error('Second parameter for RevWalk must be a raw.RevWalk'); } + + this.repo = repo; + this.rawRevWalk = rawRevWalk; }; /** - * Allocate new revwalker. - * - * @param {Function} callback + * Make a new revwalker. */ -RevWalk.prototype.allocate = function(callback) { - var self = this; - self.rawRevWalk.allocate(function revwalkAllocate(error, rawRevwalk) { - if (success(error, callback)) { - self.rawRevwalk = rawRevwalk; - callback(null, self); - } - }); +RevWalk.make = function(repo) { + return new RevWalk(repo, git.raw.RevWalk.make(repo.rawRepo)); }; /** @@ -46,38 +37,18 @@ RevWalk.prototype.allocate = function(callback) { */ RevWalk.prototype.walk = function(oid, callback) { var self = this; - self.rawRevWalk.push(oid.getRawOid(), function revWalkPush(error) { - if (!success(error, callback)) { - return; - } - - var shouldContinue = true, index = 0; + this.rawRevWalk.push(oid.getRawOid(), function revWalkPush(error) { + if (!success(error, callback)) return; function walk() { - if(!shouldContinue) { - return; - } + self.rawRevWalk.next(function revWalkNext(error, oid) { + if (error) return callback(new git.error(error.message, error.code)) + if (!oid) return callback(); - self.rawRevWalk.next(function revWalkNext(error, oid, walkOver) { - if(error) { - callback(new git.error(error.message, error.code), index, commit); - return; - } - - // Finished walking history, apply callback with noMoreCommits = true - if (walkOver) { - callback(null, index, null, walkOver); - return; - } self.repo.commit(oid, function revWalkCommitLookup(error, commit) { - if(error) { - callback(new git.error(error.message, error.code), index, commit); - return; - } - if(callback(null, index, commit) === false) { - shouldContinue = false; - } - index++; + if (error) return callback(new git.error(error.message, error.code)); + + callback(null, commit); walk(); }); }); diff --git a/src/blob.cc b/src/blob.cc index 169322fdb..a087e346a 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -87,6 +87,7 @@ Handle GitBlob::Lookup(const Arguments& args) { } LookupBaton* baton = new LookupBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -107,6 +108,7 @@ void GitBlob::LookupWork(uv_work_t *req) { baton->repo, baton->id ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -117,7 +119,7 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitBlob::New((void *)baton->blob); Handle result = to; @@ -126,11 +128,13 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -199,6 +203,7 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { } CreateFromFileBaton* baton = new CreateFromFileBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -220,6 +225,7 @@ void GitBlob::CreateFromFileWork(uv_work_t *req) { baton->repo, baton->path ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -230,7 +236,7 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { CreateFromFileBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitOid::New((void *)baton->id); Handle result = to; @@ -239,11 +245,13 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -274,6 +282,7 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { } CreateFromBufferBaton* baton = new CreateFromBufferBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -297,6 +306,7 @@ void GitBlob::CreateFromBufferWork(uv_work_t *req) { baton->buffer, baton->len ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -307,7 +317,7 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { CreateFromBufferBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitOid::New((void *)baton->oid); Handle result = to; @@ -316,11 +326,13 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/commit.cc b/src/commit.cc index 7d931c645..0b425acc5 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -94,6 +94,7 @@ Handle GitCommit::Lookup(const Arguments& args) { } LookupBaton* baton = new LookupBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -114,6 +115,7 @@ void GitCommit::LookupWork(uv_work_t *req) { baton->repo, baton->id ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -124,7 +126,7 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitCommit::New((void *)baton->commit); Handle result = to; @@ -133,11 +135,13 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -256,6 +260,7 @@ Handle GitCommit::Tree(const Arguments& args) { } TreeBaton* baton = new TreeBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->commitReference = Persistent::New(args.This()); @@ -273,6 +278,7 @@ void GitCommit::TreeWork(uv_work_t *req) { &baton->tree_out, baton->commit ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -283,7 +289,7 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { TreeBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitTree::New((void *)baton->tree_out); Handle result = to; @@ -292,11 +298,13 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -347,6 +355,7 @@ Handle GitCommit::Parent(const Arguments& args) { } ParentBaton* baton = new ParentBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->commitReference = Persistent::New(args.This()); @@ -367,6 +376,7 @@ void GitCommit::ParentWork(uv_work_t *req) { baton->commit, baton->n ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -377,7 +387,7 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { ParentBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitCommit::New((void *)baton->out); Handle result = to; @@ -386,11 +396,13 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/diff_list.cc b/src/diff_list.cc index 1870baf93..0411f88c4 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -95,6 +95,7 @@ Handle GitDiffList::TreeToTree(const Arguments& args) { } TreeToTreeBaton* baton = new TreeToTreeBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -125,6 +126,7 @@ void GitDiffList::TreeToTreeWork(uv_work_t *req) { baton->new_tree, baton->opts ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -135,7 +137,7 @@ void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { TreeToTreeBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitDiffList::New((void *)baton->diff); Handle result = to; @@ -144,11 +146,13 @@ void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -183,6 +187,7 @@ Handle GitDiffList::TreeToIndex(const Arguments& args) { } TreeToIndexBaton* baton = new TreeToIndexBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -209,6 +214,7 @@ void GitDiffList::TreeToIndexWork(uv_work_t *req) { baton->index, baton->opts ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -219,7 +225,7 @@ void GitDiffList::TreeToIndexAfterWork(uv_work_t *req) { TreeToIndexBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitDiffList::New((void *)baton->diff); Handle result = to; @@ -228,11 +234,13 @@ void GitDiffList::TreeToIndexAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -264,6 +272,7 @@ Handle GitDiffList::IndexToWorkdir(const Arguments& args) { } IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -287,6 +296,7 @@ void GitDiffList::IndexToWorkdirWork(uv_work_t *req) { baton->index, baton->opts ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -297,7 +307,7 @@ void GitDiffList::IndexToWorkdirAfterWork(uv_work_t *req) { IndexToWorkdirBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitDiffList::New((void *)baton->diff); Handle result = to; @@ -306,11 +316,13 @@ void GitDiffList::IndexToWorkdirAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -341,6 +353,7 @@ Handle GitDiffList::TreeToWorkdir(const Arguments& args) { } TreeToWorkdirBaton* baton = new TreeToWorkdirBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -364,6 +377,7 @@ void GitDiffList::TreeToWorkdirWork(uv_work_t *req) { baton->old_tree, baton->opts ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -374,7 +388,7 @@ void GitDiffList::TreeToWorkdirAfterWork(uv_work_t *req) { TreeToWorkdirBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitDiffList::New((void *)baton->diff); Handle result = to; @@ -383,11 +397,13 @@ void GitDiffList::TreeToWorkdirAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/error.cc b/src/error.cc index 5ecee568a..06b4d389b 100755 --- a/src/error.cc +++ b/src/error.cc @@ -1,4 +1,4 @@ -/** + /** * Copyright (c) 2011, Tim Branyen @tbranyen * @author Michael Robinson @codeofinterest * diff --git a/src/index.cc b/src/index.cc index e503aa1be..82bb85bbe 100644 --- a/src/index.cc +++ b/src/index.cc @@ -92,6 +92,7 @@ Handle GitIndex::Open(const Arguments& args) { } OpenBaton* baton = new OpenBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->index_pathReference = Persistent::New(args[0]); @@ -110,6 +111,7 @@ void GitIndex::OpenWork(uv_work_t *req) { &baton->out, baton->index_path ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -120,7 +122,7 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitIndex::New((void *)baton->out); Handle result = to; @@ -129,11 +131,13 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -168,6 +172,7 @@ Handle GitIndex::Read(const Arguments& args) { } ReadBaton* baton = new ReadBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); @@ -184,6 +189,7 @@ void GitIndex::ReadWork(uv_work_t *req) { int result = git_index_read( baton->index ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -194,7 +200,7 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { ReadBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle result = Local::New(Undefined()); Handle argv[2] = { @@ -202,11 +208,13 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -226,6 +234,7 @@ Handle GitIndex::Write(const Arguments& args) { } WriteBaton* baton = new WriteBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); @@ -242,6 +251,7 @@ void GitIndex::WriteWork(uv_work_t *req) { int result = git_index_write( baton->index ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -252,7 +262,7 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { WriteBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle result = Local::New(Undefined()); Handle argv[2] = { @@ -260,11 +270,13 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -287,6 +299,7 @@ Handle GitIndex::ReadTree(const Arguments& args) { } ReadTreeBaton* baton = new ReadTreeBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); @@ -306,6 +319,7 @@ void GitIndex::ReadTreeWork(uv_work_t *req) { baton->index, baton->tree ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -316,7 +330,7 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { ReadTreeBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle result = Local::New(Undefined()); Handle argv[2] = { @@ -324,11 +338,13 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -349,6 +365,7 @@ Handle GitIndex::WriteTree(const Arguments& args) { } WriteTreeBaton* baton = new WriteTreeBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); @@ -366,6 +383,7 @@ void GitIndex::WriteTreeWork(uv_work_t *req) { baton->out, baton->index ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -376,7 +394,7 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { WriteTreeBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitOid::New((void *)baton->out); Handle result = to; @@ -385,11 +403,13 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -484,6 +504,7 @@ Handle GitIndex::AddBypath(const Arguments& args) { } AddBypathBaton* baton = new AddBypathBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->indexReference = Persistent::New(args.This()); @@ -504,6 +525,7 @@ void GitIndex::AddBypathWork(uv_work_t *req) { baton->index, baton->path ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -514,7 +536,7 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { AddBypathBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle result = Local::New(Undefined()); Handle argv[2] = { @@ -522,11 +544,13 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/object.cc b/src/object.cc index ea79accd6..4ee33cd7b 100644 --- a/src/object.cc +++ b/src/object.cc @@ -86,6 +86,7 @@ Handle GitObject::Lookup(const Arguments& args) { } LookupBaton* baton = new LookupBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -109,6 +110,7 @@ void GitObject::LookupWork(uv_work_t *req) { baton->id, baton->type ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -119,7 +121,7 @@ void GitObject::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitObject::New((void *)baton->object); Handle result = to; @@ -128,11 +130,13 @@ void GitObject::LookupAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -199,6 +203,7 @@ Handle GitObject::Peel(const Arguments& args) { } PeelBaton* baton = new PeelBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->objectReference = Persistent::New(args.This()); @@ -219,6 +224,7 @@ void GitObject::PeelWork(uv_work_t *req) { baton->object, baton->target_type ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -229,7 +235,7 @@ void GitObject::PeelAfterWork(uv_work_t *req) { PeelBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitObject::New((void *)baton->peeled); Handle result = to; @@ -238,11 +244,13 @@ void GitObject::PeelAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/oid.cc b/src/oid.cc index 11b7edb52..51bef2cd4 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -68,7 +68,7 @@ Handle GitOid::FromString(const Arguments& args) { return ThrowException(Exception::Error(String::New("String str is required."))); } - git_oid *out = (git_oid *)malloc(sizeof(git_oid)); + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); int result = git_oid_fromstr( out diff --git a/src/reference.cc b/src/reference.cc index 628711746..a95dbd197 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -95,6 +95,7 @@ Handle GitReference::Lookup(const Arguments& args) { } LookupBaton* baton = new LookupBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -116,6 +117,7 @@ void GitReference::LookupWork(uv_work_t *req) { baton->repo, baton->name ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -126,7 +128,7 @@ void GitReference::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitReference::New((void *)baton->out); Handle result = to; @@ -135,11 +137,13 @@ void GitReference::LookupAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -167,6 +171,7 @@ Handle GitReference::OidForName(const Arguments& args) { } OidForNameBaton* baton = new OidForNameBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -188,6 +193,7 @@ void GitReference::OidForNameWork(uv_work_t *req) { baton->repo, baton->name ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -198,7 +204,7 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { OidForNameBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitOid::New((void *)baton->out); Handle result = to; @@ -207,11 +213,13 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -343,6 +351,7 @@ Handle GitReference::Resolve(const Arguments& args) { } ResolveBaton* baton = new ResolveBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->refReference = Persistent::New(args.This()); @@ -360,6 +369,7 @@ void GitReference::ResolveWork(uv_work_t *req) { &baton->out, baton->ref ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -370,7 +380,7 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { ResolveBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitReference::New((void *)baton->out); Handle result = to; @@ -379,11 +389,13 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -455,6 +467,7 @@ Handle GitReference::Rename(const Arguments& args) { } RenameBaton* baton = new RenameBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->refReference = Persistent::New(args.This()); @@ -479,6 +492,7 @@ void GitReference::RenameWork(uv_work_t *req) { baton->new_name, baton->force ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -489,7 +503,7 @@ void GitReference::RenameAfterWork(uv_work_t *req) { RenameBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitReference::New((void *)baton->out); Handle result = to; @@ -498,11 +512,13 @@ void GitReference::RenameAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -525,6 +541,7 @@ Handle GitReference::Delete(const Arguments& args) { } DeleteBaton* baton = new DeleteBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->refReference = Persistent::New(args.This()); @@ -541,6 +558,7 @@ void GitReference::DeleteWork(uv_work_t *req) { int result = git_reference_delete( baton->ref ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -551,7 +569,7 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { DeleteBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle result = Local::New(Undefined()); Handle argv[2] = { @@ -559,11 +577,13 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/repo.cc b/src/repo.cc index 2f761ba09..761e79cf3 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -77,6 +77,7 @@ Handle GitRepo::Open(const Arguments& args) { } OpenBaton* baton = new OpenBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->pathReference = Persistent::New(args[0]); @@ -95,6 +96,7 @@ void GitRepo::OpenWork(uv_work_t *req) { &baton->out, baton->path ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -105,7 +107,7 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitRepo::New((void *)baton->out); Handle result = to; @@ -114,11 +116,13 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -145,6 +149,7 @@ Handle GitRepo::Init(const Arguments& args) { } InitBaton* baton = new InitBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->pathReference = Persistent::New(args[0]); @@ -166,6 +171,7 @@ void GitRepo::InitWork(uv_work_t *req) { baton->path, baton->is_bare ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -176,7 +182,7 @@ void GitRepo::InitAfterWork(uv_work_t *req) { InitBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitRepo::New((void *)baton->out); Handle result = to; @@ -185,11 +191,13 @@ void GitRepo::InitAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/revwalk.cc b/src/revwalk.cc index 97b10981f..93123ed05 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -1,27 +1,31 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" -#include "../include/oid.h" #include "../include/revwalk.h" +#include "../include/oid.h" #include "../include/repo.h" -#include "../include/commit.h" -#include "../include/error.h" #include "../include/functions/utilities.h" +#include "../include/functions/string.h" using namespace v8; using namespace node; -void GitRevWalk::Initialize(Handle target) { +GitRevWalk::GitRevWalk(git_revwalk *raw) { + this->raw = raw; +} + +GitRevWalk::~GitRevWalk() { + git_revwalk_free(this->raw); +} + +void GitRevWalk::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -29,231 +33,707 @@ void GitRevWalk::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("RevWalk")); - NODE_SET_PROTOTYPE_METHOD(tpl, "allocate", Allocate); + NODE_SET_METHOD(tpl, "make", Make); NODE_SET_PROTOTYPE_METHOD(tpl, "reset", Reset); NODE_SET_PROTOTYPE_METHOD(tpl, "push", Push); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushGlob", PushGlob); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushHead", PushHead); + NODE_SET_PROTOTYPE_METHOD(tpl, "hide", Hide); + NODE_SET_PROTOTYPE_METHOD(tpl, "hideGlob", HideGlob); + NODE_SET_PROTOTYPE_METHOD(tpl, "hideHead", HideHead); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushRef", PushRef); + NODE_SET_PROTOTYPE_METHOD(tpl, "hideRef", HideRef); NODE_SET_PROTOTYPE_METHOD(tpl, "next", Next); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - - // Local sort = Object::New(); - - // sort->Set(String::New("NONE"), Integer::New(0)); - // sort->Set(String::New("TOPOLOGICAL"), Integer::New(1)); - // sort->Set(String::New("TIME"), Integer::New(2)); - // sort->Set(String::New("REVERSE"), Integer::New(4)); + NODE_SET_PROTOTYPE_METHOD(tpl, "sorting", Sorting); - // tpl->Set(String::New("sort"), sort); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("RevWalk"), constructor_template); } -git_revwalk* GitRevWalk::GetValue() { - return this->revwalk; +Handle GitRevWalk::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_revwalk is required."))); + } + + GitRevWalk* object = new GitRevWalk((git_revwalk *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); } -void GitRevWalk::SetValue(git_revwalk* revwalk) { - this->revwalk = revwalk; + +Handle GitRevWalk::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRevWalk::constructor_template->NewInstance(1, argv)); } -git_repository* GitRevWalk::GetRepo() { - return this->repo; + +git_revwalk *GitRevWalk::GetValue() { + return this->raw; } -void GitRevWalk::SetRepo(git_repository* repo) { - this->repo = repo; + + +Handle GitRevWalk::Make(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + + git_revwalk *out = NULL; + + int result = git_revwalk_new( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + Handle to; + to = GitRevWalk::New((void *)out); + return scope.Close(to); } -Handle GitRevWalk::Free(const Arguments& args) { +Handle GitRevWalk::Reset(const Arguments& args) { HandleScope scope; + - GitRevWalk *revwalk = ObjectWrap::Unwrap(args.This()); + git_revwalk_reset( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - git_revwalk_free(revwalk->revwalk); return Undefined(); } -Handle GitRevWalk::New(const Arguments& args) { +Handle GitRevWalk::Push(const Arguments& args) { HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } - GitRevWalk *revwalk = new GitRevWalk(); - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - GitRepo *repo = ObjectWrap::Unwrap(args[0]->ToObject()); - revwalk->SetRepo(repo->GetValue()); + PushBaton* baton = new PushBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + baton->id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[1])); - revwalk->Wrap(args.This()); + uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); - return scope.Close(args.This()); + return Undefined(); } -Handle GitRevWalk::Reset(const Arguments& args) { +void GitRevWalk::PushWork(uv_work_t *req) { + PushBaton *baton = static_cast(req->data); + int result = git_revwalk_push( + baton->walk, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::PushAfterWork(uv_work_t *req) { HandleScope scope; + PushBaton *baton = static_cast(req->data); - GitRevWalk *revwalk = ObjectWrap::Unwrap(args.This()); - git_revwalk_reset(revwalk->revwalk); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { - return Undefined(); + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -Handle GitRevWalk::Allocate(const Arguments& args) { +Handle GitRevWalk::PushGlob(const Arguments& args) { HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String glob is required."))); + } - if(args.Length() == 0 || !args[0]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - AllocateBaton *baton = new AllocateBaton; + PushGlobBaton* baton = new PushGlobBaton; + baton->error_code = GIT_OK; + baton->error = NULL; baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->globReference = Persistent::New(args[0]); + String::Utf8Value glob(args[0]->ToString()); + baton->glob = strdup(*glob); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, PushGlobWork, (uv_after_work_cb)PushGlobAfterWork); + + return Undefined(); +} + +void GitRevWalk::PushGlobWork(uv_work_t *req) { + PushGlobBaton *baton = static_cast(req->data); + int result = git_revwalk_push_glob( + baton->walk, + baton->glob + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { + HandleScope scope; + PushGlobBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->globReference.Dispose(); + baton->callback.Dispose(); + delete baton->glob; + delete baton; +} + +Handle GitRevWalk::PushHead(const Arguments& args) { + HandleScope scope; + + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + PushHeadBaton* baton = new PushHeadBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->revwalk = ObjectWrap::Unwrap(args.This()); - baton->rawRevwalk = NULL; - baton->rawRepo = baton->revwalk->GetRepo(); + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); - uv_queue_work(uv_default_loop(), &baton->request, AllocateWork, (uv_after_work_cb)AllocateAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, PushHeadWork, (uv_after_work_cb)PushHeadAfterWork); return Undefined(); } -void GitRevWalk::AllocateWork(uv_work_t *req) { - AllocateBaton *baton = static_cast(req->data); - int returnCode = git_revwalk_new(&baton->rawRevwalk, baton->rawRepo); - if (returnCode != GIT_OK) { +void GitRevWalk::PushHeadWork(uv_work_t *req) { + PushHeadBaton *baton = static_cast(req->data); + int result = git_revwalk_push_head( + baton->walk + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitRevWalk::AllocateAfterWork(uv_work_t *req) { +void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { + HandleScope scope; + PushHeadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRevWalk::Hide(const Arguments& args) { HandleScope scope; - AllocateBaton *baton = static_cast(req->data); + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid commit_id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + HideBaton* baton = new HideBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->commit_idReference = Persistent::New(args[0]); + baton->commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, HideWork, (uv_after_work_cb)HideAfterWork); + + return Undefined(); +} +void GitRevWalk::HideWork(uv_work_t *req) { + HideBaton *baton = static_cast(req->data); + int result = git_revwalk_hide( + baton->walk, + baton->commit_id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} - if (success(baton->error, baton->callback)) { +void GitRevWalk::HideAfterWork(uv_work_t *req) { + HandleScope scope; + HideBaton *baton = static_cast(req->data); - baton->revwalk->SetValue(baton->rawRevwalk); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); Handle argv[2] = { Local::New(Null()), - baton->revwalk->handle_ + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->walkReference.Dispose(); + baton->commit_idReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -Handle GitRevWalk::Push(const Arguments& args) { +Handle GitRevWalk::HideGlob(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object."))); + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String glob is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - PushBaton* baton = new PushBaton; + HideGlobBaton* baton = new HideGlobBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->globReference = Persistent::New(args[0]); + String::Utf8Value glob(args[0]->ToString()); + baton->glob = strdup(*glob); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, HideGlobWork, (uv_after_work_cb)HideGlobAfterWork); + + return Undefined(); +} + +void GitRevWalk::HideGlobWork(uv_work_t *req) { + HideGlobBaton *baton = static_cast(req->data); + int result = git_revwalk_hide_glob( + baton->walk, + baton->glob + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { + HandleScope scope; + HideGlobBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->globReference.Dispose(); + baton->callback.Dispose(); + delete baton->glob; + delete baton; +} +Handle GitRevWalk::HideHead(const Arguments& args) { + HandleScope scope; + + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + HideHeadBaton* baton = new HideHeadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, HideHeadWork, (uv_after_work_cb)HideHeadAfterWork); + + return Undefined(); +} + +void GitRevWalk::HideHeadWork(uv_work_t *req) { + HideHeadBaton *baton = static_cast(req->data); + int result = git_revwalk_hide_head( + baton->walk + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { + HandleScope scope; + HideHeadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRevWalk::PushRef(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + PushRefBaton* baton = new PushRefBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawRevwalk = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawOid = *ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->refnameReference = Persistent::New(args[0]); + String::Utf8Value refname(args[0]->ToString()); + baton->refname = strdup(*refname); baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, PushRefWork, (uv_after_work_cb)PushRefAfterWork); return Undefined(); } -void GitRevWalk::PushWork(uv_work_t *req) { - PushBaton *baton = static_cast(req->data); - - git_revwalk_sorting(baton->rawRevwalk, GIT_SORT_TIME | GIT_SORT_REVERSE); - int returnCode = git_revwalk_push(baton->rawRevwalk, &baton->rawOid); - if (returnCode) { +void GitRevWalk::PushRefWork(uv_work_t *req) { + PushRefBaton *baton = static_cast(req->data); + int result = git_revwalk_push_ref( + baton->walk, + baton->refname + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitRevWalk::PushAfterWork(uv_work_t *req) { + +void GitRevWalk::PushRefAfterWork(uv_work_t *req) { HandleScope scope; - PushBaton *baton = static_cast(req->data); + PushRefBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { - argv[0] = Local::New(Null()); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->refnameReference.Dispose(); + baton->callback.Dispose(); + delete baton->refname; + delete baton; +} + +Handle GitRevWalk::HideRef(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); } + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + HideRefBaton* baton = new HideRefBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->refnameReference = Persistent::New(args[0]); + String::Utf8Value refname(args[0]->ToString()); + baton->refname = strdup(*refname); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, HideRefWork, (uv_after_work_cb)HideRefAfterWork); + + return Undefined(); +} + +void GitRevWalk::HideRefWork(uv_work_t *req) { + HideRefBaton *baton = static_cast(req->data); + int result = git_revwalk_hide_ref( + baton->walk, + baton->refname + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::HideRefAfterWork(uv_work_t *req) { + HandleScope scope; + HideRefBaton *baton = static_cast(req->data); + TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + if (try_catch.HasCaught()) { - node::FatalException(try_catch); + node::FatalException(try_catch); } - delete req; + baton->walkReference.Dispose(); + baton->refnameReference.Dispose(); + baton->callback.Dispose(); + delete baton->refname; + delete baton; } Handle GitRevWalk::Next(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { + + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } NextBaton* baton = new NextBaton; - - baton->request.data = baton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawRevwalk = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->walkOver = false; + baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, NextWork, (uv_after_work_cb)NextAfterWork); return Undefined(); } + void GitRevWalk::NextWork(uv_work_t *req) { NextBaton *baton = static_cast(req->data); - - int returnCode = git_revwalk_next(&baton->rawOid, baton->rawRevwalk); - if (returnCode != GIT_OK) { - if (returnCode == GIT_ITEROVER) { - baton->walkOver = true; - } else { - git_revwalk_reset(baton->rawRevwalk); - baton->error = giterr_last(); - } + int result = git_revwalk_next( + baton->out, + baton->walk + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); } } + void GitRevWalk::NextAfterWork(uv_work_t *req) { HandleScope scope; NextBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - git_oid *rawOid = (git_oid *)malloc(sizeof(git_oid)); - git_oid_cpy(rawOid, &baton->rawOid); - Handle argv[1] = { External::New(rawOid) }; - Local oid = GitOid::constructor_template->NewInstance(1, argv); - - Local argv2[3] = { + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitOid::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { Local::New(Null()), - oid, - Local::New(Boolean::New(baton->walkOver)) + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + GitError::WrapError(baton->error) }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 3, argv2); - if(try_catch.HasCaught()) { - FatalException(try_catch); - } + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->walkReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRevWalk::Sorting(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number sort_mode is required."))); + } + + + git_revwalk_sorting( + ObjectWrap::Unwrap(args.This())->GetValue() + , (unsigned int) args[0]->ToUint32()->Value() + ); + + + return Undefined(); } Persistent GitRevWalk::constructor_template; diff --git a/src/tag.cc b/src/tag.cc index c9fb7b2f4..bb08d4b37 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -92,6 +92,7 @@ Handle GitTag::Lookup(const Arguments& args) { } LookupBaton* baton = new LookupBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -112,6 +113,7 @@ void GitTag::LookupWork(uv_work_t *req) { baton->repo, baton->id ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -122,7 +124,7 @@ void GitTag::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitTag::New((void *)baton->out); Handle result = to; @@ -131,11 +133,13 @@ void GitTag::LookupAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -170,6 +174,7 @@ Handle GitTag::Target(const Arguments& args) { } TargetBaton* baton = new TargetBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->tagReference = Persistent::New(args.This()); @@ -187,6 +192,7 @@ void GitTag::TargetWork(uv_work_t *req) { &baton->target_out, baton->tag ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -197,7 +203,7 @@ void GitTag::TargetAfterWork(uv_work_t *req) { TargetBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitObject::New((void *)baton->target_out); Handle result = to; @@ -206,11 +212,13 @@ void GitTag::TargetAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -318,6 +326,7 @@ Handle GitTag::Create(const Arguments& args) { } CreateBaton* baton = new CreateBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -352,6 +361,7 @@ void GitTag::CreateWork(uv_work_t *req) { baton->message, baton->force ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -362,7 +372,7 @@ void GitTag::CreateAfterWork(uv_work_t *req) { CreateBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitOid::New((void *)baton->oid); Handle result = to; @@ -371,11 +381,13 @@ void GitTag::CreateAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -414,6 +426,7 @@ Handle GitTag::CreateLightweight(const Arguments& args) { } CreateLightweightBaton* baton = new CreateLightweightBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -441,6 +454,7 @@ void GitTag::CreateLightweightWork(uv_work_t *req) { baton->target, baton->force ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -451,7 +465,7 @@ void GitTag::CreateLightweightAfterWork(uv_work_t *req) { CreateLightweightBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitOid::New((void *)baton->oid); Handle result = to; @@ -460,11 +474,13 @@ void GitTag::CreateLightweightAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/tree.cc b/src/tree.cc index bc8864472..61d284084 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -86,6 +86,7 @@ Handle GitTree::Lookup(const Arguments& args) { } LookupBaton* baton = new LookupBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -106,6 +107,7 @@ void GitTree::LookupWork(uv_work_t *req) { baton->repo, baton->id ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -116,7 +118,7 @@ void GitTree::LookupAfterWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitTree::New((void *)baton->out); Handle result = to; @@ -125,11 +127,13 @@ void GitTree::LookupAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -235,6 +239,7 @@ Handle GitTree::GetEntryByPath(const Arguments& args) { } GetEntryByPathBaton* baton = new GetEntryByPathBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->rootReference = Persistent::New(args.This()); @@ -256,6 +261,7 @@ void GitTree::GetEntryByPathWork(uv_work_t *req) { baton->root, baton->path ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -266,7 +272,7 @@ void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { GetEntryByPathBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitTreeEntry::New((void *)baton->out); Handle result = to; @@ -275,11 +281,13 @@ void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 1b7eb4d1a..02f656595 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -137,6 +137,7 @@ Handle GitTreeEntry::GetObject(const Arguments& args) { } GetObjectBaton* baton = new GetObjectBaton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); @@ -157,6 +158,7 @@ void GitTreeEntry::GetObjectWork(uv_work_t *req) { baton->repo, baton->entry ); + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -167,7 +169,7 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { GetObjectBaton *baton = static_cast(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { Handle to; to = GitObject::New((void *)baton->object_out); Handle result = to; @@ -176,11 +178,13 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 5adb6b269..d84b395d3 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -146,6 +146,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg } <%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; + baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; <% @@ -180,6 +181,11 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <% } -%> <% } -%> <% if (!(arg.isReturn || arg.isSelf)) jsArg++; -%> +<% } else { -%> +<% if (arg.shouldAlloc) { -%> + baton-><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); +<% } else { -%> +<% } -%> <% } -%> <% } -%> baton->callback = Persistent::New(Local::Cast(args[<%- jsArg %>])); @@ -200,6 +206,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req <% } -%> ); <% if (functionInfo.return.isErrorCode) { -%> + baton->error_code = result; if (result != GIT_OK) { baton->error = giterr_last(); } @@ -213,7 +220,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); TryCatch try_catch; - if (!baton->error) { + if (baton->error_code == GIT_OK) { <% if (!returns.length) { %> Handle result = Local::New(Undefined()); <% } else if (returns.length == 1) { -%> @@ -238,11 +245,13 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t result }; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else { + } else if (baton->error) { Handle argv[1] = { GitError::WrapError(baton->error) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } if (try_catch.HasCaught()) { @@ -277,7 +286,7 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg if (!arg.isReturn) continue; -%> <% if (arg.shouldAlloc) { -%> - <%- arg.cType %><%- arg.name %> = (<%- functionInfo.args[0].cType %>)malloc(sizeof(<%- cType %>)); + <%- arg.cType %><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); <% } else { -%> <%- arg.cType.replace('*', '') %><%- arg.name %> = NULL; <% } -%> diff --git a/templates/header.h.ejs b/templates/header.h.ejs index 6cd6f1f43..1a31a7fe7 100644 --- a/templates/header.h.ejs +++ b/templates/header.h.ejs @@ -57,6 +57,7 @@ class <%- cppClassName %> : public ObjectWrap { struct <%- functionInfo.cppFunctionName %>Baton { uv_work_t request; + int error_code; const git_error* error; <% for (var i = 0; i < functionInfo.args.length; i++) { diff --git a/test/convenience-commit.js b/test/convenience-commit.js index cf492a1d7..daaa75d9a 100644 --- a/test/convenience-commit.js +++ b/test/convenience-commit.js @@ -188,10 +188,10 @@ exports.history = function(test) { historyCount++; }).on('end', function(error, commits) { test.equals(null, error, 'There should be no errors'); - test.equals(historyCount, expectedHistoryCount, 'Manual count does not match expected'); - test.equals(commits.length, expectedHistoryCount, '"end" count does not match expected'); + test.equals(historyCount, expectedHistoryCount); + test.equals(commits.length, expectedHistoryCount); test.done(); - }); + }).start(); }); }); }; diff --git a/test/raw-revwalk.js b/test/raw-revwalk.js index 9aa0bd250..469f18b51 100644 --- a/test/raw-revwalk.js +++ b/test/raw-revwalk.js @@ -22,19 +22,3 @@ var helper = { } } }; - -/** - * RevWalk - */ -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.RevWalk, 'RevWalk'); - - // Ensure we get an instance of Oid - git.Repo.open('../.git', function(error, repository) { - test.ok(new git.RevWalk(repository) instanceof git.RevWalk, 'Invocation returns an instance of RevWalk'); - test.done(); - }); -}; diff --git a/v0.18.0.json b/v0.18.0.json index 0b8e76b8b..0061e871d 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -11366,8 +11366,9 @@ }, { "filename": "revwalk.h", - "jsClassName": "Revwalk", - "cppClassName": "GitRevwalk", + "dependencies": ["../include/oid.h", "../include/repo.h"], + "jsClassName": "RevWalk", + "cppClassName": "GitRevWalk", "cType": "git_revwalk", "freeFunctionName": "git_revwalk_free", "functions": [ @@ -11378,8 +11379,8 @@ "name": "out", "isReturn": true, "cType": "git_revwalk **", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk" + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk" }, { "name": "repo", @@ -11392,8 +11393,8 @@ "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "jsFunctionName": "new", - "cppFunctionName": "New", + "jsFunctionName": "make", + "cppFunctionName": "Make", "return": { "cType": "int", "cppClassName": "Int32", @@ -11406,8 +11407,8 @@ { "name": "walker", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true } ], @@ -11427,8 +11428,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11438,7 +11439,7 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "push", @@ -11455,8 +11456,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11466,7 +11467,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "pushGlob", @@ -11483,12 +11484,12 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "pushHead", @@ -11505,8 +11506,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11516,7 +11517,7 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "hide", @@ -11533,8 +11534,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11544,7 +11545,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "hideGlob", @@ -11561,12 +11562,12 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "hideHead", @@ -11583,8 +11584,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11594,7 +11595,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "pushRef", @@ -11611,8 +11612,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11622,7 +11623,7 @@ "jsClassName": "String" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "hideRef", @@ -11640,19 +11641,21 @@ "name": "out", "isReturn": true, "cType": "git_oid *", + "shouldAlloc": true, "cppClassName": "GitOid", "jsClassName": "Oid" }, { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk" + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "next", "cppFunctionName": "Next", "return": { @@ -11667,8 +11670,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11694,8 +11697,8 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true }, { @@ -11705,7 +11708,8 @@ "jsClassName": "String" } ], - "isAsync": false, + "ignore": "This is in the documentation, but doesn't seem to exist!", + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "pushRange", @@ -11722,10 +11726,11 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk" + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -11743,11 +11748,12 @@ { "name": "walk", "cType": "git_revwalk *", - "cppClassName": "GitRevwalk", - "jsClassName": "Revwalk", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, From 271c65ed16ab147cee715e1076e1d716156cc5a3 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Thu, 27 Jun 2013 22:06:27 +0200 Subject: [PATCH 12/28] Removed unnecessary Error wrapper --- binding.gyp | 2 - example/raw-repo.js | 3 +- gen.js | 12 +- include/branch.h | 48 +++ include/error.h | 39 -- include/functions/utilities.h | 15 - include/remote.h | 88 ++++ include/utils.h | 19 - lib/blob.js | 4 +- lib/error.js | 62 --- lib/index.js | 1 - lib/revwalk.js | 6 +- lib/tree.js | 4 +- lib/tree_entry.js | 4 +- lib/utilities.js | 13 +- src/base.cc | 3 - src/blob.cc | 9 +- src/branch.cc | 360 ++++++++++++++++ src/commit.cc | 9 +- src/delta.cc | 1 - src/diff_file.cc | 1 - src/diff_find_options.cc | 1 - src/diff_list.cc | 15 +- src/diff_options.cc | 1 - src/diff_range.cc | 1 - src/error.cc | 112 ----- src/index.cc | 21 +- src/object.cc | 5 +- src/oid.cc | 3 +- src/patch.cc | 9 +- src/reference.cc | 27 +- src/remote.cc | 785 ++++++++++++++++++++++++++++++++++ src/repo.cc | 5 +- src/revwalk.cc | 21 +- src/signature.cc | 3 +- src/tag.cc | 13 +- src/threads.cc | 3 +- src/time.cc | 1 - src/tree.cc | 5 +- src/tree_entry.cc | 3 +- templates/class.cc.ejs | 5 +- test/convenience-error.js | 85 ---- test/convenience-repo.js | 2 +- test/raw-error.js | 67 --- test/raw-repo.js | 2 +- test/utilities.js | 10 +- v0.18.0.json | 63 ++- 47 files changed, 1426 insertions(+), 545 deletions(-) create mode 100644 include/branch.h delete mode 100755 include/error.h delete mode 100644 include/functions/utilities.h create mode 100644 include/remote.h delete mode 100644 include/utils.h delete mode 100644 lib/error.js create mode 100644 src/branch.cc delete mode 100755 src/error.cc create mode 100644 src/remote.cc delete mode 100644 test/convenience-error.js delete mode 100644 test/raw-error.js diff --git a/binding.gyp b/binding.gyp index c843a8eed..f0919a220 100644 --- a/binding.gyp +++ b/binding.gyp @@ -6,7 +6,6 @@ 'src/base.cc', 'src/blob.cc', 'src/commit.cc', - 'src/error.cc', 'src/oid.cc', 'src/reference.cc', 'src/object.cc', @@ -28,7 +27,6 @@ 'src/threads.cc', 'src/wrapper.cc', 'src/functions/string.cc', - 'src/functions/utilities.cc' ], 'include_dirs': [ diff --git a/example/raw-repo.js b/example/raw-repo.js index bda7da00e..b569f2ade 100644 --- a/example/raw-repo.js +++ b/example/raw-repo.js @@ -2,8 +2,7 @@ var git = require( '../' ).raw, path = require( 'path' ); -var repo = new git.Repo(), - error = new git.Error(); +var repo = new git.Repo(); // Access existing repository repo.open( path.resolve( '../.git' ), function( err ) { diff --git a/gen.js b/gen.js index 0526992ce..d05c6d7ad 100644 --- a/gen.js +++ b/gen.js @@ -8,10 +8,10 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), for (var i in idefs) { var idef = idefs[i]; - if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag", "Threads", "Tree", "DiffList", "Patch", "Delta", "DiffOptions", "DiffFindOptions", "DiffFile", "DiffRange", "RevWalk"].indexOf(idef.jsClassName) > -1) { - fs.writeFileSync( - path.resolve("./include/" + idef.filename), headerTemplate(idef)); - fs.writeFileSync( - path.resolve("./src/" + path.basename(idef.filename, '.h') + '.cc'), classTemplate(idef)); - } + if (idef.ignore) continue; + + fs.writeFileSync( + path.resolve("./include/" + idef.filename), headerTemplate(idef)); + fs.writeFileSync( + path.resolve("./src/" + path.basename(idef.filename, '.h') + '.cc'), classTemplate(idef)); } diff --git a/include/branch.h b/include/branch.h new file mode 100644 index 000000000..bfbf9bcdb --- /dev/null +++ b/include/branch.h @@ -0,0 +1,48 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef BRANCH_H +#define BRANCH_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class Branch : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_branch *GetValue(); + + static Handle New(void *raw); + + private: + Branch(git_branch *raw); + ~Branch(); + + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static Handle Delete(const Arguments& args); + static Handle Foreach(const Arguments& args); + static Handle Move(const Arguments& args); + static Handle Lookup(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Upstream(const Arguments& args); + static Handle SetUpstream(const Arguments& args); + static Handle UpstreamName(const Arguments& args); + static Handle IsHead(const Arguments& args); + static Handle RemoteName(const Arguments& args); + git_branch *raw; +}; + +#endif diff --git a/include/error.h b/include/error.h deleted file mode 100755 index 101a51122..000000000 --- a/include/error.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#ifndef ERROR_H -#define ERROR_H - -#include - -#include "git2.h" - -using namespace v8; -using namespace node; - -/** - * Wrapper for libgit2 git_error. - */ -class GitError : public ObjectWrap { - public: - - static Persistent constructor_template; - - static void Initialize(Handle target); - - static Local WrapError(const git_error* error); - - protected: - GitError() {}; - ~GitError() {}; - - const git_error* error; - - static Handle New(const Arguments& args); -}; - -#endif diff --git a/include/functions/utilities.h b/include/functions/utilities.h deleted file mode 100644 index ad9ec84c2..000000000 --- a/include/functions/utilities.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef UTILITY_FUNCTIONS -#define UTILITY_FUNCTIONS - -#include -#include - -#include "git2.h" - -#include "../../include/error.h" - -using namespace v8; - -bool success(const git_error* error, Persistent callback); - -#endif diff --git a/include/remote.h b/include/remote.h new file mode 100644 index 000000000..e965ae164 --- /dev/null +++ b/include/remote.h @@ -0,0 +1,88 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef REMOTE_H +#define REMOTE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class Remote : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_remote *GetValue(); + + static Handle New(void *raw); + + private: + Remote(git_remote *raw); + ~Remote(); + + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static void CreateWork(uv_work_t* req); + static void CreateAfterWork(uv_work_t* req); + + struct CreateBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_remote * out; + Persistent repoReference; + git_repository * repo; + Persistent nameReference; + const char * name; + Persistent urlReference; + const char * url; + Persistent callback; + }; + static Handle CreateInmemory(const Arguments& args); + static Handle Load(const Arguments& args); + static Handle Save(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Url(const Arguments& args); + static Handle Pushurl(const Arguments& args); + static Handle SetUrl(const Arguments& args); + static Handle SetPushurl(const Arguments& args); + static Handle SetFetchspec(const Arguments& args); + static Handle Fetchspec(const Arguments& args); + static Handle SetPushspec(const Arguments& args); + static Handle Pushspec(const Arguments& args); + static Handle Connect(const Arguments& args); + static Handle Ls(const Arguments& args); + static Handle Download(const Arguments& args); + static Handle Connected(const Arguments& args); + static Handle Stop(const Arguments& args); + static Handle Disconnect(const Arguments& args); + static Handle Free(const Arguments& args); + static Handle UpdateTips(const Arguments& args); + static Handle ValidUrl(const Arguments& args); + static Handle SupportedUrl(const Arguments& args); + static Handle List(const Arguments& args); + static Handle CheckCert(const Arguments& args); + static Handle SetCredAcquireCb(const Arguments& args); + static Handle SetTransport(const Arguments& args); + static Handle SetCallbacks(const Arguments& args); + static Handle Stats(const Arguments& args); + static Handle Autotag(const Arguments& args); + static Handle SetAutotag(const Arguments& args); + static Handle Rename(const Arguments& args); + static Handle UpdateFetchhead(const Arguments& args); + static Handle SetUpdateFetchhead(const Arguments& args); + static Handle IsValidName(const Arguments& args); + git_remote *raw; +}; + +#endif diff --git a/include/utils.h b/include/utils.h deleted file mode 100644 index f8a4faf55..000000000 --- a/include/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H - -// Credit: @samcday -// http://sambro.is-super-awesome.com/2011/03/03/creating-a-proper-buffer-in-a-node-c-addon/ -#define MAKE_FAST_BUFFER(NG_SLOW_BUFFER, NG_FAST_BUFFER) \ - Local NG_JS_BUFFER = Local::Cast( \ - Context::GetCurrent()->Global()->Get( \ - String::New("Buffer"))); \ - \ - Handle NG_JS_ARGS[3] = { \ - NG_SLOW_BUFFER->handle_, \ - Integer::New(Buffer::Length(NG_SLOW_BUFFER)), \ - Integer::New(0) \ - }; \ - \ - NG_FAST_BUFFER = NG_JS_BUFFER->NewInstance(3, NG_JS_ARGS); - -#endif diff --git a/lib/blob.js b/lib/blob.js index 8f66519cb..86d1ebc95 100644 --- a/lib/blob.js +++ b/lib/blob.js @@ -8,8 +8,8 @@ var git = require('../'), * @param {git.raw.Blob} [rawBlob = new git.raw.Blob(rawRepo)] Raw blob object. */ var Blob = function(rawBlob) { - if(!(rawBlob instanceof git.raw.Blob)) { - throw new git.error('First parameter for Blob must be a raw blob'); + if (!(rawBlob instanceof git.raw.Blob)) { + throw new Exception('First parameter for Blob must be a raw blob'); } this.rawBlob = rawBlob; }; diff --git a/lib/error.js b/lib/error.js deleted file mode 100644 index 9fbeac5a4..000000000 --- a/lib/error.js +++ /dev/null @@ -1,62 +0,0 @@ -var git = require('../'), - util = require('util'); - -/** - * GitError constructor. - * - * @constructor - * @param {String} [message = 'No message'] The error description. Set from giterr_last->message. - * @param {Integer} [code = git.raw.Error.codes.GITERR_INVALID] The error code. Set from giterr_last->klass - */ -var GitError = function(message, code) { - Error.call(this); - Error.captureStackTrace(this, exports.error); - - this.name = 'GitError'; - this.message = message || 'No message'; - this.code = code || git.raw.Error.codes.GITERR_INVALID; -}; - -util.inherits(GitError, Error); - -/** - * Refer to vendor/libgit2/include/git2/errors.h for error code definitions. - * - * @readonly - * @enum {Integer} - */ -GitError.prototype.codes = { - /** 0 */ GITERR_NOMEMORY: git.raw.Error.codes.GITERR_NOMEMORY, - /** 1 */ GITERR_OS: git.raw.Error.codes.GITERR_OS, - /** 2 */ GITERR_INVALID: git.raw.Error.codes.GITERR_INVALID, - /** 3 */ GITERR_REFERENCE: git.raw.Error.codes.GITERR_REFERENCE, - /** 4 */ GITERR_ZLIB: git.raw.Error.codes.GITERR_ZLIB, - /** 5 */ GITERR_REPOSITORY: git.raw.Error.codes.GITERR_REPOSITORY, - /** 6 */ GITERR_CONFIG: git.raw.Error.codes.GITERR_CONFIG, - /** 7 */ GITERR_REGEX: git.raw.Error.codes.GITERR_REGEX, - /** 8 */ GITERR_ODB: git.raw.Error.codes.GITERR_ODB, - /** 9 */ GITERR_INDEX: git.raw.Error.codes.GITERR_INDEX, - /** 10 */ GITERR_OBJECT: git.raw.Error.codes.GITERR_OBJECT, - /** 11 */ GITERR_NET: git.raw.Error.codes.GITERR_NET, - /** 12 */ GITERR_TAG: git.raw.Error.codes.GITERR_TAG, - /** 13 */ GITERR_TREE: git.raw.Error.codes.GITERR_TREE -}; - -/** - * Refer to vendor/libgit2/include/git2/errors.h for return code definitions. - * - * @readonly - * @enum {Integer} - */ -GitError.prototype.returnCodes = { - /** 0 */ GIT_OK: git.raw.Error.returnCodes.GIT_OK, - /** -1 */ GIT_ERROR: git.raw.Error.returnCodes.GIT_ERROR, - /** -3 */ GIT_ENOTFOUND: git.raw.Error.returnCodes.GIT_ENOTFOUND, - /** -4 */ GIT_EEXISTS: git.raw.Error.returnCodes.GIT_EEXISTS, - /** -5 */ GIT_EAMBIGUOUS: git.raw.Error.returnCodes.GIT_EAMBIGUOUS, - /** -6 */ GIT_EBUFS: git.raw.Error.returnCodes.GIT_EBUFS, - /** -30 */ GIT_PASSTHROUGH: git.raw.Error.returnCodes.GIT_PASSTHROUGH, - /** -31 */ GIT_ITEROVER: git.raw.Error.returnCodes.GIT_ITEROVER -}; - -exports.error = GitError; diff --git a/lib/index.js b/lib/index.js index 432860a29..641ee813b 100755 --- a/lib/index.js +++ b/lib/index.js @@ -29,7 +29,6 @@ try { // Initialize objects that need to access their raw counterparts exports.diffList = require('./diff_list.js').diffList; -exports.error = require('./error.js').error; exports.entry = require('./tree_entry.js').entry; // Set version diff --git a/lib/revwalk.js b/lib/revwalk.js index b4eb69ab4..aaf8e99aa 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -10,11 +10,11 @@ var git = require('../'), */ var RevWalk = function(repo, rawRevWalk) { if (!(repo instanceof git.repo)) { - throw new git.error('First parameter for RevWalk must be a repo'); + throw new Exception('First parameter for RevWalk must be a repo'); } if (!(rawRevWalk instanceof git.raw.RevWalk)) { - throw new git.error('Second parameter for RevWalk must be a raw.RevWalk'); + throw new Exception('Second parameter for RevWalk must be a raw.RevWalk'); } this.repo = repo; @@ -42,7 +42,7 @@ RevWalk.prototype.walk = function(oid, callback) { function walk() { self.rawRevWalk.next(function revWalkNext(error, oid) { - if (error) return callback(new git.error(error.message, error.code)) + if (error) return callback(new git.error(error.message, error.code)); if (!oid) return callback(); self.repo.commit(oid, function revWalkCommitLookup(error, commit) { diff --git a/lib/tree.js b/lib/tree.js index 78b0225ab..ec632d7b6 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -11,11 +11,11 @@ var git = require('../'), */ var Tree = function(repo, rawTree) { if(!(repo instanceof git.repo)) { - throw new git.error('First parameter for Tree must be a raw repo'); + throw new Exception('First parameter for Tree must be a raw repo'); } if(!(rawTree instanceof git.raw.Tree)) { - throw new git.error('Second parameter for Tree must be a raw tree'); + throw new Exception('Second parameter for Tree must be a raw tree'); } this.repo = repo; diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 84c5b1147..9bb92edb1 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -11,11 +11,11 @@ var git = require('../'), */ var TreeEntry = function(repo, rawTreeEntry) { if(!(repo instanceof git.repo)) { - throw new git.error('First parameter for Tree Entry must be a repo', 0); + throw new Error('First parameter for Tree Entry must be a repo', 0); } if(!(rawTreeEntry instanceof git.raw.TreeEntry)) { - throw new git.error('Second parameter for Tree Entry must be a raw tree entry', 0); + throw new Error('Second parameter for Tree Entry must be a raw tree entry', 0); } this.repo = repo; diff --git a/lib/utilities.js b/lib/utilities.js index f7d62b3c0..09dfa83b5 100755 --- a/lib/utilities.js +++ b/lib/utilities.js @@ -14,17 +14,8 @@ var utilities = { * @return {Boolean} True if the error was null, false otherwise. */ success: function(error, callback) { - if (typeof callback !== 'function') { - throw new Error('Callback must be provided'); - } - if (error) { - if (error instanceof git.error) { - callback(error); - } else { - callback(new git.error(error.message, error.code)); - } - return false; - } + if (typeof callback !== 'function') throw new Error('Callback must be provided'); + if (error) return callback(error); return true; } }; diff --git a/src/base.cc b/src/base.cc index ac49bd008..4e8121c58 100755 --- a/src/base.cc +++ b/src/base.cc @@ -14,7 +14,6 @@ #include "../include/reference.h" #include "../include/signature.h" #include "../include/time.h" -#include "../include/error.h" #include "../include/blob.h" #include "../include/repo.h" #include "../include/oid.h" @@ -39,8 +38,6 @@ extern "C" void init(Handle target) { Wrapper::Initialize(target); - GitError::Initialize(target); - GitReference::Initialize(target); GitIndex::Initialize(target); GitTag::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index a087e346a..efcdcb1b2 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -13,7 +13,6 @@ #include "../include/wrapper.h" #include "node_buffer.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -130,7 +129,7 @@ void GitBlob::LookupAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -247,7 +246,7 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -328,7 +327,7 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -354,7 +353,7 @@ Handle GitBlob::IsBinary(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); diff --git a/src/branch.cc b/src/branch.cc new file mode 100644 index 000000000..fab0224f3 --- /dev/null +++ b/src/branch.cc @@ -0,0 +1,360 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/branch.h" + +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +Branch::Branch(git_branch *raw) { + this->raw = raw; +} + +Branch::~Branch() { + git_branch_free(this->raw); +} + +void Branch::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Branch")); + + NODE_SET_METHOD(tpl, "create", Create); + NODE_SET_METHOD(tpl, "delete", Delete); + NODE_SET_METHOD(tpl, "foreach", Foreach); + NODE_SET_METHOD(tpl, "move", Move); + NODE_SET_METHOD(tpl, "lookup", Lookup); + NODE_SET_METHOD(tpl, "name", Name); + NODE_SET_METHOD(tpl, "upstream", Upstream); + NODE_SET_METHOD(tpl, "setUpstream", SetUpstream); + NODE_SET_METHOD(tpl, "upstreamName", UpstreamName); + NODE_SET_METHOD(tpl, "isHead", IsHead); + NODE_SET_METHOD(tpl, "remoteName", RemoteName); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Branch"), constructor_template); +} + +Handle Branch::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_branch is required."))); + } + + Branch* object = new Branch((git_branch *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle Branch::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(Branch::constructor_template->NewInstance(1, argv)); +} + +git_branch *Branch::GetValue() { + return this->raw; +} + + +Handle Branch::Create(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String branch_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Commit target is required."))); + } + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + + int result = git_branch_create( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , (int) args[3]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); +} + +Handle Branch::Delete(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + + + int result = git_branch_delete( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Branch::Foreach(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number list_flags is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("BranchForeachCb branch_cb is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("void payload is required."))); + } + + + int result = git_branch_foreach( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , (unsigned int) args[1]->ToUint32()->Value() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , ObjectWrap::Unwrap(args[3]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Branch::Move(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String new_branch_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + + int result = git_branch_move( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + , (int) args[2]->ToInt32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); +} + +Handle Branch::Lookup(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String branch_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("BranchT branch_type is required."))); + } + + git_reference *out = NULL; + + int result = git_branch_lookup( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); +} + +Handle Branch::Name(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference ref is required."))); + } + + const char *out = NULL; + + int result = git_branch_name( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = String::New(out); + return scope.Close(to); +} + +Handle Branch::Upstream(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + + git_reference *out = NULL; + + int result = git_branch_upstream( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); +} + +Handle Branch::SetUpstream(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String upstream_name is required."))); + } + + + int result = git_branch_set_upstream( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Branch::UpstreamName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tracking_branch_name_out is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number buffer_size is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 3 || !args[3]->IsString()) { + return ThrowException(Exception::Error(String::New("String canonical_branch_name is required."))); + } + + + int result = git_branch_upstream_name( + stringArgToString(args[0]->ToString()).c_str() + , (size_t) args[1]->ToUint32()->Value() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , stringArgToString(args[3]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Branch::IsHead(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + + + int result = git_branch_is_head( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Branch::RemoteName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String remote_name_out is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number buffer_size is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 3 || !args[3]->IsString()) { + return ThrowException(Exception::Error(String::New("String canonical_branch_name is required."))); + } + + + int result = git_branch_remote_name( + stringArgToString(args[0]->ToString()).c_str() + , (size_t) args[1]->ToUint32()->Value() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , stringArgToString(args[3]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Persistent Branch::constructor_template; diff --git a/src/commit.cc b/src/commit.cc index 0b425acc5..e37a69bd1 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -13,7 +13,6 @@ #include "../include/signature.h" #include "../include/tree.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -137,7 +136,7 @@ void GitCommit::LookupAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -300,7 +299,7 @@ void GitCommit::TreeAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -398,7 +397,7 @@ void GitCommit::ParentAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -447,7 +446,7 @@ Handle GitCommit::NthGenAncestor(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; diff --git a/src/delta.cc b/src/delta.cc index 7aad77a5a..37e8994f5 100644 --- a/src/delta.cc +++ b/src/delta.cc @@ -10,7 +10,6 @@ #include "../include/delta.h" #include "../include/diff_file.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; diff --git a/src/diff_file.cc b/src/diff_file.cc index b3e5f589a..16e18839b 100644 --- a/src/diff_file.cc +++ b/src/diff_file.cc @@ -10,7 +10,6 @@ #include "../include/diff_file.h" #include "../include/oid.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc index d4cebc759..916069908 100644 --- a/src/diff_find_options.cc +++ b/src/diff_find_options.cc @@ -9,7 +9,6 @@ #include "../include/diff_find_options.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; diff --git a/src/diff_list.cc b/src/diff_list.cc index 0411f88c4..e7a62048d 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -16,7 +16,6 @@ #include "../include/patch.h" #include "../include/delta.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -148,7 +147,7 @@ void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -236,7 +235,7 @@ void GitDiffList::TreeToIndexAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -318,7 +317,7 @@ void GitDiffList::IndexToWorkdirAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -399,7 +398,7 @@ void GitDiffList::TreeToWorkdirAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -429,7 +428,7 @@ Handle GitDiffList::Merge(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -448,7 +447,7 @@ Handle GitDiffList::FindSimilar(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -506,7 +505,7 @@ Handle GitDiffList::Patch(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle toReturn = Object::New(); diff --git a/src/diff_options.cc b/src/diff_options.cc index aadd012f4..58894d3f3 100644 --- a/src/diff_options.cc +++ b/src/diff_options.cc @@ -9,7 +9,6 @@ #include "../include/diff_options.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; diff --git a/src/diff_range.cc b/src/diff_range.cc index fcf986369..bbd02e8c1 100644 --- a/src/diff_range.cc +++ b/src/diff_range.cc @@ -9,7 +9,6 @@ #include "../include/diff_range.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; diff --git a/src/error.cc b/src/error.cc deleted file mode 100755 index 06b4d389b..000000000 --- a/src/error.cc +++ /dev/null @@ -1,112 +0,0 @@ - /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#include -#include - -#include "cvv8/v8-convert.hpp" - -#include "git2.h" - -#include "../include/error.h" - -using namespace v8; -using namespace node; -using namespace cvv8; - -/** - * Copied from libgit2/include/errors.h, to allow exporting to JS - */ -typedef enum { - _GIT_OK = 0, - _GIT_ERROR = -1, - _GIT_ENOTFOUND = -3, - _GIT_EEXISTS = -4, - _GIT_EAMBIGUOUS = -5, - _GIT_EBUFS = -6, - - _GIT_PASSTHROUGH = -30, - _GIT_ITEROVER = -31, -} git_error_return_t; - -namespace cvv8 { - template <> - struct NativeToJS : NativeToJS {}; - - template <> - struct NativeToJS : NativeToJS {}; -} - -void GitError::Initialize (Handle target) { - HandleScope scope; - - Local tpl = FunctionTemplate::New(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(String::NewSymbol("Error")); - - // Add libgit2 error codes to error object - Local libgit2Errors = Object::New(); - - libgit2Errors->Set(String::NewSymbol("GITERR_NOMEMORY"), CastToJS(GITERR_NOMEMORY), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_OS"), CastToJS(GITERR_OS), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_INVALID"), CastToJS(GITERR_INVALID), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_REFERENCE"), CastToJS(GITERR_REFERENCE), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_ZLIB"), CastToJS(GITERR_ZLIB), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_REPOSITORY"), CastToJS(GITERR_REPOSITORY), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_CONFIG"), CastToJS(GITERR_CONFIG), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_REGEX"), CastToJS(GITERR_REGEX), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_ODB"), CastToJS(GITERR_ODB), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_INDEX"), CastToJS(GITERR_INDEX), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_OBJECT"), CastToJS(GITERR_OBJECT), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_NET"), CastToJS(GITERR_NET), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_TAG"), CastToJS(GITERR_TAG), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_TREE"), CastToJS(GITERR_TREE), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_INDEXER"), CastToJS(GITERR_INDEXER), ReadOnly); - - // Add libgit2 error codes to error object - Local libgit2ReturnCodes = Object::New(); - - libgit2ReturnCodes->Set(String::NewSymbol("GIT_OK"), CastToJS(_GIT_OK), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_ERROR"), CastToJS(_GIT_ERROR), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_ENOTFOUND"), CastToJS(_GIT_ENOTFOUND), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_EEXISTS"), CastToJS(_GIT_EEXISTS), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_EAMBIGUOUS"), CastToJS(_GIT_EAMBIGUOUS), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_EBUFS"), CastToJS(_GIT_EBUFS), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_PASSTHROUGH"), CastToJS(_GIT_PASSTHROUGH), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_ITEROVER"), CastToJS(_GIT_ITEROVER), ReadOnly); - - constructor_template = Persistent::New(tpl->GetFunction()); - constructor_template->Set(String::NewSymbol("codes"), libgit2Errors, ReadOnly); - constructor_template->Set(String::NewSymbol("returnCodes"), libgit2ReturnCodes, ReadOnly); - - - target->Set(String::NewSymbol("Error"), constructor_template); -} - -Local GitError::WrapError(const git_error* error) { - - Local gitError = GitError::constructor_template->NewInstance(); - Local stackTrace = StackTrace::CurrentStackTrace(10); - - gitError->Set(String::NewSymbol("stackTrace"), CastToJS(stackTrace->AsArray())); - gitError->Set(String::NewSymbol("message"), String::New(error->message)); - gitError->Set(String::NewSymbol("code"), Integer::New(error->klass)); - - return gitError; -} - -Handle GitError::New(const Arguments& args) { - HandleScope scope; - - GitError *error = new GitError(); - error->Wrap(args.This()); - - return scope.Close(args.This()); -} - -Persistent GitError::constructor_template; diff --git a/src/index.cc b/src/index.cc index 82bb85bbe..c0fe3595b 100644 --- a/src/index.cc +++ b/src/index.cc @@ -12,7 +12,6 @@ #include "../include/repo.h" #include "../include/tree.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -133,7 +132,7 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -210,7 +209,7 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -272,7 +271,7 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -340,7 +339,7 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -405,7 +404,7 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -463,7 +462,7 @@ Handle GitIndex::Remove(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -486,7 +485,7 @@ Handle GitIndex::RemoveDirectory(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -546,7 +545,7 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -576,7 +575,7 @@ Handle GitIndex::RemoveBypath(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -617,7 +616,7 @@ Handle GitIndex::ConflictRemove(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); diff --git a/src/object.cc b/src/object.cc index 4ee33cd7b..a9079b867 100644 --- a/src/object.cc +++ b/src/object.cc @@ -11,7 +11,6 @@ #include "../include/oid.h" #include "../include/repo.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -132,7 +131,7 @@ void GitObject::LookupAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -246,7 +245,7 @@ void GitObject::PeelAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { diff --git a/src/oid.cc b/src/oid.cc index 51bef2cd4..6013403b8 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -9,7 +9,6 @@ #include "../include/oid.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -76,7 +75,7 @@ Handle GitOid::FromString(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; diff --git a/src/patch.cc b/src/patch.cc index 96d6fb00c..c1d4c55f5 100644 --- a/src/patch.cc +++ b/src/patch.cc @@ -11,7 +11,6 @@ #include "../include/delta.h" #include "../include/diff_range.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -113,7 +112,7 @@ Handle GitPatch::Stats(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle toReturn = Object::New(); @@ -151,7 +150,7 @@ Handle GitPatch::Hunk(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle toReturn = Object::New(); @@ -216,7 +215,7 @@ Handle GitPatch::Line(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle toReturn = Object::New(); @@ -250,7 +249,7 @@ Handle GitPatch::ToString(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; diff --git a/src/reference.cc b/src/reference.cc index a95dbd197..159c8a242 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -12,7 +12,6 @@ #include "../include/oid.h" #include "../include/object.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -139,7 +138,7 @@ void GitReference::LookupAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -215,7 +214,7 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -258,7 +257,7 @@ Handle GitReference::CreateSymbolic(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; @@ -292,7 +291,7 @@ Handle GitReference::Create(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; @@ -391,7 +390,7 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -421,7 +420,7 @@ Handle GitReference::SetSymbolicTarget(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; @@ -444,7 +443,7 @@ Handle GitReference::setTarget(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; @@ -514,7 +513,7 @@ void GitReference::RenameAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -579,7 +578,7 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -603,7 +602,7 @@ Handle GitReference::IsBranch(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -618,7 +617,7 @@ Handle GitReference::IsRemote(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -639,7 +638,7 @@ Handle GitReference::Peel(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; @@ -659,7 +658,7 @@ Handle GitReference::IsValidName(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); diff --git a/src/remote.cc b/src/remote.cc new file mode 100644 index 000000000..32149460e --- /dev/null +++ b/src/remote.cc @@ -0,0 +1,785 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/remote.h" + +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +Remote::Remote(git_remote *raw) { + this->raw = raw; +} + +Remote::~Remote() { + git_remote_free(this->raw); +} + +void Remote::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Remote")); + + NODE_SET_METHOD(tpl, "create", Create); + NODE_SET_METHOD(tpl, "createInmemory", CreateInmemory); + NODE_SET_METHOD(tpl, "load", Load); + NODE_SET_PROTOTYPE_METHOD(tpl, "save", Save); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushurl", Pushurl); + NODE_SET_PROTOTYPE_METHOD(tpl, "setUrl", SetUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "setPushurl", SetPushurl); + NODE_SET_PROTOTYPE_METHOD(tpl, "setFetchspec", SetFetchspec); + NODE_SET_PROTOTYPE_METHOD(tpl, "fetchspec", Fetchspec); + NODE_SET_PROTOTYPE_METHOD(tpl, "setPushspec", SetPushspec); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushspec", Pushspec); + NODE_SET_PROTOTYPE_METHOD(tpl, "connect", Connect); + NODE_SET_PROTOTYPE_METHOD(tpl, "ls", Ls); + NODE_SET_PROTOTYPE_METHOD(tpl, "download", Download); + NODE_SET_PROTOTYPE_METHOD(tpl, "connected", Connected); + NODE_SET_PROTOTYPE_METHOD(tpl, "stop", Stop); + NODE_SET_PROTOTYPE_METHOD(tpl, "disconnect", Disconnect); + NODE_SET_METHOD(tpl, "free", Free); + NODE_SET_PROTOTYPE_METHOD(tpl, "updateTips", UpdateTips); + NODE_SET_METHOD(tpl, "validUrl", ValidUrl); + NODE_SET_METHOD(tpl, "supportedUrl", SupportedUrl); + NODE_SET_METHOD(tpl, "list", List); + NODE_SET_PROTOTYPE_METHOD(tpl, "checkCert", CheckCert); + NODE_SET_PROTOTYPE_METHOD(tpl, "setCredAcquireCb", SetCredAcquireCb); + NODE_SET_PROTOTYPE_METHOD(tpl, "setTransport", SetTransport); + NODE_SET_PROTOTYPE_METHOD(tpl, "setCallbacks", SetCallbacks); + NODE_SET_PROTOTYPE_METHOD(tpl, "stats", Stats); + NODE_SET_METHOD(tpl, "autotag", Autotag); + NODE_SET_PROTOTYPE_METHOD(tpl, "setAutotag", SetAutotag); + NODE_SET_PROTOTYPE_METHOD(tpl, "rename", Rename); + NODE_SET_PROTOTYPE_METHOD(tpl, "updateFetchhead", UpdateFetchhead); + NODE_SET_PROTOTYPE_METHOD(tpl, "setUpdateFetchhead", SetUpdateFetchhead); + NODE_SET_METHOD(tpl, "isValidName", IsValidName); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Remote"), constructor_template); +} + +Handle Remote::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_remote is required."))); + } + + Remote* object = new Remote((git_remote *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle Remote::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(Remote::constructor_template->NewInstance(1, argv)); +} + +git_remote *Remote::GetValue() { + return this->raw; +} + + +Handle Remote::Create(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 2 || !args[2]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateBaton* baton = new CreateBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->nameReference = Persistent::New(args[1]); + String::Utf8Value name(args[1]->ToString()); + baton->name = strdup(*name); + baton->urlReference = Persistent::New(args[2]); + String::Utf8Value url(args[2]->ToString()); + baton->url = strdup(*url); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateWork, (uv_after_work_cb)CreateAfterWork); + + return Undefined(); +} + +void Remote::CreateWork(uv_work_t *req) { + CreateBaton *baton = static_cast(req->data); + int result = git_remote_create( + &baton->out, + baton->repo, + baton->name, + baton->url + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void Remote::CreateAfterWork(uv_work_t *req) { + HandleScope scope; + CreateBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = Remote::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); + baton->urlReference.Dispose(); + baton->callback.Dispose(); + delete baton->name; + delete baton->url; + delete baton; +} + +Handle Remote::CreateInmemory(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String fetch is required."))); + } + if (args.Length() == 2 || !args[2]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + git_remote *out = NULL; + + int result = git_remote_create_inmemory( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + , stringArgToString(args[2]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = Remote::New((void *)out); + return scope.Close(to); +} + +Handle Remote::Load(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + git_remote *out = NULL; + + int result = git_remote_load( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , stringArgToString(args[1]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = Remote::New((void *)out); + return scope.Close(to); +} + +Handle Remote::Save(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_save( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_remote_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +Handle Remote::Url(const Arguments& args) { + HandleScope scope; + + + const char * result = git_remote_url( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +Handle Remote::Pushurl(const Arguments& args) { + HandleScope scope; + + + const char * result = git_remote_pushurl( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +Handle Remote::SetUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("const url is required."))); + } + + + int result = git_remote_set_url( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::SetPushurl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("const url is required."))); + } + + + int result = git_remote_set_pushurl( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::SetFetchspec(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String spec is required."))); + } + + + int result = git_remote_set_fetchspec( + ObjectWrap::Unwrap(args.This())->GetValue() + , stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Fetchspec(const Arguments& args) { + HandleScope scope; + + + const git_refspec * result = git_remote_fetchspec( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = Refspec::New((void *)result); + return scope.Close(to); +} + +Handle Remote::SetPushspec(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String spec is required."))); + } + + + int result = git_remote_set_pushspec( + ObjectWrap::Unwrap(args.This())->GetValue() + , stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Pushspec(const Arguments& args) { + HandleScope scope; + + + const git_refspec * result = git_remote_pushspec( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = Refspec::New((void *)result); + return scope.Close(to); +} + +Handle Remote::Connect(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Direction direction is required."))); + } + + + int result = git_remote_connect( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Ls(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("HeadlistCb list_cb is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("void payload is required."))); + } + + + int result = git_remote_ls( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Download(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("TransferProgressCallback progress_cb is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("void payload is required."))); + } + + + int result = git_remote_download( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Connected(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_connected( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Stop(const Arguments& args) { + HandleScope scope; + + + git_remote_stop( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return Undefined(); +} + +Handle Remote::Disconnect(const Arguments& args) { + HandleScope scope; + + + git_remote_disconnect( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return Undefined(); +} + +Handle Remote::Free(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Remote remote is required."))); + } + + + git_remote_free( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + + return Undefined(); +} + +Handle Remote::UpdateTips(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_update_tips( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::ValidUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + + int result = git_remote_valid_url( + stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::SupportedUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("const url is required."))); + } + + + int result = git_remote_supported_url( + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::List(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + + git_strarray out = NULL; + + int result = git_remote_list( + &out + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = Strarray::New((void *)out); + return scope.Close(to); +} + +Handle Remote::CheckCert(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number check is required."))); + } + + + git_remote_check_cert( + ObjectWrap::Unwrap(args.This())->GetValue() + , (int) args[0]->ToInt32()->Value() + ); + + + return Undefined(); +} + +Handle Remote::SetCredAcquireCb(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("CredAcquireCb cred_acquire_cb is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("void payload is required."))); + } + + + git_remote_set_cred_acquire_cb( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + ); + + + return Undefined(); +} + +Handle Remote::SetTransport(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Transport transport is required."))); + } + + + int result = git_remote_set_transport( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::SetCallbacks(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("RemoteCallbacks callbacks is required."))); + } + + + int result = git_remote_set_callbacks( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::Stats(const Arguments& args) { + HandleScope scope; + + + const git_transfer_progress * result = git_remote_stats( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + Handle to; + to = TransferProgress::New((void *)result); + return scope.Close(to); +} + +Handle Remote::Autotag(const Arguments& args) { + HandleScope scope; + + + GIT_EXTERN( result = git_remote_autotag( + ); + + + Handle to; + to = GIT_EXTERN(::New((void *)result); + return scope.Close(to); +} + +Handle Remote::SetAutotag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("RemoteAutotagOptionT value is required."))); + } + + + git_remote_set_autotag( + ObjectWrap::Unwrap(args.This())->GetValue() + , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + + return Undefined(); +} + +Handle Remote::Rename(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String new_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("RemoteRenameProblemCb callback is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("void payload is required."))); + } + + + int result = git_remote_rename( + ObjectWrap::Unwrap(args.This())->GetValue() + , stringArgToString(args[0]->ToString()).c_str() + , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::UpdateFetchhead(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_update_fetchhead( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle Remote::SetUpdateFetchhead(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number value is required."))); + } + + + git_remote_set_update_fetchhead( + ObjectWrap::Unwrap(args.This())->GetValue() + , (int) args[0]->ToInt32()->Value() + ); + + + return Undefined(); +} + +Handle Remote::IsValidName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String remote_name is required."))); + } + + + int result = git_remote_is_valid_name( + stringArgToString(args[0]->ToString()).c_str() + ); + + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Persistent Remote::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 761e79cf3..54182eb01 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -9,7 +9,6 @@ #include "../include/repo.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -118,7 +117,7 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -193,7 +192,7 @@ void GitRepo::InitAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { diff --git a/src/revwalk.cc b/src/revwalk.cc index 93123ed05..739cdd0db 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -11,7 +11,6 @@ #include "../include/oid.h" #include "../include/repo.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -89,7 +88,7 @@ Handle GitRevWalk::Make(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; @@ -162,7 +161,7 @@ void GitRevWalk::PushAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -232,7 +231,7 @@ void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -296,7 +295,7 @@ void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -364,7 +363,7 @@ void GitRevWalk::HideAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -434,7 +433,7 @@ void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -498,7 +497,7 @@ void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -567,7 +566,7 @@ void GitRevWalk::PushRefAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -638,7 +637,7 @@ void GitRevWalk::HideRefAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -705,7 +704,7 @@ void GitRevWalk::NextAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { diff --git a/src/signature.cc b/src/signature.cc index cc80fd715..3f2c843f8 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -10,7 +10,6 @@ #include "../include/signature.h" #include "../include/time.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -83,7 +82,7 @@ Handle GitSignature::Now(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; diff --git a/src/tag.cc b/src/tag.cc index bb08d4b37..6f58f540e 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -13,7 +13,6 @@ #include "../include/object.h" #include "../include/signature.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -135,7 +134,7 @@ void GitTag::LookupAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -214,7 +213,7 @@ void GitTag::TargetAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -383,7 +382,7 @@ void GitTag::CreateAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -476,7 +475,7 @@ void GitTag::CreateLightweightAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -511,7 +510,7 @@ Handle GitTag::Delete(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); @@ -531,7 +530,7 @@ Handle GitTag::Peel(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } Handle to; diff --git a/src/threads.cc b/src/threads.cc index de1eb583b..a46818c96 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -9,7 +9,6 @@ #include "../include/threads.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -35,7 +34,7 @@ Handle GitThreads::Init(const Arguments& args) { ); if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } return Undefined(); diff --git a/src/time.cc b/src/time.cc index 25849c7fb..215870caa 100644 --- a/src/time.cc +++ b/src/time.cc @@ -9,7 +9,6 @@ #include "../include/time.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; diff --git a/src/tree.cc b/src/tree.cc index 61d284084..e7dfc664a 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -12,7 +12,6 @@ #include "../include/oid.h" #include "../include/tree_entry.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -129,7 +128,7 @@ void GitTree::LookupAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -283,7 +282,7 @@ void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 02f656595..98f962d5a 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -12,7 +12,6 @@ #include "../include/repo.h" #include "../include/object.h" -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -180,7 +179,7 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index d84b395d3..4e5e47ff6 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -26,7 +26,6 @@ <% } -%> <% } -%> -#include "../include/functions/utilities.h" #include "../include/functions/string.h" using namespace v8; @@ -247,7 +246,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else if (baton->error) { Handle argv[1] = { - GitError::WrapError(baton->error) + Exception::Error(String::New(baton->error->message)) }; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); } else { @@ -317,7 +316,7 @@ ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->Get <% if (functionInfo.return.isErrorCode) { -%> if (result != GIT_OK) { - return ThrowException(GitError::WrapError(giterr_last())); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } <% } -%> diff --git a/test/convenience-error.js b/test/convenience-error.js deleted file mode 100644 index 327ad2761..000000000 --- a/test/convenience-error.js +++ /dev/null @@ -1,85 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require( 'fs' ); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Test that the error object is present. - * - * @param {Object} test - */ -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.error, 'Error'); - test.done(); -}; - -exports.codes = function(test) { - test.expect(14); - var error = new git.error(); - test.equal(error.codes.GITERR_NOMEMORY, git.raw.Error.codes.GITERR_NOMEMORY, 'GITERR_NOMEMORY code should match expected value'); - test.equal(error.codes.GITERR_OS, git.raw.Error.codes.GITERR_OS, 'GITERR_OS code should match expected value'); - test.equal(error.codes.GITERR_INVALID, git.raw.Error.codes.GITERR_INVALID, 'GITERR_INVALID code should match expected value'); - test.equal(error.codes.GITERR_REFERENCE, git.raw.Error.codes.GITERR_REFERENCE, 'GITERR_REFERENCE code should match expected value'); - test.equal(error.codes.GITERR_ZLIB, git.raw.Error.codes.GITERR_ZLIB, 'GITERR_ZLIB code should match expected value'); - test.equal(error.codes.GITERR_REPOSITORY, git.raw.Error.codes.GITERR_REPOSITORY, 'GITERR_REPOSITORY code should match expected value'); - test.equal(error.codes.GITERR_CONFIG, git.raw.Error.codes.GITERR_CONFIG, 'GITERR_CONFIG code should match expected value'); - test.equal(error.codes.GITERR_REGEX, git.raw.Error.codes.GITERR_REGEX, 'GITERR_REGEX code should match expected value'); - test.equal(error.codes.GITERR_ODB, git.raw.Error.codes.GITERR_ODB, 'GITERR_ODB code should match expected value'); - test.equal(error.codes.GITERR_INDEX, git.raw.Error.codes.GITERR_INDEX, 'GITERR_INDEX code should match expected value'); - test.equal(error.codes.GITERR_OBJECT, git.raw.Error.codes.GITERR_OBJECT, 'GITERR_OBJECT code should match expected value'); - test.equal(error.codes.GITERR_NET, git.raw.Error.codes.GITERR_NET, 'GITERR_NET code should match expected value'); - test.equal(error.codes.GITERR_TAG, git.raw.Error.codes.GITERR_TAG, 'GITERR_TAG code should match expected value'); - test.equal(error.codes.GITERR_TREE, git.raw.Error.codes.GITERR_TREE, 'GITERR_TREE code should match expected value'); - test.done(); -}; - -exports.returnCodes = function(test) { - test.expect(8); - var error = new git.error(); - test.equal(error.returnCodes.GIT_OK, git.raw.Error.returnCodes.GIT_OK, 'GIT_OK return code should match expected value'); - test.equal(error.returnCodes.GIT_ERROR, git.raw.Error.returnCodes.GIT_ERROR, 'GIT_ERROR return code should match expected value'); - test.equal(error.returnCodes.GIT_ENOTFOUND, git.raw.Error.returnCodes.GIT_ENOTFOUND, 'GIT_ENOTFOUND return code should match expected value'); - test.equal(error.returnCodes.GIT_EEXISTS, git.raw.Error.returnCodes.GIT_EEXISTS, 'GIT_EEXISTS return code should match expected value'); - test.equal(error.returnCodes.GIT_EAMBIGUOUS, git.raw.Error.returnCodes.GIT_EAMBIGUOUS, 'GIT_EAMBIGUOUS return code should match expected value'); - test.equal(error.returnCodes.GIT_EBUFS, git.raw.Error.returnCodes.GIT_EBUFS, 'GIT_EBUFS return code should match expected value'); - test.equal(error.returnCodes.GIT_PASSTHROUGH, git.raw.Error.returnCodes.GIT_PASSTHROUGH, 'GIT_PASSTHROUGH return code should match expected value'); - test.equal(error.returnCodes.GIT_ITEROVER, git.raw.Error.returnCodes.GIT_ITEROVER, 'GIT_ITEROVER return code should match expected value'); - test.done(); -}; - -/** - * Test that - * - * @param {Object} test - */ -exports.improperCommitId = function(test) { - test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit('not a proper commit sha', function(error, commit) { - test.notEqual(error.code, git.error.GIT_SUCCESS, 'Attempting to get commit by invalid SHA should error'); - test.done(); - }); - }); -}; - diff --git a/test/convenience-repo.js b/test/convenience-repo.js index 2b39768e1..0567e1f2b 100644 --- a/test/convenience-repo.js +++ b/test/convenience-repo.js @@ -39,7 +39,7 @@ exports.method = function(test){ // Test invalid repository git.repo.open('/etc/hosts', function(error, repository) { - test.equals(error.code, error.codes.GITERR_REPOSITORY, error.message, 'Invalid repository error code'); + test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); // Test valid repository git.repo.open('../.git', function(error, repository) { diff --git a/test/raw-error.js b/test/raw-error.js deleted file mode 100644 index 3c23a4244..000000000 --- a/test/raw-error.js +++ /dev/null @@ -1,67 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Error -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Error, 'Error'); - - // Ensure we get an instance of Error - test.ok(new git.Error() instanceof git.Error, 'Invocation returns an instance of Error'); - - test.done(); -}; - -exports.codes = function(test) { - test.expect(23); - - test.equals(git.Error.returnCodes.GIT_OK, 0, 'GIT_OK should equal 0'), - test.equals(git.Error.returnCodes.GIT_ERROR, -1, 'GIT_ERROR should equal -1'), - test.equals(git.Error.returnCodes.GIT_ENOTFOUND, -3, 'GIT_ENOTFOUND should equal -3'), - test.equals(git.Error.returnCodes.GIT_EEXISTS, -4, 'GIT_EEXISTS should equal -4'), - test.equals(git.Error.returnCodes.GIT_EAMBIGUOUS, -5, 'GIT_EAMBIGUOUS should equal -5'), - test.equals(git.Error.returnCodes.GIT_EBUFS, -6, 'GIT_EBUFS should equal -6'), - test.equals(git.Error.returnCodes.GIT_PASSTHROUGH, -30, 'GIT_PASSTHROUGH should equal -30'), - test.equals(git.Error.returnCodes.GIT_ITEROVER, -31, 'GIT_ITEROVER should equal -31'), - - test.equals(git.Error.codes.GITERR_NOMEMORY, 0, 'GITERR_NOMEMORY should equal 0'); - test.equals(git.Error.codes.GITERR_OS, 1, 'GITERR_OS should equal 1'); - test.equals(git.Error.codes.GITERR_INVALID, 2, 'GITERR_INVALID should equal 2'); - test.equals(git.Error.codes.GITERR_REFERENCE, 3, 'GITERR_REFERENCE should equal 3'); - test.equals(git.Error.codes.GITERR_ZLIB, 4, 'GITERR_ZLIB should equal 4'); - test.equals(git.Error.codes.GITERR_REPOSITORY, 5, 'GITERR_REPOSITORY should equal 5'); - test.equals(git.Error.codes.GITERR_CONFIG, 6, 'GITERR_CONFIG should equal 6'); - test.equals(git.Error.codes.GITERR_REGEX, 7, 'GITERR_REGEX should equal 7'); - test.equals(git.Error.codes.GITERR_ODB, 8, 'GITERR_ODB should equal 8'); - test.equals(git.Error.codes.GITERR_INDEX, 9, 'GITERR_INDEX should equal 9'); - test.equals(git.Error.codes.GITERR_OBJECT, 10, 'GITERR_OBJECT should equal 10'); - test.equals(git.Error.codes.GITERR_NET, 11, 'GITERR_NET should equal 11'); - test.equals(git.Error.codes.GITERR_TAG, 12, 'GITERR_TAG should equal 12'); - test.equals(git.Error.codes.GITERR_TREE, 13, 'GITERR_TREE should equal 13'); - test.equals(git.Error.codes.GITERR_INDEXER, 14, 'GITERR_INDEXER should equal 14'); - - test.done(); -}; diff --git a/test/raw-repo.js b/test/raw-repo.js index 734103d4f..532687f8b 100644 --- a/test/raw-repo.js +++ b/test/raw-repo.js @@ -46,7 +46,7 @@ exports.open = function(test){ // Test invalid repository git.Repo.open('/etc/hosts', function(error) { - test.equals(git.Error.codes.GIT_ERROR, error.klass, 'Invalid repository error code'); + test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); // Test valid repository git.Repo.open(path.resolve('../.git'), function(error, repo) { diff --git a/test/utilities.js b/test/utilities.js index 06f9714f3..c1f1002a2 100644 --- a/test/utilities.js +++ b/test/utilities.js @@ -12,12 +12,12 @@ exports.successNoError = function(test){ /** * Test whether success function calls callback with error */ -exports.successError = function(test){ - test.expect(3); - utilities.success(new git.error('Message', git.raw.Error.codes.GITERR_INVALID), function(error) { +exports.successError = function(test) { + test.expect(2); + var e = new Error("Message"); + utilities.success(e, function(error) { test.notEqual(error, null, 'Error should not be null'); - test.equal(error.code, git.raw.Error.codes.GITERR_INVALID, 'Error code should match input'); - test.equal(error.message, 'Message', 'Error message should match input'); + test.equal(error, e, 'Error message should match input'); test.done(); }); }; diff --git a/v0.18.0.json b/v0.18.0.json index 0061e871d..d115b1d14 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -1,6 +1,7 @@ [ { "filename": "attr.h", + "ignore": true, "jsClassName": "Attr", "cppClassName": "Attr", "cType": "git_attr", @@ -136,6 +137,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -932,6 +934,7 @@ }, { "filename": "checkout.h", + "ignore": true, "jsClassName": "Checkout", "cppClassName": "Checkout", "cType": "git_checkout", @@ -1034,6 +1037,7 @@ }, { "filename": "clone.h", + "ignore": true, "jsClassName": "Clone", "cppClassName": "Clone", "cType": "git_clone", @@ -1655,6 +1659,7 @@ }, { "filename": "common.h", + "ignore": true, "jsClassName": "Common", "cppClassName": "Common", "cType": "git_common", @@ -1730,6 +1735,7 @@ }, { "filename": "config.h", + "ignore": true, "jsClassName": "Config", "cppClassName": "Config", "cType": "git_config", @@ -2716,6 +2722,7 @@ }, { "filename": "cred_helpers.h", + "ignore": true, "jsClassName": "CredHelpers", "cppClassName": "CredHelpers", "cType": "git_cred_helpers", @@ -3880,20 +3887,22 @@ ] }, { - "filename": "errors.h", - "jsClassName": "Errors", - "cppClassName": "Errors", - "cType": "git_errors", + "filename": "error.h", + "ignore": true, + "jsClassName": "Error", + "cppClassName": "GitError", + "cType": "git_error", "freeFunctionName": "git_errors_free", "functions": [ { "cFunctionName": "giterr_last", "args": [], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "giterrLast", - "cppFunctionName": "GiterrLast", + "isPrototypeMethod": true, + "jsFunctionName": "lastError", + "cppFunctionName": "LastError", "return": { "cType": "const git_error *", "cppClassName": "Error" @@ -3902,11 +3911,12 @@ { "cFunctionName": "giterr_clear", "args": [], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "giterrClear", - "cppFunctionName": "GiterrClear", + "jsFunctionName": "clear", + "cppFunctionName": "Clear", "return": { "cType": "void", "cppClassName": "void" @@ -3928,11 +3938,12 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "giterrSetStr", - "cppFunctionName": "GiterrSetStr", + "jsFunctionName": "setString", + "cppFunctionName": "SetString", "return": { "cType": "void", "cppClassName": "void" @@ -3941,11 +3952,12 @@ { "cFunctionName": "giterr_set_oom", "args": [], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "giterrSetOom", - "cppFunctionName": "GiterrSetOom", + "jsFunctionName": "setOOM", + "cppFunctionName": "SetOOM", "return": { "cType": "void", "cppClassName": "void" @@ -3955,6 +3967,7 @@ }, { "filename": "graph.h", + "ignore": true, "jsClassName": "Graph", "cppClassName": "Graph", "cType": "git_graph", @@ -4009,6 +4022,7 @@ }, { "filename": "ignore.h", + "ignore": true, "jsClassName": "Ignore", "cppClassName": "Ignore", "cType": "git_ignore", @@ -5087,6 +5101,7 @@ }, { "filename": "indexer.h", + "ignore": true, "jsClassName": "Indexer", "cppClassName": "Indexer", "cType": "git_indexer", @@ -5243,6 +5258,7 @@ }, { "filename": "inttypes.h", + "ignore": true, "jsClassName": "Inttypes", "cppClassName": "Inttypes", "cType": "git_inttypes", @@ -5251,6 +5267,7 @@ }, { "filename": "merge.h", + "ignore": true, "jsClassName": "Merge", "cppClassName": "Merge", "cType": "git_merge", @@ -5334,6 +5351,7 @@ }, { "filename": "message.h", + "ignore": true, "jsClassName": "Message", "cppClassName": "Message", "cType": "git_message", @@ -5383,6 +5401,7 @@ }, { "filename": "net.h", + "ignore": true, "jsClassName": "Net", "cppClassName": "Net", "cType": "git_net", @@ -5391,6 +5410,7 @@ }, { "filename": "notes.h", + "ignore": true, "jsClassName": "Notes", "cppClassName": "Notes", "cType": "git_notes", @@ -6098,6 +6118,7 @@ }, { "filename": "odb.h", + "ignore": true, "jsClassName": "Odb", "cppClassName": "Odb", "cType": "git_odb", @@ -6806,6 +6827,7 @@ }, { "filename": "odb_backend.h", + "ignore": true, "jsClassName": "OdbBackend", "cppClassName": "OdbBackend", "cType": "git_odb_backend", @@ -7330,6 +7352,7 @@ }, { "filename": "pack.h", + "ignore": true, "jsClassName": "Pack", "cppClassName": "Pack", "cType": "git_pack", @@ -7574,6 +7597,7 @@ }, { "filename": "push.h", + "ignore": true, "jsClassName": "Push", "cppClassName": "Push", "cType": "git_push", @@ -7788,6 +7812,7 @@ }, { "filename": "refdb.h", + "ignore": true, "jsClassName": "Refdb", "cppClassName": "Refdb", "cType": "git_refdb", @@ -7963,6 +7988,7 @@ }, { "filename": "refdb_backend.h", + "ignore": true, "jsClassName": "RefdbBackend", "cppClassName": "RefdbBackend", "cType": "git_refdb_backend", @@ -8006,6 +8032,7 @@ }, { "filename": "reflog.h", + "ignore": true, "jsClassName": "Reflog", "cppClassName": "Reflog", "cType": "git_reflog", @@ -9114,6 +9141,7 @@ }, { "filename": "refspec.h", + "ignore": true, "jsClassName": "Refspec", "cppClassName": "Refspec", "cType": "git_refspec", @@ -11215,6 +11243,7 @@ }, { "filename": "reset.h", + "ignore": true, "jsClassName": "Reset", "cppClassName": "Reset", "cType": "git_reset", @@ -11290,6 +11319,7 @@ }, { "filename": "revparse.h", + "ignore": true, "jsClassName": "Revparse", "cppClassName": "Revparse", "cType": "git_revparse", @@ -11955,6 +11985,7 @@ }, { "filename": "stash.h", + "ignore": true, "jsClassName": "Stash", "cppClassName": "Stash", "cType": "git_stash", @@ -12070,6 +12101,7 @@ }, { "filename": "status.h", + "ignore": true, "jsClassName": "Status", "cppClassName": "Status", "cType": "git_status", @@ -12217,6 +12249,7 @@ }, { "filename": "stdint.h", + "ignore": true, "jsClassName": "Stdint", "cppClassName": "Stdint", "cType": "git_stdint", @@ -12225,6 +12258,7 @@ }, { "filename": "strarray.h", + "ignore": true, "jsClassName": "Strarray", "cppClassName": "Strarray", "cType": "git_strarray", @@ -12283,6 +12317,7 @@ }, { "filename": "submodule.h", + "ignore": true, "jsClassName": "Submodule", "cppClassName": "Submodule", "cType": "git_submodule", @@ -13548,6 +13583,7 @@ }, { "filename": "trace.h", + "ignore": true, "jsClassName": "Trace", "cppClassName": "Trace", "cType": "git_trace", @@ -13584,6 +13620,7 @@ }, { "filename": "transport.h", + "ignore": true, "jsClassName": "Transport", "cppClassName": "Transport", "cType": "git_transport", From 486b0cc0c5f602752e9ace4e1f6147c6cd767ff7 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Thu, 27 Jun 2013 22:16:26 +0200 Subject: [PATCH 13/28] Removed unnecessary success() utility --- lib/blob.js | 17 ++++++----------- lib/commit.js | 23 ++++++++++------------- lib/diff_list.js | 2 +- lib/oid.js | 3 +-- lib/patch.js | 3 +-- lib/reference.js | 9 ++++----- lib/repo.js | 34 ++++++++++++++-------------------- lib/revwalk.js | 9 ++++----- lib/tree.js | 14 ++++++-------- lib/tree_entry.js | 3 +-- lib/utilities.js | 22 ---------------------- test/utilities.js | 23 ----------------------- 12 files changed, 48 insertions(+), 114 deletions(-) delete mode 100755 lib/utilities.js delete mode 100644 test/utilities.js diff --git a/lib/blob.js b/lib/blob.js index 86d1ebc95..b0297c2aa 100644 --- a/lib/blob.js +++ b/lib/blob.js @@ -1,5 +1,4 @@ -var git = require('../'), - success = require('./utilities').success; +var git = require('../'); /** * Blob convenience class constructor. @@ -9,7 +8,7 @@ var git = require('../'), */ var Blob = function(rawBlob) { if (!(rawBlob instanceof git.raw.Blob)) { - throw new Exception('First parameter for Blob must be a raw blob'); + throw new Error('First parameter for Blob must be a raw blob'); } this.rawBlob = rawBlob; }; @@ -49,10 +48,8 @@ Blob.prototype.createFromFile = function(path, callback) { * @param {Blob|null} blob The new blob or null. */ git.raw.Blob.createFromFile(path, self.rawRepo, function blobCreateFromFileCallback(error, rawBlob) { - if (success(error, callback)) { - self.rawBlob = rawBlob; - callback(null, self); - } + if (error) return callback(error); + callback(null, new Blob(rawBlob)); }); }; @@ -70,10 +67,8 @@ Blob.prototype.createFromFile = function(path, callback) { */ var self = this; self.rawBlob.createFromBuffer(buffer, self.rawRepo, function blobCreateFromBufferCallback(error, rawBlob) { - if (success(error, callback)) { - self.rawBlob = rawBlob; - callback(null, self); - } + if (error) return callback(error); + callback(null, new Blob(rawBlob)); }); }; diff --git a/lib/commit.js b/lib/commit.js index 224883099..cd8d319ec 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -1,5 +1,4 @@ var git = require( '../' ), - success = require('./utilities').success, events = require('events'); /** @@ -11,12 +10,12 @@ var git = require( '../' ), */ var Commit = function(repo, rawCommit) { if (!(repo instanceof git.repo)) { - throw new git.error('First parameter for Commit must be a raw repo'); + throw new Error('First parameter for Commit must be a raw repo'); } this.repo = repo; if (!(rawCommit instanceof git.raw.Commit)) { - throw new git.error('Second parameter for Commit must be a raw commit'); + throw new Error('Second parameter for Commit must be a raw commit'); } this.rawCommit = rawCommit; }; @@ -113,9 +112,8 @@ Commit.prototype.file = function(path, callback) { this.getTree(function (error, tree) { if (error) return callback(error); tree.entry(path, function(error, entry) { - if (success(error, callback)) { - callback(null, entry); - } + if (error) return callback(error); + callback(null, entry); }); }); }; @@ -184,9 +182,8 @@ Commit.prototype.parents = function(callback) { if (n < 0) return callback(null, acc); rawCommit.parent(n, function nextParent(error, rawParentCommit) { - if (success(error, callback)) { - processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback) - } + if (error) return callback(error); + processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback) }); } @@ -207,18 +204,18 @@ Commit.prototype.parentsDiffTrees = function(callback) { */ var self = this; self.parents(function commitParents(error, parents) { - if (!success(error, callback)) return; + if (error) return callback(error); var parentDiffLists = []; parents.forEach(function commitEachParent(parent) { parent.getTree(function(error, parentTree) { - if (!success(error, callback)) return; + if (error) return callback(error); self.getTree(function(error, thisTree) { - if (!success(error, callback)) return; + if (error) return callback(error); git.diffList.treeToTree(self.repo, parentTree, thisTree, function walkDiffList(error, diffList) { - if (!success(error, callback)) return; + if (error) return callback(error); parentDiffLists.push(diffList); if (parentDiffLists.length === parents.length) { diff --git a/lib/diff_list.js b/lib/diff_list.js index 9e7de0f72..6f545b871 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -9,7 +9,7 @@ var git = require('../'), */ var DiffList = function(rawDiffList) { if (!(rawDiffList instanceof git.raw.DiffList)) { - throw new git.error('Parameter for DiffList must be a raw difflist'); + throw new Error('Parameter for DiffList must be a raw difflist'); } this.rawDiffList = rawDiffList; }; diff --git a/lib/oid.js b/lib/oid.js index a49d954ac..44d876341 100644 --- a/lib/oid.js +++ b/lib/oid.js @@ -1,5 +1,4 @@ -var git = require('../'), - success = require('./utilities').success; +var git = require('../'); /** * Convenience Oid constructor. diff --git a/lib/patch.js b/lib/patch.js index b6db577fb..13d38632c 100644 --- a/lib/patch.js +++ b/lib/patch.js @@ -1,5 +1,4 @@ -var git = require('../'), - success = require('./utilities').success; +var git = require('../'); /** * Convenience patch class. diff --git a/lib/reference.js b/lib/reference.js index a2bb45e80..f7a15c67c 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -1,5 +1,4 @@ -var git = require('../'), - success = require('./utilities').success; +var git = require('../'); /** * Convenience reference constructor. @@ -10,7 +9,7 @@ var git = require('../'), */ var Reference = function(rawReference) { if (!(rawReference instanceof git.raw.Reference)) { - throw new git.error('First parameter for Reference must be a raw reference'); + throw new Error('First parameter for Reference must be a raw reference'); } this.rawReference = rawReference; }; @@ -36,11 +35,11 @@ Reference.lookup = function(rawRepo, name, callback) { git.raw.Reference.lookup(rawRepo, name, function referenceLookup(error, rawReference) { if (rawReference.type() == Reference.Type.Symbolic) { rawReference.resolve(function referenceResolve(error, rawReference) { - if (!success(error, callback)) return; + if (error) return callback(error); callback(null, new Reference(rawReference)); }); } else { - if (!success(error, callback)) return; + if (error) return callback(error); callback(null, new Reference(rawReference)); } }); diff --git a/lib/repo.js b/lib/repo.js index 4f7f7d552..1e291adfe 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -1,5 +1,4 @@ -var git = require('../'), - success = require('./utilities').success; +var git = require('../'); /** * Convenience repository class. @@ -24,9 +23,8 @@ Repo.init = function(directory, isBare, callback) { * @param {Repo|null} repo Initialized repository. */ git.raw.Repo.init(directory, isBare, function(error, rawRepo) { - if (success(error, callback)) { - callback(null, new Repo(rawRepo)); - } + if (error) return callback(error); + callback(null, new Repo(rawRepo)); }); }; @@ -46,12 +44,11 @@ Repo.open = function(directory, callback) { * @param {Repo|null} repo Opened repository. */ if (typeof callback !== 'function') { - throw new git.error('Callback is required and must be a Function'); + throw new Error('Callback is required and must be a Function'); } git.raw.Repo.open(directory, function openRepository(error, rawRepo) { - if (success(error, callback)) { - callback(null, new Repo(rawRepo)); - } + if (error) return callback(error); + callback(null, new Repo(rawRepo)); }); }; @@ -69,11 +66,11 @@ Repo.prototype.branch = function(name, callback) { */ var self = this; git.reference.lookup(this.rawRepo, 'refs/heads/' + name, function referenceLookupCallback(error, reference) { - if (!success(error, callback)) return; + if (error) return callback(error); var oid = reference.oid(); self.commit(oid, function commitLookupCallback(error, commit) { - if (!success(error, callback)) return; + if (error) return callback(error); callback(null, commit); }); @@ -97,9 +94,8 @@ Repo.prototype.commit = function(oid, callback) { if (typeof oid === 'string') oid = git.raw.Oid.fromString(oid); git.raw.Commit.lookup(this.rawRepo, oid, function(error, rawCommit) { - if (success(error, callback)) { - callback(null, new git.commit(self, rawCommit)); - } + if (error) return callback(error); + callback(null, new git.commit(self, rawCommit)); }); } catch (e) { callback(e); @@ -119,9 +115,8 @@ Repo.prototype.blob = function(oid, callback) { * @param {Blob|null} blob Retrieved blob object or null. */ git.raw.Blob.lookup(this.rawRepo, oid.rawOid, function blobLookup(error, rawBlob) { - if (success(error, callback)) { - callback(null, new git.blob(rawBlob)); - } + if (error) return callback(error); + callback(null, new git.blob(rawBlob)); }); }; @@ -139,9 +134,8 @@ Repo.prototype.tree = function(oid, callback) { */ var self = this; git.raw.Tree.lookup(this.rawRepo, oid.rawOid, function(error, rawTree) { - if (success(error, callback)) { - callback(null, new git.tree(self, rawTree)); - } + if (error) return callback(error); + callback(null, new git.tree(self, rawTree)); }); }; diff --git a/lib/revwalk.js b/lib/revwalk.js index aaf8e99aa..bbd07f24e 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -1,5 +1,4 @@ -var git = require('../'), - success = require('./utilities').success; +var git = require('../'); /** * Convenience revision walking class @@ -10,11 +9,11 @@ var git = require('../'), */ var RevWalk = function(repo, rawRevWalk) { if (!(repo instanceof git.repo)) { - throw new Exception('First parameter for RevWalk must be a repo'); + throw new Error('First parameter for RevWalk must be a repo'); } if (!(rawRevWalk instanceof git.raw.RevWalk)) { - throw new Exception('Second parameter for RevWalk must be a raw.RevWalk'); + throw new Error('Second parameter for RevWalk must be a raw.RevWalk'); } this.repo = repo; @@ -38,7 +37,7 @@ RevWalk.make = function(repo) { RevWalk.prototype.walk = function(oid, callback) { var self = this; this.rawRevWalk.push(oid.getRawOid(), function revWalkPush(error) { - if (!success(error, callback)) return; + if (error) return callback(error); function walk() { self.rawRevWalk.next(function revWalkNext(error, oid) { diff --git a/lib/tree.js b/lib/tree.js index ec632d7b6..fcf42f100 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -1,5 +1,4 @@ var git = require('../'), - success = require('./utilities').success, events = require('events'); /** @@ -10,12 +9,12 @@ var git = require('../'), * @param {git.raw.Tree} [rawTree = new git.raw.Tree(rawRepo)] Raw tree object. */ var Tree = function(repo, rawTree) { - if(!(repo instanceof git.repo)) { - throw new Exception('First parameter for Tree must be a raw repo'); + if (!(repo instanceof git.repo)) { + throw new Error('First parameter for Tree must be a raw repo'); } - if(!(rawTree instanceof git.raw.Tree)) { - throw new Exception('Second parameter for Tree must be a raw tree'); + if (!(rawTree instanceof git.raw.Tree)) { + throw new Error('Second parameter for Tree must be a raw tree'); } this.repo = repo; @@ -36,9 +35,8 @@ Tree.prototype.entry = function(path, callback) { */ var self = this; self.rawTree.getEntryByPath(path, function(error, rawEntry) { - if (success(error, callback)) { - callback(null, new git.entry(self.repo, rawEntry)); - } + if (error) return callback(error); + callback(null, new git.entry(self.repo, rawEntry)); }); }; diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 9bb92edb1..f6e33c2b6 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -1,6 +1,5 @@ var git = require('../'), - path = require('path'), - success = require('./utilities').success; + path = require('path'); /** * Convenience tree entry constructor. diff --git a/lib/utilities.js b/lib/utilities.js deleted file mode 100755 index 09dfa83b5..000000000 --- a/lib/utilities.js +++ /dev/null @@ -1,22 +0,0 @@ -var git = require('../'); - -/** - * @namespace - */ -var utilities = { - /** - * Check if error is null, if it is not, convert it to a GitError and call - * the callback. - * - * @param {Object} error - * @param {Function} callback - * - * @return {Boolean} True if the error was null, false otherwise. - */ - success: function(error, callback) { - if (typeof callback !== 'function') throw new Error('Callback must be provided'); - if (error) return callback(error); - return true; - } -}; -exports.success = utilities.success; diff --git a/test/utilities.js b/test/utilities.js deleted file mode 100644 index c1f1002a2..000000000 --- a/test/utilities.js +++ /dev/null @@ -1,23 +0,0 @@ -var git = require('../'), - utilities = require('../lib/utilities'); - -exports.successNoError = function(test){ - test.expect(0); - - if (utilities.success(null, function() { })) { - test.done(); - } -}; - -/** - * Test whether success function calls callback with error - */ -exports.successError = function(test) { - test.expect(2); - var e = new Error("Message"); - utilities.success(e, function(error) { - test.notEqual(error, null, 'Error should not be null'); - test.equal(error, e, 'Error message should match input'); - test.done(); - }); -}; From 6527aacc8b03c1f9c8f19c8374cf202677301e8b Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Thu, 27 Jun 2013 22:48:40 +0200 Subject: [PATCH 14/28] Extracted a partial for conversion from v8 types to c types --- TODO | 2 - binding.gyp | 1 - src/blob.cc | 38 ++++---- src/branch.cc | 113 +++++++++++++++--------- src/commit.cc | 37 +++----- src/delta.cc | 2 - src/diff_file.cc | 2 - src/diff_find_options.cc | 2 - src/diff_list.cc | 76 ++++++++-------- src/diff_options.cc | 2 - src/diff_range.cc | 2 - src/functions/string.cc | 9 -- src/functions/utilities.cc | 21 ----- src/index.cc | 77 ++++++++-------- src/object.cc | 23 +++-- src/oid.cc | 9 +- src/patch.cc | 21 ++--- src/reference.cc | 98 +++++++++++---------- src/remote.cc | 155 ++++++++++++++++++--------------- src/repo.cc | 23 +++-- src/revwalk.cc | 64 ++++++-------- src/signature.cc | 13 +-- src/tag.cc | 75 ++++++++-------- src/threads.cc | 4 - src/time.cc | 2 - src/tree.cc | 35 ++++---- src/tree_entry.cc | 12 +-- templates/class.cc.ejs | 44 +++++----- templates/convertFromV8.cc.ejs | 12 +++ 29 files changed, 483 insertions(+), 491 deletions(-) delete mode 100644 src/functions/string.cc delete mode 100644 src/functions/utilities.cc create mode 100644 templates/convertFromV8.cc.ejs diff --git a/TODO b/TODO index b00e5712f..f4850133f 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ - rename all async methods getXXX -- convert to "ignore": true for all classes - reorder functions so the raw api is oo-like - rename files remove .h -- remove stringArgToString invocation diff --git a/binding.gyp b/binding.gyp index f0919a220..88968d0d9 100644 --- a/binding.gyp +++ b/binding.gyp @@ -26,7 +26,6 @@ 'src/diff_range.cc', 'src/threads.cc', 'src/wrapper.cc', - 'src/functions/string.cc', ], 'include_dirs': [ diff --git a/src/blob.cc b/src/blob.cc index efcdcb1b2..d45b2a5db 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -13,8 +13,6 @@ #include "../include/wrapper.h" #include "node_buffer.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -73,8 +71,7 @@ git_blob *GitBlob::GetValue() { Handle GitBlob::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -90,9 +87,11 @@ Handle GitBlob::Lookup(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->idReference = Persistent::New(args[1]); - baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->id = from_id; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); @@ -153,7 +152,6 @@ Handle GitBlob::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -167,7 +165,6 @@ Handle GitBlob::Content(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Wrapper::New((void *)result); return scope.Close(to); @@ -181,7 +178,6 @@ Handle GitBlob::Size(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Number::New(result); return scope.Close(to); @@ -189,8 +185,7 @@ Handle GitBlob::Size(const Arguments& args) { Handle GitBlob::CreateFromFile(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -206,10 +201,12 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->pathReference = Persistent::New(args[1]); - String::Utf8Value path(args[1]->ToString()); - baton->path = strdup(*path); + String::Utf8Value path(args[1]->ToString()); + const char * from_path = strdup(*path); + baton->path = from_path; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); @@ -265,8 +262,7 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { Handle GitBlob::CreateFromBuffer(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -285,11 +281,14 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->bufferReference = Persistent::New(args[1]); - baton->buffer = Buffer::Data(ObjectWrap::Unwrap(args[1]->ToObject())); + const void * from_buffer = Buffer::Data(ObjectWrap::Unwrap(args[1]->ToObject())); + baton->buffer = from_buffer; baton->lenReference = Persistent::New(args[2]); - baton->len = (size_t) args[2]->ToNumber()->Value(); + size_t from_len = (size_t) args[2]->ToNumber()->Value(); + baton->len = from_len; baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateFromBufferWork, (uv_after_work_cb)CreateFromBufferAfterWork); @@ -351,7 +350,6 @@ Handle GitBlob::IsBinary(const Arguments& args) { int result = git_blob_is_binary( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/branch.cc b/src/branch.cc index fab0224f3..5bd5e03d5 100644 --- a/src/branch.cc +++ b/src/branch.cc @@ -9,8 +9,6 @@ #include "../include/branch.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -87,15 +85,20 @@ Handle Branch::Create(const Arguments& args) { } git_reference *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value branch_name(args[1]->ToString()); + const char * from_branch_name = strdup(*branch_name); + const git_commit * from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + int from_force = (int) args[3]->ToInt32()->Value(); int result = git_branch_create( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() - , (int) args[3]->ToInt32()->Value() + , from_repo + , from_branch_name + , from_target + , from_force ); - + delete from_branch_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -111,11 +114,11 @@ Handle Branch::Delete(const Arguments& args) { return ThrowException(Exception::Error(String::New("Reference branch is required."))); } + git_reference * from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_branch_delete( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + from_branch ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -138,14 +141,17 @@ Handle Branch::Foreach(const Arguments& args) { return ThrowException(Exception::Error(String::New("void payload is required."))); } + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + unsigned int from_list_flags = (unsigned int) args[1]->ToUint32()->Value(); + git_branch_foreach_cb from_branch_cb = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + void * from_payload = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); int result = git_branch_foreach( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , (unsigned int) args[1]->ToUint32()->Value() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() - , ObjectWrap::Unwrap(args[3]->ToObject())->GetValue() + from_repo + , from_list_flags + , from_branch_cb + , from_payload ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -166,14 +172,18 @@ Handle Branch::Move(const Arguments& args) { } git_reference *out = NULL; + git_reference * from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value new_branch_name(args[1]->ToString()); + const char * from_new_branch_name = strdup(*new_branch_name); + int from_force = (int) args[2]->ToInt32()->Value(); int result = git_branch_move( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() - , (int) args[2]->ToInt32()->Value() + , from_branch + , from_new_branch_name + , from_force ); - + delete from_new_branch_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -196,14 +206,18 @@ Handle Branch::Lookup(const Arguments& args) { } git_reference *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value branch_name(args[1]->ToString()); + const char * from_branch_name = strdup(*branch_name); + git_branch_t from_branch_type = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); int result = git_branch_lookup( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , from_repo + , from_branch_name + , from_branch_type ); - + delete from_branch_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -220,12 +234,12 @@ Handle Branch::Name(const Arguments& args) { } const char *out = NULL; + git_reference * from_ref = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_branch_name( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_ref ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -242,12 +256,12 @@ Handle Branch::Upstream(const Arguments& args) { } git_reference *out = NULL; + git_reference * from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_branch_upstream( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_branch ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -266,12 +280,15 @@ Handle Branch::SetUpstream(const Arguments& args) { return ThrowException(Exception::Error(String::New("String upstream_name is required."))); } + git_reference * from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value upstream_name(args[1]->ToString()); + const char * from_upstream_name = strdup(*upstream_name); int result = git_branch_set_upstream( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() + from_branch + , from_upstream_name ); - + delete from_upstream_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -294,14 +311,21 @@ Handle Branch::UpstreamName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String canonical_branch_name is required."))); } + String::Utf8Value tracking_branch_name_out(args[0]->ToString()); + char * from_tracking_branch_name_out = strdup(*tracking_branch_name_out); + size_t from_buffer_size = (size_t) args[1]->ToUint32()->Value(); + git_repository * from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + String::Utf8Value canonical_branch_name(args[3]->ToString()); + const char * from_canonical_branch_name = strdup(*canonical_branch_name); int result = git_branch_upstream_name( - stringArgToString(args[0]->ToString()).c_str() - , (size_t) args[1]->ToUint32()->Value() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() - , stringArgToString(args[3]->ToString()).c_str() + from_tracking_branch_name_out + , from_buffer_size + , from_repo + , from_canonical_branch_name ); - + delete from_tracking_branch_name_out; + delete from_canonical_branch_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -315,11 +339,11 @@ Handle Branch::IsHead(const Arguments& args) { return ThrowException(Exception::Error(String::New("Reference branch is required."))); } + git_reference * from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_branch_is_head( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + from_branch ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -342,14 +366,21 @@ Handle Branch::RemoteName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String canonical_branch_name is required."))); } + String::Utf8Value remote_name_out(args[0]->ToString()); + char * from_remote_name_out = strdup(*remote_name_out); + size_t from_buffer_size = (size_t) args[1]->ToUint32()->Value(); + git_repository * from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + String::Utf8Value canonical_branch_name(args[3]->ToString()); + const char * from_canonical_branch_name = strdup(*canonical_branch_name); int result = git_branch_remote_name( - stringArgToString(args[0]->ToString()).c_str() - , (size_t) args[1]->ToUint32()->Value() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() - , stringArgToString(args[3]->ToString()).c_str() + from_remote_name_out + , from_buffer_size + , from_repo + , from_canonical_branch_name ); - + delete from_remote_name_out; + delete from_canonical_branch_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/commit.cc b/src/commit.cc index e37a69bd1..d618f92de 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -13,8 +13,6 @@ #include "../include/signature.h" #include "../include/tree.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -80,8 +78,7 @@ git_commit *GitCommit::GetValue() { Handle GitCommit::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -97,9 +94,11 @@ Handle GitCommit::Lookup(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->idReference = Persistent::New(args[1]); - baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->id = from_id; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); @@ -160,7 +159,6 @@ Handle GitCommit::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -174,7 +172,6 @@ Handle GitCommit::MessageEncoding(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -188,7 +185,6 @@ Handle GitCommit::Message(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -202,7 +198,6 @@ Handle GitCommit::Time(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Number::New(result); return scope.Close(to); @@ -216,7 +211,6 @@ Handle GitCommit::Offset(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Integer::New(result); return scope.Close(to); @@ -230,7 +224,6 @@ Handle GitCommit::Committer(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitSignature::New((void *)result); return scope.Close(to); @@ -244,7 +237,6 @@ Handle GitCommit::Author(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitSignature::New((void *)result); return scope.Close(to); @@ -252,8 +244,7 @@ Handle GitCommit::Author(const Arguments& args) { Handle GitCommit::Tree(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -322,7 +313,6 @@ Handle GitCommit::TreeId(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -336,7 +326,6 @@ Handle GitCommit::ParentCount(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Uint32::New(result); return scope.Close(to); @@ -344,8 +333,7 @@ Handle GitCommit::ParentCount(const Arguments& args) { Handle GitCommit::Parent(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsUint32()) { + if (args.Length() == 0 || !args[0]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number n is required."))); } @@ -360,7 +348,8 @@ Handle GitCommit::Parent(const Arguments& args) { baton->commitReference = Persistent::New(args.This()); baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); baton->nReference = Persistent::New(args[0]); - baton->n = (unsigned int) args[0]->ToUint32()->Value(); + unsigned int from_n = (unsigned int) args[0]->ToUint32()->Value(); + baton->n = from_n; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, ParentWork, (uv_after_work_cb)ParentAfterWork); @@ -419,13 +408,13 @@ Handle GitCommit::ParentId(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number n is required."))); } + unsigned int from_n = (unsigned int) args[0]->ToUint32()->Value(); const git_oid * result = git_commit_parent_id( ObjectWrap::Unwrap(args.This())->GetValue() - , (unsigned int) args[0]->ToUint32()->Value() + , from_n ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -438,13 +427,13 @@ Handle GitCommit::NthGenAncestor(const Arguments& args) { } git_commit *ancestor = NULL; + unsigned int from_n = (unsigned int) args[0]->ToUint32()->Value(); int result = git_commit_nth_gen_ancestor( &ancestor , ObjectWrap::Unwrap(args.This())->GetValue() - , (unsigned int) args[0]->ToUint32()->Value() + , from_n ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/delta.cc b/src/delta.cc index 37e8994f5..3584cacba 100644 --- a/src/delta.cc +++ b/src/delta.cc @@ -10,8 +10,6 @@ #include "../include/delta.h" #include "../include/diff_file.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; diff --git a/src/diff_file.cc b/src/diff_file.cc index 16e18839b..c66e818d6 100644 --- a/src/diff_file.cc +++ b/src/diff_file.cc @@ -10,8 +10,6 @@ #include "../include/diff_file.h" #include "../include/oid.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc index 916069908..70fc89de9 100644 --- a/src/diff_find_options.cc +++ b/src/diff_find_options.cc @@ -9,8 +9,6 @@ #include "../include/diff_find_options.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; diff --git a/src/diff_list.cc b/src/diff_list.cc index e7a62048d..62c2d602d 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -16,8 +16,6 @@ #include "../include/patch.h" #include "../include/delta.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -78,8 +76,7 @@ git_diff_list *GitDiffList::GetValue() { Handle GitDiffList::TreeToTree(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -98,14 +95,18 @@ Handle GitDiffList::TreeToTree(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->old_treeReference = Persistent::New(args[1]); - baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + git_tree * from_old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->old_tree = from_old_tree; baton->new_treeReference = Persistent::New(args[2]); - baton->new_tree = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + git_tree * from_new_tree = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->new_tree = from_new_tree; baton->optsReference = Persistent::New(args[3]); if (args[3]->IsObject()) { - baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->opts = from_opts; } else { baton->opts = NULL; } @@ -167,8 +168,7 @@ void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { Handle GitDiffList::TreeToIndex(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -190,13 +190,17 @@ Handle GitDiffList::TreeToIndex(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->old_treeReference = Persistent::New(args[1]); - baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + git_tree * from_old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->old_tree = from_old_tree; baton->indexReference = Persistent::New(args[2]); - baton->index = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + git_index * from_index = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->index = from_index; baton->optsReference = Persistent::New(args[3]); - baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->opts = from_opts; baton->callback = Persistent::New(Local::Cast(args[4])); uv_queue_work(uv_default_loop(), &baton->request, TreeToIndexWork, (uv_after_work_cb)TreeToIndexAfterWork); @@ -255,8 +259,7 @@ void GitDiffList::TreeToIndexAfterWork(uv_work_t *req) { Handle GitDiffList::IndexToWorkdir(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -275,11 +278,14 @@ Handle GitDiffList::IndexToWorkdir(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->indexReference = Persistent::New(args[1]); - baton->index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + git_index * from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->index = from_index; baton->optsReference = Persistent::New(args[2]); - baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); @@ -336,8 +342,7 @@ void GitDiffList::IndexToWorkdirAfterWork(uv_work_t *req) { Handle GitDiffList::TreeToWorkdir(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -356,11 +361,14 @@ Handle GitDiffList::TreeToWorkdir(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->old_treeReference = Persistent::New(args[1]); - baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + git_tree * from_old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->old_tree = from_old_tree; baton->optsReference = Persistent::New(args[2]); - baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, TreeToWorkdirWork, (uv_after_work_cb)TreeToWorkdirAfterWork); @@ -421,12 +429,12 @@ Handle GitDiffList::Merge(const Arguments& args) { return ThrowException(Exception::Error(String::New("DiffList from is required."))); } + const git_diff_list * from_from = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_diff_merge( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_from ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -440,12 +448,12 @@ Handle GitDiffList::FindSimilar(const Arguments& args) { return ThrowException(Exception::Error(String::New("DiffFindOptions options is required."))); } + git_diff_find_options * from_options = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_diff_find_similar( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_options ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -461,7 +469,6 @@ Handle GitDiffList::Size(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Uint32::New(result); return scope.Close(to); @@ -476,13 +483,14 @@ Handle GitDiffList::NumDeltasOfType(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number type is required."))); } + git_diff_list * from_diff = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_delta_t from_type = (git_delta_t) args[1]->ToInt32()->Value(); size_t result = git_diff_num_deltas_of_type( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , (git_delta_t) args[1]->ToInt32()->Value() + from_diff + , from_type ); - Handle to; to = Uint32::New(result); return scope.Close(to); @@ -496,14 +504,14 @@ Handle GitDiffList::Patch(const Arguments& args) { git_diff_patch *patch_out = NULL; const git_diff_delta *delta_out = NULL; + size_t from_idx = (size_t) args[0]->ToUint32()->Value(); int result = git_diff_get_patch( &patch_out , &delta_out , ObjectWrap::Unwrap(args.This())->GetValue() - , (size_t) args[0]->ToUint32()->Value() + , from_idx ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/diff_options.cc b/src/diff_options.cc index 58894d3f3..c427b5658 100644 --- a/src/diff_options.cc +++ b/src/diff_options.cc @@ -9,8 +9,6 @@ #include "../include/diff_options.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; diff --git a/src/diff_range.cc b/src/diff_range.cc index bbd02e8c1..1de98d0b8 100644 --- a/src/diff_range.cc +++ b/src/diff_range.cc @@ -9,8 +9,6 @@ #include "../include/diff_range.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; diff --git a/src/functions/string.cc b/src/functions/string.cc deleted file mode 100644 index 5c74f4aa7..000000000 --- a/src/functions/string.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -#include "../../include/functions/string.h" - -std::string stringArgToString(const v8::Local arg) { - v8::String::Utf8Value param1(arg); - return std::string(*param1); -} diff --git a/src/functions/utilities.cc b/src/functions/utilities.cc deleted file mode 100644 index ec5904dcc..000000000 --- a/src/functions/utilities.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "../../include/functions/utilities.h" - -using namespace v8; - -bool success(const git_error* error, Persistent callback) { - HandleScope scope; - - if (error) { - Local argv[1] = { - GitError::WrapError(error) - }; - - TryCatch try_catch; - callback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - FatalException(try_catch); - } - return false; - } - return true; -} diff --git a/src/index.cc b/src/index.cc index c0fe3595b..ba2931ec3 100644 --- a/src/index.cc +++ b/src/index.cc @@ -12,8 +12,6 @@ #include "../include/repo.h" #include "../include/tree.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -81,8 +79,7 @@ git_index *GitIndex::GetValue() { Handle GitIndex::Open(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String index_path is required."))); } @@ -95,8 +92,9 @@ Handle GitIndex::Open(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->index_pathReference = Persistent::New(args[0]); - String::Utf8Value index_path(args[0]->ToString()); - baton->index_path = strdup(*index_path); + String::Utf8Value index_path(args[0]->ToString()); + const char * from_index_path = strdup(*index_path); + baton->index_path = from_index_path; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); @@ -156,7 +154,6 @@ Handle GitIndex::Owner(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitRepo::New((void *)result); return scope.Close(to); @@ -164,8 +161,7 @@ Handle GitIndex::Owner(const Arguments& args) { Handle GitIndex::Read(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -226,8 +222,7 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { Handle GitIndex::Write(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -288,8 +283,7 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { Handle GitIndex::ReadTree(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Tree tree is required."))); } @@ -304,7 +298,8 @@ Handle GitIndex::ReadTree(const Arguments& args) { baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->treeReference = Persistent::New(args[0]); - baton->tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const git_tree * from_tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->tree = from_tree; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, ReadTreeWork, (uv_after_work_cb)ReadTreeAfterWork); @@ -357,8 +352,7 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { Handle GitIndex::WriteTree(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -427,7 +421,6 @@ Handle GitIndex::Entrycount(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Uint32::New(result); return scope.Close(to); @@ -441,7 +434,6 @@ Handle GitIndex::Clear(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - return Undefined(); } @@ -454,13 +446,16 @@ Handle GitIndex::Remove(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + int from_stage = (int) args[1]->ToInt32()->Value(); int result = git_index_remove( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() - , (int) args[1]->ToInt32()->Value() + , from_path + , from_stage ); - + delete from_path; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -477,13 +472,16 @@ Handle GitIndex::RemoveDirectory(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number stage is required."))); } + String::Utf8Value dir(args[0]->ToString()); + const char * from_dir = strdup(*dir); + int from_stage = (int) args[1]->ToInt32()->Value(); int result = git_index_remove_directory( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() - , (int) args[1]->ToInt32()->Value() + , from_dir + , from_stage ); - + delete from_dir; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -493,8 +491,7 @@ Handle GitIndex::RemoveDirectory(const Arguments& args) { Handle GitIndex::AddBypath(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } @@ -509,8 +506,9 @@ Handle GitIndex::AddBypath(const Arguments& args) { baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->pathReference = Persistent::New(args[0]); - String::Utf8Value path(args[0]->ToString()); - baton->path = strdup(*path); + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + baton->path = from_path; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, AddBypathWork, (uv_after_work_cb)AddBypathAfterWork); @@ -568,12 +566,14 @@ Handle GitIndex::RemoveBypath(const Arguments& args) { return ThrowException(Exception::Error(String::New("String path is required."))); } + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); int result = git_index_remove_bypath( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() + , from_path ); - + delete from_path; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -590,13 +590,16 @@ Handle GitIndex::Find(const Arguments& args) { return ThrowException(Exception::Error(String::New("String path is required."))); } + size_t * from_at_pos = (size_t *) args[0]->ToUint32()->Value(); + String::Utf8Value path(args[1]->ToString()); + const char * from_path = strdup(*path); int result = git_index_find( - (size_t *) args[0]->ToUint32()->Value() + from_at_pos , ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() + , from_path ); - + delete from_path; Handle to; to = Int32::New(result); @@ -609,12 +612,14 @@ Handle GitIndex::ConflictRemove(const Arguments& args) { return ThrowException(Exception::Error(String::New("String path is required."))); } + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); int result = git_index_conflict_remove( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() + , from_path ); - + delete from_path; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -630,7 +635,6 @@ Handle GitIndex::ConflictCleanup(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - return Undefined(); } @@ -642,7 +646,6 @@ Handle GitIndex::HasConflicts(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Int32::New(result); return scope.Close(to); diff --git a/src/object.cc b/src/object.cc index a9079b867..fb37cedb6 100644 --- a/src/object.cc +++ b/src/object.cc @@ -11,8 +11,6 @@ #include "../include/oid.h" #include "../include/repo.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -69,8 +67,7 @@ git_object *GitObject::GetValue() { Handle GitObject::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -89,11 +86,14 @@ Handle GitObject::Lookup(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->idReference = Persistent::New(args[1]); - baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->id = from_id; baton->typeReference = Persistent::New(args[2]); - baton->type = (git_otype) args[2]->ToInt32()->Value(); + git_otype from_type = (git_otype) args[2]->ToInt32()->Value(); + baton->type = from_type; baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); @@ -156,7 +156,6 @@ Handle GitObject::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -170,7 +169,6 @@ Handle GitObject::Type(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Number::New(result); return scope.Close(to); @@ -184,7 +182,6 @@ Handle GitObject::Owner(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitRepo::New((void *)result); return scope.Close(to); @@ -192,8 +189,7 @@ Handle GitObject::Owner(const Arguments& args) { Handle GitObject::Peel(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsInt32()) { + if (args.Length() == 0 || !args[0]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number target_type is required."))); } @@ -208,7 +204,8 @@ Handle GitObject::Peel(const Arguments& args) { baton->objectReference = Persistent::New(args.This()); baton->object = ObjectWrap::Unwrap(args.This())->GetValue(); baton->target_typeReference = Persistent::New(args[0]); - baton->target_type = (git_otype) args[0]->ToInt32()->Value(); + git_otype from_target_type = (git_otype) args[0]->ToInt32()->Value(); + baton->target_type = from_target_type; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PeelWork, (uv_after_work_cb)PeelAfterWork); diff --git a/src/oid.cc b/src/oid.cc index 6013403b8..05c9939a4 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -9,8 +9,6 @@ #include "../include/oid.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -68,12 +66,14 @@ Handle GitOid::FromString(const Arguments& args) { } git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + String::Utf8Value str(args[0]->ToString()); + const char * from_str = strdup(*str); int result = git_oid_fromstr( out - , stringArgToString(args[0]->ToString()).c_str() + , from_str ); - + delete from_str; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -91,7 +91,6 @@ Handle GitOid::Sha(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); diff --git a/src/patch.cc b/src/patch.cc index c1d4c55f5..65dfef6dc 100644 --- a/src/patch.cc +++ b/src/patch.cc @@ -11,8 +11,6 @@ #include "../include/delta.h" #include "../include/diff_range.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -77,7 +75,6 @@ Handle GitPatch::Delta(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitDelta::New((void *)result); return scope.Close(to); @@ -91,7 +88,6 @@ Handle GitPatch::Size(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Uint32::New(result); return scope.Close(to); @@ -110,7 +106,6 @@ Handle GitPatch::Stats(const Arguments& args) { , &total_deletions , ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -139,6 +134,7 @@ Handle GitPatch::Hunk(const Arguments& args) { const char *header = NULL; size_t header_len = NULL; size_t lines_in_hunk = NULL; + size_t from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); int result = git_diff_patch_get_hunk( &range @@ -146,9 +142,8 @@ Handle GitPatch::Hunk(const Arguments& args) { , &header_len , &lines_in_hunk , ObjectWrap::Unwrap(args.This())->GetValue() - , (size_t) args[0]->ToUint32()->Value() + , from_hunk_idx ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -176,13 +171,13 @@ Handle GitPatch::Lines(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); } + size_t from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); int result = git_diff_patch_num_lines_in_hunk( ObjectWrap::Unwrap(args.This())->GetValue() - , (size_t) args[0]->ToUint32()->Value() + , from_hunk_idx ); - Handle to; to = Int32::New(result); return scope.Close(to); @@ -202,6 +197,8 @@ Handle GitPatch::Line(const Arguments& args) { size_t content_len = NULL; int old_lineno = NULL; int new_lineno = NULL; + size_t from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + size_t from_line_of_hunk = (size_t) args[1]->ToUint32()->Value(); int result = git_diff_patch_get_line_in_hunk( &line_origin @@ -210,10 +207,9 @@ Handle GitPatch::Line(const Arguments& args) { , &old_lineno , &new_lineno , ObjectWrap::Unwrap(args.This())->GetValue() - , (size_t) args[0]->ToUint32()->Value() - , (size_t) args[1]->ToUint32()->Value() + , from_hunk_idx + , from_line_of_hunk ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -247,7 +243,6 @@ Handle GitPatch::ToString(const Arguments& args) { &string , ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/reference.cc b/src/reference.cc index 159c8a242..3a50da113 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -12,8 +12,6 @@ #include "../include/oid.h" #include "../include/object.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -81,8 +79,7 @@ git_reference *GitReference::GetValue() { Handle GitReference::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -98,10 +95,12 @@ Handle GitReference::Lookup(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->nameReference = Persistent::New(args[1]); - String::Utf8Value name(args[1]->ToString()); - baton->name = strdup(*name); + String::Utf8Value name(args[1]->ToString()); + const char * from_name = strdup(*name); + baton->name = from_name; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); @@ -157,8 +156,7 @@ void GitReference::LookupAfterWork(uv_work_t *req) { Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -174,10 +172,12 @@ Handle GitReference::OidForName(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->nameReference = Persistent::New(args[1]); - String::Utf8Value name(args[1]->ToString()); - baton->name = strdup(*name); + String::Utf8Value name(args[1]->ToString()); + const char * from_name = strdup(*name); + baton->name = from_name; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, OidForNameWork, (uv_after_work_cb)OidForNameAfterWork); @@ -247,15 +247,22 @@ Handle GitReference::CreateSymbolic(const Arguments& args) { } git_reference *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value name(args[1]->ToString()); + const char * from_name = strdup(*name); + String::Utf8Value target(args[2]->ToString()); + const char * from_target = strdup(*target); + int from_force = (int) args[3]->ToInt32()->Value(); int result = git_reference_symbolic_create( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() - , stringArgToString(args[2]->ToString()).c_str() - , (int) args[3]->ToInt32()->Value() + , from_repo + , from_name + , from_target + , from_force ); - + delete from_name; + delete from_target; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -281,15 +288,20 @@ Handle GitReference::Create(const Arguments& args) { } git_reference *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value name(args[1]->ToString()); + const char * from_name = strdup(*name); + const git_oid * from_id = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + int from_force = (int) args[3]->ToInt32()->Value(); int result = git_reference_create( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() - , (int) args[3]->ToInt32()->Value() + , from_repo + , from_name + , from_id + , from_force ); - + delete from_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -307,7 +319,6 @@ Handle GitReference::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -321,7 +332,6 @@ Handle GitReference::Name(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -335,7 +345,6 @@ Handle GitReference::Type(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Number::New(result); return scope.Close(to); @@ -343,8 +352,7 @@ Handle GitReference::Type(const Arguments& args) { Handle GitReference::Resolve(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -412,13 +420,15 @@ Handle GitReference::SetSymbolicTarget(const Arguments& args) { } git_reference *out = NULL; + String::Utf8Value target(args[0]->ToString()); + const char * from_target = strdup(*target); int result = git_reference_symbolic_set_target( &out , ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() + , from_target ); - + delete from_target; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -435,13 +445,13 @@ Handle GitReference::setTarget(const Arguments& args) { } git_reference *out = NULL; + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_reference_set_target( &out , ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_id ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -453,8 +463,7 @@ Handle GitReference::setTarget(const Arguments& args) { Handle GitReference::Rename(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String new_name is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { @@ -472,10 +481,12 @@ Handle GitReference::Rename(const Arguments& args) { baton->refReference = Persistent::New(args.This()); baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); baton->new_nameReference = Persistent::New(args[0]); - String::Utf8Value new_name(args[0]->ToString()); - baton->new_name = strdup(*new_name); + String::Utf8Value new_name(args[0]->ToString()); + const char * from_new_name = strdup(*new_name); + baton->new_name = from_new_name; baton->forceReference = Persistent::New(args[1]); - baton->force = (int) args[1]->ToInt32()->Value(); + int from_force = (int) args[1]->ToInt32()->Value(); + baton->force = from_force; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, RenameWork, (uv_after_work_cb)RenameAfterWork); @@ -533,8 +544,7 @@ void GitReference::RenameAfterWork(uv_work_t *req) { Handle GitReference::Delete(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -600,7 +610,6 @@ Handle GitReference::IsBranch(const Arguments& args) { int result = git_reference_is_branch( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -615,7 +624,6 @@ Handle GitReference::IsRemote(const Arguments& args) { int result = git_reference_is_remote( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -630,13 +638,13 @@ Handle GitReference::Peel(const Arguments& args) { } git_object *out = NULL; + git_otype from_type = (git_otype) args[0]->ToInt32()->Value(); int result = git_reference_peel( &out , ObjectWrap::Unwrap(args.This())->GetValue() - , (git_otype) args[0]->ToInt32()->Value() + , from_type ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -652,11 +660,13 @@ Handle GitReference::IsValidName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String refname is required."))); } + String::Utf8Value refname(args[0]->ToString()); + const char * from_refname = strdup(*refname); int result = git_reference_is_valid_name( - stringArgToString(args[0]->ToString()).c_str() + from_refname ); - + delete from_refname; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/remote.cc b/src/remote.cc index 32149460e..779ba4380 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -9,8 +9,6 @@ #include "../include/remote.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -97,8 +95,7 @@ git_remote *Remote::GetValue() { Handle Remote::Create(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -117,13 +114,16 @@ Handle Remote::Create(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->nameReference = Persistent::New(args[1]); - String::Utf8Value name(args[1]->ToString()); - baton->name = strdup(*name); + String::Utf8Value name(args[1]->ToString()); + const char * from_name = strdup(*name); + baton->name = from_name; baton->urlReference = Persistent::New(args[2]); - String::Utf8Value url(args[2]->ToString()); - baton->url = strdup(*url); + String::Utf8Value url(args[2]->ToString()); + const char * from_url = strdup(*url); + baton->url = from_url; baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateWork, (uv_after_work_cb)CreateAfterWork); @@ -193,14 +193,20 @@ Handle Remote::CreateInmemory(const Arguments& args) { } git_remote *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value fetch(args[1]->ToString()); + const char * from_fetch = strdup(*fetch); + String::Utf8Value url(args[2]->ToString()); + const char * from_url = strdup(*url); int result = git_remote_create_inmemory( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() - , stringArgToString(args[2]->ToString()).c_str() + , from_repo + , from_fetch + , from_url ); - + delete from_fetch; + delete from_url; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -220,13 +226,16 @@ Handle Remote::Load(const Arguments& args) { } git_remote *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value name(args[1]->ToString()); + const char * from_name = strdup(*name); int result = git_remote_load( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() + , from_repo + , from_name ); - + delete from_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -243,7 +252,6 @@ Handle Remote::Save(const Arguments& args) { int result = git_remote_save( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -259,7 +267,6 @@ Handle Remote::Name(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -273,7 +280,6 @@ Handle Remote::Url(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -287,7 +293,6 @@ Handle Remote::Pushurl(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -299,12 +304,12 @@ Handle Remote::SetUrl(const Arguments& args) { return ThrowException(Exception::Error(String::New("const url is required."))); } + const char* from_url = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_set_url( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_url ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -318,12 +323,12 @@ Handle Remote::SetPushurl(const Arguments& args) { return ThrowException(Exception::Error(String::New("const url is required."))); } + const char* from_url = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_set_pushurl( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_url ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -337,12 +342,14 @@ Handle Remote::SetFetchspec(const Arguments& args) { return ThrowException(Exception::Error(String::New("String spec is required."))); } + String::Utf8Value spec(args[0]->ToString()); + const char * from_spec = strdup(*spec); int result = git_remote_set_fetchspec( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() + , from_spec ); - + delete from_spec; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -358,7 +365,6 @@ Handle Remote::Fetchspec(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Refspec::New((void *)result); return scope.Close(to); @@ -370,12 +376,14 @@ Handle Remote::SetPushspec(const Arguments& args) { return ThrowException(Exception::Error(String::New("String spec is required."))); } + String::Utf8Value spec(args[0]->ToString()); + const char * from_spec = strdup(*spec); int result = git_remote_set_pushspec( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() + , from_spec ); - + delete from_spec; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -391,7 +399,6 @@ Handle Remote::Pushspec(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Refspec::New((void *)result); return scope.Close(to); @@ -403,12 +410,12 @@ Handle Remote::Connect(const Arguments& args) { return ThrowException(Exception::Error(String::New("Direction direction is required."))); } + git_direction from_direction = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_connect( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_direction ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -425,13 +432,14 @@ Handle Remote::Ls(const Arguments& args) { return ThrowException(Exception::Error(String::New("void payload is required."))); } + git_headlist_cb from_list_cb = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + void * from_payload = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); int result = git_remote_ls( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + , from_list_cb + , from_payload ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -448,13 +456,14 @@ Handle Remote::Download(const Arguments& args) { return ThrowException(Exception::Error(String::New("void payload is required."))); } + git_transfer_progress_callback from_progress_cb = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + void * from_payload = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); int result = git_remote_download( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + , from_progress_cb + , from_payload ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -469,7 +478,6 @@ Handle Remote::Connected(const Arguments& args) { int result = git_remote_connected( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -485,7 +493,6 @@ Handle Remote::Stop(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - return Undefined(); } @@ -497,7 +504,6 @@ Handle Remote::Disconnect(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - return Undefined(); } @@ -507,12 +513,12 @@ Handle Remote::Free(const Arguments& args) { return ThrowException(Exception::Error(String::New("Remote remote is required."))); } + git_remote * from_remote = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); git_remote_free( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + from_remote ); - return Undefined(); } @@ -523,7 +529,6 @@ Handle Remote::UpdateTips(const Arguments& args) { int result = git_remote_update_tips( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -537,11 +542,13 @@ Handle Remote::ValidUrl(const Arguments& args) { return ThrowException(Exception::Error(String::New("String url is required."))); } + String::Utf8Value url(args[0]->ToString()); + const char * from_url = strdup(*url); int result = git_remote_valid_url( - stringArgToString(args[0]->ToString()).c_str() + from_url ); - + delete from_url; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -555,11 +562,11 @@ Handle Remote::SupportedUrl(const Arguments& args) { return ThrowException(Exception::Error(String::New("const url is required."))); } + const char* from_url = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_supported_url( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + from_url ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -574,12 +581,12 @@ Handle Remote::List(const Arguments& args) { } git_strarray out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_list( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_repo ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -595,13 +602,13 @@ Handle Remote::CheckCert(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number check is required."))); } + int from_check = (int) args[0]->ToInt32()->Value(); git_remote_check_cert( ObjectWrap::Unwrap(args.This())->GetValue() - , (int) args[0]->ToInt32()->Value() + , from_check ); - return Undefined(); } @@ -614,14 +621,15 @@ Handle Remote::SetCredAcquireCb(const Arguments& args) { return ThrowException(Exception::Error(String::New("void payload is required."))); } + git_cred_acquire_cb from_cred_acquire_cb = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + void * from_payload = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); git_remote_set_cred_acquire_cb( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() + , from_cred_acquire_cb + , from_payload ); - return Undefined(); } @@ -631,12 +639,12 @@ Handle Remote::SetTransport(const Arguments& args) { return ThrowException(Exception::Error(String::New("Transport transport is required."))); } + git_transport * from_transport = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_set_transport( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_transport ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -650,12 +658,12 @@ Handle Remote::SetCallbacks(const Arguments& args) { return ThrowException(Exception::Error(String::New("RemoteCallbacks callbacks is required."))); } + git_remote_callbacks * from_callbacks = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_set_callbacks( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_callbacks ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -671,7 +679,6 @@ Handle Remote::Stats(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = TransferProgress::New((void *)result); return scope.Close(to); @@ -684,7 +691,6 @@ Handle Remote::Autotag(const Arguments& args) { GIT_EXTERN( result = git_remote_autotag( ); - Handle to; to = GIT_EXTERN(::New((void *)result); return scope.Close(to); @@ -696,13 +702,13 @@ Handle Remote::SetAutotag(const Arguments& args) { return ThrowException(Exception::Error(String::New("RemoteAutotagOptionT value is required."))); } + git_remote_autotag_option_t from_value = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); git_remote_set_autotag( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_value ); - return Undefined(); } @@ -718,14 +724,18 @@ Handle Remote::Rename(const Arguments& args) { return ThrowException(Exception::Error(String::New("void payload is required."))); } + String::Utf8Value new_name(args[0]->ToString()); + const char * from_new_name = strdup(*new_name); + git_remote_rename_problem_cb from_callback = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + void * from_payload = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); int result = git_remote_rename( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() - , ObjectWrap::Unwrap(args[1]->ToObject())->GetValue() - , ObjectWrap::Unwrap(args[2]->ToObject())->GetValue() + , from_new_name + , from_callback + , from_payload ); - + delete from_new_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -740,7 +750,6 @@ Handle Remote::UpdateFetchhead(const Arguments& args) { int result = git_remote_update_fetchhead( ObjectWrap::Unwrap(args.This())->GetValue() ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -754,13 +763,13 @@ Handle Remote::SetUpdateFetchhead(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number value is required."))); } + int from_value = (int) args[0]->ToInt32()->Value(); git_remote_set_update_fetchhead( ObjectWrap::Unwrap(args.This())->GetValue() - , (int) args[0]->ToInt32()->Value() + , from_value ); - return Undefined(); } @@ -770,11 +779,13 @@ Handle Remote::IsValidName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String remote_name is required."))); } + String::Utf8Value remote_name(args[0]->ToString()); + const char * from_remote_name = strdup(*remote_name); int result = git_remote_is_valid_name( - stringArgToString(args[0]->ToString()).c_str() + from_remote_name ); - + delete from_remote_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/repo.cc b/src/repo.cc index 54182eb01..d422264da 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -9,8 +9,6 @@ #include "../include/repo.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -66,8 +64,7 @@ git_repository *GitRepo::GetValue() { Handle GitRepo::Open(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } @@ -80,8 +77,9 @@ Handle GitRepo::Open(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->pathReference = Persistent::New(args[0]); - String::Utf8Value path(args[0]->ToString()); - baton->path = strdup(*path); + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + baton->path = from_path; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); @@ -135,8 +133,7 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { Handle GitRepo::Init(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsBoolean()) { @@ -152,10 +149,12 @@ Handle GitRepo::Init(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->pathReference = Persistent::New(args[0]); - String::Utf8Value path(args[0]->ToString()); - baton->path = strdup(*path); + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + baton->path = from_path; baton->is_bareReference = Persistent::New(args[1]); - baton->is_bare = (unsigned) args[1]->ToBoolean()->Value(); + unsigned from_is_bare = (unsigned) args[1]->ToBoolean()->Value(); + baton->is_bare = from_is_bare; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); @@ -217,7 +216,6 @@ Handle GitRepo::Path(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -231,7 +229,6 @@ Handle GitRepo::Workdir(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); diff --git a/src/revwalk.cc b/src/revwalk.cc index 739cdd0db..013584669 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -11,8 +11,6 @@ #include "../include/oid.h" #include "../include/repo.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -81,12 +79,12 @@ Handle GitRevWalk::Make(const Arguments& args) { } git_revwalk *out = NULL; + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_revwalk_new( &out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_repo ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -104,14 +102,12 @@ Handle GitRevWalk::Reset(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - return Undefined(); } Handle GitRevWalk::Push(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } @@ -126,7 +122,8 @@ Handle GitRevWalk::Push(const Arguments& args) { baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->idReference = Persistent::New(args[0]); - baton->id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); @@ -179,8 +176,7 @@ void GitRevWalk::PushAfterWork(uv_work_t *req) { Handle GitRevWalk::PushGlob(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String glob is required."))); } @@ -195,8 +191,9 @@ Handle GitRevWalk::PushGlob(const Arguments& args) { baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->globReference = Persistent::New(args[0]); - String::Utf8Value glob(args[0]->ToString()); - baton->glob = strdup(*glob); + String::Utf8Value glob(args[0]->ToString()); + const char * from_glob = strdup(*glob); + baton->glob = from_glob; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushGlobWork, (uv_after_work_cb)PushGlobAfterWork); @@ -250,8 +247,7 @@ void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { Handle GitRevWalk::PushHead(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -312,8 +308,7 @@ void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { Handle GitRevWalk::Hide(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid commit_id is required."))); } @@ -328,7 +323,8 @@ Handle GitRevWalk::Hide(const Arguments& args) { baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->commit_idReference = Persistent::New(args[0]); - baton->commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const git_oid * from_commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->commit_id = from_commit_id; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, HideWork, (uv_after_work_cb)HideAfterWork); @@ -381,8 +377,7 @@ void GitRevWalk::HideAfterWork(uv_work_t *req) { Handle GitRevWalk::HideGlob(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String glob is required."))); } @@ -397,8 +392,9 @@ Handle GitRevWalk::HideGlob(const Arguments& args) { baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->globReference = Persistent::New(args[0]); - String::Utf8Value glob(args[0]->ToString()); - baton->glob = strdup(*glob); + String::Utf8Value glob(args[0]->ToString()); + const char * from_glob = strdup(*glob); + baton->glob = from_glob; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, HideGlobWork, (uv_after_work_cb)HideGlobAfterWork); @@ -452,8 +448,7 @@ void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { Handle GitRevWalk::HideHead(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -514,8 +509,7 @@ void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { Handle GitRevWalk::PushRef(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String refname is required."))); } @@ -530,8 +524,9 @@ Handle GitRevWalk::PushRef(const Arguments& args) { baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->refnameReference = Persistent::New(args[0]); - String::Utf8Value refname(args[0]->ToString()); - baton->refname = strdup(*refname); + String::Utf8Value refname(args[0]->ToString()); + const char * from_refname = strdup(*refname); + baton->refname = from_refname; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushRefWork, (uv_after_work_cb)PushRefAfterWork); @@ -585,8 +580,7 @@ void GitRevWalk::PushRefAfterWork(uv_work_t *req) { Handle GitRevWalk::HideRef(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String refname is required."))); } @@ -601,8 +595,9 @@ Handle GitRevWalk::HideRef(const Arguments& args) { baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->refnameReference = Persistent::New(args[0]); - String::Utf8Value refname(args[0]->ToString()); - baton->refname = strdup(*refname); + String::Utf8Value refname(args[0]->ToString()); + const char * from_refname = strdup(*refname); + baton->refname = from_refname; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, HideRefWork, (uv_after_work_cb)HideRefAfterWork); @@ -656,8 +651,7 @@ void GitRevWalk::HideRefAfterWork(uv_work_t *req) { Handle GitRevWalk::Next(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -725,13 +719,13 @@ Handle GitRevWalk::Sorting(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number sort_mode is required."))); } + unsigned int from_sort_mode = (unsigned int) args[0]->ToUint32()->Value(); git_revwalk_sorting( ObjectWrap::Unwrap(args.This())->GetValue() - , (unsigned int) args[0]->ToUint32()->Value() + , from_sort_mode ); - return Undefined(); } diff --git a/src/signature.cc b/src/signature.cc index 3f2c843f8..f8b679be1 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -10,8 +10,6 @@ #include "../include/signature.h" #include "../include/time.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -74,13 +72,18 @@ Handle GitSignature::Now(const Arguments& args) { } git_signature *out = NULL; + String::Utf8Value name(args[0]->ToString()); + const char * from_name = strdup(*name); + String::Utf8Value email(args[1]->ToString()); + const char * from_email = strdup(*email); int result = git_signature_now( &out - , stringArgToString(args[0]->ToString()).c_str() - , stringArgToString(args[1]->ToString()).c_str() + , from_name + , from_email ); - + delete from_name; + delete from_email; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/tag.cc b/src/tag.cc index 6f58f540e..acfe6f935 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -13,8 +13,6 @@ #include "../include/object.h" #include "../include/signature.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -78,8 +76,7 @@ git_tag *GitTag::GetValue() { Handle GitTag::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -95,9 +92,11 @@ Handle GitTag::Lookup(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->idReference = Persistent::New(args[1]); - baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->id = from_id; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); @@ -158,7 +157,6 @@ Handle GitTag::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -166,8 +164,7 @@ Handle GitTag::Oid(const Arguments& args) { Handle GitTag::Target(const Arguments& args) { HandleScope scope; - - + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } @@ -236,7 +233,6 @@ Handle GitTag::TargetId(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -250,7 +246,6 @@ Handle GitTag::TargetType(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Int32::New(result); return scope.Close(to); @@ -264,7 +259,6 @@ Handle GitTag::Name(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -278,7 +272,6 @@ Handle GitTag::Tagger(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitSignature::New((void *)result); return scope.Close(to); @@ -292,7 +285,6 @@ Handle GitTag::Message(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -300,8 +292,7 @@ Handle GitTag::Message(const Arguments& args) { Handle GitTag::Create(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -329,19 +320,25 @@ Handle GitTag::Create(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->tag_nameReference = Persistent::New(args[1]); - String::Utf8Value tag_name(args[1]->ToString()); - baton->tag_name = strdup(*tag_name); + String::Utf8Value tag_name(args[1]->ToString()); + const char * from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; baton->targetReference = Persistent::New(args[2]); - baton->target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const git_object * from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->target = from_target; baton->taggerReference = Persistent::New(args[3]); - baton->tagger = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + const git_signature * from_tagger = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->tagger = from_tagger; baton->messageReference = Persistent::New(args[4]); - String::Utf8Value message(args[4]->ToString()); - baton->message = strdup(*message); + String::Utf8Value message(args[4]->ToString()); + const char * from_message = strdup(*message); + baton->message = from_message; baton->forceReference = Persistent::New(args[5]); - baton->force = (int) args[5]->ToInt32()->Value(); + int from_force = (int) args[5]->ToInt32()->Value(); + baton->force = from_force; baton->callback = Persistent::New(Local::Cast(args[6])); uv_queue_work(uv_default_loop(), &baton->request, CreateWork, (uv_after_work_cb)CreateAfterWork); @@ -406,8 +403,7 @@ void GitTag::CreateAfterWork(uv_work_t *req) { Handle GitTag::CreateLightweight(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { @@ -429,14 +425,18 @@ Handle GitTag::CreateLightweight(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->tag_nameReference = Persistent::New(args[1]); - String::Utf8Value tag_name(args[1]->ToString()); - baton->tag_name = strdup(*tag_name); + String::Utf8Value tag_name(args[1]->ToString()); + const char * from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; baton->targetReference = Persistent::New(args[2]); - baton->target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const git_object * from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->target = from_target; baton->forceReference = Persistent::New(args[3]); - baton->force = (int) args[3]->ToInt32()->Value(); + int from_force = (int) args[3]->ToInt32()->Value(); + baton->force = from_force; baton->callback = Persistent::New(Local::Cast(args[4])); uv_queue_work(uv_default_loop(), &baton->request, CreateLightweightWork, (uv_after_work_cb)CreateLightweightAfterWork); @@ -503,12 +503,15 @@ Handle GitTag::Delete(const Arguments& args) { return ThrowException(Exception::Error(String::New("String tag_name is required."))); } + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value tag_name(args[1]->ToString()); + const char * from_tag_name = strdup(*tag_name); int result = git_tag_delete( - ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() - , stringArgToString(args[1]->ToString()).c_str() + from_repo + , from_tag_name ); - + delete from_tag_name; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -523,12 +526,12 @@ Handle GitTag::Peel(const Arguments& args) { } git_object *tag_target_out = NULL; + const git_tag * from_tag = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_tag_peel( &tag_target_out - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_tag ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/threads.cc b/src/threads.cc index a46818c96..06bedf47f 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -9,8 +9,6 @@ #include "../include/threads.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -32,7 +30,6 @@ Handle GitThreads::Init(const Arguments& args) { int result = git_threads_init( ); - if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -47,7 +44,6 @@ Handle GitThreads::Shutdown(const Arguments& args) { git_threads_shutdown( ); - return Undefined(); } diff --git a/src/time.cc b/src/time.cc index 215870caa..5d48810d5 100644 --- a/src/time.cc +++ b/src/time.cc @@ -9,8 +9,6 @@ #include "../include/time.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; diff --git a/src/tree.cc b/src/tree.cc index e7dfc664a..49558eda1 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -12,8 +12,6 @@ #include "../include/oid.h" #include "../include/tree_entry.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -72,8 +70,7 @@ git_tree *GitTree::GetValue() { Handle GitTree::Lookup(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { @@ -89,9 +86,11 @@ Handle GitTree::Lookup(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->idReference = Persistent::New(args[1]); - baton->id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->id = from_id; baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); @@ -152,7 +151,6 @@ Handle GitTree::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -166,7 +164,6 @@ Handle GitTree::Size(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Uint32::New(result); return scope.Close(to); @@ -178,12 +175,14 @@ Handle GitTree::EntryByName(const Arguments& args) { return ThrowException(Exception::Error(String::New("String filename is required."))); } + String::Utf8Value filename(args[0]->ToString()); + const char * from_filename = strdup(*filename); const git_tree_entry * result = git_tree_entry_byname( ObjectWrap::Unwrap(args.This())->GetValue() - , stringArgToString(args[0]->ToString()).c_str() + , from_filename ); - + delete from_filename; Handle to; to = GitTreeEntry::New((void *)result); @@ -196,13 +195,13 @@ Handle GitTree::EntryByIndex(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number idx is required."))); } + size_t from_idx = (size_t) args[0]->ToUint32()->Value(); const git_tree_entry * result = git_tree_entry_byindex( ObjectWrap::Unwrap(args.This())->GetValue() - , (size_t) args[0]->ToUint32()->Value() + , from_idx ); - Handle to; to = GitTreeEntry::New((void *)result); return scope.Close(to); @@ -214,13 +213,13 @@ Handle GitTree::EntryByOid(const Arguments& args) { return ThrowException(Exception::Error(String::New("Oid oid is required."))); } + const git_oid * from_oid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); const git_tree_entry * result = git_tree_entry_byoid( ObjectWrap::Unwrap(args.This())->GetValue() - , ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + , from_oid ); - Handle to; to = GitTreeEntry::New((void *)result); return scope.Close(to); @@ -228,8 +227,7 @@ Handle GitTree::EntryByOid(const Arguments& args) { Handle GitTree::GetEntryByPath(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsString()) { + if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); } @@ -244,8 +242,9 @@ Handle GitTree::GetEntryByPath(const Arguments& args) { baton->rootReference = Persistent::New(args.This()); baton->root = ObjectWrap::Unwrap(args.This())->GetValue(); baton->pathReference = Persistent::New(args[0]); - String::Utf8Value path(args[0]->ToString()); - baton->path = strdup(*path); + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + baton->path = from_path; baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetEntryByPathWork, (uv_after_work_cb)GetEntryByPathAfterWork); diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 98f962d5a..1dc1256bf 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -12,8 +12,6 @@ #include "../include/repo.h" #include "../include/object.h" -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -76,7 +74,6 @@ Handle GitTreeEntry::Name(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = String::New(result); return scope.Close(to); @@ -90,7 +87,6 @@ Handle GitTreeEntry::Oid(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = GitOid::New((void *)result); return scope.Close(to); @@ -104,7 +100,6 @@ Handle GitTreeEntry::Type(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Number::New(result); return scope.Close(to); @@ -118,7 +113,6 @@ Handle GitTreeEntry::filemode(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() ); - Handle to; to = Number::New(result); return scope.Close(to); @@ -126,8 +120,7 @@ Handle GitTreeEntry::filemode(const Arguments& args) { Handle GitTreeEntry::GetObject(const Arguments& args) { HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); } @@ -140,7 +133,8 @@ Handle GitTreeEntry::GetObject(const Arguments& args) { baton->error = NULL; baton->request.data = baton; baton->repoReference = Persistent::New(args[0]); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; baton->entryReference = Persistent::New(args.This()); baton->entry = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[1])); diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 4e5e47ff6..66a8acd14 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -26,8 +26,6 @@ <% } -%> <% } -%> -#include "../include/functions/string.h" - using namespace v8; using namespace node; @@ -137,7 +135,7 @@ void <%- cppClassName %>::Initialize(Handle target) { <% if (functionInfo.isAsync) { -%> Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; - <% var jsArg; %> + <% var jsArg; -%> <% include templates/guardArguments.cc.ejs -%> if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->IsFunction()) { @@ -160,19 +158,9 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg baton-><%- arg.name %>Reference = Persistent::New(args[<%- jsArg %>]); <% if (arg.isOptional) { -%> if (args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { - <% } -%> -<% if (arg.cppClassName == 'String') { -%> - String::Utf8Value <%- arg.name %>(args[<%- jsArg %>]->ToString()); - baton-><%- arg.name %> = strdup(*<%- arg.name %>); -<% } else if (arg.cppClassName == 'Array') { -%> - baton-><%- arg.name %> = Array::Cast(*args[<%- jsArg %>]); -<% } else if (arg.cppClassName == 'Buffer') { -%> - baton-><%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())); -<% } else if (isV8Value(arg.cppClassName)) { -%> - baton-><%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value(); -<% } else { -%> - baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue(); <% } -%> + <% include templates/convertFromV8.cc.ejs -%> + baton-><%- arg.name %> = from_<%- arg.name %>; <% if (arg.isOptional) { -%> } else { baton-><%- arg.name %> = NULL; @@ -236,7 +224,6 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t -%> <% include templates/convertToV8.cc.ejs -%> result->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); - <% } -%> <% } -%> Handle argv[2] = { @@ -290,7 +277,14 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg <%- arg.cType.replace('*', '') %><%- arg.name %> = NULL; <% } -%> <% } -%> - +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; + if (arg.isSelf || arg.isReturn) continue; +-%> +<% include templates/convertFromV8.cc.ejs -%> +<% jsArg++; -%> +<% } %> <% if (returns.length || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( <% for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { @@ -301,19 +295,23 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() <% } else if (arg.isReturn) { -%> <%- arg.name %> -<% } else if (arg.cppClassName == 'String') { -%> -stringArgToString(args[<%- jsArg %>]->ToString()).c_str() -<% } else if (isV8Value(arg.cppClassName)) { -%> -(<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value() <% } else { -%> -ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue() +from_<%- arg.name %> <% } -%> <% if (!(arg.isReturn || arg.isSelf)) jsArg++; } -%> ); - +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isSelf || arg.isReturn) continue; +-%> +<% if (arg.cppClassName == 'String') { -%> + delete from_<%- arg.name %>; +<% } -%> +<% } -%> <% if (functionInfo.return.isErrorCode) { -%> if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); diff --git a/templates/convertFromV8.cc.ejs b/templates/convertFromV8.cc.ejs new file mode 100644 index 000000000..ad7246417 --- /dev/null +++ b/templates/convertFromV8.cc.ejs @@ -0,0 +1,12 @@ +<% if (arg.cppClassName == 'String') { -%> + String::Utf8Value <%- arg.name %>(args[<%- jsArg %>]->ToString()); + <%- arg.cType %> from_<%- arg.name %> = strdup(*<%- arg.name %>); +<% } else if (arg.cppClassName == 'Array') { -%> + <%- arg.cType %> from_<%- arg.name %> = Array::Cast(*args[<%- jsArg %>]); +<% } else if (arg.cppClassName == 'Buffer') { -%> + <%- arg.cType %> from_<%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())); +<% } else if (isV8Value(arg.cppClassName)) { -%> + <%- arg.cType %> from_<%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value(); +<% } else { -%> + <%- arg.cType %> from_<%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue(); +<% } -%> From 8c83ea529f14f833d75ba713a0f71ec67fa4b0dd Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 28 Jun 2013 19:23:39 +0200 Subject: [PATCH 15/28] Put factory methods as instance methods on repo --- binding.gyp | 2 + example/raw-blob.js | 3 +- include/blob.h | 15 - include/commit.h | 15 - include/object.h | 17 - include/refdb.h | 37 + include/reference.h | 17 - include/remote.h | 29 +- include/repo.h | 151 +++ include/revwalk.h | 1 - include/submodule.h | 146 +++ include/tag.h | 57 - include/tree.h | 15 - lib/commit.js | 2 +- lib/repo.js | 8 +- lib/revwalk.js | 7 - src/base.cc | 4 + src/blob.cc | 76 -- src/commit.cc | 76 -- src/object.cc | 84 -- src/refdb.cc | 60 ++ src/reference.cc | 160 --- src/remote.cc | 315 ++---- src/repo.cc | 870 +++++++++++++++ src/revwalk.cc | 23 - src/submodule.cc | 676 ++++++++++++ src/tag.cc | 282 ----- src/tree.cc | 76 -- test/raw-blob.js | 19 +- test/raw-commit.js | 21 +- test/raw-reference.js | 14 +- v0.18.0.json | 2385 +++++++++++++++++++++-------------------- 32 files changed, 3265 insertions(+), 2398 deletions(-) create mode 100644 include/refdb.h create mode 100644 include/submodule.h create mode 100644 src/refdb.cc create mode 100644 src/submodule.cc diff --git a/binding.gyp b/binding.gyp index 88968d0d9..16fc5e64c 100644 --- a/binding.gyp +++ b/binding.gyp @@ -26,6 +26,8 @@ 'src/diff_range.cc', 'src/threads.cc', 'src/wrapper.cc', + 'src/refdb.cc', + 'src/submodule.cc' ], 'include_dirs': [ diff --git a/example/raw-blob.js b/example/raw-blob.js index cee4b70a2..18b6d238b 100644 --- a/example/raw-blob.js +++ b/example/raw-blob.js @@ -6,8 +6,7 @@ repo.open( path.resolve( '../.git' ), function() { var oid = new git.Oid(); oid.mkstr( '59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5' ); - var commit = new git.Commit(); - commit.lookup( repo, oid, function( err ) { + repo.getCommit(oid, function( err ) { var tree = new git.Tree( repo ), entry = new git.TreeEntry(), blob = new git.Blob( repo ); diff --git a/include/blob.h b/include/blob.h index ddd714667..22d777e1a 100755 --- a/include/blob.h +++ b/include/blob.h @@ -31,21 +31,6 @@ class GitBlob : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - struct LookupBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_blob * blob; - Persistent repoReference; - git_repository * repo; - Persistent idReference; - const git_oid * id; - Persistent callback; - }; static Handle Oid(const Arguments& args); static Handle Content(const Arguments& args); static Handle Size(const Arguments& args); diff --git a/include/commit.h b/include/commit.h index 6c28a080c..0a938d5cf 100755 --- a/include/commit.h +++ b/include/commit.h @@ -31,21 +31,6 @@ class GitCommit : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - struct LookupBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_commit * commit; - Persistent repoReference; - git_repository * repo; - Persistent idReference; - const git_oid * id; - Persistent callback; - }; static Handle Oid(const Arguments& args); static Handle MessageEncoding(const Arguments& args); static Handle Message(const Arguments& args); diff --git a/include/object.h b/include/object.h index 8f63fb5de..c0f3d6d30 100644 --- a/include/object.h +++ b/include/object.h @@ -31,23 +31,6 @@ class GitObject : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - struct LookupBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_object * object; - Persistent repoReference; - git_repository * repo; - Persistent idReference; - const git_oid * id; - Persistent typeReference; - git_otype type; - Persistent callback; - }; static Handle Oid(const Arguments& args); static Handle Type(const Arguments& args); static Handle Owner(const Arguments& args); diff --git a/include/refdb.h b/include/refdb.h new file mode 100644 index 000000000..51355028f --- /dev/null +++ b/include/refdb.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITREFDB_H +#define GITREFDB_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitRefDb : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_refdb *GetValue(); + + static Handle New(void *raw); + + private: + GitRefDb(git_refdb *raw); + ~GitRefDb(); + + static Handle New(const Arguments& args); + + + git_refdb *raw; +}; + +#endif diff --git a/include/reference.h b/include/reference.h index 6f36a6a6c..05ee69f66 100644 --- a/include/reference.h +++ b/include/reference.h @@ -31,21 +31,6 @@ class GitReference : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - struct LookupBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_reference * out; - Persistent repoReference; - git_repository * repo; - Persistent nameReference; - const char * name; - Persistent callback; - }; static Handle OidForName(const Arguments& args); static void OidForNameWork(uv_work_t* req); static void OidForNameAfterWork(uv_work_t* req); @@ -61,8 +46,6 @@ class GitReference : public ObjectWrap { const char * name; Persistent callback; }; - static Handle CreateSymbolic(const Arguments& args); - static Handle Create(const Arguments& args); static Handle Oid(const Arguments& args); static Handle Name(const Arguments& args); static Handle Type(const Arguments& args); diff --git a/include/remote.h b/include/remote.h index e965ae164..e698c5eb8 100644 --- a/include/remote.h +++ b/include/remote.h @@ -2,8 +2,8 @@ * This code is auto-generated; unless you know what you're doing, do not modify! **/ -#ifndef REMOTE_H -#define REMOTE_H +#ifndef GITREMOTE_H +#define GITREMOTE_H #include #include @@ -14,7 +14,7 @@ using namespace node; using namespace v8; -class Remote : public ObjectWrap { +class GitRemote : public ObjectWrap { public: static Persistent constructor_template; @@ -25,31 +25,12 @@ class Remote : public ObjectWrap { static Handle New(void *raw); private: - Remote(git_remote *raw); - ~Remote(); + GitRemote(git_remote *raw); + ~GitRemote(); static Handle New(const Arguments& args); - static Handle Create(const Arguments& args); - static void CreateWork(uv_work_t* req); - static void CreateAfterWork(uv_work_t* req); - - struct CreateBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_remote * out; - Persistent repoReference; - git_repository * repo; - Persistent nameReference; - const char * name; - Persistent urlReference; - const char * url; - Persistent callback; - }; - static Handle CreateInmemory(const Arguments& args); - static Handle Load(const Arguments& args); static Handle Save(const Arguments& args); static Handle Name(const Arguments& args); static Handle Url(const Arguments& args); diff --git a/include/repo.h b/include/repo.h index 9682e5c9c..3afef0ca6 100755 --- a/include/repo.h +++ b/include/repo.h @@ -61,6 +61,157 @@ class GitRepo : public ObjectWrap { }; static Handle Path(const Arguments& args); static Handle Workdir(const Arguments& args); + static Handle GetBlob(const Arguments& args); + static void GetBlobWork(uv_work_t* req); + static void GetBlobAfterWork(uv_work_t* req); + + struct GetBlobBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_blob * blob; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle GetCommit(const Arguments& args); + static void GetCommitWork(uv_work_t* req); + static void GetCommitAfterWork(uv_work_t* req); + + struct GetCommitBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_commit * commit; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle GetObject(const Arguments& args); + static void GetObjectWork(uv_work_t* req); + static void GetObjectAfterWork(uv_work_t* req); + + struct GetObjectBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_object * object; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent typeReference; + git_otype type; + Persistent callback; + }; + static Handle GetReference(const Arguments& args); + static void GetReferenceWork(uv_work_t* req); + static void GetReferenceAfterWork(uv_work_t* req); + + struct GetReferenceBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_reference * out; + Persistent repoReference; + git_repository * repo; + Persistent nameReference; + const char * name; + Persistent callback; + }; + static Handle CreateSymbolicReference(const Arguments& args); + static Handle CreateReference(const Arguments& args); + static Handle CreateRevWalk(const Arguments& args); + static Handle GetSubmodule(const Arguments& args); + static Handle AddSubmodule(const Arguments& args); + static Handle GetTag(const Arguments& args); + static void GetTagWork(uv_work_t* req); + static void GetTagAfterWork(uv_work_t* req); + + struct GetTagBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_tag * out; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle CreateTag(const Arguments& args); + static void CreateTagWork(uv_work_t* req); + static void CreateTagAfterWork(uv_work_t* req); + + struct CreateTagBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent targetReference; + const git_object * target; + Persistent taggerReference; + const git_signature * tagger; + Persistent messageReference; + const char * message; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle CreateLightweightTag(const Arguments& args); + static void CreateLightweightTagWork(uv_work_t* req); + static void CreateLightweightTagAfterWork(uv_work_t* req); + + struct CreateLightweightTagBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent targetReference; + const git_object * target; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle GetTree(const Arguments& args); + static void GetTreeWork(uv_work_t* req); + static void GetTreeAfterWork(uv_work_t* req); + + struct GetTreeBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_tree * out; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle ReloadSubmodules(const Arguments& args); + static void ReloadSubmodulesWork(uv_work_t* req); + static void ReloadSubmodulesAfterWork(uv_work_t* req); + + struct ReloadSubmodulesBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent repoReference; + git_repository * repo; + Persistent callback; + }; git_repository *raw; }; diff --git a/include/revwalk.h b/include/revwalk.h index 47e5900ed..c2096cc61 100755 --- a/include/revwalk.h +++ b/include/revwalk.h @@ -31,7 +31,6 @@ class GitRevWalk : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Make(const Arguments& args); static Handle Reset(const Arguments& args); static Handle Push(const Arguments& args); static void PushWork(uv_work_t* req); diff --git a/include/submodule.h b/include/submodule.h new file mode 100644 index 000000000..f80d8ee3d --- /dev/null +++ b/include/submodule.h @@ -0,0 +1,146 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITSUBMODULE_H +#define GITSUBMODULE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitSubmodule : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_submodule *GetValue(); + + static Handle New(void *raw); + + private: + GitSubmodule(git_submodule *raw); + ~GitSubmodule(); + + static Handle New(const Arguments& args); + + + static Handle AddFinalize(const Arguments& args); + static void AddFinalizeWork(uv_work_t* req); + static void AddFinalizeAfterWork(uv_work_t* req); + + struct AddFinalizeBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle AddToIndex(const Arguments& args); + static void AddToIndexWork(uv_work_t* req); + static void AddToIndexAfterWork(uv_work_t* req); + + struct AddToIndexBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent write_indexReference; + int write_index; + Persistent callback; + }; + static Handle Save(const Arguments& args); + static void SaveWork(uv_work_t* req); + static void SaveAfterWork(uv_work_t* req); + + struct SaveBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Name(const Arguments& args); + static Handle Path(const Arguments& args); + static Handle Url(const Arguments& args); + static Handle SetUrl(const Arguments& args); + static Handle IndexId(const Arguments& args); + static Handle HeadId(const Arguments& args); + static Handle Init(const Arguments& args); + static void InitWork(uv_work_t* req); + static void InitAfterWork(uv_work_t* req); + + struct InitBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent overwriteReference; + int overwrite; + Persistent callback; + }; + static Handle Sync(const Arguments& args); + static void SyncWork(uv_work_t* req); + static void SyncAfterWork(uv_work_t* req); + + struct SyncBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Open(const Arguments& args); + static void OpenWork(uv_work_t* req); + static void OpenAfterWork(uv_work_t* req); + + struct OpenBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_repository * repo; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Reload(const Arguments& args); + static void ReloadWork(uv_work_t* req); + static void ReloadAfterWork(uv_work_t* req); + + struct ReloadBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Status(const Arguments& args); + static void StatusWork(uv_work_t* req); + static void StatusAfterWork(uv_work_t* req); + + struct StatusBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent statusReference; + unsigned int * status; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + git_submodule *raw; +}; + +#endif diff --git a/include/tag.h b/include/tag.h index 9d9bb624c..dae3dc6e8 100755 --- a/include/tag.h +++ b/include/tag.h @@ -31,21 +31,6 @@ class GitTag : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - struct LookupBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_tag * out; - Persistent repoReference; - git_repository * repo; - Persistent idReference; - const git_oid * id; - Persistent callback; - }; static Handle Oid(const Arguments& args); static Handle Target(const Arguments& args); static void TargetWork(uv_work_t* req); @@ -65,48 +50,6 @@ class GitTag : public ObjectWrap { static Handle Name(const Arguments& args); static Handle Tagger(const Arguments& args); static Handle Message(const Arguments& args); - static Handle Create(const Arguments& args); - static void CreateWork(uv_work_t* req); - static void CreateAfterWork(uv_work_t* req); - - struct CreateBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_oid * oid; - Persistent repoReference; - git_repository * repo; - Persistent tag_nameReference; - const char * tag_name; - Persistent targetReference; - const git_object * target; - Persistent taggerReference; - const git_signature * tagger; - Persistent messageReference; - const char * message; - Persistent forceReference; - int force; - Persistent callback; - }; - static Handle CreateLightweight(const Arguments& args); - static void CreateLightweightWork(uv_work_t* req); - static void CreateLightweightAfterWork(uv_work_t* req); - - struct CreateLightweightBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_oid * oid; - Persistent repoReference; - git_repository * repo; - Persistent tag_nameReference; - const char * tag_name; - Persistent targetReference; - const git_object * target; - Persistent forceReference; - int force; - Persistent callback; - }; static Handle Delete(const Arguments& args); static Handle Peel(const Arguments& args); git_tag *raw; diff --git a/include/tree.h b/include/tree.h index 200ef555a..e354c9de8 100755 --- a/include/tree.h +++ b/include/tree.h @@ -31,21 +31,6 @@ class GitTree : public ObjectWrap { static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - struct LookupBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_tree * out; - Persistent repoReference; - git_repository * repo; - Persistent idReference; - const git_oid * id; - Persistent callback; - }; static Handle Oid(const Arguments& args); static Handle Size(const Arguments& args); static Handle EntryByName(const Arguments& args); diff --git a/lib/commit.js b/lib/commit.js index cd8d319ec..e75117465 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -132,7 +132,7 @@ Commit.prototype.history = function() { var event = new events.EventEmitter(); var oid = this.oid(); - var revwalk = git.revwalk.make(this.repo); + var revwalk = new git.revwalk(this.repo, this.repo.rawRepo.createRevWalk()); var commits = []; event.start = function() { revwalk.walk(oid, function commitRevWalk(error, commit) { diff --git a/lib/repo.js b/lib/repo.js index 1e291adfe..962e9bb6d 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -65,7 +65,7 @@ Repo.prototype.branch = function(name, callback) { * @param {Commit|null} repo HEAD commit for the branch. */ var self = this; - git.reference.lookup(this.rawRepo, 'refs/heads/' + name, function referenceLookupCallback(error, reference) { + this.rawRepo.getReference('refs/heads/' + name, function referenceLookupCallback(error, reference) { if (error) return callback(error); var oid = reference.oid(); @@ -93,7 +93,7 @@ Repo.prototype.commit = function(oid, callback) { try { if (typeof oid === 'string') oid = git.raw.Oid.fromString(oid); - git.raw.Commit.lookup(this.rawRepo, oid, function(error, rawCommit) { + this.rawRepo.getCommit(oid, function(error, rawCommit) { if (error) return callback(error); callback(null, new git.commit(self, rawCommit)); }); @@ -114,7 +114,7 @@ Repo.prototype.blob = function(oid, callback) { * @param {GitError|null} error An Error or null if successful. * @param {Blob|null} blob Retrieved blob object or null. */ - git.raw.Blob.lookup(this.rawRepo, oid.rawOid, function blobLookup(error, rawBlob) { + this.rawRepo.getBlob(oid.rawOid, function blobLookup(error, rawBlob) { if (error) return callback(error); callback(null, new git.blob(rawBlob)); }); @@ -133,7 +133,7 @@ Repo.prototype.tree = function(oid, callback) { * @param {Tree|null} tree The tree object or null. */ var self = this; - git.raw.Tree.lookup(this.rawRepo, oid.rawOid, function(error, rawTree) { + this.rawRepo.getTree(oid.rawOid, function(error, rawTree) { if (error) return callback(error); callback(null, new git.tree(self, rawTree)); }); diff --git a/lib/revwalk.js b/lib/revwalk.js index bbd07f24e..d2fb4849f 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -20,13 +20,6 @@ var RevWalk = function(repo, rawRevWalk) { this.rawRevWalk = rawRevWalk; }; -/** - * Make a new revwalker. - */ -RevWalk.make = function(repo) { - return new RevWalk(repo, git.raw.RevWalk.make(repo.rawRepo)); -}; - /** * Walk the history from the given oid. * diff --git a/src/base.cc b/src/base.cc index 4e8121c58..1816428c5 100755 --- a/src/base.cc +++ b/src/base.cc @@ -32,6 +32,8 @@ #include "../include/threads.h" #include "../include/index.h" #include "../include/tag.h" +#include "../include/refdb.h" +#include "../include/submodule.h" extern "C" void init(Handle target) { HandleScope scope; @@ -49,6 +51,8 @@ extern "C" void init(Handle target) { GitRepo::Initialize(target); GitCommit::Initialize(target); GitRevWalk::Initialize(target); + GitRefDb::Initialize(target); + GitSubmodule::Initialize(target); GitTree::Initialize(target); GitTreeEntry::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index d45b2a5db..20e2dbd43 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -32,7 +32,6 @@ void GitBlob::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Blob")); - NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "content", Content); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); @@ -69,81 +68,6 @@ git_blob *GitBlob::GetValue() { } -Handle GitBlob::Lookup(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid id is required."))); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->idReference = Persistent::New(args[1]); - const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->id = from_id; - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} - -void GitBlob::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - int result = git_blob_lookup( - &baton->blob, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitBlob::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitBlob::New((void *)baton->blob); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->idReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; diff --git a/src/commit.cc b/src/commit.cc index d618f92de..6bd308faf 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -32,7 +32,6 @@ void GitCommit::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Commit")); - NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "messageEncoding", MessageEncoding); NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); @@ -76,81 +75,6 @@ git_commit *GitCommit::GetValue() { } -Handle GitCommit::Lookup(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid id is required."))); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->idReference = Persistent::New(args[1]); - const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->id = from_id; - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} - -void GitCommit::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - int result = git_commit_lookup( - &baton->commit, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitCommit::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitCommit::New((void *)baton->commit); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->idReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; diff --git a/src/object.cc b/src/object.cc index fb37cedb6..470b6cfdf 100644 --- a/src/object.cc +++ b/src/object.cc @@ -30,7 +30,6 @@ void GitObject::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Object")); - NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner); @@ -65,89 +64,6 @@ git_object *GitObject::GetValue() { } -Handle GitObject::Lookup(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid id is required."))); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return ThrowException(Exception::Error(String::New("Number type is required."))); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->idReference = Persistent::New(args[1]); - const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->id = from_id; - baton->typeReference = Persistent::New(args[2]); - git_otype from_type = (git_otype) args[2]->ToInt32()->Value(); - baton->type = from_type; - baton->callback = Persistent::New(Local::Cast(args[3])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} - -void GitObject::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - int result = git_object_lookup( - &baton->object, - baton->repo, - baton->id, - baton->type - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitObject::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitObject::New((void *)baton->object); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->idReference.Dispose(); - baton->typeReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitObject::Oid(const Arguments& args) { HandleScope scope; diff --git a/src/refdb.cc b/src/refdb.cc new file mode 100644 index 000000000..73caf4d0b --- /dev/null +++ b/src/refdb.cc @@ -0,0 +1,60 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/refdb.h" + +using namespace v8; +using namespace node; + +GitRefDb::GitRefDb(git_refdb *raw) { + this->raw = raw; +} + +GitRefDb::~GitRefDb() { +} + +void GitRefDb::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("RefDb")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("RefDb"), constructor_template); +} + +Handle GitRefDb::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_refdb is required."))); + } + + GitRefDb* object = new GitRefDb((git_refdb *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitRefDb::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRefDb::constructor_template->NewInstance(1, argv)); +} + +git_refdb *GitRefDb::GetValue() { + return this->raw; +} + + +Persistent GitRefDb::constructor_template; diff --git a/src/reference.cc b/src/reference.cc index 3a50da113..44313fdcc 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -31,10 +31,7 @@ void GitReference::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Reference")); - NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_METHOD(tpl, "oidForName", OidForName); - NODE_SET_METHOD(tpl, "createSymbolic", CreateSymbolic); - NODE_SET_METHOD(tpl, "create", Create); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); @@ -77,83 +74,6 @@ git_reference *GitReference::GetValue() { } -Handle GitReference::Lookup(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String name is required."))); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->nameReference = Persistent::New(args[1]); - String::Utf8Value name(args[1]->ToString()); - const char * from_name = strdup(*name); - baton->name = from_name; - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} - -void GitReference::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - int result = git_reference_lookup( - &baton->out, - baton->repo, - baton->name - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitReference::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitReference::New((void *)baton->out); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->nameReference.Dispose(); - baton->callback.Dispose(); - delete baton->name; - delete baton; -} - Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -231,86 +151,6 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { delete baton; } -Handle GitReference::CreateSymbolic(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String name is required."))); - } - if (args.Length() == 2 || !args[2]->IsString()) { - return ThrowException(Exception::Error(String::New("String target is required."))); - } - if (args.Length() == 3 || !args[3]->IsInt32()) { - return ThrowException(Exception::Error(String::New("Number force is required."))); - } - - git_reference *out = NULL; - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - String::Utf8Value name(args[1]->ToString()); - const char * from_name = strdup(*name); - String::Utf8Value target(args[2]->ToString()); - const char * from_target = strdup(*target); - int from_force = (int) args[3]->ToInt32()->Value(); - - int result = git_reference_symbolic_create( - &out - , from_repo - , from_name - , from_target - , from_force - ); - delete from_name; - delete from_target; - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } - - Handle to; - to = GitReference::New((void *)out); - return scope.Close(to); -} - -Handle GitReference::Create(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String name is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid id is required."))); - } - if (args.Length() == 3 || !args[3]->IsInt32()) { - return ThrowException(Exception::Error(String::New("Number force is required."))); - } - - git_reference *out = NULL; - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - String::Utf8Value name(args[1]->ToString()); - const char * from_name = strdup(*name); - const git_oid * from_id = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - int from_force = (int) args[3]->ToInt32()->Value(); - - int result = git_reference_create( - &out - , from_repo - , from_name - , from_id - , from_force - ); - delete from_name; - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } - - Handle to; - to = GitReference::New((void *)out); - return scope.Close(to); -} - Handle GitReference::Oid(const Arguments& args) { HandleScope scope; diff --git a/src/remote.cc b/src/remote.cc index 779ba4380..1a252fe0a 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -12,15 +12,15 @@ using namespace v8; using namespace node; -Remote::Remote(git_remote *raw) { +GitRemote::GitRemote(git_remote *raw) { this->raw = raw; } -Remote::~Remote() { +GitRemote::~GitRemote() { git_remote_free(this->raw); } -void Remote::Initialize(Handle target) { +void GitRemote::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -28,9 +28,6 @@ void Remote::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Remote")); - NODE_SET_METHOD(tpl, "create", Create); - NODE_SET_METHOD(tpl, "createInmemory", CreateInmemory); - NODE_SET_METHOD(tpl, "load", Load); NODE_SET_PROTOTYPE_METHOD(tpl, "save", Save); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url); @@ -69,188 +66,36 @@ void Remote::Initialize(Handle target) { target->Set(String::NewSymbol("Remote"), constructor_template); } -Handle Remote::New(const Arguments& args) { +Handle GitRemote::New(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { return ThrowException(Exception::Error(String::New("git_remote is required."))); } - Remote* object = new Remote((git_remote *) External::Unwrap(args[0])); + GitRemote* object = new GitRemote((git_remote *) External::Unwrap(args[0])); object->Wrap(args.This()); return scope.Close(args.This()); } -Handle Remote::New(void *raw) { +Handle GitRemote::New(void *raw) { HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - return scope.Close(Remote::constructor_template->NewInstance(1, argv)); + return scope.Close(GitRemote::constructor_template->NewInstance(1, argv)); } -git_remote *Remote::GetValue() { +git_remote *GitRemote::GetValue() { return this->raw; } -Handle Remote::Create(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String name is required."))); - } - if (args.Length() == 2 || !args[2]->IsString()) { - return ThrowException(Exception::Error(String::New("String url is required."))); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - CreateBaton* baton = new CreateBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->nameReference = Persistent::New(args[1]); - String::Utf8Value name(args[1]->ToString()); - const char * from_name = strdup(*name); - baton->name = from_name; - baton->urlReference = Persistent::New(args[2]); - String::Utf8Value url(args[2]->ToString()); - const char * from_url = strdup(*url); - baton->url = from_url; - baton->callback = Persistent::New(Local::Cast(args[3])); - - uv_queue_work(uv_default_loop(), &baton->request, CreateWork, (uv_after_work_cb)CreateAfterWork); - - return Undefined(); -} - -void Remote::CreateWork(uv_work_t *req) { - CreateBaton *baton = static_cast(req->data); - int result = git_remote_create( - &baton->out, - baton->repo, - baton->name, - baton->url - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void Remote::CreateAfterWork(uv_work_t *req) { - HandleScope scope; - CreateBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = Remote::New((void *)baton->out); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->nameReference.Dispose(); - baton->urlReference.Dispose(); - baton->callback.Dispose(); - delete baton->name; - delete baton->url; - delete baton; -} - -Handle Remote::CreateInmemory(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String fetch is required."))); - } - if (args.Length() == 2 || !args[2]->IsString()) { - return ThrowException(Exception::Error(String::New("String url is required."))); - } - - git_remote *out = NULL; - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - String::Utf8Value fetch(args[1]->ToString()); - const char * from_fetch = strdup(*fetch); - String::Utf8Value url(args[2]->ToString()); - const char * from_url = strdup(*url); - - int result = git_remote_create_inmemory( - &out - , from_repo - , from_fetch - , from_url - ); - delete from_fetch; - delete from_url; - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } - - Handle to; - to = Remote::New((void *)out); - return scope.Close(to); -} - -Handle Remote::Load(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String name is required."))); - } - - git_remote *out = NULL; - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - String::Utf8Value name(args[1]->ToString()); - const char * from_name = strdup(*name); - - int result = git_remote_load( - &out - , from_repo - , from_name - ); - delete from_name; - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } - - Handle to; - to = Remote::New((void *)out); - return scope.Close(to); -} - -Handle Remote::Save(const Arguments& args) { +Handle GitRemote::Save(const Arguments& args) { HandleScope scope; int result = git_remote_save( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); @@ -259,12 +104,12 @@ Handle Remote::Save(const Arguments& args) { return Undefined(); } -Handle Remote::Name(const Arguments& args) { +Handle GitRemote::Name(const Arguments& args) { HandleScope scope; const char * result = git_remote_name( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); Handle to; @@ -272,12 +117,12 @@ Handle Remote::Name(const Arguments& args) { return scope.Close(to); } -Handle Remote::Url(const Arguments& args) { +Handle GitRemote::Url(const Arguments& args) { HandleScope scope; const char * result = git_remote_url( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); Handle to; @@ -285,12 +130,12 @@ Handle Remote::Url(const Arguments& args) { return scope.Close(to); } -Handle Remote::Pushurl(const Arguments& args) { +Handle GitRemote::Pushurl(const Arguments& args) { HandleScope scope; const char * result = git_remote_pushurl( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); Handle to; @@ -298,18 +143,20 @@ Handle Remote::Pushurl(const Arguments& args) { return scope.Close(to); } -Handle Remote::SetUrl(const Arguments& args) { +Handle GitRemote::SetUrl(const Arguments& args) { HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("const url is required."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); } - const char* from_url = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value url(args[0]->ToString()); + const char* from_url = strdup(*url); int result = git_remote_set_url( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_url ); + delete from_url; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -317,18 +164,20 @@ Handle Remote::SetUrl(const Arguments& args) { return Undefined(); } -Handle Remote::SetPushurl(const Arguments& args) { +Handle GitRemote::SetPushurl(const Arguments& args) { HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("const url is required."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); } - const char* from_url = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value url(args[0]->ToString()); + const char* from_url = strdup(*url); int result = git_remote_set_pushurl( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_url ); + delete from_url; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -336,7 +185,7 @@ Handle Remote::SetPushurl(const Arguments& args) { return Undefined(); } -Handle Remote::SetFetchspec(const Arguments& args) { +Handle GitRemote::SetFetchspec(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String spec is required."))); @@ -346,7 +195,7 @@ Handle Remote::SetFetchspec(const Arguments& args) { const char * from_spec = strdup(*spec); int result = git_remote_set_fetchspec( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_spec ); delete from_spec; @@ -357,12 +206,12 @@ Handle Remote::SetFetchspec(const Arguments& args) { return Undefined(); } -Handle Remote::Fetchspec(const Arguments& args) { +Handle GitRemote::Fetchspec(const Arguments& args) { HandleScope scope; const git_refspec * result = git_remote_fetchspec( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); Handle to; @@ -370,7 +219,7 @@ Handle Remote::Fetchspec(const Arguments& args) { return scope.Close(to); } -Handle Remote::SetPushspec(const Arguments& args) { +Handle GitRemote::SetPushspec(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String spec is required."))); @@ -380,7 +229,7 @@ Handle Remote::SetPushspec(const Arguments& args) { const char * from_spec = strdup(*spec); int result = git_remote_set_pushspec( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_spec ); delete from_spec; @@ -391,12 +240,12 @@ Handle Remote::SetPushspec(const Arguments& args) { return Undefined(); } -Handle Remote::Pushspec(const Arguments& args) { +Handle GitRemote::Pushspec(const Arguments& args) { HandleScope scope; const git_refspec * result = git_remote_pushspec( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); Handle to; @@ -404,7 +253,7 @@ Handle Remote::Pushspec(const Arguments& args) { return scope.Close(to); } -Handle Remote::Connect(const Arguments& args) { +Handle GitRemote::Connect(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Direction direction is required."))); @@ -413,7 +262,7 @@ Handle Remote::Connect(const Arguments& args) { git_direction from_direction = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_connect( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_direction ); if (result != GIT_OK) { @@ -423,7 +272,7 @@ Handle Remote::Connect(const Arguments& args) { return Undefined(); } -Handle Remote::Ls(const Arguments& args) { +Handle GitRemote::Ls(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("HeadlistCb list_cb is required."))); @@ -436,7 +285,7 @@ Handle Remote::Ls(const Arguments& args) { void * from_payload = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); int result = git_remote_ls( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_list_cb , from_payload ); @@ -447,7 +296,7 @@ Handle Remote::Ls(const Arguments& args) { return Undefined(); } -Handle Remote::Download(const Arguments& args) { +Handle GitRemote::Download(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("TransferProgressCallback progress_cb is required."))); @@ -460,7 +309,7 @@ Handle Remote::Download(const Arguments& args) { void * from_payload = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); int result = git_remote_download( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_progress_cb , from_payload ); @@ -471,12 +320,12 @@ Handle Remote::Download(const Arguments& args) { return Undefined(); } -Handle Remote::Connected(const Arguments& args) { +Handle GitRemote::Connected(const Arguments& args) { HandleScope scope; int result = git_remote_connected( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); @@ -485,35 +334,35 @@ Handle Remote::Connected(const Arguments& args) { return Undefined(); } -Handle Remote::Stop(const Arguments& args) { +Handle GitRemote::Stop(const Arguments& args) { HandleScope scope; git_remote_stop( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); return Undefined(); } -Handle Remote::Disconnect(const Arguments& args) { +Handle GitRemote::Disconnect(const Arguments& args) { HandleScope scope; git_remote_disconnect( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); return Undefined(); } -Handle Remote::Free(const Arguments& args) { +Handle GitRemote::Free(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Remote remote is required."))); } - git_remote * from_remote = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_remote * from_remote = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); git_remote_free( from_remote @@ -522,12 +371,12 @@ Handle Remote::Free(const Arguments& args) { return Undefined(); } -Handle Remote::UpdateTips(const Arguments& args) { +Handle GitRemote::UpdateTips(const Arguments& args) { HandleScope scope; int result = git_remote_update_tips( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); @@ -536,7 +385,7 @@ Handle Remote::UpdateTips(const Arguments& args) { return Undefined(); } -Handle Remote::ValidUrl(const Arguments& args) { +Handle GitRemote::ValidUrl(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String url is required."))); @@ -556,17 +405,19 @@ Handle Remote::ValidUrl(const Arguments& args) { return Undefined(); } -Handle Remote::SupportedUrl(const Arguments& args) { +Handle GitRemote::SupportedUrl(const Arguments& args) { HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("const url is required."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); } - const char* from_url = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + String::Utf8Value url(args[0]->ToString()); + const char* from_url = strdup(*url); int result = git_remote_supported_url( from_url ); + delete from_url; if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -574,7 +425,7 @@ Handle Remote::SupportedUrl(const Arguments& args) { return Undefined(); } -Handle Remote::List(const Arguments& args) { +Handle GitRemote::List(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Repository repo is required."))); @@ -596,7 +447,7 @@ Handle Remote::List(const Arguments& args) { return scope.Close(to); } -Handle Remote::CheckCert(const Arguments& args) { +Handle GitRemote::CheckCert(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number check is required."))); @@ -605,14 +456,14 @@ Handle Remote::CheckCert(const Arguments& args) { int from_check = (int) args[0]->ToInt32()->Value(); git_remote_check_cert( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_check ); return Undefined(); } -Handle Remote::SetCredAcquireCb(const Arguments& args) { +Handle GitRemote::SetCredAcquireCb(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("CredAcquireCb cred_acquire_cb is required."))); @@ -625,7 +476,7 @@ Handle Remote::SetCredAcquireCb(const Arguments& args) { void * from_payload = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); git_remote_set_cred_acquire_cb( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_cred_acquire_cb , from_payload ); @@ -633,7 +484,7 @@ Handle Remote::SetCredAcquireCb(const Arguments& args) { return Undefined(); } -Handle Remote::SetTransport(const Arguments& args) { +Handle GitRemote::SetTransport(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Transport transport is required."))); @@ -642,7 +493,7 @@ Handle Remote::SetTransport(const Arguments& args) { git_transport * from_transport = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_set_transport( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_transport ); if (result != GIT_OK) { @@ -652,7 +503,7 @@ Handle Remote::SetTransport(const Arguments& args) { return Undefined(); } -Handle Remote::SetCallbacks(const Arguments& args) { +Handle GitRemote::SetCallbacks(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("RemoteCallbacks callbacks is required."))); @@ -661,7 +512,7 @@ Handle Remote::SetCallbacks(const Arguments& args) { git_remote_callbacks * from_callbacks = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); int result = git_remote_set_callbacks( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_callbacks ); if (result != GIT_OK) { @@ -671,12 +522,12 @@ Handle Remote::SetCallbacks(const Arguments& args) { return Undefined(); } -Handle Remote::Stats(const Arguments& args) { +Handle GitRemote::Stats(const Arguments& args) { HandleScope scope; const git_transfer_progress * result = git_remote_stats( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); Handle to; @@ -684,7 +535,7 @@ Handle Remote::Stats(const Arguments& args) { return scope.Close(to); } -Handle Remote::Autotag(const Arguments& args) { +Handle GitRemote::Autotag(const Arguments& args) { HandleScope scope; @@ -696,7 +547,7 @@ Handle Remote::Autotag(const Arguments& args) { return scope.Close(to); } -Handle Remote::SetAutotag(const Arguments& args) { +Handle GitRemote::SetAutotag(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("RemoteAutotagOptionT value is required."))); @@ -705,14 +556,14 @@ Handle Remote::SetAutotag(const Arguments& args) { git_remote_autotag_option_t from_value = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); git_remote_set_autotag( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_value ); return Undefined(); } -Handle Remote::Rename(const Arguments& args) { +Handle GitRemote::Rename(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String new_name is required."))); @@ -730,7 +581,7 @@ Handle Remote::Rename(const Arguments& args) { void * from_payload = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); int result = git_remote_rename( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_new_name , from_callback , from_payload @@ -743,12 +594,12 @@ Handle Remote::Rename(const Arguments& args) { return Undefined(); } -Handle Remote::UpdateFetchhead(const Arguments& args) { +Handle GitRemote::UpdateFetchhead(const Arguments& args) { HandleScope scope; int result = git_remote_update_fetchhead( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); @@ -757,7 +608,7 @@ Handle Remote::UpdateFetchhead(const Arguments& args) { return Undefined(); } -Handle Remote::SetUpdateFetchhead(const Arguments& args) { +Handle GitRemote::SetUpdateFetchhead(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { return ThrowException(Exception::Error(String::New("Number value is required."))); @@ -766,14 +617,14 @@ Handle Remote::SetUpdateFetchhead(const Arguments& args) { int from_value = (int) args[0]->ToInt32()->Value(); git_remote_set_update_fetchhead( - ObjectWrap::Unwrap(args.This())->GetValue() + ObjectWrap::Unwrap(args.This())->GetValue() , from_value ); return Undefined(); } -Handle Remote::IsValidName(const Arguments& args) { +Handle GitRemote::IsValidName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String remote_name is required."))); @@ -793,4 +644,4 @@ Handle Remote::IsValidName(const Arguments& args) { return Undefined(); } -Persistent Remote::constructor_template; +Persistent GitRemote::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index d422264da..6414c0e94 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -8,6 +8,17 @@ #include "git2.h" #include "../include/repo.h" +#include "../include/oid.h" +#include "../include/commit.h" +#include "../include/blob.h" +#include "../include/object.h" +#include "../include/reference.h" +#include "../include/submodule.h" +#include "../include/refdb.h" +#include "../include/revwalk.h" +#include "../include/tag.h" +#include "../include/signature.h" +#include "../include/tree.h" using namespace v8; using namespace node; @@ -32,6 +43,20 @@ void GitRepo::Initialize(Handle target) { NODE_SET_METHOD(tpl, "init", Init); NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); NODE_SET_PROTOTYPE_METHOD(tpl, "workdir", Workdir); + NODE_SET_PROTOTYPE_METHOD(tpl, "getBlob", GetBlob); + NODE_SET_PROTOTYPE_METHOD(tpl, "getCommit", GetCommit); + NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); + NODE_SET_PROTOTYPE_METHOD(tpl, "getReference", GetReference); + NODE_SET_PROTOTYPE_METHOD(tpl, "createSymbolicReference", CreateSymbolicReference); + NODE_SET_PROTOTYPE_METHOD(tpl, "createReference", CreateReference); + NODE_SET_PROTOTYPE_METHOD(tpl, "createRevWalk", CreateRevWalk); + NODE_SET_PROTOTYPE_METHOD(tpl, "getSubmodule", GetSubmodule); + NODE_SET_PROTOTYPE_METHOD(tpl, "addSubmodule", AddSubmodule); + NODE_SET_PROTOTYPE_METHOD(tpl, "getTag", GetTag); + NODE_SET_PROTOTYPE_METHOD(tpl, "createTag", CreateTag); + NODE_SET_METHOD(tpl, "createLightweightTag", CreateLightweightTag); + NODE_SET_PROTOTYPE_METHOD(tpl, "getTree", GetTree); + NODE_SET_METHOD(tpl, "reloadSubmodules", ReloadSubmodules); constructor_template = Persistent::New(tpl->GetFunction()); @@ -234,4 +259,849 @@ Handle GitRepo::Workdir(const Arguments& args) { return scope.Close(to); } +Handle GitRepo::GetBlob(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetBlobBaton* baton = new GetBlobBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetBlobWork, (uv_after_work_cb)GetBlobAfterWork); + + return Undefined(); +} + +void GitRepo::GetBlobWork(uv_work_t *req) { + GetBlobBaton *baton = static_cast(req->data); + int result = git_blob_lookup( + &baton->blob, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetBlobAfterWork(uv_work_t *req) { + HandleScope scope; + GetBlobBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitBlob::New((void *)baton->blob); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRepo::GetCommit(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetCommitBaton* baton = new GetCommitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetCommitWork, (uv_after_work_cb)GetCommitAfterWork); + + return Undefined(); +} + +void GitRepo::GetCommitWork(uv_work_t *req) { + GetCommitBaton *baton = static_cast(req->data); + int result = git_commit_lookup( + &baton->commit, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetCommitAfterWork(uv_work_t *req) { + HandleScope scope; + GetCommitBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitCommit::New((void *)baton->commit); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRepo::GetObject(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetObjectBaton* baton = new GetObjectBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->typeReference = Persistent::New(args[1]); + git_otype from_type = (git_otype) args[1]->ToInt32()->Value(); + baton->type = from_type; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, GetObjectWork, (uv_after_work_cb)GetObjectAfterWork); + + return Undefined(); +} + +void GitRepo::GetObjectWork(uv_work_t *req) { + GetObjectBaton *baton = static_cast(req->data); + int result = git_object_lookup( + &baton->object, + baton->repo, + baton->id, + baton->type + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetObjectAfterWork(uv_work_t *req) { + HandleScope scope; + GetObjectBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitObject::New((void *)baton->object); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->typeReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRepo::GetReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetReferenceBaton* baton = new GetReferenceBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->nameReference = Persistent::New(args[0]); + String::Utf8Value name(args[0]->ToString()); + const char * from_name = strdup(*name); + baton->name = from_name; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetReferenceWork, (uv_after_work_cb)GetReferenceAfterWork); + + return Undefined(); +} + +void GitRepo::GetReferenceWork(uv_work_t *req) { + GetReferenceBaton *baton = static_cast(req->data); + int result = git_reference_lookup( + &baton->out, + baton->repo, + baton->name + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetReferenceAfterWork(uv_work_t *req) { + HandleScope scope; + GetReferenceBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitReference::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); + baton->callback.Dispose(); + delete baton->name; + delete baton; +} + +Handle GitRepo::CreateSymbolicReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String target is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + String::Utf8Value name(args[0]->ToString()); + const char * from_name = strdup(*name); + String::Utf8Value target(args[1]->ToString()); + const char * from_target = strdup(*target); + int from_force = (int) args[2]->ToInt32()->Value(); + + int result = git_reference_symbolic_create( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + , from_target + , from_force + ); + delete from_name; + delete from_target; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); +} + +Handle GitRepo::CreateReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + String::Utf8Value name(args[0]->ToString()); + const char * from_name = strdup(*name); + const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + int from_force = (int) args[2]->ToInt32()->Value(); + + int result = git_reference_create( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + , from_id + , from_force + ); + delete from_name; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitReference::New((void *)out); + return scope.Close(to); +} + +Handle GitRepo::CreateRevWalk(const Arguments& args) { + HandleScope scope; + + git_revwalk *out = NULL; + + int result = git_revwalk_new( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitRevWalk::New((void *)out); + return scope.Close(to); +} + +Handle GitRepo::GetSubmodule(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + git_submodule *submodule = NULL; + String::Utf8Value name(args[0]->ToString()); + const char * from_name = strdup(*name); + + int result = git_submodule_lookup( + &submodule + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + ); + delete from_name; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitSubmodule::New((void *)submodule); + return scope.Close(to); +} + +Handle GitRepo::AddSubmodule(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number use_gitlink is required."))); + } + + git_submodule *submodule = NULL; + String::Utf8Value url(args[0]->ToString()); + const char * from_url = strdup(*url); + String::Utf8Value path(args[1]->ToString()); + const char * from_path = strdup(*path); + int from_use_gitlink = (int) args[2]->ToInt32()->Value(); + + int result = git_submodule_add_setup( + &submodule + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_url + , from_path + , from_use_gitlink + ); + delete from_url; + delete from_path; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitSubmodule::New((void *)submodule); + return scope.Close(to); +} + +Handle GitRepo::GetTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetTagBaton* baton = new GetTagBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetTagWork, (uv_after_work_cb)GetTagAfterWork); + + return Undefined(); +} + +void GitRepo::GetTagWork(uv_work_t *req) { + GetTagBaton *baton = static_cast(req->data); + int result = git_tag_lookup( + &baton->out, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetTagAfterWork(uv_work_t *req) { + HandleScope scope; + GetTagBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitTag::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRepo::CreateTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Object target is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature tagger is required."))); + } + if (args.Length() == 3 || !args[3]->IsString()) { + return ThrowException(Exception::Error(String::New("String message is required."))); + } + if (args.Length() == 4 || !args[4]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + if (args.Length() == 5 || !args[5]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateTagBaton* baton = new CreateTagBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->tag_nameReference = Persistent::New(args[0]); + String::Utf8Value tag_name(args[0]->ToString()); + const char * from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->targetReference = Persistent::New(args[1]); + const git_object * from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->target = from_target; + baton->taggerReference = Persistent::New(args[2]); + const git_signature * from_tagger = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->tagger = from_tagger; + baton->messageReference = Persistent::New(args[3]); + String::Utf8Value message(args[3]->ToString()); + const char * from_message = strdup(*message); + baton->message = from_message; + baton->forceReference = Persistent::New(args[4]); + int from_force = (int) args[4]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[5])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateTagWork, (uv_after_work_cb)CreateTagAfterWork); + + return Undefined(); +} + +void GitRepo::CreateTagWork(uv_work_t *req) { + CreateTagBaton *baton = static_cast(req->data); + int result = git_tag_create( + baton->oid, + baton->repo, + baton->tag_name, + baton->target, + baton->tagger, + baton->message, + baton->force + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateTagAfterWork(uv_work_t *req) { + HandleScope scope; + CreateTagBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitOid::New((void *)baton->oid); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->targetReference.Dispose(); + baton->taggerReference.Dispose(); + baton->messageReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + delete baton->tag_name; + delete baton->message; + delete baton; +} + +Handle GitRepo::CreateLightweightTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Object target is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateLightweightTagBaton* baton = new CreateLightweightTagBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->tag_nameReference = Persistent::New(args[0]); + String::Utf8Value tag_name(args[0]->ToString()); + const char * from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->targetReference = Persistent::New(args[1]); + const git_object * from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->target = from_target; + baton->forceReference = Persistent::New(args[2]); + int from_force = (int) args[2]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateLightweightTagWork, (uv_after_work_cb)CreateLightweightTagAfterWork); + + return Undefined(); +} + +void GitRepo::CreateLightweightTagWork(uv_work_t *req) { + CreateLightweightTagBaton *baton = static_cast(req->data); + int result = git_tag_create_lightweight( + baton->oid, + baton->repo, + baton->tag_name, + baton->target, + baton->force + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { + HandleScope scope; + CreateLightweightTagBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitOid::New((void *)baton->oid); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->targetReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + delete baton->tag_name; + delete baton; +} + +Handle GitRepo::GetTree(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetTreeBaton* baton = new GetTreeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetTreeWork, (uv_after_work_cb)GetTreeAfterWork); + + return Undefined(); +} + +void GitRepo::GetTreeWork(uv_work_t *req) { + GetTreeBaton *baton = static_cast(req->data); + int result = git_tree_lookup( + &baton->out, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetTreeAfterWork(uv_work_t *req) { + HandleScope scope; + GetTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitTree::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitRepo::ReloadSubmodules(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReloadSubmodulesBaton* baton = new ReloadSubmodulesBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ReloadSubmodulesWork, (uv_after_work_cb)ReloadSubmodulesAfterWork); + + return Undefined(); +} + +void GitRepo::ReloadSubmodulesWork(uv_work_t *req) { + ReloadSubmodulesBaton *baton = static_cast(req->data); + int result = git_submodule_reload_all( + baton->repo + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::ReloadSubmodulesAfterWork(uv_work_t *req) { + HandleScope scope; + ReloadSubmodulesBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + Persistent GitRepo::constructor_template; diff --git a/src/revwalk.cc b/src/revwalk.cc index 013584669..c5c2e4c2b 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -30,7 +30,6 @@ void GitRevWalk::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("RevWalk")); - NODE_SET_METHOD(tpl, "make", Make); NODE_SET_PROTOTYPE_METHOD(tpl, "reset", Reset); NODE_SET_PROTOTYPE_METHOD(tpl, "push", Push); NODE_SET_PROTOTYPE_METHOD(tpl, "pushGlob", PushGlob); @@ -72,28 +71,6 @@ git_revwalk *GitRevWalk::GetValue() { } -Handle GitRevWalk::Make(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - - git_revwalk *out = NULL; - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_revwalk_new( - &out - , from_repo - ); - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } - - Handle to; - to = GitRevWalk::New((void *)out); - return scope.Close(to); -} - Handle GitRevWalk::Reset(const Arguments& args) { HandleScope scope; diff --git a/src/submodule.cc b/src/submodule.cc new file mode 100644 index 000000000..165d14f3b --- /dev/null +++ b/src/submodule.cc @@ -0,0 +1,676 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/submodule.h" +#include "../include/oid.h" +#include "../include/repo.h" + +using namespace v8; +using namespace node; + +GitSubmodule::GitSubmodule(git_submodule *raw) { + this->raw = raw; +} + +GitSubmodule::~GitSubmodule() { +} + +void GitSubmodule::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Submodule")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "addFinalize", AddFinalize); + NODE_SET_PROTOTYPE_METHOD(tpl, "addToIndex", AddToIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "save", Save); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url); + NODE_SET_PROTOTYPE_METHOD(tpl, "setUrl", SetUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "indexId", IndexId); + NODE_SET_PROTOTYPE_METHOD(tpl, "headId", HeadId); + NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init); + NODE_SET_PROTOTYPE_METHOD(tpl, "sync", Sync); + NODE_SET_PROTOTYPE_METHOD(tpl, "open", Open); + NODE_SET_PROTOTYPE_METHOD(tpl, "reload", Reload); + NODE_SET_PROTOTYPE_METHOD(tpl, "status", Status); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Submodule"), constructor_template); +} + +Handle GitSubmodule::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_submodule is required."))); + } + + GitSubmodule* object = new GitSubmodule((git_submodule *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitSubmodule::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitSubmodule::constructor_template->NewInstance(1, argv)); +} + +git_submodule *GitSubmodule::GetValue() { + return this->raw; +} + + +Handle GitSubmodule::AddFinalize(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddFinalizeBaton* baton = new AddFinalizeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, AddFinalizeWork, (uv_after_work_cb)AddFinalizeAfterWork); + + return Undefined(); +} + +void GitSubmodule::AddFinalizeWork(uv_work_t *req) { + AddFinalizeBaton *baton = static_cast(req->data); + int result = git_submodule_add_finalize( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::AddFinalizeAfterWork(uv_work_t *req) { + HandleScope scope; + AddFinalizeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::AddToIndex(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number write_index is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddToIndexBaton* baton = new AddToIndexBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->write_indexReference = Persistent::New(args[0]); + int from_write_index = (int) args[0]->ToInt32()->Value(); + baton->write_index = from_write_index; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, AddToIndexWork, (uv_after_work_cb)AddToIndexAfterWork); + + return Undefined(); +} + +void GitSubmodule::AddToIndexWork(uv_work_t *req) { + AddToIndexBaton *baton = static_cast(req->data); + int result = git_submodule_add_to_index( + baton->submodule, + baton->write_index + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::AddToIndexAfterWork(uv_work_t *req) { + HandleScope scope; + AddToIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->write_indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::Save(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + SaveBaton* baton = new SaveBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, SaveWork, (uv_after_work_cb)SaveAfterWork); + + return Undefined(); +} + +void GitSubmodule::SaveWork(uv_work_t *req) { + SaveBaton *baton = static_cast(req->data); + int result = git_submodule_save( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::SaveAfterWork(uv_work_t *req) { + HandleScope scope; + SaveBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_submodule_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +Handle GitSubmodule::Path(const Arguments& args) { + HandleScope scope; + + + const char * result = git_submodule_path( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +Handle GitSubmodule::Url(const Arguments& args) { + HandleScope scope; + + + const char * result = git_submodule_url( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +Handle GitSubmodule::SetUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + String::Utf8Value url(args[0]->ToString()); + const char * from_url = strdup(*url); + + int result = git_submodule_set_url( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_url + ); + delete from_url; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle GitSubmodule::IndexId(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_submodule_index_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); +} + +Handle GitSubmodule::HeadId(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_submodule_head_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); +} + +Handle GitSubmodule::Init(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number overwrite is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + InitBaton* baton = new InitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->overwriteReference = Persistent::New(args[0]); + int from_overwrite = (int) args[0]->ToInt32()->Value(); + baton->overwrite = from_overwrite; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); + + return Undefined(); +} + +void GitSubmodule::InitWork(uv_work_t *req) { + InitBaton *baton = static_cast(req->data); + int result = git_submodule_init( + baton->submodule, + baton->overwrite + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::InitAfterWork(uv_work_t *req) { + HandleScope scope; + InitBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->overwriteReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::Sync(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + SyncBaton* baton = new SyncBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, SyncWork, (uv_after_work_cb)SyncAfterWork); + + return Undefined(); +} + +void GitSubmodule::SyncWork(uv_work_t *req) { + SyncBaton *baton = static_cast(req->data); + int result = git_submodule_sync( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::SyncAfterWork(uv_work_t *req) { + HandleScope scope; + SyncBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::Open(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + OpenBaton* baton = new OpenBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); + + return Undefined(); +} + +void GitSubmodule::OpenWork(uv_work_t *req) { + OpenBaton *baton = static_cast(req->data); + int result = git_submodule_open( + &baton->repo, + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::OpenAfterWork(uv_work_t *req) { + HandleScope scope; + OpenBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitRepo::New((void *)baton->repo); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::Reload(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReloadBaton* baton = new ReloadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ReloadWork, (uv_after_work_cb)ReloadAfterWork); + + return Undefined(); +} + +void GitSubmodule::ReloadWork(uv_work_t *req) { + ReloadBaton *baton = static_cast(req->data); + int result = git_submodule_reload( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::ReloadAfterWork(uv_work_t *req) { + HandleScope scope; + ReloadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitSubmodule::Status(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number status is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + StatusBaton* baton = new StatusBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->statusReference = Persistent::New(args[0]); + unsigned int * from_status = (unsigned int *) args[0]->ToInt32()->Value(); + baton->status = from_status; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, StatusWork, (uv_after_work_cb)StatusAfterWork); + + return Undefined(); +} + +void GitSubmodule::StatusWork(uv_work_t *req) { + StatusBaton *baton = static_cast(req->data); + int result = git_submodule_status( + baton->status, + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::StatusAfterWork(uv_work_t *req) { + HandleScope scope; + StatusBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->statusReference.Dispose(); + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Persistent GitSubmodule::constructor_template; diff --git a/src/tag.cc b/src/tag.cc index acfe6f935..617f31b21 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -32,7 +32,6 @@ void GitTag::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Tag")); - NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "target", Target); NODE_SET_PROTOTYPE_METHOD(tpl, "targetId", TargetId); @@ -40,8 +39,6 @@ void GitTag::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "tagger", Tagger); NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); - NODE_SET_METHOD(tpl, "create", Create); - NODE_SET_METHOD(tpl, "createLightweight", CreateLightweight); NODE_SET_METHOD(tpl, "delete", Delete); NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); @@ -74,81 +71,6 @@ git_tag *GitTag::GetValue() { } -Handle GitTag::Lookup(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid id is required."))); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->idReference = Persistent::New(args[1]); - const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->id = from_id; - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} - -void GitTag::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - int result = git_tag_lookup( - &baton->out, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitTag::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitTag::New((void *)baton->out); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->idReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitTag::Oid(const Arguments& args) { HandleScope scope; @@ -290,210 +212,6 @@ Handle GitTag::Message(const Arguments& args) { return scope.Close(to); } -Handle GitTag::Create(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String tag_name is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("Object target is required."))); - } - if (args.Length() == 3 || !args[3]->IsObject()) { - return ThrowException(Exception::Error(String::New("Signature tagger is required."))); - } - if (args.Length() == 4 || !args[4]->IsString()) { - return ThrowException(Exception::Error(String::New("String message is required."))); - } - if (args.Length() == 5 || !args[5]->IsInt32()) { - return ThrowException(Exception::Error(String::New("Number force is required."))); - } - - if (args.Length() == 6 || !args[6]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - CreateBaton* baton = new CreateBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->tag_nameReference = Persistent::New(args[1]); - String::Utf8Value tag_name(args[1]->ToString()); - const char * from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - baton->targetReference = Persistent::New(args[2]); - const git_object * from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->target = from_target; - baton->taggerReference = Persistent::New(args[3]); - const git_signature * from_tagger = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); - baton->tagger = from_tagger; - baton->messageReference = Persistent::New(args[4]); - String::Utf8Value message(args[4]->ToString()); - const char * from_message = strdup(*message); - baton->message = from_message; - baton->forceReference = Persistent::New(args[5]); - int from_force = (int) args[5]->ToInt32()->Value(); - baton->force = from_force; - baton->callback = Persistent::New(Local::Cast(args[6])); - - uv_queue_work(uv_default_loop(), &baton->request, CreateWork, (uv_after_work_cb)CreateAfterWork); - - return Undefined(); -} - -void GitTag::CreateWork(uv_work_t *req) { - CreateBaton *baton = static_cast(req->data); - int result = git_tag_create( - baton->oid, - baton->repo, - baton->tag_name, - baton->target, - baton->tagger, - baton->message, - baton->force - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitTag::CreateAfterWork(uv_work_t *req) { - HandleScope scope; - CreateBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitOid::New((void *)baton->oid); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->tag_nameReference.Dispose(); - baton->targetReference.Dispose(); - baton->taggerReference.Dispose(); - baton->messageReference.Dispose(); - baton->forceReference.Dispose(); - baton->callback.Dispose(); - delete baton->tag_name; - delete baton->message; - delete baton; -} - -Handle GitTag::CreateLightweight(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String tag_name is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("Object target is required."))); - } - if (args.Length() == 3 || !args[3]->IsInt32()) { - return ThrowException(Exception::Error(String::New("Number force is required."))); - } - - if (args.Length() == 4 || !args[4]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - CreateLightweightBaton* baton = new CreateLightweightBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->tag_nameReference = Persistent::New(args[1]); - String::Utf8Value tag_name(args[1]->ToString()); - const char * from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - baton->targetReference = Persistent::New(args[2]); - const git_object * from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->target = from_target; - baton->forceReference = Persistent::New(args[3]); - int from_force = (int) args[3]->ToInt32()->Value(); - baton->force = from_force; - baton->callback = Persistent::New(Local::Cast(args[4])); - - uv_queue_work(uv_default_loop(), &baton->request, CreateLightweightWork, (uv_after_work_cb)CreateLightweightAfterWork); - - return Undefined(); -} - -void GitTag::CreateLightweightWork(uv_work_t *req) { - CreateLightweightBaton *baton = static_cast(req->data); - int result = git_tag_create_lightweight( - baton->oid, - baton->repo, - baton->tag_name, - baton->target, - baton->force - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitTag::CreateLightweightAfterWork(uv_work_t *req) { - HandleScope scope; - CreateLightweightBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitOid::New((void *)baton->oid); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->tag_nameReference.Dispose(); - baton->targetReference.Dispose(); - baton->forceReference.Dispose(); - baton->callback.Dispose(); - delete baton->tag_name; - delete baton; -} - Handle GitTag::Delete(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/src/tree.cc b/src/tree.cc index 49558eda1..b32ee7bd5 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -31,7 +31,6 @@ void GitTree::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Tree")); - NODE_SET_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByName", EntryByName); @@ -68,81 +67,6 @@ git_tree *GitTree::GetValue() { } -Handle GitTree::Lookup(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid id is required."))); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->idReference = Persistent::New(args[1]); - const git_oid * from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->id = from_id; - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} - -void GitTree::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - int result = git_tree_lookup( - &baton->out, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitTree::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitTree::New((void *)baton->out); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->idReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitTree::Oid(const Arguments& args) { HandleScope scope; diff --git a/test/raw-blob.js b/test/raw-blob.js index ccd4ea282..f7dee10d7 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -34,26 +34,13 @@ exports.constructor = function(test){ // Blob::Lookup exports.lookup = function(test) { - test.expect(5); + test.expect(1); var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); git.Repo.open('../.git', function(error, repo) { - // Test for function - helper.testFunction(test.equals, git.Blob.lookup, 'Blob::Lookup'); - - // Test repo argument existence - helper.testException(test.ok, function() { - git.Blob.lookup(); - }, 'Throw an exception if no repo Object'); - - // Test Oid argument existence - helper.testException(test.ok, function() { - git.Blob.lookup(repo); - }, 'Throw an exception if no oid Object'); - // Test Callback argument existence helper.testException(test.ok, function() { - git.Blob.lookup(repo, testOid); + repo.getBlob(testOid); }, 'Throw an exception if no callback Object'); test.done(); @@ -66,7 +53,7 @@ exports.rawContent = function(test) { var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'); test.expect(3); git.Repo.open(path.resolve('../.git'), function(err, repo) { - git.Blob.lookup(repo, testOid, function(err, blob) { + repo.getBlob(testOid, function(err, blob) { // Test for function helper.testFunction(test.equals, blob.content, 'Blob::RawContent'); test.equals(blob.content().toBuffer(7).toString(), "@import"); diff --git a/test/raw-commit.js b/test/raw-commit.js index 4e1d4cf32..f3f8dc21e 100644 --- a/test/raw-commit.js +++ b/test/raw-commit.js @@ -24,35 +24,22 @@ var helper = { * Commit::Lookup */ exports.lookup = function(test) { - test.expect(7); + test.expect(3); var testOid = git.Oid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762'); - // Test for function - helper.testFunction(test.equals, git.Commit.lookup, 'Commit::Lookup'); - git.Repo.open('../.git', function(error, repo) { - // Test repo argument existence - helper.testException(test.ok, function() { - git.Commit.lookup(); - }, 'Throw an exception if no repo'); - // Test oid argument existence helper.testException(test.ok, function() { - git.Commit.lookup(repo); + repo.getCommit(); }, 'Throw an exception if no oid'); - // Test callback argument existence - helper.testException(test.ok, function() { - git.Commit.lookup(repo); - }, 'Throw an exception if no callback'); - // Test that all arguments result correctly helper.testException(test.ifError, function() { - git.Commit.lookup(repo, testOid, function() {}); + repo.getCommit(testOid, function() {}); }, 'No exception is thrown with proper arguments'); // Test valid commit - git.Commit.lookup(repo, testOid, function(err) { + repo.getCommit(testOid, function(err) { test.equal(null, err, 'Valid commit'); test.done(); }); diff --git a/test/raw-reference.js b/test/raw-reference.js index 2d21ad4b3..29a36f2bc 100644 --- a/test/raw-reference.js +++ b/test/raw-reference.js @@ -35,25 +35,17 @@ exports.constructor = function(test){ // Ref::Lookup exports.lookup = function(test) { - test.expect(5); - - // Test for function - helper.testFunction(test.equals, git.Reference.lookup, 'Ref::Lookup'); - - // Test repo argument existence - helper.testException(test.ok, function() { - git.Reference.lookup(); - }, 'Throw an exception if no repo'); + test.expect(2); git.Repo.open('../.git', function(error, repo) { // Test name argument existence helper.testException(test.ok, function() { - git.Reference.lookup(repo); + repo.getReference(); }, 'Throw an exception if no name'); // Test callback argument existence helper.testException(test.ok, function() { - git.Reference.lookup(repo, 'refs/heads/master'); + repo.getReference('refs/heads/master'); }, 'Throw an exception if no callback'); // Cleanup, remove test repo directory - if it exists diff --git a/v0.18.0.json b/v0.18.0.json index d115b1d14..6c32327d7 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -217,81 +217,6 @@ "cType": "git_blob", "freeFunctionName": "git_blob_free", "functions": [ - { - "cFunctionName": "git_blob_lookup", - "args": [ - { - "name": "blob", - "cType": "git_blob **", - "cppClassName": "GitBlob", - "jsClassName": "Blob", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_blob_lookup_prefix", - "args": [ - { - "name": "blob", - "cType": "git_blob **", - "cppClassName": "GitBlob", - "jsClassName": "Blob", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - }, - { - "name": "len", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" - } - ], - "ignore": true, - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookupPrefix", - "cppFunctionName": "LookupPrefix", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_blob_free", "args": [ @@ -1093,40 +1018,6 @@ "cType": "git_commit", "freeFunctionName": "git_commit_free", "functions": [ - { - "cFunctionName": "git_commit_lookup", - "args": [ - { - "name": "commit", - "cType": "git_commit **", - "cppClassName": "GitCommit", - "jsClassName": "Commit", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_commit_lookup_prefix", "args": [ @@ -1507,83 +1398,6 @@ "isErrorCode": true } }, - { - "cFunctionName": "git_commit_create", - "args": [ - { - "name": "id", - "cType": "git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "update_ref", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "author", - "cType": "const git_signature *", - "cppClassName": "GitSignature", - "jsClassName": "Signature" - }, - { - "name": "committer", - "cType": "const git_signature *", - "cppClassName": "GitSignature", - "jsClassName": "Signature" - }, - { - "name": "message_encoding", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "message", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "tree", - "cType": "const git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "parent_count", - "cType": "int", - "cppClassName": "Int32", - "jsClassName": "Number" - }, - { - "name": "parents", - "cType": "const git_commit **", - "cppClassName": "Array", - "jsClassName": "Array" - } - ], - "ignore": true, - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "create", - "cppFunctionName": "Create", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_commit_create_v", "args": [ @@ -5792,137 +5606,50 @@ "freeFunctionName": "git_object_free", "functions": [ { - "cFunctionName": "git_object_lookup", + "cFunctionName": "git_object_id", "args": [ { - "name": "object", - "cType": "git_object **", + "name": "obj", + "cType": "const git_object *", "cppClassName": "GitObject", "jsClassName": "Object", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - }, - { - "name": "type", - "cType": "git_otype", - "cppClassName": "Int32", - "jsClassName": "Number" + "isSelf": true } ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cType": "const git_oid *", + "cppClassName": "GitOid" } }, { - "cFunctionName": "git_object_lookup_prefix", + "cFunctionName": "git_object_type", "args": [ { - "name": "object_out", - "cType": "git_object **", + "name": "obj", + "cType": "const git_object *", "cppClassName": "GitObject", "jsClassName": "Object", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - }, - { - "name": "len", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" - }, - { - "name": "type", - "cType": "git_otype", - "cppClassName": "Number", - "jsClassName": "Number" - } - ], - "ignore": true, - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookupPrefix", - "cppFunctionName": "LookupPrefix", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_object_id", - "args": [ - { - "name": "obj", - "cType": "const git_object *", - "cppClassName": "GitObject", - "jsClassName": "Object", - "isSelf": true - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": true, - "jsFunctionName": "oid", - "cppFunctionName": "Oid", - "return": { - "cType": "const git_oid *", - "cppClassName": "GitOid" - } - }, - { - "cFunctionName": "git_object_type", - "args": [ - { - "name": "obj", - "cType": "const git_object *", - "cppClassName": "GitObject", - "jsClassName": "Object", - "isSelf": true - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": true, - "jsFunctionName": "type", - "cppFunctionName": "Type", - "return": { - "cType": "git_otype", - "cppClassName": "Number" - } - }, - { - "cFunctionName": "git_object_owner", - "args": [ + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_otype", + "cppClassName": "Number" + } + }, + { + "cFunctionName": "git_object_owner", + "args": [ { "name": "obj", "cType": "const git_object *", @@ -6976,8 +6703,8 @@ { "name": "raw", "cType": "const unsigned char *", - "cppClassName": "const", - "jsClassName": "const" + "cppClassName": "String", + "jsClassName": "String" } ], "ignore": true, @@ -7616,7 +7343,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote" } ], @@ -7812,11 +7539,9 @@ }, { "filename": "refdb.h", - "ignore": true, - "jsClassName": "Refdb", - "cppClassName": "Refdb", + "jsClassName": "RefDb", + "cppClassName": "GitRefDb", "cType": "git_refdb", - "freeFunctionName": "git_refdb_free", "functions": [ { "cFunctionName": "git_reference__alloc", @@ -7824,8 +7549,8 @@ { "name": "refdb", "cType": "git_refdb *", - "cppClassName": "Refdb", - "jsClassName": "Refdb", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", "isSelf": true }, { @@ -7847,6 +7572,7 @@ "jsClassName": "String" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -7857,74 +7583,19 @@ "cppClassName": "GitReference" } }, - { - "cFunctionName": "git_refdb_new", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_refdb **", - "cppClassName": "Refdb", - "jsClassName": "Refdb" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "new", - "cppFunctionName": "New", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_refdb_open", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_refdb **", - "cppClassName": "Refdb", - "jsClassName": "Refdb" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "open", - "cppFunctionName": "Open", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_refdb_compress", "args": [ { "name": "refdb", "cType": "git_refdb *", - "cppClassName": "Refdb", - "jsClassName": "Refdb", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", "isSelf": true } ], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "compress", @@ -7941,10 +7612,11 @@ { "name": "refdb", "cType": "git_refdb *", - "cppClassName": "Refdb", - "jsClassName": "Refdb" + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -7962,8 +7634,8 @@ { "name": "refdb", "cType": "git_refdb *", - "cppClassName": "Refdb", - "jsClassName": "Refdb", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", "isSelf": true }, { @@ -7973,6 +7645,7 @@ "jsClassName": "RefdbBackend" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -7993,42 +7666,7 @@ "cppClassName": "RefdbBackend", "cType": "git_refdb_backend", "freeFunctionName": "git_refdb_backend_free", - "functions": [ - { - "cFunctionName": "git_refdb_backend_fs", - "args": [ - { - "name": "backend_out", - "cType": "struct git_refdb_backend **", - "cppClassName": "RefdbBackend", - "jsClassName": "RefdbBackend", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "refdb", - "cType": "git_refdb *", - "cppClassName": "Refdb", - "jsClassName": "Refdb" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "fs", - "cppFunctionName": "Fs", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - } - ] + "functions": [] }, { "filename": "reflog.h", @@ -8373,40 +8011,6 @@ "cType": "git_reference", "freeFunctionName": "git_reference_free", "functions": [ - { - "cFunctionName": "git_reference_lookup", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_reference **", - "cppClassName": "GitReference", - "jsClassName": "Reference" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_reference_name_to_id", "args": [ @@ -8442,120 +8046,28 @@ } }, { - "cFunctionName": "git_reference_symbolic_create", + "cFunctionName": "git_reference_target", "args": [ { - "name": "out", - "isReturn": true, - "cType": "git_reference **", + "name": "ref", + "cType": "const git_reference *", "cppClassName": "GitReference", - "jsClassName": "Reference" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "target", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "force", - "cType": "int", - "cppClassName": "Int32", - "jsClassName": "Number" + "jsClassName": "Reference", + "isSelf": true } ], "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "createSymbolic", - "cppFunctionName": "CreateSymbolic", + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true + "cType": "const git_oid *", + "cppClassName": "GitOid" } }, { - "cFunctionName": "git_reference_create", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_reference **", - "cppClassName": "GitReference", - "jsClassName": "Reference" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - }, - { - "name": "force", - "cType": "int", - "cppClassName": "Int32", - "jsClassName": "Number" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "create", - "cppFunctionName": "Create", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_reference_target", - "args": [ - { - "name": "ref", - "cType": "const git_reference *", - "cppClassName": "GitReference", - "jsClassName": "Reference", - "isSelf": true - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": true, - "jsFunctionName": "oid", - "cppFunctionName": "Oid", - "return": { - "cType": "const git_oid *", - "cppClassName": "GitOid" - } - }, - { - "cFunctionName": "git_reference_symbolic_target", + "cFunctionName": "git_reference_symbolic_target", "args": [ { "name": "ref", @@ -9351,132 +8863,19 @@ }, { "filename": "remote.h", + "ignore": true, "jsClassName": "Remote", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "cType": "git_remote", "freeFunctionName": "git_remote_free", "functions": [ - { - "cFunctionName": "git_remote_create", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_remote **", - "cppClassName": "Remote", - "jsClassName": "Remote" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "url", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "create", - "cppFunctionName": "Create", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_remote_create_inmemory", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_remote **", - "cppClassName": "Remote", - "jsClassName": "Remote" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "fetch", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "url", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "createInmemory", - "cppFunctionName": "CreateInmemory", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_remote_load", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_remote **", - "cppClassName": "Remote", - "jsClassName": "Remote" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "load", - "cppFunctionName": "Load", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_remote_save", "args": [ { "name": "remote", "cType": "const git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9498,7 +8897,7 @@ { "name": "remote", "cType": "const git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9519,7 +8918,7 @@ { "name": "remote", "cType": "const git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9540,7 +8939,7 @@ { "name": "remote", "cType": "const git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9561,15 +8960,15 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, { "name": "url", "cType": "const char*", - "cppClassName": "const", - "jsClassName": "const" + "cppClassName": "String", + "jsClassName": "String" } ], "isAsync": false, @@ -9589,15 +8988,15 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, { "name": "url", "cType": "const char*", - "cppClassName": "const", - "jsClassName": "const" + "cppClassName": "String", + "jsClassName": "String" } ], "isAsync": false, @@ -9617,7 +9016,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -9645,7 +9044,7 @@ { "name": "remote", "cType": "const git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9666,7 +9065,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -9694,7 +9093,7 @@ { "name": "remote", "cType": "const git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9715,7 +9114,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -9743,7 +9142,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -9777,7 +9176,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -9811,7 +9210,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9833,7 +9232,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9854,7 +9253,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9875,7 +9274,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote" } ], @@ -9896,7 +9295,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -9939,8 +9338,8 @@ { "name": "url", "cType": "const char*", - "cppClassName": "const", - "jsClassName": "const" + "cppClassName": "String", + "jsClassName": "String" } ], "isAsync": false, @@ -9988,7 +9387,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10015,7 +9414,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10048,7 +9447,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10076,7 +9475,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10104,7 +9503,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -10138,7 +9537,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10165,7 +9564,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10205,7 +9604,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true } @@ -10227,7 +9626,7 @@ { "name": "remote", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote", "isSelf": true }, @@ -10273,7 +9672,7 @@ }, { "filename": "repo.h", - "dependencies": [], + "dependencies": ["../include/oid.h", "../include/commit.h", "../include/blob.h", "../include/object.h", "../include/reference.h", "../include/submodule.h", "../include/refdb.h", "../include/revwalk.h", "../include/tag.h", "../include/signature.h", "../include/tree.h"], "jsClassName": "Repo", "cppClassName": "GitRepo", "cType": "git_repository", @@ -10833,8 +10232,8 @@ "name": "out", "isReturn": true, "cType": "git_refdb **", - "cppClassName": "Refdb", - "jsClassName": "Refdb" + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" }, { "name": "repo", @@ -10868,8 +10267,8 @@ { "name": "refdb", "cType": "git_refdb *", - "cppClassName": "Refdb", - "jsClassName": "Refdb" + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" } ], "ignore": true, @@ -11150,8 +10549,8 @@ { "name": "refname", "cType": "const char*", - "cppClassName": "const", - "jsClassName": "const" + "cppClassName": "String", + "jsClassName": "String" } ], "ignore": true, @@ -11178,8 +10577,8 @@ { "name": "commitish", "cType": "const git_oid*", - "cppClassName": "const", - "jsClassName": "const" + "cppClassName": "String", + "jsClassName": "String" } ], "ignore": true, @@ -11238,44 +10637,36 @@ "cppClassName": "Int32", "isErrorCode": true } - } - ] - }, - { - "filename": "reset.h", - "ignore": true, - "jsClassName": "Reset", - "cppClassName": "Reset", - "cType": "git_reset", - "freeFunctionName": "git_reset_free", - "functions": [ + }, { - "cFunctionName": "git_reset", + "cFunctionName": "git_blob_lookup", "args": [ + { + "name": "blob", + "cType": "git_blob **", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isReturn": true + }, { "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "target", - "cType": "git_object *", - "cppClassName": "GitObject", - "jsClassName": "Object" + "jsClassName": "Repository", + "isSelf": true }, { - "name": "reset_type", - "cType": "git_reset_t", - "cppClassName": "ResetT", - "jsClassName": "ResetT" + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "gitReset", - "cppFunctionName": "GitReset", + "isPrototypeMethod": true, + "jsFunctionName": "getBlob", + "cppFunctionName": "GetBlob", "return": { "cType": "int", "cppClassName": "Int32", @@ -11283,30 +10674,1056 @@ } }, { - "cFunctionName": "git_reset_default", + "cFunctionName": "git_blob_lookup_prefix", "args": [ + { + "name": "blob", + "cType": "git_blob **", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isReturn": true + }, { "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true }, { - "name": "target", - "cType": "git_object *", - "cppClassName": "GitObject", - "jsClassName": "Object" + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" }, { - "name": "pathspecs", - "cType": "git_strarray*", - "cppClassName": "Strarray*", - "jsClassName": "Strarray*" + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getBlobByPrefix", + "cppFunctionName": "GetBlobByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_lookup", + "args": [ + { + "name": "commit", + "cType": "git_commit **", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getCommit", + "cppFunctionName": "GetCommit", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_commit_create", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "update_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature" + }, + { + "name": "message_encoding", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "parent_count", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + }, + { + "name": "parents", + "cType": "const git_commit **", + "cppClassName": "Array", + "jsClassName": "Array" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createCommit", + "cppFunctionName": "CreateCommit", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_object_lookup", + "args": [ + { + "name": "object", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getObject", + "cppFunctionName": "GetObject", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_object_lookup_prefix", + "args": [ + { + "name": "object_out", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Number", + "jsClassName": "Number" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getObjectByPrefix", + "cppFunctionName": "GetObjectByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refdb_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_refdb **", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "newRefDbWithoutBackends", + "cppFunctionName": "NewRefDbWithoutBackends", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refdb_open", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_refdb **", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "openRefDb", + "cppFunctionName": "OpenRefDb", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_refdb_backend_fs", + "args": [ + { + "name": "backend_out", + "cType": "struct git_refdb_backend **", + "cppClassName": "RefdbBackend", + "jsClassName": "RefdbBackend", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "openRefDbBackend", + "cppFunctionName": "OpenRefDbBackend", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getReference", + "cppFunctionName": "GetReference", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_symbolic_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createSymbolicReference", + "cppFunctionName": "CreateSymbolicReference", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createReference", + "cppFunctionName": "CreateReference", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_remote **", + "cppClassName": "GitRemote", + "jsClassName": "Remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addRemote", + "cppFunctionName": "AddRemote", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_create_inmemory", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_remote **", + "cppClassName": "GitRemote", + "jsClassName": "Remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "fetch", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addRemoteInMemory", + "cppFunctionName": "AddRemoteInMemory", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_remote_load", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_remote **", + "cppClassName": "GitRemote", + "jsClassName": "Remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "loadRemote", + "cppFunctionName": "LoadRemote", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_revwalk_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_revwalk **", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createRevWalk", + "cppFunctionName": "CreateRevWalk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_lookup", + "args": [ + { + "name": "submodule", + "cType": "git_submodule **", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getSubmodule", + "cppFunctionName": "GetSubmodule", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_add_setup", + "args": [ + { + "name": "submodule", + "cType": "git_submodule **", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "use_gitlink", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addSubmodule", + "cppFunctionName": "AddSubmodule", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tag **", + "cppClassName": "GitTag", + "jsClassName": "Tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTag", + "cppFunctionName": "GetTag", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_lookup_prefix", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tag **", + "cppClassName": "GitTag", + "jsClassName": "Tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTagByPrefix", + "cppFunctionName": "GetTagByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_create", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object" + }, + { + "name": "tagger", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createTag", + "cppFunctionName": "CreateTag", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_create_lightweight", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "target", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "createLightweightTag", + "cppFunctionName": "CreateLightweightTag", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tree **", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTree", + "cppFunctionName": "GetTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tree_lookup_prefix", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tree **", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTreeByPrefix", + "cppFunctionName": "GetTreeByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_submodule_reload_all", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "reloadSubmodules", + "cppFunctionName": "ReloadSubmodules", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + } + ] + }, + { + "filename": "reset.h", + "ignore": true, + "jsClassName": "Reset", + "cppClassName": "Reset", + "cType": "git_reset", + "freeFunctionName": "git_reset_free", + "functions": [ + { + "cFunctionName": "git_reset", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "target", + "cType": "git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object" + }, + { + "name": "reset_type", + "cType": "git_reset_t", + "cppClassName": "ResetT", + "jsClassName": "ResetT" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitReset", + "cppFunctionName": "GitReset", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reset_default", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "target", + "cType": "git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object" + }, + { + "name": "pathspecs", + "cType": "git_strarray*", + "cppClassName": "Strarray*", + "jsClassName": "Strarray*" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, "jsFunctionName": "default", "cppFunctionName": "Default", "return": { @@ -11402,35 +11819,6 @@ "cType": "git_revwalk", "freeFunctionName": "git_revwalk_free", "functions": [ - { - "cFunctionName": "git_revwalk_new", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_revwalk **", - "cppClassName": "GitRevWalk", - "jsClassName": "RevWalk" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - } - ], - - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "make", - "cppFunctionName": "Make", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_revwalk_reset", "args": [ @@ -12317,46 +12705,11 @@ }, { "filename": "submodule.h", - "ignore": true, + "dependencies": ["../include/oid.h", "../include/repo.h"], "jsClassName": "Submodule", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "cType": "git_submodule", - "freeFunctionName": "git_submodule_free", "functions": [ - { - "cFunctionName": "git_submodule_lookup", - "args": [ - { - "name": "submodule", - "cType": "git_submodule **", - "cppClassName": "Submodule", - "jsClassName": "Submodule", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_submodule_foreach", "args": [ @@ -12379,6 +12732,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -12390,64 +12744,18 @@ "isErrorCode": true } }, - { - "cFunctionName": "git_submodule_add_setup", - "args": [ - { - "name": "submodule", - "cType": "git_submodule **", - "cppClassName": "Submodule", - "jsClassName": "Submodule", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "url", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "path", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "use_gitlink", - "cType": "int", - "cppClassName": "Int32", - "jsClassName": "Number" - } - ], - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "addSetup", - "cppFunctionName": "AddSetup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_submodule_add_finalize", "args": [ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "addFinalize", @@ -12464,7 +12772,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true }, @@ -12475,7 +12783,7 @@ "jsClassName": "Number" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "addToIndex", @@ -12492,12 +12800,12 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "save", @@ -12514,11 +12822,12 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12535,7 +12844,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } @@ -12556,7 +12865,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } @@ -12577,7 +12886,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } @@ -12598,7 +12907,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true }, @@ -12626,7 +12935,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } @@ -12647,7 +12956,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } @@ -12668,11 +12977,12 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12686,7 +12996,8 @@ { "cFunctionName": "git_submodule_ignore", "args": [], - "isAsync": false, + "ignore": true, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": false, "jsFunctionName": "ignore", @@ -12702,7 +13013,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true }, @@ -12713,6 +13024,7 @@ "jsClassName": "SubmoduleIgnoreT" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12725,6 +13037,7 @@ }, { "cFunctionName": "git_submodule_update", + "ignore": true, "args": [], "isAsync": false, "isConstructorMethod": false, @@ -12742,7 +13055,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true }, @@ -12753,6 +13066,7 @@ "jsClassName": "SubmoduleUpdateT" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12769,11 +13083,12 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12791,7 +13106,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true }, @@ -12802,6 +13117,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12819,7 +13135,7 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true }, @@ -12830,7 +13146,7 @@ "jsClassName": "Number" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "init", @@ -12847,12 +13163,12 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "sync", @@ -12870,18 +13186,20 @@ "name": "repo", "cType": "git_repository **", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isReturn": true }, { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", - "jsClassName": "Submodule" + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "open", "cppFunctionName": "Open", "return": { @@ -12896,12 +13214,12 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule", "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "reload", @@ -12912,27 +13230,6 @@ "isErrorCode": true } }, - { - "cFunctionName": "git_submodule_reload_all", - "args": [ - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "reloadAll", - "cppFunctionName": "ReloadAll", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_submodule_status", "args": [ @@ -12945,13 +13242,14 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", - "jsClassName": "Submodule" + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "status", "cppFunctionName": "Status", "return": { @@ -12972,10 +13270,11 @@ { "name": "submodule", "cType": "git_submodule *", - "cppClassName": "Submodule", + "cppClassName": "GitSubmodule", "jsClassName": "Submodule" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -12997,81 +13296,6 @@ "cType": "git_tag", "freeFunctionName": "git_tag_free", "functions": [ - { - "cFunctionName": "git_tag_lookup", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_tag **", - "cppClassName": "GitTag", - "jsClassName": "Tag" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tag_lookup_prefix", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_tag **", - "cppClassName": "GitTag", - "jsClassName": "Tag" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - }, - { - "name": "len", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" - } - ], - "ignore": true, - "isAsync": false, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookupPrefix", - "cppFunctionName": "LookupPrefix", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_tag_free", "args": [ @@ -13249,64 +13473,6 @@ "cppClassName": "String" } }, - { - "cFunctionName": "git_tag_create", - "args": [ - { - "name": "oid", - "cType": "git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "tag_name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "target", - "cType": "const git_object *", - "cppClassName": "GitObject", - "jsClassName": "Object" - }, - { - "name": "tagger", - "cType": "const git_signature *", - "cppClassName": "GitSignature", - "jsClassName": "Signature" - }, - { - "name": "message", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "force", - "cType": "int", - "cppClassName": "Int32", - "jsClassName": "Number" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "create", - "cppFunctionName": "Create", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_tag_create_frombuffer", "args": [ @@ -13347,52 +13513,6 @@ "isErrorCode": true } }, - { - "cFunctionName": "git_tag_create_lightweight", - "args": [ - { - "name": "oid", - "cType": "git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "tag_name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "target", - "cType": "const git_object *", - "cppClassName": "GitObject", - "jsClassName": "Object" - }, - { - "name": "force", - "cType": "int", - "cppClassName": "Int32", - "jsClassName": "Number" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "createLightweight", - "cppFunctionName": "CreateLightweight", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_tag_delete", "args": [ @@ -13673,7 +13793,7 @@ { "name": "owner", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote" }, { @@ -13707,7 +13827,7 @@ { "name": "owner", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote" }, { @@ -13741,7 +13861,7 @@ { "name": "owner", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote" }, { @@ -13775,7 +13895,7 @@ { "name": "owner", "cType": "git_remote *", - "cppClassName": "Remote", + "cppClassName": "GitRemote", "jsClassName": "Remote" }, { @@ -14065,81 +14185,6 @@ "cType": "git_tree", "freeFunctionName": "git_tree_free", "functions": [ - { - "cFunctionName": "git_tree_lookup", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_tree **", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookup", - "cppFunctionName": "Lookup", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tree_lookup_prefix", - "args": [ - { - "name": "out", - "isReturn": true, - "cType": "git_tree **", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "id", - "cType": "const git_oid *", - "cppClassName": "GitOid", - "jsClassName": "Oid" - }, - { - "name": "len", - "cType": "size_t", - "cppClassName": "Uint32", - "jsClassName": "Number" - } - ], - "ignore": true, - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "lookupPrefix", - "cppFunctionName": "LookupPrefix", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_tree_free", "args": [ From a2a547924dd48e03e54b0f819338a0a7c728cda7 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sat, 29 Jun 2013 17:50:52 +0200 Subject: [PATCH 16/28] Made the diff methods prototype methods --- include/diff_list.h | 72 ------- include/index.h | 17 ++ include/tree.h | 55 ++++++ lib/commit.js | 6 +- lib/diff_list.js | 8 - lib/tree.js | 13 +- src/diff_list.cc | 353 ----------------------------------- src/index.cc | 86 +++++++++ src/tree.cc | 260 ++++++++++++++++++++++++++ test/convenience-difflist.js | 2 +- v0.18.0.json | 353 ++++++++++++++++++----------------- 11 files changed, 612 insertions(+), 613 deletions(-) diff --git a/include/diff_list.h b/include/diff_list.h index 177ff350f..185a00e56 100644 --- a/include/diff_list.h +++ b/include/diff_list.h @@ -31,78 +31,6 @@ class GitDiffList : public ObjectWrap { static Handle New(const Arguments& args); - static Handle TreeToTree(const Arguments& args); - static void TreeToTreeWork(uv_work_t* req); - static void TreeToTreeAfterWork(uv_work_t* req); - - struct TreeToTreeBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_diff_list * diff; - Persistent repoReference; - git_repository * repo; - Persistent old_treeReference; - git_tree * old_tree; - Persistent new_treeReference; - git_tree * new_tree; - Persistent optsReference; - const git_diff_options * opts; - Persistent callback; - }; - static Handle TreeToIndex(const Arguments& args); - static void TreeToIndexWork(uv_work_t* req); - static void TreeToIndexAfterWork(uv_work_t* req); - - struct TreeToIndexBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_diff_list * diff; - Persistent repoReference; - git_repository * repo; - Persistent old_treeReference; - git_tree * old_tree; - Persistent indexReference; - git_index * index; - Persistent optsReference; - const git_diff_options * opts; - Persistent callback; - }; - static Handle IndexToWorkdir(const Arguments& args); - static void IndexToWorkdirWork(uv_work_t* req); - static void IndexToWorkdirAfterWork(uv_work_t* req); - - struct IndexToWorkdirBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_diff_list * diff; - Persistent repoReference; - git_repository * repo; - Persistent indexReference; - git_index * index; - Persistent optsReference; - const git_diff_options * opts; - Persistent callback; - }; - static Handle TreeToWorkdir(const Arguments& args); - static void TreeToWorkdirWork(uv_work_t* req); - static void TreeToWorkdirAfterWork(uv_work_t* req); - - struct TreeToWorkdirBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_diff_list * diff; - Persistent repoReference; - git_repository * repo; - Persistent old_treeReference; - git_tree * old_tree; - Persistent optsReference; - const git_diff_options * opts; - Persistent callback; - }; static Handle Merge(const Arguments& args); static Handle FindSimilar(const Arguments& args); static Handle Size(const Arguments& args); diff --git a/include/index.h b/include/index.h index a74610e7d..2a374e4ff 100755 --- a/include/index.h +++ b/include/index.h @@ -119,6 +119,23 @@ class GitIndex : public ObjectWrap { static Handle ConflictRemove(const Arguments& args); static Handle ConflictCleanup(const Arguments& args); static Handle HasConflicts(const Arguments& args); + static Handle IndexToWorkdir(const Arguments& args); + static void IndexToWorkdirWork(uv_work_t* req); + static void IndexToWorkdirAfterWork(uv_work_t* req); + + struct IndexToWorkdirBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; git_index *raw; }; diff --git a/include/tree.h b/include/tree.h index e354c9de8..15010092b 100755 --- a/include/tree.h +++ b/include/tree.h @@ -51,6 +51,61 @@ class GitTree : public ObjectWrap { const char * path; Persistent callback; }; + static Handle DiffTree(const Arguments& args); + static void DiffTreeWork(uv_work_t* req); + static void DiffTreeAfterWork(uv_work_t* req); + + struct DiffTreeBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent new_treeReference; + git_tree * new_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle DiffIndex(const Arguments& args); + static void DiffIndexWork(uv_work_t* req); + static void DiffIndexAfterWork(uv_work_t* req); + + struct DiffIndexBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle DiffWorkDir(const Arguments& args); + static void DiffWorkDirWork(uv_work_t* req); + static void DiffWorkDirAfterWork(uv_work_t* req); + + struct DiffWorkDirBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; git_tree *raw; }; diff --git a/lib/commit.js b/lib/commit.js index e75117465..f209bc811 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -161,7 +161,7 @@ Commit.prototype.history = function() { event.emit('commit', null, commit); commits.push(commit); }); - } + }; return event; }; @@ -183,7 +183,7 @@ Commit.prototype.parents = function(callback) { rawCommit.parent(n, function nextParent(error, rawParentCommit) { if (error) return callback(error); - processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback) + processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback); }); } @@ -214,7 +214,7 @@ Commit.prototype.parentsDiffTrees = function(callback) { self.getTree(function(error, thisTree) { if (error) return callback(error); - git.diffList.treeToTree(self.repo, parentTree, thisTree, function walkDiffList(error, diffList) { + parentTree.diff(thisTree, function walkDiffList(error, diffList) { if (error) return callback(error); parentDiffLists.push(diffList); diff --git a/lib/diff_list.js b/lib/diff_list.js index 6f545b871..afc9a27e8 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -49,14 +49,6 @@ DiffList.LineOrigin = { /** 'B' */ Binary: 102 }; -DiffList.treeToTree = function(repo, oldTree, newTree, callback) { - git.raw.DiffList.treeToTree(repo.rawRepo, oldTree.rawTree, newTree.rawTree, null, function(error, rawDiffList) { - if (error) return callback(new git.error(error.message, error.code), null); - - callback(null, new DiffList(rawDiffList)); - }); -}; - /** * Retrieve patches diff --git a/lib/tree.js b/lib/tree.js index fcf42f100..966e243ac 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -44,7 +44,18 @@ Tree.prototype.entry = function(path, callback) { * Retrieve the number of entries in this tree. */ Tree.prototype.size = function() { - return self.rawTree.size(); + return this.rawTree.size(); +}; + +/** + * Diff two trees + */ +Tree.prototype.diff = function(that, callback) { + this.rawTree.diffTree(this.repo.rawRepo, that.rawTree, null, function(error, rawDiffList) { + if (error) return callback(error); + + callback(null, new git.diffList(rawDiffList)); + }); }; /** diff --git a/src/diff_list.cc b/src/diff_list.cc index 62c2d602d..3de29d109 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -35,10 +35,6 @@ void GitDiffList::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("DiffList")); - NODE_SET_METHOD(tpl, "treeToTree", TreeToTree); - NODE_SET_METHOD(tpl, "treeToIndex", TreeToIndex); - NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); - NODE_SET_METHOD(tpl, "treeToWorkdir", TreeToWorkdir); NODE_SET_PROTOTYPE_METHOD(tpl, "merge", Merge); NODE_SET_PROTOTYPE_METHOD(tpl, "findSimilar", FindSimilar); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); @@ -74,355 +70,6 @@ git_diff_list *GitDiffList::GetValue() { } -Handle GitDiffList::TreeToTree(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); - } - - if (args.Length() == 4 || !args[4]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TreeToTreeBaton* baton = new TreeToTreeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->old_treeReference = Persistent::New(args[1]); - git_tree * from_old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->old_tree = from_old_tree; - baton->new_treeReference = Persistent::New(args[2]); - git_tree * from_new_tree = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->new_tree = from_new_tree; - baton->optsReference = Persistent::New(args[3]); - if (args[3]->IsObject()) { - const git_diff_options * from_opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); - baton->opts = from_opts; - } else { - baton->opts = NULL; - } - baton->callback = Persistent::New(Local::Cast(args[4])); - - uv_queue_work(uv_default_loop(), &baton->request, TreeToTreeWork, (uv_after_work_cb)TreeToTreeAfterWork); - - return Undefined(); -} - -void GitDiffList::TreeToTreeWork(uv_work_t *req) { - TreeToTreeBaton *baton = static_cast(req->data); - int result = git_diff_tree_to_tree( - &baton->diff, - baton->repo, - baton->old_tree, - baton->new_tree, - baton->opts - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { - HandleScope scope; - TreeToTreeBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitDiffList::New((void *)baton->diff); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->old_treeReference.Dispose(); - baton->new_treeReference.Dispose(); - baton->optsReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - -Handle GitDiffList::TreeToIndex(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("Index index is required."))); - } - if (args.Length() == 3 || !args[3]->IsObject()) { - return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); - } - - if (args.Length() == 4 || !args[4]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TreeToIndexBaton* baton = new TreeToIndexBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->old_treeReference = Persistent::New(args[1]); - git_tree * from_old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->old_tree = from_old_tree; - baton->indexReference = Persistent::New(args[2]); - git_index * from_index = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->index = from_index; - baton->optsReference = Persistent::New(args[3]); - const git_diff_options * from_opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); - baton->opts = from_opts; - baton->callback = Persistent::New(Local::Cast(args[4])); - - uv_queue_work(uv_default_loop(), &baton->request, TreeToIndexWork, (uv_after_work_cb)TreeToIndexAfterWork); - - return Undefined(); -} - -void GitDiffList::TreeToIndexWork(uv_work_t *req) { - TreeToIndexBaton *baton = static_cast(req->data); - int result = git_diff_tree_to_index( - &baton->diff, - baton->repo, - baton->old_tree, - baton->index, - baton->opts - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitDiffList::TreeToIndexAfterWork(uv_work_t *req) { - HandleScope scope; - TreeToIndexBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitDiffList::New((void *)baton->diff); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->old_treeReference.Dispose(); - baton->indexReference.Dispose(); - baton->optsReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - -Handle GitDiffList::IndexToWorkdir(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Index index is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->indexReference = Persistent::New(args[1]); - git_index * from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->index = from_index; - baton->optsReference = Persistent::New(args[2]); - const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->opts = from_opts; - baton->callback = Persistent::New(Local::Cast(args[3])); - - uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); - - return Undefined(); -} - -void GitDiffList::IndexToWorkdirWork(uv_work_t *req) { - IndexToWorkdirBaton *baton = static_cast(req->data); - int result = git_diff_index_to_workdir( - &baton->diff, - baton->repo, - baton->index, - baton->opts - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitDiffList::IndexToWorkdirAfterWork(uv_work_t *req) { - HandleScope scope; - IndexToWorkdirBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitDiffList::New((void *)baton->diff); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->indexReference.Dispose(); - baton->optsReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - -Handle GitDiffList::TreeToWorkdir(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TreeToWorkdirBaton* baton = new TreeToWorkdirBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->repoReference = Persistent::New(args[0]); - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->old_treeReference = Persistent::New(args[1]); - git_tree * from_old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->old_tree = from_old_tree; - baton->optsReference = Persistent::New(args[2]); - const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->opts = from_opts; - baton->callback = Persistent::New(Local::Cast(args[3])); - - uv_queue_work(uv_default_loop(), &baton->request, TreeToWorkdirWork, (uv_after_work_cb)TreeToWorkdirAfterWork); - - return Undefined(); -} - -void GitDiffList::TreeToWorkdirWork(uv_work_t *req) { - TreeToWorkdirBaton *baton = static_cast(req->data); - int result = git_diff_tree_to_workdir( - &baton->diff, - baton->repo, - baton->old_tree, - baton->opts - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitDiffList::TreeToWorkdirAfterWork(uv_work_t *req) { - HandleScope scope; - TreeToWorkdirBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitDiffList::New((void *)baton->diff); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->repoReference.Dispose(); - baton->old_treeReference.Dispose(); - baton->optsReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitDiffList::Merge(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/src/index.cc b/src/index.cc index ba2931ec3..d13913639 100644 --- a/src/index.cc +++ b/src/index.cc @@ -11,6 +11,8 @@ #include "../include/oid.h" #include "../include/repo.h" #include "../include/tree.h" +#include "../include/diff_list.h" +#include "../include/diff_options.h" using namespace v8; using namespace node; @@ -47,6 +49,7 @@ void GitIndex::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "conflictRemove", ConflictRemove); NODE_SET_PROTOTYPE_METHOD(tpl, "conflictCleanup", ConflictCleanup); NODE_SET_PROTOTYPE_METHOD(tpl, "hasConflicts", HasConflicts); + NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); constructor_template = Persistent::New(tpl->GetFunction()); @@ -651,4 +654,87 @@ Handle GitIndex::HasConflicts(const Arguments& args) { return scope.Close(to); } +Handle GitIndex::IndexToWorkdir(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->indexReference = Persistent::New(args[1]); + git_index * from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->index = from_index; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); + + return Undefined(); +} + +void GitIndex::IndexToWorkdirWork(uv_work_t *req) { + IndexToWorkdirBaton *baton = static_cast(req->data); + int result = git_diff_index_to_workdir( + &baton->diff, + baton->repo, + baton->index, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::IndexToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + IndexToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + Persistent GitIndex::constructor_template; diff --git a/src/tree.cc b/src/tree.cc index b32ee7bd5..2182f0e4f 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -11,6 +11,9 @@ #include "../include/repo.h" #include "../include/oid.h" #include "../include/tree_entry.h" +#include "../include/diff_list.h" +#include "../include/diff_options.h" +#include "../include/index.h" using namespace v8; using namespace node; @@ -37,6 +40,9 @@ void GitTree::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "entryByIndex", EntryByIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByOid", EntryByOid); NODE_SET_PROTOTYPE_METHOD(tpl, "getEntryByPath", GetEntryByPath); + NODE_SET_PROTOTYPE_METHOD(tpl, "diffTree", DiffTree); + NODE_SET_PROTOTYPE_METHOD(tpl, "diffIndex", DiffIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "diffWorkDir", DiffWorkDir); constructor_template = Persistent::New(tpl->GetFunction()); @@ -222,4 +228,258 @@ void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { delete baton; } +Handle GitTree::DiffTree(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DiffTreeBaton* baton = new DiffTreeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); + baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->new_treeReference = Persistent::New(args[1]); + git_tree * from_new_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->new_tree = from_new_tree; + baton->optsReference = Persistent::New(args[2]); + if (args[2]->IsObject()) { + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; + } else { + baton->opts = NULL; + } + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, DiffTreeWork, (uv_after_work_cb)DiffTreeAfterWork); + + return Undefined(); +} + +void GitTree::DiffTreeWork(uv_work_t *req) { + DiffTreeBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_tree( + &baton->diff, + baton->repo, + baton->old_tree, + baton->new_tree, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTree::DiffTreeAfterWork(uv_work_t *req) { + HandleScope scope; + DiffTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->new_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitTree::DiffIndex(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DiffIndexBaton* baton = new DiffIndexBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); + baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->indexReference = Persistent::New(args[1]); + git_index * from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->index = from_index; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, DiffIndexWork, (uv_after_work_cb)DiffIndexAfterWork); + + return Undefined(); +} + +void GitTree::DiffIndexWork(uv_work_t *req) { + DiffIndexBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_index( + &baton->diff, + baton->repo, + baton->old_tree, + baton->index, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTree::DiffIndexAfterWork(uv_work_t *req) { + HandleScope scope; + DiffIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitTree::DiffWorkDir(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DiffWorkDirBaton* baton = new DiffWorkDirBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); + baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->optsReference = Persistent::New(args[1]); + const git_diff_options * from_opts = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, DiffWorkDirWork, (uv_after_work_cb)DiffWorkDirAfterWork); + + return Undefined(); +} + +void GitTree::DiffWorkDirWork(uv_work_t *req) { + DiffWorkDirBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_workdir( + &baton->diff, + baton->repo, + baton->old_tree, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTree::DiffWorkDirAfterWork(uv_work_t *req) { + HandleScope scope; + DiffWorkDirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitDiffList::New((void *)baton->diff); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + Persistent GitTree::constructor_template; diff --git a/test/convenience-difflist.js b/test/convenience-difflist.js index 5a6628b04..82b98ea65 100644 --- a/test/convenience-difflist.js +++ b/test/convenience-difflist.js @@ -46,7 +46,7 @@ exports.walkingDiffs = function(test) { commit.parents(function(error, parents) { parents[0].getTree(function(error, parentTree) { commit.getTree(function(error, commitTree) { - git.diffList.treeToTree(commit.repo, parentTree, commitTree, function(error, diffList) { + parentTree.diff(commitTree, function(error, diffList) { test.equal(null, error, 'Should not error'); diffList.patches().forEach(function(patch) { diff --git a/v0.18.0.json b/v0.18.0.json index 6c32327d7..63eb44a5b 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -3120,179 +3120,6 @@ "cppClassName": "void" } }, - { - "cFunctionName": "git_diff_tree_to_tree", - "args": [ - { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "GitDiffList", - "jsClassName": "DiffList", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "old_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "new_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "GitDiffOptions", - "jsClassName": "DiffOptions", - "isOptional": true - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "treeToTree", - "cppFunctionName": "TreeToTree", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_diff_tree_to_index", - "args": [ - { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "GitDiffList", - "jsClassName": "DiffList", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "old_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "index", - "cType": "git_index *", - "cppClassName": "GitIndex", - "jsClassName": "Index" - }, - { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "GitDiffOptions", - "jsClassName": "DiffOptions" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "treeToIndex", - "cppFunctionName": "TreeToIndex", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_diff_index_to_workdir", - "args": [ - { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "GitDiffList", - "jsClassName": "DiffList", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "index", - "cType": "git_index *", - "cppClassName": "GitIndex", - "jsClassName": "Index" - }, - { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "GitDiffOptions", - "jsClassName": "DiffOptions" - } - ], - "isAsync": true, - "isConstructorMethod": true, - "isPrototypeMethod": false, - "jsFunctionName": "indexToWorkdir", - "cppFunctionName": "IndexToWorkdir", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_diff_tree_to_workdir", - "args": [ - { - "name": "diff", - "cType": "git_diff_list **", - "cppClassName": "GitDiffList", - "jsClassName": "DiffList", - "isReturn": true - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "old_tree", - "cType": "git_tree *", - "cppClassName": "GitTree", - "jsClassName": "Tree" - }, - { - "name": "opts", - "cType": "const git_diff_options *", - "cppClassName": "GitDiffOptions", - "jsClassName": "DiffOptions" - } - ], - "isAsync": true, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "treeToWorkdir", - "cppFunctionName": "TreeToWorkdir", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_diff_merge", "args": [ @@ -3927,7 +3754,7 @@ }, { "filename": "index.h", - "dependencies": ["../include/oid.h", "../include/repo.h", "../include/tree.h"], + "dependencies": ["../include/oid.h", "../include/repo.h", "../include/tree.h", "../include/diff_list.h", "../include/diff_options.h"], "jsClassName": "Index", "cppClassName": "GitIndex", "cType": "git_index", @@ -4910,6 +4737,46 @@ "cType": "void", "cppClassName": "void" } + }, + { + "cFunctionName": "git_diff_index_to_workdir", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "indexToWorkdir", + "cppFunctionName": "IndexToWorkdir", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } } ] }, @@ -14179,7 +14046,7 @@ }, { "filename": "tree.h", - "dependencies": ["../include/repo.h", "../include/oid.h", "../include/tree_entry.h"], + "dependencies": ["../include/repo.h", "../include/oid.h", "../include/tree_entry.h", "../include/diff_list.h", "../include/diff_options.h", "../include/index.h"], "jsClassName": "Tree", "cppClassName": "GitTree", "cType": "git_tree", @@ -14689,6 +14556,142 @@ "cppClassName": "Int32", "isErrorCode": true } + }, + { + "cFunctionName": "git_diff_tree_to_tree", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true + }, + { + "name": "new_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions", + "isOptional": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "diffTree", + "cppFunctionName": "DiffTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_tree_to_index", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index" + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "diffIndex", + "cppFunctionName": "DiffIndex", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_diff_tree_to_workdir", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "diffWorkDir", + "cppFunctionName": "DiffWorkDir", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } } ] } From da4c29d90436d3b322221de96b1e44df48fc4538 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Tue, 2 Jul 2013 15:18:49 +0200 Subject: [PATCH 17/28] Raw and convenience API merged into one, using decorators --- TODO | 3 +- example/convenience-commit.js | 2 +- example/convenience-tree.js | 2 +- include/commit.h | 13 -- lib/blob.js | 76 +------- lib/commit.js | 109 ++--------- lib/diff_list.js | 66 +------ lib/index.js | 32 ++-- lib/oid.js | 37 ---- lib/reference.js | 52 +----- lib/repo.js | 170 ++++++++---------- lib/revwalk.js | 31 +--- lib/signature.js | 23 --- lib/tree.js | 79 ++++---- lib/tree_entry.js | 72 +------- lib/util.js | 11 ++ src/commit.cc | 64 ------- test/blob.js | 13 ++ test/{convenience-commit.js => commit.js} | 105 ++++------- test/convenience-oid.js | 37 ---- test/convenience-repo.js | 84 --------- test/{convenience-difflist.js => difflist.js} | 48 +---- test/{convenience-entry.js => entry.js} | 16 +- test/oid.js | 10 ++ test/raw-blob.js | 87 --------- test/raw-commit.js | 47 ----- test/raw-oid.js | 71 -------- test/raw-reference.js | 71 -------- test/raw-repo.js | 98 ---------- test/reference.js | 14 ++ test/repo.js | 57 ++++++ test/{raw-revwalk.js => revwalk.js} | 0 test/{convenience-tree.js => tree.js} | 4 +- v0.18.0.json | 6 +- 34 files changed, 333 insertions(+), 1277 deletions(-) delete mode 100644 lib/oid.js delete mode 100644 lib/signature.js create mode 100644 lib/util.js create mode 100644 test/blob.js rename test/{convenience-commit.js => commit.js} (65%) delete mode 100644 test/convenience-oid.js delete mode 100644 test/convenience-repo.js rename test/{convenience-difflist.js => difflist.js} (70%) rename test/{convenience-entry.js => entry.js} (81%) create mode 100644 test/oid.js delete mode 100644 test/raw-blob.js delete mode 100644 test/raw-commit.js delete mode 100644 test/raw-oid.js delete mode 100644 test/raw-reference.js delete mode 100644 test/raw-repo.js create mode 100644 test/reference.js create mode 100644 test/repo.js rename test/{raw-revwalk.js => revwalk.js} (100%) rename test/{convenience-tree.js => tree.js} (89%) diff --git a/TODO b/TODO index f4850133f..860e3013f 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ - rename all async methods getXXX -- reorder functions so the raw api is oo-like +- audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. - rename files remove .h +- Cleanup diff api diff --git a/example/convenience-commit.js b/example/convenience-commit.js index 1e2320a85..a6724b986 100644 --- a/example/convenience-commit.js +++ b/example/convenience-commit.js @@ -7,7 +7,7 @@ git.repo('.git', function(error, repository) { if (error) throw error; // Use the master branch (a branch is the HEAD commit) - repository.branch('master', function(error, branch) { + repository.getBranch('master', function(error, branch) { if (error) throw error; // History returns an event, and begins walking the history diff --git a/example/convenience-tree.js b/example/convenience-tree.js index efe4cb928..6cda8a75d 100644 --- a/example/convenience-tree.js +++ b/example/convenience-tree.js @@ -6,7 +6,7 @@ git.repo('.git', function(error, repository) { if (error) throw error; // Use the master branch. - repository.branch('master', function(error, branch) { + repository.getBranch('master', function(error, branch) { if (error) throw error; // Iterate over the revision history. diff --git a/include/commit.h b/include/commit.h index 0a938d5cf..2e04076c9 100755 --- a/include/commit.h +++ b/include/commit.h @@ -38,19 +38,6 @@ class GitCommit : public ObjectWrap { static Handle Offset(const Arguments& args); static Handle Committer(const Arguments& args); static Handle Author(const Arguments& args); - static Handle Tree(const Arguments& args); - static void TreeWork(uv_work_t* req); - static void TreeAfterWork(uv_work_t* req); - - struct TreeBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_tree * tree_out; - Persistent commitReference; - const git_commit * commit; - Persistent callback; - }; static Handle TreeId(const Arguments& args); static Handle ParentCount(const Arguments& args); static Handle Parent(const Arguments& args); diff --git a/lib/blob.js b/lib/blob.js index b0297c2aa..de8f141ba 100644 --- a/lib/blob.js +++ b/lib/blob.js @@ -1,75 +1,17 @@ -var git = require('../'); +var git = require('../'), + Blob = git.Blob; /** - * Blob convenience class constructor. - * - * @constructor - * @param {git.raw.Blob} [rawBlob = new git.raw.Blob(rawRepo)] Raw blob object. + * Replace old content method with something nicer. */ -var Blob = function(rawBlob) { - if (!(rawBlob instanceof git.raw.Blob)) { - throw new Error('First parameter for Blob must be a raw blob'); - } - this.rawBlob = rawBlob; +var oldContent = Blob.prototype.content; +Blob.prototype.content = function() { + return oldContent.call(this).toBuffer(this.size()); }; /** - * Retrieve the blob's raw content buffer. + * Retrieve the blob's content as String. */ -Blob.prototype.rawContent = function() { - return this.rawBlob.content().toBuffer(this.size()); +Blob.prototype.toString = function() { + return this.content().toString(); }; - -/** - * Retrieve the blob's length. - */ -Blob.prototype.size = function() { - return this.rawBlob.size(); -}; - -/** - * Retrieve the blob's content. - */ -Blob.prototype.content = function(callback) { - var content = this.rawContent(); - return content.toString(); -}; - -/** - * Create a new blob from the file at the given path. - * - * @param {String} path Full path to the file. - * @param {Blob~createFromFileCallback} callback - */ -Blob.prototype.createFromFile = function(path, callback) { - /** - * @callback Blob~createFromFileCallback Callback executed after blob is created. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob The new blob or null. - */ - git.raw.Blob.createFromFile(path, self.rawRepo, function blobCreateFromFileCallback(error, rawBlob) { - if (error) return callback(error); - callback(null, new Blob(rawBlob)); - }); -}; - -/** - * Create a new blob from the given buffer. - * - * @param {Buffer} buffer Buffer used to create blob. - * @param {Blob~createFromBufferCallback} callback - */ -Blob.prototype.createFromFile = function(path, callback) { - /** - * @callback Blob~createFromBufferCallback Callback executed after blob is created. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} content The new blob or null. - */ - var self = this; - self.rawBlob.createFromBuffer(buffer, self.rawRepo, function blobCreateFromBufferCallback(error, rawBlob) { - if (error) return callback(error); - callback(null, new Blob(rawBlob)); - }); -}; - -exports.blob = Blob; diff --git a/lib/commit.js b/lib/commit.js index f209bc811..7c699d279 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -1,31 +1,6 @@ -var git = require( '../' ), - events = require('events'); - -/** - * Convenience commit constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. - * @param {git.raw.Commit} [rawCommit = new git.raw.Commit(rawRepo)] Raw commit object. - */ -var Commit = function(repo, rawCommit) { - if (!(repo instanceof git.repo)) { - throw new Error('First parameter for Commit must be a raw repo'); - } - this.repo = repo; - - if (!(rawCommit instanceof git.raw.Commit)) { - throw new Error('Second parameter for Commit must be a raw commit'); - } - this.rawCommit = rawCommit; -}; - -/** - * Retrieve the commit's OID. - */ -Commit.prototype.oid = function() { - return new git.oid(this.rawCommit.oid()); -}; +var git = require('../'), + Commit = git.Commit, + events = require('events'); /** * Retrieve the SHA. @@ -34,66 +9,25 @@ Commit.prototype.sha = function() { return this.oid().sha(); }; -/** - * Retrieve the message - */ -Commit.prototype.message = function() { - return this.rawCommit.message(); -}; - /** * Retrieve the commit time as a unix timestamp. */ -Commit.prototype.time = function() { - return this.rawCommit.time() * 1000; +Commit.prototype.timeMs = function() { + return this.time() * 1000; }; /** * Retrieve the commit time as a Date object. */ Commit.prototype.date = function() { - return new Date(this.time()); -}; - -/** - * Retrieve the commit's positive or negative timezone offset, in minutes from UTC. - */ -Commit.prototype.offset = function(callback) { - return this.rawCommit.offset(); -}; - -/** - * Retrieve the commit's author signature. - */ -Commit.prototype.author = function() { - return this.rawCommit.author(); + return new Date(this.timeMs()); }; /** - * Retrieve the commit's committer. - */ -Commit.prototype.committer = function() { - return this.rawCommit.committer(); -}; - -/** - * Retrieve the tree for this commit. - * - * @param {Commit~getTreeCallback} callback + * Get the tree associated with this commit. */ Commit.prototype.getTree = function(callback) { - /** - * @callback Commit~getTreeCallback Callback executed on tree retrieval - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} Tree - */ - - var self = this; - this.rawCommit.tree(function(error, rawTree) { - if (error) return callback(error); - - callback(null, new git.tree(self.repo, rawTree)); - }); + this.repo.getTree(this.treeId(), callback); }; /** @@ -103,7 +37,7 @@ Commit.prototype.getTree = function(callback) { * @param {String} path * @param {Commit~fileCallback} callback */ -Commit.prototype.file = function(path, callback) { +Commit.prototype.getFile = function(path, callback) { /** * @callback Commit~fileCallback Callback executed on file retrieval. * @param {GitError|null} error An Error or null if successful. @@ -111,10 +45,8 @@ Commit.prototype.file = function(path, callback) { */ this.getTree(function (error, tree) { if (error) return callback(error); - tree.entry(path, function(error, entry) { - if (error) return callback(error); - callback(null, entry); - }); + + tree.getEntryByPath(path, callback); }); }; @@ -132,7 +64,7 @@ Commit.prototype.history = function() { var event = new events.EventEmitter(); var oid = this.oid(); - var revwalk = new git.revwalk(this.repo, this.repo.rawRepo.createRevWalk()); + var revwalk = this.repo.createRevWalk(); var commits = []; event.start = function() { revwalk.walk(oid, function commitRevWalk(error, commit) { @@ -170,24 +102,23 @@ Commit.prototype.history = function() { * * @param {Commit~parentsCallback} callback */ -Commit.prototype.parents = function(callback) { +Commit.prototype.getParents = function(callback) { /** * @callback Commit~parentsCallback Callback executed on parents retrieval. * @param {GitError|null} error An Error or null if successful. * @param {Commit[]|null} parents Commit's parent(s). */ var self = this; - - function processParents(rawCommit, n, acc, callback) { + function processParents(commit, n, acc, callback) { if (n < 0) return callback(null, acc); - rawCommit.parent(n, function nextParent(error, rawParentCommit) { + self.repo.getCommit(self.parentId(n), function nextParent(error, parent) { if (error) return callback(error); - processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback); + processParents(parent, n-1, acc.concat([parent]), callback); }); } - processParents(this.rawCommit, this.rawCommit.parentCount() - 1, [], callback); + processParents(this, this.parentCount() - 1, [], callback); }; /** @@ -196,14 +127,14 @@ Commit.prototype.parents = function(callback) { * * @param {Commit~parentsDiffTreesCallback} callback */ -Commit.prototype.parentsDiffTrees = function(callback) { +Commit.prototype.diff = function(callback) { /** * @callback Commit~parentsDiffTreesCallback Callback executed on diff trees retrieval. * @param {GitError|null} error An Error or null if successful. * @param {DiffList[]|null} diffLists Array of DiffTrees showing changes between this commit and its parent(s) */ var self = this; - self.parents(function commitParents(error, parents) { + self.getParents(function commitParents(error, parents) { if (error) return callback(error); var parentDiffLists = []; @@ -227,5 +158,3 @@ Commit.prototype.parentsDiffTrees = function(callback) { }); }); }; - -exports.commit = Commit; diff --git a/lib/diff_list.js b/lib/diff_list.js index afc9a27e8..17ff30230 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -1,19 +1,7 @@ var git = require('../'), + DiffList = git.DiffList, events = require('events'); -/** - * Convenience diff list class. - * - * @constructor - * @param {git.raw.DiffList} [rawDiffList = new git.raw.DiffList] - */ -var DiffList = function(rawDiffList) { - if (!(rawDiffList instanceof git.raw.DiffList)) { - throw new Error('Parameter for DiffList must be a raw difflist'); - } - this.rawDiffList = rawDiffList; -}; - /** * Refer to vendor/libgit2/include/git2/diff.h for delta type definitions. * @@ -56,58 +44,10 @@ DiffList.LineOrigin = { * @return {Array} patches */ DiffList.prototype.patches = function() { - var size = this.rawDiffList.size(); + var size = this.size(); result = []; for (var i = 0; i < size; i++) { - result.push(this.rawDiffList.patch(i)); + result.push(this.patch(i)); } return result; }; - -exports.diffList = DiffList; - -/** - * @namespace - * @property {Object} oldFile Contains details for the old file state - * @property {String} oldFile.path The path to the old file, relative to the repository - * @property {Object} newFile Contains details for the new file state - * @property {String} newFile.path The path to the new file, relative to the repository - * @property {Object[]} content Array of context & differences - * @property {Object} content[].range - * @property {Object} content[].range.old - * @property {Integer} content[].range.old.start - * @property {Integer} content[].range.old.lines - * @property {Object} content[].range.new - * @property {Integer} content[].range.new.start - * @property {Integer} content[].range.new.lines - * @property {Object} content[].content Content of the delta - * @property {DiffList.lineOriginTypes} content[].lineOrigin - * @property {Integer} content[].contentLength - * @property {Integer} status Type of delta - */ -var FileDelta = { - oldFile: { - path: String - }, - newFile: { - path: String - }, - content: [ - { - range: { - old: { - start: Number, - lines: Number - }, - 'new': { - start: Number, - lines: Number - } - }, - content: String, - lineOrigin: String, - contentLength: Number - } - ], - status: Number -}; diff --git a/lib/index.js b/lib/index.js index 641ee813b..af2f05255 100755 --- a/lib/index.js +++ b/lib/index.js @@ -9,30 +9,24 @@ if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { process.env.PATH = root + ':' + path; } -// Import libraries -exports.blob = require('./blob.js').blob; -exports.repo = require('./repo.js').repo; -exports.init = require('./repo.js').init; -exports.signature = require('./signature.js').signature; -exports.oid = require('./oid.js').oid; -exports.reference = require('./reference.js').reference; -exports.revwalk = require('./revwalk.js').revwalk; -exports.commit = require('./commit.js').commit; -exports.tree = require('./tree.js').tree; - // Assign raw api to module -try { - exports.raw = require('../build/Debug/nodegit'); -} catch (error) { - exports.raw = require('../build/Release/nodegit'); +var rawApi = require('../build/Release/nodegit'); +for (var key in rawApi) { + exports[key] = rawApi[key]; } -// Initialize objects that need to access their raw counterparts -exports.diffList = require('./diff_list.js').diffList; -exports.entry = require('./tree_entry.js').entry; +// Import extensions +require('./commit.js'); +require('./blob.js'); +require('./repo.js'); +require('./reference.js'); +require('./revwalk.js'); +require('./tree.js'); +require('./diff_list.js'); +require('./tree_entry.js'); // Set version exports.version = require('../package').version; // Initialize threads -exports.raw.Threads.init(); +exports.Threads.init(); diff --git a/lib/oid.js b/lib/oid.js deleted file mode 100644 index 44d876341..000000000 --- a/lib/oid.js +++ /dev/null @@ -1,37 +0,0 @@ -var git = require('../'); - -/** - * Convenience Oid constructor. - * - * @constructor - * @param {git.raw.Oid} [rawOid = new git.rawOid] Raw Oid object. - */ -var Oid = function(rawOid) { - this.rawOid = rawOid; -}; - -/** - * Create Oid object from string. - * - * @param {String} sha - */ -Oid.fromString = function(sha) { - var rawOid = git.raw.Oid.fromString(sha); - return new Oid(rawOid); -}; - -/** - * @return {git.raw.Oid} The wrapped raw Oid object. - */ -Oid.prototype.getRawOid = function() { - return this.rawOid; -}; - -/** - * Convert the raw Oid to a SHA - */ -Oid.prototype.sha = function() { - return this.rawOid.sha(); -}; - -exports.oid = Oid; diff --git a/lib/reference.js b/lib/reference.js index f7a15c67c..386b86e73 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -1,55 +1,7 @@ -var git = require('../'); - -/** - * Convenience reference constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo - * @param {git.raw.Reference} [rawReference = new git.raw.Reference()] - */ -var Reference = function(rawReference) { - if (!(rawReference instanceof git.raw.Reference)) { - throw new Error('First parameter for Reference must be a raw reference'); - } - this.rawReference = rawReference; -}; +var git = require('../'), + Reference = git.Reference; Reference.Type = { Oid: 0, Symbolic: 1 }; - -/** - * Lookup the reference with the given name. - * - * @param {String} name - * @param {Reference~lookupCallback} callback - */ -Reference.lookup = function(rawRepo, name, callback) { - /** - * @callback Reference~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Reference|null} reference Retrieved reference object or null. - */ - var self = this; - git.raw.Reference.lookup(rawRepo, name, function referenceLookup(error, rawReference) { - if (rawReference.type() == Reference.Type.Symbolic) { - rawReference.resolve(function referenceResolve(error, rawReference) { - if (error) return callback(error); - callback(null, new Reference(rawReference)); - }); - } else { - if (error) return callback(error); - callback(null, new Reference(rawReference)); - } - }); -}; - -/** - * Get the Oid representing this reference. - */ -Reference.prototype.oid = function() { - return this.rawReference.oid(); -}; - -exports.reference = Reference; diff --git a/lib/repo.js b/lib/repo.js index 962e9bb6d..0c379c6b0 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -1,56 +1,7 @@ -var git = require('../'); - -/** - * Convenience repository class. - * - * @constructor - */ -var Repo = function(rawRepo) { - this.rawRepo = rawRepo; -}; - -/** - * Initialise a git repository at directory. - * - * @param {String} directory - * @param {Boolean} isBare True if the repository is to be bare, false otherwise. - * @param {Repo~initCallback} callback - */ -Repo.init = function(directory, isBare, callback) { - /** - * @callback Repo~initCallback Callback executed when repository is initialized. - * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Initialized repository. - */ - git.raw.Repo.init(directory, isBare, function(error, rawRepo) { - if (error) return callback(error); - callback(null, new Repo(rawRepo)); - }); -}; - -/** - * Open the git repository at directory. - * - * @example - * git.repo('/path/to/repository/.git', function(error, repo) { }); - * - * @param {String} directory The .git directory for the repository to open. - * @param {Repo~openCallback} callback - */ -Repo.open = function(directory, callback) { - /** - * @callback Repo~openCallback Callback executed when repository is opened. - * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Opened repository. - */ - if (typeof callback !== 'function') { - throw new Error('Callback is required and must be a Function'); - } - git.raw.Repo.open(directory, function openRepository(error, rawRepo) { - if (error) return callback(error); - callback(null, new Repo(rawRepo)); - }); -}; +var git = require('../'), + util = require('./util.js'), + Repo = git.Repo, + Reference = git.Reference; /** * Look up a branch's most recent commit. @@ -58,24 +9,50 @@ Repo.open = function(directory, callback) { * @param {String} name Branch name, e.g. 'master' * @param {Repo~branchCallback} callback */ -Repo.prototype.branch = function(name, callback) { +Repo.prototype.getBranch = function(name, callback) { /** * @callback Repo~branchCallback Callback executed when the branch is checked out. * @param {GitError|null} error An Error or null if successful. * @param {Commit|null} repo HEAD commit for the branch. */ var self = this; - this.rawRepo.getReference('refs/heads/' + name, function referenceLookupCallback(error, reference) { + this.getReference('refs/heads/' + name, function referenceLookupCallback(error, reference) { if (error) return callback(error); - var oid = reference.oid(); - self.commit(oid, function commitLookupCallback(error, commit) { + self.getCommit(reference.oid(), function commitLookupCallback(error, commit) { if (error) return callback(error); callback(null, commit); }); }); }; +util.makeSafe(Repo.prototype, 'getBranch'); + +/** + * Lookup the reference with the given name. + * + * @param {String} name + * @param {Reference~lookupCallback} callback + */ +var oldGetReference = Repo.prototype.getReference; +Repo.prototype.getReference = function(name, callback) { + var self = this; + oldGetReference.call(this, name, function(error, reference) { + if (error) return callback(error); + + if (reference.type() == Reference.Type.Symbolic) { + reference.resolve(function (error, reference) { + if (error) return callback(error); + reference.repo = self; + callback(null, reference); + }); + } else { + reference.repo = self; + callback(null, reference); + } + }); +}; +util.makeSafe(Repo.prototype, 'getReference'); /** * Retrieve the commit identified by oid. @@ -83,60 +60,65 @@ Repo.prototype.branch = function(name, callback) { * @param {String|Oid} String sha or Oid * @param {Repo~commitCallback} callback */ -Repo.prototype.commit = function(oid, callback) { - /** - * @callback Repo~commitCallback Callback executed when the commit is looked up. - * @param {GitError|null} error An Error or null if successful. - * @param {Commit|null} commit Commit represented by sha. - */ +var oldGetCommit = Repo.prototype.getCommit; +Repo.prototype.getCommit = function(oid, callback) { var self = this; - try { - if (typeof oid === 'string') oid = git.raw.Oid.fromString(oid); - - this.rawRepo.getCommit(oid, function(error, rawCommit) { - if (error) return callback(error); - callback(null, new git.commit(self, rawCommit)); - }); - } catch (e) { - callback(e); - } + oldGetCommit.call(this, normalizeOid(oid), function(error, commit) { + if (error) return callback(error); + commit.repo = self; + callback(null, commit); + }); }; +util.makeSafe(Repo.prototype, 'getCommit'); /** * Retrieve the blob represented by the oid. * - * @param {git.Oid} oid The OID representing the blob to lookup. + * @param {String|Oid} String sha or Oid * @param {Blob~lookupCallback} callback */ -Repo.prototype.blob = function(oid, callback) { - /** - * @callback Blob~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob Retrieved blob object or null. - */ - this.rawRepo.getBlob(oid.rawOid, function blobLookup(error, rawBlob) { +var oldBlob = Repo.prototype.getBlob; +Repo.prototype.getBlob = function(oid, callback) { + var self = this; + oldBlob.call(this, normalizeOid(oid), function(error, blob) { if (error) return callback(error); - callback(null, new git.blob(rawBlob)); + blob.repo = self; + callback(null, blob); }); }; +util.makeSafe(Repo.prototype, 'blob'); /** - * Retrieve the raw tree identified by the given Oid. + * Retrieve the blob represented by the oid. * - * @param {Oid} oid The Oid identifying a tree. - * @param {Tree~lookupCallback} callback + * @param {String|Oid} String sha or Oid + * @param {Blob~lookupCallback} callback */ -Repo.prototype.tree = function(oid, callback) { - /** - * @callback Tree~lookupCallback Callback executed when the tree is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree The tree object or null. - */ +var oldGetTree = Repo.prototype.getTree; +Repo.prototype.getTree = function(oid, callback) { var self = this; - this.rawRepo.getTree(oid.rawOid, function(error, rawTree) { + oldGetTree.call(this, normalizeOid(oid), function(error, tree) { if (error) return callback(error); - callback(null, new git.tree(self, rawTree)); + tree.repo = self; + callback(null, tree); }); }; +util.makeSafe(Repo.prototype, 'getTree'); + +/** + * Retrieve the blob represented by the oid. + * + * @param {String|Oid} String sha or Oid + * @param {Blob~lookupCallback} callback + */ +var oldCreateRevWalk = Repo.prototype.createRevWalk; +Repo.prototype.createRevWalk = function() { + var revWalk = oldCreateRevWalk.call(this); + revWalk.repo = this; + return revWalk; +}; -exports.repo = Repo; +function normalizeOid(oid) { + if (typeof oid === 'string') oid = git.Oid.fromString(oid); + return oid; +} diff --git a/lib/revwalk.js b/lib/revwalk.js index d2fb4849f..1ae3b77da 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -1,24 +1,5 @@ -var git = require('../'); - -/** - * Convenience revision walking class - * - * @constructor - * @param {git.repo} repo - * @param {git.raw.RevWalk|null} rawRevWalk - */ -var RevWalk = function(repo, rawRevWalk) { - if (!(repo instanceof git.repo)) { - throw new Error('First parameter for RevWalk must be a repo'); - } - - if (!(rawRevWalk instanceof git.raw.RevWalk)) { - throw new Error('Second parameter for RevWalk must be a raw.RevWalk'); - } - - this.repo = repo; - this.rawRevWalk = rawRevWalk; -}; +var git = require('../'), + RevWalk = git.RevWalk; /** * Walk the history from the given oid. @@ -29,15 +10,15 @@ var RevWalk = function(repo, rawRevWalk) { */ RevWalk.prototype.walk = function(oid, callback) { var self = this; - this.rawRevWalk.push(oid.getRawOid(), function revWalkPush(error) { + this.push(oid, function revWalkPush(error) { if (error) return callback(error); function walk() { - self.rawRevWalk.next(function revWalkNext(error, oid) { + self.next(function revWalkNext(error, oid) { if (error) return callback(new git.error(error.message, error.code)); if (!oid) return callback(); - self.repo.commit(oid, function revWalkCommitLookup(error, commit) { + self.repo.getCommit(oid, function revWalkCommitLookup(error, commit) { if (error) return callback(new git.error(error.message, error.code)); callback(null, commit); @@ -48,5 +29,3 @@ RevWalk.prototype.walk = function(oid, callback) { walk(); }); }; - -exports.revwalk = RevWalk; diff --git a/lib/signature.js b/lib/signature.js deleted file mode 100644 index c33f91b13..000000000 --- a/lib/signature.js +++ /dev/null @@ -1,23 +0,0 @@ -var git = require('../'); - -var Signature = function(rawSignature) { - if (rawSignature instanceof git.raw.Signature) { - this.rawSignature = rawSignature; - } else { - this.rawSignature = new git.raw.Signature(); - } -}; - -Signature.prototype.name = function(callback) { - callback(null, this.rawSignature.name()); -}; - -Signature.prototype.email = function(callback) { - callback(null, this.rawSignature.email()); -}; - -Signature.prototype.duplicate = function(callback) { - callback(null, new Signature(git.rawSignature.duplicate())); -}; - -exports.signature = Signature; diff --git a/lib/tree.js b/lib/tree.js index 966e243ac..38cf9a573 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -1,63 +1,55 @@ var git = require('../'), + Tree = git.Tree, events = require('events'); /** - * Tree convenience class constructor. - * - * @constructor - * @param {git.Repo} repo repository object. - * @param {git.raw.Tree} [rawTree = new git.raw.Tree(rawRepo)] Raw tree object. + * Diff two trees */ -var Tree = function(repo, rawTree) { - if (!(repo instanceof git.repo)) { - throw new Error('First parameter for Tree must be a raw repo'); - } - - if (!(rawTree instanceof git.raw.Tree)) { - throw new Error('Second parameter for Tree must be a raw tree'); - } - - this.repo = repo; - this.rawTree = rawTree; +Tree.prototype.diff = function(that, callback) { + this.diffTree(this.repo, that, null, callback); }; /** - * Retrieve the entry by path. - * - * @param {String} path Path to the tree entry, relative to repository root. - * @param {Tree~entryCallback} callback + * Get an entry at the ith position. */ -Tree.prototype.entry = function(path, callback) { - /** - * @callback Tree~entryCallback Callback executed when an entry is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Entry|null} entry The tree entry object or null. - */ - var self = this; - self.rawTree.getEntryByPath(path, function(error, rawEntry) { - if (error) return callback(error); - callback(null, new git.entry(self.repo, rawEntry)); - }); +var oldEntryByIndex = Tree.prototype.entryByIndex; +Tree.prototype.entryByIndex = function(i) { + var entry = oldEntryByIndex.call(this, i); + entry.parent = this; + return entry; }; /** - * Retrieve the number of entries in this tree. + * Get an entry at the ith position. */ -Tree.prototype.size = function() { - return this.rawTree.size(); -}; +Tree.prototype.entry = Tree.prototype.entryByIndex; /** - * Diff two trees + * Get an entry at the ith position. */ -Tree.prototype.diff = function(that, callback) { - this.rawTree.diffTree(this.repo.rawRepo, that.rawTree, null, function(error, rawDiffList) { +var oldGetEntryByPath = Tree.prototype.getEntryByPath; +Tree.prototype.getEntryByPath = function(path, callback) { + var self = this; + oldGetEntryByPath.call(this, path, function(error, entry) { if (error) return callback(error); - callback(null, new git.diffList(rawDiffList)); + entry.parent = self; + callback(null, entry); }); }; +/** + * Return an array of the entries in this tree (excluding its children). + */ +Tree.prototype.entries = function() { + var size = this.size(), + result = []; + for (var i = 0; i < size; i++) { + result.push(this.entryByIndex(i)); + } + return result; +}; + /** * Walk the tree. * @@ -82,10 +74,7 @@ Tree.prototype.walk = function(blobsOnly) { total--; if (error) return errors.push(error); - var size = tree.rawTree.size(); - for (var i = 0; i < size; i ++) { - var rawEntry = tree.rawTree.entryByIndex(i), - entry = new git.entry(tree.repo, rawEntry); + tree.entries().forEach(function (entry) { if (!blobsOnly || entry.isFile()) { /** * Entry event. @@ -103,7 +92,7 @@ Tree.prototype.walk = function(blobsOnly) { total++; entry.getTree(dfs); } - } + }); if (total === 0) event.emit('end', errors.length ? errors : null, entries); } @@ -114,5 +103,3 @@ Tree.prototype.walk = function(blobsOnly) { return event; }; - -exports.tree = Tree; diff --git a/lib/tree_entry.js b/lib/tree_entry.js index f6e33c2b6..3aa85185f 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -1,25 +1,5 @@ var git = require('../'), - path = require('path'); - -/** - * Convenience tree entry constructor. - * - * @constructor - * @param {git.Repo} repo Repo object. - * @param {git.raw.TreeEntry} rawTreeEntry Raw tree entry object. - */ -var TreeEntry = function(repo, rawTreeEntry) { - if(!(repo instanceof git.repo)) { - throw new Error('First parameter for Tree Entry must be a repo', 0); - } - - if(!(rawTreeEntry instanceof git.raw.TreeEntry)) { - throw new Error('Second parameter for Tree Entry must be a raw tree entry', 0); - } - - this.repo = repo; - this.rawEntry = rawTreeEntry; -}; + TreeEntry = git.TreeEntry; /** * Refer to vendor/libgit2/include/git2/types.h for filemode definitions. @@ -47,13 +27,6 @@ TreeEntry.prototype.isTree = function() { TreeEntry.prototype.isDirectory = TreeEntry.prototype.isTree; -/** - * Retrieve the Oid for this TreeEntry. - */ -TreeEntry.prototype.oid = function(callback) { - return new git.oid(this.rawEntry.oid()); -}; - /** * Retrieve the SHA for this TreeEntry. */ @@ -62,48 +35,15 @@ TreeEntry.prototype.sha = function() { }; /** - * Retrieve the SHA for this TreeEntry. - */ -TreeEntry.prototype.filemode = function() { - return this.rawEntry.filemode(); -}; - -/** - * Retrieve the name for this TreeEntry. + * Retrieve the tree for this entry. */ -TreeEntry.prototype.name = function() { - return this.rawEntry.name(); +TreeEntry.prototype.getTree = function(callback) { + this.parent.repo.getTree(this.oid(), callback); }; /** - * Convert the TreeEntry to a blob. - * - * @param {TreeEntry~blobCallback} callback + * Retrieve the tree for this entry. */ TreeEntry.prototype.getBlob = function(callback) { - if (!this.isFile()) return callback(new git.error('Not a blob/file', 0)); - - /** - * @callback TreeEntry~blobCallback Callback executed after blob is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob the blob representation of the entry. - */ - this.repo.blob(this.oid(), callback); + this.parent.repo.getBlob(this.oid(), callback); }; - -/** - * Convert the TreeEntry to a tree. - * - * @param {TreeEntry~treeCallback} callback - */ -TreeEntry.prototype.getTree = function(callback) { - if (!this.isTree()) return callback(new git.error('Not a tree/directory', 0)); - /** - * @callback TreeEntry~treeCallback Callback executed after blob is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} blob the blob representation of the entry. - */ - this.repo.tree(this.oid(), callback); -}; - -exports.entry = TreeEntry; diff --git a/lib/util.js b/lib/util.js new file mode 100644 index 000000000..9fd5fd5a4 --- /dev/null +++ b/lib/util.js @@ -0,0 +1,11 @@ +exports.makeSafe = function(object, key) { + var oldFn = object[key]; + object[key] = function() { + try { + oldFn.apply(this, arguments); + } catch (e) { + var callback = arguments[arguments.length - 1]; + callback(e); + } + }; +}; diff --git a/src/commit.cc b/src/commit.cc index 6bd308faf..f1026e259 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -39,7 +39,6 @@ void GitCommit::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); NODE_SET_PROTOTYPE_METHOD(tpl, "committer", Committer); NODE_SET_PROTOTYPE_METHOD(tpl, "author", Author); - NODE_SET_PROTOTYPE_METHOD(tpl, "tree", Tree); NODE_SET_PROTOTYPE_METHOD(tpl, "treeId", TreeId); NODE_SET_PROTOTYPE_METHOD(tpl, "parentCount", ParentCount); NODE_SET_PROTOTYPE_METHOD(tpl, "parent", Parent); @@ -166,69 +165,6 @@ Handle GitCommit::Author(const Arguments& args) { return scope.Close(to); } -Handle GitCommit::Tree(const Arguments& args) { - HandleScope scope; - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TreeBaton* baton = new TreeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->commitReference = Persistent::New(args.This()); - baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, TreeWork, (uv_after_work_cb)TreeAfterWork); - - return Undefined(); -} - -void GitCommit::TreeWork(uv_work_t *req) { - TreeBaton *baton = static_cast(req->data); - int result = git_commit_tree( - &baton->tree_out, - baton->commit - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitCommit::TreeAfterWork(uv_work_t *req) { - HandleScope scope; - TreeBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitTree::New((void *)baton->tree_out); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->commitReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; diff --git a/test/blob.js b/test/blob.js new file mode 100644 index 000000000..b79adb69b --- /dev/null +++ b/test/blob.js @@ -0,0 +1,13 @@ +var git = require('../'), + path = require('path'); + +exports.content = function(test) { + var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'); + test.expect(1); + git.Repo.open(path.resolve('../.git'), function(err, repo) { + repo.getBlob(testOid, function(err, blob) { + test.equals(blob.toString().slice(0, 7), "@import"); + test.done(); + }); + }); +}; diff --git a/test/convenience-commit.js b/test/commit.js similarity index 65% rename from test/convenience-commit.js rename to test/commit.js index daaa75d9a..1549f271a 100644 --- a/test/convenience-commit.js +++ b/test/commit.js @@ -4,40 +4,10 @@ var git = require('../'), var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Test that the commit object is present. - */ -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.commit, 'Commmit'); - test.done(); -}; - exports.message = function(test) { test.expect(3); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var message = commit.message(); test.equals(error, null, 'There should be no error'); test.notEqual(message, null, 'Message should not be null'); @@ -49,8 +19,8 @@ exports.message = function(test) { exports.sha = function(test) { test.expect(3); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var sha = commit.sha(); test.equals(error, null, 'There should be no error'); test.notEqual(sha, null, 'SHA should not be null'); @@ -62,9 +32,9 @@ exports.sha = function(test) { exports.time = function(test) { test.expect(3); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - var time = commit.time(); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var time = commit.timeMs(); test.equals(error, null, 'There should be no error'); test.notEqual(time, null, 'Time should not be null'); test.equals(time, 1362012884000, 'Time should match expected value'); @@ -75,8 +45,8 @@ exports.time = function(test) { exports.date = function(test) { test.expect(4); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var date = commit.date(); test.equals(error, null, 'There should be no error'); test.notEqual(date, null, 'Date should not be null'); @@ -89,8 +59,8 @@ exports.date = function(test) { exports.offset = function(test) { test.expect(3); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var offset = commit.offset(); test.equals(error, null, 'There should be no error'); test.notEqual(offset, null, 'Offset should not be null'); @@ -102,8 +72,8 @@ exports.offset = function(test) { exports.author = function(test) { test.expect(2); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var author = commit.author(); test.equals(error, null, 'There should be no error'); test.notEqual(author, null, 'Author should not be null'); @@ -114,8 +84,8 @@ exports.author = function(test) { exports.authorName = function(test) { test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var author = commit.author(); var name = author.name(); test.equals(name, 'Michael Robinson', 'The author name should match expected value'); @@ -126,8 +96,8 @@ exports.authorName = function(test) { exports.authorEmail = function(test) { test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var author = commit.author(); var email = author.email(); test.equals(email, 'mike@panmedia.co.nz', 'The author email should match expected value'); @@ -138,8 +108,8 @@ exports.authorEmail = function(test) { exports.committerName = function(test) { test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var committer = commit.committer(); var name = committer.name(); test.equals(name, 'Michael Robinson', 'The author name should match expected value'); @@ -150,8 +120,8 @@ exports.committerName = function(test) { exports.committerEmail = function(test) { test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { var committer = commit.committer(); var email = committer.email(); test.equals(email, 'mike@panmedia.co.nz', 'The committer email should match expected value'); @@ -165,8 +135,8 @@ exports.committerEmail = function(test) { */ exports.improperCommitId = function(test) { test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit('not a proper commit sha', function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit('not a proper commit sha', function(error, commit) { test.notEqual(error, null, 'Error should occur'); test.done(); }); @@ -178,8 +148,8 @@ exports.improperCommitId = function(test) { */ exports.history = function(test) { test.expect(368); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { test.equals(null, error, 'Getting latest branch commit should not error'); var historyCount = 0; var expectedHistoryCount = 364; @@ -200,12 +170,11 @@ exports.history = function(test) { * Test that retreiving master branch's HEAD commit works as expected. */ exports.masterHead = function(test) { - test.expect(2); - git.repo.open('../.git', function(error, repository) { - repository.branch('master', function(error, branch) { - test.equals(error, null, 'Getting branch should not error'); + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getBranch('master', function(error, branch) { var sha = branch.sha(); - repository.commit(sha, function(error, commit) { + repository.getCommit(sha, function(error, commit) { test.equals(error, null, 'Getting latest branch commit should not error'); test.done(); }); @@ -220,9 +189,9 @@ exports.masterHead = function(test) { */ exports.parents = function(test) { test.expect(3); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parents(function(error, parents) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + commit.getParents(function(error, parents) { test.equals(parents.length, 1, 'Commit should have exactly one parent'); var sha = parents[0].sha(); test.equals(error, null, 'Getting parent SHA should not error'); @@ -238,8 +207,8 @@ exports.parents = function(test) { */ exports.tree = function(test) { test.expect(2); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { test.equals(error, null, 'Getting latest branch commit should not error'); var commitTreeEntryCount = 0; @@ -261,9 +230,9 @@ exports.tree = function(test) { */ exports.parentsDiffTrees = function(test) { test.expect(1); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parentsDiffTrees(function(error, parentsDiffTrees) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + commit.diff(function(error, parentsDiffTrees) { test.equals(parentsDiffTrees.length, 1, 'Should be one item in parents diff trees'); test.done(); }); diff --git a/test/convenience-oid.js b/test/convenience-oid.js deleted file mode 100644 index 408bce34c..000000000 --- a/test/convenience-oid.js +++ /dev/null @@ -1,37 +0,0 @@ -var git = require('../'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.commit, 'Oid'); - test.done(); -}; - -var knownSha = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; - -exports.fromStringAndSha = function(test) { - test.expect(1); - var oid = git.oid.fromString(knownSha); - test.equal(oid.sha(), knownSha, 'SHA should match known value'); - test.done(); -}; diff --git a/test/convenience-repo.js b/test/convenience-repo.js deleted file mode 100644 index 0567e1f2b..000000000 --- a/test/convenience-repo.js +++ /dev/null @@ -1,84 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require( 'fs' ); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } catch (ex) { - test(true, label); - } - } -}; - -/** - * Repo - * Ensure the repo method can handle opening repositories with async/sync - * signatures properly. - */ -exports.method = function(test){ - test.expect(5); - - helper.testFunction(test.equals, git.repo, 'Repo'); - - // Test callback argument existence - helper.testException(test.ok, function() { - git.repo.open('some/path'); - }, 'Throw an exception if no callback'); - - // Test invalid repository - git.repo.open('/etc/hosts', function(error, repository) { - test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); - - // Test valid repository - git.repo.open('../.git', function(error, repository) { - test.equals(null, error, 'Valid repository error code'); - test.done(); - }); - }); -}; - -/** - * Ensure repo doesn't attempt to open missing directories - */ -exports.nonexistentDirectory = function(test) { - test.expect(2); - git.repo.open('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { - test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); - test.equals(repository, null, 'Non existent directory should result in null repository'); - test.done(); - }); -}; - -/** - * Ensure the init method can create repositories at the destination path and - * can create either bare/non-bare. - */ -exports.init = function(test) { - test.expect(2); - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // Create bare repo and test for creation - git.repo.init('./test.git', true, function(error, path, isBare) { - test.equals(null, error, 'Successfully created bare repository'); - // Verify repo exists - git.repo.open('./test.git', function(error, path, repo) { - test.equals(null, error, 'Valid repository created'); - - // Cleanup, remove test repo directory - rimraf('./test.git', test.done); - }); - }); - }); -}; diff --git a/test/convenience-difflist.js b/test/difflist.js similarity index 70% rename from test/convenience-difflist.js rename to test/difflist.js index 82b98ea65..12fcd54b2 100644 --- a/test/convenience-difflist.js +++ b/test/difflist.js @@ -4,36 +4,6 @@ var git = require('../'), var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Test that the commit object is present. - */ -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.diffList, 'DiffList'); - test.done(); -}; - /** * Test that retreiving parent works as expected. * @@ -41,9 +11,9 @@ exports.method = function(test){ */ exports.walkingDiffs = function(test) { test.expect(16); - git.repo.open('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parents(function(error, parents) { + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + commit.getParents(function(error, parents) { parents[0].getTree(function(error, parentTree) { commit.getTree(function(error, commitTree) { parentTree.diff(commitTree, function(error, diffList) { @@ -58,20 +28,20 @@ exports.walkingDiffs = function(test) { var hunk = patch.hunk(0); test.equal(hunk.lines, 5, 'Content array should be of known length'); - test.equal(delta.status(), git.diffList.Delta.Modified, 'Status should be known type'); + test.equal(delta.status(), git.DiffList.Delta.Modified, 'Status should be known type'); - test.equal(patch.line(0, 0).lineOrigin, git.diffList.LineOrigin.Context, 'First content item should be context'); - test.equal(patch.line(0, 1).lineOrigin, git.diffList.LineOrigin.Context, 'Second content item should be context'); - test.equal(patch.line(0, 2).lineOrigin, git.diffList.LineOrigin.Context, 'Third content item should be context'); + test.equal(patch.line(0, 0).lineOrigin, git.DiffList.LineOrigin.Context, 'First content item should be context'); + test.equal(patch.line(0, 1).lineOrigin, git.DiffList.LineOrigin.Context, 'Second content item should be context'); + test.equal(patch.line(0, 2).lineOrigin, git.DiffList.LineOrigin.Context, 'Third content item should be context'); var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; test.equal(patch.line(0, 3).content, oldContent, 'Old content should match known value'); - test.equal(patch.line(0, 3).lineOrigin, git.diffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); + test.equal(patch.line(0, 3).lineOrigin, git.DiffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); test.equal(patch.line(0, 3).length, 90, 'Fourth content length should match known value'); var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; test.equal(patch.line(0, 4).content, newContent, 'New content should match known value'); - test.equal(patch.line(0, 4).lineOrigin, git.diffList.LineOrigin.Addition, 'Fifth content item should be addition'); + test.equal(patch.line(0, 4).lineOrigin, git.DiffList.LineOrigin.Addition, 'Fifth content item should be addition'); test.equal(patch.line(0, 4).length, 162, 'Fifth content length should match known value'); test.done(); }); diff --git a/test/convenience-entry.js b/test/entry.js similarity index 81% rename from test/convenience-entry.js rename to test/entry.js index d68165755..57235aa71 100644 --- a/test/convenience-entry.js +++ b/test/entry.js @@ -3,11 +3,9 @@ var git = require('../'); var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; var getEntry = function(path, callback) { - git.repo.open('../.git', function(error, repo) { - repo.commit(sha, function(error, commit) { - commit.file(path, function(error, entry) { - callback(error, entry); - }); + git.Repo.open('../.git', function(error, repo) { + repo.getCommit(sha, function(error, commit) { + commit.getFile(path, callback); }); }); }; @@ -46,11 +44,9 @@ exports.isFile = function(test) { exports.isDirectory = function(test) { test.expect(2); getEntry('example', function(error, entry) { - var isFile = entry.isFile(); - test.equal(isFile, false, 'Entry is a directory'); + test.equal(entry.isFile(), false, 'Entry is a directory'); getEntry('README.md', function(error, entry) { - var isFile = entry.isFile() - test.equal(isFile, true, 'Entry is a file'); + test.equal(entry.isFile(), true, 'Entry is a file'); test.done(); }); }); @@ -80,7 +76,7 @@ exports.getTree = function(test) { test.expect(1); getEntry('test', function(error, entry) { entry.getTree(function(error, tree) { - test.equal(tree instanceof git.tree, true, 'Expected instance of Tree'); + test.equal(tree instanceof git.Tree, true, 'Expected instance of Tree'); test.done(); }); }); diff --git a/test/oid.js b/test/oid.js new file mode 100644 index 000000000..3ce3d48d1 --- /dev/null +++ b/test/oid.js @@ -0,0 +1,10 @@ +var git = require('../'); + +var knownSha = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; + +exports.fromStringAndSha = function(test) { + test.expect(1); + var oid = git.Oid.fromString(knownSha); + test.equal(oid.sha(), knownSha, 'SHA should match known value'); + test.done(); +}; diff --git a/test/raw-blob.js b/test/raw-blob.js deleted file mode 100644 index f7dee10d7..000000000 --- a/test/raw-blob.js +++ /dev/null @@ -1,87 +0,0 @@ -var git = require('../').raw, - path = require('path'), - rimraf = require('rimraf'); - -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Blob constructor - */ -exports.constructor = function(test){ - test.expect(3); - helper.testFunction(test.equals, git.Blob, 'Blob'); - test.throws(function() { new git.Blob(); }); - test.done(); -}; - -// Blob::Lookup -exports.lookup = function(test) { - test.expect(1); - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); - - git.Repo.open('../.git', function(error, repo) { - // Test Callback argument existence - helper.testException(test.ok, function() { - repo.getBlob(testOid); - }, 'Throw an exception if no callback Object'); - - test.done(); - }); -}; - -// Blob::RawContent -exports.rawContent = function(test) { - // This shouldn't fail unless someone rewrites history: - var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'); - test.expect(3); - git.Repo.open(path.resolve('../.git'), function(err, repo) { - repo.getBlob(testOid, function(err, blob) { - // Test for function - helper.testFunction(test.equals, blob.content, 'Blob::RawContent'); - test.equals(blob.content().toBuffer(7).toString(), "@import"); - - test.done(); - }); - }); -}; - -// Blob::CreateFromFile -exports.createFromFile = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, git.Blob.createFromFile, 'Blob::CreateFromFile'); - - test.done(); -}; - -// Blob::CreateFromBuffer -exports.createFromBuffer = function(test) { - var testOid = git.Oid.fromString('fce88902e66c72b5b93e75bdb5ae717038b221f6'); - test.expect(2); - - // Test for function - helper.testFunction(test.equals, git.Blob.createFromBuffer, 'Blob::CreateFromBuffer'); - - test.done(); -}; diff --git a/test/raw-commit.js b/test/raw-commit.js deleted file mode 100644 index f3f8dc21e..000000000 --- a/test/raw-commit.js +++ /dev/null @@ -1,47 +0,0 @@ -var git = require('../').raw; - -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Commit::Lookup - */ -exports.lookup = function(test) { - test.expect(3); - - var testOid = git.Oid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762'); - - git.Repo.open('../.git', function(error, repo) { - // Test oid argument existence - helper.testException(test.ok, function() { - repo.getCommit(); - }, 'Throw an exception if no oid'); - - // Test that all arguments result correctly - helper.testException(test.ifError, function() { - repo.getCommit(testOid, function() {}); - }, 'No exception is thrown with proper arguments'); - // Test valid commit - repo.getCommit(testOid, function(err) { - test.equal(null, err, 'Valid commit'); - test.done(); - }); - }); -}; diff --git a/test/raw-oid.js b/test/raw-oid.js deleted file mode 100644 index 4b12e5c28..000000000 --- a/test/raw-oid.js +++ /dev/null @@ -1,71 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Oid -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Oid, 'Oid'); - - // Ensure we get an instance of Oid - test.throws(function() { new git.Oid(); }, 'Cannot instantiate an Oid directly'); - - test.done(); -}; - -// Oid::FromString -exports.fromString = function(test) { - test.expect(6); - - // Test for function - helper.testFunction(test.equals, git.Oid.fromString, 'Oid::FromString'); - - // Test path argument existence - helper.testException(test.ok, function() { - git.Oid.fromString(); - }, 'Throw an exception if no hex String'); - - // Test that both arguments result correctly - test.throws(function() { git.Oid.fromString("somestr", function() {}); }); - - // Test valid hex id string - test.throws(function() { git.Oid.fromString('1392DLFJIOS'); }); - test.doesNotThrow(function() { git.Oid.fromString('1810DFF58D8A660512D4832E740F692884338CCD'); }); - test.done(); -}; - -// Oid::Sha -exports.sha = function(test) { - test.expect(3); - var sha = '1810DFF58D8A660512D4832E740F692884338CCD'; - var testOid = git.Oid.fromString(sha); - - // Test for function - helper.testFunction(test.equals, testOid.sha, 'Oid::Sha'); - - // Test valid hex id string - test.equals(sha, testOid.sha().toUpperCase(), 'Valid hex id String'); - test.done(); -}; diff --git a/test/raw-reference.js b/test/raw-reference.js deleted file mode 100644 index 29a36f2bc..000000000 --- a/test/raw-reference.js +++ /dev/null @@ -1,71 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Ref -exports.constructor = function(test){ - test.expect(2); - - // Test for function - helper.testFunction(test.equals, git.Reference, 'Reference'); - - test.done(); -}; - -// Ref::Lookup -exports.lookup = function(test) { - - test.expect(2); - - git.Repo.open('../.git', function(error, repo) { - // Test name argument existence - helper.testException(test.ok, function() { - repo.getReference(); - }, 'Throw an exception if no name'); - - // Test callback argument existence - helper.testException(test.ok, function() { - repo.getReference('refs/heads/master'); - }, 'Throw an exception if no callback'); - - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // // Create bare repo and test for creation - // repo.init('./test.git', true, function(err, path, is_bare) { - // test.equals(0, err, 'Successfully created bare repository'); - // // Verify repo exists - // repo.open('./test.git', function(err, path) { - // test.equals(0, err, 'Valid repository created'); - // test.equals(true, is_bare, 'Returns valid is_bare value'); - - // repo.free(); - - // // Cleanup, remove test repo directory - // rimraf('./test.git', function() { - test.done(); - // }); - // }); - // }); - }); - }); -}; diff --git a/test/raw-repo.js b/test/raw-repo.js deleted file mode 100644 index 532687f8b..000000000 --- a/test/raw-repo.js +++ /dev/null @@ -1,98 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'), - path = require('path'), - fs = require('fs'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Repo -exports.open = function(test){ - test.expect(9); - - // Test for function - helper.testFunction(test.equals, git.Repo, 'Repo'); - - // Test for function - helper.testFunction(test.equals, git.Repo.open, 'Repo::Open'); - - // Test path argument existence - helper.testException(test.ok, function() { - git.Repo.open(); - }, 'Throw an exception if no path'); - - // Test callback argument existence - helper.testException(test.ok, function() { - git.Repo.open('some/path'); - }, 'Throw an exception if no callback'); - - // Test invalid repository - git.Repo.open('/etc/hosts', function(error) { - test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); - - // Test valid repository - git.Repo.open(path.resolve('../.git'), function(error, repo) { - test.ok(repo instanceof git.Repo, 'Invocation returns an instance of Repo'); - test.equals(null, error, 'Valid repository error code'); - test.done(); - }); - }); -}; - -// Repo::Init -exports.init = function(test) { - test.expect(7); - - // Test for function - helper.testFunction(test.equals, git.Repo.init, 'Repo::Init'); - - // Test path argument existence - helper.testException(test.ok, function() { - git.Repo.init(); - }, 'Throw an exception if no path'); - - // Test is_bare argument existence - helper.testException(test.ok, function() { - git.Repo.init("some/path"); - }, 'Throw an exception if no is_bare'); - - // Test callback argument existence - helper.testException(test.ok, function() { - git.Repo.init("some/path", true); - }, 'Throw an exception if no callback'); - - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // Create bare repo and test for creation - git.Repo.init('./test.git', true, function(error, path, is_bare) { - test.equals(null, error, 'Successfully created bare repository'); - // Verify repo exists - git.Repo.open('./test.git', function(error, path) { - test.equals(null, error, 'Valid repository created'); - - // Cleanup, remove test repo directory - rimraf('./test.git', function() { - test.done(); - }); - }); - }); - }); -}; diff --git a/test/reference.js b/test/reference.js new file mode 100644 index 000000000..f7e2bb1f2 --- /dev/null +++ b/test/reference.js @@ -0,0 +1,14 @@ +var git = require('../'), + rimraf = require('rimraf'); + +// Ref::Lookup +exports.lookup = function(test) { + test.expect(1); + + git.Repo.open('../.git', function(error, repo) { + repo.getReference('refs/heads/master', function(error, reference) { + test.ok(reference instanceof git.Reference); + test.done(); + }); + }); +}; diff --git a/test/repo.js b/test/repo.js new file mode 100644 index 000000000..2c63f3455 --- /dev/null +++ b/test/repo.js @@ -0,0 +1,57 @@ +var git = require('../'), + rimraf = require('rimraf'), + fs = require( 'fs' ); + +/** + * Repo + * Ensure the repo method can handle opening repositories with async/sync + * signatures properly. + */ +exports.open = function(test){ + test.expect(2); + + // Test invalid repository + git.Repo.open('/etc/hosts', function(error, repository) { + test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); + + // Test valid repository + git.Repo.open('../.git', function(error, repository) { + test.equals(null, error, 'Valid repository error code'); + test.done(); + }); + }); +}; + +/** + * Ensure repo doesn't attempt to open missing directories + */ +exports.nonexistentDirectory = function(test) { + test.expect(2); + git.Repo.open('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { + test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); + test.equals(repository, null, 'Non existent directory should result in null repository'); + test.done(); + }); +}; + +/** + * Ensure the init method can create repositories at the destination path and + * can create either bare/non-bare. + */ +exports.init = function(test) { + test.expect(2); + // Cleanup, remove test repo directory - if it exists + rimraf('./test.git', function() { + // Create bare repo and test for creation + git.Repo.init('./test.git', true, function(error, path, isBare) { + test.equals(null, error, 'Successfully created bare repository'); + // Verify repo exists + git.Repo.open('./test.git', function(error, path, repo) { + test.equals(null, error, 'Valid repository created'); + + // Cleanup, remove test repo directory + rimraf('./test.git', test.done); + }); + }); + }); +}; diff --git a/test/raw-revwalk.js b/test/revwalk.js similarity index 100% rename from test/raw-revwalk.js rename to test/revwalk.js diff --git a/test/convenience-tree.js b/test/tree.js similarity index 89% rename from test/convenience-tree.js rename to test/tree.js index f91d6ad34..f4a5e2d85 100644 --- a/test/convenience-tree.js +++ b/test/tree.js @@ -8,8 +8,8 @@ var fileCount = 512; // Number of blob & blob executabless exports.walk = function(test) { test.expect(515); - git.repo.open('../.git', function(error, repo) { - repo.commit(sha, function(error, commit) { + git.Repo.open('../.git', function(error, repo) { + repo.getCommit(sha, function(error, commit) { var entryCount = 0; commit.getTree(function(error, tree) { tree.walk().on('entry', function(index, entry) { diff --git a/v0.18.0.json b/v0.18.0.json index 63eb44a5b..c20489b0f 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -1247,11 +1247,12 @@ "isSelf": true } ], + "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "tree", - "cppFunctionName": "Tree", + "jsFunctionName": "getTree", + "cppFunctionName": "GetTree", "return": { "cType": "int", "cppClassName": "Int32", @@ -1325,6 +1326,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, From 698c74e817243efe441a5d1f3cbaf3998282ca86 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 3 Jul 2013 12:33:09 +0200 Subject: [PATCH 18/28] GitOdb --- TODO | 3 + binding.gyp | 2 + example/general.js | 292 +++++++++++++++++++++++++++++++++++ include/commit.h | 15 -- include/odb.h | 48 ++++++ include/odb_object.h | 41 +++++ include/tree.h | 8 +- lib/commit.js | 2 +- lib/tree.js | 6 +- src/base.cc | 4 + src/commit.cc | 72 --------- src/odb.cc | 352 +++++++++++++++++++++++++++++++++++++++++++ src/odb_object.cc | 119 +++++++++++++++ src/tree.cc | 16 +- v0.18.0.json | 182 ++++++++++++---------- 15 files changed, 982 insertions(+), 180 deletions(-) create mode 100644 example/general.js create mode 100644 include/odb.h create mode 100644 include/odb_object.h create mode 100644 src/odb.cc create mode 100644 src/odb_object.cc diff --git a/TODO b/TODO index 860e3013f..f8113efd8 100644 --- a/TODO +++ b/TODO @@ -2,3 +2,6 @@ - audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. - rename files remove .h - Cleanup diff api +- free everything malloc'd +- codegen documentation +- extract out more partials diff --git a/binding.gyp b/binding.gyp index 16fc5e64c..f283a8069 100644 --- a/binding.gyp +++ b/binding.gyp @@ -27,6 +27,8 @@ 'src/threads.cc', 'src/wrapper.cc', 'src/refdb.cc', + 'src/odb_object.cc', + 'src/odb.cc', 'src/submodule.cc' ], diff --git a/example/general.js b/example/general.js new file mode 100644 index 000000000..991c06b7b --- /dev/null +++ b/example/general.js @@ -0,0 +1,292 @@ +var git = require('nodegit'); + +git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { + if (error) throw error; + + // ### SHA-1 Value Conversions + + // The `git_oid` is the structure that keeps the SHA value. We will use + // this throughout the example for storing the value of the current SHA + // key we're working with. + var oid = git.Oid.fromString('fd6e612585290339ea8bf39c692a7ff6a29cb7c3'); + + // If you have a oid, you can easily get the hex value of the SHA as well. + console.log(oid.sha()); + + // ### Working with the Object Database + + // **libgit2** provides [direct access][odb] to the object database. The + // object database is where the actual objects are stored in Git. For + // working with raw objects, we'll need to get this structure from the + // repository. + var odb = repo.odb(); + + // We can read raw objects directly from the object database if we have + // the oid (SHA) of the object. This allows us to access objects without + // knowing thier type and inspect the raw bytes unparsed. + + odb.read(oid, function(error, object) { + if (error) throw error; + + // A raw object only has three properties - the type (commit, blob, tree + // or tag), the size of the raw data and the raw, unparsed data itself. + // For a commit or tag, that raw data is human readable plain ASCII + // text. For a blob it is just file contents, so it could be text or + // binary data. For a tree it is a special binary format, so it's unlikely + // to be hugely helpful as a raw object. + var data = object.data(), + type = object.type(); + + console.log(object.size(), object.type()); + }); + + // You can also write raw object data to Git. This is pretty cool because + // it gives you direct access to the key/value properties of Git. Here + // we'll write a new blob object that just contains a simple string. + // Notice that we have to specify the object type as the `git_otype` enum. + odb.write("test data", git.Object.Type.Blob, function(error, oid) { + if (error) throw error; + + // Now that we've written the object, we can check out what SHA1 was + // generated when the object was written to our database. + console.log(oid.sha()); + }); + + // ### Object Parsing + + // libgit2 has methods to parse every object type in Git so you don't have + // to work directly with the raw data. This is much faster and simpler + // than trying to deal with the raw data yourself. + + // #### Commit Parsing + + // [Parsing commit objects][pco] is simple and gives you access to all the + // data in the commit - the author (name, email, datetime), committer + // (same), tree, message, encoding and parent(s). + + oid = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); + repo.getCommit(oid, function(error, commit) { + if (error) throw error; + + // Each of the properties of the commit object are accessible via methods, + // including commonly needed variations, such as `git_commit_time` which + // returns the author time and `git_commit_message` which gives you the + // commit message (as a NUL-terminated string). + console.log(commit.message(), commit.author(), commit.committer(), commit.time()); + + // Commits can have zero or more parents. The first (root) commit will + // have no parents, most commits will have one (i.e. the commit it was + // based on) and merge commits will have two or more. Commits can + // technically have any number, though it's rare to have more than two. + commit.getParents(function(error, parents) { + parents.forEach(function(parent) { + console.log(parent.oid()); + }); + }); + }); + + // #### Writing Commits + + // libgit2 provides a couple of methods to create commit objects easily as + // well. There are four different create signatures, we'll just show one + // of them here. You can read about the other ones in the [commit API + // docs][cd]. + // + // [cd]: http://libgit2.github.com/libgit2/#HEAD/group/commit + + var author = new git.Signature("Scott Chacon", "schacon@gmail.com", 123456789, 60); + var committer = new git.Signature("Scott A Chacon", "scott@github.com", 987654321, 90); + + // Commit objects need a tree to point to and optionally one or more + // parents. Here we're creating oid objects to create the commit with, + // but you can also use existing ones: + var treeId = git.Oid.fromString("28873d96b4e8f4e33ea30f4c682fd325f7ba56ac"); + var parentId = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); + + repo.getTree(treeId, function(error, tree) { + repo.getCommit(parentId, function(error, parent) { + + // Here we actually create the commit object with a single call with all + // the values we need to create the commit. The SHA key is written to the + // `commit_id` variable here. + repo.createCommit( + null /* do not update the HEAD */, + author, + committer, + null /* use default message encoding */, + "example commit", + tree, + 1, parent, + function (error, commitOid) { + console.log(commitOid.sha()); + }); + }); + }); + + // #### Tag Parsing + + // You can parse and create tags with the [tag management API][tm], which + // functions very similarly to the commit lookup, parsing and creation + // methods, since the objects themselves are very similar. + + var oid = git.Oid.fromString("bc422d45275aca289c51d79830b45cecebff7c3a"); + repo.getTag(oid, function(error, tag) { + if (error) throw error; + + // Now that we have the tag object, we can extract the information it + // generally contains: the target (usually a commit object), the type of + // the target object (usually 'commit'), the name ('v1.0'), the tagger (a + // git_signature - name, email, timestamp), and the tag message. + console.log(tag.name(), tag.type(), tag.message()); + + tag.getTarget(function (error, commit) { + if (error) throw error; + console.log(commit); + }); + }); + + // #### Tree Parsing + + // [Tree parsing][tp] is a bit different than the other objects, in that + // we have a subtype which is the tree entry. This is not an actual + // object type in Git, but a useful structure for parsing and traversing + // tree entries. + + var oid = git.Oid.fromString("2a741c18ac5ff082a7caaec6e74db3075a1906b5"); + repo.getTree(oid, function(error, tree) { + if (error) throw error; + + console.log(tree.size()); + tree.entries().forEach(function(entry) { + console.log(entry.name()); + + if (entry.isDirectory()) { + entry.getTree(function(error, tree) { + if (error) throw error; + + console.log("Recursively got tree"); + }); + } else { + entry.getBlob(function(error, blob) { + console.log(blob.toString()); + }); + } + }); + + // You can also access tree entries by path if you know the path of the + // entry you're looking for. + tree.getFile("/src/hello.c", function(error, entry) { + entry.getBlob(function(error, blob) { + console.log(blob.toString()); + }); + }); + }); + + // #### Blob Parsing + + // The last object type is the simplest and requires the least parsing + // help. Blobs are just file contents and can contain anything, there is + // no structure to it. The main advantage to using the [simple blob + // api][ba] is that when you're creating blobs you don't have to calculate + // the size of the content. There is also a helper for reading a file + // from disk and writing it to the db and getting the oid back so you + // don't have to do all those steps yourself. + + var oid = git.Oid.fromString("af7574ea73f7b166f869ef1a39be126d9a186ae0"); + repo.getBlob(oid, function(error, blob) { + if (error) throw error; + + // You can access a buffer with the raw contents of the blob directly. + // Note that this buffer may not be contain ASCII data for certain blobs + // (e.g. binary files). + + var buffer = blob.content(); + + // If you know that the blob is UTF-8, however, + + console.log(blob.toString()); + }); + + // ### Revwalking + + // The libgit2 [revision walking api][rw] provides methods to traverse the + // directed graph created by the parent pointers of the commit objects. + // Since all commits point back to the commit that came directly before + // them, you can walk this parentage as a graph and find all the commits + // that were ancestors of (reachable from) a given starting point. This + // can allow you to create `git log` type functionality. + + var oid = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); + + // To use the revwalker, create a new walker, tell it how you want to sort + // the output and then push one or more starting points onto the walker. + // If you want to emulate the output of `git log` you would push the SHA + // of the commit that HEAD points to into the walker and then start + // traversing them. You can also 'hide' commits that you want to stop at + // or not see any of their ancestors. So if you want to emulate `git log + // branch1..branch2`, you would push the oid of `branch2` and hide the oid + // of `branch1`. + var revWalk = repo.createRevWalk(); + revWalk.sorting(git.RevWalk.Topological | git.RevWalkReverse); + revWalk.push(oid); + + // Now that we have the starting point pushed onto the walker, we start + // asking for ancestors. It will return them in the sorting order we asked + // for as commit oids. We can then lookup and parse the commited pointed + // at by the returned OID; note that this operation is specially fast + // since the raw contents of the commit object will be cached in memory + + function walk() { + revWalk.next(function(error, oid) { + if (error) throw error; + if (!oid) return; + + repo.getCommit(oid, function(error, commit) { + if (error) throw error; + + console.log(commit.sha()); + walk(); + }); + }); + } + walk(); + + // ### Index File Manipulation + + // The [index file API][gi] allows you to read, traverse, update and write + // the Git index file (sometimes thought of as the staging area). + repo.getIndex(function(error, index) { + if (error) throw error; + + // For each entry in the index, you can get a bunch of information + // including the SHA (oid), path and mode which map to the tree objects + // that are written out. It also has filesystem properties to help + // determine what to inspect for changes (ctime, mtime, dev, ino, uid, + // gid, file_size and flags) All these properties are exported publicly in + // the `git_index_entry` struct + + index.entries().forEach(function(entry) { + console.log(entry.path(), entry.mtime(), entry.size()); + }); + }); + + // ### References + + // The [reference API][ref] allows you to list, resolve, create and update + // references such as branches, tags and remote references (everything in + // the .git/refs directory). + + repo.getReferences(function(error, references) { + if (error) throw error; + + references.forEach(function(reference) { + if (reference.type() == git.Reference.Oid) { + console.log(oid.sha()); + } else if (reference.type() == git.Reference.Symbolic) { + console.log(reference.symbolicTarget()); + } + }); + }); +}); + + diff --git a/include/commit.h b/include/commit.h index 2e04076c9..6f69f5889 100755 --- a/include/commit.h +++ b/include/commit.h @@ -40,21 +40,6 @@ class GitCommit : public ObjectWrap { static Handle Author(const Arguments& args); static Handle TreeId(const Arguments& args); static Handle ParentCount(const Arguments& args); - static Handle Parent(const Arguments& args); - static void ParentWork(uv_work_t* req); - static void ParentAfterWork(uv_work_t* req); - - struct ParentBaton { - uv_work_t request; - int error_code; - const git_error* error; - git_commit * out; - Persistent commitReference; - git_commit * commit; - Persistent nReference; - unsigned int n; - Persistent callback; - }; static Handle ParentId(const Arguments& args); static Handle NthGenAncestor(const Arguments& args); git_commit *raw; diff --git a/include/odb.h b/include/odb.h new file mode 100644 index 000000000..d1ac839d6 --- /dev/null +++ b/include/odb.h @@ -0,0 +1,48 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITODB_H +#define GITODB_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitOdb : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_odb *GetValue(); + + static Handle New(void *raw); + + private: + GitOdb(git_odb *raw); + ~GitOdb(); + + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static Handle Open(const Arguments& args); + static Handle AddDiskAlternate(const Arguments& args); + static Handle Read(const Arguments& args); + static Handle ReadPrefix(const Arguments& args); + static Handle ReadHeader(const Arguments& args); + static Handle Exists(const Arguments& args); + static Handle Refresh(const Arguments& args); + static Handle Write(const Arguments& args); + static Handle Hash(const Arguments& args); + static Handle Hashfile(const Arguments& args); + git_odb *raw; +}; + +#endif diff --git a/include/odb_object.h b/include/odb_object.h new file mode 100644 index 000000000..6c9d45df8 --- /dev/null +++ b/include/odb_object.h @@ -0,0 +1,41 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITODBOBJECT_H +#define GITODBOBJECT_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitOdbObject : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_odb_object *GetValue(); + + static Handle New(void *raw); + + private: + GitOdbObject(git_odb_object *raw); + ~GitOdbObject(); + + static Handle New(const Arguments& args); + + + static Handle ObjectData(const Arguments& args); + static Handle ObjectSize(const Arguments& args); + static Handle ObjectType(const Arguments& args); + static Handle Oid(const Arguments& args); + git_odb_object *raw; +}; + +#endif diff --git a/include/tree.h b/include/tree.h index 15010092b..0590b5cf9 100755 --- a/include/tree.h +++ b/include/tree.h @@ -36,11 +36,11 @@ class GitTree : public ObjectWrap { static Handle EntryByName(const Arguments& args); static Handle EntryByIndex(const Arguments& args); static Handle EntryByOid(const Arguments& args); - static Handle GetEntryByPath(const Arguments& args); - static void GetEntryByPathWork(uv_work_t* req); - static void GetEntryByPathAfterWork(uv_work_t* req); + static Handle GetFile(const Arguments& args); + static void GetFileWork(uv_work_t* req); + static void GetFileAfterWork(uv_work_t* req); - struct GetEntryByPathBaton { + struct GetFileBaton { uv_work_t request; int error_code; const git_error* error; diff --git a/lib/commit.js b/lib/commit.js index 7c699d279..9cb83a8fd 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -46,7 +46,7 @@ Commit.prototype.getFile = function(path, callback) { this.getTree(function (error, tree) { if (error) return callback(error); - tree.getEntryByPath(path, callback); + tree.getFile(path, callback); }); }; diff --git a/lib/tree.js b/lib/tree.js index 38cf9a573..f71fedd53 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -27,10 +27,10 @@ Tree.prototype.entry = Tree.prototype.entryByIndex; /** * Get an entry at the ith position. */ -var oldGetEntryByPath = Tree.prototype.getEntryByPath; -Tree.prototype.getEntryByPath = function(path, callback) { +var oldGetFile = Tree.prototype.getFile; +Tree.prototype.getFile = function(path, callback) { var self = this; - oldGetEntryByPath.call(this, path, function(error, entry) { + oldGetFile.call(this, path, function(error, entry) { if (error) return callback(error); entry.parent = self; diff --git a/src/base.cc b/src/base.cc index 1816428c5..e3ef7aafc 100755 --- a/src/base.cc +++ b/src/base.cc @@ -33,6 +33,8 @@ #include "../include/index.h" #include "../include/tag.h" #include "../include/refdb.h" +#include "../include/odb_object.h" +#include "../include/odb.h" #include "../include/submodule.h" extern "C" void init(Handle target) { @@ -52,6 +54,8 @@ extern "C" void init(Handle target) { GitCommit::Initialize(target); GitRevWalk::Initialize(target); GitRefDb::Initialize(target); + GitOdb::Initialize(target); + GitOdbObject::Initialize(target); GitSubmodule::Initialize(target); GitTree::Initialize(target); diff --git a/src/commit.cc b/src/commit.cc index f1026e259..322623f65 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -41,7 +41,6 @@ void GitCommit::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "author", Author); NODE_SET_PROTOTYPE_METHOD(tpl, "treeId", TreeId); NODE_SET_PROTOTYPE_METHOD(tpl, "parentCount", ParentCount); - NODE_SET_PROTOTYPE_METHOD(tpl, "parent", Parent); NODE_SET_PROTOTYPE_METHOD(tpl, "parentId", ParentId); NODE_SET_PROTOTYPE_METHOD(tpl, "nthGenAncestor", NthGenAncestor); @@ -191,77 +190,6 @@ Handle GitCommit::ParentCount(const Arguments& args) { return scope.Close(to); } -Handle GitCommit::Parent(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsUint32()) { - return ThrowException(Exception::Error(String::New("Number n is required."))); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - ParentBaton* baton = new ParentBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; - baton->commitReference = Persistent::New(args.This()); - baton->commit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->nReference = Persistent::New(args[0]); - unsigned int from_n = (unsigned int) args[0]->ToUint32()->Value(); - baton->n = from_n; - baton->callback = Persistent::New(Local::Cast(args[1])); - - uv_queue_work(uv_default_loop(), &baton->request, ParentWork, (uv_after_work_cb)ParentAfterWork); - - return Undefined(); -} - -void GitCommit::ParentWork(uv_work_t *req) { - ParentBaton *baton = static_cast(req->data); - int result = git_commit_parent( - &baton->out, - baton->commit, - baton->n - ); - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -} - -void GitCommit::ParentAfterWork(uv_work_t *req) { - HandleScope scope; - ParentBaton *baton = static_cast(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - to = GitCommit::New((void *)baton->out); - Handle result = to; - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - baton->commitReference.Dispose(); - baton->nReference.Dispose(); - baton->callback.Dispose(); - delete baton; -} - Handle GitCommit::ParentId(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { diff --git a/src/odb.cc b/src/odb.cc new file mode 100644 index 000000000..c179a8acd --- /dev/null +++ b/src/odb.cc @@ -0,0 +1,352 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/odb.h" +#include "../include/oid.h" +#include "../include/odb_object.h" +#include "node_buffer.h" + +using namespace v8; +using namespace node; + +GitOdb::GitOdb(git_odb *raw) { + this->raw = raw; +} + +GitOdb::~GitOdb() { + git_odb_free(this->raw); +} + +void GitOdb::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Odb")); + + NODE_SET_METHOD(tpl, "create()", Create); + NODE_SET_METHOD(tpl, "open", Open); + NODE_SET_PROTOTYPE_METHOD(tpl, "addDiskAlternate", AddDiskAlternate); + NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); + NODE_SET_METHOD(tpl, "readPrefix", ReadPrefix); + NODE_SET_METHOD(tpl, "readHeader", ReadHeader); + NODE_SET_PROTOTYPE_METHOD(tpl, "exists", Exists); + NODE_SET_PROTOTYPE_METHOD(tpl, "refresh", Refresh); + NODE_SET_METHOD(tpl, "write", Write); + NODE_SET_METHOD(tpl, "hash", Hash); + NODE_SET_METHOD(tpl, "hashfile", Hashfile); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Odb"), constructor_template); +} + +Handle GitOdb::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_odb is required."))); + } + + GitOdb* object = new GitOdb((git_odb *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitOdb::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitOdb::constructor_template->NewInstance(1, argv)); +} + +git_odb *GitOdb::GetValue() { + return this->raw; +} + + +Handle GitOdb::Create(const Arguments& args) { + HandleScope scope; + + git_odb *out = NULL; + + int result = git_odb_new( + &out + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOdb::New((void *)out); + return scope.Close(to); +} + +Handle GitOdb::Open(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String objects_dir is required."))); + } + + git_odb *out = NULL; + String::Utf8Value objects_dir(args[0]->ToString()); + const char * from_objects_dir = strdup(*objects_dir); + + int result = git_odb_open( + &out + , from_objects_dir + ); + delete from_objects_dir; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOdb::New((void *)out); + return scope.Close(to); +} + +Handle GitOdb::AddDiskAlternate(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + + int result = git_odb_add_disk_alternate( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_path + ); + delete from_path; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle GitOdb::Read(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + git_odb_object *out = NULL; + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_odb_read( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_id + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOdbObject::New((void *)out); + return scope.Close(to); +} + +Handle GitOdb::ReadPrefix(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Odb db is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid short_id is required."))); + } + if (args.Length() == 2 || !args[2]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + + git_odb_object *out = NULL; + git_odb * from_db = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const git_oid * from_short_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + size_t from_len = (size_t) args[2]->ToUint32()->Value(); + + int result = git_odb_read_prefix( + &out + , from_db + , from_short_id + , from_len + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOdbObject::New((void *)out); + return scope.Close(to); +} + +Handle GitOdb::ReadHeader(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len_out is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type_out is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Odb db is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + size_t * from_len_out = (size_t *) args[0]->ToUint32()->Value(); + git_otype * from_type_out = (git_otype *) args[1]->ToInt32()->Value(); + git_odb * from_db = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const git_oid * from_id = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + + int result = git_odb_read_header( + from_len_out + , from_type_out + , from_db + , from_id + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle GitOdb::Exists(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_odb_exists( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_id + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle GitOdb::Refresh(const Arguments& args) { + HandleScope scope; + + + int result = git_odb_refresh( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + return Undefined(); +} + +Handle GitOdb::Write(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Buffer data is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + const void * from_data = Buffer::Data(ObjectWrap::Unwrap(args[0]->ToObject())); + size_t from_len = (size_t) args[1]->ToUint32()->Value(); + git_otype from_type = (git_otype) args[2]->ToInt32()->Value(); + + int result = git_odb_write( + out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_data + , from_len + , from_type + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOid::New((void *)out); + return scope.Close(to); +} + +Handle GitOdb::Hash(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Buffer data is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + const void * from_data = Buffer::Data(ObjectWrap::Unwrap(args[0]->ToObject())); + size_t from_len = (size_t) args[1]->ToUint32()->Value(); + git_otype from_type = (git_otype) args[2]->ToInt32()->Value(); + + int result = git_odb_hash( + out + , from_data + , from_len + , from_type + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOid::New((void *)out); + return scope.Close(to); +} + +Handle GitOdb::Hashfile(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + String::Utf8Value path(args[0]->ToString()); + const char * from_path = strdup(*path); + git_otype from_type = (git_otype) args[1]->ToInt32()->Value(); + + int result = git_odb_hashfile( + out + , from_path + , from_type + ); + delete from_path; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOid::New((void *)out); + return scope.Close(to); +} + +Persistent GitOdb::constructor_template; diff --git a/src/odb_object.cc b/src/odb_object.cc new file mode 100644 index 000000000..1ca188007 --- /dev/null +++ b/src/odb_object.cc @@ -0,0 +1,119 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/odb_object.h" +#include "../include/wrapper.h" +#include "../include/oid.h" + +using namespace v8; +using namespace node; + +GitOdbObject::GitOdbObject(git_odb_object *raw) { + this->raw = raw; +} + +GitOdbObject::~GitOdbObject() { + git_odb_object_free(this->raw); +} + +void GitOdbObject::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("OdbObject")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "objectData", ObjectData); + NODE_SET_PROTOTYPE_METHOD(tpl, "objectSize", ObjectSize); + NODE_SET_METHOD(tpl, "objectType", ObjectType); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("OdbObject"), constructor_template); +} + +Handle GitOdbObject::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_odb_object is required."))); + } + + GitOdbObject* object = new GitOdbObject((git_odb_object *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitOdbObject::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitOdbObject::constructor_template->NewInstance(1, argv)); +} + +git_odb_object *GitOdbObject::GetValue() { + return this->raw; +} + + +Handle GitOdbObject::ObjectData(const Arguments& args) { + HandleScope scope; + + + const void * result = git_odb_object_data( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Wrapper::New((void *)result); + return scope.Close(to); +} + +Handle GitOdbObject::ObjectSize(const Arguments& args) { + HandleScope scope; + + + size_t result = git_odb_object_size( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +Handle GitOdbObject::ObjectType(const Arguments& args) { + HandleScope scope; + + + git_otype result = git_odb_object_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +Handle GitOdbObject::Oid(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_odb_object_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = GitOid::New((void *)result); + return scope.Close(to); +} + +Persistent GitOdbObject::constructor_template; diff --git a/src/tree.cc b/src/tree.cc index 2182f0e4f..8b5641b24 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -39,7 +39,7 @@ void GitTree::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "entryByName", EntryByName); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByIndex", EntryByIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByOid", EntryByOid); - NODE_SET_PROTOTYPE_METHOD(tpl, "getEntryByPath", GetEntryByPath); + NODE_SET_PROTOTYPE_METHOD(tpl, "getFile", GetFile); NODE_SET_PROTOTYPE_METHOD(tpl, "diffTree", DiffTree); NODE_SET_PROTOTYPE_METHOD(tpl, "diffIndex", DiffIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "diffWorkDir", DiffWorkDir); @@ -155,7 +155,7 @@ Handle GitTree::EntryByOid(const Arguments& args) { return scope.Close(to); } -Handle GitTree::GetEntryByPath(const Arguments& args) { +Handle GitTree::GetFile(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); @@ -165,7 +165,7 @@ Handle GitTree::GetEntryByPath(const Arguments& args) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - GetEntryByPathBaton* baton = new GetEntryByPathBaton; + GetFileBaton* baton = new GetFileBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; @@ -177,13 +177,13 @@ Handle GitTree::GetEntryByPath(const Arguments& args) { baton->path = from_path; baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, GetEntryByPathWork, (uv_after_work_cb)GetEntryByPathAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetFileWork, (uv_after_work_cb)GetFileAfterWork); return Undefined(); } -void GitTree::GetEntryByPathWork(uv_work_t *req) { - GetEntryByPathBaton *baton = static_cast(req->data); +void GitTree::GetFileWork(uv_work_t *req) { + GetFileBaton *baton = static_cast(req->data); int result = git_tree_entry_bypath( &baton->out, baton->root, @@ -195,9 +195,9 @@ void GitTree::GetEntryByPathWork(uv_work_t *req) { } } -void GitTree::GetEntryByPathAfterWork(uv_work_t *req) { +void GitTree::GetFileAfterWork(uv_work_t *req) { HandleScope scope; - GetEntryByPathBaton *baton = static_cast(req->data); + GetFileBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { diff --git a/v0.18.0.json b/v0.18.0.json index c20489b0f..3f015536c 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -5714,9 +5714,9 @@ }, { "filename": "odb.h", - "ignore": true, + "dependencies": ["../include/oid.h", "../include/odb_object.h", "node_buffer.h"], "jsClassName": "Odb", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "cType": "git_odb", "freeFunctionName": "git_odb_free", "functions": [ @@ -5727,15 +5727,15 @@ "name": "out", "isReturn": true, "cType": "git_odb **", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" } ], "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "jsFunctionName": "new", - "cppFunctionName": "New", + "jsFunctionName": "create()", + "cppFunctionName": "Create", "return": { "cType": "int", "cppClassName": "Int32", @@ -5749,7 +5749,7 @@ "name": "out", "isReturn": true, "cType": "git_odb **", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -5776,7 +5776,7 @@ { "name": "odb", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb", "isSelf": true }, @@ -5793,6 +5793,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -5810,7 +5811,7 @@ { "name": "odb", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb", "isSelf": true }, @@ -5827,6 +5828,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -5844,7 +5846,7 @@ { "name": "odb", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb", "isSelf": true }, @@ -5872,10 +5874,11 @@ { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -5894,14 +5897,15 @@ "name": "out", "isReturn": true, "cType": "git_odb_object **", - "cppClassName": "OdbObject", + "cppClassName": "GitOdbObject", "jsClassName": "OdbObject" }, { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", - "jsClassName": "Odb" + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true }, { "name": "id", @@ -5912,7 +5916,7 @@ ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "read", "cppFunctionName": "Read", "return": { @@ -5928,13 +5932,13 @@ "name": "out", "isReturn": true, "cType": "git_odb_object **", - "cppClassName": "OdbObject", + "cppClassName": "GitOdbObject", "jsClassName": "OdbObject" }, { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -5979,7 +5983,7 @@ { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -6006,7 +6010,7 @@ { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb", "isSelf": true }, @@ -6034,7 +6038,7 @@ { "name": "db", "cType": "struct git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb", "isSelf": true } @@ -6056,7 +6060,7 @@ { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb", "isSelf": true }, @@ -6073,6 +6077,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -6090,6 +6095,7 @@ { "name": "out", "isReturn": true, + "shouldAlloc": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6097,14 +6103,15 @@ { "name": "odb", "cType": "git_odb *", - "cppClassName": "Odb", - "jsClassName": "Odb" + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true }, { "name": "data", "cType": "const void *", - "cppClassName": "void", - "jsClassName": "void" + "cppClassName": "Buffer", + "jsClassName": "Buffer" }, { "name": "len", @@ -6137,13 +6144,13 @@ "name": "out", "isReturn": true, "cType": "git_odb_stream **", - "cppClassName": "OdbStream", + "cppClassName": "GitOdbStream", "jsClassName": "OdbStream" }, { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -6159,6 +6166,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -6177,13 +6185,13 @@ "name": "out", "isReturn": true, "cType": "git_odb_stream **", - "cppClassName": "OdbStream", + "cppClassName": "GitOdbStream", "jsClassName": "OdbStream" }, { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -6193,6 +6201,7 @@ "jsClassName": "Oid" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -6217,7 +6226,7 @@ { "name": "db", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -6233,6 +6242,7 @@ "jsClassName": "void" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, @@ -6250,6 +6260,7 @@ { "name": "out", "isReturn": true, + "shouldAlloc": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6257,8 +6268,8 @@ { "name": "data", "cType": "const void *", - "cppClassName": "void", - "jsClassName": "void" + "cppClassName": "Buffer", + "jsClassName": "Buffer" }, { "name": "len", @@ -6290,6 +6301,7 @@ { "name": "out", "isReturn": true, + "shouldAlloc": true, "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid" @@ -6317,106 +6329,122 @@ "cppClassName": "Int32", "isErrorCode": true } - }, + } + ] + }, + { + "filename": "odb_object.h", + "dependencies": ["../include/wrapper.h", "../include/oid.h"], + "jsClassName": "OdbObject", + "cppClassName": "GitOdbObject", + "cType": "git_odb_object", + "freeFunctionName": "git_odb_object_free", + "functions": [ { - "cFunctionName": "git_odb_object_free", + "cFunctionName": "git_odb_object_data", "args": [ { "name": "object", "cType": "git_odb_object *", - "cppClassName": "OdbObject", - "jsClassName": "OdbObject" + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "isFree": true, - "jsFunctionName": "objectFree", - "cppFunctionName": "ObjectFree", + "isPrototypeMethod": true, + "jsFunctionName": "objectData", + "cppFunctionName": "ObjectData", "return": { - "cType": "void", - "cppClassName": "void" + "cType": "const void *", + "cppClassName": "Wrapper" } }, { - "cFunctionName": "git_odb_object_id", + "cFunctionName": "git_odb_object_size", "args": [ { "name": "object", "cType": "git_odb_object *", - "cppClassName": "OdbObject", - "jsClassName": "OdbObject" + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "objectId", - "cppFunctionName": "ObjectId", + "isPrototypeMethod": true, + "jsFunctionName": "objectSize", + "cppFunctionName": "ObjectSize", "return": { - "cType": "const git_oid *", - "cppClassName": "GitOid" + "cType": "size_t", + "cppClassName": "Uint32" } }, { - "cFunctionName": "git_odb_object_data", + "cFunctionName": "git_odb_object_type", "args": [ { "name": "object", "cType": "git_odb_object *", - "cppClassName": "OdbObject", - "jsClassName": "OdbObject" + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": false, - "jsFunctionName": "objectData", - "cppFunctionName": "ObjectData", + "jsFunctionName": "objectType", + "cppFunctionName": "ObjectType", "return": { - "cType": "const void *", - "cppClassName": "void" + "cType": "git_otype", + "cppClassName": "Int32" } }, { - "cFunctionName": "git_odb_object_size", + "cFunctionName": "git_odb_object_free", "args": [ { "name": "object", "cType": "git_odb_object *", - "cppClassName": "OdbObject", - "jsClassName": "OdbObject" + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "objectSize", - "cppFunctionName": "ObjectSize", + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "objectFree", + "cppFunctionName": "ObjectFree", "return": { - "cType": "size_t", - "cppClassName": "Uint32" + "cType": "void", + "cppClassName": "void" } }, { - "cFunctionName": "git_odb_object_type", + "cFunctionName": "git_odb_object_id", "args": [ { "name": "object", "cType": "git_odb_object *", - "cppClassName": "OdbObject", - "jsClassName": "OdbObject" + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true } ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "objectType", - "cppFunctionName": "ObjectType", + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", "return": { - "cType": "git_otype", - "cppClassName": "Int32" + "cType": "const git_oid *", + "cppClassName": "GitOid" } } ] @@ -9588,7 +9616,7 @@ { "name": "odb", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" } ], @@ -10044,7 +10072,7 @@ "name": "out", "isReturn": true, "cType": "git_odb **", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" }, { @@ -10079,7 +10107,7 @@ { "name": "odb", "cType": "git_odb *", - "cppClassName": "Odb", + "cppClassName": "GitOdb", "jsClassName": "Odb" } ], @@ -14248,8 +14276,8 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "getEntryByPath", - "cppFunctionName": "GetEntryByPath", + "jsFunctionName": "getFile", + "cppFunctionName": "GetFile", "return": { "cType": "int", "cppClassName": "Int32", From ec030743aba41685db8aef3be1b10fdae1db249f Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 3 Jul 2013 18:05:53 +0200 Subject: [PATCH 19/28] General overview in examples --- TODO | 4 +- binding.gyp | 2 + example/general.js | 212 ++++++++++-------- include/index.h | 4 +- include/index_entry.h | 40 ++++ include/index_time.h | 39 ++++ include/odb.h | 32 +++ include/odb_object.h | 6 +- include/repo.h | 28 +++ include/signature.h | 1 + include/tag.h | 9 +- index.js | 36 ++++ lib/index.js | 46 ++-- lib/object.js | 31 +++ lib/odb.js | 16 ++ lib/oid.js | 6 + lib/patch.js | 10 - lib/repo.js | 42 +++- lib/revwalk.js | 21 ++ lib/threads.js | 36 ---- lib/util.js | 7 + package.json | 2 +- src/base.cc | 4 + src/index.cc | 38 ++-- src/index_entry.cc | 98 +++++++++ src/index_time.cc | 84 ++++++++ src/odb.cc | 153 ++++++++++--- src/odb_object.cc | 12 +- src/repo.cc | 157 ++++++++++++++ src/signature.cc | 42 ++++ src/tag.cc | 42 +--- src/tree_entry.cc | 1 - v0.18.0.json | 487 ++++++++++++++++++++++++------------------ 33 files changed, 1268 insertions(+), 480 deletions(-) create mode 100644 include/index_entry.h create mode 100644 include/index_time.h create mode 100755 index.js mode change 100755 => 100644 lib/index.js create mode 100644 lib/object.js create mode 100644 lib/odb.js create mode 100644 lib/oid.js delete mode 100644 lib/patch.js delete mode 100644 lib/threads.js create mode 100644 src/index_entry.cc create mode 100644 src/index_time.cc diff --git a/TODO b/TODO index f8113efd8..f94421965 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,9 @@ -- rename all async methods getXXX - audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. - rename files remove .h - Cleanup diff api - free everything malloc'd - codegen documentation - extract out more partials +- audit return types for things that should be copied +- array handling +- make normalizeOid do more work. diff --git a/binding.gyp b/binding.gyp index f283a8069..d0069fe86 100644 --- a/binding.gyp +++ b/binding.gyp @@ -11,6 +11,8 @@ 'src/object.cc', 'src/repo.cc', 'src/index.cc', + 'src/index_entry.cc', + 'src/index_time.cc', 'src/tag.cc', 'src/revwalk.cc', 'src/signature.cc', diff --git a/example/general.js b/example/general.js index 991c06b7b..69d850b24 100644 --- a/example/general.js +++ b/example/general.js @@ -1,28 +1,52 @@ -var git = require('nodegit'); - -git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { +var git = require('../index.js'); + +// **nodegit** is a javascript library for node.js that wraps libgit2, a +// pure C implementation of the Git core. It provides an asynchronous +// interface around any functions that do I/O, and a sychronous interface +// around the rest. +// +// This file is an example of using that API in a real, JS file. +// +// **libgit2** (for the most part) only implements the core plumbing +// functions, not really the higher level porcelain stuff. For a primer on +// Git Internals that you will need to know to work with Git at this level, +// check out [Chapter 9][pg] of the Pro Git book. + +// Nearly, all git operations in the context of a repository. +// To open a repository, + +git.Repo.open('.git', function(error, repo) { + // For all of the following examples, error-handling will be performed in + // this naive way: if (error) throw error; + console.log("Opened repository."); // ### SHA-1 Value Conversions - // The `git_oid` is the structure that keeps the SHA value. We will use - // this throughout the example for storing the value of the current SHA - // key we're working with. - var oid = git.Oid.fromString('fd6e612585290339ea8bf39c692a7ff6a29cb7c3'); + // Objects in git (commits, blobs, etc.) are referred to by their SHA value + // **nodegit** uses a simple wrapper around hash values called an `Oid`. + // The oid validates that the SHA is well-formed. + + var oid = git.Oid.fromString('fd373a561d63bfc0a5665608fe057f2131d81fee'); - // If you have a oid, you can easily get the hex value of the SHA as well. - console.log(oid.sha()); + // Most functions in in **nodegit** that take an oid will also take a + // string, so for example, you can look up a commit by a string SHA or + // an Oid, but but any functions that create new SHAs will always return + // an Oid. + + // If you have a oid, you can easily get the hex value of the SHA again. + console.log("Sha hex string:", oid.sha()); // ### Working with the Object Database - // **libgit2** provides [direct access][odb] to the object database. The + // **libgit2** provides [direct access][odb] to the object database. The // object database is where the actual objects are stored in Git. For // working with raw objects, we'll need to get this structure from the // repository. var odb = repo.odb(); // We can read raw objects directly from the object database if we have - // the oid (SHA) of the object. This allows us to access objects without + // the oid (SHA) of the object. This allows us to access objects without // knowing thier type and inspect the raw bytes unparsed. odb.read(oid, function(error, object) { @@ -37,19 +61,19 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { var data = object.data(), type = object.type(); - console.log(object.size(), object.type()); + console.log("Object size and type:", object.size(), object.type()); }); // You can also write raw object data to Git. This is pretty cool because - // it gives you direct access to the key/value properties of Git. Here + // it gives you direct access to the key/value properties of Git. Here // we'll write a new blob object that just contains a simple string. - // Notice that we have to specify the object type as the `git_otype` enum. - odb.write("test data", git.Object.Type.Blob, function(error, oid) { + // Notice that we have to specify the object type. + odb.write("test data", "test data".length, git.Object.Type.Blob, function(error, oid) { if (error) throw error; // Now that we've written the object, we can check out what SHA1 was // generated when the object was written to our database. - console.log(oid.sha()); + console.log("Written Object: ", oid.sha()); }); // ### Object Parsing @@ -64,61 +88,63 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { // data in the commit - the author (name, email, datetime), committer // (same), tree, message, encoding and parent(s). - oid = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); + oid = git.Oid.fromString("698c74e817243efe441a5d1f3cbaf3998282ca86"); + + // Many methods in **nodegit** are asynchronous, because they do file + // or network I/O. By convention, all asynchronous methods are named + // imperatively, like `getCommit`, `open`, `read`, `write`, etc., whereas + // synchronous methods are named nominatively, like `type`, `size`, `name`. + repo.getCommit(oid, function(error, commit) { if (error) throw error; // Each of the properties of the commit object are accessible via methods, // including commonly needed variations, such as `git_commit_time` which // returns the author time and `git_commit_message` which gives you the - // commit message (as a NUL-terminated string). - console.log(commit.message(), commit.author(), commit.committer(), commit.time()); + // commit message. + console.log("Commit:", commit.message(), commit.author().name(), commit.date()); // Commits can have zero or more parents. The first (root) commit will // have no parents, most commits will have one (i.e. the commit it was - // based on) and merge commits will have two or more. Commits can + // based on) and merge commits will have two or more. Commits can // technically have any number, though it's rare to have more than two. commit.getParents(function(error, parents) { parents.forEach(function(parent) { - console.log(parent.oid()); + console.log("Parent:", parent.oid().sha()); }); }); }); // #### Writing Commits - // libgit2 provides a couple of methods to create commit objects easily as - // well. There are four different create signatures, we'll just show one - // of them here. You can read about the other ones in the [commit API - // docs][cd]. - // - // [cd]: http://libgit2.github.com/libgit2/#HEAD/group/commit + // nodegit provides a couple of methods to create commit objects easily as + // well. - var author = new git.Signature("Scott Chacon", "schacon@gmail.com", 123456789, 60); - var committer = new git.Signature("Scott A Chacon", "scott@github.com", 987654321, 90); + var author = git.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60); + var committer = git.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90); // Commit objects need a tree to point to and optionally one or more - // parents. Here we're creating oid objects to create the commit with, + // parents. Here we're creating oid objects to create the commit with, // but you can also use existing ones: + var treeId = git.Oid.fromString("28873d96b4e8f4e33ea30f4c682fd325f7ba56ac"); var parentId = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); repo.getTree(treeId, function(error, tree) { repo.getCommit(parentId, function(error, parent) { - + return "Not yet working!"; // Here we actually create the commit object with a single call with all - // the values we need to create the commit. The SHA key is written to the + // the values we need to create the commit. The SHA key is written to the // `commit_id` variable here. repo.createCommit( null /* do not update the HEAD */, author, committer, - null /* use default message encoding */, "example commit", tree, - 1, parent, + [parent], function (error, commitOid) { - console.log(commitOid.sha()); + console.log("New Commit:", commitOid.sha()); }); }); }); @@ -129,7 +155,7 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { // functions very similarly to the commit lookup, parsing and creation // methods, since the objects themselves are very similar. - var oid = git.Oid.fromString("bc422d45275aca289c51d79830b45cecebff7c3a"); + oid = git.Oid.fromString("97f6d755647aca272e7c8003323472cefca772fc"); repo.getTag(oid, function(error, tag) { if (error) throw error; @@ -137,47 +163,50 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { // generally contains: the target (usually a commit object), the type of // the target object (usually 'commit'), the name ('v1.0'), the tagger (a // git_signature - name, email, timestamp), and the tag message. - console.log(tag.name(), tag.type(), tag.message()); + console.log(tag.name(), tag.targetType(), tag.message()); - tag.getTarget(function (error, commit) { + tag.getTarget(function (error, target) { if (error) throw error; - console.log(commit); + + console.log("Target is commit:", target.isCommit()); }); }); // #### Tree Parsing + // A Tree is how Git represents the state of the filesystem + // at a given revision. In general, a tree corresponds to a directory, + // and files in that directory are either files (blobs) or directories. + // [Tree parsing][tp] is a bit different than the other objects, in that - // we have a subtype which is the tree entry. This is not an actual + // we have a subtype which is the tree entry. This is not an actual // object type in Git, but a useful structure for parsing and traversing // tree entries. - var oid = git.Oid.fromString("2a741c18ac5ff082a7caaec6e74db3075a1906b5"); + oid = git.Oid.fromString("e1b0c7ea57bfc5e30ec279402a98168a27838ac9"); repo.getTree(oid, function(error, tree) { if (error) throw error; - console.log(tree.size()); - tree.entries().forEach(function(entry) { - console.log(entry.name()); - - if (entry.isDirectory()) { - entry.getTree(function(error, tree) { - if (error) throw error; - - console.log("Recursively got tree"); - }); - } else { - entry.getBlob(function(error, blob) { - console.log(blob.toString()); - }); - } - }); + console.log("Tree Size:", tree.size()); + function dfs(error, tree) { + tree.entries().forEach(function(entry) { + if (entry.isDirectory()) { + entry.getTree(dfs); + } else if (entry.isFile()) { + console.log("Tree Entry:", entry.name()); + } + }); + } + dfs(null, tree); // You can also access tree entries by path if you know the path of the // entry you're looking for. - tree.getFile("/src/hello.c", function(error, entry) { + tree.getFile("example/general.js", function(error, entry) { + if (error) throw error; + + // Entries which are files have blobs associated with them: entry.getBlob(function(error, blob) { - console.log(blob.toString()); + console.log("Blob size:", blob.size()); }); }); }); @@ -188,23 +217,21 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { // help. Blobs are just file contents and can contain anything, there is // no structure to it. The main advantage to using the [simple blob // api][ba] is that when you're creating blobs you don't have to calculate - // the size of the content. There is also a helper for reading a file + // the size of the content. There is also a helper for reading a file // from disk and writing it to the db and getting the oid back so you // don't have to do all those steps yourself. - var oid = git.Oid.fromString("af7574ea73f7b166f869ef1a39be126d9a186ae0"); + oid = git.Oid.fromString("991c06b7b1ec6f939488427e4b41a4fa3e1edd5f"); repo.getBlob(oid, function(error, blob) { if (error) throw error; - // You can access a buffer with the raw contents of the blob directly. + // You can access a node.js Buffer with the raw contents of the blob directly. // Note that this buffer may not be contain ASCII data for certain blobs // (e.g. binary files). - var buffer = blob.content(); // If you know that the blob is UTF-8, however, - - console.log(blob.toString()); + console.log("Blob contents:", blob.toString().slice(0, 38)); }); // ### Revwalking @@ -213,60 +240,62 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { // directed graph created by the parent pointers of the commit objects. // Since all commits point back to the commit that came directly before // them, you can walk this parentage as a graph and find all the commits - // that were ancestors of (reachable from) a given starting point. This + // that were ancestors of (reachable from) a given starting point. This // can allow you to create `git log` type functionality. - var oid = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); + oid = git.Oid.fromString("698c74e817243efe441a5d1f3cbaf3998282ca86"); // To use the revwalker, create a new walker, tell it how you want to sort // the output and then push one or more starting points onto the walker. // If you want to emulate the output of `git log` you would push the SHA // of the commit that HEAD points to into the walker and then start - // traversing them. You can also 'hide' commits that you want to stop at - // or not see any of their ancestors. So if you want to emulate `git log + // traversing them. You can also 'hide' commits that you want to stop at + // or not see any of their ancestors. So if you want to emulate `git log // branch1..branch2`, you would push the oid of `branch2` and hide the oid // of `branch1`. var revWalk = repo.createRevWalk(); - revWalk.sorting(git.RevWalk.Topological | git.RevWalkReverse); - revWalk.push(oid); - - // Now that we have the starting point pushed onto the walker, we start - // asking for ancestors. It will return them in the sorting order we asked - // for as commit oids. We can then lookup and parse the commited pointed - // at by the returned OID; note that this operation is specially fast - // since the raw contents of the commit object will be cached in memory + revWalk.sorting(git.RevWalk.Sort.Topological, git.RevWalk.Sort.Reverse); + revWalk.push(oid, function(error) { + if (error) throw error; - function walk() { - revWalk.next(function(error, oid) { - if (error) throw error; - if (!oid) return; + // Now that we have the starting point pushed onto the walker, we start + // asking for ancestors. It will return them in the sorting order we asked + // for as commit oids. We can then lookup and parse the commited pointed + // at by the returned OID; note that this operation is specially fast + // since the raw contents of the commit object will be cached in memory - repo.getCommit(oid, function(error, commit) { + function walk() { + revWalk.next(function(error, oid) { if (error) throw error; + if (!oid) return; + + repo.getCommit(oid, function(error, commit) { + if (error) throw error; - console.log(commit.sha()); - walk(); + console.log("Commit:", commit.sha()); + walk(); + }); }); - }); - } - walk(); + } + walk(); + }); // ### Index File Manipulation // The [index file API][gi] allows you to read, traverse, update and write // the Git index file (sometimes thought of as the staging area). - repo.getIndex(function(error, index) { + repo.openIndex(function(error, index) { if (error) throw error; // For each entry in the index, you can get a bunch of information // including the SHA (oid), path and mode which map to the tree objects - // that are written out. It also has filesystem properties to help + // that are written out. It also has filesystem properties to help // determine what to inspect for changes (ctime, mtime, dev, ino, uid, // gid, file_size and flags) All these properties are exported publicly in - // the `git_index_entry` struct + // the `IndexEntry` class index.entries().forEach(function(entry) { - console.log(entry.path(), entry.mtime(), entry.size()); + console.log("Index Entry:", entry.path(), entry.mtime().seconds()); }); }); @@ -276,6 +305,7 @@ git.Repo.open('/opt/libgit2-test/.git', function(error, repo) { // references such as branches, tags and remote references (everything in // the .git/refs directory). + return "this doesn't yet work"; repo.getReferences(function(error, references) { if (error) throw error; diff --git a/include/index.h b/include/index.h index 2a374e4ff..e634d7ea0 100755 --- a/include/index.h +++ b/include/index.h @@ -44,7 +44,6 @@ class GitIndex : public ObjectWrap { const char * index_path; Persistent callback; }; - static Handle Owner(const Arguments& args); static Handle Read(const Arguments& args); static void ReadWork(uv_work_t* req); static void ReadAfterWork(uv_work_t* req); @@ -96,8 +95,9 @@ class GitIndex : public ObjectWrap { git_index * index; Persistent callback; }; - static Handle Entrycount(const Arguments& args); + static Handle Size(const Arguments& args); static Handle Clear(const Arguments& args); + static Handle Entry(const Arguments& args); static Handle Remove(const Arguments& args); static Handle RemoveDirectory(const Arguments& args); static Handle AddBypath(const Arguments& args); diff --git a/include/index_entry.h b/include/index_entry.h new file mode 100644 index 000000000..0416e4f5c --- /dev/null +++ b/include/index_entry.h @@ -0,0 +1,40 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITINDEXENTRY_H +#define GITINDEXENTRY_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitIndexEntry : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_index_entry *GetValue(); + + static Handle New(void *raw); + + private: + GitIndexEntry(git_index_entry *raw); + ~GitIndexEntry(); + + static Handle New(const Arguments& args); + + static Handle Ctime(const Arguments& args); + static Handle Mtime(const Arguments& args); + static Handle Path(const Arguments& args); + + git_index_entry *raw; +}; + +#endif diff --git a/include/index_time.h b/include/index_time.h new file mode 100644 index 000000000..765ce6cc7 --- /dev/null +++ b/include/index_time.h @@ -0,0 +1,39 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITINDEXTIME_H +#define GITINDEXTIME_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitIndexTime : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_index_time *GetValue(); + + static Handle New(void *raw); + + private: + GitIndexTime(git_index_time *raw); + ~GitIndexTime(); + + static Handle New(const Arguments& args); + + static Handle Seconds(const Arguments& args); + static Handle Nanoseconds(const Arguments& args); + + git_index_time *raw; +}; + +#endif diff --git a/include/odb.h b/include/odb.h index d1ac839d6..6ed9913d9 100644 --- a/include/odb.h +++ b/include/odb.h @@ -35,11 +35,43 @@ class GitOdb : public ObjectWrap { static Handle Open(const Arguments& args); static Handle AddDiskAlternate(const Arguments& args); static Handle Read(const Arguments& args); + static void ReadWork(uv_work_t* req); + static void ReadAfterWork(uv_work_t* req); + + struct ReadBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_odb_object * out; + Persistent dbReference; + git_odb * db; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; static Handle ReadPrefix(const Arguments& args); static Handle ReadHeader(const Arguments& args); static Handle Exists(const Arguments& args); static Handle Refresh(const Arguments& args); static Handle Write(const Arguments& args); + static void WriteWork(uv_work_t* req); + static void WriteAfterWork(uv_work_t* req); + + struct WriteBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * out; + Persistent odbReference; + git_odb * odb; + Persistent dataReference; + const void * data; + Persistent lenReference; + size_t len; + Persistent typeReference; + git_otype type; + Persistent callback; + }; static Handle Hash(const Arguments& args); static Handle Hashfile(const Arguments& args); git_odb *raw; diff --git a/include/odb_object.h b/include/odb_object.h index 6c9d45df8..7938dfa49 100644 --- a/include/odb_object.h +++ b/include/odb_object.h @@ -31,9 +31,9 @@ class GitOdbObject : public ObjectWrap { static Handle New(const Arguments& args); - static Handle ObjectData(const Arguments& args); - static Handle ObjectSize(const Arguments& args); - static Handle ObjectType(const Arguments& args); + static Handle Data(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Type(const Arguments& args); static Handle Oid(const Arguments& args); git_odb_object *raw; }; diff --git a/include/repo.h b/include/repo.h index 3afef0ca6..342866964 100755 --- a/include/repo.h +++ b/include/repo.h @@ -61,6 +61,20 @@ class GitRepo : public ObjectWrap { }; static Handle Path(const Arguments& args); static Handle Workdir(const Arguments& args); + static Handle Odb(const Arguments& args); + static Handle openIndex(const Arguments& args); + static void openIndexWork(uv_work_t* req); + static void openIndexAfterWork(uv_work_t* req); + + struct openIndexBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_index * out; + Persistent repoReference; + git_repository * repo; + Persistent callback; + }; static Handle GetBlob(const Arguments& args); static void GetBlobWork(uv_work_t* req); static void GetBlobAfterWork(uv_work_t* req); @@ -212,6 +226,20 @@ class GitRepo : public ObjectWrap { git_repository * repo; Persistent callback; }; + static Handle Delete(const Arguments& args); + static void DeleteWork(uv_work_t* req); + static void DeleteAfterWork(uv_work_t* req); + + struct DeleteBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent callback; + }; git_repository *raw; }; diff --git a/include/signature.h b/include/signature.h index de5883796..14d542c82 100755 --- a/include/signature.h +++ b/include/signature.h @@ -34,6 +34,7 @@ class GitSignature : public ObjectWrap { static Handle Email(const Arguments& args); static Handle Time(const Arguments& args); + static Handle Create(const Arguments& args); static Handle Now(const Arguments& args); git_signature *raw; }; diff --git a/include/tag.h b/include/tag.h index dae3dc6e8..f89ded8b1 100755 --- a/include/tag.h +++ b/include/tag.h @@ -32,11 +32,11 @@ class GitTag : public ObjectWrap { static Handle Oid(const Arguments& args); - static Handle Target(const Arguments& args); - static void TargetWork(uv_work_t* req); - static void TargetAfterWork(uv_work_t* req); + static Handle GetTarget(const Arguments& args); + static void GetTargetWork(uv_work_t* req); + static void GetTargetAfterWork(uv_work_t* req); - struct TargetBaton { + struct GetTargetBaton { uv_work_t request; int error_code; const git_error* error; @@ -50,7 +50,6 @@ class GitTag : public ObjectWrap { static Handle Name(const Arguments& args); static Handle Tagger(const Arguments& args); static Handle Message(const Arguments& args); - static Handle Delete(const Arguments& args); static Handle Peel(const Arguments& args); git_tag *raw; }; diff --git a/index.js b/index.js new file mode 100755 index 000000000..03b0ec510 --- /dev/null +++ b/index.js @@ -0,0 +1,36 @@ +// Used to detect for Cygwin +var os = require('os'); + +// Required for Windows/Cygwin support +var root = [__dirname, '/vendor/libgit2/build/shared'].join(''), + path = process.env.PATH; + +if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { + process.env.PATH = root + ':' + path; +} + +// Assign raw api to module +var rawApi = require('./build/Release/nodegit'); +for (var key in rawApi) { + exports[key] = rawApi[key]; +} + +// Import extensions +require('./lib/commit.js'); +require('./lib/blob.js'); +require('./lib/object.js'); +require('./lib/odb.js'); +require('./lib/oid.js'); +require('./lib/index.js'); +require('./lib/repo.js'); +require('./lib/reference.js'); +require('./lib/revwalk.js'); +require('./lib/tree.js'); +require('./lib/diff_list.js'); +require('./lib/tree_entry.js'); + +// Set version +exports.version = require('./package').version; + +// Initialize threads +exports.Threads.init(); diff --git a/lib/index.js b/lib/index.js old mode 100755 new mode 100644 index af2f05255..a7321c12e --- a/lib/index.js +++ b/lib/index.js @@ -1,32 +1,14 @@ -// Used to detect for Cygwin -var os = require('os'); - -// Required for Windows/Cygwin support -var root = [__dirname, '/../vendor/libgit2/build/shared'].join(''), - path = process.env.PATH; - -if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { - process.env.PATH = root + ':' + path; -} - -// Assign raw api to module -var rawApi = require('../build/Release/nodegit'); -for (var key in rawApi) { - exports[key] = rawApi[key]; -} - -// Import extensions -require('./commit.js'); -require('./blob.js'); -require('./repo.js'); -require('./reference.js'); -require('./revwalk.js'); -require('./tree.js'); -require('./diff_list.js'); -require('./tree_entry.js'); - -// Set version -exports.version = require('../package').version; - -// Initialize threads -exports.Threads.init(); +var git = require('../'), + Index = git.Index; + +/** + * Return an array of the entries in this index. + */ +Index.prototype.entries = function() { + var size = this.size(), + result = []; + for (var i = 0; i < size; i++) { + result.push(this.entry(i)); + } + return result; +}; diff --git a/lib/object.js b/lib/object.js new file mode 100644 index 000000000..002a8d0ae --- /dev/null +++ b/lib/object.js @@ -0,0 +1,31 @@ +var git = require('../'), + Object = git.Object; + +Object.Type = { + Any: -2, /**< Object can be any of the following */ + Bad: -1, /**< Object is invalid. */ + Ext1: 0, /**< Reserved for future use. */ + Commit: 1, /**< A commit object. */ + Tree: 2, /**< A tree (directory listing) object. */ + Blob: 3, /**< A file revision object. */ + Tag: 4, /**< An annotated tag object. */ + Ext2: 5, /**< Reserved for future use. */ + OffsetDelta: 6, /**< A delta, base is given by an offset. */ + OidDelta: 7 /**< A delta, base is given by object id. */ +}; + +Object.prototype.isCommit = function() { + return this.type() == Object.Type.Commit; +}; + +Object.prototype.isTree = function() { + return this.type() == Object.Type.Tree; +}; + +Object.prototype.isBlob = function() { + return this.type() == Object.Type.Blob; +}; + +Object.prototype.isTag = function() { + return this.type() == Object.Type.Tag; +}; diff --git a/lib/odb.js b/lib/odb.js new file mode 100644 index 000000000..586c047c0 --- /dev/null +++ b/lib/odb.js @@ -0,0 +1,16 @@ +var git = require('../'), + util = require('./util.js'), + Odb = git.Odb; + +/** + * Retrieve the object identified by oid. + * + * @param {String|Oid} String sha or Oid + * @param {Repo~commitCallback} callback + */ +var oldRead = Odb.prototype.read; +Odb.prototype.read = function(oid, callback) { + var self = this; + oldRead.call(this, util.normalizeOid(oid), callback); +}; +util.makeSafe(Odb.prototype, 'read'); diff --git a/lib/oid.js b/lib/oid.js new file mode 100644 index 000000000..bdc2de1ee --- /dev/null +++ b/lib/oid.js @@ -0,0 +1,6 @@ +var git = require('../'), + Oid = git.Oid; + +Oid.prototype.toString = function() { + return this.sha(); +}; diff --git a/lib/patch.js b/lib/patch.js deleted file mode 100644 index 13d38632c..000000000 --- a/lib/patch.js +++ /dev/null @@ -1,10 +0,0 @@ -var git = require('../'); - -/** - * Convenience patch class. - * - * @constructor - */ -var Patch = function(rawPatch) { - this.rawPatch = rawPatch; -}; diff --git a/lib/repo.js b/lib/repo.js index 0c379c6b0..ca2f9246b 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -63,7 +63,7 @@ util.makeSafe(Repo.prototype, 'getReference'); var oldGetCommit = Repo.prototype.getCommit; Repo.prototype.getCommit = function(oid, callback) { var self = this; - oldGetCommit.call(this, normalizeOid(oid), function(error, commit) { + oldGetCommit.call(this, util.normalizeOid(oid), function(error, commit) { if (error) return callback(error); commit.repo = self; callback(null, commit); @@ -80,7 +80,7 @@ util.makeSafe(Repo.prototype, 'getCommit'); var oldBlob = Repo.prototype.getBlob; Repo.prototype.getBlob = function(oid, callback) { var self = this; - oldBlob.call(this, normalizeOid(oid), function(error, blob) { + oldBlob.call(this, util.normalizeOid(oid), function(error, blob) { if (error) return callback(error); blob.repo = self; callback(null, blob); @@ -97,7 +97,7 @@ util.makeSafe(Repo.prototype, 'blob'); var oldGetTree = Repo.prototype.getTree; Repo.prototype.getTree = function(oid, callback) { var self = this; - oldGetTree.call(this, normalizeOid(oid), function(error, tree) { + oldGetTree.call(this, util.normalizeOid(oid), function(error, tree) { if (error) return callback(error); tree.repo = self; callback(null, tree); @@ -105,6 +105,19 @@ Repo.prototype.getTree = function(oid, callback) { }; util.makeSafe(Repo.prototype, 'getTree'); +/** + * Retrieve the tag represented by the oid. + * + * @param {String|Oid} String sha or Oid + * @param {Blob~lookupCallback} callback + */ +var oldGetTag = Repo.prototype.getTag; +Repo.prototype.getTag = function(oid, callback) { + var self = this; + oldGetTag.call(this, util.normalizeOid(oid), callback); +}; +util.makeSafe(Repo.prototype, 'getTag'); + /** * Retrieve the blob represented by the oid. * @@ -118,7 +131,22 @@ Repo.prototype.createRevWalk = function() { return revWalk; }; -function normalizeOid(oid) { - if (typeof oid === 'string') oid = git.Oid.fromString(oid); - return oid; -} +/** + * Create a commit + * + * @param {String|Oid} String sha or Oid + * @param {Blob~lookupCallback} callback + */ +var oldCreateCommit = Repo.prototype.createCommit; +Repo.prototype.createCommit = function(updateRef, author, committer, message, tree, parents, callback) { + oldCreateCommit.call( + this, + updateRef, + author, + committer, + null /* use default message encoding */, + message, + tree, + parents.length, parents, + callback); +}; diff --git a/lib/revwalk.js b/lib/revwalk.js index 1ae3b77da..3b9e1a5ec 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -1,6 +1,27 @@ var git = require('../'), RevWalk = git.RevWalk; +/** + * Refer to vendor/libgit2/include/git2/revwalk.h for sort definitions. + */ +RevWalk.Sort = { + None: 0, + Topological: 1, + Time: 2, + Reverse: 4 +}; + +/** + * Set the sort order for the revwalk + */ +var oldSorting = RevWalk.prototype.sorting; +RevWalk.prototype.sorting = function() { + var sort = 0; + for (var i = 0; i < arguments.length; i++) + sort |= arguments[i]; + oldSorting.call(this, sort); +}; + /** * Walk the history from the given oid. * diff --git a/lib/threads.js b/lib/threads.js deleted file mode 100644 index ae9f31efe..000000000 --- a/lib/threads.js +++ /dev/null @@ -1,36 +0,0 @@ -var git = require('../'); - -var _Blob = function(obj) { - var self = {}; - - if( obj instanceof git.raw.Repo ) { - self.repo = obj; - self.blob = new git.raw.Blob( obj ); - } - else if( obj instanceof git.raw.Blob ) { - self.blob = obj; - } - - Object.defineProperty( self, 'raw', { - get: function() { - return self.blob.rawContent().toString(); - }, - enumerable: true - }); - - self.lookup = function( oid ) { - self.blob.lookup( self.repo, oid, function() { - var args = Array.prototype.slice.call( arguments ); - args[0] = git.util().error( args[0] ); - - callback.apply( self, args.concat( self ) ); - }); - }; - - return self; -}; - -exports.blob = _Blob; - - -exports = _Threads; diff --git a/lib/util.js b/lib/util.js index 9fd5fd5a4..c689c71c9 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,3 +1,5 @@ +var git = require('../'); + exports.makeSafe = function(object, key) { var oldFn = object[key]; object[key] = function() { @@ -9,3 +11,8 @@ exports.makeSafe = function(object, key) { } }; }; + +exports.normalizeOid = function(oid) { + if (typeof oid === 'string') oid = git.Oid.fromString(oid); + return oid; +}; diff --git a/package.json b/package.json index e84d6130a..41048b750 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "email": "mike@pagesofinterest.net" } ], - "main": "./lib/index.js", + "main": "index.js", "repository": { "type": "git", "url": "git://github.com/tbranyen/nodegit.git" diff --git a/src/base.cc b/src/base.cc index e3ef7aafc..3f78598c7 100755 --- a/src/base.cc +++ b/src/base.cc @@ -31,6 +31,8 @@ #include "../include/delta.h" #include "../include/threads.h" #include "../include/index.h" +#include "../include/index_entry.h" +#include "../include/index_time.h" #include "../include/tag.h" #include "../include/refdb.h" #include "../include/odb_object.h" @@ -44,6 +46,8 @@ extern "C" void init(Handle target) { GitReference::Initialize(target); GitIndex::Initialize(target); + GitIndexEntry::Initialize(target); + GitIndexTime::Initialize(target); GitTag::Initialize(target); GitSignature::Initialize(target); GitTime::Initialize(target); diff --git a/src/index.cc b/src/index.cc index d13913639..e5969ccb1 100644 --- a/src/index.cc +++ b/src/index.cc @@ -13,6 +13,7 @@ #include "../include/tree.h" #include "../include/diff_list.h" #include "../include/diff_options.h" +#include "../include/index_entry.h" using namespace v8; using namespace node; @@ -34,13 +35,13 @@ void GitIndex::Initialize(Handle target) { tpl->SetClassName(String::NewSymbol("Index")); NODE_SET_METHOD(tpl, "open", Open); - NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner); NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); NODE_SET_PROTOTYPE_METHOD(tpl, "readTree", ReadTree); NODE_SET_PROTOTYPE_METHOD(tpl, "writeTree", WriteTree); - NODE_SET_PROTOTYPE_METHOD(tpl, "entrycount", Entrycount); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); NODE_SET_PROTOTYPE_METHOD(tpl, "clear", Clear); + NODE_SET_PROTOTYPE_METHOD(tpl, "entry", Entry); NODE_SET_PROTOTYPE_METHOD(tpl, "remove", Remove); NODE_SET_PROTOTYPE_METHOD(tpl, "removeDirectory", RemoveDirectory); NODE_SET_PROTOTYPE_METHOD(tpl, "addByPath", AddBypath); @@ -149,19 +150,6 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { delete baton; } -Handle GitIndex::Owner(const Arguments& args) { - HandleScope scope; - - - git_repository * result = git_index_owner( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = GitRepo::New((void *)result); - return scope.Close(to); -} - Handle GitIndex::Read(const Arguments& args) { HandleScope scope; @@ -416,7 +404,7 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { delete baton; } -Handle GitIndex::Entrycount(const Arguments& args) { +Handle GitIndex::Size(const Arguments& args) { HandleScope scope; @@ -440,6 +428,24 @@ Handle GitIndex::Clear(const Arguments& args) { return Undefined(); } +Handle GitIndex::Entry(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); + } + + size_t from_n = (size_t) args[0]->ToUint32()->Value(); + + const git_index_entry * result = git_index_get_byindex( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_n + ); + + Handle to; + to = GitIndexEntry::New((void *)result); + return scope.Close(to); +} + Handle GitIndex::Remove(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { diff --git a/src/index_entry.cc b/src/index_entry.cc new file mode 100644 index 000000000..8217eac26 --- /dev/null +++ b/src/index_entry.cc @@ -0,0 +1,98 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/index_entry.h" +#include "../include/index_time.h" + +using namespace v8; +using namespace node; + +GitIndexEntry::GitIndexEntry(git_index_entry *raw) { + this->raw = raw; +} + +GitIndexEntry::~GitIndexEntry() { + free(this->raw); +} + +void GitIndexEntry::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("IndexEntry")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "ctime", Ctime); + NODE_SET_PROTOTYPE_METHOD(tpl, "mtime", Mtime); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("IndexEntry"), constructor_template); +} + +Handle GitIndexEntry::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_index_entry is required."))); + } + + GitIndexEntry* object = new GitIndexEntry((git_index_entry *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitIndexEntry::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitIndexEntry::constructor_template->NewInstance(1, argv)); +} + +git_index_entry *GitIndexEntry::GetValue() { + return this->raw; +} + + +Handle GitIndexEntry::Ctime(const Arguments& args) { + HandleScope scope; + Handle to; + + git_index_time *ctime = + &ObjectWrap::Unwrap(args.This())->GetValue()->ctime; + + to = GitIndexTime::New((void *)ctime); + return scope.Close(to); +} + +Handle GitIndexEntry::Mtime(const Arguments& args) { + HandleScope scope; + Handle to; + + git_index_time *mtime = + &ObjectWrap::Unwrap(args.This())->GetValue()->mtime; + + to = GitIndexTime::New((void *)mtime); + return scope.Close(to); +} + +Handle GitIndexEntry::Path(const Arguments& args) { + HandleScope scope; + Handle to; + + char * path = + ObjectWrap::Unwrap(args.This())->GetValue()->path; + + to = String::New(path); + return scope.Close(to); +} + +Persistent GitIndexEntry::constructor_template; diff --git a/src/index_time.cc b/src/index_time.cc new file mode 100644 index 000000000..90caa18f9 --- /dev/null +++ b/src/index_time.cc @@ -0,0 +1,84 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/index_time.h" + +using namespace v8; +using namespace node; + +GitIndexTime::GitIndexTime(git_index_time *raw) { + this->raw = raw; +} + +GitIndexTime::~GitIndexTime() { +} + +void GitIndexTime::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("IndexTime")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "seconds", Seconds); + NODE_SET_PROTOTYPE_METHOD(tpl, "nanoseconds", Nanoseconds); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("IndexTime"), constructor_template); +} + +Handle GitIndexTime::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_index_time is required."))); + } + + GitIndexTime* object = new GitIndexTime((git_index_time *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitIndexTime::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitIndexTime::constructor_template->NewInstance(1, argv)); +} + +git_index_time *GitIndexTime::GetValue() { + return this->raw; +} + + +Handle GitIndexTime::Seconds(const Arguments& args) { + HandleScope scope; + Handle to; + + git_time_t seconds = + ObjectWrap::Unwrap(args.This())->GetValue()->seconds; + + to = Uint32::New(seconds); + return scope.Close(to); +} + +Handle GitIndexTime::Nanoseconds(const Arguments& args) { + HandleScope scope; + Handle to; + + unsigned int nanoseconds = + ObjectWrap::Unwrap(args.This())->GetValue()->nanoseconds; + + to = Uint32::New(nanoseconds); + return scope.Close(to); +} + +Persistent GitIndexTime::constructor_template; diff --git a/src/odb.cc b/src/odb.cc index c179a8acd..ea4987070 100644 --- a/src/odb.cc +++ b/src/odb.cc @@ -39,7 +39,7 @@ void GitOdb::Initialize(Handle target) { NODE_SET_METHOD(tpl, "readHeader", ReadHeader); NODE_SET_PROTOTYPE_METHOD(tpl, "exists", Exists); NODE_SET_PROTOTYPE_METHOD(tpl, "refresh", Refresh); - NODE_SET_METHOD(tpl, "write", Write); + NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); NODE_SET_METHOD(tpl, "hash", Hash); NODE_SET_METHOD(tpl, "hashfile", Hashfile); @@ -136,25 +136,73 @@ Handle GitOdb::AddDiskAlternate(const Arguments& args) { Handle GitOdb::Read(const Arguments& args) { HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { + if (args.Length() == 0 || !args[0]->IsObject()) { return ThrowException(Exception::Error(String::New("Oid id is required."))); } - git_odb_object *out = NULL; - const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReadBaton* baton = new ReadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->dbReference = Persistent::New(args.This()); + baton->db = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); + return Undefined(); +} + +void GitOdb::ReadWork(uv_work_t *req) { + ReadBaton *baton = static_cast(req->data); int result = git_odb_read( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_id + &baton->out, + baton->db, + baton->id ); + baton->error_code = result; if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); + baton->error = giterr_last(); } +} + +void GitOdb::ReadAfterWork(uv_work_t *req) { + HandleScope scope; + ReadBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { Handle to; - to = GitOdbObject::New((void *)out); - return scope.Close(to); + to = GitOdbObject::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->dbReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; } Handle GitOdb::ReadPrefix(const Arguments& args) { @@ -257,8 +305,8 @@ Handle GitOdb::Refresh(const Arguments& args) { Handle GitOdb::Write(const Arguments& args) { HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Buffer data is required."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String data is required."))); } if (args.Length() == 1 || !args[1]->IsUint32()) { return ThrowException(Exception::Error(String::New("Number len is required."))); @@ -267,25 +315,82 @@ Handle GitOdb::Write(const Arguments& args) { return ThrowException(Exception::Error(String::New("Number type is required."))); } - git_oid *out = (git_oid *)malloc(sizeof(git_oid )); - const void * from_data = Buffer::Data(ObjectWrap::Unwrap(args[0]->ToObject())); - size_t from_len = (size_t) args[1]->ToUint32()->Value(); - git_otype from_type = (git_otype) args[2]->ToInt32()->Value(); + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteBaton* baton = new WriteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); + baton->odbReference = Persistent::New(args.This()); + baton->odb = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->dataReference = Persistent::New(args[0]); + String::Utf8Value data(args[0]->ToString()); + const void * from_data = strdup(*data); + baton->data = from_data; + baton->lenReference = Persistent::New(args[1]); + size_t from_len = (size_t) args[1]->ToUint32()->Value(); + baton->len = from_len; + baton->typeReference = Persistent::New(args[2]); + git_otype from_type = (git_otype) args[2]->ToInt32()->Value(); + baton->type = from_type; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); + return Undefined(); +} + +void GitOdb::WriteWork(uv_work_t *req) { + WriteBaton *baton = static_cast(req->data); int result = git_odb_write( - out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_data - , from_len - , from_type + baton->out, + baton->odb, + baton->data, + baton->len, + baton->type ); + baton->error_code = result; if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); + baton->error = giterr_last(); } +} + +void GitOdb::WriteAfterWork(uv_work_t *req) { + HandleScope scope; + WriteBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { Handle to; - to = GitOid::New((void *)out); - return scope.Close(to); + to = GitOid::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->odbReference.Dispose(); + baton->dataReference.Dispose(); + baton->lenReference.Dispose(); + baton->typeReference.Dispose(); + baton->callback.Dispose(); + delete baton->data; + delete baton; } Handle GitOdb::Hash(const Arguments& args) { diff --git a/src/odb_object.cc b/src/odb_object.cc index 1ca188007..c017057a1 100644 --- a/src/odb_object.cc +++ b/src/odb_object.cc @@ -30,9 +30,9 @@ void GitOdbObject::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("OdbObject")); - NODE_SET_PROTOTYPE_METHOD(tpl, "objectData", ObjectData); - NODE_SET_PROTOTYPE_METHOD(tpl, "objectSize", ObjectSize); - NODE_SET_METHOD(tpl, "objectType", ObjectType); + NODE_SET_PROTOTYPE_METHOD(tpl, "data", Data); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); @@ -64,7 +64,7 @@ git_odb_object *GitOdbObject::GetValue() { } -Handle GitOdbObject::ObjectData(const Arguments& args) { +Handle GitOdbObject::Data(const Arguments& args) { HandleScope scope; @@ -77,7 +77,7 @@ Handle GitOdbObject::ObjectData(const Arguments& args) { return scope.Close(to); } -Handle GitOdbObject::ObjectSize(const Arguments& args) { +Handle GitOdbObject::Size(const Arguments& args) { HandleScope scope; @@ -90,7 +90,7 @@ Handle GitOdbObject::ObjectSize(const Arguments& args) { return scope.Close(to); } -Handle GitOdbObject::ObjectType(const Arguments& args) { +Handle GitOdbObject::Type(const Arguments& args) { HandleScope scope; diff --git a/src/repo.cc b/src/repo.cc index 6414c0e94..d8d06c0c3 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -19,6 +19,8 @@ #include "../include/tag.h" #include "../include/signature.h" #include "../include/tree.h" +#include "../include/odb.h" +#include "../include/index.h" using namespace v8; using namespace node; @@ -43,6 +45,8 @@ void GitRepo::Initialize(Handle target) { NODE_SET_METHOD(tpl, "init", Init); NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); NODE_SET_PROTOTYPE_METHOD(tpl, "workdir", Workdir); + NODE_SET_PROTOTYPE_METHOD(tpl, "odb", Odb); + NODE_SET_PROTOTYPE_METHOD(tpl, "openIndex", openIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "getBlob", GetBlob); NODE_SET_PROTOTYPE_METHOD(tpl, "getCommit", GetCommit); NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); @@ -57,6 +61,7 @@ void GitRepo::Initialize(Handle target) { NODE_SET_METHOD(tpl, "createLightweightTag", CreateLightweightTag); NODE_SET_PROTOTYPE_METHOD(tpl, "getTree", GetTree); NODE_SET_METHOD(tpl, "reloadSubmodules", ReloadSubmodules); + NODE_SET_PROTOTYPE_METHOD(tpl, "delete", Delete); constructor_template = Persistent::New(tpl->GetFunction()); @@ -259,6 +264,87 @@ Handle GitRepo::Workdir(const Arguments& args) { return scope.Close(to); } +Handle GitRepo::Odb(const Arguments& args) { + HandleScope scope; + + git_odb *out = NULL; + + int result = git_repository_odb( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitOdb::New((void *)out); + return scope.Close(to); +} + +Handle GitRepo::openIndex(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + openIndexBaton* baton = new openIndexBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, openIndexWork, (uv_after_work_cb)openIndexAfterWork); + + return Undefined(); +} + +void GitRepo::openIndexWork(uv_work_t *req) { + openIndexBaton *baton = static_cast(req->data); + int result = git_repository_index( + &baton->out, + baton->repo + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::openIndexAfterWork(uv_work_t *req) { + HandleScope scope; + openIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitIndex::New((void *)baton->out); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + Handle GitRepo::GetBlob(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -1104,4 +1190,75 @@ void GitRepo::ReloadSubmodulesAfterWork(uv_work_t *req) { delete baton; } +Handle GitRepo::Delete(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DeleteBaton* baton = new DeleteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->tag_nameReference = Persistent::New(args[0]); + String::Utf8Value tag_name(args[0]->ToString()); + const char * from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, DeleteWork, (uv_after_work_cb)DeleteAfterWork); + + return Undefined(); +} + +void GitRepo::DeleteWork(uv_work_t *req) { + DeleteBaton *baton = static_cast(req->data); + int result = git_tag_delete( + baton->repo, + baton->tag_name + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::DeleteAfterWork(uv_work_t *req) { + HandleScope scope; + DeleteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->callback.Dispose(); + delete baton->tag_name; + delete baton; +} + Persistent GitRepo::constructor_template; diff --git a/src/signature.cc b/src/signature.cc index f8b679be1..0be456bf0 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -28,6 +28,7 @@ void GitSignature::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Signature")); + NODE_SET_METHOD(tpl, "create", Create); NODE_SET_METHOD(tpl, "now", Now); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); @@ -62,6 +63,47 @@ git_signature *GitSignature::GetValue() { } +Handle GitSignature::Create(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String email is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number time is required."))); + } + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number offset is required."))); + } + + git_signature *out = NULL; + String::Utf8Value name(args[0]->ToString()); + const char * from_name = strdup(*name); + String::Utf8Value email(args[1]->ToString()); + const char * from_email = strdup(*email); + git_time_t from_time = (git_time_t) args[2]->ToInt32()->Value(); + int from_offset = (int) args[3]->ToInt32()->Value(); + + int result = git_signature_new( + &out + , from_name + , from_email + , from_time + , from_offset + ); + delete from_name; + delete from_email; + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } + + Handle to; + to = GitSignature::New((void *)out); + return scope.Close(to); +} + Handle GitSignature::Now(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { diff --git a/src/tag.cc b/src/tag.cc index 617f31b21..226e172f1 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -33,13 +33,12 @@ void GitTag::Initialize(Handle target) { tpl->SetClassName(String::NewSymbol("Tag")); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "target", Target); + NODE_SET_PROTOTYPE_METHOD(tpl, "getTarget", GetTarget); NODE_SET_PROTOTYPE_METHOD(tpl, "targetId", TargetId); NODE_SET_PROTOTYPE_METHOD(tpl, "targetType", TargetType); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "tagger", Tagger); NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); - NODE_SET_METHOD(tpl, "delete", Delete); NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); @@ -84,14 +83,14 @@ Handle GitTag::Oid(const Arguments& args) { return scope.Close(to); } -Handle GitTag::Target(const Arguments& args) { +Handle GitTag::GetTarget(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - TargetBaton* baton = new TargetBaton; + GetTargetBaton* baton = new GetTargetBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; @@ -99,13 +98,13 @@ Handle GitTag::Target(const Arguments& args) { baton->tag = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); - uv_queue_work(uv_default_loop(), &baton->request, TargetWork, (uv_after_work_cb)TargetAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetTargetWork, (uv_after_work_cb)GetTargetAfterWork); return Undefined(); } -void GitTag::TargetWork(uv_work_t *req) { - TargetBaton *baton = static_cast(req->data); +void GitTag::GetTargetWork(uv_work_t *req) { + GetTargetBaton *baton = static_cast(req->data); int result = git_tag_target( &baton->target_out, baton->tag @@ -116,9 +115,9 @@ void GitTag::TargetWork(uv_work_t *req) { } } -void GitTag::TargetAfterWork(uv_work_t *req) { +void GitTag::GetTargetAfterWork(uv_work_t *req) { HandleScope scope; - TargetBaton *baton = static_cast(req->data); + GetTargetBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { @@ -212,31 +211,6 @@ Handle GitTag::Message(const Arguments& args) { return scope.Close(to); } -Handle GitTag::Delete(const Arguments& args) { - HandleScope scope; - if (args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository repo is required."))); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("String tag_name is required."))); - } - - git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - String::Utf8Value tag_name(args[1]->ToString()); - const char * from_tag_name = strdup(*tag_name); - - int result = git_tag_delete( - from_repo - , from_tag_name - ); - delete from_tag_name; - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } - - return Undefined(); -} - Handle GitTag::Peel(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 1dc1256bf..7a74d00d1 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -20,7 +20,6 @@ GitTreeEntry::GitTreeEntry(git_tree_entry *raw) { } GitTreeEntry::~GitTreeEntry() { - git_tree_entry_free(this->raw); } void GitTreeEntry::Initialize(Handle target) { diff --git a/v0.18.0.json b/v0.18.0.json index 3f015536c..2c9626a34 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -3754,9 +3754,67 @@ } ] }, + { + "filename": "index_time.h", + "jsClassName": "IndexTime", + "cppClassName": "GitIndexTime", + "cType": "git_index_time", + "fields": [ + { + "jsFunctionName": "seconds", + "cppFunctionName": "Seconds", + "name": "seconds", + "cType": "git_time_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "jsFunctionName": "nanoseconds", + "cppFunctionName": "Nanoseconds", + "name": "nanoseconds", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number" + } + ] + }, + { + "filename": "index_entry.h", + "dependencies": ["../include/index_time.h"], + "jsClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", + "cType": "git_index_entry", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "ctime", + "cppFunctionName": "Ctime", + "name": "ctime", + "cType": "git_index_time", + "cppClassName": "GitIndexTime", + "jsClassName": "IndexTime" + }, + { + "jsFunctionName": "mtime", + "cppFunctionName": "Mtime", + "name": "mtime", + "cType": "git_index_time", + "cppClassName": "GitIndexTime", + "jsClassName": "IndexTime" + }, + { + "jsFunctionName": "path", + "cppFunctionName": "Path", + "name": "path", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String" + } + ] + }, { "filename": "index.h", - "dependencies": ["../include/oid.h", "../include/repo.h", "../include/tree.h", "../include/diff_list.h", "../include/diff_options.h"], + "dependencies": ["../include/oid.h", "../include/repo.h", "../include/tree.h", "../include/diff_list.h", "../include/diff_options.h", "../include/index_entry.h"], "jsClassName": "Index", "cppClassName": "GitIndex", "cType": "git_index", @@ -3826,7 +3884,7 @@ "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "isFree": true, "jsFunctionName": "free", "cppFunctionName": "Free", @@ -3846,6 +3904,7 @@ "isSelf": true } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4057,8 +4116,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "entrycount", - "cppFunctionName": "Entrycount", + "jsFunctionName": "size", + "cppFunctionName": "Size", "return": { "cType": "size_t", "cppClassName": "Uint32" @@ -4102,15 +4161,14 @@ "jsClassName": "Number" } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "getByindex", - "cppFunctionName": "GetByindex", + "jsFunctionName": "entry", + "cppFunctionName": "Entry", "return": { "cType": "const git_index_entry *", - "cppClassName": "IndexEntry" + "cppClassName": "GitIndexEntry" } }, { @@ -4140,11 +4198,11 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "getBypath", - "cppFunctionName": "GetBypath", + "jsFunctionName": "getFile", + "cppFunctionName": "GetFile", "return": { "cType": "const git_index_entry *", - "cppClassName": "IndexEntry" + "cppClassName": "GitIndexEntry" } }, { @@ -4228,7 +4286,7 @@ { "name": "source_entry", "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" } ], @@ -4250,7 +4308,7 @@ { "name": "entry", "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" } ], @@ -4368,19 +4426,19 @@ { "name": "ancestor_entry", "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" }, { "name": "our_entry", "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" }, { "name": "their_entry", "cType": "const git_index_entry *", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" } ], @@ -4402,19 +4460,19 @@ { "name": "ancestor_out", "cType": "git_index_entry **", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" }, { "name": "our_out", "cType": "git_index_entry **", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" }, { "name": "their_out", "cType": "git_index_entry **", - "cppClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", "jsClassName": "IndexEntry" }, { @@ -5914,7 +5972,7 @@ "jsClassName": "Oid" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, "jsFunctionName": "read", @@ -6110,8 +6168,8 @@ { "name": "data", "cType": "const void *", - "cppClassName": "Buffer", - "jsClassName": "Buffer" + "cppClassName": "String", + "jsClassName": "String" }, { "name": "len", @@ -6126,9 +6184,9 @@ "jsClassName": "Number" } ], - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "write", "cppFunctionName": "Write", "return": { @@ -6354,8 +6412,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "objectData", - "cppFunctionName": "ObjectData", + "jsFunctionName": "data", + "cppFunctionName": "Data", "return": { "cType": "const void *", "cppClassName": "Wrapper" @@ -6375,8 +6433,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "objectSize", - "cppFunctionName": "ObjectSize", + "jsFunctionName": "size", + "cppFunctionName": "Size", "return": { "cType": "size_t", "cppClassName": "Uint32" @@ -6395,9 +6453,9 @@ ], "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "objectType", - "cppFunctionName": "ObjectType", + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", "return": { "cType": "git_otype", "cppClassName": "Int32" @@ -6419,8 +6477,8 @@ "isConstructorMethod": false, "isPrototypeMethod": true, "isFree": true, - "jsFunctionName": "objectFree", - "cppFunctionName": "ObjectFree", + "jsFunctionName": "free", + "cppFunctionName": "Free", "return": { "cType": "void", "cppClassName": "void" @@ -8211,40 +8269,6 @@ "isErrorCode": true } }, - { - "cFunctionName": "git_reference_list", - "args": [ - { - "name": "array", - "cType": "git_strarray *", - "cppClassName": "Strarray", - "jsClassName": "Strarray" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "list_flags", - "cType": "unsigned int", - "cppClassName": "Uint32", - "jsClassName": "Number" - } - ], - "ignore": true, - "isAsync": true, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "list", - "cppFunctionName": "List", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_reference_foreach", "args": [ @@ -9569,7 +9593,7 @@ }, { "filename": "repo.h", - "dependencies": ["../include/oid.h", "../include/commit.h", "../include/blob.h", "../include/object.h", "../include/reference.h", "../include/submodule.h", "../include/refdb.h", "../include/revwalk.h", "../include/tag.h", "../include/signature.h", "../include/tree.h"], + "dependencies": ["../include/oid.h", "../include/commit.h", "../include/blob.h", "../include/object.h", "../include/reference.h", "../include/submodule.h", "../include/refdb.h", "../include/revwalk.h", "../include/tag.h", "../include/signature.h", "../include/tree.h", "../include/odb.h", "../include/index.h"], "jsClassName": "Repo", "cppClassName": "GitRepo", "cType": "git_repository", @@ -10079,13 +10103,13 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, - "isPrototypeMethod": false, + "isPrototypeMethod": true, "jsFunctionName": "odb", "cppFunctionName": "Odb", "return": { @@ -10193,15 +10217,15 @@ "name": "repo", "cType": "git_repository *", "cppClassName": "GitRepo", - "jsClassName": "Repository" + "jsClassName": "Repository", + "isSelf": true } ], - "ignore": true, - "isAsync": false, + "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "index", - "cppFunctionName": "Index", + "isPrototypeMethod": true, + "jsFunctionName": "openIndex", + "cppFunctionName": "openIndex", "return": { "cType": "int", "cppClassName": "Int32", @@ -11552,6 +11576,169 @@ "cppClassName": "Int32", "isErrorCode": true } + }, + { + "cFunctionName": "git_tag_delete", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_list", + "args": [ + { + "name": "tag_names", + "cType": "git_strarray *", + "cppClassName": "Array", + "jsClassName": "Array", + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "listTags", + "cppFunctionName": "ListTags", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_list_match", + "args": [ + { + "name": "tag_names", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray", + "isReturn": true + }, + { + "name": "pattern", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "listMatch", + "cppFunctionName": "ListMatch", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_tag_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "callback", + "cType": "git_tag_foreach_cb", + "cppClassName": "TagForeachCb", + "jsClassName": "TagForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } + }, + { + "cFunctionName": "git_reference_list", + "args": [ + { + "name": "array", + "cType": "git_strarray *", + "cppClassName": "Array", + "jsClassName": "Array" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "list", + "cppFunctionName": "List", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true + } } ] }, @@ -12165,7 +12352,7 @@ { "name": "time", "cType": "git_time_t", - "cppClassName": "Integer", + "cppClassName": "Int32", "jsClassName": "Number" }, { @@ -12175,12 +12362,11 @@ "jsClassName": "Number" } ], - "ignore": true, - "isAsync": true, + "isAsync": false, "isConstructorMethod": true, "isPrototypeMethod": false, - "jsFunctionName": "new", - "cppFunctionName": "New", + "jsFunctionName": "create", + "cppFunctionName": "Create", "return": { "cType": "int", "cppClassName": "Int32", @@ -13257,8 +13443,8 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "target", - "cppFunctionName": "Target", + "jsFunctionName": "getTarget", + "cppFunctionName": "GetTarget", "return": { "cType": "int", "cppClassName": "Int32", @@ -13410,129 +13596,6 @@ "isErrorCode": true } }, - { - "cFunctionName": "git_tag_delete", - "args": [ - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "tag_name", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - } - ], - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "delete", - "cppFunctionName": "Delete", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tag_list", - "args": [ - { - "name": "tag_names", - "cType": "git_strarray *", - "cppClassName": "Strarray", - "jsClassName": "Strarray" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - } - ], - "ignore": true, - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "list", - "cppFunctionName": "List", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tag_list_match", - "args": [ - { - "name": "tag_names", - "cType": "git_strarray *", - "cppClassName": "Strarray", - "jsClassName": "Strarray" - }, - { - "name": "pattern", - "cType": "const char *", - "cppClassName": "String", - "jsClassName": "String" - }, - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - } - ], - "ignore": true, - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "listMatch", - "cppFunctionName": "ListMatch", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, - { - "cFunctionName": "git_tag_foreach", - "args": [ - { - "name": "repo", - "cType": "git_repository *", - "cppClassName": "GitRepo", - "jsClassName": "Repository" - }, - { - "name": "callback", - "cType": "git_tag_foreach_cb", - "cppClassName": "TagForeachCb", - "jsClassName": "TagForeachCb" - }, - { - "name": "payload", - "cType": "void *", - "cppClassName": "void", - "jsClassName": "void" - } - ], - "ignore": true, - "isAsync": false, - "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "foreach", - "cppFunctionName": "Foreach", - "return": { - "cType": "int", - "cppClassName": "Int32", - "isErrorCode": true - } - }, { "cFunctionName": "git_tag_peel", "args": [ @@ -13877,7 +13940,6 @@ "jsClassName": "TreeEntry", "cppClassName": "GitTreeEntry", "cType": "git_tree_entry", - "freeFunctionName": "git_tree_entry_free", "functions": [ { "cFunctionName": "git_tree_entry_dup", @@ -14192,7 +14254,8 @@ "cppFunctionName": "EntryByName", "return": { "cType": "const git_tree_entry *", - "cppClassName": "GitTreeEntry" + "cppClassName": "GitTreeEntry", + "shouldAlloc": true } }, { @@ -14219,7 +14282,8 @@ "cppFunctionName": "EntryByIndex", "return": { "cType": "const git_tree_entry *", - "cppClassName": "GitTreeEntry" + "cppClassName": "GitTreeEntry", + "shouldAlloc": true } }, { @@ -14246,7 +14310,8 @@ "cppFunctionName": "EntryByOid", "return": { "cType": "const git_tree_entry *", - "cppClassName": "GitTreeEntry" + "cppClassName": "GitTreeEntry", + "shouldAlloc": true } }, { From 4bf472da9fe2ebc20cc5cfd64a328481882ddb0d Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 3 Jul 2013 18:44:52 +0200 Subject: [PATCH 20/28] Nicer diff API --- TODO | 8 ++--- lib/commit.js | 2 +- lib/convenient_hunk.js | 17 +++++++++++ lib/convenient_patch.js | 68 +++++++++++++++++++++++++++++++++++++++++ lib/diff_list.js | 6 ++-- test/commit.js | 24 ++++++--------- test/difflist.js | 63 ++++++++++++++++++-------------------- 7 files changed, 132 insertions(+), 56 deletions(-) create mode 100644 lib/convenient_hunk.js create mode 100644 lib/convenient_patch.js diff --git a/TODO b/TODO index f94421965..383baff5a 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,9 @@ +- make normalizeOid do more work. +- extract out more partials + - audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. - rename files remove .h -- Cleanup diff api -- free everything malloc'd +- free everything malloc'd, or figure out the right coding conventions for copying. - codegen documentation -- extract out more partials - audit return types for things that should be copied - array handling -- make normalizeOid do more work. diff --git a/lib/commit.js b/lib/commit.js index 9cb83a8fd..1039f55ed 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -127,7 +127,7 @@ Commit.prototype.getParents = function(callback) { * * @param {Commit~parentsDiffTreesCallback} callback */ -Commit.prototype.diff = function(callback) { +Commit.prototype.getDiff = function(callback) { /** * @callback Commit~parentsDiffTreesCallback Callback executed on diff trees retrieval. * @param {GitError|null} error An Error or null if successful. diff --git a/lib/convenient_hunk.js b/lib/convenient_hunk.js new file mode 100644 index 000000000..8e0a61090 --- /dev/null +++ b/lib/convenient_hunk.js @@ -0,0 +1,17 @@ +function ConvenientHunk(raw, i) { + this.raw = raw; + this.i = i; +} + +ConvenientHunk.prototype.size = function() { + return this.raw.hunk(this.i).lines; +}; + +ConvenientHunk.prototype.lines = function() { + var result = []; + for (var i = 0; i < this.size(); i++) + result.push(this.raw.line(this.i, i)); + return result; +}; + +exports.ConvenientHunk = ConvenientHunk; diff --git a/lib/convenient_patch.js b/lib/convenient_patch.js new file mode 100644 index 000000000..c5b073a09 --- /dev/null +++ b/lib/convenient_patch.js @@ -0,0 +1,68 @@ +var git = require('../'), + DiffList = git.DiffList, + ConvenientHunk = require('./convenient_hunk').ConvenientHunk; + +function ConvenientPatch(raw) { + this.raw = raw; +} + +ConvenientPatch.prototype.oldFile = function() { + return this.raw.delta.oldFile(); +}; + +ConvenientPatch.prototype.newFile = function() { + return this.raw.delta.newFile(); +}; + +ConvenientPatch.prototype.size = function() { + return this.raw.patch.size(); +}; + +ConvenientPatch.prototype.status = function() { + return this.raw.delta.status(); +}; + +ConvenientPatch.prototype.isUnmodified = function() { + return this.status() == DiffList.Delta.Unmodified; +}; + +ConvenientPatch.prototype.isAdded = function() { + return this.status() == DiffList.Delta.Added; +}; + +ConvenientPatch.prototype.isDeleted = function() { + return this.status() == DiffList.Delta.Deleted; +}; + +ConvenientPatch.prototype.isModified = function() { + return this.status() == DiffList.Delta.Modified; +}; + +ConvenientPatch.prototype.isRenamed = function() { + return this.status() == DiffList.Delta.Renamed; +}; + +ConvenientPatch.prototype.isCopied = function() { + return this.status() == DiffList.Delta.Copied; +}; + +ConvenientPatch.prototype.isIgnored = function() { + return this.status() == DiffList.Delta.Ignored; +}; + +ConvenientPatch.prototype.isUntracked = function() { + return this.status() == DiffList.Delta.Untracked; +}; + +ConvenientPatch.prototype.isTypeChange = function() { + return this.status() == DiffList.Delta.TypeChange; +}; + +ConvenientPatch.prototype.hunks = function() { + var result = []; + for (var i = 0; i < this.size(); i++) + result.push(new ConvenientHunk(this.raw.patch, i)); + return result; +}; + +exports.ConvenientPatch = ConvenientPatch; diff --git a/lib/diff_list.js b/lib/diff_list.js index 17ff30230..52ab70852 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -1,7 +1,10 @@ var git = require('../'), DiffList = git.DiffList, + ConvenientPatch = require('./convenient_patch').ConvenientPatch, events = require('events'); +console.log(ConvenientPatch); + /** * Refer to vendor/libgit2/include/git2/diff.h for delta type definitions. * @@ -37,7 +40,6 @@ DiffList.LineOrigin = { /** 'B' */ Binary: 102 }; - /** * Retrieve patches * @@ -47,7 +49,7 @@ DiffList.prototype.patches = function() { var size = this.size(); result = []; for (var i = 0; i < size; i++) { - result.push(this.patch(i)); + result.push(new ConvenientPatch(this.patch(i))); } return result; }; diff --git a/test/commit.js b/test/commit.js index 1549f271a..1e2e7f314 100644 --- a/test/commit.js +++ b/test/commit.js @@ -5,12 +5,11 @@ var git = require('../'), var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; exports.message = function(test) { - test.expect(3); + test.expect(2); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { var message = commit.message(); test.equals(error, null, 'There should be no error'); - test.notEqual(message, null, 'Message should not be null'); test.equals(message, 'Update README.md', 'Message should match expected value'); test.done(); }); @@ -18,12 +17,11 @@ exports.message = function(test) { }; exports.sha = function(test) { - test.expect(3); + test.expect(2); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { var sha = commit.sha(); test.equals(error, null, 'There should be no error'); - test.notEqual(sha, null, 'SHA should not be null'); test.equals(sha, historyCountKnownSHA, 'SHA should match expected value'); test.done(); }); @@ -31,12 +29,11 @@ exports.sha = function(test) { }; exports.time = function(test) { - test.expect(3); + test.expect(2); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { var time = commit.timeMs(); test.equals(error, null, 'There should be no error'); - test.notEqual(time, null, 'Time should not be null'); test.equals(time, 1362012884000, 'Time should match expected value'); test.done(); }); @@ -44,13 +41,11 @@ exports.time = function(test) { }; exports.date = function(test) { - test.expect(4); + test.expect(2); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { var date = commit.date(); test.equals(error, null, 'There should be no error'); - test.notEqual(date, null, 'Date should not be null'); - test.equal(date instanceof Date, true, 'Date should be a date object'); test.equals(date.getTime(), 1362012884000, 'Date should match expected value'); test.done(); }); @@ -58,12 +53,11 @@ exports.date = function(test) { }; exports.offset = function(test) { - test.expect(3); + test.expect(2); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { var offset = commit.offset(); test.equals(error, null, 'There should be no error'); - test.notEqual(offset, null, 'Offset should not be null'); test.equals(offset, 780, 'Offset should match expected value'); test.done(); }); @@ -226,14 +220,14 @@ exports.tree = function(test) { }; /** - * Test that parentsDiffTrees works as expected. + * Test that getDiff works as expected. */ -exports.parentsDiffTrees = function(test) { +exports.getDiff = function(test) { test.expect(1); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { - commit.diff(function(error, parentsDiffTrees) { - test.equals(parentsDiffTrees.length, 1, 'Should be one item in parents diff trees'); + commit.getDiff(function(error, diff) { + test.equals(diff.length, 1, 'Should be one item in parents diff trees'); test.done(); }); }); diff --git a/test/difflist.js b/test/difflist.js index 12fcd54b2..6815e2d82 100644 --- a/test/difflist.js +++ b/test/difflist.js @@ -13,40 +13,35 @@ exports.walkingDiffs = function(test) { test.expect(16); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { - commit.getParents(function(error, parents) { - parents[0].getTree(function(error, parentTree) { - commit.getTree(function(error, commitTree) { - parentTree.diff(commitTree, function(error, diffList) { - test.equal(null, error, 'Should not error'); - - diffList.patches().forEach(function(patch) { - var delta = patch.delta, patch = patch.patch; - test.equal(null, error, 'Should not error'); - test.equal(delta.oldFile().path(), 'README.md', 'Old file path should match expected'); - test.equal(delta.newFile().path(), 'README.md', 'New file path should match expected'); - test.equal(patch.size(), 1, 'Content array should be of known length'); - var hunk = patch.hunk(0); - - test.equal(hunk.lines, 5, 'Content array should be of known length'); - test.equal(delta.status(), git.DiffList.Delta.Modified, 'Status should be known type'); - - test.equal(patch.line(0, 0).lineOrigin, git.DiffList.LineOrigin.Context, 'First content item should be context'); - test.equal(patch.line(0, 1).lineOrigin, git.DiffList.LineOrigin.Context, 'Second content item should be context'); - test.equal(patch.line(0, 2).lineOrigin, git.DiffList.LineOrigin.Context, 'Third content item should be context'); - - var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; - test.equal(patch.line(0, 3).content, oldContent, 'Old content should match known value'); - test.equal(patch.line(0, 3).lineOrigin, git.DiffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); - test.equal(patch.line(0, 3).length, 90, 'Fourth content length should match known value'); - - var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; - test.equal(patch.line(0, 4).content, newContent, 'New content should match known value'); - test.equal(patch.line(0, 4).lineOrigin, git.DiffList.LineOrigin.Addition, 'Fifth content item should be addition'); - test.equal(patch.line(0, 4).length, 162, 'Fifth content length should match known value'); - test.done(); - }); - }); - }); + commit.getDiff(function(error, diffList) { + test.equal(null, error, 'Should not error'); + + diffList[0].patches().forEach(function(patch) { + test.equal(null, error, 'Should not error'); + + test.equal(patch.oldFile().path(), 'README.md', 'Old file path should match expected'); + test.equal(patch.newFile().path(), 'README.md', 'New file path should match expected'); + test.equal(patch.size(), 1, 'Content array should be of known length'); + test.ok(patch.isModified(), 'Status should be known type'); + + var hunk = patch.hunks()[0]; + test.equal(hunk.size(), 5, 'Content array should be of known length'); + var lines = hunk.lines(); + + test.equal(lines[0].lineOrigin, git.DiffList.LineOrigin.Context, 'First content item should be context'); + test.equal(lines[1].lineOrigin, git.DiffList.LineOrigin.Context, 'Second content item should be context'); + test.equal(lines[2].lineOrigin, git.DiffList.LineOrigin.Context, 'Third content item should be context'); + + var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; + test.equal(lines[3].content, oldContent, 'Old content should match known value'); + test.equal(lines[3].lineOrigin, git.DiffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); + test.equal(lines[3].length, 90, 'Fourth content length should match known value'); + + var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; + test.equal(lines[4].content, newContent, 'New content should match known value'); + test.equal(lines[4].lineOrigin, git.DiffList.LineOrigin.Addition, 'Fifth content item should be addition'); + test.equal(lines[4].length, 162, 'Fifth content length should match known value'); + test.done(); }); }); }); From 6f85118ffe67d07819a0b11208ea6df1800dd585 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 3 Jul 2013 18:53:05 +0200 Subject: [PATCH 21/28] Refactored normalizeOid --- lib/odb.js | 6 +----- lib/repo.js | 14 +++++++++----- lib/util.js | 11 ++++++++--- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/odb.js b/lib/odb.js index 586c047c0..9c731488d 100644 --- a/lib/odb.js +++ b/lib/odb.js @@ -8,9 +8,5 @@ var git = require('../'), * @param {String|Oid} String sha or Oid * @param {Repo~commitCallback} callback */ -var oldRead = Odb.prototype.read; -Odb.prototype.read = function(oid, callback) { - var self = this; - oldRead.call(this, util.normalizeOid(oid), callback); -}; +util.normalizeOid(Odb.prototype, 'read'); util.makeSafe(Odb.prototype, 'read'); diff --git a/lib/repo.js b/lib/repo.js index ca2f9246b..8e5754a3e 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -63,12 +63,13 @@ util.makeSafe(Repo.prototype, 'getReference'); var oldGetCommit = Repo.prototype.getCommit; Repo.prototype.getCommit = function(oid, callback) { var self = this; - oldGetCommit.call(this, util.normalizeOid(oid), function(error, commit) { + oldGetCommit.call(this, oid, function(error, commit) { if (error) return callback(error); commit.repo = self; callback(null, commit); }); }; +util.normalizeOid(Repo.prototype, 'getCommit'); util.makeSafe(Repo.prototype, 'getCommit'); /** @@ -80,13 +81,14 @@ util.makeSafe(Repo.prototype, 'getCommit'); var oldBlob = Repo.prototype.getBlob; Repo.prototype.getBlob = function(oid, callback) { var self = this; - oldBlob.call(this, util.normalizeOid(oid), function(error, blob) { + oldBlob.call(this, oid, function(error, blob) { if (error) return callback(error); blob.repo = self; callback(null, blob); }); }; -util.makeSafe(Repo.prototype, 'blob'); +util.normalizeOid(Repo.prototype, 'getBlob'); +util.makeSafe(Repo.prototype, 'getBlob'); /** * Retrieve the blob represented by the oid. @@ -97,12 +99,13 @@ util.makeSafe(Repo.prototype, 'blob'); var oldGetTree = Repo.prototype.getTree; Repo.prototype.getTree = function(oid, callback) { var self = this; - oldGetTree.call(this, util.normalizeOid(oid), function(error, tree) { + oldGetTree.call(this, oid, function(error, tree) { if (error) return callback(error); tree.repo = self; callback(null, tree); }); }; +util.normalizeOid(Repo.prototype, 'getTree'); util.makeSafe(Repo.prototype, 'getTree'); /** @@ -114,8 +117,9 @@ util.makeSafe(Repo.prototype, 'getTree'); var oldGetTag = Repo.prototype.getTag; Repo.prototype.getTag = function(oid, callback) { var self = this; - oldGetTag.call(this, util.normalizeOid(oid), callback); + oldGetTag.call(this, oid, callback); }; +util.normalizeOid(Repo.prototype, 'getTag'); util.makeSafe(Repo.prototype, 'getTag'); /** diff --git a/lib/util.js b/lib/util.js index c689c71c9..a9db9724e 100644 --- a/lib/util.js +++ b/lib/util.js @@ -12,7 +12,12 @@ exports.makeSafe = function(object, key) { }; }; -exports.normalizeOid = function(oid) { - if (typeof oid === 'string') oid = git.Oid.fromString(oid); - return oid; +exports.normalizeOid = function(object, key) { + var oldFn = object[key]; + object[key] = function() { + var oid = arguments[0]; + if (typeof oid === 'string') oid = git.Oid.fromString(oid); + arguments[0] = oid; + oldFn.apply(this, arguments); + }; }; From 5de90007b32a96ef0ed31a2f9e8b850e2350cfaa Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 3 Jul 2013 19:20:37 +0200 Subject: [PATCH 22/28] Extracted out partials so template code is slightly easier to follow --- TODO | 4 - templates/asyncFunction.cc.ejs | 128 ++++++++++++++++++ templates/class.cc.ejs | 228 +-------------------------------- templates/fields.cc.ejs | 20 +++ templates/syncFunction.cc.ejs | 77 +++++++++++ 5 files changed, 228 insertions(+), 229 deletions(-) create mode 100644 templates/asyncFunction.cc.ejs create mode 100644 templates/fields.cc.ejs create mode 100644 templates/syncFunction.cc.ejs diff --git a/TODO b/TODO index 383baff5a..d1010c413 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,4 @@ -- make normalizeOid do more work. -- extract out more partials - - audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. -- rename files remove .h - free everything malloc'd, or figure out the right coding conventions for copying. - codegen documentation - audit return types for things that should be copied diff --git a/templates/asyncFunction.cc.ejs b/templates/asyncFunction.cc.ejs new file mode 100644 index 000000000..eba4589a3 --- /dev/null +++ b/templates/asyncFunction.cc.ejs @@ -0,0 +1,128 @@ +Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <% var jsArg; -%> + <% include guardArguments.cc.ejs -%> + + if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + <%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; +-%> +<% if (!arg.isReturn) { -%> +<% if (arg.isSelf) { -%> + baton-><%- arg.name %>Reference = Persistent::New(args.This()); + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); +<% } else { -%> + baton-><%- arg.name %>Reference = Persistent::New(args[<%- jsArg %>]); +<% if (arg.isOptional) { -%> + if (args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { +<% } -%> + <% include convertFromV8.cc.ejs -%> + baton-><%- arg.name %> = from_<%- arg.name %>; +<% if (arg.isOptional) { -%> + } else { + baton-><%- arg.name %> = NULL; + } +<% } -%> +<% } -%> +<% if (!(arg.isReturn || arg.isSelf)) jsArg++; -%> +<% } else { -%> +<% if (arg.shouldAlloc) { -%> + baton-><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); +<% } else { -%> +<% } -%> +<% } -%> +<% } -%> + baton->callback = Persistent::New(Local::Cast(args[<%- jsArg %>])); + + uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); + + return Undefined(); +} + +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { + <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); + <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> + <% if (arg.isReturn && /\*\*/.test(arg.cType)) { %>&<% } %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> +<% } -%> + ); +<% if (functionInfo.return.isErrorCode) { -%> + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +<% } else { -%> + baton->result = result; +<% } -%> +} + +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t *req) { + HandleScope scope; + <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { +<% if (!returns.length) { %> + Handle result = Local::New(Undefined()); +<% } else if (returns.length == 1) { -%> +<% var to = returns[0]; to.name = "baton->" + to.name; -%> + Handle to; + <% include convertToV8.cc.ejs -%> + Handle result = to; +<% } else { -%> + Handle result = Object::New(); + Handle to; +<% + for (r in returns) { + var to = returns[r]; +-%> + <% include convertToV8.cc.ejs -%> + result->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); +<% } -%> +<% } -%> + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } +<% + for (var i = 0, j = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn) continue; +-%> + baton-><%- arg.name %>Reference.Dispose(); +<% } -%> + baton->callback.Dispose(); +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> +<% if (arg.cppClassName == 'String') { -%> + delete baton-><%- arg.name %>; +<% } -%> +<% } -%> + delete baton; +} diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 66a8acd14..5ce5818b1 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -133,235 +133,13 @@ void <%- cppClassName %>::Initialize(Handle target) { -%> <% if (functionInfo.isAsync) { -%> -Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { - HandleScope scope; - <% var jsArg; -%> - <% include templates/guardArguments.cc.ejs -%> - - if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - <%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->request.data = baton; -<% - for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { - var arg = functionInfo.args[cArg]; --%> -<% if (!arg.isReturn) { -%> -<% if (arg.isSelf) { -%> - baton-><%- arg.name %>Reference = Persistent::New(args.This()); - baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); -<% } else { -%> - baton-><%- arg.name %>Reference = Persistent::New(args[<%- jsArg %>]); -<% if (arg.isOptional) { -%> - if (args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { -<% } -%> - <% include templates/convertFromV8.cc.ejs -%> - baton-><%- arg.name %> = from_<%- arg.name %>; -<% if (arg.isOptional) { -%> - } else { - baton-><%- arg.name %> = NULL; - } -<% } -%> -<% } -%> -<% if (!(arg.isReturn || arg.isSelf)) jsArg++; -%> -<% } else { -%> -<% if (arg.shouldAlloc) { -%> - baton-><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); -<% } else { -%> -<% } -%> -<% } -%> -<% } -%> - baton->callback = Persistent::New(Local::Cast(args[<%- jsArg %>])); - - uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); - - return Undefined(); -} - -void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { - <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); - <%- functionInfo.return.cType %> result = <%- functionInfo.cFunctionName %>( -<% - for (var i = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; --%> - <% if (arg.isReturn && /\*\*/.test(arg.cType)) { %>&<% } %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> -<% } -%> - ); -<% if (functionInfo.return.isErrorCode) { -%> - baton->error_code = result; - if (result != GIT_OK) { - baton->error = giterr_last(); - } -<% } else { -%> - baton->result = result; -<% } -%> -} - -void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t *req) { - HandleScope scope; - <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); - - TryCatch try_catch; - if (baton->error_code == GIT_OK) { -<% if (!returns.length) { %> - Handle result = Local::New(Undefined()); -<% } else if (returns.length == 1) { -%> -<% var to = returns[0]; to.name = "baton->" + to.name; -%> - Handle to; - <% include templates/convertToV8.cc.ejs -%> - Handle result = to; -<% } else { -%> - Handle result = Object::New(); - Handle to; -<% - for (r in returns) { - var to = returns[r]; --%> - <% include templates/convertToV8.cc.ejs -%> - result->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); -<% } -%> -<% } -%> - Handle argv[2] = { - Local::New(Null()), - result - }; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - } else if (baton->error) { - Handle argv[1] = { - Exception::Error(String::New(baton->error->message)) - }; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - } else { - baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } -<% - for (var i = 0, j = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; - if (arg.isReturn) continue; --%> - baton-><%- arg.name %>Reference.Dispose(); -<% } -%> - baton->callback.Dispose(); -<% - for (var i = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; --%> -<% if (arg.cppClassName == 'String') { -%> - delete baton-><%- arg.name %>; -<% } -%> -<% } -%> - delete baton; -} -<% } else { -%> -Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { - HandleScope scope; - <% include templates/guardArguments.cc.ejs -%> - -<% - for (var i = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; - if (!arg.isReturn) continue; --%> -<% if (arg.shouldAlloc) { -%> - <%- arg.cType %><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); -<% } else { -%> - <%- arg.cType.replace('*', '') %><%- arg.name %> = NULL; -<% } -%> -<% } -%> -<% - for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { - var arg = functionInfo.args[cArg]; - if (arg.isSelf || arg.isReturn) continue; --%> -<% include templates/convertFromV8.cc.ejs -%> -<% jsArg++; -%> -<% } %> - <% if (returns.length || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( -<% - for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { - var arg = functionInfo.args[cArg]; --%> - <% if (cArg > 0) { %>, <% } -%><% if (arg.isReturn && !arg.shouldAlloc) { %>&<% } -%> -<% if (arg.isSelf) { -%> -ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() -<% } else if (arg.isReturn) { -%> -<%- arg.name %> -<% } else { -%> -from_<%- arg.name %> -<% } -%> -<% - if (!(arg.isReturn || arg.isSelf)) jsArg++; - } --%> - ); -<% - for (var i = 0; i < functionInfo.args.length; i++) { - var arg = functionInfo.args[i]; - if (arg.isSelf || arg.isReturn) continue; --%> -<% if (arg.cppClassName == 'String') { -%> - delete from_<%- arg.name %>; -<% } -%> -<% } -%> -<% if (functionInfo.return.isErrorCode) { -%> - if (result != GIT_OK) { - return ThrowException(Exception::Error(String::New(giterr_last()->message))); - } -<% } -%> - -<% if (!returns.length) { -%> - return Undefined(); -<% } else if (returns.length == 1) { -%> -<% var to = returns[0]; -%> - Handle to; - <% include templates/convertToV8.cc.ejs -%> - return scope.Close(to); +<% include templates/asyncFunction.cc.ejs -%> <% } else { -%> - Handle toReturn = Object::New(); - Handle to; -<% - for (r in returns) { - var to = returns[r]; --%> - <% include templates/convertToV8.cc.ejs -%> - toReturn->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); - -<% } -%> - return scope.Close(toReturn); -<% } -%> -} -<% } -%> -<% } -%> +<% include templates/syncFunction.cc.ejs -%> <% } -%> -<% if (typeof fields != 'undefined') { -%> -<% - for (var i in fields) { - var fieldInfo = fields[i]; - if (fieldInfo.ignore) continue; --%> - -Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Arguments& args) { - HandleScope scope; - <% var to = fieldInfo; -%> - Handle to; - - <%- fieldInfo.cType %> <% if (!isV8Value(fieldInfo.cppClassName)) { %>*<% } %><%- fieldInfo.name %> = - <% if (!isV8Value(fieldInfo.cppClassName)) { %>&<% } %>ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; - - <% include templates/convertToV8.cc.ejs -%> - return scope.Close(to); -} <% } -%> <% } -%> +<% include templates/fields.cc.ejs -%> <% if (typeof cType != 'undefined') { -%> Persistent <%- cppClassName %>::constructor_template; diff --git a/templates/fields.cc.ejs b/templates/fields.cc.ejs new file mode 100644 index 000000000..44c8fcb57 --- /dev/null +++ b/templates/fields.cc.ejs @@ -0,0 +1,20 @@ +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> + +Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <% var to = fieldInfo; -%> + Handle to; + + <%- fieldInfo.cType %> <% if (!isV8Value(fieldInfo.cppClassName)) { %>*<% } %><%- fieldInfo.name %> = + <% if (!isV8Value(fieldInfo.cppClassName)) { %>&<% } %>ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; + + <% include convertToV8.cc.ejs -%> + return scope.Close(to); +} +<% } -%> +<% } -%> diff --git a/templates/syncFunction.cc.ejs b/templates/syncFunction.cc.ejs new file mode 100644 index 000000000..6544d88a0 --- /dev/null +++ b/templates/syncFunction.cc.ejs @@ -0,0 +1,77 @@ +Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <% include guardArguments.cc.ejs -%> + +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (!arg.isReturn) continue; +-%> +<% if (arg.shouldAlloc) { -%> + <%- arg.cType %><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); +<% } else { -%> + <%- arg.cType.replace('*', '') %><%- arg.name %> = NULL; +<% } -%> +<% } -%> +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; + if (arg.isSelf || arg.isReturn) continue; +-%> +<% include convertFromV8.cc.ejs -%> +<% jsArg++; -%> +<% } %> + <% if (returns.length || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; +-%> + <% if (cArg > 0) { %>, <% } -%><% if (arg.isReturn && !arg.shouldAlloc) { %>&<% } -%> +<% if (arg.isSelf) { -%> +ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() +<% } else if (arg.isReturn) { -%> +<%- arg.name %> +<% } else { -%> +from_<%- arg.name %> +<% } -%> +<% + if (!(arg.isReturn || arg.isSelf)) jsArg++; + } +-%> + ); +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isSelf || arg.isReturn) continue; +-%> +<% if (arg.cppClassName == 'String') { -%> + delete from_<%- arg.name %>; +<% } -%> +<% } -%> +<% if (functionInfo.return.isErrorCode) { -%> + if (result != GIT_OK) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } +<% } -%> + +<% if (!returns.length) { -%> + return Undefined(); +<% } else if (returns.length == 1) { -%> +<% var to = returns[0]; -%> + Handle to; + <% include convertToV8.cc.ejs -%> + return scope.Close(to); +<% } else { -%> + Handle toReturn = Object::New(); + Handle to; +<% + for (r in returns) { + var to = returns[r]; +-%> + <% include convertToV8.cc.ejs -%> + toReturn->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); + +<% } -%> + return scope.Close(toReturn); +<% } -%> +} From 1273fff13b3c28cfdb13ba7f575d696d2a8902e1 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Thu, 4 Jul 2013 11:30:26 +0200 Subject: [PATCH 23/28] Audit of memory leaks --- TODO | 3 - binding.gyp | 4 +- include/functions/copy.h | 15 ++ include/functions/string.h | 8 - include/object.h | 1 - lib/diff_list.js | 2 - munge.js | 46 ++++- src/blob.cc | 7 +- src/branch.cc | 2 + src/commit.cc | 17 +- src/delta.cc | 9 +- src/diff_file.cc | 6 +- src/diff_find_options.cc | 2 + src/diff_list.cc | 2 + src/diff_options.cc | 2 + src/diff_range.cc | 2 + src/functions/copy.cc | 39 +++++ src/index.cc | 6 +- src/index_entry.cc | 8 +- src/index_time.cc | 3 + src/object.cc | 19 +- src/odb.cc | 2 + src/odb_object.cc | 5 +- src/oid.cc | 3 + src/patch.cc | 5 +- src/refdb.cc | 3 + src/reference.cc | 6 +- src/repo.cc | 4 + src/revwalk.cc | 2 + src/signature.cc | 6 +- src/submodule.cc | 9 +- src/tag.cc | 11 +- src/threads.cc | 2 + src/time.cc | 2 + src/tree.cc | 14 +- src/tree_entry.cc | 6 +- templates/class.cc.ejs | 2 + templates/convertToV8.cc.ejs | 3 + v0.18.0.json | 324 +++++++++++++++++++++++++---------- 39 files changed, 460 insertions(+), 152 deletions(-) create mode 100644 include/functions/copy.h delete mode 100644 include/functions/string.h create mode 100644 src/functions/copy.cc diff --git a/TODO b/TODO index d1010c413..ef875f88f 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,2 @@ -- audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. -- free everything malloc'd, or figure out the right coding conventions for copying. - codegen documentation -- audit return types for things that should be copied - array handling diff --git a/binding.gyp b/binding.gyp index d0069fe86..0531f01de 100644 --- a/binding.gyp +++ b/binding.gyp @@ -31,7 +31,9 @@ 'src/refdb.cc', 'src/odb_object.cc', 'src/odb.cc', - 'src/submodule.cc' + 'src/submodule.cc', + 'src/functions/copy.cc', + ], 'include_dirs': [ diff --git a/include/functions/copy.h b/include/functions/copy.h new file mode 100644 index 000000000..514b8de29 --- /dev/null +++ b/include/functions/copy.h @@ -0,0 +1,15 @@ +#include + +#include "git2.h" + +#ifndef COPY_FUNCTIONS +#define COPY_FUNCTIONS + +const git_oid *git_oid_dup(const git_oid *arg); +const git_index_entry *git_index_entry_dup(const git_index_entry *arg); +const git_index_time *git_index_time_dup(const git_index_time *arg); +const git_time *git_time_dup(const git_time *arg); +const git_diff_delta *git_diff_delta_dup(const git_diff_delta *arg); +const git_diff_file *git_diff_file_dup(const git_diff_file *arg); + +#endif diff --git a/include/functions/string.h b/include/functions/string.h deleted file mode 100644 index 85c63027b..000000000 --- a/include/functions/string.h +++ /dev/null @@ -1,8 +0,0 @@ -#include - -#ifndef STRING_FUNCTIONS -#define STRING_FUNCTIONS - -std::string stringArgToString(const v8::Local arg); - -#endif diff --git a/include/object.h b/include/object.h index c0f3d6d30..6ab9d3537 100644 --- a/include/object.h +++ b/include/object.h @@ -33,7 +33,6 @@ class GitObject : public ObjectWrap { static Handle Oid(const Arguments& args); static Handle Type(const Arguments& args); - static Handle Owner(const Arguments& args); static Handle Peel(const Arguments& args); static void PeelWork(uv_work_t* req); static void PeelAfterWork(uv_work_t* req); diff --git a/lib/diff_list.js b/lib/diff_list.js index 52ab70852..f0967ba4f 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -3,8 +3,6 @@ var git = require('../'), ConvenientPatch = require('./convenient_patch').ConvenientPatch, events = require('events'); -console.log(ConvenientPatch); - /** * Refer to vendor/libgit2/include/git2/diff.h for delta type definitions. * diff --git a/munge.js b/munge.js index 97d76a3cd..2e62caebf 100644 --- a/munge.js +++ b/munge.js @@ -1,16 +1,52 @@ var fs = require('fs'), - _ = require('underscore'), path = require('path'); +var ds = new RegExp('\\*\\*'); + var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')); +var types2free = {}; + +var oidFns = "git_blob_id git_commit_id git_commit_tree_id git_commit_parent_id git_indexer_stream_hash git_note_oid git_object_id git_odb_object_id git_reflog_entry_id_old git_reflog_entry_id_new git_reference_target git_submodule_index_id git_submodule_head_id git_submodule_wd_id git_tag_id git_tag_target_id git_tree_entry_id git_tree_id".split(' '); + +for (var i in idefs) { + var idef = idefs[i]; + + for (var f in idef.functions) { + var fn = idef.functions[f]; + + if (oidFns.indexOf(fn.cFunctionName) > -1) { + fn.return.copy = "git_oid_dup"; + } + } +} +console.log(JSON.stringify(idefs, null, 2)); + +return; + for (var i in idefs) { var idef = idefs[i]; + types2free[idef.cType] = idef.freeFunctionName; +} + +for (var t in types2free) { + var re = new RegExp(t); - for (var j in idef.functions) { - var fn = idef.functions[j]; - if (!fn.isConstructorMethod) continue; - fn.args[0].isReturn = true; + for (var i in idefs) { + var idef = idefs[i]; + + for (var f in idef.fields) { + var fn = idef.functions[f]; + + for (var a in fn.args) { + var arg = fn.args[a]; + + if (t == "git_oid" && arg.isReturn && re.test(arg.cType) && !ds.test(arg.cType)) { + arg.shouldAlloc = true; + } + } + } } } console.log(JSON.stringify(idefs, null, 2)); + diff --git a/src/blob.cc b/src/blob.cc index 20e2dbd43..ab7ee53df 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/blob.h" #include "../include/repo.h" #include "../include/oid.h" @@ -77,7 +79,8 @@ Handle GitBlob::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -124,6 +127,7 @@ Handle GitBlob::CreateFromFile(const Arguments& args) { baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; + baton->id = (git_oid *)malloc(sizeof(git_oid )); baton->repoReference = Persistent::New(args[0]); git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->repo = from_repo; @@ -204,6 +208,7 @@ Handle GitBlob::CreateFromBuffer(const Arguments& args) { baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; + baton->oid = (git_oid *)malloc(sizeof(git_oid )); baton->repoReference = Persistent::New(args[0]); git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->repo = from_repo; diff --git a/src/branch.cc b/src/branch.cc index 5bd5e03d5..60c8c2bad 100644 --- a/src/branch.cc +++ b/src/branch.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/branch.h" using namespace v8; diff --git a/src/commit.cc b/src/commit.cc index 322623f65..f22611fe0 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/commit.h" #include "../include/oid.h" #include "../include/repo.h" @@ -82,7 +84,8 @@ Handle GitCommit::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -147,7 +150,8 @@ Handle GitCommit::Committer(const Arguments& args) { ); Handle to; - to = GitSignature::New((void *)result); + result = (const git_signature * )git_signature_dup(result); + to = GitSignature::New((void *)result); return scope.Close(to); } @@ -160,7 +164,8 @@ Handle GitCommit::Author(const Arguments& args) { ); Handle to; - to = GitSignature::New((void *)result); + result = (const git_signature * )git_signature_dup(result); + to = GitSignature::New((void *)result); return scope.Close(to); } @@ -173,7 +178,8 @@ Handle GitCommit::TreeId(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -204,7 +210,8 @@ Handle GitCommit::ParentId(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } diff --git a/src/delta.cc b/src/delta.cc index 3584cacba..156f6ce46 100644 --- a/src/delta.cc +++ b/src/delta.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/delta.h" #include "../include/diff_file.h" @@ -18,6 +20,7 @@ GitDelta::GitDelta(git_diff_delta *raw) { } GitDelta::~GitDelta() { + free(this->raw); } void GitDelta::Initialize(Handle target) { @@ -70,7 +73,8 @@ Handle GitDelta::OldFile(const Arguments& args) { git_diff_file *old_file = &ObjectWrap::Unwrap(args.This())->GetValue()->old_file; - to = GitDiffFile::New((void *)old_file); + old_file = (git_diff_file *)git_diff_file_dup(old_file); + to = GitDiffFile::New((void *)old_file); return scope.Close(to); } @@ -81,7 +85,8 @@ Handle GitDelta::NewFile(const Arguments& args) { git_diff_file *new_file = &ObjectWrap::Unwrap(args.This())->GetValue()->new_file; - to = GitDiffFile::New((void *)new_file); + new_file = (git_diff_file *)git_diff_file_dup(new_file); + to = GitDiffFile::New((void *)new_file); return scope.Close(to); } diff --git a/src/diff_file.cc b/src/diff_file.cc index c66e818d6..bd82f9a77 100644 --- a/src/diff_file.cc +++ b/src/diff_file.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/diff_file.h" #include "../include/oid.h" @@ -18,6 +20,7 @@ GitDiffFile::GitDiffFile(git_diff_file *raw) { } GitDiffFile::~GitDiffFile() { + free(this->raw); } void GitDiffFile::Initialize(Handle target) { @@ -70,7 +73,8 @@ Handle GitDiffFile::Oid(const Arguments& args) { git_oid *oid = &ObjectWrap::Unwrap(args.This())->GetValue()->oid; - to = GitOid::New((void *)oid); + oid = (git_oid *)git_oid_dup(oid); + to = GitOid::New((void *)oid); return scope.Close(to); } diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc index 70fc89de9..f6fd85756 100644 --- a/src/diff_find_options.cc +++ b/src/diff_find_options.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/diff_find_options.h" using namespace v8; diff --git a/src/diff_list.cc b/src/diff_list.cc index 3de29d109..f09a652ec 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/diff_list.h" #include "../include/diff_options.h" #include "../include/diff_find_options.h" diff --git a/src/diff_options.cc b/src/diff_options.cc index c427b5658..dad3fd108 100644 --- a/src/diff_options.cc +++ b/src/diff_options.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/diff_options.h" using namespace v8; diff --git a/src/diff_range.cc b/src/diff_range.cc index 1de98d0b8..cacbd49b5 100644 --- a/src/diff_range.cc +++ b/src/diff_range.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/diff_range.h" using namespace v8; diff --git a/src/functions/copy.cc b/src/functions/copy.cc new file mode 100644 index 000000000..e392140f6 --- /dev/null +++ b/src/functions/copy.cc @@ -0,0 +1,39 @@ +#include + +#include "git2.h" + +const git_oid *git_oid_dup(const git_oid *arg) { + git_oid *result = (git_oid *)malloc(sizeof(git_oid)); + git_oid_cpy(result, arg); + return result; +} + +const git_index_entry *git_index_entry_dup(const git_index_entry *arg) { + git_index_entry *result = (git_index_entry *)malloc(sizeof(git_index_entry)); + *result = *arg; + return result; +} + +const git_index_time *git_index_time_dup(const git_index_time *arg) { + git_index_time *result = (git_index_time *)malloc(sizeof(git_index_time)); + *result = (const git_index_time) *arg; + return result; +} + +const git_time *git_time_dup(const git_time *arg) { + git_time *result = (git_time *)malloc(sizeof(git_time)); + *result = *arg; + return result; +} + +const git_diff_delta *git_diff_delta_dup(const git_diff_delta *arg) { + git_diff_delta *result = (git_diff_delta *)malloc(sizeof(git_diff_delta)); + *result = *arg; + return result; +} + +const git_diff_file *git_diff_file_dup(const git_diff_file *arg) { + git_diff_file *result = (git_diff_file *)malloc(sizeof(git_diff_file)); + *result = *arg; + return result; +} diff --git a/src/index.cc b/src/index.cc index e5969ccb1..79bd83da6 100644 --- a/src/index.cc +++ b/src/index.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/index.h" #include "../include/oid.h" #include "../include/repo.h" @@ -352,6 +354,7 @@ Handle GitIndex::WriteTree(const Arguments& args) { baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); @@ -442,7 +445,8 @@ Handle GitIndex::Entry(const Arguments& args) { ); Handle to; - to = GitIndexEntry::New((void *)result); + result = (const git_index_entry * )git_index_entry_dup(result); + to = GitIndexEntry::New((void *)result); return scope.Close(to); } diff --git a/src/index_entry.cc b/src/index_entry.cc index 8217eac26..fb0d509ae 100644 --- a/src/index_entry.cc +++ b/src/index_entry.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/index_entry.h" #include "../include/index_time.h" @@ -69,7 +71,8 @@ Handle GitIndexEntry::Ctime(const Arguments& args) { git_index_time *ctime = &ObjectWrap::Unwrap(args.This())->GetValue()->ctime; - to = GitIndexTime::New((void *)ctime); + ctime = (git_index_time *)git_index_time_dup(ctime); + to = GitIndexTime::New((void *)ctime); return scope.Close(to); } @@ -80,7 +83,8 @@ Handle GitIndexEntry::Mtime(const Arguments& args) { git_index_time *mtime = &ObjectWrap::Unwrap(args.This())->GetValue()->mtime; - to = GitIndexTime::New((void *)mtime); + mtime = (git_index_time *)git_index_time_dup(mtime); + to = GitIndexTime::New((void *)mtime); return scope.Close(to); } diff --git a/src/index_time.cc b/src/index_time.cc index 90caa18f9..5501bd61a 100644 --- a/src/index_time.cc +++ b/src/index_time.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/index_time.h" using namespace v8; @@ -17,6 +19,7 @@ GitIndexTime::GitIndexTime(git_index_time *raw) { } GitIndexTime::~GitIndexTime() { + free(this->raw); } void GitIndexTime::Initialize(Handle target) { diff --git a/src/object.cc b/src/object.cc index 470b6cfdf..7334f4610 100644 --- a/src/object.cc +++ b/src/object.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/object.h" #include "../include/oid.h" #include "../include/repo.h" @@ -32,7 +34,6 @@ void GitObject::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); - NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner); NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); @@ -73,7 +74,8 @@ Handle GitObject::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -90,19 +92,6 @@ Handle GitObject::Type(const Arguments& args) { return scope.Close(to); } -Handle GitObject::Owner(const Arguments& args) { - HandleScope scope; - - - git_repository * result = git_object_owner( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = GitRepo::New((void *)result); - return scope.Close(to); -} - Handle GitObject::Peel(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { diff --git a/src/odb.cc b/src/odb.cc index ea4987070..434083f41 100644 --- a/src/odb.cc +++ b/src/odb.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/odb.h" #include "../include/oid.h" #include "../include/odb_object.h" diff --git a/src/odb_object.cc b/src/odb_object.cc index c017057a1..25ed1ebe8 100644 --- a/src/odb_object.cc +++ b/src/odb_object.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/odb_object.h" #include "../include/wrapper.h" #include "../include/oid.h" @@ -112,7 +114,8 @@ Handle GitOdbObject::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } diff --git a/src/oid.cc b/src/oid.cc index 05c9939a4..4b619ef07 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/oid.h" using namespace v8; @@ -17,6 +19,7 @@ GitOid::GitOid(git_oid *raw) { } GitOid::~GitOid() { + free(this->raw); } void GitOid::Initialize(Handle target) { diff --git a/src/patch.cc b/src/patch.cc index 65dfef6dc..13c6eb8da 100644 --- a/src/patch.cc +++ b/src/patch.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/patch.h" #include "../include/delta.h" #include "../include/diff_range.h" @@ -76,7 +78,8 @@ Handle GitPatch::Delta(const Arguments& args) { ); Handle to; - to = GitDelta::New((void *)result); + result = (const git_diff_delta * )git_diff_delta_dup(result); + to = GitDelta::New((void *)result); return scope.Close(to); } diff --git a/src/refdb.cc b/src/refdb.cc index 73caf4d0b..d1b344d76 100644 --- a/src/refdb.cc +++ b/src/refdb.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/refdb.h" using namespace v8; @@ -17,6 +19,7 @@ GitRefDb::GitRefDb(git_refdb *raw) { } GitRefDb::~GitRefDb() { + free(this->raw); } void GitRefDb::Initialize(Handle target) { diff --git a/src/reference.cc b/src/reference.cc index 44313fdcc..80a7c2c69 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/reference.h" #include "../include/repo.h" #include "../include/oid.h" @@ -91,6 +93,7 @@ Handle GitReference::OidForName(const Arguments& args) { baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); baton->repoReference = Persistent::New(args[0]); git_repository * from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); baton->repo = from_repo; @@ -160,7 +163,8 @@ Handle GitReference::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } diff --git a/src/repo.cc b/src/repo.cc index d8d06c0c3..a5c4bfb32 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/repo.h" #include "../include/oid.h" #include "../include/commit.h" @@ -888,6 +890,7 @@ Handle GitRepo::CreateTag(const Arguments& args) { baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; + baton->oid = (git_oid *)malloc(sizeof(git_oid )); baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); baton->tag_nameReference = Persistent::New(args[0]); @@ -989,6 +992,7 @@ Handle GitRepo::CreateLightweightTag(const Arguments& args) { baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; + baton->oid = (git_oid *)malloc(sizeof(git_oid )); baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); baton->tag_nameReference = Persistent::New(args[0]); diff --git a/src/revwalk.cc b/src/revwalk.cc index c5c2e4c2b..75208e59a 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/revwalk.h" #include "../include/oid.h" #include "../include/repo.h" diff --git a/src/signature.cc b/src/signature.cc index 0be456bf0..492a84d50 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/signature.h" #include "../include/time.h" @@ -18,6 +20,7 @@ GitSignature::GitSignature(git_signature *raw) { } GitSignature::~GitSignature() { + git_signature_free(this->raw); } void GitSignature::Initialize(Handle target) { @@ -164,7 +167,8 @@ Handle GitSignature::Time(const Arguments& args) { git_time *when = &ObjectWrap::Unwrap(args.This())->GetValue()->when; - to = GitTime::New((void *)when); + when = (git_time *)git_time_dup(when); + to = GitTime::New((void *)when); return scope.Close(to); } diff --git a/src/submodule.cc b/src/submodule.cc index 165d14f3b..1d064e7b4 100644 --- a/src/submodule.cc +++ b/src/submodule.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/submodule.h" #include "../include/oid.h" #include "../include/repo.h" @@ -19,6 +21,7 @@ GitSubmodule::GitSubmodule(git_submodule *raw) { } GitSubmodule::~GitSubmodule() { + free(this->raw); } void GitSubmodule::Initialize(Handle target) { @@ -333,7 +336,8 @@ Handle GitSubmodule::IndexId(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -346,7 +350,8 @@ Handle GitSubmodule::HeadId(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } diff --git a/src/tag.cc b/src/tag.cc index 226e172f1..61444e3de 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/tag.h" #include "../include/oid.h" #include "../include/repo.h" @@ -79,7 +81,8 @@ Handle GitTag::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -155,7 +158,8 @@ Handle GitTag::TargetId(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -194,7 +198,8 @@ Handle GitTag::Tagger(const Arguments& args) { ); Handle to; - to = GitSignature::New((void *)result); + result = (const git_signature * )git_signature_dup(result); + to = GitSignature::New((void *)result); return scope.Close(to); } diff --git a/src/threads.cc b/src/threads.cc index 06bedf47f..785d853e3 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/threads.h" using namespace v8; diff --git a/src/time.cc b/src/time.cc index 5d48810d5..b03a49c84 100644 --- a/src/time.cc +++ b/src/time.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/time.h" using namespace v8; diff --git a/src/tree.cc b/src/tree.cc index 8b5641b24..6a3ccd7f5 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/tree.h" #include "../include/repo.h" #include "../include/oid.h" @@ -82,7 +84,8 @@ Handle GitTree::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } @@ -115,7 +118,8 @@ Handle GitTree::EntryByName(const Arguments& args) { delete from_filename; Handle to; - to = GitTreeEntry::New((void *)result); + result = (const git_tree_entry * )git_tree_entry_dup(result); + to = GitTreeEntry::New((void *)result); return scope.Close(to); } @@ -133,7 +137,8 @@ Handle GitTree::EntryByIndex(const Arguments& args) { ); Handle to; - to = GitTreeEntry::New((void *)result); + result = (const git_tree_entry * )git_tree_entry_dup(result); + to = GitTreeEntry::New((void *)result); return scope.Close(to); } @@ -151,7 +156,8 @@ Handle GitTree::EntryByOid(const Arguments& args) { ); Handle to; - to = GitTreeEntry::New((void *)result); + result = (const git_tree_entry * )git_tree_entry_dup(result); + to = GitTreeEntry::New((void *)result); return scope.Close(to); } diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 7a74d00d1..4583b4b45 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -7,6 +7,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/tree_entry.h" #include "../include/oid.h" #include "../include/repo.h" @@ -20,6 +22,7 @@ GitTreeEntry::GitTreeEntry(git_tree_entry *raw) { } GitTreeEntry::~GitTreeEntry() { + git_tree_entry_free(this->raw); } void GitTreeEntry::Initialize(Handle target) { @@ -87,7 +90,8 @@ Handle GitTreeEntry::Oid(const Arguments& args) { ); Handle to; - to = GitOid::New((void *)result); + result = (const git_oid * )git_oid_dup(result); + to = GitOid::New((void *)result); return scope.Close(to); } diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index 5ce5818b1..c328fed6e 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -19,6 +19,8 @@ #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/<%= filename %>" <% if (typeof dependencies != 'undefined') { -%> <% for (d in dependencies) { -%> diff --git a/templates/convertToV8.cc.ejs b/templates/convertToV8.cc.ejs index 40a970743..22bd6359b 100644 --- a/templates/convertToV8.cc.ejs +++ b/templates/convertToV8.cc.ejs @@ -6,5 +6,8 @@ <% } else if (to.cppClassName == "External") { -%> to = External::New((void *)<%- toName %>); <% } else { -%> +<% if (to.copy) { -%> + <%- toName %> = (<%- to.cType %> <% if (!/\*/.test(to.cType)) {%>*<% } %>)<%- to.copy %>(<%- toName %>); +<% } -%> to = <%- to.cppClassName %>::New((void *)<%- toName %>); <% } -%> diff --git a/v0.18.0.json b/v0.18.0.json index 2c9626a34..22bbfd147 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -5,7 +5,6 @@ "jsClassName": "Attr", "cppClassName": "Attr", "cType": "git_attr", - "freeFunctionName": null, "functions": [ { "cFunctionName": "git_attr_get", @@ -257,7 +256,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -344,6 +344,7 @@ "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid", + "shouldAlloc": true, "isReturn": true }, { @@ -424,6 +425,7 @@ "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid", + "shouldAlloc": true, "isReturn": true }, { @@ -1012,7 +1014,12 @@ }, { "filename": "commit.h", - "dependencies": ["../include/oid.h", "../include/repo.h", "../include/signature.h", "../include/tree.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/signature.h", + "../include/tree.h" + ], "jsClassName": "Commit", "cppClassName": "GitCommit", "cType": "git_commit", @@ -1100,7 +1107,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -1205,7 +1213,8 @@ "cppFunctionName": "Committer", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature" + "cppClassName": "GitSignature", + "copy": "git_signature_dup" } }, { @@ -1226,7 +1235,8 @@ "cppFunctionName": "Author", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature" + "cppClassName": "GitSignature", + "copy": "git_signature_dup" } }, { @@ -1277,7 +1287,8 @@ "cppFunctionName": "TreeId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -1309,8 +1320,7 @@ "isReturn": true, "cType": "git_commit **", "cppClassName": "GitCommit", - "jsClassName": "Commit", - "isReturn": true + "jsClassName": "Commit" }, { "name": "commit", @@ -1362,7 +1372,8 @@ "cppFunctionName": "ParentId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -1408,6 +1419,7 @@ "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid", + "shouldAlloc": true, "isReturn": true }, { @@ -2593,7 +2605,10 @@ }, { "filename": "patch.h", - "dependencies": ["../include/delta.h", "../include/diff_range.h"], + "dependencies": [ + "../include/delta.h", + "../include/diff_range.h" + ], "jsClassName": "Patch", "cppClassName": "GitPatch", "cType": "git_diff_patch", @@ -2640,7 +2655,8 @@ "cppFunctionName": "Delta", "return": { "cType": "const git_diff_delta *", - "cppClassName": "GitDelta" + "cppClassName": "GitDelta", + "copy": "git_diff_delta_dup" } }, { @@ -2996,10 +3012,13 @@ }, { "filename": "diff_file.h", - "dependencies": ["../include/oid.h"], + "dependencies": [ + "../include/oid.h" + ], "jsClassName": "DiffFile", "cppClassName": "GitDiffFile", "cType": "git_diff_file", + "freeFunctionName": "free", "fields": [ { "jsFunctionName": "oid", @@ -3007,7 +3026,8 @@ "name": "oid", "cType": "git_oid", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "copy": "git_oid_dup" }, { "jsFunctionName": "path", @@ -3045,10 +3065,13 @@ }, { "filename": "delta.h", - "dependencies": ["../include/diff_file.h"], + "dependencies": [ + "../include/diff_file.h" + ], "jsClassName": "Delta", "cppClassName": "GitDelta", "cType": "git_diff_delta", + "freeFunctionName": "free", "fields": [ { "jsFunctionName": "oldFile", @@ -3056,7 +3079,8 @@ "name": "old_file", "cType": "git_diff_file", "cppClassName": "GitDiffFile", - "jsClassName": "DiffFile" + "jsClassName": "DiffFile", + "copy": "git_diff_file_dup" }, { "jsFunctionName": "newFile", @@ -3064,7 +3088,8 @@ "name": "new_file", "cType": "git_diff_file", "cppClassName": "GitDiffFile", - "jsClassName": "DiffFile" + "jsClassName": "DiffFile", + "copy": "git_diff_file_dup" }, { "jsFunctionName": "status", @@ -3094,7 +3119,15 @@ }, { "filename": "diff_list.h", - "dependencies": ["../include/diff_options.h", "../include/diff_find_options.h", "../include/repo.h", "../include/tree.h", "../include/index.h", "../include/patch.h", "../include/delta.h"], + "dependencies": [ + "../include/diff_options.h", + "../include/diff_find_options.h", + "../include/repo.h", + "../include/tree.h", + "../include/index.h", + "../include/patch.h", + "../include/delta.h" + ], "jsClassName": "DiffList", "cppClassName": "GitDiffList", "cType": "git_diff_list", @@ -3548,7 +3581,8 @@ "cppFunctionName": "LastError", "return": { "cType": "const git_error *", - "cppClassName": "Error" + "cppClassName": "Error", + "copy": "fixme" } }, { @@ -3759,6 +3793,7 @@ "jsClassName": "IndexTime", "cppClassName": "GitIndexTime", "cType": "git_index_time", + "freeFunctionName": "free", "fields": [ { "jsFunctionName": "seconds", @@ -3780,7 +3815,9 @@ }, { "filename": "index_entry.h", - "dependencies": ["../include/index_time.h"], + "dependencies": [ + "../include/index_time.h" + ], "jsClassName": "IndexEntry", "cppClassName": "GitIndexEntry", "cType": "git_index_entry", @@ -3792,7 +3829,8 @@ "name": "ctime", "cType": "git_index_time", "cppClassName": "GitIndexTime", - "jsClassName": "IndexTime" + "jsClassName": "IndexTime", + "copy": "git_index_time_dup" }, { "jsFunctionName": "mtime", @@ -3800,7 +3838,8 @@ "name": "mtime", "cType": "git_index_time", "cppClassName": "GitIndexTime", - "jsClassName": "IndexTime" + "jsClassName": "IndexTime", + "copy": "git_index_time_dup" }, { "jsFunctionName": "path", @@ -3814,7 +3853,14 @@ }, { "filename": "index.h", - "dependencies": ["../include/oid.h", "../include/repo.h", "../include/tree.h", "../include/diff_list.h", "../include/diff_options.h", "../include/index_entry.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/tree.h", + "../include/diff_list.h", + "../include/diff_options.h", + "../include/index_entry.h" + ], "jsClassName": "Index", "cppClassName": "GitIndex", "cType": "git_index", @@ -3904,7 +3950,7 @@ "isSelf": true } ], - "ignore": true, + "ignore": "Never make public for memory allocation reasons", "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -4046,7 +4092,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "index", @@ -4075,7 +4122,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "index", @@ -4168,7 +4216,8 @@ "cppFunctionName": "Entry", "return": { "cType": "const git_index_entry *", - "cppClassName": "GitIndexEntry" + "cppClassName": "GitIndexEntry", + "copy": "git_index_entry_dup" } }, { @@ -4202,7 +4251,8 @@ "cppFunctionName": "GetFile", "return": { "cType": "const git_index_entry *", - "cppClassName": "GitIndexEntry" + "cppClassName": "GitIndexEntry", + "copy": "git_index_entry_dup" } }, { @@ -4651,7 +4701,8 @@ "cppFunctionName": "ReucGetBypath", "return": { "cType": "const git_index_reuc_entry *", - "cppClassName": "IndexReucEntry" + "cppClassName": "IndexReucEntry", + "copy": "fixme" } }, { @@ -4679,7 +4730,8 @@ "cppFunctionName": "ReucGetByindex", "return": { "cType": "const git_index_reuc_entry *", - "cppClassName": "IndexReucEntry" + "cppClassName": "IndexReucEntry", + "copy": "fixme" } }, { @@ -4971,7 +5023,8 @@ "cppFunctionName": "StreamHash", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -5022,7 +5075,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "repo", @@ -5062,7 +5116,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "repo", @@ -5322,7 +5377,8 @@ "cppFunctionName": "GitNoteOid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -5333,7 +5389,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "repo", @@ -5526,7 +5583,10 @@ }, { "filename": "object.h", - "dependencies": ["../include/oid.h", "../include/repo.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h" + ], "jsClassName": "Object", "cppClassName": "GitObject", "cType": "git_object", @@ -5550,7 +5610,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -5585,6 +5646,7 @@ "isSelf": true } ], + "ignore": "Never make public for memory allocation reasons", "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -5772,7 +5834,11 @@ }, { "filename": "odb.h", - "dependencies": ["../include/oid.h", "../include/odb_object.h", "node_buffer.h"], + "dependencies": [ + "../include/oid.h", + "../include/odb_object.h", + "node_buffer.h" + ], "jsClassName": "Odb", "cppClassName": "GitOdb", "cType": "git_odb", @@ -6392,7 +6458,10 @@ }, { "filename": "odb_object.h", - "dependencies": ["../include/wrapper.h", "../include/oid.h"], + "dependencies": [ + "../include/wrapper.h", + "../include/oid.h" + ], "jsClassName": "OdbObject", "cppClassName": "GitOdbObject", "cType": "git_odb_object", @@ -6502,7 +6571,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } } ] @@ -6551,6 +6621,7 @@ "jsClassName": "Oid", "cppClassName": "GitOid", "cType": "git_oid", + "freeFunctionName": "free", "functions": [ { "cFunctionName": "git_oid_fromstr", @@ -6589,7 +6660,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "str", @@ -6618,7 +6690,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "str", @@ -6653,7 +6726,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "raw", @@ -6793,7 +6867,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "src", @@ -6977,7 +7052,8 @@ "cppFunctionName": "ShortenNew", "return": { "cType": "git_oid_shorten *", - "cppClassName": "OidShorten" + "cppClassName": "OidShorten", + "copy": "fixme" } }, { @@ -7497,6 +7573,8 @@ "jsClassName": "RefDb", "cppClassName": "GitRefDb", "cType": "git_refdb", + "note": "this should be git_refdb_free, but it's not available", + "freeFunctionName": "free", "functions": [ { "cFunctionName": "git_reference__alloc", @@ -7535,7 +7613,8 @@ "cppFunctionName": "GitReference_Alloc", "return": { "cType": "git_reference *", - "cppClassName": "GitReference" + "cppClassName": "GitReference", + "copy": "fixme" } }, { @@ -7807,6 +7886,7 @@ "jsClassName": "Number" } ], + "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -7814,7 +7894,8 @@ "cppFunctionName": "EntryByindex", "return": { "cType": "const git_reflog_entry *", - "cppClassName": "ReflogEntry" + "cppClassName": "ReflogEntry", + "copy": "fixme" } }, { @@ -7868,7 +7949,8 @@ "cppFunctionName": "EntryIdOld", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -7888,7 +7970,8 @@ "cppFunctionName": "EntryIdNew", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -7908,7 +7991,8 @@ "cppFunctionName": "EntryCommitter", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature" + "cppClassName": "GitSignature", + "copy": "git_signature_dup" } }, { @@ -7974,7 +8058,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "repo", @@ -8018,7 +8103,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -8125,7 +8211,7 @@ "isSelf": true } ], - "ignore": true, + "ignore": "Never make public for memory allocation reasons", "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -8977,7 +9063,8 @@ "cppFunctionName": "Fetchspec", "return": { "cType": "const git_refspec *", - "cppClassName": "Refspec" + "cppClassName": "Refspec", + "copy": "fixme" } }, { @@ -9026,7 +9113,8 @@ "cppFunctionName": "Pushspec", "return": { "cType": "const git_refspec *", - "cppClassName": "Refspec" + "cppClassName": "Refspec", + "copy": "fixme" } }, { @@ -9593,7 +9681,21 @@ }, { "filename": "repo.h", - "dependencies": ["../include/oid.h", "../include/commit.h", "../include/blob.h", "../include/object.h", "../include/reference.h", "../include/submodule.h", "../include/refdb.h", "../include/revwalk.h", "../include/tag.h", "../include/signature.h", "../include/tree.h", "../include/odb.h", "../include/index.h"], + "dependencies": [ + "../include/oid.h", + "../include/commit.h", + "../include/blob.h", + "../include/object.h", + "../include/reference.h", + "../include/submodule.h", + "../include/refdb.h", + "../include/revwalk.h", + "../include/tag.h", + "../include/signature.h", + "../include/tree.h", + "../include/odb.h", + "../include/index.h" + ], "jsClassName": "Repo", "cppClassName": "GitRepo", "cType": "git_repository", @@ -10419,7 +10521,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "repo", @@ -10679,7 +10782,8 @@ "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid", - "isReturn": true + "isReturn": true, + "shouldAlloc": true }, { "name": "repo", @@ -11201,7 +11305,6 @@ "isSelf": true } ], - "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -11380,7 +11483,8 @@ "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid", - "isReturn": true + "isReturn": true, + "shouldAlloc": true }, { "name": "repo", @@ -11439,7 +11543,8 @@ "cType": "git_oid *", "cppClassName": "GitOid", "jsClassName": "Oid", - "isReturn": true + "isReturn": true, + "shouldAlloc": true }, { "name": "repo", @@ -11897,7 +12002,10 @@ }, { "filename": "revwalk.h", - "dependencies": ["../include/oid.h", "../include/repo.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h" + ], "jsClassName": "RevWalk", "cppClassName": "GitRevWalk", "cType": "git_revwalk", @@ -12255,7 +12363,7 @@ "isSelf": true } ], - "ignore": true, + "ignore": "Never make public for memory allocation reasons", "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -12296,10 +12404,13 @@ }, { "filename": "signature.h", - "dependencies": ["../include/time.h"], + "dependencies": [ + "../include/time.h" + ], "jsClassName": "Signature", "cppClassName": "GitSignature", "cType": "git_signature", + "freeFunctionName": "git_signature_free", "fields": [ { "jsFunctionName": "name", @@ -12323,7 +12434,8 @@ "name": "when", "cType": "git_time", "cppClassName": "GitTime", - "jsClassName": "Time" + "jsClassName": "Time", + "copy": "git_time_dup" } ], "functions": [ @@ -12381,8 +12493,7 @@ "isReturn": true, "cType": "git_signature **", "cppClassName": "GitSignature", - "jsClassName": "Signature", - "isReturn": true + "jsClassName": "Signature" }, { "name": "name", @@ -12470,7 +12581,8 @@ "isReturn": true, "cType": "git_oid *", "cppClassName": "GitOid", - "jsClassName": "Oid" + "jsClassName": "Oid", + "shouldAlloc": true }, { "name": "repo", @@ -12788,10 +12900,14 @@ }, { "filename": "submodule.h", - "dependencies": ["../include/oid.h", "../include/repo.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h" + ], "jsClassName": "Submodule", "cppClassName": "GitSubmodule", "cType": "git_submodule", + "freeFunctionName": "free", "functions": [ { "cFunctionName": "git_submodule_foreach", @@ -12910,7 +13026,7 @@ "isSelf": true } ], - "ignore": true, + "ignore": "Never make public for memory allocation reasons", "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -13030,7 +13146,8 @@ "cppFunctionName": "IndexId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -13051,7 +13168,8 @@ "cppFunctionName": "HeadId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -13073,7 +13191,8 @@ "cppFunctionName": "WdId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -13103,8 +13222,8 @@ { "name": "ignore", "cType": "git_submodule_ignore_t", - "cppClassName": "SubmoduleIgnoreT", - "jsClassName": "SubmoduleIgnoreT" + "cppClassName": "Uint32", + "jsClassName": "Uint32" } ], "ignore": true, @@ -13115,7 +13234,7 @@ "cppFunctionName": "SetIgnore", "return": { "cType": "git_submodule_ignore_t", - "cppClassName": "SubmoduleIgnoreT" + "cppClassName": "Uint32" } }, { @@ -13145,8 +13264,8 @@ { "name": "update", "cType": "git_submodule_update_t", - "cppClassName": "SubmoduleUpdateT", - "jsClassName": "SubmoduleUpdateT" + "cppClassName": "Uint32", + "jsClassName": "Uint32" } ], "ignore": true, @@ -13373,7 +13492,12 @@ }, { "filename": "tag.h", - "dependencies": ["../include/oid.h", "../include/repo.h", "../include/object.h", "../include/signature.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/object.h", + "../include/signature.h" + ], "jsClassName": "Tag", "cppClassName": "GitTag", "cType": "git_tag", @@ -13419,7 +13543,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -13469,7 +13594,8 @@ "cppFunctionName": "TargetId", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -13532,7 +13658,8 @@ "cppFunctionName": "Tagger", "return": { "cType": "const git_signature *", - "cppClassName": "GitSignature" + "cppClassName": "GitSignature", + "copy": "git_signature_dup" } }, { @@ -13936,10 +14063,15 @@ }, { "filename": "tree_entry.h", - "dependencies": ["../include/oid.h", "../include/repo.h", "../include/object.h"], + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/object.h" + ], "jsClassName": "TreeEntry", "cppClassName": "GitTreeEntry", "cType": "git_tree_entry", + "freeFunctionName": "git_tree_entry_free", "functions": [ { "cFunctionName": "git_tree_entry_dup", @@ -14025,7 +14157,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -14138,7 +14271,14 @@ }, { "filename": "tree.h", - "dependencies": ["../include/repo.h", "../include/oid.h", "../include/tree_entry.h", "../include/diff_list.h", "../include/diff_options.h", "../include/index.h"], + "dependencies": [ + "../include/repo.h", + "../include/oid.h", + "../include/tree_entry.h", + "../include/diff_list.h", + "../include/diff_options.h", + "../include/index.h" + ], "jsClassName": "Tree", "cppClassName": "GitTree", "cType": "git_tree", @@ -14184,7 +14324,8 @@ "cppFunctionName": "Oid", "return": { "cType": "const git_oid *", - "cppClassName": "GitOid" + "cppClassName": "GitOid", + "copy": "git_oid_dup" } }, { @@ -14198,7 +14339,7 @@ "isSelf": true } ], - "ignore": true, + "ignore": "Never make public for memory allocation reasons", "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -14255,7 +14396,7 @@ "return": { "cType": "const git_tree_entry *", "cppClassName": "GitTreeEntry", - "shouldAlloc": true + "copy": "git_tree_entry_dup" } }, { @@ -14283,7 +14424,7 @@ "return": { "cType": "const git_tree_entry *", "cppClassName": "GitTreeEntry", - "shouldAlloc": true + "copy": "git_tree_entry_dup" } }, { @@ -14311,7 +14452,7 @@ "return": { "cType": "const git_tree_entry *", "cppClassName": "GitTreeEntry", - "shouldAlloc": true + "copy": "git_tree_entry_dup" } }, { @@ -14466,7 +14607,8 @@ "cppFunctionName": "GitTreebuilderGet", "return": { "cType": "const git_tree_entry *", - "cppClassName": "GitTreeEntry" + "cppClassName": "GitTreeEntry", + "copy": "git_tree_entry_dup" } }, { From eebd0ead15d62eaf0ba276da53af43bbc3ce43ab Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 5 Jul 2013 14:09:38 +0200 Subject: [PATCH 24/28] Made all the examples work --- example/apps/git_profanity_check.js | 54 +++++++++++------------------ example/convenience-commit.js | 48 ------------------------- example/convenience-repo.js | 19 ---------- example/convenience-tree.js | 23 ------------ example/diff-commits.js | 35 +++++++++++++++++++ example/general.js | 7 ++-- example/raw-blob.js | 23 ------------ example/raw-commit.js | 13 ------- example/raw-error.js | 7 ---- example/raw-oid.js | 9 ----- example/raw-repo.js | 16 --------- example/raw-revwalk.js | 34 ------------------ example/read-file.js | 27 +++++++++++++++ example/readme-example.js | 14 -------- example/walk-history.js | 27 +++++++++++++++ example/walk-tree.js | 27 +++++++++++++++ include/functions/copy.h | 1 + include/tree.h | 8 ++--- lib/commit.js | 14 ++++---- lib/convenient_hunk.js | 4 +++ lib/diff_list.js | 16 ++++----- lib/repo.js | 9 +++++ lib/tree.js | 46 ++++++++++++++++++------ lib/tree_entry.js | 18 ++++++++-- src/blob.cc | 2 +- src/functions/copy.cc | 6 ++++ src/index.cc | 4 +-- src/odb.cc | 2 +- src/patch.cc | 5 +-- src/reference.cc | 4 +-- src/repo.cc | 14 ++++---- src/revwalk.cc | 8 ++--- src/tree.cc | 18 +++++----- templates/asyncFunction.cc.ejs | 2 +- templates/convertToV8.cc.ejs | 8 +++-- test/commit.js | 10 +++--- test/{entry.js => tree_entry.js} | 2 +- v0.18.0.json | 12 ++++--- 38 files changed, 280 insertions(+), 316 deletions(-) delete mode 100644 example/convenience-commit.js delete mode 100644 example/convenience-repo.js delete mode 100644 example/convenience-tree.js create mode 100644 example/diff-commits.js delete mode 100644 example/raw-blob.js delete mode 100644 example/raw-commit.js delete mode 100644 example/raw-error.js delete mode 100644 example/raw-oid.js delete mode 100644 example/raw-repo.js delete mode 100644 example/raw-revwalk.js create mode 100644 example/read-file.js delete mode 100644 example/readme-example.js create mode 100644 example/walk-history.js create mode 100644 example/walk-tree.js rename test/{entry.js => tree_entry.js} (98%) diff --git a/example/apps/git_profanity_check.js b/example/apps/git_profanity_check.js index 3031f4186..09f0e09db 100644 --- a/example/apps/git_profanity_check.js +++ b/example/apps/git_profanity_check.js @@ -5,50 +5,36 @@ // Script to detect cursewords in commit messages and provide the // offending commit sha's. // vim: ft=javascript -var git = require( 'nodegit' ); +var git = require('../../'); -var curses = [ 'add', 'swears', 'here' ] - , path = './.git' - , branch = 'master' - , reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); +var curses = ['add', 'swears', 'here'], + path = './.git', + branchName = 'master', + reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); -// Set git path -if ( process.argv.length < 3 ) { - console.log( 'No path passed as argument, defaulting to ./.git' ); -} -else { +if (process.argv.length < 3) { + console.log('No git path passed as argument, defaulting to ./.git'); +} else { path = process.argv[2]; - // Set repo branch - if ( process.argv.length < 4 ) { - console.log( 'No branch passed as argument, defaulting to master' ); - } - else { - branch = process.argv[3]; + if (process.argv.length < 4) { + console.log('No repo branchName passed as argument, defaulting to master'); + } else { + branchName = process.argv[3]; } } -// Open repository -git.repo( path, function( err, repo ) { - if ( err ) { - throw new Error( err ); - } +git.Repo.open(path, function(error, repo) { + if (error) throw error; - // Open branch - repo.branch( branch, function( err, branch ) { - if ( err ) { - throw new Error( err ); - } + repo.getBranch(branchName, function(error, branch) { + if (error) throw error; - // Iterate history var history = branch.history(); - history.on( 'commit', function( idx, commit ) { - // Check commit messages first - if ( reCurse.test(commit.message) ) { - console.log( 'Curse detected in commit', commit.sha, 'message' ); - return; - } - }); + history.on('commit', function(commit) { + if (reCurse.test(commit.message())) + console.log('Curse detected in commit', commit.sha(), 'message', commit.message()); + }).start(); }); }); diff --git a/example/convenience-commit.js b/example/convenience-commit.js deleted file mode 100644 index a6724b986..000000000 --- a/example/convenience-commit.js +++ /dev/null @@ -1,48 +0,0 @@ -// Load in the module. -var git = require('nodegit'), - async = require('async'); - -// Open the repository in the current directory. -git.repo('.git', function(error, repository) { - if (error) throw error; - - // Use the master branch (a branch is the HEAD commit) - repository.getBranch('master', function(error, branch) { - if (error) throw error; - - // History returns an event, and begins walking the history - var history = branch.history(); - - // History emits 'commit' event for each commit in the branch's history - history.on('commit', function(error, commit) { - // Print out `git log` emulation. - async.series([ - function(callback) { - commit.sha(callback); - }, - function(callback) { - commit.date(callback); - }, - function(callback) { - commit.author(function(error, author) { - author.name(callback); - }); - }, - function(callback) { - commit.author(function(error, author) { - author.email(callback); - }); - }, - function(callback) { - commit.message(callback); - } - ], function printCommit(error, results) { - if (error) throw error; - console.log('SHA ' + results[0]); - console.log(results[1] * 1000); - console.log(results[2] + ' <' + results[3] + '>'); - console.log(results[4]); - }); - }); - }); -}); diff --git a/example/convenience-repo.js b/example/convenience-repo.js deleted file mode 100644 index e641fe880..000000000 --- a/example/convenience-repo.js +++ /dev/null @@ -1,19 +0,0 @@ -// Load in the module -var git = require( '../' ); -// Open a repository for reading -git.repo( '../.git', function( err, repo ) { - // Success is always 0, failure is always an error string - if( err ) { throw err; } - // Use the master branch - repo.branch( 'master', function( err, branch ) { - if( err ) { throw err; } - // Iterate over the revision history - branch.history().on( 'commit', function( err, commit ) { - // Print out `git log` emulation - console.log( 'commit ' + commit.sha ); - console.log( commit.author.name + ' <' + commit.author.email + '>' ); - console.log( commit.time ); - console.log( commit.message ); - }); - }); -}); diff --git a/example/convenience-tree.js b/example/convenience-tree.js deleted file mode 100644 index 6cda8a75d..000000000 --- a/example/convenience-tree.js +++ /dev/null @@ -1,23 +0,0 @@ -// Load in the module. -var git = require('nodegit'); - -// Open the repository in the current directory. -git.repo('.git', function(error, repository) { - if (error) throw error; - - // Use the master branch. - repository.getBranch('master', function(error, branch) { - if (error) throw error; - - // Iterate over the revision history. - branch.tree(function(error, tree) { - console.log(tree); - if (error) throw error; - tree.walk().on('entry', function(error, entry) { - entry.name(function(error, name) { - console.log(name); - }); - }); - }); - }); -}); diff --git a/example/diff-commits.js b/example/diff-commits.js new file mode 100644 index 000000000..edd05b3eb --- /dev/null +++ b/example/diff-commits.js @@ -0,0 +1,35 @@ +var git = require('../'), + path = require('path'); + +// This code examines the diffs between a particular commit and all of its +// parents. Since this commit is not a merge, it only has one parent. This is +// similar to doing `git show`. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { + if (error) throw error; + + console.log('commit ' + commit.sha()); + console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>'); + console.log('Date:', commit.date()); + console.log('\n ' + commit.message()); + + commit.getDiff(function(error, diffList) { + if (error) throw error; + + diffList.forEach(function(diff) { + diff.patches().forEach(function(patch) { + console.log("diff", patch.oldFile().path(), patch.newFile().path()); + patch.hunks().forEach(function(hunk) { + console.log(hunk.header().trim()); + hunk.lines().forEach(function(line) { + console.log(String.fromCharCode(line.lineOrigin) + line.content.trim()); + }); + }); + }); + }); + }); + }); +}); diff --git a/example/general.js b/example/general.js index 69d850b24..9953524a6 100644 --- a/example/general.js +++ b/example/general.js @@ -1,4 +1,5 @@ -var git = require('../index.js'); +var git = require('../'), + path = require('path'); // **nodegit** is a javascript library for node.js that wraps libgit2, a // pure C implementation of the Git core. It provides an asynchronous @@ -15,7 +16,7 @@ var git = require('../index.js'); // Nearly, all git operations in the context of a repository. // To open a repository, -git.Repo.open('.git', function(error, repo) { +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { // For all of the following examples, error-handling will be performed in // this naive way: if (error) throw error; @@ -201,7 +202,7 @@ git.Repo.open('.git', function(error, repo) { // You can also access tree entries by path if you know the path of the // entry you're looking for. - tree.getFile("example/general.js", function(error, entry) { + tree.getEntry("example/general.js", function(error, entry) { if (error) throw error; // Entries which are files have blobs associated with them: diff --git a/example/raw-blob.js b/example/raw-blob.js deleted file mode 100644 index 18b6d238b..000000000 --- a/example/raw-blob.js +++ /dev/null @@ -1,23 +0,0 @@ -var git = require( '../' ).raw - , path = require( 'path' ); - -var repo = new git.Repo(); -repo.open( path.resolve( '../.git' ), function() { - var oid = new git.Oid(); - oid.mkstr( '59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5' ); - - repo.getCommit(oid, function( err ) { - var tree = new git.Tree( repo ), - entry = new git.TreeEntry(), - blob = new git.Blob( repo ); - - if( !commit.tree( tree ) && tree.entryCount() > 1 ) { - tree.entryByIndex( entry, 1 ); - entry.toObject( repo, blob ); - - console.log( entry.name() + ':' ); - console.log( blob.rawSize() ); - console.log( typeof blob.rawContent() ); - } - }); -}); diff --git a/example/raw-commit.js b/example/raw-commit.js deleted file mode 100644 index 07212061d..000000000 --- a/example/raw-commit.js +++ /dev/null @@ -1,13 +0,0 @@ -var git = require( '../' ).raw, - path = require( 'path' ); - -var repo = new git.Repo(); -repo.open( path.resolve( '../.git' ), function() { - var oid = new git.Oid(); - oid.mkstr( '59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5' ); - - var commit = new git.Commit(); - commit.lookup( repo, oid, function( err ) { - console.log( new git.Error().strError( err ) ); - }); -}); diff --git a/example/raw-error.js b/example/raw-error.js deleted file mode 100644 index ab20568aa..000000000 --- a/example/raw-error.js +++ /dev/null @@ -1,7 +0,0 @@ -var git2 = require( '../' ).raw; - -var error = new git2.Error(); -// Valid -console.log( error.strError(0) ); -// Invalid -console.log( error.strError(-2) ); diff --git a/example/raw-oid.js b/example/raw-oid.js deleted file mode 100644 index 5b57a1234..000000000 --- a/example/raw-oid.js +++ /dev/null @@ -1,9 +0,0 @@ -var git = require( '../' ).raw; - -var oid = new git.Oid(); -oid.mkstr('1810DFF58D8A660512D4832E740F692884338CCD'); -console.log( oid.toString(40) ); - -//// Test formatting -//console.log( oid.mkstr('5f2aa9407f7b3aeb531c621c3358953841ccfc98') ); -//console.log( oid.toString(40) ); diff --git a/example/raw-repo.js b/example/raw-repo.js deleted file mode 100644 index b569f2ade..000000000 --- a/example/raw-repo.js +++ /dev/null @@ -1,16 +0,0 @@ -var git = require( '../' ).raw, - path = require( 'path' ); - - -var repo = new git.Repo(); - -// Access existing repository -repo.open( path.resolve( '../.git' ), function( err ) { - var master = new git.Ref(repo); - repo.lookupRef( master, 'refs/heads/master', function( err, ref ) { - console.log(err, master); - var oid = new git.Oid(); - master.oid(oid); - console.log( oid.toString(40) ); - }); -}); diff --git a/example/raw-revwalk.js b/example/raw-revwalk.js deleted file mode 100644 index 25d6930d5..000000000 --- a/example/raw-revwalk.js +++ /dev/null @@ -1,34 +0,0 @@ -var git = require( '../' ).raw, - path = require( 'path' ); - -var repo = new git.Repo(); - -// Access existing repository -repo.open( path.resolve( '../.git' ), function( err ) { - var revwalk = new git.RevWalk( repo ), - oid = new git.Oid(), - error = new git.Error(), - master = new git.Ref( repo ), - commit = new git.Commit( repo ); - - if( err ) { console.log( error.strError( err ) ); return; } - - oid.mkstr( '2a900f56b6dc6cc285b4d25b2407d9a3dfe76002' ); - - commit.lookup( repo, oid, function( err ) { - if( err ) { console.log('Error', error.strError(err)); return; } - revwalk.push( commit ); - - var _commit = new git.Commit(repo); - - function walk() { - revwalk.next(_commit, function( err ) { - if( err ) { return; } - console.log( _commit.messageShort() ); - walk(); - }); - } - - walk(); - }); -}); diff --git a/example/read-file.js b/example/read-file.js new file mode 100644 index 000000000..fc698b03d --- /dev/null +++ b/example/read-file.js @@ -0,0 +1,27 @@ +var git = require('../'), + path = require('path'); + +// This example opens a certain file, `README.md`, at a particular commit, +// and prints the first 10 lines as well as some metadata. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { + if (error) throw error; + + commit.getEntry('README.md', function(error, entry) { + if (error) throw error; + + entry.getBlob(function(error, blob) { + if (error) throw error; + + console.log(entry.name(), entry.sha(), blob.size() + 'b'); + console.log('========================================================\n\n'); + var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n'); + console.log(firstTenLines); + console.log('...'); + }); + }); + }); +}); diff --git a/example/readme-example.js b/example/readme-example.js deleted file mode 100644 index 6ca62d8ca..000000000 --- a/example/readme-example.js +++ /dev/null @@ -1,14 +0,0 @@ -var git = require( 'nodegit' ); - -git.repo( 'jquery/.git', function() { - console.log( 'Repo opened' ); - - this.branch( 'master', function() { - console.log( 'Branch opened' ); - - this.history().on( 'commit', function( i, commit ) { - console.log( commit.id.toString(40) ); - }); - - }); -}); diff --git a/example/walk-history.js b/example/walk-history.js new file mode 100644 index 000000000..498711e2f --- /dev/null +++ b/example/walk-history.js @@ -0,0 +1,27 @@ +var git = require('../'), + path = require('path'); + +// This code walks the history of the master branch and prints results +// that look very similar to calling `git log` from the command line + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getMaster(function(error, branch) { + if (error) throw error; + + // History returns an event. + var history = branch.history(); + + // History emits 'commit' event for each commit in the branch's history + history.on('commit', function(commit) { + console.log('commit ' + commit.sha()); + console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>'); + console.log('Date:', commit.date()); + console.log('\n ' + commit.message()); + }); + + // Don't forget to call `start()`! + history.start(); + }); +}); diff --git a/example/walk-tree.js b/example/walk-tree.js new file mode 100644 index 000000000..c5c5f98a8 --- /dev/null +++ b/example/walk-tree.js @@ -0,0 +1,27 @@ +var git = require('../'), + path = require('path'); + +// A `tree` in git is typically a representation of the filesystem at +// a revision. A tree has a set of entries, each entry being either a +// tree (directory), or a file. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getMaster(function(error, branch) { + if (error) throw error; + + branch.getTree(function(error, tree) { + if (error) throw error; + + // `walk()` returns an event. + var walker = tree.walk(); + walker.on('entry', function(entry) { + console.log(entry.path()); + }); + + // Don't forget to call `start()`! + walker.start(); + }); + }); +}); diff --git a/include/functions/copy.h b/include/functions/copy.h index 514b8de29..fe2408740 100644 --- a/include/functions/copy.h +++ b/include/functions/copy.h @@ -11,5 +11,6 @@ const git_index_time *git_index_time_dup(const git_index_time *arg); const git_time *git_time_dup(const git_time *arg); const git_diff_delta *git_diff_delta_dup(const git_diff_delta *arg); const git_diff_file *git_diff_file_dup(const git_diff_file *arg); +const git_diff_range *git_diff_range_dup(const git_diff_range *arg); #endif diff --git a/include/tree.h b/include/tree.h index 0590b5cf9..2aeb17f8c 100755 --- a/include/tree.h +++ b/include/tree.h @@ -36,11 +36,11 @@ class GitTree : public ObjectWrap { static Handle EntryByName(const Arguments& args); static Handle EntryByIndex(const Arguments& args); static Handle EntryByOid(const Arguments& args); - static Handle GetFile(const Arguments& args); - static void GetFileWork(uv_work_t* req); - static void GetFileAfterWork(uv_work_t* req); + static Handle GetEntry(const Arguments& args); + static void GetEntryWork(uv_work_t* req); + static void GetEntryAfterWork(uv_work_t* req); - struct GetFileBaton { + struct GetEntryBaton { uv_work_t request; int error_code; const git_error* error; diff --git a/lib/commit.js b/lib/commit.js index 1039f55ed..3c67606bf 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -31,22 +31,22 @@ Commit.prototype.getTree = function(callback) { }; /** - * Retrieve the file represented by path for this commit. + * Retrieve the entry represented by path for this commit. * Path must be relative to repository root. * * @param {String} path * @param {Commit~fileCallback} callback */ -Commit.prototype.getFile = function(path, callback) { +Commit.prototype.getEntry = function(path, callback) { /** * @callback Commit~fileCallback Callback executed on file retrieval. * @param {GitError|null} error An Error or null if successful. * @param {Entry|null} file Retrieved file entry. */ - this.getTree(function (error, tree) { + this.getTree(function(error, tree) { if (error) return callback(error); - tree.getFile(path, callback); + tree.getEntry(path, callback); }); }; @@ -68,7 +68,7 @@ Commit.prototype.history = function() { var commits = []; event.start = function() { revwalk.walk(oid, function commitRevWalk(error, commit) { - if (error) return event.emit('end', error, commits); + if (error) return event.emit('error', error); if (!commit) { /** @@ -79,7 +79,7 @@ Commit.prototype.history = function() { * @param {GitError|null} error An error object if there was an issue, null otherwise. * @param {Commit[]} commits The commits. */ - event.emit('end', null, commits); + event.emit('end', commits); return; } /** @@ -90,7 +90,7 @@ Commit.prototype.history = function() { * @param {GitError|null} error An error object if there was an issue, null otherwise. * @param {Commit} commit The commit. */ - event.emit('commit', null, commit); + event.emit('commit', commit); commits.push(commit); }); }; diff --git a/lib/convenient_hunk.js b/lib/convenient_hunk.js index 8e0a61090..960061039 100644 --- a/lib/convenient_hunk.js +++ b/lib/convenient_hunk.js @@ -3,6 +3,10 @@ function ConvenientHunk(raw, i) { this.i = i; } +ConvenientHunk.prototype.header = function() { + return this.raw.hunk(this.i).header; +}; + ConvenientHunk.prototype.size = function() { return this.raw.hunk(this.i).lines; }; diff --git a/lib/diff_list.js b/lib/diff_list.js index f0967ba4f..03a1ab1c8 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -28,14 +28,14 @@ DiffList.Delta = { * @enum {String} */ DiffList.LineOrigin = { - /** ' ' */ Context: 32, - /** '+' */ Addition: 43, - /** '-' */ Deletion: 45, - /** '\n' */ AddEofNl: 13, - /** '' */ DelEofNl: 0, - /** 'F' */ FileHdr: 106, - /** 'H' */ HunkHdr: 110, - /** 'B' */ Binary: 102 + /** ' ' */ Context: 32, + /** '+' */ Addition: 43, + /** '-' */ Deletion: 45, + /** '\n' */ AddEofNl: 13, + /** '' */ DelEofNl: 0, + /** 'F' */ FileHdr: 106, + /** 'H' */ HunkHdr: 110, + /** 'B' */ Binary: 102 }; /** diff --git a/lib/repo.js b/lib/repo.js index 8e5754a3e..4ba765473 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -135,6 +135,15 @@ Repo.prototype.createRevWalk = function() { return revWalk; }; +/** + * Retrieve the master branch. + * + * @param {Blob~lookupCallback} callback + */ +Repo.prototype.getMaster = function(callback) { + this.getBranch('master', callback); +}; + /** * Create a commit * diff --git a/lib/tree.js b/lib/tree.js index f71fedd53..2ee35e15a 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -1,6 +1,7 @@ var git = require('../'), Tree = git.Tree, - events = require('events'); + events = require('events'), + path = require('path'); /** * Diff two trees @@ -11,6 +12,8 @@ Tree.prototype.diff = function(that, callback) { /** * Get an entry at the ith position. + * + * @param {Number} i */ var oldEntryByIndex = Tree.prototype.entryByIndex; Tree.prototype.entryByIndex = function(i) { @@ -20,19 +23,32 @@ Tree.prototype.entryByIndex = function(i) { }; /** - * Get an entry at the ith position. + * Get an entry by name: + * + * @param {String} name */ -Tree.prototype.entry = Tree.prototype.entryByIndex; +var oldEntryByName = Tree.prototype.entryByName; +Tree.prototype.entryByName = function(name) { + var entry = oldEntryByName.call(this, name); + entry.parent = this; + return entry; +}; /** - * Get an entry at the ith position. + * Get an entry at a path + * + * @param {String} path */ -var oldGetFile = Tree.prototype.getFile; -Tree.prototype.getFile = function(path, callback) { +var oldGetEntry = Tree.prototype.getEntry; +Tree.prototype.getEntry = function(path, callback) { + // FIXME: this method ought to implement the recursion directly, rather than + // rely on oldGetEntry, in order to ensure that `parent` pointers are direct. var self = this; - oldGetFile.call(this, path, function(error, entry) { + oldGetEntry.call(this, path, function(error, entry) { if (error) return callback(error); + // This is unlikely to be the *direct* parent; some methods, like `path()` + // rely on directness. entry.parent = self; callback(null, entry); }); @@ -70,7 +86,9 @@ Tree.prototype.walk = function(blobsOnly) { var total = 1; - function dfs(error, tree) { + // This looks like a DFS, but it is a BFS because of implicit queueing in + // the recursive call to `entry.getTree(bfs)` + function bfs(error, tree) { total--; if (error) return errors.push(error); @@ -81,7 +99,6 @@ Tree.prototype.walk = function(blobsOnly) { * * @event Tree#entry * - * @param {GitError|null} error An error object if there was an issue, null otherwise. * @param {Entry} entry The tree entry. */ event.emit('entry', entry); @@ -90,7 +107,7 @@ Tree.prototype.walk = function(blobsOnly) { if (entry.isTree()) { total++; - entry.getTree(dfs); + entry.getTree(bfs); } }); if (total === 0) @@ -98,8 +115,15 @@ Tree.prototype.walk = function(blobsOnly) { } event.start = function() { - dfs(null, self); + bfs(null, self); }; return event; }; + +/** + * Return the path of this tree. + */ +Tree.prototype.path = function(blobsOnly) { + return this.entry ? this.entry.path() : ''; +}; diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 3aa85185f..82e10ced0 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -1,5 +1,6 @@ var git = require('../'), - TreeEntry = git.TreeEntry; + TreeEntry = git.TreeEntry, + path = require('path'); /** * Refer to vendor/libgit2/include/git2/types.h for filemode definitions. @@ -38,7 +39,13 @@ TreeEntry.prototype.sha = function() { * Retrieve the tree for this entry. */ TreeEntry.prototype.getTree = function(callback) { - this.parent.repo.getTree(this.oid(), callback); + var self = this; + this.parent.repo.getTree(this.oid(), function(error, tree) { + if (error) return callback(error); + + tree.entry = self; + callback(null, tree); + }); }; /** @@ -47,3 +54,10 @@ TreeEntry.prototype.getTree = function(callback) { TreeEntry.prototype.getBlob = function(callback) { this.parent.repo.getBlob(this.oid(), callback); }; + +/** + * Returns the path for this entry. + */ +TreeEntry.prototype.path = function(callback) { + return path.join(this.parent.path(), this.name()); +}; diff --git a/src/blob.cc b/src/blob.cc index ab7ee53df..dc043f273 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -184,7 +184,7 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { baton->repoReference.Dispose(); baton->pathReference.Dispose(); baton->callback.Dispose(); - delete baton->path; + free((void *)baton->path); delete baton; } diff --git a/src/functions/copy.cc b/src/functions/copy.cc index e392140f6..c6e86ca2b 100644 --- a/src/functions/copy.cc +++ b/src/functions/copy.cc @@ -37,3 +37,9 @@ const git_diff_file *git_diff_file_dup(const git_diff_file *arg) { *result = *arg; return result; } + +const git_diff_range *git_diff_range_dup(const git_diff_range *arg) { + git_diff_range *result = (git_diff_range *)malloc(sizeof(git_diff_range)); + *result = *arg; + return result; +} diff --git a/src/index.cc b/src/index.cc index 79bd83da6..25884fcdd 100644 --- a/src/index.cc +++ b/src/index.cc @@ -148,7 +148,7 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { } baton->index_pathReference.Dispose(); baton->callback.Dispose(); - delete baton->index_path; + free((void *)baton->index_path); delete baton; } @@ -569,7 +569,7 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { baton->indexReference.Dispose(); baton->pathReference.Dispose(); baton->callback.Dispose(); - delete baton->path; + free((void *)baton->path); delete baton; } diff --git a/src/odb.cc b/src/odb.cc index 434083f41..2467df197 100644 --- a/src/odb.cc +++ b/src/odb.cc @@ -391,7 +391,7 @@ void GitOdb::WriteAfterWork(uv_work_t *req) { baton->lenReference.Dispose(); baton->typeReference.Dispose(); baton->callback.Dispose(); - delete baton->data; + free((void *)baton->data); delete baton; } diff --git a/src/patch.cc b/src/patch.cc index 13c6eb8da..596335d94 100644 --- a/src/patch.cc +++ b/src/patch.cc @@ -153,7 +153,8 @@ Handle GitPatch::Hunk(const Arguments& args) { Handle toReturn = Object::New(); Handle to; - to = GitDiffRange::New((void *)range); + range = (const git_diff_range * )git_diff_range_dup(range); + to = GitDiffRange::New((void *)range); toReturn->Set(String::NewSymbol("range"), to); to = String::New(header); @@ -222,7 +223,7 @@ Handle GitPatch::Line(const Arguments& args) { to = Integer::New(line_origin); toReturn->Set(String::NewSymbol("lineOrigin"), to); - to = String::New(content); + to = String::New(content, content_len); toReturn->Set(String::NewSymbol("content"), to); to = Uint32::New(content_len); diff --git a/src/reference.cc b/src/reference.cc index 80a7c2c69..dddc5f917 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -150,7 +150,7 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { baton->repoReference.Dispose(); baton->nameReference.Dispose(); baton->callback.Dispose(); - delete baton->name; + free((void *)baton->name); delete baton; } @@ -382,7 +382,7 @@ void GitReference::RenameAfterWork(uv_work_t *req) { baton->new_nameReference.Dispose(); baton->forceReference.Dispose(); baton->callback.Dispose(); - delete baton->new_name; + free((void *)baton->new_name); delete baton; } diff --git a/src/repo.cc b/src/repo.cc index a5c4bfb32..79d141c07 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -159,7 +159,7 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { } baton->pathReference.Dispose(); baton->callback.Dispose(); - delete baton->path; + free((void *)baton->path); delete baton; } @@ -236,7 +236,7 @@ void GitRepo::InitAfterWork(uv_work_t *req) { baton->pathReference.Dispose(); baton->is_bareReference.Dispose(); baton->callback.Dispose(); - delete baton->path; + free((void *)baton->path); delete baton; } @@ -637,7 +637,7 @@ void GitRepo::GetReferenceAfterWork(uv_work_t *req) { baton->repoReference.Dispose(); baton->nameReference.Dispose(); baton->callback.Dispose(); - delete baton->name; + free((void *)baton->name); delete baton; } @@ -967,8 +967,8 @@ void GitRepo::CreateTagAfterWork(uv_work_t *req) { baton->messageReference.Dispose(); baton->forceReference.Dispose(); baton->callback.Dispose(); - delete baton->tag_name; - delete baton->message; + free((void *)baton->tag_name); + free((void *)baton->message); delete baton; } @@ -1058,7 +1058,7 @@ void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { baton->targetReference.Dispose(); baton->forceReference.Dispose(); baton->callback.Dispose(); - delete baton->tag_name; + free((void *)baton->tag_name); delete baton; } @@ -1261,7 +1261,7 @@ void GitRepo::DeleteAfterWork(uv_work_t *req) { baton->repoReference.Dispose(); baton->tag_nameReference.Dispose(); baton->callback.Dispose(); - delete baton->tag_name; + free((void *)baton->tag_name); delete baton; } diff --git a/src/revwalk.cc b/src/revwalk.cc index 75208e59a..7a66dd615 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -220,7 +220,7 @@ void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { baton->walkReference.Dispose(); baton->globReference.Dispose(); baton->callback.Dispose(); - delete baton->glob; + free((void *)baton->glob); delete baton; } @@ -421,7 +421,7 @@ void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { baton->walkReference.Dispose(); baton->globReference.Dispose(); baton->callback.Dispose(); - delete baton->glob; + free((void *)baton->glob); delete baton; } @@ -553,7 +553,7 @@ void GitRevWalk::PushRefAfterWork(uv_work_t *req) { baton->walkReference.Dispose(); baton->refnameReference.Dispose(); baton->callback.Dispose(); - delete baton->refname; + free((void *)baton->refname); delete baton; } @@ -624,7 +624,7 @@ void GitRevWalk::HideRefAfterWork(uv_work_t *req) { baton->walkReference.Dispose(); baton->refnameReference.Dispose(); baton->callback.Dispose(); - delete baton->refname; + free((void *)baton->refname); delete baton; } diff --git a/src/tree.cc b/src/tree.cc index 6a3ccd7f5..d56f180fe 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -41,7 +41,7 @@ void GitTree::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "entryByName", EntryByName); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByIndex", EntryByIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByOid", EntryByOid); - NODE_SET_PROTOTYPE_METHOD(tpl, "getFile", GetFile); + NODE_SET_PROTOTYPE_METHOD(tpl, "getEntry", GetEntry); NODE_SET_PROTOTYPE_METHOD(tpl, "diffTree", DiffTree); NODE_SET_PROTOTYPE_METHOD(tpl, "diffIndex", DiffIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "diffWorkDir", DiffWorkDir); @@ -161,7 +161,7 @@ Handle GitTree::EntryByOid(const Arguments& args) { return scope.Close(to); } -Handle GitTree::GetFile(const Arguments& args) { +Handle GitTree::GetEntry(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("String path is required."))); @@ -171,7 +171,7 @@ Handle GitTree::GetFile(const Arguments& args) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - GetFileBaton* baton = new GetFileBaton; + GetEntryBaton* baton = new GetEntryBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; @@ -183,13 +183,13 @@ Handle GitTree::GetFile(const Arguments& args) { baton->path = from_path; baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, GetFileWork, (uv_after_work_cb)GetFileAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetEntryWork, (uv_after_work_cb)GetEntryAfterWork); return Undefined(); } -void GitTree::GetFileWork(uv_work_t *req) { - GetFileBaton *baton = static_cast(req->data); +void GitTree::GetEntryWork(uv_work_t *req) { + GetEntryBaton *baton = static_cast(req->data); int result = git_tree_entry_bypath( &baton->out, baton->root, @@ -201,9 +201,9 @@ void GitTree::GetFileWork(uv_work_t *req) { } } -void GitTree::GetFileAfterWork(uv_work_t *req) { +void GitTree::GetEntryAfterWork(uv_work_t *req) { HandleScope scope; - GetFileBaton *baton = static_cast(req->data); + GetEntryBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { @@ -230,7 +230,7 @@ void GitTree::GetFileAfterWork(uv_work_t *req) { baton->rootReference.Dispose(); baton->pathReference.Dispose(); baton->callback.Dispose(); - delete baton->path; + free((void *)baton->path); delete baton; } diff --git a/templates/asyncFunction.cc.ejs b/templates/asyncFunction.cc.ejs index eba4589a3..b18dba88c 100644 --- a/templates/asyncFunction.cc.ejs +++ b/templates/asyncFunction.cc.ejs @@ -121,7 +121,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t var arg = functionInfo.args[i]; -%> <% if (arg.cppClassName == 'String') { -%> - delete baton-><%- arg.name %>; + free((void *)baton-><%- arg.name %>); <% } -%> <% } -%> delete baton; diff --git a/templates/convertToV8.cc.ejs b/templates/convertToV8.cc.ejs index 22bd6359b..0cc581074 100644 --- a/templates/convertToV8.cc.ejs +++ b/templates/convertToV8.cc.ejs @@ -1,13 +1,17 @@ <% toName = to.name || 'result' -%> <% if (to.cppClassName == "String") { -%> - to = <%- to.cppClassName %>::New(<%- toName %>); +<% if (typeof to.size != 'undefined') { -%> + to = String::New(<%- toName %>, <%- to.size %>); +<% } else { -%> + to = String::New(<%- toName %>); +<% } -%> <% } else if (isV8Value(to.cppClassName)) { -%> to = <%- to.cppClassName %>::New(<%- toName %>); <% } else if (to.cppClassName == "External") { -%> to = External::New((void *)<%- toName %>); <% } else { -%> <% if (to.copy) { -%> - <%- toName %> = (<%- to.cType %> <% if (!/\*/.test(to.cType)) {%>*<% } %>)<%- to.copy %>(<%- toName %>); + <%- toName %> = (<%- to.cType.replace('**', '*') %> <% if (!/\*/.test(to.cType)) {%>*<% } %>)<%- to.copy %>(<%- toName %>); <% } -%> to = <%- to.cppClassName %>::New((void *)<%- toName %>); <% } -%> diff --git a/test/commit.js b/test/commit.js index 1e2e7f314..16515cd45 100644 --- a/test/commit.js +++ b/test/commit.js @@ -141,20 +141,22 @@ exports.improperCommitId = function(test) { * Test that retreiving walking a given commit's history works as expected. */ exports.history = function(test) { - test.expect(368); + test.expect(4); git.Repo.open('../.git', function(error, repository) { repository.getCommit(historyCountKnownSHA, function(error, commit) { test.equals(null, error, 'Getting latest branch commit should not error'); var historyCount = 0; var expectedHistoryCount = 364; - commit.history().on('commit', function(error, commit) { - test.equals(null, error, 'There should be no errors'); + commit.history().on('commit', function(commit) { historyCount++; - }).on('end', function(error, commits) { + }).on('end', function(commits) { test.equals(null, error, 'There should be no errors'); test.equals(historyCount, expectedHistoryCount); test.equals(commits.length, expectedHistoryCount); test.done(); + }).on('error', function(error) { + test.equals(null, error, 'There should be no errors'); + test.ok(false, 'There should be no errors'); }).start(); }); }); diff --git a/test/entry.js b/test/tree_entry.js similarity index 98% rename from test/entry.js rename to test/tree_entry.js index 57235aa71..4ee9b1338 100644 --- a/test/entry.js +++ b/test/tree_entry.js @@ -5,7 +5,7 @@ var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; var getEntry = function(path, callback) { git.Repo.open('../.git', function(error, repo) { repo.getCommit(sha, function(error, commit) { - commit.getFile(path, callback); + commit.getEntry(path, callback); }); }); }; diff --git a/v0.18.0.json b/v0.18.0.json index 22bbfd147..a5b9642aa 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -2732,7 +2732,8 @@ "cType": "const git_diff_range **", "cppClassName": "GitDiffRange", "jsClassName": "DiffRange", - "isReturn": true + "isReturn": true, + "copy": "git_diff_range_dup" }, { "name": "header", @@ -2824,6 +2825,7 @@ { "name": "content", "jsName": "content", + "size": "content_len", "cType": "const char **", "cppClassName": "String", "jsClassName": "String", @@ -4247,8 +4249,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "getFile", - "cppFunctionName": "GetFile", + "jsFunctionName": "getEntry", + "cppFunctionName": "GetEntry", "return": { "cType": "const git_index_entry *", "cppClassName": "GitIndexEntry", @@ -14482,8 +14484,8 @@ "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "getFile", - "cppFunctionName": "GetFile", + "jsFunctionName": "getEntry", + "cppFunctionName": "GetEntry", "return": { "cType": "int", "cppClassName": "Int32", From 591558265c69610946b543594462842fd5041515 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 5 Jul 2013 15:21:45 +0200 Subject: [PATCH 25/28] Basic support for arrays --- TODO | 1 - example/general.js | 31 +++-- include/repo.h | 44 ++++++ lib/object.js | 13 +- lib/oid.js | 4 + lib/reference.js | 12 +- lib/util.js | 6 +- src/branch.cc | 16 +-- src/index.cc | 10 +- src/odb.cc | 6 +- src/oid.cc | 2 +- src/reference.cc | 4 +- src/repo.cc | 236 ++++++++++++++++++++++++++++++++- src/signature.cc | 8 +- src/submodule.cc | 2 +- src/tree.cc | 2 +- templates/asyncFunction.cc.ejs | 8 +- templates/class.cc.ejs | 2 +- templates/convertFromV8.cc.ejs | 9 +- templates/convertToV8.cc.ejs | 9 ++ templates/syncFunction.cc.ejs | 8 +- util/hint-check.js | 59 +++------ v0.18.0.json | 25 ++-- 23 files changed, 403 insertions(+), 114 deletions(-) diff --git a/TODO b/TODO index ef875f88f..34afdf82b 100644 --- a/TODO +++ b/TODO @@ -1,2 +1 @@ - codegen documentation -- array handling diff --git a/example/general.js b/example/general.js index 9953524a6..f01781bed 100644 --- a/example/general.js +++ b/example/general.js @@ -128,12 +128,14 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { // parents. Here we're creating oid objects to create the commit with, // but you can also use existing ones: - var treeId = git.Oid.fromString("28873d96b4e8f4e33ea30f4c682fd325f7ba56ac"); - var parentId = git.Oid.fromString("f0877d0b841d75172ec404fc9370173dfffc20d1"); + var treeId = git.Oid.fromString("4170d10f19600b9cb086504e8e05fe7d863358a2"); + var parentId = git.Oid.fromString("eebd0ead15d62eaf0ba276da53af43bbc3ce43ab"); repo.getTree(treeId, function(error, tree) { + if (error) throw error; + repo.getCommit(parentId, function(error, parent) { - return "Not yet working!"; + if (error) throw error; // Here we actually create the commit object with a single call with all // the values we need to create the commit. The SHA key is written to the // `commit_id` variable here. @@ -144,8 +146,8 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { "example commit", tree, [parent], - function (error, commitOid) { - console.log("New Commit:", commitOid.sha()); + function (error, oid) { + console.log("New Commit:", oid.sha()); }); }); }); @@ -306,16 +308,19 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { // references such as branches, tags and remote references (everything in // the .git/refs directory). - return "this doesn't yet work"; - repo.getReferences(function(error, references) { + repo.getReferences(git.Reference.Type.Oid | git.Reference.Type.Symbolic, function(error, referenceNames) { if (error) throw error; - references.forEach(function(reference) { - if (reference.type() == git.Reference.Oid) { - console.log(oid.sha()); - } else if (reference.type() == git.Reference.Symbolic) { - console.log(reference.symbolicTarget()); - } + referenceNames.forEach(function(referenceName) { + repo.getReference(referenceName, function(error, reference) { + if (error) throw error; + + if (reference.isOid()) { + console.log("Reference:", referenceName, reference.oid()); + } else if (reference.isSymbolic()) { + console.log("Reference:", referenceName, reference.symbolicTarget()); + } + }); }); }); }); diff --git a/include/repo.h b/include/repo.h index 342866964..b66f14baf 100755 --- a/include/repo.h +++ b/include/repo.h @@ -105,6 +105,35 @@ class GitRepo : public ObjectWrap { const git_oid * id; Persistent callback; }; + static Handle CreateCommit(const Arguments& args); + static void CreateCommitWork(uv_work_t* req); + static void CreateCommitAfterWork(uv_work_t* req); + + struct CreateCommitBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * id; + Persistent repoReference; + git_repository * repo; + Persistent update_refReference; + const char * update_ref; + Persistent authorReference; + const git_signature * author; + Persistent committerReference; + const git_signature * committer; + Persistent message_encodingReference; + const char * message_encoding; + Persistent messageReference; + const char * message; + Persistent treeReference; + const git_tree * tree; + Persistent parent_countReference; + int parent_count; + Persistent parentsReference; + const git_commit ** parents; + Persistent callback; + }; static Handle GetObject(const Arguments& args); static void GetObjectWork(uv_work_t* req); static void GetObjectAfterWork(uv_work_t* req); @@ -240,6 +269,21 @@ class GitRepo : public ObjectWrap { const char * tag_name; Persistent callback; }; + static Handle GetReferences(const Arguments& args); + static void GetReferencesWork(uv_work_t* req); + static void GetReferencesAfterWork(uv_work_t* req); + + struct GetReferencesBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_strarray * array; + Persistent repoReference; + git_repository * repo; + Persistent list_flagsReference; + unsigned int list_flags; + Persistent callback; + }; git_repository *raw; }; diff --git a/lib/object.js b/lib/object.js index 002a8d0ae..e58522890 100644 --- a/lib/object.js +++ b/lib/object.js @@ -1,7 +1,6 @@ -var git = require('../'), - Object = git.Object; +var git = require('../'); -Object.Type = { +git.Object.Type = { Any: -2, /**< Object can be any of the following */ Bad: -1, /**< Object is invalid. */ Ext1: 0, /**< Reserved for future use. */ @@ -14,18 +13,18 @@ Object.Type = { OidDelta: 7 /**< A delta, base is given by object id. */ }; -Object.prototype.isCommit = function() { +git.Object.prototype.isCommit = function() { return this.type() == Object.Type.Commit; }; -Object.prototype.isTree = function() { +git.Object.prototype.isTree = function() { return this.type() == Object.Type.Tree; }; -Object.prototype.isBlob = function() { +git.Object.prototype.isBlob = function() { return this.type() == Object.Type.Blob; }; -Object.prototype.isTag = function() { +git.Object.prototype.isTag = function() { return this.type() == Object.Type.Tag; }; diff --git a/lib/oid.js b/lib/oid.js index bdc2de1ee..5b68dee40 100644 --- a/lib/oid.js +++ b/lib/oid.js @@ -4,3 +4,7 @@ var git = require('../'), Oid.prototype.toString = function() { return this.sha(); }; + +Oid.prototype.inspect = function() { + return "[Oid " + this.sha() + "]"; +}; diff --git a/lib/reference.js b/lib/reference.js index 386b86e73..f690983db 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -2,6 +2,14 @@ var git = require('../'), Reference = git.Reference; Reference.Type = { - Oid: 0, - Symbolic: 1 + Oid: 1, + Symbolic: 2 +}; + +Reference.prototype.isOid = function() { + return this.type() == Reference.Type.Oid; +}; + +Reference.prototype.isSymbolic = function() { + return this.type() == Reference.Type.Symbolic; }; diff --git a/lib/util.js b/lib/util.js index a9db9724e..096a34291 100644 --- a/lib/util.js +++ b/lib/util.js @@ -17,7 +17,9 @@ exports.normalizeOid = function(object, key) { object[key] = function() { var oid = arguments[0]; if (typeof oid === 'string') oid = git.Oid.fromString(oid); - arguments[0] = oid; - oldFn.apply(this, arguments); + var newArguments = [oid]; + for (var i = 1; i < arguments.length; i++) + newArguments[i] = arguments[i]; + oldFn.apply(this, newArguments); }; }; diff --git a/src/branch.cc b/src/branch.cc index 60c8c2bad..6bb6207b5 100644 --- a/src/branch.cc +++ b/src/branch.cc @@ -100,7 +100,7 @@ Handle Branch::Create(const Arguments& args) { , from_target , from_force ); - delete from_branch_name; + free((void *)from_branch_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -185,7 +185,7 @@ Handle Branch::Move(const Arguments& args) { , from_new_branch_name , from_force ); - delete from_new_branch_name; + free((void *)from_new_branch_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -219,7 +219,7 @@ Handle Branch::Lookup(const Arguments& args) { , from_branch_name , from_branch_type ); - delete from_branch_name; + free((void *)from_branch_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -290,7 +290,7 @@ Handle Branch::SetUpstream(const Arguments& args) { from_branch , from_upstream_name ); - delete from_upstream_name; + free((void *)from_upstream_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -326,8 +326,8 @@ Handle Branch::UpstreamName(const Arguments& args) { , from_repo , from_canonical_branch_name ); - delete from_tracking_branch_name_out; - delete from_canonical_branch_name; + free((void *)from_tracking_branch_name_out); + free((void *)from_canonical_branch_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -381,8 +381,8 @@ Handle Branch::RemoteName(const Arguments& args) { , from_repo , from_canonical_branch_name ); - delete from_remote_name_out; - delete from_canonical_branch_name; + free((void *)from_remote_name_out); + free((void *)from_canonical_branch_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/index.cc b/src/index.cc index 25884fcdd..063c6af1e 100644 --- a/src/index.cc +++ b/src/index.cc @@ -468,7 +468,7 @@ Handle GitIndex::Remove(const Arguments& args) { , from_path , from_stage ); - delete from_path; + free((void *)from_path); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -494,7 +494,7 @@ Handle GitIndex::RemoveDirectory(const Arguments& args) { , from_dir , from_stage ); - delete from_dir; + free((void *)from_dir); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -586,7 +586,7 @@ Handle GitIndex::RemoveBypath(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() , from_path ); - delete from_path; + free((void *)from_path); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -612,7 +612,7 @@ Handle GitIndex::Find(const Arguments& args) { , ObjectWrap::Unwrap(args.This())->GetValue() , from_path ); - delete from_path; + free((void *)from_path); Handle to; to = Int32::New(result); @@ -632,7 +632,7 @@ Handle GitIndex::ConflictRemove(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() , from_path ); - delete from_path; + free((void *)from_path); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/odb.cc b/src/odb.cc index 2467df197..840029d63 100644 --- a/src/odb.cc +++ b/src/odb.cc @@ -105,7 +105,7 @@ Handle GitOdb::Open(const Arguments& args) { &out , from_objects_dir ); - delete from_objects_dir; + free((void *)from_objects_dir); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -128,7 +128,7 @@ Handle GitOdb::AddDiskAlternate(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() , from_path ); - delete from_path; + free((void *)from_path); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -446,7 +446,7 @@ Handle GitOdb::Hashfile(const Arguments& args) { , from_path , from_type ); - delete from_path; + free((void *)from_path); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/oid.cc b/src/oid.cc index 4b619ef07..7f8937676 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -76,7 +76,7 @@ Handle GitOid::FromString(const Arguments& args) { out , from_str ); - delete from_str; + free((void *)from_str); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/reference.cc b/src/reference.cc index dddc5f917..569ba578b 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -272,7 +272,7 @@ Handle GitReference::SetSymbolicTarget(const Arguments& args) { , ObjectWrap::Unwrap(args.This())->GetValue() , from_target ); - delete from_target; + free((void *)from_target); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -510,7 +510,7 @@ Handle GitReference::IsValidName(const Arguments& args) { int result = git_reference_is_valid_name( from_refname ); - delete from_refname; + free((void *)from_refname); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/repo.cc b/src/repo.cc index 79d141c07..b994daea6 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -51,6 +51,7 @@ void GitRepo::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "openIndex", openIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "getBlob", GetBlob); NODE_SET_PROTOTYPE_METHOD(tpl, "getCommit", GetCommit); + NODE_SET_PROTOTYPE_METHOD(tpl, "createCommit", CreateCommit); NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); NODE_SET_PROTOTYPE_METHOD(tpl, "getReference", GetReference); NODE_SET_PROTOTYPE_METHOD(tpl, "createSymbolicReference", CreateSymbolicReference); @@ -64,6 +65,7 @@ void GitRepo::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "getTree", GetTree); NODE_SET_METHOD(tpl, "reloadSubmodules", ReloadSubmodules); NODE_SET_PROTOTYPE_METHOD(tpl, "delete", Delete); + NODE_SET_PROTOTYPE_METHOD(tpl, "getReferences", GetReferences); constructor_template = Persistent::New(tpl->GetFunction()); @@ -489,6 +491,148 @@ void GitRepo::GetCommitAfterWork(uv_work_t *req) { delete baton; } +Handle GitRepo::CreateCommit(const Arguments& args) { + HandleScope scope; + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature author is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature committer is required."))); + } + if (args.Length() == 4 || !args[4]->IsString()) { + return ThrowException(Exception::Error(String::New("String message is required."))); + } + if (args.Length() == 5 || !args[5]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree tree is required."))); + } + if (args.Length() == 6 || !args[6]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number parent_count is required."))); + } + if (args.Length() == 7 || !args[7]->IsObject()) { + return ThrowException(Exception::Error(String::New("Array parents is required."))); + } + + if (args.Length() == 8 || !args[8]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateCommitBaton* baton = new CreateCommitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->id = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->update_refReference = Persistent::New(args[0]); + if (args[0]->IsString()) { + String::Utf8Value update_ref(args[0]->ToString()); + const char * from_update_ref = strdup(*update_ref); + baton->update_ref = from_update_ref; + } else { + baton->update_ref = NULL; + } + baton->authorReference = Persistent::New(args[1]); + const git_signature * from_author = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->author = from_author; + baton->committerReference = Persistent::New(args[2]); + const git_signature * from_committer = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->committer = from_committer; + baton->message_encodingReference = Persistent::New(args[3]); + if (args[3]->IsString()) { + String::Utf8Value message_encoding(args[3]->ToString()); + const char * from_message_encoding = strdup(*message_encoding); + baton->message_encoding = from_message_encoding; + } else { + baton->message_encoding = NULL; + } + baton->messageReference = Persistent::New(args[4]); + String::Utf8Value message(args[4]->ToString()); + const char * from_message = strdup(*message); + baton->message = from_message; + baton->treeReference = Persistent::New(args[5]); + const git_tree * from_tree = ObjectWrap::Unwrap(args[5]->ToObject())->GetValue(); + baton->tree = from_tree; + baton->parent_countReference = Persistent::New(args[6]); + int from_parent_count = (int) args[6]->ToInt32()->Value(); + baton->parent_count = from_parent_count; + baton->parentsReference = Persistent::New(args[7]); + Array *tmp_parents = Array::Cast(*args[7]); + const git_commit ** from_parents = (const git_commit **)malloc(tmp_parents->Length() * sizeof(const git_commit *)); + for (unsigned int i = 0; i < tmp_parents->Length(); i++) { + + from_parents[i] = ObjectWrap::Unwrap(tmp_parents->Get(Number::New(static_cast(i)))->ToObject())->GetValue(); + } + baton->parents = from_parents; + baton->callback = Persistent::New(Local::Cast(args[8])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateCommitWork, (uv_after_work_cb)CreateCommitAfterWork); + + return Undefined(); +} + +void GitRepo::CreateCommitWork(uv_work_t *req) { + CreateCommitBaton *baton = static_cast(req->data); + int result = git_commit_create( + baton->id, + baton->repo, + baton->update_ref, + baton->author, + baton->committer, + baton->message_encoding, + baton->message, + baton->tree, + baton->parent_count, + baton->parents + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateCommitAfterWork(uv_work_t *req) { + HandleScope scope; + CreateCommitBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + to = GitOid::New((void *)baton->id); + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->update_refReference.Dispose(); + baton->authorReference.Dispose(); + baton->committerReference.Dispose(); + baton->message_encodingReference.Dispose(); + baton->messageReference.Dispose(); + baton->treeReference.Dispose(); + baton->parent_countReference.Dispose(); + baton->parentsReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->update_ref); + free((void *)baton->message_encoding); + free((void *)baton->message); + free((void *)baton->parents); + delete baton; +} + Handle GitRepo::GetObject(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -667,8 +811,8 @@ Handle GitRepo::CreateSymbolicReference(const Arguments& args) { , from_target , from_force ); - delete from_name; - delete from_target; + free((void *)from_name); + free((void *)from_target); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -703,7 +847,7 @@ Handle GitRepo::CreateReference(const Arguments& args) { , from_id , from_force ); - delete from_name; + free((void *)from_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -746,7 +890,7 @@ Handle GitRepo::GetSubmodule(const Arguments& args) { , ObjectWrap::Unwrap(args.This())->GetValue() , from_name ); - delete from_name; + free((void *)from_name); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -782,8 +926,8 @@ Handle GitRepo::AddSubmodule(const Arguments& args) { , from_path , from_use_gitlink ); - delete from_url; - delete from_path; + free((void *)from_url); + free((void *)from_path); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -1265,4 +1409,84 @@ void GitRepo::DeleteAfterWork(uv_work_t *req) { delete baton; } +Handle GitRepo::GetReferences(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetReferencesBaton* baton = new GetReferencesBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->array = (git_strarray *)malloc(sizeof(git_strarray )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->list_flagsReference = Persistent::New(args[0]); + if (args[0]->IsUint32()) { + unsigned int from_list_flags = (unsigned int) args[0]->ToUint32()->Value(); + baton->list_flags = from_list_flags; + } else { + baton->list_flags = NULL; + } + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetReferencesWork, (uv_after_work_cb)GetReferencesAfterWork); + + return Undefined(); +} + +void GitRepo::GetReferencesWork(uv_work_t *req) { + GetReferencesBaton *baton = static_cast(req->data); + int result = git_reference_list( + baton->array, + baton->repo, + baton->list_flags + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetReferencesAfterWork(uv_work_t *req) { + HandleScope scope; + GetReferencesBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + + Local tmpArray = Array::New(baton->array->count); + for (unsigned int i = 0; i < baton->array->count; i++) { + tmpArray->Set(Number::New(i), String::New(baton->array->strings[i])); + } + to = tmpArray; + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->list_flagsReference.Dispose(); + baton->callback.Dispose(); + + git_strarray_free(baton->array); + delete baton; +} + Persistent GitRepo::constructor_template; diff --git a/src/signature.cc b/src/signature.cc index 492a84d50..fbaa72439 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -96,8 +96,8 @@ Handle GitSignature::Create(const Arguments& args) { , from_time , from_offset ); - delete from_name; - delete from_email; + free((void *)from_name); + free((void *)from_email); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } @@ -127,8 +127,8 @@ Handle GitSignature::Now(const Arguments& args) { , from_name , from_email ); - delete from_name; - delete from_email; + free((void *)from_name); + free((void *)from_email); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/submodule.cc b/src/submodule.cc index 1d064e7b4..af2732df3 100644 --- a/src/submodule.cc +++ b/src/submodule.cc @@ -319,7 +319,7 @@ Handle GitSubmodule::SetUrl(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() , from_url ); - delete from_url; + free((void *)from_url); if (result != GIT_OK) { return ThrowException(Exception::Error(String::New(giterr_last()->message))); } diff --git a/src/tree.cc b/src/tree.cc index d56f180fe..3083d7c6e 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -115,7 +115,7 @@ Handle GitTree::EntryByName(const Arguments& args) { ObjectWrap::Unwrap(args.This())->GetValue() , from_filename ); - delete from_filename; + free((void *)from_filename); Handle to; result = (const git_tree_entry * )git_tree_entry_dup(result); diff --git a/templates/asyncFunction.cc.ejs b/templates/asyncFunction.cc.ejs index b18dba88c..b97729e3e 100644 --- a/templates/asyncFunction.cc.ejs +++ b/templates/asyncFunction.cc.ejs @@ -76,7 +76,7 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t <% if (!returns.length) { %> Handle result = Local::New(Undefined()); <% } else if (returns.length == 1) { -%> -<% var to = returns[0]; to.name = "baton->" + to.name; -%> +<% var to = {}; to.__proto__ = returns[0]; to.name = "baton->" + to.name; -%> Handle to; <% include convertToV8.cc.ejs -%> Handle result = to; @@ -120,9 +120,13 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t for (var i = 0; i < functionInfo.args.length; i++) { var arg = functionInfo.args[i]; -%> -<% if (arg.cppClassName == 'String') { -%> +<% if (['String', 'Array'].indexOf(arg.cppClassName) > -1) { -%> +<% if (arg.freeFunctionName) { %> + <%- arg.freeFunctionName %>(baton-><%- arg.name %>); +<% } else { -%> free((void *)baton-><%- arg.name %>); <% } -%> +<% } -%> <% } -%> delete baton; } diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs index c328fed6e..1ddc9d618 100644 --- a/templates/class.cc.ejs +++ b/templates/class.cc.ejs @@ -1,6 +1,6 @@ <% function isV8Value(cppClassName) { - return ["Boolean", "Number", "String", "Integer", "Int32", "Uint32", "Array", "Date", "Function"].indexOf(cppClassName) > -1; + return ["Boolean", "Number", "String", "Integer", "Int32", "Uint32", "Date", "Function"].indexOf(cppClassName) > -1; } function cppClassName2v8ValueClassName(cppClassName) { diff --git a/templates/convertFromV8.cc.ejs b/templates/convertFromV8.cc.ejs index ad7246417..a6862e043 100644 --- a/templates/convertFromV8.cc.ejs +++ b/templates/convertFromV8.cc.ejs @@ -2,7 +2,14 @@ String::Utf8Value <%- arg.name %>(args[<%- jsArg %>]->ToString()); <%- arg.cType %> from_<%- arg.name %> = strdup(*<%- arg.name %>); <% } else if (arg.cppClassName == 'Array') { -%> - <%- arg.cType %> from_<%- arg.name %> = Array::Cast(*args[<%- jsArg %>]); + Array *tmp_<%- arg.name %> = Array::Cast(*args[<%- jsArg %>]); + <%- arg.cType %> from_<%- arg.name %> = (<%- arg.cType %>)malloc(tmp_<%- arg.name %>->Length() * sizeof(<%- arg.cType.replace('**', '*') %>)); + for (unsigned int i = 0; i < tmp_<%- arg.name %>->Length(); i++) { +<% + // FIXME: should recursively call convertFromv8. +%> + from_<%- arg.name %>[i] = ObjectWrap::Unwrap<<%- arg.arrayElementCppClassName %>>(tmp_<%- arg.name %>->Get(Number::New(static_cast(i)))->ToObject())->GetValue(); + } <% } else if (arg.cppClassName == 'Buffer') { -%> <%- arg.cType %> from_<%- arg.name %> = Buffer::Data(ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())); <% } else if (isV8Value(arg.cppClassName)) { -%> diff --git a/templates/convertToV8.cc.ejs b/templates/convertToV8.cc.ejs index 0cc581074..3a779b9cf 100644 --- a/templates/convertToV8.cc.ejs +++ b/templates/convertToV8.cc.ejs @@ -9,6 +9,15 @@ to = <%- to.cppClassName %>::New(<%- toName %>); <% } else if (to.cppClassName == "External") { -%> to = External::New((void *)<%- toName %>); +<% } else if (to.cppClassName == 'Array') { -%> +<% + // FIXME this is not general purpose enough. +%> + Local tmpArray = Array::New(<%- toName %>-><%- to.size %>); + for (unsigned int i = 0; i < <%- toName %>-><%- to.size %>; i++) { + tmpArray->Set(Number::New(i), String::New(<%- toName %>-><%- to.key %>[i])); + } + to = tmpArray; <% } else { -%> <% if (to.copy) { -%> <%- toName %> = (<%- to.cType.replace('**', '*') %> <% if (!/\*/.test(to.cType)) {%>*<% } %>)<%- to.copy %>(<%- toName %>); diff --git a/templates/syncFunction.cc.ejs b/templates/syncFunction.cc.ejs index 6544d88a0..14b81218f 100644 --- a/templates/syncFunction.cc.ejs +++ b/templates/syncFunction.cc.ejs @@ -44,8 +44,12 @@ from_<%- arg.name %> var arg = functionInfo.args[i]; if (arg.isSelf || arg.isReturn) continue; -%> -<% if (arg.cppClassName == 'String') { -%> - delete from_<%- arg.name %>; +<% if (['String', 'Array'].indexOf(arg.cppClassName) > -1) { -%> +<% if (arg.freeFunctionName) { %> + <%- arg.freeFunctionName %>(from_<%- arg.name %>); +<% } else { -%> + free((void *)from_<%- arg.name %>); +<% } -%> <% } -%> <% } -%> <% if (functionInfo.return.isErrorCode) { -%> diff --git a/util/hint-check.js b/util/hint-check.js index 54091ff8b..ab71ac549 100644 --- a/util/hint-check.js +++ b/util/hint-check.js @@ -1,49 +1,22 @@ -var nodejshint = require( './nodejshint.js' ).test, +var nodejshint = require('./nodejshint.js').test, + fs = require('fs'), + path = require('path'); -files = [ - // Test convenience api - 'lib/blob.js' -, 'lib/commit.js' -, 'lib/error.js' -, 'lib/index.js' -, 'lib/object.js' -, 'lib/oid.js' -, 'lib/ref.js' -, 'lib/repo.js' -, 'lib/revwalk.js' -, 'lib/sig.js' -, 'lib/tree.js' -, 'lib/tree_entry.js' -, 'lib/util.js' +var files = []; - // Test unit test -, 'test/convenience-repo.js' -, 'test/index.js' -, 'test/raw-blob.js' -, 'test/raw-commit.js' -, 'test/raw-error.js' -, 'test/raw-object.js' -, 'test/raw-oid.js' -, 'test/raw-reference.js' -, 'test/raw-repo.js' -, 'test/raw-revwalk.js' - - // Test examples -, 'example/convenience-repo.js' -, 'example/convenience-tree.js' -, 'example/raw-error.js' -, 'example/raw-oid.js' -, 'example/raw-repo.js' -, 'example/raw-revwalk.js' -]; +['lib', 'test', 'example'].forEach(function(dir) { + console.log(dir); + fs.readdirSync(dir).forEach(function(file) { + if (/\.js$/.test(file)) files.push(path.join(dir, file)); + }); +}); -nodejshint( files, function( failures ) { - console.log( failures, 'failures' ); +nodejshint(files, function(failures) { + console.log(failures, 'failures'); - if( !files.length ) { - process.exit( 0 ); - } - else { - process.exit( 1 ); + if(!files.length) { + process.exit(0); + } else { + process.exit(1); } }); diff --git a/v0.18.0.json b/v0.18.0.json index a5b9642aa..2792cf530 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -10798,7 +10798,8 @@ "name": "update_ref", "cType": "const char *", "cppClassName": "String", - "jsClassName": "String" + "jsClassName": "String", + "isOptional": true }, { "name": "author", @@ -10816,7 +10817,8 @@ "name": "message_encoding", "cType": "const char *", "cppClassName": "String", - "jsClassName": "String" + "jsClassName": "String", + "isOptional": true }, { "name": "message", @@ -10840,10 +10842,10 @@ "name": "parents", "cType": "const git_commit **", "cppClassName": "Array", + "arrayElementCppClassName": "GitCommit", "jsClassName": "Array" } ], - "ignore": true, "isAsync": true, "isConstructorMethod": false, "isPrototypeMethod": true, @@ -11819,7 +11821,12 @@ "name": "array", "cType": "git_strarray *", "cppClassName": "Array", - "jsClassName": "Array" + "jsClassName": "Array", + "freeFunctionName": "git_strarray_free", + "size": "count", + "key": "strings", + "shouldAlloc": true, + "isReturn": true }, { "name": "repo", @@ -11832,15 +11839,15 @@ "name": "list_flags", "cType": "unsigned int", "cppClassName": "Uint32", - "jsClassName": "Number" + "jsClassName": "Number", + "isOptional": true } ], - "ignore": true, "isAsync": true, "isConstructorMethod": false, - "isPrototypeMethod": false, - "jsFunctionName": "list", - "cppFunctionName": "List", + "isPrototypeMethod": true, + "jsFunctionName": "getReferences", + "cppFunctionName": "GetReferences", "return": { "cType": "int", "cppClassName": "Int32", From 075d4816e35b6f717493fe378eb90e13030b6b04 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 5 Jul 2013 21:09:48 +0200 Subject: [PATCH 26/28] Documentation for codegen --- src/blob.cc | 22 +++++++ src/branch.cc | 55 +++++++++++++++++ src/commit.cc | 35 +++++++++++ src/diff_list.cc | 19 ++++++ src/index.cc | 56 ++++++++++++++++++ src/object.cc | 10 ++++ src/odb.cc | 48 +++++++++++++++ src/odb_object.cc | 12 ++++ src/oid.cc | 7 +++ src/patch.cc | 34 +++++++++++ src/reference.cc | 43 ++++++++++++++ src/repo.cc | 105 +++++++++++++++++++++++++++++++++ src/revwalk.cc | 30 ++++++++++ src/signature.cc | 12 ++++ src/submodule.cc | 38 ++++++++++++ src/tag.cc | 25 ++++++++ src/threads.cc | 4 ++ src/tree.cc | 39 ++++++++++++ src/tree_entry.cc | 16 +++++ templates/asyncFunction.cc.ejs | 3 + templates/doc.cc.ejs | 14 +++++ templates/syncFunction.cc.ejs | 3 + 22 files changed, 630 insertions(+) create mode 100644 templates/doc.cc.ejs diff --git a/src/blob.cc b/src/blob.cc index dc043f273..547b603ec 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -70,6 +70,9 @@ git_blob *GitBlob::GetValue() { } +/** + * @return {GitOid} result + */ Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; @@ -84,6 +87,9 @@ Handle GitBlob::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @return {Wrapper} result + */ Handle GitBlob::Content(const Arguments& args) { HandleScope scope; @@ -97,6 +103,9 @@ Handle GitBlob::Content(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitBlob::Size(const Arguments& args) { HandleScope scope; @@ -110,6 +119,11 @@ Handle GitBlob::Size(const Arguments& args) { return scope.Close(to); } +/** + * @param {Repository} repo + * @param {String} path + * @param {Oid} callback + */ Handle GitBlob::CreateFromFile(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -188,6 +202,12 @@ void GitBlob::CreateFromFileAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Repository} repo + * @param {Buffer} buffer + * @param {Number} len + * @param {Oid} callback + */ Handle GitBlob::CreateFromBuffer(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -272,6 +292,8 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; diff --git a/src/branch.cc b/src/branch.cc index 6bb6207b5..32b44daed 100644 --- a/src/branch.cc +++ b/src/branch.cc @@ -71,6 +71,13 @@ git_branch *Branch::GetValue() { } +/** + * @param {Repository} repo + * @param {String} branch_name + * @param {Commit} target + * @param {Number} force + * @return {Reference} out + */ Handle Branch::Create(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -110,6 +117,9 @@ Handle Branch::Create(const Arguments& args) { return scope.Close(to); } +/** + * @param {Reference} branch + */ Handle Branch::Delete(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -128,6 +138,12 @@ Handle Branch::Delete(const Arguments& args) { return Undefined(); } +/** + * @param {Repository} repo + * @param {Number} list_flags + * @param {BranchForeachCb} branch_cb + * @param {void} payload + */ Handle Branch::Foreach(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -161,6 +177,12 @@ Handle Branch::Foreach(const Arguments& args) { return Undefined(); } +/** + * @param {Reference} branch + * @param {String} new_branch_name + * @param {Number} force + * @return {Reference} out + */ Handle Branch::Move(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -195,6 +217,12 @@ Handle Branch::Move(const Arguments& args) { return scope.Close(to); } +/** + * @param {Repository} repo + * @param {String} branch_name + * @param {BranchT} branch_type + * @return {Reference} out + */ Handle Branch::Lookup(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -229,6 +257,10 @@ Handle Branch::Lookup(const Arguments& args) { return scope.Close(to); } +/** + * @param {Reference} ref + * @return {String} out + */ Handle Branch::Name(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -251,6 +283,10 @@ Handle Branch::Name(const Arguments& args) { return scope.Close(to); } +/** + * @param {Reference} branch + * @return {Reference} out + */ Handle Branch::Upstream(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -273,6 +309,10 @@ Handle Branch::Upstream(const Arguments& args) { return scope.Close(to); } +/** + * @param {Reference} branch + * @param {String} upstream_name + */ Handle Branch::SetUpstream(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -298,6 +338,12 @@ Handle Branch::SetUpstream(const Arguments& args) { return Undefined(); } +/** + * @param {String} tracking_branch_name_out + * @param {Number} buffer_size + * @param {Repository} repo + * @param {String} canonical_branch_name + */ Handle Branch::UpstreamName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -335,6 +381,9 @@ Handle Branch::UpstreamName(const Arguments& args) { return Undefined(); } +/** + * @param {Reference} branch + */ Handle Branch::IsHead(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -353,6 +402,12 @@ Handle Branch::IsHead(const Arguments& args) { return Undefined(); } +/** + * @param {String} remote_name_out + * @param {Number} buffer_size + * @param {Repository} repo + * @param {String} canonical_branch_name + */ Handle Branch::RemoteName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { diff --git a/src/commit.cc b/src/commit.cc index f22611fe0..05362f229 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -75,6 +75,9 @@ git_commit *GitCommit::GetValue() { } +/** + * @return {GitOid} result + */ Handle GitCommit::Oid(const Arguments& args) { HandleScope scope; @@ -89,6 +92,9 @@ Handle GitCommit::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitCommit::MessageEncoding(const Arguments& args) { HandleScope scope; @@ -102,6 +108,9 @@ Handle GitCommit::MessageEncoding(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitCommit::Message(const Arguments& args) { HandleScope scope; @@ -115,6 +124,9 @@ Handle GitCommit::Message(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitCommit::Time(const Arguments& args) { HandleScope scope; @@ -128,6 +140,9 @@ Handle GitCommit::Time(const Arguments& args) { return scope.Close(to); } +/** + * @return {Integer} result + */ Handle GitCommit::Offset(const Arguments& args) { HandleScope scope; @@ -141,6 +156,9 @@ Handle GitCommit::Offset(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitSignature} result + */ Handle GitCommit::Committer(const Arguments& args) { HandleScope scope; @@ -155,6 +173,9 @@ Handle GitCommit::Committer(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitSignature} result + */ Handle GitCommit::Author(const Arguments& args) { HandleScope scope; @@ -169,6 +190,9 @@ Handle GitCommit::Author(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitOid} result + */ Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; @@ -183,6 +207,9 @@ Handle GitCommit::TreeId(const Arguments& args) { return scope.Close(to); } +/** + * @return {Uint32} result + */ Handle GitCommit::ParentCount(const Arguments& args) { HandleScope scope; @@ -196,6 +223,10 @@ Handle GitCommit::ParentCount(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} n + * @return {GitOid} result + */ Handle GitCommit::ParentId(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -215,6 +246,10 @@ Handle GitCommit::ParentId(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} n + * @return {Commit} ancestor + */ Handle GitCommit::NthGenAncestor(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { diff --git a/src/diff_list.cc b/src/diff_list.cc index f09a652ec..eb98297d1 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -72,6 +72,9 @@ git_diff_list *GitDiffList::GetValue() { } +/** + * @param {DiffList} from + */ Handle GitDiffList::Merge(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -91,6 +94,9 @@ Handle GitDiffList::Merge(const Arguments& args) { return Undefined(); } +/** + * @param {DiffFindOptions} options + */ Handle GitDiffList::FindSimilar(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -110,6 +116,9 @@ Handle GitDiffList::FindSimilar(const Arguments& args) { return Undefined(); } +/** + * @return {Uint32} result + */ Handle GitDiffList::Size(const Arguments& args) { HandleScope scope; @@ -123,6 +132,11 @@ Handle GitDiffList::Size(const Arguments& args) { return scope.Close(to); } +/** + * @param {DiffList} diff + * @param {Number} type + * @return {Uint32} result + */ Handle GitDiffList::NumDeltasOfType(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -145,6 +159,11 @@ Handle GitDiffList::NumDeltasOfType(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} idx + * @return {Patch} patch_out + * @return {Delta} delta_out + */ Handle GitDiffList::Patch(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { diff --git a/src/index.cc b/src/index.cc index 063c6af1e..95f77b02e 100644 --- a/src/index.cc +++ b/src/index.cc @@ -83,6 +83,10 @@ git_index *GitIndex::GetValue() { } +/** + * @param {String} index_path + * @param {Index} callback + */ Handle GitIndex::Open(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -152,6 +156,8 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitIndex::Read(const Arguments& args) { HandleScope scope; @@ -213,6 +219,8 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitIndex::Write(const Arguments& args) { HandleScope scope; @@ -274,6 +282,9 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Tree} tree + */ Handle GitIndex::ReadTree(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -343,6 +354,9 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} callback + */ Handle GitIndex::WriteTree(const Arguments& args) { HandleScope scope; @@ -407,6 +421,9 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { delete baton; } +/** + * @return {Uint32} result + */ Handle GitIndex::Size(const Arguments& args) { HandleScope scope; @@ -420,6 +437,8 @@ Handle GitIndex::Size(const Arguments& args) { return scope.Close(to); } +/** + */ Handle GitIndex::Clear(const Arguments& args) { HandleScope scope; @@ -431,6 +450,10 @@ Handle GitIndex::Clear(const Arguments& args) { return Undefined(); } +/** + * @param {Number} n + * @return {GitIndexEntry} result + */ Handle GitIndex::Entry(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -450,6 +473,10 @@ Handle GitIndex::Entry(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} path + * @param {Number} stage + */ Handle GitIndex::Remove(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -476,6 +503,10 @@ Handle GitIndex::Remove(const Arguments& args) { return Undefined(); } +/** + * @param {String} dir + * @param {Number} stage + */ Handle GitIndex::RemoveDirectory(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -502,6 +533,9 @@ Handle GitIndex::RemoveDirectory(const Arguments& args) { return Undefined(); } +/** + * @param {String} path + */ Handle GitIndex::AddBypath(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -573,6 +607,9 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} path + */ Handle GitIndex::RemoveBypath(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -594,6 +631,11 @@ Handle GitIndex::RemoveBypath(const Arguments& args) { return Undefined(); } +/** + * @param {Number} at_pos + * @param {String} path + * @return {Int32} result + */ Handle GitIndex::Find(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -619,6 +661,9 @@ Handle GitIndex::Find(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} path + */ Handle GitIndex::ConflictRemove(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -640,6 +685,8 @@ Handle GitIndex::ConflictRemove(const Arguments& args) { return Undefined(); } +/** + */ Handle GitIndex::ConflictCleanup(const Arguments& args) { HandleScope scope; @@ -651,6 +698,9 @@ Handle GitIndex::ConflictCleanup(const Arguments& args) { return Undefined(); } +/** + * @return {Int32} result + */ Handle GitIndex::HasConflicts(const Arguments& args) { HandleScope scope; @@ -664,6 +714,12 @@ Handle GitIndex::HasConflicts(const Arguments& args) { return scope.Close(to); } +/** + * @param {Repository} repo + * @param {Index} index + * @param {DiffOptions} opts + * @param {DiffList} callback + */ Handle GitIndex::IndexToWorkdir(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/src/object.cc b/src/object.cc index 7334f4610..35c94288b 100644 --- a/src/object.cc +++ b/src/object.cc @@ -65,6 +65,9 @@ git_object *GitObject::GetValue() { } +/** + * @return {GitOid} result + */ Handle GitObject::Oid(const Arguments& args) { HandleScope scope; @@ -79,6 +82,9 @@ Handle GitObject::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitObject::Type(const Arguments& args) { HandleScope scope; @@ -92,6 +98,10 @@ Handle GitObject::Type(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} target_type + * @param {Object} callback + */ Handle GitObject::Peel(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { diff --git a/src/odb.cc b/src/odb.cc index 840029d63..9b1684988 100644 --- a/src/odb.cc +++ b/src/odb.cc @@ -74,6 +74,9 @@ git_odb *GitOdb::GetValue() { } +/** + * @return {Odb} out + */ Handle GitOdb::Create(const Arguments& args) { HandleScope scope; @@ -91,6 +94,10 @@ Handle GitOdb::Create(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} objects_dir + * @return {Odb} out + */ Handle GitOdb::Open(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -115,6 +122,9 @@ Handle GitOdb::Open(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} path + */ Handle GitOdb::AddDiskAlternate(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -136,6 +146,10 @@ Handle GitOdb::AddDiskAlternate(const Arguments& args) { return Undefined(); } +/** + * @param {Oid} id + * @param {OdbObject} callback + */ Handle GitOdb::Read(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -207,6 +221,12 @@ void GitOdb::ReadAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Odb} db + * @param {Oid} short_id + * @param {Number} len + * @return {OdbObject} out + */ Handle GitOdb::ReadPrefix(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -239,6 +259,12 @@ Handle GitOdb::ReadPrefix(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} len_out + * @param {Number} type_out + * @param {Odb} db + * @param {Oid} id + */ Handle GitOdb::ReadHeader(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -272,6 +298,9 @@ Handle GitOdb::ReadHeader(const Arguments& args) { return Undefined(); } +/** + * @param {Oid} id + */ Handle GitOdb::Exists(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -291,6 +320,8 @@ Handle GitOdb::Exists(const Arguments& args) { return Undefined(); } +/** + */ Handle GitOdb::Refresh(const Arguments& args) { HandleScope scope; @@ -305,6 +336,12 @@ Handle GitOdb::Refresh(const Arguments& args) { return Undefined(); } +/** + * @param {String} data + * @param {Number} len + * @param {Number} type + * @param {Oid} callback + */ Handle GitOdb::Write(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -395,6 +432,12 @@ void GitOdb::WriteAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Buffer} data + * @param {Number} len + * @param {Number} type + * @return {Oid} out + */ Handle GitOdb::Hash(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -427,6 +470,11 @@ Handle GitOdb::Hash(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} path + * @param {Number} type + * @return {Oid} out + */ Handle GitOdb::Hashfile(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { diff --git a/src/odb_object.cc b/src/odb_object.cc index 25ed1ebe8..fc7354617 100644 --- a/src/odb_object.cc +++ b/src/odb_object.cc @@ -66,6 +66,9 @@ git_odb_object *GitOdbObject::GetValue() { } +/** + * @return {Wrapper} result + */ Handle GitOdbObject::Data(const Arguments& args) { HandleScope scope; @@ -79,6 +82,9 @@ Handle GitOdbObject::Data(const Arguments& args) { return scope.Close(to); } +/** + * @return {Uint32} result + */ Handle GitOdbObject::Size(const Arguments& args) { HandleScope scope; @@ -92,6 +98,9 @@ Handle GitOdbObject::Size(const Arguments& args) { return scope.Close(to); } +/** + * @return {Int32} result + */ Handle GitOdbObject::Type(const Arguments& args) { HandleScope scope; @@ -105,6 +114,9 @@ Handle GitOdbObject::Type(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitOid} result + */ Handle GitOdbObject::Oid(const Arguments& args) { HandleScope scope; diff --git a/src/oid.cc b/src/oid.cc index 7f8937676..9a8ed1099 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -62,6 +62,10 @@ git_oid *GitOid::GetValue() { } +/** + * @param {String} str + * @return {Oid} out + */ Handle GitOid::FromString(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -86,6 +90,9 @@ Handle GitOid::FromString(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitOid::Sha(const Arguments& args) { HandleScope scope; diff --git a/src/patch.cc b/src/patch.cc index 596335d94..13aee67e1 100644 --- a/src/patch.cc +++ b/src/patch.cc @@ -69,6 +69,9 @@ git_diff_patch *GitPatch::GetValue() { } +/** + * @return {GitDelta} result + */ Handle GitPatch::Delta(const Arguments& args) { HandleScope scope; @@ -83,6 +86,9 @@ Handle GitPatch::Delta(const Arguments& args) { return scope.Close(to); } +/** + * @return {Uint32} result + */ Handle GitPatch::Size(const Arguments& args) { HandleScope scope; @@ -96,6 +102,11 @@ Handle GitPatch::Size(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} total_context + * @return {Number} total_additions + * @return {Number} total_deletions + */ Handle GitPatch::Stats(const Arguments& args) { HandleScope scope; @@ -127,6 +138,13 @@ Handle GitPatch::Stats(const Arguments& args) { return scope.Close(toReturn); } +/** + * @param {Number} hunk_idx + * @return {DiffRange} range + * @return {String} header + * @return {Number} header_len + * @return {Number} lines_in_hunk + */ Handle GitPatch::Hunk(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -169,6 +187,10 @@ Handle GitPatch::Hunk(const Arguments& args) { return scope.Close(toReturn); } +/** + * @param {Number} hunk_idx + * @return {Int32} result + */ Handle GitPatch::Lines(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -187,6 +209,15 @@ Handle GitPatch::Lines(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} hunk_idx + * @param {Number} line_of_hunk + * @return {Number} line_origin + * @return {String} content + * @return {Number} content_len + * @return {Number} old_lineno + * @return {Number} new_lineno + */ Handle GitPatch::Line(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -238,6 +269,9 @@ Handle GitPatch::Line(const Arguments& args) { return scope.Close(toReturn); } +/** + * @return {String} string + */ Handle GitPatch::ToString(const Arguments& args) { HandleScope scope; diff --git a/src/reference.cc b/src/reference.cc index 569ba578b..b1789c131 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -76,6 +76,11 @@ git_reference *GitReference::GetValue() { } +/** + * @param {Repository} repo + * @param {String} name + * @param {Oid} callback + */ Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -154,6 +159,9 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { delete baton; } +/** + * @return {GitOid} result + */ Handle GitReference::Oid(const Arguments& args) { HandleScope scope; @@ -168,6 +176,9 @@ Handle GitReference::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitReference::Name(const Arguments& args) { HandleScope scope; @@ -181,6 +192,9 @@ Handle GitReference::Name(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitReference::Type(const Arguments& args) { HandleScope scope; @@ -194,6 +208,9 @@ Handle GitReference::Type(const Arguments& args) { return scope.Close(to); } +/** + * @param {Reference} callback + */ Handle GitReference::Resolve(const Arguments& args) { HandleScope scope; @@ -257,6 +274,10 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} target + * @return {Reference} out + */ Handle GitReference::SetSymbolicTarget(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -282,6 +303,10 @@ Handle GitReference::SetSymbolicTarget(const Arguments& args) { return scope.Close(to); } +/** + * @param {Oid} id + * @return {Reference} out + */ Handle GitReference::setTarget(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -305,6 +330,11 @@ Handle GitReference::setTarget(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} new_name + * @param {Number} force + * @param {Reference} callback + */ Handle GitReference::Rename(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -386,6 +416,8 @@ void GitReference::RenameAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitReference::Delete(const Arguments& args) { HandleScope scope; @@ -447,6 +479,8 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitReference::IsBranch(const Arguments& args) { HandleScope scope; @@ -461,6 +495,8 @@ Handle GitReference::IsBranch(const Arguments& args) { return Undefined(); } +/** + */ Handle GitReference::IsRemote(const Arguments& args) { HandleScope scope; @@ -475,6 +511,10 @@ Handle GitReference::IsRemote(const Arguments& args) { return Undefined(); } +/** + * @param {Number} type + * @return {Object} out + */ Handle GitReference::Peel(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { @@ -498,6 +538,9 @@ Handle GitReference::Peel(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} refname + */ Handle GitReference::IsValidName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { diff --git a/src/repo.cc b/src/repo.cc index b994daea6..7e2090843 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -96,6 +96,10 @@ git_repository *GitRepo::GetValue() { } +/** + * @param {String} path + * @param {Repository} callback + */ Handle GitRepo::Open(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -165,6 +169,11 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} path + * @param {Boolean} is_bare + * @param {Repository} callback + */ Handle GitRepo::Init(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -242,6 +251,9 @@ void GitRepo::InitAfterWork(uv_work_t *req) { delete baton; } +/** + * @return {String} result + */ Handle GitRepo::Path(const Arguments& args) { HandleScope scope; @@ -255,6 +267,9 @@ Handle GitRepo::Path(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitRepo::Workdir(const Arguments& args) { HandleScope scope; @@ -268,6 +283,9 @@ Handle GitRepo::Workdir(const Arguments& args) { return scope.Close(to); } +/** + * @return {Odb} out + */ Handle GitRepo::Odb(const Arguments& args) { HandleScope scope; @@ -286,6 +304,9 @@ Handle GitRepo::Odb(const Arguments& args) { return scope.Close(to); } +/** + * @param {Index} callback + */ Handle GitRepo::openIndex(const Arguments& args) { HandleScope scope; @@ -349,6 +370,10 @@ void GitRepo::openIndexAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} id + * @param {Blob} callback + */ Handle GitRepo::GetBlob(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -420,6 +445,10 @@ void GitRepo::GetBlobAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} id + * @param {Commit} callback + */ Handle GitRepo::GetCommit(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -491,6 +520,17 @@ void GitRepo::GetCommitAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} update_ref + * @param {Signature} author + * @param {Signature} committer + * @param {String} message_encoding + * @param {String} message + * @param {Tree} tree + * @param {Number} parent_count + * @param {Array} parents + * @param {Oid} callback + */ Handle GitRepo::CreateCommit(const Arguments& args) { HandleScope scope; if (args.Length() == 1 || !args[1]->IsObject()) { @@ -633,6 +673,11 @@ void GitRepo::CreateCommitAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} id + * @param {Number} type + * @param {Object} callback + */ Handle GitRepo::GetObject(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -712,6 +757,10 @@ void GitRepo::GetObjectAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} name + * @param {Reference} callback + */ Handle GitRepo::GetReference(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -785,6 +834,12 @@ void GitRepo::GetReferenceAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} name + * @param {String} target + * @param {Number} force + * @return {Reference} out + */ Handle GitRepo::CreateSymbolicReference(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -822,6 +877,12 @@ Handle GitRepo::CreateSymbolicReference(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} name + * @param {Oid} id + * @param {Number} force + * @return {Reference} out + */ Handle GitRepo::CreateReference(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -857,6 +918,9 @@ Handle GitRepo::CreateReference(const Arguments& args) { return scope.Close(to); } +/** + * @return {RevWalk} out + */ Handle GitRepo::CreateRevWalk(const Arguments& args) { HandleScope scope; @@ -875,6 +939,10 @@ Handle GitRepo::CreateRevWalk(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} name + * @return {Submodule} submodule + */ Handle GitRepo::GetSubmodule(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -900,6 +968,12 @@ Handle GitRepo::GetSubmodule(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} url + * @param {String} path + * @param {Number} use_gitlink + * @return {Submodule} submodule + */ Handle GitRepo::AddSubmodule(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -937,6 +1011,10 @@ Handle GitRepo::AddSubmodule(const Arguments& args) { return scope.Close(to); } +/** + * @param {Oid} id + * @param {Tag} callback + */ Handle GitRepo::GetTag(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -1008,6 +1086,14 @@ void GitRepo::GetTagAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} tag_name + * @param {Object} target + * @param {Signature} tagger + * @param {String} message + * @param {Number} force + * @param {Oid} callback + */ Handle GitRepo::CreateTag(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -1116,6 +1202,12 @@ void GitRepo::CreateTagAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} tag_name + * @param {Object} target + * @param {Number} force + * @param {Oid} callback + */ Handle GitRepo::CreateLightweightTag(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -1206,6 +1298,10 @@ void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} id + * @param {Tree} callback + */ Handle GitRepo::GetTree(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -1277,6 +1373,8 @@ void GitRepo::GetTreeAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitRepo::ReloadSubmodules(const Arguments& args) { HandleScope scope; @@ -1338,6 +1436,9 @@ void GitRepo::ReloadSubmodulesAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} tag_name + */ Handle GitRepo::Delete(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -1409,6 +1510,10 @@ void GitRepo::DeleteAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Number} list_flags + * @param {Array} callback + */ Handle GitRepo::GetReferences(const Arguments& args) { HandleScope scope; diff --git a/src/revwalk.cc b/src/revwalk.cc index 7a66dd615..febbc5a3a 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -73,6 +73,8 @@ git_revwalk *GitRevWalk::GetValue() { } +/** + */ Handle GitRevWalk::Reset(const Arguments& args) { HandleScope scope; @@ -84,6 +86,9 @@ Handle GitRevWalk::Reset(const Arguments& args) { return Undefined(); } +/** + * @param {Oid} id + */ Handle GitRevWalk::Push(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -153,6 +158,9 @@ void GitRevWalk::PushAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} glob + */ Handle GitRevWalk::PushGlob(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -224,6 +232,8 @@ void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitRevWalk::PushHead(const Arguments& args) { HandleScope scope; @@ -285,6 +295,9 @@ void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} commit_id + */ Handle GitRevWalk::Hide(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -354,6 +367,9 @@ void GitRevWalk::HideAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} glob + */ Handle GitRevWalk::HideGlob(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -425,6 +441,8 @@ void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitRevWalk::HideHead(const Arguments& args) { HandleScope scope; @@ -486,6 +504,9 @@ void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} refname + */ Handle GitRevWalk::PushRef(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -557,6 +578,9 @@ void GitRevWalk::PushRefAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {String} refname + */ Handle GitRevWalk::HideRef(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -628,6 +652,9 @@ void GitRevWalk::HideRefAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Oid} callback + */ Handle GitRevWalk::Next(const Arguments& args) { HandleScope scope; @@ -692,6 +719,9 @@ void GitRevWalk::NextAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Number} sort_mode + */ Handle GitRevWalk::Sorting(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { diff --git a/src/signature.cc b/src/signature.cc index fbaa72439..5dca006db 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -66,6 +66,13 @@ git_signature *GitSignature::GetValue() { } +/** + * @param {String} name + * @param {String} email + * @param {Number} time + * @param {Number} offset + * @return {Signature} out + */ Handle GitSignature::Create(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -107,6 +114,11 @@ Handle GitSignature::Create(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} name + * @param {String} email + * @return {Signature} out + */ Handle GitSignature::Now(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { diff --git a/src/submodule.cc b/src/submodule.cc index af2732df3..68fca691c 100644 --- a/src/submodule.cc +++ b/src/submodule.cc @@ -76,6 +76,8 @@ git_submodule *GitSubmodule::GetValue() { } +/** + */ Handle GitSubmodule::AddFinalize(const Arguments& args) { HandleScope scope; @@ -137,6 +139,9 @@ void GitSubmodule::AddFinalizeAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Number} write_index + */ Handle GitSubmodule::AddToIndex(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { @@ -206,6 +211,8 @@ void GitSubmodule::AddToIndexAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitSubmodule::Save(const Arguments& args) { HandleScope scope; @@ -267,6 +274,9 @@ void GitSubmodule::SaveAfterWork(uv_work_t *req) { delete baton; } +/** + * @return {String} result + */ Handle GitSubmodule::Name(const Arguments& args) { HandleScope scope; @@ -280,6 +290,9 @@ Handle GitSubmodule::Name(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitSubmodule::Path(const Arguments& args) { HandleScope scope; @@ -293,6 +306,9 @@ Handle GitSubmodule::Path(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitSubmodule::Url(const Arguments& args) { HandleScope scope; @@ -306,6 +322,9 @@ Handle GitSubmodule::Url(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} url + */ Handle GitSubmodule::SetUrl(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -327,6 +346,9 @@ Handle GitSubmodule::SetUrl(const Arguments& args) { return Undefined(); } +/** + * @return {GitOid} result + */ Handle GitSubmodule::IndexId(const Arguments& args) { HandleScope scope; @@ -341,6 +363,9 @@ Handle GitSubmodule::IndexId(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitOid} result + */ Handle GitSubmodule::HeadId(const Arguments& args) { HandleScope scope; @@ -355,6 +380,9 @@ Handle GitSubmodule::HeadId(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} overwrite + */ Handle GitSubmodule::Init(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { @@ -424,6 +452,8 @@ void GitSubmodule::InitAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitSubmodule::Sync(const Arguments& args) { HandleScope scope; @@ -485,6 +515,9 @@ void GitSubmodule::SyncAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Repository} callback + */ Handle GitSubmodule::Open(const Arguments& args) { HandleScope scope; @@ -548,6 +581,8 @@ void GitSubmodule::OpenAfterWork(uv_work_t *req) { delete baton; } +/** + */ Handle GitSubmodule::Reload(const Arguments& args) { HandleScope scope; @@ -609,6 +644,9 @@ void GitSubmodule::ReloadAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Number} status + */ Handle GitSubmodule::Status(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { diff --git a/src/tag.cc b/src/tag.cc index 61444e3de..9415978a5 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -72,6 +72,9 @@ git_tag *GitTag::GetValue() { } +/** + * @return {GitOid} result + */ Handle GitTag::Oid(const Arguments& args) { HandleScope scope; @@ -86,6 +89,9 @@ Handle GitTag::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @param {Object} callback + */ Handle GitTag::GetTarget(const Arguments& args) { HandleScope scope; @@ -149,6 +155,9 @@ void GitTag::GetTargetAfterWork(uv_work_t *req) { delete baton; } +/** + * @return {GitOid} result + */ Handle GitTag::TargetId(const Arguments& args) { HandleScope scope; @@ -163,6 +172,9 @@ Handle GitTag::TargetId(const Arguments& args) { return scope.Close(to); } +/** + * @return {Int32} result + */ Handle GitTag::TargetType(const Arguments& args) { HandleScope scope; @@ -176,6 +188,9 @@ Handle GitTag::TargetType(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitTag::Name(const Arguments& args) { HandleScope scope; @@ -189,6 +204,9 @@ Handle GitTag::Name(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitSignature} result + */ Handle GitTag::Tagger(const Arguments& args) { HandleScope scope; @@ -203,6 +221,9 @@ Handle GitTag::Tagger(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ Handle GitTag::Message(const Arguments& args) { HandleScope scope; @@ -216,6 +237,10 @@ Handle GitTag::Message(const Arguments& args) { return scope.Close(to); } +/** + * @param {Tag} tag + * @return {Object} tag_target_out + */ Handle GitTag::Peel(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/src/threads.cc b/src/threads.cc index 785d853e3..03d3aee2a 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -26,6 +26,8 @@ void GitThreads::Initialize(Handle target) { } +/** + */ Handle GitThreads::Init(const Arguments& args) { HandleScope scope; @@ -39,6 +41,8 @@ Handle GitThreads::Init(const Arguments& args) { return Undefined(); } +/** + */ Handle GitThreads::Shutdown(const Arguments& args) { HandleScope scope; diff --git a/src/tree.cc b/src/tree.cc index 3083d7c6e..e4e15db10 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -75,6 +75,9 @@ git_tree *GitTree::GetValue() { } +/** + * @return {GitOid} result + */ Handle GitTree::Oid(const Arguments& args) { HandleScope scope; @@ -89,6 +92,9 @@ Handle GitTree::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @return {Uint32} result + */ Handle GitTree::Size(const Arguments& args) { HandleScope scope; @@ -102,6 +108,10 @@ Handle GitTree::Size(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} filename + * @return {GitTreeEntry} result + */ Handle GitTree::EntryByName(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -123,6 +133,10 @@ Handle GitTree::EntryByName(const Arguments& args) { return scope.Close(to); } +/** + * @param {Number} idx + * @return {GitTreeEntry} result + */ Handle GitTree::EntryByIndex(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { @@ -142,6 +156,10 @@ Handle GitTree::EntryByIndex(const Arguments& args) { return scope.Close(to); } +/** + * @param {Oid} oid + * @return {GitTreeEntry} result + */ Handle GitTree::EntryByOid(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -161,6 +179,10 @@ Handle GitTree::EntryByOid(const Arguments& args) { return scope.Close(to); } +/** + * @param {String} path + * @param {TreeEntry} callback + */ Handle GitTree::GetEntry(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { @@ -234,6 +256,12 @@ void GitTree::GetEntryAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Repository} repo + * @param {Tree} new_tree + * @param {DiffOptions} opts + * @param {DiffList} callback + */ Handle GitTree::DiffTree(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -322,6 +350,12 @@ void GitTree::DiffTreeAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Repository} repo + * @param {Index} index + * @param {DiffOptions} opts + * @param {DiffList} callback + */ Handle GitTree::DiffIndex(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { @@ -409,6 +443,11 @@ void GitTree::DiffIndexAfterWork(uv_work_t *req) { delete baton; } +/** + * @param {Repository} repo + * @param {DiffOptions} opts + * @param {DiffList} callback + */ Handle GitTree::DiffWorkDir(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 4583b4b45..6a276705d 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -68,6 +68,9 @@ git_tree_entry *GitTreeEntry::GetValue() { } +/** + * @return {String} result + */ Handle GitTreeEntry::Name(const Arguments& args) { HandleScope scope; @@ -81,6 +84,9 @@ Handle GitTreeEntry::Name(const Arguments& args) { return scope.Close(to); } +/** + * @return {GitOid} result + */ Handle GitTreeEntry::Oid(const Arguments& args) { HandleScope scope; @@ -95,6 +101,9 @@ Handle GitTreeEntry::Oid(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitTreeEntry::Type(const Arguments& args) { HandleScope scope; @@ -108,6 +117,9 @@ Handle GitTreeEntry::Type(const Arguments& args) { return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitTreeEntry::filemode(const Arguments& args) { HandleScope scope; @@ -121,6 +133,10 @@ Handle GitTreeEntry::filemode(const Arguments& args) { return scope.Close(to); } +/** + * @param {Repository} repo + * @param {Object} callback + */ Handle GitTreeEntry::GetObject(const Arguments& args) { HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { diff --git a/templates/asyncFunction.cc.ejs b/templates/asyncFunction.cc.ejs index b97729e3e..b6a875ae5 100644 --- a/templates/asyncFunction.cc.ejs +++ b/templates/asyncFunction.cc.ejs @@ -1,3 +1,6 @@ +/** +<% include doc.cc.ejs -%> + */ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; <% var jsArg; -%> diff --git a/templates/doc.cc.ejs b/templates/doc.cc.ejs new file mode 100644 index 000000000..44ca0979a --- /dev/null +++ b/templates/doc.cc.ejs @@ -0,0 +1,14 @@ +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn || arg.isSelf) continue; +-%> + * @param {<%- arg.jsClassName %>} <%- arg.name %> +<% } -%> +<% for (var r = 0; r < returns.length; r++) { -%> +<% if (functionInfo.isAsync) { -%> + * @param {<%- returns[r].jsClassName || returns[r].cppClassName %>} callback +<% } else { -%> + * @return {<%- returns[r].jsClassName || returns[r].cppClassName %>} <%- returns[r].name || 'result' %> +<% } -%> +<% } -%> diff --git a/templates/syncFunction.cc.ejs b/templates/syncFunction.cc.ejs index 14b81218f..1e18f8f13 100644 --- a/templates/syncFunction.cc.ejs +++ b/templates/syncFunction.cc.ejs @@ -1,3 +1,6 @@ +/** +<% include doc.cc.ejs -%> + */ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { HandleScope scope; <% include guardArguments.cc.ejs -%> From faefa7cb25645c58e8fe97c8d0644cc90014104b Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 15 Jul 2013 11:27:58 +0200 Subject: [PATCH 27/28] fixed broken test on linux: /etc/hosts -> /private/etc/hosts --- test/repo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repo.js b/test/repo.js index 2c63f3455..fa6bcd3dc 100644 --- a/test/repo.js +++ b/test/repo.js @@ -11,7 +11,7 @@ exports.open = function(test){ test.expect(2); // Test invalid repository - git.Repo.open('/etc/hosts', function(error, repository) { + git.Repo.open('/private/etc/hosts', function(error, repository) { test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); // Test valid repository From 25ae260b40fbd4484861a187af8a8619632ff839 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sun, 21 Jul 2013 19:04:26 +0200 Subject: [PATCH 28/28] bug fixes --- example/general.js | 2 +- include/reference.h | 3 ++- lib/reference.js | 17 ++++++++++++++++- src/reference.cc | 21 +++++++++++++++++++-- test/repo.js | 4 ++-- v0.18.0.json | 5 ++--- 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/example/general.js b/example/general.js index f01781bed..2a7baea94 100644 --- a/example/general.js +++ b/example/general.js @@ -308,7 +308,7 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { // references such as branches, tags and remote references (everything in // the .git/refs directory). - repo.getReferences(git.Reference.Type.Oid | git.Reference.Type.Symbolic, function(error, referenceNames) { + repo.getReferences(git.Reference.Type.All, function(error, referenceNames) { if (error) throw error; referenceNames.forEach(function(referenceName) { diff --git a/include/reference.h b/include/reference.h index 05ee69f66..9f215ea33 100644 --- a/include/reference.h +++ b/include/reference.h @@ -47,8 +47,9 @@ class GitReference : public ObjectWrap { Persistent callback; }; static Handle Oid(const Arguments& args); - static Handle Name(const Arguments& args); + static Handle SymbolicTarget(const Arguments& args); static Handle Type(const Arguments& args); + static Handle Name(const Arguments& args); static Handle Resolve(const Arguments& args); static void ResolveWork(uv_work_t* req); static void ResolveAfterWork(uv_work_t* req); diff --git a/lib/reference.js b/lib/reference.js index f690983db..33ebe85a7 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -3,7 +3,8 @@ var git = require('../'), Reference.Type = { Oid: 1, - Symbolic: 2 + Symbolic: 2, + All: 3 }; Reference.prototype.isOid = function() { @@ -13,3 +14,17 @@ Reference.prototype.isOid = function() { Reference.prototype.isSymbolic = function() { return this.type() == Reference.Type.Symbolic; }; + +var oldSymbolicTarget = Reference.prototype.symbolicTarget; +Reference.prototype.symbolicTarget = function() { + if (!this.isSymbolic()) throw this.name() + " is not symbolic"; + + return oldSymbolicTarget.call(this); +}; + +var oldOid = Reference.prototype.oid; +Reference.prototype.oid = function() { + if (!this.isOid()) throw this.name() + " is not oid"; + + return oldOid.call(this); +}; diff --git a/src/reference.cc b/src/reference.cc index b1789c131..d2bbfb059 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -35,8 +35,9 @@ void GitReference::Initialize(Handle target) { NODE_SET_METHOD(tpl, "oidForName", OidForName); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "symbolicTarget", SymbolicTarget); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "resolve", Resolve); NODE_SET_PROTOTYPE_METHOD(tpl, "setSymbolicTarget", SetSymbolicTarget); NODE_SET_PROTOTYPE_METHOD(tpl, "setTarget", setTarget); @@ -179,7 +180,7 @@ Handle GitReference::Oid(const Arguments& args) { /** * @return {String} result */ -Handle GitReference::Name(const Arguments& args) { +Handle GitReference::SymbolicTarget(const Arguments& args) { HandleScope scope; @@ -208,6 +209,22 @@ Handle GitReference::Type(const Arguments& args) { return scope.Close(to); } +/** + * @return {String} result + */ +Handle GitReference::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_reference_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + /** * @param {Reference} callback */ diff --git a/test/repo.js b/test/repo.js index fa6bcd3dc..886dee035 100644 --- a/test/repo.js +++ b/test/repo.js @@ -11,8 +11,8 @@ exports.open = function(test){ test.expect(2); // Test invalid repository - git.Repo.open('/private/etc/hosts', function(error, repository) { - test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); + git.Repo.open('../templates', function(error, repository) { + test.equals(error.message, "Could not find repository from '../templates'"); // Test valid repository git.Repo.open('../.git', function(error, repository) { diff --git a/v0.18.0.json b/v0.18.0.json index 2792cf530..0d99bd119 100644 --- a/v0.18.0.json +++ b/v0.18.0.json @@ -8123,8 +8123,8 @@ "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true, - "jsFunctionName": "name", - "cppFunctionName": "Name", + "jsFunctionName": "symbolicTarget", + "cppFunctionName": "SymbolicTarget", "return": { "cType": "const char *", "cppClassName": "String" @@ -8162,7 +8162,6 @@ "isSelf": true } ], - "ignore": true, "isAsync": false, "isConstructorMethod": false, "isPrototypeMethod": true,