From 67189221b38fe5ff32f2cdd997fcbeed646115d6 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Tue, 6 May 2014 22:03:04 -0400 Subject: [PATCH 1/3] Removed all generated C++. --- .gitignore | 9 + include/blob.h | 39 - include/branch.h | 46 - include/clone_options.h | 35 - include/commit.h | 46 - include/delta.h | 40 - include/diff.h | 111 -- include/diff_file.h | 40 - include/diff_find_options.h | 35 - include/diff_list.h | 40 - include/diff_options.h | 35 - include/diff_range.h | 39 - include/index.h | 199 ---- include/index_entry.h | 47 - include/index_time.h | 37 - include/object.h | 60 - include/odb.h | 92 -- include/odb_object.h | 39 - include/oid.h | 37 - include/patch.h | 42 - include/refdb.h | 35 - include/reference.h | 135 --- include/remote.h | 115 -- include/repo.h | 515 -------- include/revwalk.h | 233 ---- include/signature.h | 40 - include/submodule.h | 213 ---- include/tag.h | 64 - include/threads.h | 31 - include/time.h | 37 - include/tree.h | 138 --- include/tree_builder.h | 64 - include/tree_entry.h | 62 - src/base.cc | 0 src/blob.cc | 145 --- src/branch.cc | 535 --------- src/clone_options.cc | 62 - src/commit.cc | 315 ----- src/delta.cc | 137 --- src/diff.cc | 518 -------- src/diff_file.cc | 130 -- src/diff_find_options.cc | 62 - src/diff_list.cc | 225 ---- src/diff_options.cc | 62 - src/diff_range.cc | 110 -- src/functions/copy.cc | 6 - src/index.cc | 857 ------------- src/index_entry.cc | 229 ---- src/index_time.cc | 86 -- src/object.cc | 187 --- src/odb.cc | 594 --------- src/odb_object.cc | 143 --- src/oid.cc | 119 -- src/patch.cc | 325 ----- src/refdb.cc | 62 - src/reference.cc | 647 ---------- src/remote.cc | 592 --------- src/repo.cc | 2248 ----------------------------------- src/revwalk.cc | 753 ------------ src/signature.cc | 214 ---- src/submodule.cc | 743 ------------ src/tag.cc | 297 ----- src/threads.cc | 58 - src/time.cc | 86 -- src/tree.cc | 619 ---------- src/tree_builder.cc | 346 ------ src/tree_entry.cc | 222 ---- 67 files changed, 9 insertions(+), 14475 deletions(-) delete mode 100755 include/blob.h delete mode 100644 include/branch.h delete mode 100644 include/clone_options.h delete mode 100755 include/commit.h delete mode 100644 include/delta.h delete mode 100644 include/diff.h delete mode 100644 include/diff_file.h delete mode 100644 include/diff_find_options.h delete mode 100644 include/diff_list.h delete mode 100644 include/diff_options.h delete mode 100644 include/diff_range.h delete mode 100755 include/index.h delete mode 100644 include/index_entry.h delete mode 100644 include/index_time.h delete mode 100644 include/object.h delete mode 100644 include/odb.h delete mode 100644 include/odb_object.h delete mode 100755 include/oid.h delete mode 100644 include/patch.h delete mode 100644 include/refdb.h delete mode 100644 include/reference.h delete mode 100644 include/remote.h delete mode 100755 include/repo.h delete mode 100755 include/revwalk.h delete mode 100755 include/signature.h delete mode 100644 include/submodule.h delete mode 100755 include/tag.h delete mode 100755 include/threads.h delete mode 100644 include/time.h delete mode 100755 include/tree.h delete mode 100644 include/tree_builder.h delete mode 100755 include/tree_entry.h mode change 100755 => 100644 src/base.cc delete mode 100755 src/blob.cc delete mode 100644 src/branch.cc delete mode 100644 src/clone_options.cc delete mode 100755 src/commit.cc delete mode 100644 src/delta.cc delete mode 100644 src/diff.cc delete mode 100644 src/diff_file.cc delete mode 100644 src/diff_find_options.cc delete mode 100755 src/diff_list.cc delete mode 100644 src/diff_options.cc delete mode 100644 src/diff_range.cc delete mode 100644 src/index.cc delete mode 100644 src/index_entry.cc delete mode 100644 src/index_time.cc delete mode 100644 src/object.cc delete mode 100644 src/odb.cc delete mode 100644 src/odb_object.cc delete mode 100755 src/oid.cc delete mode 100644 src/patch.cc delete mode 100644 src/refdb.cc delete mode 100755 src/reference.cc delete mode 100644 src/remote.cc delete mode 100755 src/repo.cc delete mode 100755 src/revwalk.cc delete mode 100755 src/signature.cc delete mode 100644 src/submodule.cc delete mode 100644 src/tag.cc delete mode 100755 src/threads.cc delete mode 100644 src/time.cc delete mode 100755 src/tree.cc delete mode 100644 src/tree_builder.cc delete mode 100755 src/tree_entry.cc diff --git a/.gitignore b/.gitignore index be86e88da..c2338a9e3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,15 @@ /doc/* !/doc/Theme.css +/src/* +!/src/functions/copy.cc +!/src/wrapper.cc +!/src/base.cc + +/include/* +!/include/functions/copy.h +!/include/wrapper.h + /node_modules/ /vendor/libgit2/ /test/repos/ diff --git a/include/blob.h b/include/blob.h deleted file mode 100755 index 14c503678..000000000 --- a/include/blob.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITBLOB_H -#define GITBLOB_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitBlob : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_blob *GetValue(); - - static Handle New(void *raw); - - private: - GitBlob(git_blob *raw); - ~GitBlob(); - - static NAN_METHOD(New); - - static NAN_METHOD(Oid); - static NAN_METHOD(Content); - static NAN_METHOD(Size); - static NAN_METHOD(IsBinary); - git_blob *raw; -}; - -#endif diff --git a/include/branch.h b/include/branch.h deleted file mode 100644 index 02a1a71dd..000000000 --- a/include/branch.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef BRANCH_H -#define BRANCH_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Create); - static NAN_METHOD(Delete); - static NAN_METHOD(Foreach); - static NAN_METHOD(Move); - static NAN_METHOD(Lookup); - static NAN_METHOD(Name); - static NAN_METHOD(Upstream); - static NAN_METHOD(SetUpstream); - static NAN_METHOD(UpstreamName); - static NAN_METHOD(IsHead); - static NAN_METHOD(RemoteName); - git_branch *raw; -}; - -#endif diff --git a/include/clone_options.h b/include/clone_options.h deleted file mode 100644 index 6ba6b027c..000000000 --- a/include/clone_options.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITCLONEOPTIONS_H -#define GITCLONEOPTIONS_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitCloneOptions : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_clone_options *GetValue(); - - static Handle New(void *raw); - - private: - GitCloneOptions(git_clone_options *raw); - ~GitCloneOptions(); - - static NAN_METHOD(New); - - git_clone_options *raw; -}; - -#endif diff --git a/include/commit.h b/include/commit.h deleted file mode 100755 index efccd66dd..000000000 --- a/include/commit.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITCOMMIT_H -#define GITCOMMIT_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitCommit : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_commit *GetValue(); - - static Handle New(void *raw); - - private: - GitCommit(git_commit *raw); - ~GitCommit(); - - static NAN_METHOD(New); - - static NAN_METHOD(Oid); - static NAN_METHOD(MessageEncoding); - static NAN_METHOD(Message); - static NAN_METHOD(Time); - static NAN_METHOD(Offset); - static NAN_METHOD(Committer); - static NAN_METHOD(Author); - static NAN_METHOD(TreeId); - static NAN_METHOD(ParentCount); - static NAN_METHOD(ParentId); - static NAN_METHOD(NthGenAncestor); - git_commit *raw; -}; - -#endif diff --git a/include/delta.h b/include/delta.h deleted file mode 100644 index 5c8b7315b..000000000 --- a/include/delta.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITDELTA_H -#define GITDELTA_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(OldFile); - static NAN_METHOD(NewFile); - static NAN_METHOD(Status); - static NAN_METHOD(Similarity); - static NAN_METHOD(Flags); - git_diff_delta *raw; -}; - -#endif diff --git a/include/diff.h b/include/diff.h deleted file mode 100644 index fa88badfa..000000000 --- a/include/diff.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * 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 "nan.h" - -#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 NAN_METHOD(New); - - static NAN_METHOD(TreeToTree); - - 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 NAN_METHOD(TreeToIndex); - 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 NAN_METHOD(IndexToWorkdir); - 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 NAN_METHOD(TreeToWorkdir); - 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 NAN_METHOD(Merge); - static NAN_METHOD(FindSimilar); - static NAN_METHOD(StatusChar); - static NAN_METHOD(NumDeltas); - static NAN_METHOD(NumDeltasOfType); - static NAN_METHOD(GetPatch); - git_diff_list *raw; -}; - -#endif diff --git a/include/diff_file.h b/include/diff_file.h deleted file mode 100644 index e00eb5a6b..000000000 --- a/include/diff_file.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITDIFFFILE_H -#define GITDIFFFILE_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Oid); - static NAN_METHOD(Path); - static NAN_METHOD(Size); - static NAN_METHOD(Flags); - static NAN_METHOD(Mode); - git_diff_file *raw; -}; - -#endif diff --git a/include/diff_find_options.h b/include/diff_find_options.h deleted file mode 100644 index e5897cf82..000000000 --- a/include/diff_find_options.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITDIFFFINDOPTIONS_H -#define GITDIFFFINDOPTIONS_H - -#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 NAN_METHOD(New); - - git_diff_find_options *raw; -}; - -#endif diff --git a/include/diff_list.h b/include/diff_list.h deleted file mode 100644 index d8b4996bb..000000000 --- a/include/diff_list.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITDIFFLIST_H -#define GITDIFFLIST_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitDiffList : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_diff_list *GetValue(); - - static Handle New(void *raw); - - private: - GitDiffList(git_diff_list *raw); - ~GitDiffList(); - - static NAN_METHOD(New); - - static NAN_METHOD(Merge); - static NAN_METHOD(FindSimilar); - static NAN_METHOD(Size); - static NAN_METHOD(NumDeltasOfType); - static NAN_METHOD(Patch); - git_diff_list *raw; -}; - -#endif diff --git a/include/diff_options.h b/include/diff_options.h deleted file mode 100644 index 79f1580be..000000000 --- a/include/diff_options.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITDIFFOPTIONS_H -#define GITDIFFOPTIONS_H - -#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 NAN_METHOD(New); - - git_diff_options *raw; -}; - -#endif diff --git a/include/diff_range.h b/include/diff_range.h deleted file mode 100644 index 3d8942288..000000000 --- a/include/diff_range.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITDIFFRANGE_H -#define GITDIFFRANGE_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(OldStart); - static NAN_METHOD(OldLines); - static NAN_METHOD(NewStart); - static NAN_METHOD(NewLines); - git_diff_range *raw; -}; - -#endif diff --git a/include/index.h b/include/index.h deleted file mode 100755 index 1346136c2..000000000 --- a/include/index.h +++ /dev/null @@ -1,199 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITINDEX_H -#define GITINDEX_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitIndex : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_index *GetValue(); - - static Handle New(void *raw); - - private: - GitIndex(git_index *raw); - ~GitIndex(); - - static NAN_METHOD(New); - - - struct OpenBaton { - int error_code; - const git_error* error; - git_index * out; - const char * index_path; - }; - class OpenWorker : public NanAsyncWorker { - public: - OpenWorker( - OpenBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~OpenWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - OpenBaton *baton; - }; - static NAN_METHOD(Open); - - struct ReadBaton { - int error_code; - const git_error* error; - git_index * index; - }; - class ReadWorker : public NanAsyncWorker { - public: - ReadWorker( - ReadBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ReadWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ReadBaton *baton; - }; - static NAN_METHOD(Read); - - struct WriteBaton { - int error_code; - const git_error* error; - git_index * index; - }; - class WriteWorker : public NanAsyncWorker { - public: - WriteWorker( - WriteBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~WriteWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - WriteBaton *baton; - }; - static NAN_METHOD(Write); - - struct ReadTreeBaton { - int error_code; - const git_error* error; - git_index * index; - const git_tree * tree; - }; - class ReadTreeWorker : public NanAsyncWorker { - public: - ReadTreeWorker( - ReadTreeBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ReadTreeWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ReadTreeBaton *baton; - }; - static NAN_METHOD(ReadTree); - - struct WriteTreeBaton { - int error_code; - const git_error* error; - git_oid * out; - git_index * index; - }; - class WriteTreeWorker : public NanAsyncWorker { - public: - WriteTreeWorker( - WriteTreeBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~WriteTreeWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - WriteTreeBaton *baton; - }; - static NAN_METHOD(WriteTree); - static NAN_METHOD(Size); - static NAN_METHOD(Clear); - static NAN_METHOD(Entry); - static NAN_METHOD(Remove); - static NAN_METHOD(RemoveDirectory); - - struct AddBypathBaton { - int error_code; - const git_error* error; - git_index * index; - const char * path; - }; - class AddBypathWorker : public NanAsyncWorker { - public: - AddBypathWorker( - AddBypathBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~AddBypathWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - AddBypathBaton *baton; - }; - static NAN_METHOD(AddBypath); - static NAN_METHOD(RemoveBypath); - static NAN_METHOD(Find); - static NAN_METHOD(ConflictRemove); - static NAN_METHOD(ConflictCleanup); - static NAN_METHOD(HasConflicts); - - struct IndexToWorkdirBaton { - int error_code; - const git_error* error; - git_diff_list * diff; - git_repository * repo; - git_index * index; - const git_diff_options * opts; - }; - class IndexToWorkdirWorker : public NanAsyncWorker { - public: - IndexToWorkdirWorker( - IndexToWorkdirBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~IndexToWorkdirWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - IndexToWorkdirBaton *baton; - }; - static NAN_METHOD(IndexToWorkdir); - git_index *raw; -}; - -#endif diff --git a/include/index_entry.h b/include/index_entry.h deleted file mode 100644 index 47f6ef156..000000000 --- a/include/index_entry.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITINDEXENTRY_H -#define GITINDEXENTRY_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Ctime); - static NAN_METHOD(Mtime); - static NAN_METHOD(Dev); - static NAN_METHOD(Ino); - static NAN_METHOD(Mode); - static NAN_METHOD(Uid); - static NAN_METHOD(gid); - static NAN_METHOD(FileSize); - static NAN_METHOD(Oid); - static NAN_METHOD(Flags); - static NAN_METHOD(FlagsExtended); - static NAN_METHOD(Path); - git_index_entry *raw; -}; - -#endif diff --git a/include/index_time.h b/include/index_time.h deleted file mode 100644 index d60a7fce3..000000000 --- a/include/index_time.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITINDEXTIME_H -#define GITINDEXTIME_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Seconds); - static NAN_METHOD(Nanoseconds); - git_index_time *raw; -}; - -#endif diff --git a/include/object.h b/include/object.h deleted file mode 100644 index 69b4c1ecb..000000000 --- a/include/object.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITOBJECT_H -#define GITOBJECT_H - -#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(); - - static Handle New(void *raw); - - private: - GitObject(git_object *raw); - ~GitObject(); - - static NAN_METHOD(New); - - static NAN_METHOD(Oid); - static NAN_METHOD(Type); - - struct PeelBaton { - int error_code; - const git_error* error; - git_object * peeled; - const git_object * object; - git_otype target_type; - }; - class PeelWorker : public NanAsyncWorker { - public: - PeelWorker( - PeelBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~PeelWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - PeelBaton *baton; - }; - static NAN_METHOD(Peel); - git_object *raw; -}; - -#endif diff --git a/include/odb.h b/include/odb.h deleted file mode 100644 index 7fb77bbba..000000000 --- a/include/odb.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITODB_H -#define GITODB_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Create); - static NAN_METHOD(Open); - static NAN_METHOD(AddDiskAlternate); - - struct ReadBaton { - int error_code; - const git_error* error; - git_odb_object * out; - git_odb * db; - const git_oid * id; - }; - class ReadWorker : public NanAsyncWorker { - public: - ReadWorker( - ReadBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ReadWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ReadBaton *baton; - }; - static NAN_METHOD(Read); - static NAN_METHOD(ReadPrefix); - static NAN_METHOD(ReadHeader); - static NAN_METHOD(Exists); - static NAN_METHOD(Refresh); - - struct WriteBaton { - int error_code; - const git_error* error; - git_oid * out; - git_odb * odb; - const void * data; - size_t len; - git_otype type; - }; - class WriteWorker : public NanAsyncWorker { - public: - WriteWorker( - WriteBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~WriteWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - WriteBaton *baton; - }; - static NAN_METHOD(Write); - static NAN_METHOD(Hash); - static NAN_METHOD(Hashfile); - git_odb *raw; -}; - -#endif diff --git a/include/odb_object.h b/include/odb_object.h deleted file mode 100644 index f32508592..000000000 --- a/include/odb_object.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITODBOBJECT_H -#define GITODBOBJECT_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Data); - static NAN_METHOD(Size); - static NAN_METHOD(Type); - static NAN_METHOD(Oid); - git_odb_object *raw; -}; - -#endif diff --git a/include/oid.h b/include/oid.h deleted file mode 100755 index 4c0e0986e..000000000 --- a/include/oid.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITOID_H -#define GITOID_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitOid : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_oid *GetValue(); - - static Handle New(void *raw); - - private: - GitOid(git_oid *raw); - ~GitOid(); - - static NAN_METHOD(New); - - static NAN_METHOD(FromString); - static NAN_METHOD(Sha); - git_oid *raw; -}; - -#endif diff --git a/include/patch.h b/include/patch.h deleted file mode 100644 index ddd6de050..000000000 --- a/include/patch.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITPATCH_H -#define GITPATCH_H - -#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 NAN_METHOD(New); - - static NAN_METHOD(Delta); - static NAN_METHOD(Size); - static NAN_METHOD(Stats); - static NAN_METHOD(Hunk); - static NAN_METHOD(Lines); - static NAN_METHOD(Line); - static NAN_METHOD(ToString); - git_diff_patch *raw; -}; - -#endif diff --git a/include/refdb.h b/include/refdb.h deleted file mode 100644 index 8f928e208..000000000 --- a/include/refdb.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITREFDB_H -#define GITREFDB_H - -#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 NAN_METHOD(New); - - git_refdb *raw; -}; - -#endif diff --git a/include/reference.h b/include/reference.h deleted file mode 100644 index 13eaa5107..000000000 --- a/include/reference.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITREFERENCE_H -#define GITREFERENCE_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitReference : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_reference *GetValue(); - - static Handle New(void *raw); - - private: - GitReference(git_reference *raw); - ~GitReference(); - - static NAN_METHOD(New); - - - struct OidForNameBaton { - int error_code; - const git_error* error; - git_oid * out; - git_repository * repo; - const char * name; - }; - class OidForNameWorker : public NanAsyncWorker { - public: - OidForNameWorker( - OidForNameBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~OidForNameWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - OidForNameBaton *baton; - }; - static NAN_METHOD(OidForName); - static NAN_METHOD(Target); - static NAN_METHOD(SymbolicTarget); - static NAN_METHOD(Type); - static NAN_METHOD(Name); - - struct ResolveBaton { - int error_code; - const git_error* error; - git_reference * out; - const git_reference * ref; - }; - class ResolveWorker : public NanAsyncWorker { - public: - ResolveWorker( - ResolveBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ResolveWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ResolveBaton *baton; - }; - static NAN_METHOD(Resolve); - static NAN_METHOD(SetSymbolicTarget); - static NAN_METHOD(setTarget); - - struct RenameBaton { - int error_code; - const git_error* error; - git_reference * out; - git_reference * ref; - const char * new_name; - int force; - }; - class RenameWorker : public NanAsyncWorker { - public: - RenameWorker( - RenameBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~RenameWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - RenameBaton *baton; - }; - static NAN_METHOD(Rename); - - struct DeleteBaton { - int error_code; - const git_error* error; - git_reference * ref; - }; - class DeleteWorker : public NanAsyncWorker { - public: - DeleteWorker( - DeleteBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DeleteWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DeleteBaton *baton; - }; - static NAN_METHOD(Delete); - static NAN_METHOD(IsBranch); - static NAN_METHOD(IsRemote); - static NAN_METHOD(Peel); - static NAN_METHOD(IsValidName); - git_reference *raw; -}; - -#endif diff --git a/include/remote.h b/include/remote.h deleted file mode 100644 index 73af9487c..000000000 --- a/include/remote.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITREMOTE_H -#define GITREMOTE_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitRemote : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_remote *GetValue(); - - static Handle New(void *raw); - - private: - GitRemote(git_remote *raw); - ~GitRemote(); - - static NAN_METHOD(New); - - static NAN_METHOD(Name); - static NAN_METHOD(Url); - static NAN_METHOD(PushUrl); - static NAN_METHOD(SetUrl); - static NAN_METHOD(SetPushUrl); - - struct ConnectBaton { - int error_code; - const git_error* error; - git_remote * remote; - git_direction direction; - }; - class ConnectWorker : public NanAsyncWorker { - public: - ConnectWorker( - ConnectBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ConnectWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ConnectBaton *baton; - }; - static NAN_METHOD(Connect); - - struct DownloadBaton { - int error_code; - const git_error* error; - git_remote * remote; - git_transfer_progress_callback progress_cb; - void * payload; - }; - class DownloadWorker : public NanAsyncWorker { - public: - DownloadWorker( - DownloadBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DownloadWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DownloadBaton *baton; - }; - static NAN_METHOD(Download); - static NAN_METHOD(Connected); - static NAN_METHOD(Stop); - - struct DisconnectBaton { - int error_code; - const git_error* error; - git_remote * remote; - }; - class DisconnectWorker : public NanAsyncWorker { - public: - DisconnectWorker( - DisconnectBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DisconnectWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DisconnectBaton *baton; - }; - static NAN_METHOD(Disconnect); - static NAN_METHOD(UpdateTips); - static NAN_METHOD(ValidUrl); - static NAN_METHOD(SupportedUrl); - static NAN_METHOD(CheckCert); - static NAN_METHOD(UpdateFetchhead); - static NAN_METHOD(SetUpdateFetchhead); - static NAN_METHOD(IsValidName); - git_remote *raw; -}; - -#endif diff --git a/include/repo.h b/include/repo.h deleted file mode 100755 index a5a71e400..000000000 --- a/include/repo.h +++ /dev/null @@ -1,515 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITREPO_H -#define GITREPO_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitRepo : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_repository *GetValue(); - - static Handle New(void *raw); - - private: - GitRepo(git_repository *raw); - ~GitRepo(); - - static NAN_METHOD(New); - - - struct OpenBaton { - int error_code; - const git_error* error; - git_repository * out; - const char * path; - }; - class OpenWorker : public NanAsyncWorker { - public: - OpenWorker( - OpenBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~OpenWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - OpenBaton *baton; - }; - static NAN_METHOD(Open); - - struct InitBaton { - int error_code; - const git_error* error; - git_repository * out; - const char * path; - unsigned is_bare; - }; - class InitWorker : public NanAsyncWorker { - public: - InitWorker( - InitBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~InitWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - InitBaton *baton; - }; - static NAN_METHOD(Init); - static NAN_METHOD(Path); - static NAN_METHOD(Workdir); - static NAN_METHOD(Odb); - - struct openIndexBaton { - int error_code; - const git_error* error; - git_index * out; - git_repository * repo; - }; - class openIndexWorker : public NanAsyncWorker { - public: - openIndexWorker( - openIndexBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~openIndexWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - openIndexBaton *baton; - }; - static NAN_METHOD(openIndex); - - struct GetBlobBaton { - int error_code; - const git_error* error; - git_blob * blob; - git_repository * repo; - const git_oid * id; - }; - class GetBlobWorker : public NanAsyncWorker { - public: - GetBlobWorker( - GetBlobBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetBlobWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetBlobBaton *baton; - }; - static NAN_METHOD(GetBlob); - - struct GetCommitBaton { - int error_code; - const git_error* error; - git_commit * commit; - git_repository * repo; - const git_oid * id; - }; - class GetCommitWorker : public NanAsyncWorker { - public: - GetCommitWorker( - GetCommitBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetCommitWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetCommitBaton *baton; - }; - static NAN_METHOD(GetCommit); - - struct CreateCommitBaton { - int error_code; - const git_error* error; - git_oid * id; - git_repository * repo; - const char * update_ref; - const git_signature * author; - const git_signature * committer; - const char * message_encoding; - const char * message; - const git_tree * tree; - int parent_count; - const git_commit ** parents; - }; - class CreateCommitWorker : public NanAsyncWorker { - public: - CreateCommitWorker( - CreateCommitBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~CreateCommitWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - CreateCommitBaton *baton; - }; - static NAN_METHOD(CreateCommit); - - struct GetObjectBaton { - int error_code; - const git_error* error; - git_object * object; - git_repository * repo; - const git_oid * id; - git_otype type; - }; - class GetObjectWorker : public NanAsyncWorker { - public: - GetObjectWorker( - GetObjectBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetObjectWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetObjectBaton *baton; - }; - static NAN_METHOD(GetObject); - - struct GetReferenceBaton { - int error_code; - const git_error* error; - git_reference * out; - git_repository * repo; - const char * name; - }; - class GetReferenceWorker : public NanAsyncWorker { - public: - GetReferenceWorker( - GetReferenceBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetReferenceWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetReferenceBaton *baton; - }; - static NAN_METHOD(GetReference); - static NAN_METHOD(CreateSymbolicReference); - static NAN_METHOD(CreateReference); - - struct AddRemoteBaton { - int error_code; - const git_error* error; - git_remote * out; - git_repository * repo; - const char * name; - const char * url; - }; - class AddRemoteWorker : public NanAsyncWorker { - public: - AddRemoteWorker( - AddRemoteBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~AddRemoteWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - AddRemoteBaton *baton; - }; - static NAN_METHOD(AddRemote); - static NAN_METHOD(CreateRevWalk); - static NAN_METHOD(GetSubmodule); - static NAN_METHOD(AddSubmodule); - - struct GetTagBaton { - int error_code; - const git_error* error; - git_tag * out; - git_repository * repo; - const git_oid * id; - }; - class GetTagWorker : public NanAsyncWorker { - public: - GetTagWorker( - GetTagBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetTagWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetTagBaton *baton; - }; - static NAN_METHOD(GetTag); - - struct CreateTagBaton { - int error_code; - const git_error* error; - git_oid * oid; - git_repository * repo; - const char * tag_name; - const git_object * target; - const git_signature * tagger; - const char * message; - int force; - }; - class CreateTagWorker : public NanAsyncWorker { - public: - CreateTagWorker( - CreateTagBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~CreateTagWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - CreateTagBaton *baton; - }; - static NAN_METHOD(CreateTag); - - struct CreateLightweightTagBaton { - int error_code; - const git_error* error; - git_oid * oid; - git_repository * repo; - const char * tag_name; - const git_object * target; - int force; - }; - class CreateLightweightTagWorker : public NanAsyncWorker { - public: - CreateLightweightTagWorker( - CreateLightweightTagBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~CreateLightweightTagWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - CreateLightweightTagBaton *baton; - }; - static NAN_METHOD(CreateLightweightTag); - - struct GetTreeBaton { - int error_code; - const git_error* error; - git_tree * out; - git_repository * repo; - const git_oid * id; - }; - class GetTreeWorker : public NanAsyncWorker { - public: - GetTreeWorker( - GetTreeBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetTreeWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetTreeBaton *baton; - }; - static NAN_METHOD(GetTree); - - struct ReloadSubmodulesBaton { - int error_code; - const git_error* error; - git_repository * repo; - }; - class ReloadSubmodulesWorker : public NanAsyncWorker { - public: - ReloadSubmodulesWorker( - ReloadSubmodulesBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ReloadSubmodulesWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ReloadSubmodulesBaton *baton; - }; - static NAN_METHOD(ReloadSubmodules); - - struct DeleteBaton { - int error_code; - const git_error* error; - git_repository * repo; - const char * tag_name; - }; - class DeleteWorker : public NanAsyncWorker { - public: - DeleteWorker( - DeleteBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DeleteWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DeleteBaton *baton; - }; - static NAN_METHOD(Delete); - - struct GetReferencesBaton { - int error_code; - const git_error* error; - git_strarray * array; - git_repository * repo; - unsigned int list_flags; - }; - class GetReferencesWorker : public NanAsyncWorker { - public: - GetReferencesWorker( - GetReferencesBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetReferencesWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetReferencesBaton *baton; - }; - static NAN_METHOD(GetReferences); - - struct CreateBlobFromBufferBaton { - int error_code; - const git_error* error; - git_oid * oid; - git_repository * repo; - const void * buffer; - size_t len; - }; - class CreateBlobFromBufferWorker : public NanAsyncWorker { - public: - CreateBlobFromBufferWorker( - CreateBlobFromBufferBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~CreateBlobFromBufferWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - CreateBlobFromBufferBaton *baton; - }; - static NAN_METHOD(CreateBlobFromBuffer); - - struct CreateBlobFromFileBaton { - int error_code; - const git_error* error; - git_oid * id; - git_repository * repo; - const char * path; - }; - class CreateBlobFromFileWorker : public NanAsyncWorker { - public: - CreateBlobFromFileWorker( - CreateBlobFromFileBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~CreateBlobFromFileWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - CreateBlobFromFileBaton *baton; - }; - static NAN_METHOD(CreateBlobFromFile); - - struct GetRemotesBaton { - int error_code; - const git_error* error; - git_strarray * out; - git_repository * repo; - }; - class GetRemotesWorker : public NanAsyncWorker { - public: - GetRemotesWorker( - GetRemotesBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetRemotesWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetRemotesBaton *baton; - }; - static NAN_METHOD(GetRemotes); - - struct CloneBaton { - int error_code; - const git_error* error; - git_repository * out; - const char * url; - const char * local_path; - const git_clone_options * options; - }; - class CloneWorker : public NanAsyncWorker { - public: - CloneWorker( - CloneBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~CloneWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - CloneBaton *baton; - }; - static NAN_METHOD(Clone); - static NAN_METHOD(GetRemote); - git_repository *raw; -}; - -#endif diff --git a/include/revwalk.h b/include/revwalk.h deleted file mode 100755 index 29866e43f..000000000 --- a/include/revwalk.h +++ /dev/null @@ -1,233 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITREVWALK_H -#define GITREVWALK_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitRevWalk : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_revwalk *GetValue(); - - static Handle New(void *raw); - - private: - GitRevWalk(git_revwalk *raw); - ~GitRevWalk(); - - static NAN_METHOD(New); - - static NAN_METHOD(Reset); - - struct PushBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - const git_oid * id; - }; - class PushWorker : public NanAsyncWorker { - public: - PushWorker( - PushBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~PushWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - PushBaton *baton; - }; - static NAN_METHOD(Push); - - struct PushGlobBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - const char * glob; - }; - class PushGlobWorker : public NanAsyncWorker { - public: - PushGlobWorker( - PushGlobBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~PushGlobWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - PushGlobBaton *baton; - }; - static NAN_METHOD(PushGlob); - - struct PushHeadBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - }; - class PushHeadWorker : public NanAsyncWorker { - public: - PushHeadWorker( - PushHeadBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~PushHeadWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - PushHeadBaton *baton; - }; - static NAN_METHOD(PushHead); - - struct HideBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - const git_oid * commit_id; - }; - class HideWorker : public NanAsyncWorker { - public: - HideWorker( - HideBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~HideWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - HideBaton *baton; - }; - static NAN_METHOD(Hide); - - struct HideGlobBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - const char * glob; - }; - class HideGlobWorker : public NanAsyncWorker { - public: - HideGlobWorker( - HideGlobBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~HideGlobWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - HideGlobBaton *baton; - }; - static NAN_METHOD(HideGlob); - - struct HideHeadBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - }; - class HideHeadWorker : public NanAsyncWorker { - public: - HideHeadWorker( - HideHeadBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~HideHeadWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - HideHeadBaton *baton; - }; - static NAN_METHOD(HideHead); - - struct PushRefBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - const char * refname; - }; - class PushRefWorker : public NanAsyncWorker { - public: - PushRefWorker( - PushRefBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~PushRefWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - PushRefBaton *baton; - }; - static NAN_METHOD(PushRef); - - struct HideRefBaton { - int error_code; - const git_error* error; - git_revwalk * walk; - const char * refname; - }; - class HideRefWorker : public NanAsyncWorker { - public: - HideRefWorker( - HideRefBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~HideRefWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - HideRefBaton *baton; - }; - static NAN_METHOD(HideRef); - - struct NextBaton { - int error_code; - const git_error* error; - git_oid * out; - git_revwalk * walk; - }; - class NextWorker : public NanAsyncWorker { - public: - NextWorker( - NextBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~NextWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - NextBaton *baton; - }; - static NAN_METHOD(Next); - static NAN_METHOD(Sorting); - git_revwalk *raw; -}; - -#endif diff --git a/include/signature.h b/include/signature.h deleted file mode 100755 index e6e3c58c7..000000000 --- a/include/signature.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITSIGNATURE_H -#define GITSIGNATURE_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitSignature : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_signature *GetValue(); - - static Handle New(void *raw); - - private: - GitSignature(git_signature *raw); - ~GitSignature(); - - static NAN_METHOD(New); - - static NAN_METHOD(Name); - static NAN_METHOD(Email); - static NAN_METHOD(Time); - static NAN_METHOD(Create); - static NAN_METHOD(Now); - git_signature *raw; -}; - -#endif diff --git a/include/submodule.h b/include/submodule.h deleted file mode 100644 index dfd25ed3e..000000000 --- a/include/submodule.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITSUBMODULE_H -#define GITSUBMODULE_H - -#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 NAN_METHOD(New); - - - struct AddFinalizeBaton { - int error_code; - const git_error* error; - git_submodule * submodule; - }; - class AddFinalizeWorker : public NanAsyncWorker { - public: - AddFinalizeWorker( - AddFinalizeBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~AddFinalizeWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - AddFinalizeBaton *baton; - }; - static NAN_METHOD(AddFinalize); - - struct AddToIndexBaton { - int error_code; - const git_error* error; - git_submodule * submodule; - int write_index; - }; - class AddToIndexWorker : public NanAsyncWorker { - public: - AddToIndexWorker( - AddToIndexBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~AddToIndexWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - AddToIndexBaton *baton; - }; - static NAN_METHOD(AddToIndex); - - struct SaveBaton { - int error_code; - const git_error* error; - git_submodule * submodule; - }; - class SaveWorker : public NanAsyncWorker { - public: - SaveWorker( - SaveBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~SaveWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - SaveBaton *baton; - }; - static NAN_METHOD(Save); - static NAN_METHOD(Name); - static NAN_METHOD(Path); - static NAN_METHOD(Url); - static NAN_METHOD(SetUrl); - static NAN_METHOD(IndexId); - static NAN_METHOD(HeadId); - - struct InitBaton { - int error_code; - const git_error* error; - git_submodule * submodule; - int overwrite; - }; - class InitWorker : public NanAsyncWorker { - public: - InitWorker( - InitBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~InitWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - InitBaton *baton; - }; - static NAN_METHOD(Init); - - struct SyncBaton { - int error_code; - const git_error* error; - git_submodule * submodule; - }; - class SyncWorker : public NanAsyncWorker { - public: - SyncWorker( - SyncBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~SyncWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - SyncBaton *baton; - }; - static NAN_METHOD(Sync); - - struct OpenBaton { - int error_code; - const git_error* error; - git_repository * repo; - git_submodule * submodule; - }; - class OpenWorker : public NanAsyncWorker { - public: - OpenWorker( - OpenBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~OpenWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - OpenBaton *baton; - }; - static NAN_METHOD(Open); - - struct ReloadBaton { - int error_code; - const git_error* error; - git_submodule * submodule; - }; - class ReloadWorker : public NanAsyncWorker { - public: - ReloadWorker( - ReloadBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~ReloadWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - ReloadBaton *baton; - }; - static NAN_METHOD(Reload); - - struct StatusBaton { - int error_code; - const git_error* error; - unsigned int * status; - git_submodule * submodule; - }; - class StatusWorker : public NanAsyncWorker { - public: - StatusWorker( - StatusBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~StatusWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - StatusBaton *baton; - }; - static NAN_METHOD(Status); - git_submodule *raw; -}; - -#endif diff --git a/include/tag.h b/include/tag.h deleted file mode 100755 index abbada0ed..000000000 --- a/include/tag.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITTAG_H -#define GITTAG_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitTag : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_tag *GetValue(); - - static Handle New(void *raw); - - private: - GitTag(git_tag *raw); - ~GitTag(); - - static NAN_METHOD(New); - - static NAN_METHOD(Oid); - - struct GetTargetBaton { - int error_code; - const git_error* error; - git_object * target_out; - const git_tag * tag; - }; - class GetTargetWorker : public NanAsyncWorker { - public: - GetTargetWorker( - GetTargetBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetTargetWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetTargetBaton *baton; - }; - static NAN_METHOD(GetTarget); - static NAN_METHOD(TargetId); - static NAN_METHOD(TargetType); - static NAN_METHOD(Name); - static NAN_METHOD(Tagger); - static NAN_METHOD(Message); - static NAN_METHOD(Peel); - git_tag *raw; -}; - -#endif diff --git a/include/threads.h b/include/threads.h deleted file mode 100755 index e66c9d06c..000000000 --- a/include/threads.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITTHREADS_H -#define GITTHREADS_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitThreads : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - - private: - - static NAN_METHOD(New); - - static NAN_METHOD(Init); - static NAN_METHOD(Shutdown); -}; - -#endif diff --git a/include/time.h b/include/time.h deleted file mode 100644 index 743c13ee7..000000000 --- a/include/time.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITTIME_H -#define GITTIME_H - -#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(); - - static Handle New(void *raw); - - private: - GitTime(git_time *raw); - ~GitTime(); - - static NAN_METHOD(New); - - static NAN_METHOD(Time); - static NAN_METHOD(Offset); - git_time *raw; -}; - -#endif diff --git a/include/tree.h b/include/tree.h deleted file mode 100755 index b926406e2..000000000 --- a/include/tree.h +++ /dev/null @@ -1,138 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITTREE_H -#define GITTREE_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitTree : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_tree *GetValue(); - - static Handle New(void *raw); - - private: - GitTree(git_tree *raw); - ~GitTree(); - - static NAN_METHOD(New); - - static NAN_METHOD(Oid); - static NAN_METHOD(Size); - static NAN_METHOD(EntryByName); - static NAN_METHOD(EntryByIndex); - static NAN_METHOD(EntryByOid); - - struct GetEntryBaton { - int error_code; - const git_error* error; - git_tree_entry * out; - git_tree * root; - const char * path; - }; - class GetEntryWorker : public NanAsyncWorker { - public: - GetEntryWorker( - GetEntryBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetEntryWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetEntryBaton *baton; - }; - static NAN_METHOD(GetEntry); - static NAN_METHOD(Builder); - - struct DiffTreeBaton { - int error_code; - const git_error* error; - git_diff_list * diff; - git_repository * repo; - git_tree * old_tree; - git_tree * new_tree; - const git_diff_options * opts; - }; - class DiffTreeWorker : public NanAsyncWorker { - public: - DiffTreeWorker( - DiffTreeBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DiffTreeWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DiffTreeBaton *baton; - }; - static NAN_METHOD(DiffTree); - - struct DiffIndexBaton { - int error_code; - const git_error* error; - git_diff_list * diff; - git_repository * repo; - git_tree * old_tree; - git_index * index; - const git_diff_options * opts; - }; - class DiffIndexWorker : public NanAsyncWorker { - public: - DiffIndexWorker( - DiffIndexBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DiffIndexWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DiffIndexBaton *baton; - }; - static NAN_METHOD(DiffIndex); - - struct DiffWorkDirBaton { - int error_code; - const git_error* error; - git_diff_list * diff; - git_repository * repo; - git_tree * old_tree; - const git_diff_options * opts; - }; - class DiffWorkDirWorker : public NanAsyncWorker { - public: - DiffWorkDirWorker( - DiffWorkDirBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~DiffWorkDirWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - DiffWorkDirBaton *baton; - }; - static NAN_METHOD(DiffWorkDir); - git_tree *raw; -}; - -#endif diff --git a/include/tree_builder.h b/include/tree_builder.h deleted file mode 100644 index 093365171..000000000 --- a/include/tree_builder.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITTREEBUILDER_H -#define GITTREEBUILDER_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitTreeBuilder : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_treebuilder *GetValue(); - - static Handle New(void *raw); - - private: - GitTreeBuilder(git_treebuilder *raw); - ~GitTreeBuilder(); - - static NAN_METHOD(New); - - static NAN_METHOD(Create); - static NAN_METHOD(Clear); - static NAN_METHOD(Size); - static NAN_METHOD(Get); - static NAN_METHOD(Insert); - static NAN_METHOD(GitTreebuilderRemove); - - struct WriteBaton { - int error_code; - const git_error* error; - git_oid * id; - git_repository * repo; - git_treebuilder * bld; - }; - class WriteWorker : public NanAsyncWorker { - public: - WriteWorker( - WriteBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~WriteWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - WriteBaton *baton; - }; - static NAN_METHOD(Write); - git_treebuilder *raw; -}; - -#endif diff --git a/include/tree_entry.h b/include/tree_entry.h deleted file mode 100755 index 126409453..000000000 --- a/include/tree_entry.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ - -#ifndef GITTREEENTRY_H -#define GITTREEENTRY_H - -#include -#include - -#include "git2.h" - -using namespace node; -using namespace v8; - -class GitTreeEntry : public ObjectWrap { - public: - - static Persistent constructor_template; - static void Initialize (Handle target); - - git_tree_entry *GetValue(); - - static Handle New(void *raw); - - private: - GitTreeEntry(git_tree_entry *raw); - ~GitTreeEntry(); - - static NAN_METHOD(New); - - static NAN_METHOD(Name); - static NAN_METHOD(Oid); - static NAN_METHOD(Type); - static NAN_METHOD(filemode); - - struct GetObjectBaton { - int error_code; - const git_error* error; - git_object * object_out; - git_repository * repo; - const git_tree_entry * entry; - }; - class GetObjectWorker : public NanAsyncWorker { - public: - GetObjectWorker( - GetObjectBaton *_baton, - NanCallback *callback - ) : NanAsyncWorker(callback) - , baton(_baton) {}; - ~GetObjectWorker() {}; - void Execute(); - void HandleOKCallback(); - - private: - GetObjectBaton *baton; - }; - static NAN_METHOD(GetObject); - git_tree_entry *raw; -}; - -#endif diff --git a/src/base.cc b/src/base.cc old mode 100755 new mode 100644 diff --git a/src/blob.cc b/src/blob.cc deleted file mode 100755 index 3ffbbb9ce..000000000 --- a/src/blob.cc +++ /dev/null @@ -1,145 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/blob.h" -#include "../include/repo.h" -#include "../include/oid.h" -#include "../include/wrapper.h" -#include "node_buffer.h" - -using namespace v8; -using namespace node; - -GitBlob::GitBlob(git_blob *raw) { - this->raw = raw; -} - -GitBlob::~GitBlob() { - git_blob_free(this->raw); -} - -void GitBlob::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Blob")); - - NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "content", Content); - NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); - NODE_SET_PROTOTYPE_METHOD(tpl, "isBinary", IsBinary); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Blob"), _constructor_template); -} - -NAN_METHOD(GitBlob::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_blob is required."); - } - GitBlob* object = new GitBlob(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitBlob::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitBlob::constructor_template)->NewInstance(1, argv)); -} - -git_blob *GitBlob::GetValue() { - return this->raw; -} - - -/** - * @return {Oid} result - */ -NAN_METHOD(GitBlob::Oid) { - NanScope(); - - - const git_oid * result = git_blob_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Wrapper} result - */ -NAN_METHOD(GitBlob::Content) { - NanScope(); - - - const void * result = git_blob_rawcontent( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - to = Wrapper::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitBlob::Size) { - NanScope(); - - - git_off_t result = git_blob_rawsize( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Boolean} result - */ -NAN_METHOD(GitBlob::IsBinary) { - NanScope(); - - - int result = git_blob_is_binary( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -Persistent GitBlob::constructor_template; diff --git a/src/branch.cc b/src/branch.cc deleted file mode 100644 index 5e9a3b340..000000000 --- a/src/branch.cc +++ /dev/null @@ -1,535 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/branch.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Branch"), _constructor_template); -} - -NAN_METHOD(Branch::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_branch is required."); - } - Branch* object = new Branch(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle Branch::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(Branch::constructor_template)->NewInstance(1, argv)); -} - -git_branch *Branch::GetValue() { - return this->raw; -} - - -/** - * @param {Repository} repo - * @param {String} branch_name - * @param {Commit} target - * @param {Number} force - * @return {Reference} out - */ -NAN_METHOD(Branch::Create) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String branch_name is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("Commit target is required."); - } - if (args.Length() == 3 || !args[3]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - git_reference * out = 0; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - const char * from_branch_name; - String::Utf8Value branch_name(args[1]->ToString()); - from_branch_name = strdup(*branch_name); - const git_commit * from_target; - from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - int from_force; - from_force = (int) args[3]->ToInt32()->Value(); - - int result = git_branch_create( - &out - , from_repo - , from_branch_name - , from_target - , from_force - ); - free((void *)from_branch_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Reference} branch - */ -NAN_METHOD(Branch::Delete) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Reference branch is required."); - } - - git_reference * from_branch; - from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_branch_delete( - from_branch - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {Repository} repo - * @param {Number} list_flags - * @param {BranchForeachCb} branch_cb - * @param {void} payload - */ -NAN_METHOD(Branch::Foreach) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError("Number list_flags is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("BranchForeachCb branch_cb is required."); - } - if (args.Length() == 3 || !args[3]->IsObject()) { - return NanThrowError("void payload is required."); - } - - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - unsigned int from_list_flags; - from_list_flags = (unsigned int) args[1]->ToUint32()->Value(); - git_branch_foreach_cb from_branch_cb; - from_branch_cb = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - void * from_payload; - from_payload = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); - - int result = git_branch_foreach( - from_repo - , from_list_flags - , from_branch_cb - , from_payload - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {Reference} branch - * @param {String} new_branch_name - * @param {Number} force - * @return {Reference} out - */ -NAN_METHOD(Branch::Move) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Reference branch is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String new_branch_name is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - git_reference * out = 0; - git_reference * from_branch; - from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - const char * from_new_branch_name; - String::Utf8Value new_branch_name(args[1]->ToString()); - from_new_branch_name = strdup(*new_branch_name); - int from_force; - from_force = (int) args[2]->ToInt32()->Value(); - - int result = git_branch_move( - &out - , from_branch - , from_new_branch_name - , from_force - ); - free((void *)from_new_branch_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Repository} repo - * @param {String} branch_name - * @param {BranchT} branch_type - * @return {Reference} out - */ -NAN_METHOD(Branch::Lookup) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String branch_name is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("BranchT branch_type is required."); - } - - git_reference * out = 0; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - const char * from_branch_name; - String::Utf8Value branch_name(args[1]->ToString()); - from_branch_name = strdup(*branch_name); - git_branch_t from_branch_type; - from_branch_type = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - - int result = git_branch_lookup( - &out - , from_repo - , from_branch_name - , from_branch_type - ); - free((void *)from_branch_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Reference} ref - * @return {String} out - */ -NAN_METHOD(Branch::Name) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Reference ref is required."); - } - - const char * out = 0; - git_reference * from_ref; - from_ref = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_branch_name( - &out - , from_ref - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - to = NanNew(out); - NanReturnValue(to); -} - -/** - * @param {Reference} branch - * @return {Reference} out - */ -NAN_METHOD(Branch::Upstream) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Reference branch is required."); - } - - git_reference * out = 0; - git_reference * from_branch; - from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_branch_upstream( - &out - , from_branch - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Reference} branch - * @param {String} upstream_name - */ -NAN_METHOD(Branch::SetUpstream) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Reference branch is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String upstream_name is required."); - } - - git_reference * from_branch; - from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - const char * from_upstream_name; - String::Utf8Value upstream_name(args[1]->ToString()); - from_upstream_name = strdup(*upstream_name); - - int result = git_branch_set_upstream( - from_branch - , from_upstream_name - ); - free((void *)from_upstream_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} tracking_branch_name_out - * @param {Number} buffer_size - * @param {Repository} repo - * @param {String} canonical_branch_name - */ -NAN_METHOD(Branch::UpstreamName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String tracking_branch_name_out is required."); - } - if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError("Number buffer_size is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 3 || !args[3]->IsString()) { - return NanThrowError("String canonical_branch_name is required."); - } - - char * from_tracking_branch_name_out; - String::Utf8Value tracking_branch_name_out(args[0]->ToString()); - from_tracking_branch_name_out = strdup(*tracking_branch_name_out); - size_t from_buffer_size; - from_buffer_size = (size_t) args[1]->ToUint32()->Value(); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - const char * from_canonical_branch_name; - String::Utf8Value canonical_branch_name(args[3]->ToString()); - from_canonical_branch_name = strdup(*canonical_branch_name); - - int result = git_branch_upstream_name( - from_tracking_branch_name_out - , from_buffer_size - , from_repo - , from_canonical_branch_name - ); - free((void *)from_tracking_branch_name_out); - free((void *)from_canonical_branch_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {Reference} branch - */ -NAN_METHOD(Branch::IsHead) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Reference branch is required."); - } - - git_reference * from_branch; - from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_branch_is_head( - from_branch - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} remote_name_out - * @param {Number} buffer_size - * @param {Repository} repo - * @param {String} canonical_branch_name - */ -NAN_METHOD(Branch::RemoteName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String remote_name_out is required."); - } - if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError("Number buffer_size is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 3 || !args[3]->IsString()) { - return NanThrowError("String canonical_branch_name is required."); - } - - char * from_remote_name_out; - String::Utf8Value remote_name_out(args[0]->ToString()); - from_remote_name_out = strdup(*remote_name_out); - size_t from_buffer_size; - from_buffer_size = (size_t) args[1]->ToUint32()->Value(); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - const char * from_canonical_branch_name; - String::Utf8Value canonical_branch_name(args[3]->ToString()); - from_canonical_branch_name = strdup(*canonical_branch_name); - - int result = git_branch_remote_name( - from_remote_name_out - , from_buffer_size - , from_repo - , from_canonical_branch_name - ); - free((void *)from_remote_name_out); - free((void *)from_canonical_branch_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -Persistent Branch::constructor_template; diff --git a/src/clone_options.cc b/src/clone_options.cc deleted file mode 100644 index c6812d369..000000000 --- a/src/clone_options.cc +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/clone_options.h" - -using namespace v8; -using namespace node; - -GitCloneOptions::GitCloneOptions(git_clone_options *raw) { - this->raw = raw; -} - -GitCloneOptions::~GitCloneOptions() { - free(this->raw); -} - -void GitCloneOptions::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("CloneOptions")); - - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("CloneOptions"), _constructor_template); -} - -NAN_METHOD(GitCloneOptions::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_clone_options is required."); - } - GitCloneOptions* object = new GitCloneOptions(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitCloneOptions::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitCloneOptions::constructor_template)->NewInstance(1, argv)); -} - -git_clone_options *GitCloneOptions::GetValue() { - return this->raw; -} - - -Persistent GitCloneOptions::constructor_template; diff --git a/src/commit.cc b/src/commit.cc deleted file mode 100755 index 0ccd639b3..000000000 --- a/src/commit.cc +++ /dev/null @@ -1,315 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/commit.h" -#include "../include/oid.h" -#include "../include/repo.h" -#include "../include/signature.h" -#include "../include/tree.h" - -using namespace v8; -using namespace node; - -GitCommit::GitCommit(git_commit *raw) { - this->raw = raw; -} - -GitCommit::~GitCommit() { - git_commit_free(this->raw); -} - -void GitCommit::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Commit")); - - 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, "committer", Committer); - 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, "parentId", ParentId); - NODE_SET_PROTOTYPE_METHOD(tpl, "nthGenAncestor", NthGenAncestor); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Commit"), _constructor_template); -} - -NAN_METHOD(GitCommit::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_commit is required."); - } - GitCommit* object = new GitCommit(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitCommit::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitCommit::constructor_template)->NewInstance(1, argv)); -} - -git_commit *GitCommit::GetValue() { - return this->raw; -} - - -/** - * @return {Oid} result - */ -NAN_METHOD(GitCommit::Oid) { - NanScope(); - - - const git_oid * result = git_commit_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitCommit::MessageEncoding) { - NanScope(); - - - const char * result = git_commit_message_encoding( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitCommit::Message) { - NanScope(); - - - const char * result = git_commit_message( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitCommit::Time) { - NanScope(); - - - git_time_t result = git_commit_time( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitCommit::Offset) { - NanScope(); - - - int result = git_commit_time_offset( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Signature} result - */ -NAN_METHOD(GitCommit::Committer) { - NanScope(); - - - const git_signature * result = git_commit_committer( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_signature * )git_signature_dup(result); - } - if (result != NULL) { - to = GitSignature::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Signature} result - */ -NAN_METHOD(GitCommit::Author) { - NanScope(); - - - const git_signature * result = git_commit_author( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_signature * )git_signature_dup(result); - } - if (result != NULL) { - to = GitSignature::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitCommit::TreeId) { - NanScope(); - - - const git_oid * result = git_commit_tree_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitCommit::ParentCount) { - NanScope(); - - - unsigned int result = git_commit_parentcount( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @param {Number} n - * @return {Oid} result - */ -NAN_METHOD(GitCommit::ParentId) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number n is required."); - } - - unsigned int from_n; - from_n = (unsigned int) args[0]->ToUint32()->Value(); - - const git_oid * result = git_commit_parent_id( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_n - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Number} n - * @return {Commit} ancestor - */ -NAN_METHOD(GitCommit::NthGenAncestor) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number n is required."); - } - - git_commit * ancestor = 0; - unsigned int from_n; - from_n = (unsigned int) args[0]->ToUint32()->Value(); - - int result = git_commit_nth_gen_ancestor( - &ancestor - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_n - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (ancestor != NULL) { - to = GitCommit::New((void *)ancestor); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -Persistent GitCommit::constructor_template; diff --git a/src/delta.cc b/src/delta.cc deleted file mode 100644 index 1428032c2..000000000 --- a/src/delta.cc +++ /dev/null @@ -1,137 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/delta.h" -#include "../include/diff_file.h" - -using namespace v8; -using namespace node; - -GitDelta::GitDelta(git_diff_delta *raw) { - this->raw = raw; -} - -GitDelta::~GitDelta() { - free(this->raw); -} - -void GitDelta::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Delta"), _constructor_template); -} - -NAN_METHOD(GitDelta::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_delta is required."); - } - GitDelta* object = new GitDelta(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitDelta::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitDelta::constructor_template)->NewInstance(1, argv)); -} - -git_diff_delta *GitDelta::GetValue() { - return this->raw; -} - - -NAN_METHOD(GitDelta::OldFile) { - NanScope(); - Handle to; - - git_diff_file *old_file = - &ObjectWrap::Unwrap(args.This())->GetValue()->old_file; - - if (old_file != NULL) { - old_file = (git_diff_file *)git_diff_file_dup(old_file); - } - if (old_file != NULL) { - to = GitDiffFile::New((void *)old_file); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitDelta::NewFile) { - NanScope(); - Handle to; - - git_diff_file *new_file = - &ObjectWrap::Unwrap(args.This())->GetValue()->new_file; - - if (new_file != NULL) { - new_file = (git_diff_file *)git_diff_file_dup(new_file); - } - if (new_file != NULL) { - to = GitDiffFile::New((void *)new_file); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitDelta::Status) { - NanScope(); - Handle to; - - git_delta_t status = - ObjectWrap::Unwrap(args.This())->GetValue()->status; - - to = NanNew(status); - NanReturnValue(to); -} - -NAN_METHOD(GitDelta::Similarity) { - NanScope(); - Handle to; - - uint32_t similarity = - ObjectWrap::Unwrap(args.This())->GetValue()->similarity; - - to = NanNew(similarity); - NanReturnValue(to); -} - -NAN_METHOD(GitDelta::Flags) { - NanScope(); - Handle to; - - uint32_t flags = - ObjectWrap::Unwrap(args.This())->GetValue()->flags; - - to = NanNew(flags); - NanReturnValue(to); -} - -Persistent GitDelta::constructor_template; diff --git a/src/diff.cc b/src/diff.cc deleted file mode 100644 index 70fad85b6..000000000 --- a/src/diff.cc +++ /dev/null @@ -1,518 +0,0 @@ -/** - * 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) { - NanScope(); - - Local tpl = FunctionTemplate::New(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("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); - - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Diff"), tpl->GetFunction()); -} - -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 deleted file mode 100644 index b19711520..000000000 --- a/src/diff_file.cc +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/diff_file.h" -#include "../include/oid.h" - -using namespace v8; -using namespace node; - -GitDiffFile::GitDiffFile(git_diff_file *raw) { - this->raw = raw; -} - -GitDiffFile::~GitDiffFile() { - free(this->raw); -} - -void GitDiffFile::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("DiffFile"), _constructor_template); -} - -NAN_METHOD(GitDiffFile::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_file is required."); - } - GitDiffFile* object = new GitDiffFile(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitDiffFile::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitDiffFile::constructor_template)->NewInstance(1, argv)); -} - -git_diff_file *GitDiffFile::GetValue() { - return this->raw; -} - - -NAN_METHOD(GitDiffFile::Oid) { - NanScope(); - Handle to; - - git_oid *oid = - &ObjectWrap::Unwrap(args.This())->GetValue()->oid; - - if (oid != NULL) { - oid = (git_oid *)git_oid_dup(oid); - } - if (oid != NULL) { - to = GitOid::New((void *)oid); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitDiffFile::Path) { - NanScope(); - Handle to; - - const char * path = - ObjectWrap::Unwrap(args.This())->GetValue()->path; - - to = NanNew(path); - NanReturnValue(to); -} - -NAN_METHOD(GitDiffFile::Size) { - NanScope(); - Handle to; - - git_off_t size = - ObjectWrap::Unwrap(args.This())->GetValue()->size; - - to = NanNew(size); - NanReturnValue(to); -} - -NAN_METHOD(GitDiffFile::Flags) { - NanScope(); - Handle to; - - uint32_t flags = - ObjectWrap::Unwrap(args.This())->GetValue()->flags; - - to = NanNew(flags); - NanReturnValue(to); -} - -NAN_METHOD(GitDiffFile::Mode) { - NanScope(); - Handle to; - - uint16_t mode = - ObjectWrap::Unwrap(args.This())->GetValue()->mode; - - to = NanNew(mode); - NanReturnValue(to); -} - -Persistent GitDiffFile::constructor_template; diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc deleted file mode 100644 index 20421c3f1..000000000 --- a/src/diff_find_options.cc +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/diff_find_options.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("DiffFindOptions")); - - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("DiffFindOptions"), _constructor_template); -} - -NAN_METHOD(GitDiffFindOptions::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_find_options is required."); - } - GitDiffFindOptions* object = new GitDiffFindOptions(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitDiffFindOptions::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(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 deleted file mode 100755 index 3a0985400..000000000 --- a/src/diff_list.cc +++ /dev/null @@ -1,225 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/diff_list.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" - -using namespace v8; -using namespace node; - -GitDiffList::GitDiffList(git_diff_list *raw) { - this->raw = raw; -} - -GitDiffList::~GitDiffList() { - git_diff_list_free(this->raw); -} - -void GitDiffList::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("DiffList")); - - 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); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("DiffList"), _constructor_template); -} - -NAN_METHOD(GitDiffList::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_list is required."); - } - GitDiffList* object = new GitDiffList(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitDiffList::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitDiffList::constructor_template)->NewInstance(1, argv)); -} - -git_diff_list *GitDiffList::GetValue() { - return this->raw; -} - - -/** - * @param {DiffList} from - */ -NAN_METHOD(GitDiffList::Merge) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("DiffList from is required."); - } - - const git_diff_list * from_from; - from_from = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_diff_merge( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_from - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {DiffFindOptions} options - */ -NAN_METHOD(GitDiffList::FindSimilar) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("DiffFindOptions options is required."); - } - - git_diff_find_options * from_options; - from_options = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_diff_find_similar( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_options - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitDiffList::Size) { - NanScope(); - - - size_t result = git_diff_num_deltas( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @param {DiffList} diff - * @param {Number} type - * @return {Number} result - */ -NAN_METHOD(GitDiffList::NumDeltasOfType) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("DiffList diff is required."); - } - if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError("Number type is required."); - } - - git_diff_list * from_diff; - from_diff = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - git_delta_t from_type; - from_type = (git_delta_t) args[1]->ToInt32()->Value(); - - size_t result = git_diff_num_deltas_of_type( - from_diff - , from_type - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @param {Number} idx - * @return {Patch} patch_out - * @return {Delta} delta_out - */ -NAN_METHOD(GitDiffList::Patch) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number idx is required."); - } - - git_diff_patch * patch_out = 0; - const git_diff_delta * delta_out = 0; - size_t from_idx; - from_idx = (size_t) args[0]->ToUint32()->Value(); - - int result = git_diff_get_patch( - &patch_out - , &delta_out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_idx - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle toReturn = NanNew(); - Handle to; - if (patch_out != NULL) { - to = GitPatch::New((void *)patch_out); - } else { - to = NanNull(); - } - toReturn->Set(NanNew("patch"), to); - - if (delta_out != NULL) { - delta_out = (const git_diff_delta * )git_diff_delta_dup(delta_out); - } - if (delta_out != NULL) { - to = GitDelta::New((void *)delta_out); - } else { - to = NanNull(); - } - toReturn->Set(NanNew("delta"), to); - - NanReturnValue(toReturn); -} - -Persistent GitDiffList::constructor_template; diff --git a/src/diff_options.cc b/src/diff_options.cc deleted file mode 100644 index 75a3bc129..000000000 --- a/src/diff_options.cc +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/diff_options.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("DiffOptions")); - - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("DiffOptions"), _constructor_template); -} - -NAN_METHOD(GitDiffOptions::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_options is required."); - } - GitDiffOptions* object = new GitDiffOptions(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitDiffOptions::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(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 deleted file mode 100644 index 82c2b5fc4..000000000 --- a/src/diff_range.cc +++ /dev/null @@ -1,110 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/diff_range.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("DiffRange"), _constructor_template); -} - -NAN_METHOD(GitDiffRange::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_range is required."); - } - GitDiffRange* object = new GitDiffRange(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitDiffRange::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitDiffRange::constructor_template)->NewInstance(1, argv)); -} - -git_diff_range *GitDiffRange::GetValue() { - return this->raw; -} - - -NAN_METHOD(GitDiffRange::OldStart) { - NanScope(); - Handle to; - - int old_start = - ObjectWrap::Unwrap(args.This())->GetValue()->old_start; - - to = NanNew(old_start); - NanReturnValue(to); -} - -NAN_METHOD(GitDiffRange::OldLines) { - NanScope(); - Handle to; - - int old_lines = - ObjectWrap::Unwrap(args.This())->GetValue()->old_lines; - - to = NanNew(old_lines); - NanReturnValue(to); -} - -NAN_METHOD(GitDiffRange::NewStart) { - NanScope(); - Handle to; - - int new_start = - ObjectWrap::Unwrap(args.This())->GetValue()->new_start; - - to = NanNew(new_start); - NanReturnValue(to); -} - -NAN_METHOD(GitDiffRange::NewLines) { - NanScope(); - Handle to; - - int new_lines = - ObjectWrap::Unwrap(args.This())->GetValue()->new_lines; - - to = NanNew(new_lines); - NanReturnValue(to); -} - -Persistent GitDiffRange::constructor_template; diff --git a/src/functions/copy.cc b/src/functions/copy.cc index d534c3da0..0effadb2c 100644 --- a/src/functions/copy.cc +++ b/src/functions/copy.cc @@ -45,9 +45,3 @@ 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 deleted file mode 100644 index fc0e7a0c3..000000000 --- a/src/index.cc +++ /dev/null @@ -1,857 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/index.h" -#include "../include/oid.h" -#include "../include/repo.h" -#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; - -GitIndex::GitIndex(git_index *raw) { - this->raw = raw; -} - -GitIndex::~GitIndex() { - git_index_free(this->raw); -} - -void GitIndex::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Index")); - - NODE_SET_METHOD(tpl, "open", Open); - 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, "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); - 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); - NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Index"), _constructor_template); -} - -NAN_METHOD(GitIndex::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_index is required."); - } - GitIndex* object = new GitIndex(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitIndex::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitIndex::constructor_template)->NewInstance(1, argv)); -} - -git_index *GitIndex::GetValue() { - return this->raw; -} - - -#include "../include/functions/copy.h" - -/** - * @param {String} index_path - * @param {Index} callback - */ -NAN_METHOD(GitIndex::Open) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String index_path is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - OpenBaton* baton = new OpenBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - const char * from_index_path; - String::Utf8Value index_path(args[0]->ToString()); - from_index_path = strdup(*index_path); - baton->index_path = from_index_path; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - OpenWorker *worker = new OpenWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("index_path", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::OpenWorker::Execute() { - int result = git_index_open( - &baton->out, - baton->index_path - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::OpenWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitIndex::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->index_path); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitIndex::Read) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ReadBaton* baton = new ReadBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - ReadWorker *worker = new ReadWorker(baton, callback); - worker->SaveToPersistent("index", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::ReadWorker::Execute() { - int result = git_index_read( - baton->index - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::ReadWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitIndex::Write) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - WriteBaton* baton = new WriteBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - WriteWorker *worker = new WriteWorker(baton, callback); - worker->SaveToPersistent("index", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::WriteWorker::Execute() { - int result = git_index_write( - baton->index - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::WriteWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Tree} tree - */ -NAN_METHOD(GitIndex::ReadTree) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Tree tree is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ReadTreeBaton* baton = new ReadTreeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_tree * from_tree; - from_tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->tree = from_tree; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - ReadTreeWorker *worker = new ReadTreeWorker(baton, callback); - worker->SaveToPersistent("index", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("tree", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::ReadTreeWorker::Execute() { - int result = git_index_read_tree( - baton->index, - baton->tree - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::ReadTreeWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} callback - */ -NAN_METHOD(GitIndex::WriteTree) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - WriteTreeBaton* baton = new WriteTreeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->out = (git_oid *)malloc(sizeof(git_oid )); - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - WriteTreeWorker *worker = new WriteTreeWorker(baton, callback); - worker->SaveToPersistent("index", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::WriteTreeWorker::Execute() { - int result = git_index_write_tree( - baton->out, - baton->index - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::WriteTreeWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitOid::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->out); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitIndex::Size) { - NanScope(); - - - size_t result = git_index_entrycount( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - */ -NAN_METHOD(GitIndex::Clear) { - NanScope(); - - - git_index_clear( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - NanReturnUndefined(); -} - -/** - * @param {Number} n - * @return {IndexEntry} result - */ -NAN_METHOD(GitIndex::Entry) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number n is required."); - } - - size_t from_n; - 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; - if (result != NULL) { - result = (const git_index_entry * )git_index_entry_dup(result); - } - if (result != NULL) { - to = GitIndexEntry::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} path - * @param {Number} stage - */ -NAN_METHOD(GitIndex::Remove) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError("Number stage is required."); - } - - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - int from_stage; - from_stage = (int) args[1]->ToInt32()->Value(); - - int result = git_index_remove( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_path - , from_stage - ); - free((void *)from_path); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} dir - * @param {Number} stage - */ -NAN_METHOD(GitIndex::RemoveDirectory) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String dir is required."); - } - if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError("Number stage is required."); - } - - const char * from_dir; - String::Utf8Value dir(args[0]->ToString()); - from_dir = strdup(*dir); - int from_stage; - from_stage = (int) args[1]->ToInt32()->Value(); - - int result = git_index_remove_directory( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_dir - , from_stage - ); - free((void *)from_dir); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - * @param {String} path - */ -NAN_METHOD(GitIndex::AddBypath) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - AddBypathBaton* baton = new AddBypathBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - AddBypathWorker *worker = new AddBypathWorker(baton, callback); - worker->SaveToPersistent("index", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("path", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::AddBypathWorker::Execute() { - int result = git_index_add_bypath( - baton->index, - baton->path - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::AddBypathWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->path); - delete baton; -} - -/** - * @param {String} path - */ -NAN_METHOD(GitIndex::RemoveBypath) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - - int result = git_index_remove_bypath( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_path - ); - free((void *)from_path); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} path - * @return {Number} at_pos - */ -NAN_METHOD(GitIndex::Find) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - size_t at_pos = 0; - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - - int result = git_index_find( - &at_pos - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_path - ); - free((void *)from_path); - - Handle to; - to = NanNew((uint32_t)at_pos); - NanReturnValue(to); -} - -/** - * @param {String} path - */ -NAN_METHOD(GitIndex::ConflictRemove) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - - int result = git_index_conflict_remove( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_path - ); - free((void *)from_path); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - */ -NAN_METHOD(GitIndex::ConflictCleanup) { - NanScope(); - - - git_index_conflict_cleanup( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - NanReturnUndefined(); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitIndex::HasConflicts) { - NanScope(); - - - int result = git_index_has_conflicts( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((int32_t)result); - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {Index} index - * @param {DiffOptions} opts - * @param {DiffList} callback - */ -NAN_METHOD(GitIndex::IndexToWorkdir) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - git_index * from_index; - if (args[1]->IsObject()) { - from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - from_index = 0; - } - baton->index = from_index; - const git_diff_options * from_opts; - if (args[2]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - - NanCallback *callback = new NanCallback(Local::Cast(args[3])); - IndexToWorkdirWorker *worker = new IndexToWorkdirWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("index", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("opts", args[2]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitIndex::IndexToWorkdirWorker::Execute() { - int result = git_diff_index_to_workdir( - &baton->diff, - baton->repo, - baton->index, - baton->opts - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitIndex::IndexToWorkdirWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->diff != NULL) { - to = GitDiffList::New((void *)baton->diff); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -Persistent GitIndex::constructor_template; diff --git a/src/index_entry.cc b/src/index_entry.cc deleted file mode 100644 index 0fef443c1..000000000 --- a/src/index_entry.cc +++ /dev/null @@ -1,229 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/index_entry.h" -#include "../include/index_time.h" -#include "../include/oid.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("IndexEntry")); - - - NODE_SET_PROTOTYPE_METHOD(tpl, "ctime", Ctime); - NODE_SET_PROTOTYPE_METHOD(tpl, "mtime", Mtime); - NODE_SET_PROTOTYPE_METHOD(tpl, "dev", Dev); - NODE_SET_PROTOTYPE_METHOD(tpl, "ino", Ino); - NODE_SET_PROTOTYPE_METHOD(tpl, "mode", Mode); - NODE_SET_PROTOTYPE_METHOD(tpl, "uid", Uid); - NODE_SET_PROTOTYPE_METHOD(tpl, "gid", gid); - NODE_SET_PROTOTYPE_METHOD(tpl, "file_size", FileSize); - NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); - NODE_SET_PROTOTYPE_METHOD(tpl, "flags_extended", FlagsExtended); - NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("IndexEntry"), _constructor_template); -} - -NAN_METHOD(GitIndexEntry::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_index_entry is required."); - } - GitIndexEntry* object = new GitIndexEntry(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitIndexEntry::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitIndexEntry::constructor_template)->NewInstance(1, argv)); -} - -git_index_entry *GitIndexEntry::GetValue() { - return this->raw; -} - - -NAN_METHOD(GitIndexEntry::Ctime) { - NanScope(); - Handle to; - - git_index_time *ctime = - &ObjectWrap::Unwrap(args.This())->GetValue()->ctime; - - if (ctime != NULL) { - ctime = (git_index_time *)git_index_time_dup(ctime); - } - if (ctime != NULL) { - to = GitIndexTime::New((void *)ctime); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Mtime) { - NanScope(); - Handle to; - - git_index_time *mtime = - &ObjectWrap::Unwrap(args.This())->GetValue()->mtime; - - if (mtime != NULL) { - mtime = (git_index_time *)git_index_time_dup(mtime); - } - if (mtime != NULL) { - to = GitIndexTime::New((void *)mtime); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Dev) { - NanScope(); - Handle to; - - unsigned int dev = - ObjectWrap::Unwrap(args.This())->GetValue()->dev; - - to = NanNew((uint32_t)dev); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Ino) { - NanScope(); - Handle to; - - unsigned int ino = - ObjectWrap::Unwrap(args.This())->GetValue()->ino; - - to = NanNew((uint32_t)ino); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Mode) { - NanScope(); - Handle to; - - uint16_t mode = - ObjectWrap::Unwrap(args.This())->GetValue()->mode; - - to = NanNew(mode); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Uid) { - NanScope(); - Handle to; - - unsigned int uid = - ObjectWrap::Unwrap(args.This())->GetValue()->uid; - - to = NanNew((uint32_t)uid); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::gid) { - NanScope(); - Handle to; - - unsigned int gid = - ObjectWrap::Unwrap(args.This())->GetValue()->gid; - - to = NanNew((uint32_t)gid); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::FileSize) { - NanScope(); - Handle to; - - unsigned int file_size = - ObjectWrap::Unwrap(args.This())->GetValue()->file_size; - - to = NanNew((uint32_t)file_size); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Oid) { - NanScope(); - Handle to; - - git_oid *oid = - &ObjectWrap::Unwrap(args.This())->GetValue()->oid; - - if (oid != NULL) { - oid = (git_oid *)git_oid_dup(oid); - } - if (oid != NULL) { - to = GitOid::New((void *)oid); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Flags) { - NanScope(); - Handle to; - - uint16_t flags = - ObjectWrap::Unwrap(args.This())->GetValue()->flags; - - to = NanNew(flags); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::FlagsExtended) { - NanScope(); - Handle to; - - uint16_t flags_extended = - ObjectWrap::Unwrap(args.This())->GetValue()->flags_extended; - - to = NanNew(flags_extended); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexEntry::Path) { - NanScope(); - Handle to; - - char * path = - ObjectWrap::Unwrap(args.This())->GetValue()->path; - - to = NanNew(path); - NanReturnValue(to); -} - -Persistent GitIndexEntry::constructor_template; diff --git a/src/index_time.cc b/src/index_time.cc deleted file mode 100644 index 2da28c951..000000000 --- a/src/index_time.cc +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/index_time.h" - -using namespace v8; -using namespace node; - -GitIndexTime::GitIndexTime(git_index_time *raw) { - this->raw = raw; -} - -GitIndexTime::~GitIndexTime() { - free(this->raw); -} - -void GitIndexTime::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("IndexTime")); - - - NODE_SET_PROTOTYPE_METHOD(tpl, "seconds", Seconds); - NODE_SET_PROTOTYPE_METHOD(tpl, "nanoseconds", Nanoseconds); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("IndexTime"), _constructor_template); -} - -NAN_METHOD(GitIndexTime::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_index_time is required."); - } - GitIndexTime* object = new GitIndexTime(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitIndexTime::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitIndexTime::constructor_template)->NewInstance(1, argv)); -} - -git_index_time *GitIndexTime::GetValue() { - return this->raw; -} - - -NAN_METHOD(GitIndexTime::Seconds) { - NanScope(); - Handle to; - - git_time_t seconds = - ObjectWrap::Unwrap(args.This())->GetValue()->seconds; - - to = NanNew((uint32_t)seconds); - NanReturnValue(to); -} - -NAN_METHOD(GitIndexTime::Nanoseconds) { - NanScope(); - Handle to; - - unsigned int nanoseconds = - ObjectWrap::Unwrap(args.This())->GetValue()->nanoseconds; - - to = NanNew((uint32_t)nanoseconds); - NanReturnValue(to); -} - -Persistent GitIndexTime::constructor_template; diff --git a/src/object.cc b/src/object.cc deleted file mode 100644 index 8a62b1300..000000000 --- a/src/object.cc +++ /dev/null @@ -1,187 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/object.h" -#include "../include/oid.h" -#include "../include/repo.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Object")); - - NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); - NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Object"), _constructor_template); -} - -NAN_METHOD(GitObject::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_object is required."); - } - GitObject* object = new GitObject(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitObject::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitObject::constructor_template)->NewInstance(1, argv)); -} - -git_object *GitObject::GetValue() { - return this->raw; -} - - -/** - * @return {Oid} result - */ -NAN_METHOD(GitObject::Oid) { - NanScope(); - - - const git_oid * result = git_object_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitObject::Type) { - NanScope(); - - - git_otype result = git_object_type( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Number} target_type - * @param {Object} callback - */ -NAN_METHOD(GitObject::Peel) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number target_type is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - PeelBaton* baton = new PeelBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->object = ObjectWrap::Unwrap(args.This())->GetValue(); - git_otype from_target_type; - from_target_type = (git_otype) args[0]->ToInt32()->Value(); - baton->target_type = from_target_type; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - PeelWorker *worker = new PeelWorker(baton, callback); - worker->SaveToPersistent("object", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("target_type", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitObject::PeelWorker::Execute() { - int result = git_object_peel( - &baton->peeled, - baton->object, - baton->target_type - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitObject::PeelWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->peeled != NULL) { - to = GitObject::New((void *)baton->peeled); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -Persistent GitObject::constructor_template; diff --git a/src/odb.cc b/src/odb.cc deleted file mode 100644 index c45ce17c8..000000000 --- a/src/odb.cc +++ /dev/null @@ -1,594 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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_PROTOTYPE_METHOD(tpl, "write", Write); - NODE_SET_METHOD(tpl, "hash", Hash); - NODE_SET_METHOD(tpl, "hashfile", Hashfile); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Odb"), _constructor_template); -} - -NAN_METHOD(GitOdb::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_odb is required."); - } - GitOdb* object = new GitOdb(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitOdb::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitOdb::constructor_template)->NewInstance(1, argv)); -} - -git_odb *GitOdb::GetValue() { - return this->raw; -} - - -/** - * @return {Odb} out - */ -NAN_METHOD(GitOdb::Create) { - NanScope(); - - git_odb * out = 0; - - int result = git_odb_new( - &out - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOdb::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} objects_dir - * @return {Odb} out - */ -NAN_METHOD(GitOdb::Open) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String objects_dir is required."); - } - - git_odb * out = 0; - const char * from_objects_dir; - String::Utf8Value objects_dir(args[0]->ToString()); - from_objects_dir = strdup(*objects_dir); - - int result = git_odb_open( - &out - , from_objects_dir - ); - free((void *)from_objects_dir); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOdb::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} path - */ -NAN_METHOD(GitOdb::AddDiskAlternate) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - - int result = git_odb_add_disk_alternate( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_path - ); - free((void *)from_path); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - * @param {OdbObject} callback - */ -NAN_METHOD(GitOdb::Read) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ReadBaton* baton = new ReadBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->db = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - ReadWorker *worker = new ReadWorker(baton, callback); - worker->SaveToPersistent("db", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitOdb::ReadWorker::Execute() { - int result = git_odb_read( - &baton->out, - baton->db, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitOdb::ReadWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitOdbObject::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - * @param {Odb} db - * @param {Oid} short_id - * @param {Number} len - * @return {OdbObject} out - */ -NAN_METHOD(GitOdb::ReadPrefix) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Odb db is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Oid short_id is required."); - } - if (args.Length() == 2 || !args[2]->IsUint32()) { - return NanThrowError("Number len is required."); - } - - git_odb_object * out = 0; - git_odb * from_db; - from_db = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - const git_oid * from_short_id; - from_short_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - size_t from_len; - 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) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOdbObject::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Odb} db - * @param {Oid} id - * @return {Number} len_out - * @return {Number} type_out - */ -NAN_METHOD(GitOdb::ReadHeader) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Odb db is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - size_t len_out = 0; - git_otype type_out = GIT_OBJ_ANY; - git_odb * from_db; - from_db = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - - int result = git_odb_read_header( - &len_out - , &type_out - , from_db - , from_id - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle toReturn = NanNew(); - Handle to; - to = NanNew((uint32_t)len_out); - toReturn->Set(NanNew("len_out"), to); - - to = NanNew((int32_t)type_out); - toReturn->Set(NanNew("type_out"), to); - - NanReturnValue(toReturn); -} - -/** - * @param {Oid} id - */ -NAN_METHOD(GitOdb::Exists) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_odb_exists( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_id - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - */ -NAN_METHOD(GitOdb::Refresh) { - NanScope(); - - - int result = git_odb_refresh( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - * @param {String} data - * @param {Number} len - * @param {Number} type - * @param {Oid} callback - */ -NAN_METHOD(GitOdb::Write) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String data is required."); - } - if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError("Number len is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number type is required."); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - WriteBaton* baton = new WriteBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->out = (git_oid *)malloc(sizeof(git_oid )); - baton->odb = ObjectWrap::Unwrap(args.This())->GetValue(); - const void * from_data; - String::Utf8Value data(args[0]->ToString()); - from_data = strdup(*data); - baton->data = from_data; - size_t from_len; - from_len = (size_t) args[1]->ToUint32()->Value(); - baton->len = from_len; - git_otype from_type; - from_type = (git_otype) args[2]->ToInt32()->Value(); - baton->type = from_type; - - NanCallback *callback = new NanCallback(Local::Cast(args[3])); - WriteWorker *worker = new WriteWorker(baton, callback); - worker->SaveToPersistent("odb", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("data", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("len", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("type", args[2]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitOdb::WriteWorker::Execute() { - int result = git_odb_write( - baton->out, - baton->odb, - baton->data, - baton->len, - baton->type - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitOdb::WriteWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitOid::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->out); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->data); - delete baton; -} - -/** - * @param {Buffer} data - * @param {Number} len - * @param {Number} type - * @return {Oid} out - */ -NAN_METHOD(GitOdb::Hash) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Buffer data is required."); - } - if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError("Number len is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number type is required."); - } - - git_oid *out = (git_oid *)malloc(sizeof(git_oid)); - const void * from_data; - from_data = Buffer::Data(args[0]->ToObject()); - size_t from_len; - from_len = (size_t) args[1]->ToUint32()->Value(); - git_otype from_type; - from_type = (git_otype) args[2]->ToInt32()->Value(); - - int result = git_odb_hash( - out - , from_data - , from_len - , from_type - ); - if (result != GIT_OK) { - free(out); - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOid::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} path - * @param {Number} type - * @return {Oid} out - */ -NAN_METHOD(GitOdb::Hashfile) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError("Number type is required."); - } - - git_oid *out = (git_oid *)malloc(sizeof(git_oid)); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - git_otype from_type; - from_type = (git_otype) args[1]->ToInt32()->Value(); - - int result = git_odb_hashfile( - out - , from_path - , from_type - ); - free((void *)from_path); - if (result != GIT_OK) { - free(out); - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOid::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -Persistent GitOdb::constructor_template; diff --git a/src/odb_object.cc b/src/odb_object.cc deleted file mode 100644 index 2316738fe..000000000 --- a/src/odb_object.cc +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("OdbObject")); - - 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); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("OdbObject"), _constructor_template); -} - -NAN_METHOD(GitOdbObject::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_odb_object is required."); - } - GitOdbObject* object = new GitOdbObject(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitOdbObject::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitOdbObject::constructor_template)->NewInstance(1, argv)); -} - -git_odb_object *GitOdbObject::GetValue() { - return this->raw; -} - - -/** - * @return {Wrapper} result - */ -NAN_METHOD(GitOdbObject::Data) { - NanScope(); - - - const void * result = git_odb_object_data( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - to = Wrapper::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitOdbObject::Size) { - NanScope(); - - - size_t result = git_odb_object_size( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitOdbObject::Type) { - NanScope(); - - - git_otype result = git_odb_object_type( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((int32_t)result); - NanReturnValue(to); -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitOdbObject::Oid) { - NanScope(); - - - const git_oid * result = git_odb_object_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -Persistent GitOdbObject::constructor_template; diff --git a/src/oid.cc b/src/oid.cc deleted file mode 100755 index e05f9400b..000000000 --- a/src/oid.cc +++ /dev/null @@ -1,119 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/oid.h" - -using namespace v8; -using namespace node; - -GitOid::GitOid(git_oid *raw) { - this->raw = raw; -} - -GitOid::~GitOid() { - free(this->raw); -} - -void GitOid::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Oid")); - - NODE_SET_METHOD(tpl, "fromString", FromString); - NODE_SET_PROTOTYPE_METHOD(tpl, "sha", Sha); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Oid"), _constructor_template); -} - -NAN_METHOD(GitOid::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_oid is required."); - } - GitOid* object = new GitOid(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitOid::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitOid::constructor_template)->NewInstance(1, argv)); -} - -git_oid *GitOid::GetValue() { - return this->raw; -} - - -/** - * @param {String} str - * @return {Oid} out - */ -NAN_METHOD(GitOid::FromString) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String str is required."); - } - - git_oid *out = (git_oid *)malloc(sizeof(git_oid)); - const char * from_str; - String::Utf8Value str(args[0]->ToString()); - from_str = strdup(*str); - - int result = git_oid_fromstr( - out - , from_str - ); - free((void *)from_str); - if (result != GIT_OK) { - free(out); - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOid::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitOid::Sha) { - NanScope(); - - - char * result = git_oid_allocfmt( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - free(result); - NanReturnValue(to); -} - -Persistent GitOid::constructor_template; diff --git a/src/patch.cc b/src/patch.cc deleted file mode 100644 index 936f2d3e6..000000000 --- a/src/patch.cc +++ /dev/null @@ -1,325 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/patch.h" -#include "../include/delta.h" -#include "../include/diff_range.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Patch"), _constructor_template); -} - -NAN_METHOD(GitPatch::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_diff_patch is required."); - } - GitPatch* object = new GitPatch(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitPatch::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitPatch::constructor_template)->NewInstance(1, argv)); -} - -git_diff_patch *GitPatch::GetValue() { - return this->raw; -} - - -/** - * @return {Delta} result - */ -NAN_METHOD(GitPatch::Delta) { - NanScope(); - - - const git_diff_delta * result = git_diff_patch_delta( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_diff_delta * )git_diff_delta_dup(result); - } - if (result != NULL) { - to = GitDelta::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitPatch::Size) { - NanScope(); - - - size_t result = git_diff_patch_num_hunks( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @return {Number} total_context - * @return {Number} total_additions - * @return {Number} total_deletions - */ -NAN_METHOD(GitPatch::Stats) { - NanScope(); - - size_t total_context = 0; - size_t total_additions = 0; - size_t total_deletions = 0; - - int result = git_diff_patch_line_stats( - &total_context - , &total_additions - , &total_deletions - , ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle toReturn = NanNew(); - Handle to; - to = NanNew(total_context); - toReturn->Set(NanNew("total_context"), to); - - to = NanNew(total_additions); - toReturn->Set(NanNew("total_additions"), to); - - to = NanNew(total_deletions); - toReturn->Set(NanNew("total_deletions"), to); - - NanReturnValue(toReturn); -} - -/** - * @param {Number} hunk_idx - * @return {DiffRange} range - * @return {String} header - * @return {Number} header_len - * @return {Number} lines_in_hunk - */ -NAN_METHOD(GitPatch::Hunk) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number hunk_idx is required."); - } - - const git_diff_range * range = 0; - const char * header = 0; - size_t header_len = 0; - size_t lines_in_hunk = 0; - size_t from_hunk_idx; - from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); - - int result = git_diff_patch_get_hunk( - &range - , &header - , &header_len - , &lines_in_hunk - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_hunk_idx - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle toReturn = NanNew(); - Handle to; - if (range != NULL) { - range = (const git_diff_range * )git_diff_range_dup(range); - } - if (range != NULL) { - to = GitDiffRange::New((void *)range); - } else { - to = NanNull(); - } - toReturn->Set(NanNew("range"), to); - - to = NanNew(header); - toReturn->Set(NanNew("header"), to); - - to = NanNew((uint32_t)header_len); - toReturn->Set(NanNew("headerLength"), to); - - to = NanNew((uint32_t)lines_in_hunk); - toReturn->Set(NanNew("lines"), to); - - NanReturnValue(toReturn); -} - -/** - * @param {Number} hunk_idx - * @return {Number} result - */ -NAN_METHOD(GitPatch::Lines) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number hunk_idx is required."); - } - - size_t from_hunk_idx; - from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); - - int result = git_diff_patch_num_lines_in_hunk( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_hunk_idx - ); - - Handle to; - to = NanNew((int32_t)result); - NanReturnValue(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 - */ -NAN_METHOD(GitPatch::Line) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number hunk_idx is required."); - } - if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError("Number line_of_hunk is required."); - } - - char line_origin = 0; - const char * content = 0; - size_t content_len = 0; - int old_lineno = 0; - int new_lineno = 0; - size_t from_hunk_idx; - from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); - size_t from_line_of_hunk; - from_line_of_hunk = (size_t) args[1]->ToUint32()->Value(); - - int result = git_diff_patch_get_line_in_hunk( - &line_origin - , &content - , &content_len - , &old_lineno - , &new_lineno - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_hunk_idx - , from_line_of_hunk - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle toReturn = NanNew(); - Handle to; - to = NanNew(line_origin); - toReturn->Set(NanNew("lineOrigin"), to); - - to = NanNew(content, content_len); - toReturn->Set(NanNew("content"), to); - - to = NanNew((uint32_t)content_len); - toReturn->Set(NanNew("length"), to); - - to = NanNew((int32_t)old_lineno); - toReturn->Set(NanNew("oldLineNumber"), to); - - to = NanNew((int32_t)new_lineno); - toReturn->Set(NanNew("newLineNumber"), to); - - NanReturnValue(toReturn); -} - -/** - * @return {String} string - */ -NAN_METHOD(GitPatch::ToString) { - NanScope(); - - char * string = 0; - - int result = git_diff_patch_to_str( - &string - , ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - to = NanNew(string); - free(string); - NanReturnValue(to); -} - -Persistent GitPatch::constructor_template; diff --git a/src/refdb.cc b/src/refdb.cc deleted file mode 100644 index b9279d17f..000000000 --- a/src/refdb.cc +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/refdb.h" - -using namespace v8; -using namespace node; - -GitRefDb::GitRefDb(git_refdb *raw) { - this->raw = raw; -} - -GitRefDb::~GitRefDb() { - free(this->raw); -} - -void GitRefDb::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("RefDb")); - - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("RefDb"), _constructor_template); -} - -NAN_METHOD(GitRefDb::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_refdb is required."); - } - GitRefDb* object = new GitRefDb(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitRefDb::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(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 deleted file mode 100755 index 131df574a..000000000 --- a/src/reference.cc +++ /dev/null @@ -1,647 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/reference.h" -#include "../include/repo.h" -#include "../include/oid.h" -#include "../include/object.h" - -using namespace v8; -using namespace node; - -GitReference::GitReference(git_reference *raw) { - this->raw = raw; -} - -GitReference::~GitReference() { - git_reference_free(this->raw); -} - -void GitReference::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Reference")); - - NODE_SET_METHOD(tpl, "oidForName", OidForName); - NODE_SET_PROTOTYPE_METHOD(tpl, "target", Target); - 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); - 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); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Reference"), _constructor_template); -} - -NAN_METHOD(GitReference::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_reference is required."); - } - GitReference* object = new GitReference(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitReference::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitReference::constructor_template)->NewInstance(1, argv)); -} - -git_reference *GitReference::GetValue() { - return this->raw; -} - - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {String} name - * @param {Oid} callback - */ -NAN_METHOD(GitReference::OidForName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String name is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - OidForNameBaton* baton = new OidForNameBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->out = (git_oid *)malloc(sizeof(git_oid )); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - const char * from_name; - String::Utf8Value name(args[1]->ToString()); - from_name = strdup(*name); - baton->name = from_name; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - OidForNameWorker *worker = new OidForNameWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("name", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitReference::OidForNameWorker::Execute() { - int result = git_reference_name_to_id( - baton->out, - baton->repo, - baton->name - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitReference::OidForNameWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitOid::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->out); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->name); - delete baton; -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitReference::Target) { - NanScope(); - - - const git_oid * result = git_reference_target( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitReference::SymbolicTarget) { - NanScope(); - - - const char * result = git_reference_symbolic_target( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitReference::Type) { - NanScope(); - - - git_ref_t result = git_reference_type( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitReference::Name) { - NanScope(); - - - const char * result = git_reference_name( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Reference} callback - */ -NAN_METHOD(GitReference::Resolve) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ResolveBaton* baton = new ResolveBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - ResolveWorker *worker = new ResolveWorker(baton, callback); - worker->SaveToPersistent("ref", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitReference::ResolveWorker::Execute() { - int result = git_reference_resolve( - &baton->out, - baton->ref - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitReference::ResolveWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitReference::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - * @param {String} target - * @return {Reference} out - */ -NAN_METHOD(GitReference::SetSymbolicTarget) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String target is required."); - } - - git_reference * out = 0; - const char * from_target; - String::Utf8Value target(args[0]->ToString()); - from_target = strdup(*target); - - int result = git_reference_symbolic_set_target( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_target - ); - free((void *)from_target); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Oid} id - * @return {Reference} out - */ -NAN_METHOD(GitReference::setTarget) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - git_reference * out = 0; - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_reference_set_target( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_id - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {String} new_name - * @param {Number} force - * @param {Reference} callback - */ -NAN_METHOD(GitReference::Rename) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String new_name is required."); - } - if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - RenameBaton* baton = new RenameBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_new_name; - String::Utf8Value new_name(args[0]->ToString()); - from_new_name = strdup(*new_name); - baton->new_name = from_new_name; - int from_force; - from_force = (int) args[1]->ToInt32()->Value(); - baton->force = from_force; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - RenameWorker *worker = new RenameWorker(baton, callback); - worker->SaveToPersistent("ref", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("new_name", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("force", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitReference::RenameWorker::Execute() { - int result = git_reference_rename( - &baton->out, - baton->ref, - baton->new_name, - baton->force - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitReference::RenameWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitReference::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->new_name); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitReference::Delete) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DeleteBaton* baton = new DeleteBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - DeleteWorker *worker = new DeleteWorker(baton, callback); - worker->SaveToPersistent("ref", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitReference::DeleteWorker::Execute() { - int result = git_reference_delete( - baton->ref - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitReference::DeleteWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - */ -NAN_METHOD(GitReference::IsBranch) { - NanScope(); - - - int result = git_reference_is_branch( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - */ -NAN_METHOD(GitReference::IsRemote) { - NanScope(); - - - int result = git_reference_is_remote( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {Number} type - * @return {Object} out - */ -NAN_METHOD(GitReference::Peel) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number type is required."); - } - - git_object * out = 0; - git_otype from_type; - from_type = (git_otype) args[0]->ToInt32()->Value(); - - int result = git_reference_peel( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_type - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitObject::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} refname - */ -NAN_METHOD(GitReference::IsValidName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String refname is required."); - } - - const char * from_refname; - String::Utf8Value refname(args[0]->ToString()); - from_refname = strdup(*refname); - - int result = git_reference_is_valid_name( - from_refname - ); - free((void *)from_refname); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -Persistent GitReference::constructor_template; diff --git a/src/remote.cc b/src/remote.cc deleted file mode 100644 index 4f6c33b1b..000000000 --- a/src/remote.cc +++ /dev/null @@ -1,592 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/remote.h" -#include "git2/net.h" - -using namespace v8; -using namespace node; - -GitRemote::GitRemote(git_remote *raw) { - this->raw = raw; -} - -GitRemote::~GitRemote() { - git_remote_free(this->raw); -} - -void GitRemote::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Remote")); - - 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, "connect", Connect); - 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_PROTOTYPE_METHOD(tpl, "updateTips", UpdateTips); - NODE_SET_METHOD(tpl, "validUrl", ValidUrl); - NODE_SET_METHOD(tpl, "supportedUrl", SupportedUrl); - NODE_SET_PROTOTYPE_METHOD(tpl, "checkCert", CheckCert); - NODE_SET_PROTOTYPE_METHOD(tpl, "updateFetchhead", UpdateFetchhead); - NODE_SET_PROTOTYPE_METHOD(tpl, "setUpdateFetchhead", SetUpdateFetchhead); - NODE_SET_METHOD(tpl, "isValidName", IsValidName); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Remote"), _constructor_template); -} - -NAN_METHOD(GitRemote::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_remote is required."); - } - GitRemote* object = new GitRemote(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitRemote::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitRemote::constructor_template)->NewInstance(1, argv)); -} - -git_remote *GitRemote::GetValue() { - return this->raw; -} - - -/** - * @return {String} result - */ -NAN_METHOD(GitRemote::Name) { - NanScope(); - - - const char * result = git_remote_name( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitRemote::Url) { - NanScope(); - - - const char * result = git_remote_url( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitRemote::PushUrl) { - NanScope(); - - - const char * result = git_remote_pushurl( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @param {String} url - */ -NAN_METHOD(GitRemote::SetUrl) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - - const char* from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - - int result = git_remote_set_url( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_url - ); - free((void *)from_url); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} url - */ -NAN_METHOD(GitRemote::SetPushUrl) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - - const char* from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - - int result = git_remote_set_pushurl( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_url - ); - free((void *)from_url); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - * @param {Number} direction - */ -NAN_METHOD(GitRemote::Connect) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsNumber()) { - return NanThrowError("Number direction is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ConnectBaton* baton = new ConnectBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); - git_direction from_direction; - from_direction = (git_direction) (int) args[0]->ToNumber()->Value(); - baton->direction = from_direction; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - ConnectWorker *worker = new ConnectWorker(baton, callback); - worker->SaveToPersistent("remote", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("direction", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRemote::ConnectWorker::Execute() { - int result = git_remote_connect( - baton->remote, - baton->direction - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRemote::ConnectWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Function} progress_cb - * @param {void} payload - */ -NAN_METHOD(GitRemote::Download) { - NanScope(); - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DownloadBaton* baton = new DownloadBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); - git_transfer_progress_callback from_progress_cb; - if (args[0]->IsFunction()) { - } else { - from_progress_cb = 0; - } - baton->progress_cb = from_progress_cb; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - DownloadWorker *worker = new DownloadWorker(baton, callback); - worker->SaveToPersistent("remote", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("progress_cb", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("payload", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRemote::DownloadWorker::Execute() { - int result = git_remote_download( - baton->remote, - baton->progress_cb, - baton->payload - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRemote::DownloadWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - */ -NAN_METHOD(GitRemote::Connected) { - NanScope(); - - - int result = git_remote_connected( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - */ -NAN_METHOD(GitRemote::Stop) { - NanScope(); - - - git_remote_stop( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitRemote::Disconnect) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DisconnectBaton* baton = new DisconnectBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - DisconnectWorker *worker = new DisconnectWorker(baton, callback); - worker->SaveToPersistent("remote", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRemote::DisconnectWorker::Execute() { - git_remote_disconnect( - baton->remote - ); -} - -void GitRemote::DisconnectWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - */ -NAN_METHOD(GitRemote::UpdateTips) { - NanScope(); - - - int result = git_remote_update_tips( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} url - */ -NAN_METHOD(GitRemote::ValidUrl) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - - const char * from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - - int result = git_remote_valid_url( - from_url - ); - free((void *)from_url); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {String} url - */ -NAN_METHOD(GitRemote::SupportedUrl) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - - const char* from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - - int result = git_remote_supported_url( - from_url - ); - free((void *)from_url); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {Number} check - */ -NAN_METHOD(GitRemote::CheckCert) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number check is required."); - } - - int from_check; - from_check = (int) args[0]->ToInt32()->Value(); - - git_remote_check_cert( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_check - ); - - NanReturnUndefined(); -} - -/** - */ -NAN_METHOD(GitRemote::UpdateFetchhead) { - NanScope(); - - - int result = git_remote_update_fetchhead( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @param {Number} value - */ -NAN_METHOD(GitRemote::SetUpdateFetchhead) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number value is required."); - } - - int from_value; - from_value = (int) args[0]->ToInt32()->Value(); - - git_remote_set_update_fetchhead( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_value - ); - - NanReturnUndefined(); -} - -/** - * @param {String} remote_name - */ -NAN_METHOD(GitRemote::IsValidName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String remote_name is required."); - } - - const char * from_remote_name; - String::Utf8Value remote_name(args[0]->ToString()); - from_remote_name = strdup(*remote_name); - - int result = git_remote_is_valid_name( - from_remote_name - ); - free((void *)from_remote_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -Persistent GitRemote::constructor_template; diff --git a/src/repo.cc b/src/repo.cc deleted file mode 100755 index 0e46f91d2..000000000 --- a/src/repo.cc +++ /dev/null @@ -1,2248 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.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" -#include "../include/odb.h" -#include "../include/index.h" -#include "../include/remote.h" -#include "../include/clone_options.h" -#include "node_buffer.h" - -using namespace v8; -using namespace node; - -GitRepo::GitRepo(git_repository *raw) { - this->raw = raw; -} - -GitRepo::~GitRepo() { - git_repository_free(this->raw); -} - -void GitRepo::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Repo")); - - 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); - 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, "createCommit", CreateCommit); - 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, "addRemote", AddRemote); - 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); - NODE_SET_PROTOTYPE_METHOD(tpl, "delete", Delete); - NODE_SET_PROTOTYPE_METHOD(tpl, "getReferences", GetReferences); - NODE_SET_PROTOTYPE_METHOD(tpl, "createBlobFromBuffer", CreateBlobFromBuffer); - NODE_SET_PROTOTYPE_METHOD(tpl, "createBlobFromFile", CreateBlobFromFile); - NODE_SET_PROTOTYPE_METHOD(tpl, "getRemotes", GetRemotes); - NODE_SET_METHOD(tpl, "clone", Clone); - NODE_SET_PROTOTYPE_METHOD(tpl, "getRemote", GetRemote); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Repo"), _constructor_template); -} - -NAN_METHOD(GitRepo::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_repository is required."); - } - GitRepo* object = new GitRepo(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitRepo::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitRepo::constructor_template)->NewInstance(1, argv)); -} - -git_repository *GitRepo::GetValue() { - return this->raw; -} - - -#include "../include/functions/copy.h" - -/** - * @param {String} path - * @param {Repository} callback - */ -NAN_METHOD(GitRepo::Open) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - OpenBaton* baton = new OpenBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - OpenWorker *worker = new OpenWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("path", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::OpenWorker::Execute() { - int result = git_repository_open( - &baton->out, - baton->path - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::OpenWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitRepo::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->path); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} path - * @param {Boolean} is_bare - * @param {Repository} callback - */ -NAN_METHOD(GitRepo::Init) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - if (args.Length() == 1 || !args[1]->IsBoolean()) { - return NanThrowError("Boolean is_bare is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - InitBaton* baton = new InitBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - unsigned from_is_bare; - from_is_bare = (unsigned) args[1]->ToBoolean()->Value(); - baton->is_bare = from_is_bare; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - InitWorker *worker = new InitWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("path", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("is_bare", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::InitWorker::Execute() { - int result = git_repository_init( - &baton->out, - baton->path, - baton->is_bare - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::InitWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitRepo::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->path); - delete baton; -} - -/** - * @return {String} result - */ -NAN_METHOD(GitRepo::Path) { - NanScope(); - - - const char * result = git_repository_path( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitRepo::Workdir) { - NanScope(); - - - const char * result = git_repository_workdir( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Odb} out - */ -NAN_METHOD(GitRepo::Odb) { - NanScope(); - - git_odb * out = 0; - - int result = git_repository_odb( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitOdb::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Index} callback - */ -NAN_METHOD(GitRepo::openIndex) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - openIndexBaton* baton = new openIndexBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - openIndexWorker *worker = new openIndexWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::openIndexWorker::Execute() { - int result = git_repository_index( - &baton->out, - baton->repo - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::openIndexWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitIndex::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - * @param {Blob} callback - */ -NAN_METHOD(GitRepo::GetBlob) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetBlobBaton* baton = new GetBlobBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetBlobWorker *worker = new GetBlobWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetBlobWorker::Execute() { - int result = git_blob_lookup( - &baton->blob, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetBlobWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->blob != NULL) { - to = GitBlob::New((void *)baton->blob); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - * @param {Commit} callback - */ -NAN_METHOD(GitRepo::GetCommit) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetCommitBaton* baton = new GetCommitBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetCommitWorker *worker = new GetCommitWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetCommitWorker::Execute() { - int result = git_commit_lookup( - &baton->commit, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetCommitWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->commit != NULL) { - to = GitCommit::New((void *)baton->commit); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @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 - */ -NAN_METHOD(GitRepo::CreateCommit) { - NanScope(); - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Signature author is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("Signature committer is required."); - } - if (args.Length() == 4 || !args[4]->IsString()) { - return NanThrowError("String message is required."); - } - if (args.Length() == 5 || !args[5]->IsObject()) { - return NanThrowError("Tree tree is required."); - } - if (args.Length() == 6 || !args[6]->IsInt32()) { - return NanThrowError("Number parent_count is required."); - } - if (args.Length() == 7 || !args[7]->IsObject()) { - return NanThrowError("Array parents is required."); - } - - if (args.Length() == 8 || !args[8]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - CreateCommitBaton* baton = new CreateCommitBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->id = (git_oid *)malloc(sizeof(git_oid )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_update_ref; - if (args[0]->IsString()) { - String::Utf8Value update_ref(args[0]->ToString()); - from_update_ref = strdup(*update_ref); - } else { - from_update_ref = 0; - } - baton->update_ref = from_update_ref; - const git_signature * from_author; - from_author = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->author = from_author; - const git_signature * from_committer; - from_committer = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->committer = from_committer; - const char * from_message_encoding; - if (args[3]->IsString()) { - String::Utf8Value message_encoding(args[3]->ToString()); - from_message_encoding = strdup(*message_encoding); - } else { - from_message_encoding = 0; - } - baton->message_encoding = from_message_encoding; - const char * from_message; - String::Utf8Value message(args[4]->ToString()); - from_message = strdup(*message); - baton->message = from_message; - const git_tree * from_tree; - from_tree = ObjectWrap::Unwrap(args[5]->ToObject())->GetValue(); - baton->tree = from_tree; - int from_parent_count; - from_parent_count = (int) args[6]->ToInt32()->Value(); - baton->parent_count = from_parent_count; - const git_commit ** from_parents; - Array *tmp_parents = Array::Cast(*args[7]); - 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(NanNew(static_cast(i)))->ToObject())->GetValue(); - } - baton->parents = from_parents; - - NanCallback *callback = new NanCallback(Local::Cast(args[8])); - CreateCommitWorker *worker = new CreateCommitWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("update_ref", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("author", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("committer", args[2]->ToObject()); - if (!args[3]->IsUndefined() && !args[3]->IsNull()) - worker->SaveToPersistent("message_encoding", args[3]->ToObject()); - if (!args[4]->IsUndefined() && !args[4]->IsNull()) - worker->SaveToPersistent("message", args[4]->ToObject()); - if (!args[5]->IsUndefined() && !args[5]->IsNull()) - worker->SaveToPersistent("tree", args[5]->ToObject()); - if (!args[6]->IsUndefined() && !args[6]->IsNull()) - worker->SaveToPersistent("parent_count", args[6]->ToObject()); - if (!args[7]->IsUndefined() && !args[7]->IsNull()) - worker->SaveToPersistent("parents", args[7]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::CreateCommitWorker::Execute() { - 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 && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::CreateCommitWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->id != NULL) { - to = GitOid::New((void *)baton->id); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->id); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->update_ref); - free((void *)baton->message_encoding); - free((void *)baton->message); - free((void *)baton->parents); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - * @param {Number} type - * @param {Object} callback - */ -NAN_METHOD(GitRepo::GetObject) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError("Number type is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetObjectBaton* baton = new GetObjectBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - git_otype from_type; - from_type = (git_otype) args[1]->ToInt32()->Value(); - baton->type = from_type; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - GetObjectWorker *worker = new GetObjectWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("type", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetObjectWorker::Execute() { - int result = git_object_lookup( - &baton->object, - baton->repo, - baton->id, - baton->type - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetObjectWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->object != NULL) { - to = GitObject::New((void *)baton->object); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} name - * @param {Reference} callback - */ -NAN_METHOD(GitRepo::GetReference) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetReferenceBaton* baton = new GetReferenceBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - baton->name = from_name; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetReferenceWorker *worker = new GetReferenceWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("name", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetReferenceWorker::Execute() { - int result = git_reference_lookup( - &baton->out, - baton->repo, - baton->name - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetReferenceWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitReference::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->name); - delete baton; -} - -/** - * @param {String} name - * @param {String} target - * @param {Number} force - * @return {Reference} out - */ -NAN_METHOD(GitRepo::CreateSymbolicReference) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String target is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - git_reference * out = 0; - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - const char * from_target; - String::Utf8Value target(args[1]->ToString()); - from_target = strdup(*target); - int from_force; - 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 - ); - free((void *)from_name); - free((void *)from_target); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} name - * @param {Oid} id - * @param {Number} force - * @return {Reference} out - */ -NAN_METHOD(GitRepo::CreateReference) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Oid id is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - git_reference * out = 0; - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - int from_force; - from_force = (int) args[2]->ToInt32()->Value(); - - int result = git_reference_create( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_name - , from_id - , from_force - ); - free((void *)from_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitReference::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {String} name - * @param {String} url - * @param {Remote} callback - */ -NAN_METHOD(GitRepo::AddRemote) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String url is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - AddRemoteBaton* baton = new AddRemoteBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - baton->name = from_name; - const char * from_url; - String::Utf8Value url(args[1]->ToString()); - from_url = strdup(*url); - baton->url = from_url; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - AddRemoteWorker *worker = new AddRemoteWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("name", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("url", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::AddRemoteWorker::Execute() { - int result = git_remote_create( - &baton->out, - baton->repo, - baton->name, - baton->url - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::AddRemoteWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitRemote::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->name); - free((void *)baton->url); - delete baton; -} - -/** - * @return {RevWalk} out - */ -NAN_METHOD(GitRepo::CreateRevWalk) { - NanScope(); - - git_revwalk * out = 0; - - int result = git_revwalk_new( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitRevWalk::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} name - * @return {Submodule} submodule - */ -NAN_METHOD(GitRepo::GetSubmodule) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - - git_submodule * submodule = 0; - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - - int result = git_submodule_lookup( - &submodule - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_name - ); - free((void *)from_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (submodule != NULL) { - to = GitSubmodule::New((void *)submodule); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} url - * @param {String} path - * @param {Number} use_gitlink - * @return {Submodule} submodule - */ -NAN_METHOD(GitRepo::AddSubmodule) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String path is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number use_gitlink is required."); - } - - git_submodule * submodule = 0; - const char * from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - const char * from_path; - String::Utf8Value path(args[1]->ToString()); - from_path = strdup(*path); - int from_use_gitlink; - 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 - ); - free((void *)from_url); - free((void *)from_path); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (submodule != NULL) { - to = GitSubmodule::New((void *)submodule); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - * @param {Tag} callback - */ -NAN_METHOD(GitRepo::GetTag) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetTagBaton* baton = new GetTagBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetTagWorker *worker = new GetTagWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetTagWorker::Execute() { - int result = git_tag_lookup( - &baton->out, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetTagWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitTag::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} tag_name - * @param {Object} target - * @param {Signature} tagger - * @param {String} message - * @param {Number} force - * @param {Oid} callback - */ -NAN_METHOD(GitRepo::CreateTag) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String tag_name is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Object target is required."); - } - if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError("Signature tagger is required."); - } - if (args.Length() == 3 || !args[3]->IsString()) { - return NanThrowError("String message is required."); - } - if (args.Length() == 4 || !args[4]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - if (args.Length() == 5 || !args[5]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - CreateTagBaton* baton = new CreateTagBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->oid = (git_oid *)malloc(sizeof(git_oid )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_tag_name; - String::Utf8Value tag_name(args[0]->ToString()); - from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - const git_object * from_target; - from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->target = from_target; - const git_signature * from_tagger; - from_tagger = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->tagger = from_tagger; - const char * from_message; - String::Utf8Value message(args[3]->ToString()); - from_message = strdup(*message); - baton->message = from_message; - int from_force; - from_force = (int) args[4]->ToInt32()->Value(); - baton->force = from_force; - - NanCallback *callback = new NanCallback(Local::Cast(args[5])); - CreateTagWorker *worker = new CreateTagWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("tag_name", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("target", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("tagger", args[2]->ToObject()); - if (!args[3]->IsUndefined() && !args[3]->IsNull()) - worker->SaveToPersistent("message", args[3]->ToObject()); - if (!args[4]->IsUndefined() && !args[4]->IsNull()) - worker->SaveToPersistent("force", args[4]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::CreateTagWorker::Execute() { - 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 && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::CreateTagWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->oid != NULL) { - to = GitOid::New((void *)baton->oid); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->oid); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->tag_name); - free((void *)baton->message); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} tag_name - * @param {Object} target - * @param {Number} force - * @param {Oid} callback - */ -NAN_METHOD(GitRepo::CreateLightweightTag) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String tag_name is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Object target is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number force is required."); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - CreateLightweightTagBaton* baton = new CreateLightweightTagBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->oid = (git_oid *)malloc(sizeof(git_oid )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_tag_name; - String::Utf8Value tag_name(args[0]->ToString()); - from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - const git_object * from_target; - from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->target = from_target; - int from_force; - from_force = (int) args[2]->ToInt32()->Value(); - baton->force = from_force; - - NanCallback *callback = new NanCallback(Local::Cast(args[3])); - CreateLightweightTagWorker *worker = new CreateLightweightTagWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("tag_name", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("target", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("force", args[2]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::CreateLightweightTagWorker::Execute() { - 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 && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::CreateLightweightTagWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->oid != NULL) { - to = GitOid::New((void *)baton->oid); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->oid); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->tag_name); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - * @param {Tree} callback - */ -NAN_METHOD(GitRepo::GetTree) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetTreeBaton* baton = new GetTreeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetTreeWorker *worker = new GetTreeWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetTreeWorker::Execute() { - int result = git_tree_lookup( - &baton->out, - baton->repo, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetTreeWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitTree::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitRepo::ReloadSubmodules) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ReloadSubmodulesBaton* baton = new ReloadSubmodulesBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - ReloadSubmodulesWorker *worker = new ReloadSubmodulesWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::ReloadSubmodulesWorker::Execute() { - int result = git_submodule_reload_all( - baton->repo - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::ReloadSubmodulesWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} tag_name - */ -NAN_METHOD(GitRepo::Delete) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String tag_name is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DeleteBaton* baton = new DeleteBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_tag_name; - String::Utf8Value tag_name(args[0]->ToString()); - from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - DeleteWorker *worker = new DeleteWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("tag_name", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::DeleteWorker::Execute() { - int result = git_tag_delete( - baton->repo, - baton->tag_name - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::DeleteWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->tag_name); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Number} list_flags - * @param {Array} callback - */ -NAN_METHOD(GitRepo::GetReferences) { - NanScope(); - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetReferencesBaton* baton = new GetReferencesBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->array = (git_strarray *)malloc(sizeof(git_strarray )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - unsigned int from_list_flags; - if (args[0]->IsUint32()) { - from_list_flags = (unsigned int) args[0]->ToUint32()->Value(); - } else { - from_list_flags = 0; - } - baton->list_flags = from_list_flags; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetReferencesWorker *worker = new GetReferencesWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("list_flags", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetReferencesWorker::Execute() { - int result = git_reference_list( - baton->array, - baton->repo, - baton->list_flags - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetReferencesWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - - Local tmpArray = NanNew(baton->array->count); - for (unsigned int i = 0; i < baton->array->count; i++) { - tmpArray->Set(NanNew(i), NanNew(baton->array->strings[i])); - } - to = tmpArray; - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->array); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - - git_strarray_free(baton->array); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Buffer} buffer - * @param {Number} len - * @param {Oid} callback - */ -NAN_METHOD(GitRepo::CreateBlobFromBuffer) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Buffer buffer is required."); - } - if (args.Length() == 1 || !args[1]->IsNumber()) { - return NanThrowError("Number len is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - CreateBlobFromBufferBaton* baton = new CreateBlobFromBufferBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->oid = (git_oid *)malloc(sizeof(git_oid )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const void * from_buffer; - from_buffer = Buffer::Data(args[0]->ToObject()); - baton->buffer = from_buffer; - size_t from_len; - from_len = (size_t) args[1]->ToNumber()->Value(); - baton->len = from_len; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - CreateBlobFromBufferWorker *worker = new CreateBlobFromBufferWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("buffer", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("len", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::CreateBlobFromBufferWorker::Execute() { - int result = git_blob_create_frombuffer( - baton->oid, - baton->repo, - baton->buffer, - baton->len - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::CreateBlobFromBufferWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->oid != NULL) { - to = GitOid::New((void *)baton->oid); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->oid); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} path - * @param {Oid} callback - */ -NAN_METHOD(GitRepo::CreateBlobFromFile) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - CreateBlobFromFileBaton* baton = new CreateBlobFromFileBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->id = (git_oid *)malloc(sizeof(git_oid )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - CreateBlobFromFileWorker *worker = new CreateBlobFromFileWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("path", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::CreateBlobFromFileWorker::Execute() { - int result = git_blob_create_fromdisk( - baton->id, - baton->repo, - baton->path - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::CreateBlobFromFileWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->id != NULL) { - to = GitOid::New((void *)baton->id); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->id); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->path); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Array} callback - */ -NAN_METHOD(GitRepo::GetRemotes) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetRemotesBaton* baton = new GetRemotesBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->out = (git_strarray *)malloc(sizeof(git_strarray )); - baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - GetRemotesWorker *worker = new GetRemotesWorker(baton, callback); - worker->SaveToPersistent("repo", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::GetRemotesWorker::Execute() { - int result = git_remote_list( - baton->out, - baton->repo - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::GetRemotesWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - - Local tmpArray = NanNew(baton->out->count); - for (unsigned int i = 0; i < baton->out->count; i++) { - tmpArray->Set(NanNew(i), NanNew(baton->out->strings[i])); - } - to = tmpArray; - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->out); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - - git_strarray_free(baton->out); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} url - * @param {String} local_path - * @param {CloneOptions} options - * @param {Repository} callback - */ -NAN_METHOD(GitRepo::Clone) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String local_path is required."); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - CloneBaton* baton = new CloneBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - const char * from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - baton->url = from_url; - const char * from_local_path; - String::Utf8Value local_path(args[1]->ToString()); - from_local_path = strdup(*local_path); - baton->local_path = from_local_path; - const git_clone_options * from_options; - if (args[2]->IsObject()) { - from_options = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_options = 0; - } - baton->options = from_options; - - NanCallback *callback = new NanCallback(Local::Cast(args[3])); - CloneWorker *worker = new CloneWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("url", args[0]->ToObject()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("local_path", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("options", args[2]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRepo::CloneWorker::Execute() { - int result = git_clone( - &baton->out, - baton->url, - baton->local_path, - baton->options - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRepo::CloneWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitRepo::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->url); - free((void *)baton->local_path); - delete baton; -} - -/** - * @param {String} name - * @return {Remote} out - */ -NAN_METHOD(GitRepo::GetRemote) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - - git_remote * out = 0; - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - - int result = git_remote_load( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_name - ); - free((void *)from_name); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitRemote::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -Persistent GitRepo::constructor_template; diff --git a/src/revwalk.cc b/src/revwalk.cc deleted file mode 100755 index 61430026f..000000000 --- a/src/revwalk.cc +++ /dev/null @@ -1,753 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/revwalk.h" -#include "../include/oid.h" -#include "../include/repo.h" - -using namespace v8; -using namespace node; - -GitRevWalk::GitRevWalk(git_revwalk *raw) { - this->raw = raw; -} - -GitRevWalk::~GitRevWalk() { - git_revwalk_free(this->raw); -} - -void GitRevWalk::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("RevWalk")); - - 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, "sorting", Sorting); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("RevWalk"), _constructor_template); -} - -NAN_METHOD(GitRevWalk::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_revwalk is required."); - } - GitRevWalk* object = new GitRevWalk(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitRevWalk::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitRevWalk::constructor_template)->NewInstance(1, argv)); -} - -git_revwalk *GitRevWalk::GetValue() { - return this->raw; -} - - -/** - */ -NAN_METHOD(GitRevWalk::Reset) { - NanScope(); - - - git_revwalk_reset( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} id - */ -NAN_METHOD(GitRevWalk::Push) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - PushBaton* baton = new PushBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - PushWorker *worker = new PushWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::PushWorker::Execute() { - int result = git_revwalk_push( - baton->walk, - baton->id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::PushWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} glob - */ -NAN_METHOD(GitRevWalk::PushGlob) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String glob is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - PushGlobBaton* baton = new PushGlobBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_glob; - String::Utf8Value glob(args[0]->ToString()); - from_glob = strdup(*glob); - baton->glob = from_glob; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - PushGlobWorker *worker = new PushGlobWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("glob", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::PushGlobWorker::Execute() { - int result = git_revwalk_push_glob( - baton->walk, - baton->glob - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::PushGlobWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->glob); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitRevWalk::PushHead) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - PushHeadBaton* baton = new PushHeadBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - PushHeadWorker *worker = new PushHeadWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::PushHeadWorker::Execute() { - int result = git_revwalk_push_head( - baton->walk - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::PushHeadWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} commit_id - */ -NAN_METHOD(GitRevWalk::Hide) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid commit_id is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - HideBaton* baton = new HideBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_oid * from_commit_id; - from_commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->commit_id = from_commit_id; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - HideWorker *worker = new HideWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("commit_id", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::HideWorker::Execute() { - int result = git_revwalk_hide( - baton->walk, - baton->commit_id - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::HideWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} glob - */ -NAN_METHOD(GitRevWalk::HideGlob) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String glob is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - HideGlobBaton* baton = new HideGlobBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_glob; - String::Utf8Value glob(args[0]->ToString()); - from_glob = strdup(*glob); - baton->glob = from_glob; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - HideGlobWorker *worker = new HideGlobWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("glob", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::HideGlobWorker::Execute() { - int result = git_revwalk_hide_glob( - baton->walk, - baton->glob - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::HideGlobWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->glob); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitRevWalk::HideHead) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - HideHeadBaton* baton = new HideHeadBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - HideHeadWorker *worker = new HideHeadWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::HideHeadWorker::Execute() { - int result = git_revwalk_hide_head( - baton->walk - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::HideHeadWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} refname - */ -NAN_METHOD(GitRevWalk::PushRef) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String refname is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - PushRefBaton* baton = new PushRefBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_refname; - String::Utf8Value refname(args[0]->ToString()); - from_refname = strdup(*refname); - baton->refname = from_refname; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - PushRefWorker *worker = new PushRefWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("refname", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::PushRefWorker::Execute() { - int result = git_revwalk_push_ref( - baton->walk, - baton->refname - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::PushRefWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->refname); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {String} refname - */ -NAN_METHOD(GitRevWalk::HideRef) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String refname is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - HideRefBaton* baton = new HideRefBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_refname; - String::Utf8Value refname(args[0]->ToString()); - from_refname = strdup(*refname); - baton->refname = from_refname; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - HideRefWorker *worker = new HideRefWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("refname", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::HideRefWorker::Execute() { - int result = git_revwalk_hide_ref( - baton->walk, - baton->refname - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::HideRefWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->refname); - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Oid} callback - */ -NAN_METHOD(GitRevWalk::Next) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - NextBaton* baton = new NextBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->out = (git_oid *)malloc(sizeof(git_oid )); - baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - NextWorker *worker = new NextWorker(baton, callback); - worker->SaveToPersistent("walk", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitRevWalk::NextWorker::Execute() { - int result = git_revwalk_next( - baton->out, - baton->walk - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitRevWalk::NextWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitOid::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->out); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - * @param {Number} sort_mode - */ -NAN_METHOD(GitRevWalk::Sorting) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number sort_mode is required."); - } - - unsigned int from_sort_mode; - from_sort_mode = (unsigned int) args[0]->ToUint32()->Value(); - - git_revwalk_sorting( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_sort_mode - ); - - NanReturnUndefined(); -} - -Persistent GitRevWalk::constructor_template; diff --git a/src/signature.cc b/src/signature.cc deleted file mode 100755 index 26d181901..000000000 --- a/src/signature.cc +++ /dev/null @@ -1,214 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/signature.h" -#include "../include/time.h" - -using namespace v8; -using namespace node; - -GitSignature::GitSignature(git_signature *raw) { - this->raw = raw; -} - -GitSignature::~GitSignature() { - git_signature_free(this->raw); -} - -void GitSignature::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Signature")); - - NODE_SET_METHOD(tpl, "create", Create); - 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, "time", Time); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Signature"), _constructor_template); -} - -NAN_METHOD(GitSignature::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_signature is required."); - } - GitSignature* object = new GitSignature(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitSignature::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitSignature::constructor_template)->NewInstance(1, argv)); -} - -git_signature *GitSignature::GetValue() { - return this->raw; -} - - -/** - * @param {String} name - * @param {String} email - * @param {Number} time - * @param {Number} offset - * @return {Signature} out - */ -NAN_METHOD(GitSignature::Create) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String email is required."); - } - if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError("Number time is required."); - } - if (args.Length() == 3 || !args[3]->IsInt32()) { - return NanThrowError("Number offset is required."); - } - - git_signature * out = 0; - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - const char * from_email; - String::Utf8Value email(args[1]->ToString()); - from_email = strdup(*email); - git_time_t from_time; - from_time = (git_time_t) args[2]->ToInt32()->Value(); - int from_offset; - from_offset = (int) args[3]->ToInt32()->Value(); - - int result = git_signature_new( - &out - , from_name - , from_email - , from_time - , from_offset - ); - free((void *)from_name); - free((void *)from_email); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitSignature::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} name - * @param {String} email - * @return {Signature} out - */ -NAN_METHOD(GitSignature::Now) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String name is required."); - } - if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError("String email is required."); - } - - git_signature * out = 0; - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - const char * from_email; - String::Utf8Value email(args[1]->ToString()); - from_email = strdup(*email); - - int result = git_signature_now( - &out - , from_name - , from_email - ); - free((void *)from_name); - free((void *)from_email); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitSignature::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -NAN_METHOD(GitSignature::Name) { - NanScope(); - Handle to; - - const char * name = - ObjectWrap::Unwrap(args.This())->GetValue()->name; - - to = NanNew(name); - NanReturnValue(to); -} - -NAN_METHOD(GitSignature::Email) { - NanScope(); - Handle to; - - const char * email = - ObjectWrap::Unwrap(args.This())->GetValue()->email; - - to = NanNew(email); - NanReturnValue(to); -} - -NAN_METHOD(GitSignature::Time) { - NanScope(); - Handle to; - - git_time *when = - &ObjectWrap::Unwrap(args.This())->GetValue()->when; - - if (when != NULL) { - when = (git_time *)git_time_dup(when); - } - if (when != NULL) { - to = GitTime::New((void *)when); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -Persistent GitSignature::constructor_template; diff --git a/src/submodule.cc b/src/submodule.cc deleted file mode 100644 index 22a9c5806..000000000 --- a/src/submodule.cc +++ /dev/null @@ -1,743 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.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() { - free(this->raw); -} - -void GitSubmodule::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("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); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Submodule"), _constructor_template); -} - -NAN_METHOD(GitSubmodule::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_submodule is required."); - } - GitSubmodule* object = new GitSubmodule(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitSubmodule::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitSubmodule::constructor_template)->NewInstance(1, argv)); -} - -git_submodule *GitSubmodule::GetValue() { - return this->raw; -} - - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitSubmodule::AddFinalize) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - AddFinalizeBaton* baton = new AddFinalizeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - AddFinalizeWorker *worker = new AddFinalizeWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::AddFinalizeWorker::Execute() { - int result = git_submodule_add_finalize( - baton->submodule - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::AddFinalizeWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Number} write_index - */ -NAN_METHOD(GitSubmodule::AddToIndex) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number write_index is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - AddToIndexBaton* baton = new AddToIndexBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - int from_write_index; - from_write_index = (int) args[0]->ToInt32()->Value(); - baton->write_index = from_write_index; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - AddToIndexWorker *worker = new AddToIndexWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("write_index", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::AddToIndexWorker::Execute() { - int result = git_submodule_add_to_index( - baton->submodule, - baton->write_index - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::AddToIndexWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitSubmodule::Save) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - SaveBaton* baton = new SaveBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - SaveWorker *worker = new SaveWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::SaveWorker::Execute() { - int result = git_submodule_save( - baton->submodule - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::SaveWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - * @return {String} result - */ -NAN_METHOD(GitSubmodule::Name) { - NanScope(); - - - const char * result = git_submodule_name( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitSubmodule::Path) { - NanScope(); - - - const char * result = git_submodule_path( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitSubmodule::Url) { - NanScope(); - - - const char * result = git_submodule_url( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @param {String} url - */ -NAN_METHOD(GitSubmodule::SetUrl) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String url is required."); - } - - const char * from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - - int result = git_submodule_set_url( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_url - ); - free((void *)from_url); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitSubmodule::IndexId) { - NanScope(); - - - const git_oid * result = git_submodule_index_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitSubmodule::HeadId) { - NanScope(); - - - const git_oid * result = git_submodule_head_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Number} overwrite - */ -NAN_METHOD(GitSubmodule::Init) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number overwrite is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - InitBaton* baton = new InitBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - int from_overwrite; - from_overwrite = (int) args[0]->ToInt32()->Value(); - baton->overwrite = from_overwrite; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - InitWorker *worker = new InitWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("overwrite", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::InitWorker::Execute() { - int result = git_submodule_init( - baton->submodule, - baton->overwrite - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::InitWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitSubmodule::Sync) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - SyncBaton* baton = new SyncBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - SyncWorker *worker = new SyncWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::SyncWorker::Execute() { - int result = git_submodule_sync( - baton->submodule - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::SyncWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} callback - */ -NAN_METHOD(GitSubmodule::Open) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - OpenBaton* baton = new OpenBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - OpenWorker *worker = new OpenWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::OpenWorker::Execute() { - int result = git_submodule_open( - &baton->repo, - baton->submodule - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::OpenWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->repo != NULL) { - to = GitRepo::New((void *)baton->repo); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - */ -NAN_METHOD(GitSubmodule::Reload) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - ReloadBaton* baton = new ReloadBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - ReloadWorker *worker = new ReloadWorker(baton, callback); - worker->SaveToPersistent("submodule", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::ReloadWorker::Execute() { - int result = git_submodule_reload( - baton->submodule - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::ReloadWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Number} status - */ -NAN_METHOD(GitSubmodule::Status) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError("Number status is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - StatusBaton* baton = new StatusBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - unsigned int * from_status; - from_status = (unsigned int *) args[0]->ToInt32()->Value(); - baton->status = from_status; - baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - StatusWorker *worker = new StatusWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("status", args[0]->ToObject()); - worker->SaveToPersistent("submodule", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitSubmodule::StatusWorker::Execute() { - int result = git_submodule_status( - baton->status, - baton->submodule - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitSubmodule::StatusWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle result = NanUndefined(); - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -Persistent GitSubmodule::constructor_template; diff --git a/src/tag.cc b/src/tag.cc deleted file mode 100644 index 0717ab100..000000000 --- a/src/tag.cc +++ /dev/null @@ -1,297 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/tag.h" -#include "../include/oid.h" -#include "../include/repo.h" -#include "../include/object.h" -#include "../include/signature.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Tag")); - - NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - 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_PROTOTYPE_METHOD(tpl, "peel", Peel); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Tag"), _constructor_template); -} - -NAN_METHOD(GitTag::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_tag is required."); - } - GitTag* object = new GitTag(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitTag::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitTag::constructor_template)->NewInstance(1, argv)); -} - -git_tag *GitTag::GetValue() { - return this->raw; -} - - -/** - * @return {Oid} result - */ -NAN_METHOD(GitTag::Oid) { - NanScope(); - - - const git_oid * result = git_tag_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Object} callback - */ -NAN_METHOD(GitTag::GetTarget) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetTargetBaton* baton = new GetTargetBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->tag = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[0])); - GetTargetWorker *worker = new GetTargetWorker(baton, callback); - worker->SaveToPersistent("tag", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTag::GetTargetWorker::Execute() { - int result = git_tag_target( - &baton->target_out, - baton->tag - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTag::GetTargetWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->target_out != NULL) { - to = GitObject::New((void *)baton->target_out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitTag::TargetId) { - NanScope(); - - - const git_oid * result = git_tag_target_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitTag::TargetType) { - NanScope(); - - - git_otype result = git_tag_target_type( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((int32_t)result); - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitTag::Name) { - NanScope(); - - - const char * result = git_tag_name( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Signature} result - */ -NAN_METHOD(GitTag::Tagger) { - NanScope(); - - - const git_signature * result = git_tag_tagger( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_signature * )git_signature_dup(result); - } - if (result != NULL) { - to = GitSignature::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {String} result - */ -NAN_METHOD(GitTag::Message) { - NanScope(); - - - const char * result = git_tag_message( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @param {Tag} tag - * @return {Object} tag_target_out - */ -NAN_METHOD(GitTag::Peel) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Tag tag is required."); - } - - git_object * tag_target_out = 0; - const git_tag * from_tag; - from_tag = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - int result = git_tag_peel( - &tag_target_out - , from_tag - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (tag_target_out != NULL) { - to = GitObject::New((void *)tag_target_out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -Persistent GitTag::constructor_template; diff --git a/src/threads.cc b/src/threads.cc deleted file mode 100755 index 5e36ef1cd..000000000 --- a/src/threads.cc +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/threads.h" - -using namespace v8; -using namespace node; - -void GitThreads::Initialize(Handle target) { - NanScope(); - - Local object = NanNew(); - - NODE_SET_METHOD(object, "init", Init); - NODE_SET_METHOD(object, "shutdown", Shutdown); - - target->Set(NanNew("Threads"), object); -} - - -/** - */ -NAN_METHOD(GitThreads::Init) { - NanScope(); - - - int result = git_threads_init( - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -/** - */ -NAN_METHOD(GitThreads::Shutdown) { - NanScope(); - - - git_threads_shutdown( - ); - - NanReturnUndefined(); -} - diff --git a/src/time.cc b/src/time.cc deleted file mode 100644 index dd495947b..000000000 --- a/src/time.cc +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/time.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) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Time")); - - - NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); - NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Time"), _constructor_template); -} - -NAN_METHOD(GitTime::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_time is required."); - } - GitTime* object = new GitTime(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitTime::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitTime::constructor_template)->NewInstance(1, argv)); -} - -git_time *GitTime::GetValue() { - return this->raw; -} - - -NAN_METHOD(GitTime::Time) { - NanScope(); - Handle to; - - git_time_t time = - ObjectWrap::Unwrap(args.This())->GetValue()->time; - - to = NanNew(time); - NanReturnValue(to); -} - -NAN_METHOD(GitTime::Offset) { - NanScope(); - Handle to; - - int offset = - ObjectWrap::Unwrap(args.This())->GetValue()->offset; - - to = NanNew((int32_t)offset); - NanReturnValue(to); -} - -Persistent GitTime::constructor_template; diff --git a/src/tree.cc b/src/tree.cc deleted file mode 100755 index 3686e35da..000000000 --- a/src/tree.cc +++ /dev/null @@ -1,619 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/tree.h" -#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/tree_builder.h" -#include "../include/index.h" - -using namespace v8; -using namespace node; - -GitTree::GitTree(git_tree *raw) { - this->raw = raw; -} - -GitTree::~GitTree() { - git_tree_free(this->raw); -} - -void GitTree::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("Tree")); - - 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, "getEntry", GetEntry); - NODE_SET_PROTOTYPE_METHOD(tpl, "builder", Builder); - NODE_SET_PROTOTYPE_METHOD(tpl, "diffTree", DiffTree); - NODE_SET_PROTOTYPE_METHOD(tpl, "diffIndex", DiffIndex); - NODE_SET_PROTOTYPE_METHOD(tpl, "diffWorkDir", DiffWorkDir); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("Tree"), _constructor_template); -} - -NAN_METHOD(GitTree::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_tree is required."); - } - GitTree* object = new GitTree(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitTree::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitTree::constructor_template)->NewInstance(1, argv)); -} - -git_tree *GitTree::GetValue() { - return this->raw; -} - - -/** - * @return {Oid} result - */ -NAN_METHOD(GitTree::Oid) { - NanScope(); - - - const git_oid * result = git_tree_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitTree::Size) { - NanScope(); - - - size_t result = git_tree_entrycount( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @param {String} filename - * @return {TreeEntry} result - */ -NAN_METHOD(GitTree::EntryByName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String filename is required."); - } - - const char * from_filename; - String::Utf8Value filename(args[0]->ToString()); - from_filename = strdup(*filename); - - const git_tree_entry * result = git_tree_entry_byname( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_filename - ); - free((void *)from_filename); - - Handle to; - if (result != NULL) { - result = (const git_tree_entry * )git_tree_entry_dup(result); - } - if (result != NULL) { - to = GitTreeEntry::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Number} idx - * @return {TreeEntry} result - */ -NAN_METHOD(GitTree::EntryByIndex) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError("Number idx is required."); - } - - size_t from_idx; - from_idx = (size_t) args[0]->ToUint32()->Value(); - - const git_tree_entry * result = git_tree_entry_byindex( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_idx - ); - - Handle to; - if (result != NULL) { - result = (const git_tree_entry * )git_tree_entry_dup(result); - } - if (result != NULL) { - to = GitTreeEntry::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {Oid} oid - * @return {TreeEntry} result - */ -NAN_METHOD(GitTree::EntryByOid) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Oid oid is required."); - } - - const git_oid * from_oid; - from_oid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - const git_tree_entry * result = git_tree_entry_byoid( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_oid - ); - - Handle to; - if (result != NULL) { - result = (const git_tree_entry * )git_tree_entry_dup(result); - } - if (result != NULL) { - to = GitTreeEntry::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {String} path - * @param {TreeEntry} callback - */ -NAN_METHOD(GitTree::GetEntry) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String path is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetEntryBaton* baton = new GetEntryBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->root = ObjectWrap::Unwrap(args.This())->GetValue(); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetEntryWorker *worker = new GetEntryWorker(baton, callback); - worker->SaveToPersistent("root", args.This()); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("path", args[0]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTree::GetEntryWorker::Execute() { - int result = git_tree_entry_bypath( - &baton->out, - baton->root, - baton->path - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTree::GetEntryWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->out != NULL) { - to = GitTreeEntry::New((void *)baton->out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - free((void *)baton->path); - delete baton; -} - -/** - * @return {TreeBuilder} out - */ -NAN_METHOD(GitTree::Builder) { - NanScope(); - - git_treebuilder * out = 0; - - int result = git_treebuilder_create( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitTreeBuilder::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {Tree} new_tree - * @param {DiffOptions} opts - * @param {DiffList} callback - */ -NAN_METHOD(GitTree::DiffTree) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Tree new_tree is required."); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DiffTreeBaton* baton = new DiffTreeBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); - git_tree * from_new_tree; - from_new_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->new_tree = from_new_tree; - const git_diff_options * from_opts; - if (args[2]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - - NanCallback *callback = new NanCallback(Local::Cast(args[3])); - DiffTreeWorker *worker = new DiffTreeWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - worker->SaveToPersistent("old_tree", args.This()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("new_tree", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("opts", args[2]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTree::DiffTreeWorker::Execute() { - 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 && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTree::DiffTreeWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->diff != NULL) { - to = GitDiffList::New((void *)baton->diff); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {Index} index - * @param {DiffOptions} opts - * @param {DiffList} callback - */ -NAN_METHOD(GitTree::DiffIndex) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - - if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DiffIndexBaton* baton = new DiffIndexBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); - git_index * from_index; - if (args[1]->IsObject()) { - from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - from_index = 0; - } - baton->index = from_index; - const git_diff_options * from_opts; - if (args[2]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - - NanCallback *callback = new NanCallback(Local::Cast(args[3])); - DiffIndexWorker *worker = new DiffIndexWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - worker->SaveToPersistent("old_tree", args.This()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("index", args[1]->ToObject()); - if (!args[2]->IsUndefined() && !args[2]->IsNull()) - worker->SaveToPersistent("opts", args[2]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTree::DiffIndexWorker::Execute() { - 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 && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTree::DiffIndexWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->diff != NULL) { - to = GitDiffList::New((void *)baton->diff); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {DiffOptions} opts - * @param {DiffList} callback - */ -NAN_METHOD(GitTree::DiffWorkDir) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - - if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - DiffWorkDirBaton* baton = new DiffWorkDirBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); - const git_diff_options * from_opts; - if (args[1]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - - NanCallback *callback = new NanCallback(Local::Cast(args[2])); - DiffWorkDirWorker *worker = new DiffWorkDirWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - worker->SaveToPersistent("old_tree", args.This()); - if (!args[1]->IsUndefined() && !args[1]->IsNull()) - worker->SaveToPersistent("opts", args[1]->ToObject()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTree::DiffWorkDirWorker::Execute() { - int result = git_diff_tree_to_workdir( - &baton->diff, - baton->repo, - baton->old_tree, - baton->opts - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTree::DiffWorkDirWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->diff != NULL) { - to = GitDiffList::New((void *)baton->diff); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -Persistent GitTree::constructor_template; diff --git a/src/tree_builder.cc b/src/tree_builder.cc deleted file mode 100644 index fd08dda9d..000000000 --- a/src/tree_builder.cc +++ /dev/null @@ -1,346 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/tree_builder.h" -#include "../include/repo.h" -#include "../include/oid.h" -#include "../include/tree_entry.h" -#include "../include/tree.h" -#include "../include/diff_list.h" -#include "../include/diff_options.h" -#include "../include/index.h" - -using namespace v8; -using namespace node; - -GitTreeBuilder::GitTreeBuilder(git_treebuilder *raw) { - this->raw = raw; -} - -GitTreeBuilder::~GitTreeBuilder() { - git_treebuilder_free(this->raw); -} - -void GitTreeBuilder::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("TreeBuilder")); - - NODE_SET_METHOD(tpl, "create", Create); - NODE_SET_PROTOTYPE_METHOD(tpl, "clear", Clear); - NODE_SET_METHOD(tpl, "size", Size); - NODE_SET_PROTOTYPE_METHOD(tpl, "get", Get); - NODE_SET_PROTOTYPE_METHOD(tpl, "insert", Insert); - NODE_SET_PROTOTYPE_METHOD(tpl, "gitTreebuilderRemove", GitTreebuilderRemove); - NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("TreeBuilder"), _constructor_template); -} - -NAN_METHOD(GitTreeBuilder::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_treebuilder is required."); - } - GitTreeBuilder* object = new GitTreeBuilder(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitTreeBuilder::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitTreeBuilder::constructor_template)->NewInstance(1, argv)); -} - -git_treebuilder *GitTreeBuilder::GetValue() { - return this->raw; -} - - -/** - * @param {Tree} source - * @return {TreeBuilder} out - */ -NAN_METHOD(GitTreeBuilder::Create) { - NanScope(); - - git_treebuilder * out = 0; - const git_tree * from_source; - if (args[0]->IsObject()) { - from_source = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - } else { - from_source = 0; - } - - int result = git_treebuilder_create( - &out - , from_source - ); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - to = GitTreeBuilder::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {TreeBuilder} bld - */ -NAN_METHOD(GitTreeBuilder::Clear) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("TreeBuilder bld is required."); - } - - git_treebuilder * from_bld; - from_bld = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - git_treebuilder_clear( - from_bld - ); - - NanReturnUndefined(); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitTreeBuilder::Size) { - NanScope(); - - - unsigned int result = git_treebuilder_entrycount( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew((uint32_t)result); - NanReturnValue(to); -} - -/** - * @param {String} filename - * @return {TreeEntry} result - */ -NAN_METHOD(GitTreeBuilder::Get) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String filename is required."); - } - - const char * from_filename; - String::Utf8Value filename(args[0]->ToString()); - from_filename = strdup(*filename); - - const git_tree_entry * result = git_treebuilder_get( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_filename - ); - free((void *)from_filename); - - Handle to; - if (result != NULL) { - result = (const git_tree_entry * )git_tree_entry_dup(result); - } - if (result != NULL) { - to = GitTreeEntry::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} filename - * @param {Oid} id - * @param {Number} filemode - * @return {TreeEntry} out - */ -NAN_METHOD(GitTreeBuilder::Insert) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String filename is required."); - } - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError("Oid id is required."); - } - if (args.Length() == 2 || !args[2]->IsNumber()) { - return NanThrowError("Number filemode is required."); - } - - const git_tree_entry * out = 0; - const char * from_filename; - String::Utf8Value filename(args[0]->ToString()); - from_filename = strdup(*filename); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - git_filemode_t from_filemode; - from_filemode = (git_filemode_t) (int) args[2]->ToNumber()->Value(); - - int result = git_treebuilder_insert( - &out - , ObjectWrap::Unwrap(args.This())->GetValue() - , from_filename - , from_id - , from_filemode - ); - free((void *)from_filename); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - Handle to; - if (out != NULL) { - out = (const git_tree_entry * )git_tree_entry_dup(out); - } - if (out != NULL) { - to = GitTreeEntry::New((void *)out); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @param {String} filename - */ -NAN_METHOD(GitTreeBuilder::GitTreebuilderRemove) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError("String filename is required."); - } - - const char * from_filename; - String::Utf8Value filename(args[0]->ToString()); - from_filename = strdup(*filename); - - int result = git_treebuilder_remove( - ObjectWrap::Unwrap(args.This())->GetValue() - , from_filename - ); - free((void *)from_filename); - if (result != GIT_OK) { - if (giterr_last()) { - return NanThrowError(giterr_last()->message); - } else { - return NanThrowError("Unknown Error"); - } - } - - NanReturnUndefined(); -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {Oid} callback - */ -NAN_METHOD(GitTreeBuilder::Write) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - WriteBaton* baton = new WriteBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - baton->id = (git_oid *)malloc(sizeof(git_oid )); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->bld = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - WriteWorker *worker = new WriteWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - worker->SaveToPersistent("bld", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTreeBuilder::WriteWorker::Execute() { - int result = git_treebuilder_write( - baton->id, - baton->repo, - baton->bld - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTreeBuilder::WriteWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->id != NULL) { - to = GitOid::New((void *)baton->id); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - free(baton->id); - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -Persistent GitTreeBuilder::constructor_template; diff --git a/src/tree_entry.cc b/src/tree_entry.cc deleted file mode 100755 index 10fe341fc..000000000 --- a/src/tree_entry.cc +++ /dev/null @@ -1,222 +0,0 @@ -/** - * This code is auto-generated; unless you know what you're doing, do not modify! - **/ -#include -#include - -#include "git2.h" - -#include "../include/functions/copy.h" - -#include "../include/tree_entry.h" -#include "../include/oid.h" -#include "../include/repo.h" -#include "../include/object.h" - -using namespace v8; -using namespace node; - -GitTreeEntry::GitTreeEntry(git_tree_entry *raw) { - this->raw = raw; -} - -GitTreeEntry::~GitTreeEntry() { - git_tree_entry_free(this->raw); -} - -void GitTreeEntry::Initialize(Handle target) { - NanScope(); - - Local tpl = NanNew(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanNew("TreeEntry")); - - NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); - NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); - NODE_SET_PROTOTYPE_METHOD(tpl, "filemode", filemode); - NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); - - - Local _constructor_template = tpl->GetFunction(); - NanAssignPersistent(constructor_template, _constructor_template); - target->Set(NanNew("TreeEntry"), _constructor_template); -} - -NAN_METHOD(GitTreeEntry::New) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError("git_tree_entry is required."); - } - GitTreeEntry* object = new GitTreeEntry(static_cast(Handle::Cast(args[0])->Value())); - object->Wrap(args.This()); - - NanReturnValue(args.This()); -} - -Handle GitTreeEntry::New(void *raw) { - NanEscapableScope(); - Handle argv[1] = { NanNew((void *)raw) }; - return NanEscapeScope(NanNew(GitTreeEntry::constructor_template)->NewInstance(1, argv)); -} - -git_tree_entry *GitTreeEntry::GetValue() { - return this->raw; -} - - -/** - * @return {String} result - */ -NAN_METHOD(GitTreeEntry::Name) { - NanScope(); - - - const char * result = git_tree_entry_name( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Oid} result - */ -NAN_METHOD(GitTreeEntry::Oid) { - NanScope(); - - - const git_oid * result = git_tree_entry_id( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - if (result != NULL) { - result = (const git_oid * )git_oid_dup(result); - } - if (result != NULL) { - to = GitOid::New((void *)result); - } else { - to = NanNull(); - } - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitTreeEntry::Type) { - NanScope(); - - - git_otype result = git_tree_entry_type( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -/** - * @return {Number} result - */ -NAN_METHOD(GitTreeEntry::filemode) { - NanScope(); - - - git_filemode_t result = git_tree_entry_filemode( - ObjectWrap::Unwrap(args.This())->GetValue() - ); - - Handle to; - to = NanNew(result); - NanReturnValue(to); -} - -#include "../include/functions/copy.h" - -/** - * @param {Repository} repo - * @param {Object} callback - */ -NAN_METHOD(GitTreeEntry::GetObject) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError("Repository repo is required."); - } - - if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError("Callback is required and must be a Function."); - } - - GetObjectBaton* baton = new GetObjectBaton; - baton->error_code = GIT_OK; - baton->error = NULL; - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - baton->entry = ObjectWrap::Unwrap(args.This())->GetValue(); - - NanCallback *callback = new NanCallback(Local::Cast(args[1])); - GetObjectWorker *worker = new GetObjectWorker(baton, callback); - if (!args[0]->IsUndefined() && !args[0]->IsNull()) - worker->SaveToPersistent("repo", args[0]->ToObject()); - worker->SaveToPersistent("entry", args.This()); - - NanAsyncQueueWorker(worker); - NanReturnUndefined(); -} - -void GitTreeEntry::GetObjectWorker::Execute() { - int result = git_tree_entry_to_object( - &baton->object_out, - baton->repo, - baton->entry - ); - baton->error_code = result; - if (result != GIT_OK && giterr_last() != NULL) { - baton->error = git_error_dup(giterr_last()); - } -} - -void GitTreeEntry::GetObjectWorker::HandleOKCallback() { - TryCatch try_catch; - if (baton->error_code == GIT_OK) { - Handle to; - if (baton->object_out != NULL) { - to = GitObject::New((void *)baton->object_out); - } else { - to = NanNull(); - } - Handle result = to; - Handle argv[2] = { - NanNull(), - result - }; - callback->Call(2, argv); - } else { - if (baton->error) { - Handle argv[1] = { - NanError(baton->error->message) - }; - callback->Call(1, argv); - if (baton->error->message) - free((void *)baton->error->message); - free((void *)baton->error); - } else { - callback->Call(0, NULL); - } - } - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete baton; -} - -Persistent GitTreeEntry::constructor_template; From 494d87aa662b438985ffde291a4fb12695422894 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Fri, 20 Jun 2014 16:01:46 -0400 Subject: [PATCH 2/3] Ensure code is generated before attempting to install. --- install.js | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/install.js b/install.js index 24dad171f..9ba6671ce 100644 --- a/install.js +++ b/install.js @@ -137,6 +137,8 @@ var dependencies = Q.allSettled([ console.info('[nodegit] Failed to build nodegit.'); console.info('[nodegit] Attempting to fallback on a prebuilt binary.'); + console.log(message.stack); + function fetchPrebuilt() { console.info('[nodegit] Fetching binary from S3.'); diff --git a/package.json b/package.json index feede962c..68737a73c 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ }, "scripts": { "lint": "jshint src", - "install": "node install.js", + "install": "npm run codegen && node install.js", "test": "cd test && nodeunit nodegit.js", "codegen": "node build/codegen/generate.js", "publish": "node-pre-gyp package && node-pre-gyp publish" From 94c2a027f7682b09885b4071c35929a9558f03bd Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sun, 22 Jun 2014 14:48:28 -0400 Subject: [PATCH 3/3] Fixed missing source from copy.cc. --- src/functions/copy.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/functions/copy.cc b/src/functions/copy.cc index 0effadb2c..d534c3da0 100644 --- a/src/functions/copy.cc +++ b/src/functions/copy.cc @@ -45,3 +45,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; +}