| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,2 @@ | |||
| 1 | - - audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. | ||
| 2 | - - free everything malloc'd, or figure out the right coding conventions for copying. | ||
| 3 | 1 | - codegen documentation | |
| 4 | - - audit return types for things that should be copied | ||
| 5 | 2 | - array handling | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,9 @@ | |||
| 31 | 31 | 'src/refdb.cc', | |
| 32 | 32 | 'src/odb_object.cc', | |
| 33 | 33 | 'src/odb.cc', | |
| 34 | - 'src/submodule.cc' | ||
| 34 | + 'src/submodule.cc', | ||
| 35 | + 'src/functions/copy.cc', | ||
| 36 | + | ||
| 35 | 37 | ], | |
| 36 | 38 | ||
| 37 | 39 | 'include_dirs': [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + #include <v8.h> | ||
| 2 | + | ||
| 3 | + #include "git2.h" | ||
| 4 | + | ||
| 5 | + #ifndef COPY_FUNCTIONS | ||
| 6 | + #define COPY_FUNCTIONS | ||
| 7 | + | ||
| 8 | + const git_oid *git_oid_dup(const git_oid *arg); | ||
| 9 | + const git_index_entry *git_index_entry_dup(const git_index_entry *arg); | ||
| 10 | + const git_index_time *git_index_time_dup(const git_index_time *arg); | ||
| 11 | + const git_time *git_time_dup(const git_time *arg); | ||
| 12 | + const git_diff_delta *git_diff_delta_dup(const git_diff_delta *arg); | ||
| 13 | + const git_diff_file *git_diff_file_dup(const git_diff_file *arg); | ||
| 14 | + | ||
| 15 | + #endif | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,6 @@ class GitObject : public ObjectWrap { | |||
| 33 | 33 | ||
| 34 | 34 | static Handle<Value> Oid(const Arguments& args); | |
| 35 | 35 | static Handle<Value> Type(const Arguments& args); | |
| 36 | - static Handle<Value> Owner(const Arguments& args); | ||
| 37 | 36 | static Handle<Value> Peel(const Arguments& args); | |
| 38 | 37 | static void PeelWork(uv_work_t* req); | |
| 39 | 38 | static void PeelAfterWork(uv_work_t* req); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,6 @@ var git = require('../'), | |||
| 3 | 3 | ConvenientPatch = require('./convenient_patch').ConvenientPatch, | |
| 4 | 4 | events = require('events'); | |
| 5 | 5 | ||
| 6 | - console.log(ConvenientPatch); | ||
| 7 | - | ||
| 8 | 6 | /** | |
| 9 | 7 | * Refer to vendor/libgit2/include/git2/diff.h for delta type definitions. | |
| 10 | 8 | * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,52 @@ | |||
| 1 | 1 | var fs = require('fs'), | |
| 2 | - _ = require('underscore'), | ||
| 3 | 2 | path = require('path'); | |
| 4 | 3 | ||
| 4 | + var ds = new RegExp('\\*\\*'); | ||
| 5 | + | ||
| 5 | 6 | var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')); | |
| 6 | 7 | ||
| 8 | + var types2free = {}; | ||
| 9 | + | ||
| 10 | + var oidFns = "git_blob_id git_commit_id git_commit_tree_id git_commit_parent_id git_indexer_stream_hash git_note_oid git_object_id git_odb_object_id git_reflog_entry_id_old git_reflog_entry_id_new git_reference_target git_submodule_index_id git_submodule_head_id git_submodule_wd_id git_tag_id git_tag_target_id git_tree_entry_id git_tree_id".split(' '); | ||
| 11 | + | ||
| 12 | + for (var i in idefs) { | ||
| 13 | + var idef = idefs[i]; | ||
| 14 | + | ||
| 15 | + for (var f in idef.functions) { | ||
| 16 | + var fn = idef.functions[f]; | ||
| 17 | + | ||
| 18 | + if (oidFns.indexOf(fn.cFunctionName) > -1) { | ||
| 19 | + fn.return.copy = "git_oid_dup"; | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + console.log(JSON.stringify(idefs, null, 2)); | ||
| 24 | + | ||
| 25 | + return; | ||
| 26 | + | ||
| 7 | 27 | for (var i in idefs) { | |
| 8 | 28 | var idef = idefs[i]; | |
| 29 | + types2free[idef.cType] = idef.freeFunctionName; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + for (var t in types2free) { | ||
| 33 | + var re = new RegExp(t); | ||
| 9 | 34 | ||
| 10 | - for (var j in idef.functions) { | ||
| 11 | - var fn = idef.functions[j]; | ||
| 12 | - if (!fn.isConstructorMethod) continue; | ||
| 13 | - fn.args[0].isReturn = true; | ||
| 35 | + for (var i in idefs) { | ||
| 36 | + var idef = idefs[i]; | ||
| 37 | + | ||
| 38 | + for (var f in idef.fields) { | ||
| 39 | + var fn = idef.functions[f]; | ||
| 40 | + | ||
| 41 | + for (var a in fn.args) { | ||
| 42 | + var arg = fn.args[a]; | ||
| 43 | + | ||
| 44 | + if (t == "git_oid" && arg.isReturn && re.test(arg.cType) && !ds.test(arg.cType)) { | ||
| 45 | + arg.shouldAlloc = true; | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + } | ||
| 14 | 49 | } | |
| 15 | 50 | } | |
| 16 | 51 | console.log(JSON.stringify(idefs, null, 2)); | |
| 52 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | 8 | #include "git2.h" | |
| 9 | 9 | ||
| 10 | + #include "../include/functions/copy.h" | ||
| 11 | + | ||
| 10 | 12 | #include "../include/blob.h" | |
| 11 | 13 | #include "../include/repo.h" | |
| 12 | 14 | #include "../include/oid.h" | |
@@ -77,7 +79,8 @@ Handle<Value> GitBlob::Oid(const Arguments& args) { | |||
| 77 | 79 | ); | |
| 78 | 80 | ||
| 79 | 81 | Handle<Value> to; | |
| 80 | - to = GitOid::New((void *)result); | ||
| 82 | + result = (const git_oid * )git_oid_dup(result); | ||
| 83 | + to = GitOid::New((void *)result); | ||
| 81 | 84 | return scope.Close(to); | |
| 82 | 85 | } | |
| 83 | 86 | ||
@@ -124,6 +127,7 @@ Handle<Value> GitBlob::CreateFromFile(const Arguments& args) { | |||
| 124 | 127 | baton->error_code = GIT_OK; | |
| 125 | 128 | baton->error = NULL; | |
| 126 | 129 | baton->request.data = baton; | |
| 130 | + baton->id = (git_oid *)malloc(sizeof(git_oid )); | ||
| 127 | 131 | baton->repoReference = Persistent<Value>::New(args[0]); | |
| 128 | 132 | git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[0]->ToObject())->GetValue(); | |
| 129 | 133 | baton->repo = from_repo; | |
@@ -204,6 +208,7 @@ Handle<Value> GitBlob::CreateFromBuffer(const Arguments& args) { | |||
| 204 | 208 | baton->error_code = GIT_OK; | |
| 205 | 209 | baton->error = NULL; | |
| 206 | 210 | baton->request.data = baton; | |
| 211 | + baton->oid = (git_oid *)malloc(sizeof(git_oid )); | ||
| 207 | 212 | baton->repoReference = Persistent<Value>::New(args[0]); | |
| 208 | 213 | git_repository * from_repo = ObjectWrap::Unwrap<GitRepo>(args[0]->ToObject())->GetValue(); | |
| 209 | 214 | baton->repo = from_repo; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | 8 | #include "git2.h" | |
| 9 | 9 | ||
| 10 | + #include "../include/functions/copy.h" | ||
| 11 | + | ||
| 10 | 12 | #include "../include/branch.h" | |
| 11 | 13 | ||
| 12 | 14 | using namespace v8; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | 8 | #include "git2.h" | |
| 9 | 9 | ||
| 10 | + #include "../include/functions/copy.h" | ||
| 11 | + | ||
| 10 | 12 | #include "../include/commit.h" | |
| 11 | 13 | #include "../include/oid.h" | |
| 12 | 14 | #include "../include/repo.h" | |
@@ -82,7 +84,8 @@ Handle<Value> GitCommit::Oid(const Arguments& args) { | |||
| 82 | 84 | ); | |
| 83 | 85 | ||
| 84 | 86 | Handle<Value> to; | |
| 85 | - to = GitOid::New((void *)result); | ||
| 87 | + result = (const git_oid * )git_oid_dup(result); | ||
| 88 | + to = GitOid::New((void *)result); | ||
| 86 | 89 | return scope.Close(to); | |
| 87 | 90 | } | |
| 88 | 91 | ||
@@ -147,7 +150,8 @@ Handle<Value> GitCommit::Committer(const Arguments& args) { | |||
| 147 | 150 | ); | |
| 148 | 151 | ||
| 149 | 152 | Handle<Value> to; | |
| 150 | - to = GitSignature::New((void *)result); | ||
| 153 | + result = (const git_signature * )git_signature_dup(result); | ||
| 154 | + to = GitSignature::New((void *)result); | ||
| 151 | 155 | return scope.Close(to); | |
| 152 | 156 | } | |
| 153 | 157 | ||
@@ -160,7 +164,8 @@ Handle<Value> GitCommit::Author(const Arguments& args) { | |||
| 160 | 164 | ); | |
| 161 | 165 | ||
| 162 | 166 | Handle<Value> to; | |
| 163 | - to = GitSignature::New((void *)result); | ||
| 167 | + result = (const git_signature * )git_signature_dup(result); | ||
| 168 | + to = GitSignature::New((void *)result); | ||
| 164 | 169 | return scope.Close(to); | |
| 165 | 170 | } | |
| 166 | 171 | ||
@@ -173,7 +178,8 @@ Handle<Value> GitCommit::TreeId(const Arguments& args) { | |||
| 173 | 178 | ); | |
| 174 | 179 | ||
| 175 | 180 | Handle<Value> to; | |
| 176 | - to = GitOid::New((void *)result); | ||
| 181 | + result = (const git_oid * )git_oid_dup(result); | ||
| 182 | + to = GitOid::New((void *)result); | ||
| 177 | 183 | return scope.Close(to); | |
| 178 | 184 | } | |
| 179 | 185 | ||
@@ -204,7 +210,8 @@ Handle<Value> GitCommit::ParentId(const Arguments& args) { | |||
| 204 | 210 | ); | |
| 205 | 211 | ||
| 206 | 212 | Handle<Value> to; | |
| 207 | - to = GitOid::New((void *)result); | ||
| 213 | + result = (const git_oid * )git_oid_dup(result); | ||
| 214 | + to = GitOid::New((void *)result); | ||
| 208 | 215 | return scope.Close(to); | |
| 209 | 216 | } | |
| 210 | 217 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments