Skip to content

Commit 2d3b9b6

Browse files
committed
Tag now code-gen'd
1 parent c20ee68 commit 2d3b9b6

File tree

18 files changed

+1190
-711
lines changed

18 files changed

+1190
-711
lines changed

binding.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
'src/reference.cc',
1212
'src/object.cc',
1313
'src/repo.cc',
14+
'src/index.cc',
15+
'src/tag.cc',
1416
'src/revwalk.cc',
1517
'src/signature.cc',
1618
'src/time.cc',

gen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')),
88

99
for (var i in idefs) {
1010
var idef = idefs[i];
11-
if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index"].indexOf(idef.jsClassName) > -1) {
11+
if (["Oid", "Blob", "Repo", "Reference", "Object", "TreeEntry", "Commit", "Signature", "Time", "Index", "Tag"].indexOf(idef.jsClassName) > -1) {
1212
fs.writeFileSync(
1313
path.resolve("./include/" + idef.filename), headerTemplate(idef));
1414
fs.writeFileSync(

include/index.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* This code is auto-generated; unless you know what you're doing, do not modify!
33
**/
44

5-
#ifndef INDEX_H
6-
#define INDEX_H
5+
#ifndef GITINDEX_H
6+
#define GITINDEX_H
77

88
#include <v8.h>
99
#include <node.h>
@@ -14,7 +14,7 @@
1414
using namespace node;
1515
using namespace v8;
1616

17-
class Index : public ObjectWrap {
17+
class GitIndex : public ObjectWrap {
1818
public:
1919

2020
static Persistent<Function> constructor_template;
@@ -23,8 +23,8 @@ class Index : public ObjectWrap {
2323
git_index *GetValue();
2424

2525
private:
26-
Index(git_index *raw);
27-
~Index();
26+
GitIndex(git_index *raw);
27+
~GitIndex();
2828

2929
static Handle<Value> New(const Arguments& args);
3030

@@ -41,7 +41,6 @@ class Index : public ObjectWrap {
4141
const char * index_path;
4242
Persistent<Function> callback;
4343
};
44-
static Handle<Value> New(const Arguments& args);
4544
static Handle<Value> Owner(const Arguments& args);
4645
static Handle<Value> Read(const Arguments& args);
4746
static void ReadWork(uv_work_t* req);

include/odb.h

Lines changed: 0 additions & 58 deletions
This file was deleted.

include/tag.h

Lines changed: 95 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,109 @@
11
/**
2-
* Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
3-
* @author Michael Robinson @codeofinterest <mike@pagesofinterest.net>
4-
*
5-
* Dual licensed under the MIT and GPL licenses.
6-
*/
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
74

8-
#ifndef TAG_H
9-
#define TAG_H
5+
#ifndef GITTAG_H
6+
#define GITTAG_H
107

8+
#include <v8.h>
119
#include <node.h>
10+
#include <string>
1211

1312
#include "git2.h"
1413

1514
using namespace node;
15+
using namespace v8;
1616

17-
/**
18-
* Class: GitTag
19-
* Wrapper for libgit2 git_error.
20-
*/
2117
class GitTag : public ObjectWrap {
2218
public:
23-
/**
24-
* Variable: constructor_template
25-
* Used to create Node.js constructor.
26-
*/
27-
static v8::Persistent<v8::FunctionTemplate> constructor_template;
28-
/**
29-
* Function: Initialize
30-
* Used to intialize the EventEmitter from Node.js
31-
*
32-
* Parameters:
33-
* target - v8::Object the Node.js global module object
34-
*/
35-
static void Initialize(v8::Handle<v8::Object> target);
36-
37-
protected:
38-
/**
39-
* Constructor: GitTag
40-
*/
41-
GitTag() {};
42-
/**
43-
* Deconstructor: GitTag
44-
*/
45-
~GitTag() {};
46-
/**
47-
* Function: New
48-
*
49-
* Parameters:
50-
* args v8::Arguments function call
51-
*
52-
* Returns:
53-
* v8::Object args.This()
54-
*/
55-
static v8::Handle<v8::Value> New(const v8::Arguments& args);
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_tag *GetValue();
24+
25+
private:
26+
GitTag(git_tag *raw);
27+
~GitTag();
28+
29+
static Handle<Value> New(const Arguments& args);
30+
31+
32+
static Handle<Value> Lookup(const Arguments& args);
33+
static void LookupWork(uv_work_t* req);
34+
static void LookupAfterWork(uv_work_t* req);
35+
36+
struct LookupBaton {
37+
uv_work_t request;
38+
const git_error* error;
39+
git_tag * out;
40+
Persistent<Value> repoReference;
41+
git_repository * repo;
42+
Persistent<Value> idReference;
43+
const git_oid * id;
44+
Persistent<Function> callback;
45+
};
46+
static Handle<Value> Oid(const Arguments& args);
47+
static Handle<Value> Target(const Arguments& args);
48+
static void TargetWork(uv_work_t* req);
49+
static void TargetAfterWork(uv_work_t* req);
50+
51+
struct TargetBaton {
52+
uv_work_t request;
53+
const git_error* error;
54+
git_object * target_out;
55+
Persistent<Value> tagReference;
56+
const git_tag * tag;
57+
Persistent<Function> callback;
58+
};
59+
static Handle<Value> TargetId(const Arguments& args);
60+
static Handle<Value> TargetType(const Arguments& args);
61+
static Handle<Value> Name(const Arguments& args);
62+
static Handle<Value> Tagger(const Arguments& args);
63+
static Handle<Value> Message(const Arguments& args);
64+
static Handle<Value> Create(const Arguments& args);
65+
static void CreateWork(uv_work_t* req);
66+
static void CreateAfterWork(uv_work_t* req);
67+
68+
struct CreateBaton {
69+
uv_work_t request;
70+
const git_error* error;
71+
git_oid * oid;
72+
Persistent<Value> repoReference;
73+
git_repository * repo;
74+
Persistent<Value> tag_nameReference;
75+
const char * tag_name;
76+
Persistent<Value> targetReference;
77+
const git_object * target;
78+
Persistent<Value> taggerReference;
79+
const git_signature * tagger;
80+
Persistent<Value> messageReference;
81+
const char * message;
82+
Persistent<Value> forceReference;
83+
int force;
84+
Persistent<Function> callback;
85+
};
86+
static Handle<Value> CreateLightweight(const Arguments& args);
87+
static void CreateLightweightWork(uv_work_t* req);
88+
static void CreateLightweightAfterWork(uv_work_t* req);
89+
90+
struct CreateLightweightBaton {
91+
uv_work_t request;
92+
const git_error* error;
93+
git_oid * oid;
94+
Persistent<Value> repoReference;
95+
git_repository * repo;
96+
Persistent<Value> tag_nameReference;
97+
const char * tag_name;
98+
Persistent<Value> targetReference;
99+
const git_object * target;
100+
Persistent<Value> forceReference;
101+
int force;
102+
Persistent<Function> callback;
103+
};
104+
static Handle<Value> Delete(const Arguments& args);
105+
static Handle<Value> Peel(const Arguments& args);
106+
git_tag *raw;
56107
};
57108

58109
#endif

src/base.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "../include/tree_entry.h"
2626
#include "../include/diff_list.h"
2727
#include "../include/threads.h"
28+
#include "../include/index.h"
29+
#include "../include/tag.h"
2830

2931
extern "C" void init(Handle<v8::Object> target) {
3032
HandleScope scope;
@@ -34,6 +36,8 @@ extern "C" void init(Handle<v8::Object> target) {
3436
GitError::Initialize(target);
3537

3638
GitReference::Initialize(target);
39+
GitIndex::Initialize(target);
40+
GitTag::Initialize(target);
3741
GitSignature::Initialize(target);
3842
GitTime::Initialize(target);
3943
GitBlob::Initialize(target);

src/blob.cc

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ Handle<Value> GitBlob::Lookup(const Arguments& args) {
9595

9696
void GitBlob::LookupWork(uv_work_t *req) {
9797
LookupBaton *baton = static_cast<LookupBaton *>(req->data);
98-
int result = git_blob_lookup(
98+
int blob = git_blob_lookup(
9999
&baton->blob,
100100
baton->repo,
101101
baton->id
102102
);
103-
if (result != GIT_OK) {
103+
if (blob != GIT_OK) {
104104
baton->error = giterr_last();
105105
}
106106
}
@@ -137,11 +137,13 @@ void GitBlob::LookupAfterWork(uv_work_t *req) {
137137
Handle<Value> GitBlob::Oid(const Arguments& args) {
138138
HandleScope scope;
139139

140-
const git_oid * result = git_blob_id(
140+
const git_oid * result = git_blob_id(
141+
141142

142143
ObjectWrap::Unwrap<GitBlob>(args.This())->GetValue()
143144
);
144145

146+
145147
// XXX need to copy object?
146148
Handle<Value> argv[1] = { External::New((void *)result) };
147149
return scope.Close(GitOid::constructor_template->NewInstance(1, argv));
@@ -150,11 +152,13 @@ Handle<Value> GitBlob::Oid(const Arguments& args) {
150152
Handle<Value> GitBlob::Content(const Arguments& args) {
151153
HandleScope scope;
152154

153-
const void * result = git_blob_rawcontent(
155+
const void * result = git_blob_rawcontent(
156+
154157

155158
ObjectWrap::Unwrap<GitBlob>(args.This())->GetValue()
156159
);
157160

161+
158162
// XXX need to copy object?
159163
Handle<Value> argv[1] = { External::New((void *)result) };
160164
return scope.Close(Wrapper::constructor_template->NewInstance(1, argv));
@@ -163,11 +167,13 @@ Handle<Value> GitBlob::Content(const Arguments& args) {
163167
Handle<Value> GitBlob::Size(const Arguments& args) {
164168
HandleScope scope;
165169

166-
git_off_t result = git_blob_rawsize(
170+
git_off_t result = git_blob_rawsize(
171+
167172

168173
ObjectWrap::Unwrap<GitBlob>(args.This())->GetValue()
169174
);
170175

176+
171177
return scope.Close(Number::New(result));
172178
}
173179

@@ -201,12 +207,12 @@ Handle<Value> GitBlob::CreateFromFile(const Arguments& args) {
201207

202208
void GitBlob::CreateFromFileWork(uv_work_t *req) {
203209
CreateFromFileBaton *baton = static_cast<CreateFromFileBaton *>(req->data);
204-
int result = git_blob_create_fromdisk(
210+
int id = git_blob_create_fromdisk(
205211
baton->id,
206212
baton->repo,
207213
baton->path
208214
);
209-
if (result != GIT_OK) {
215+
if (id != GIT_OK) {
210216
baton->error = giterr_last();
211217
}
212218
}
@@ -275,13 +281,13 @@ Handle<Value> GitBlob::CreateFromBuffer(const Arguments& args) {
275281

276282
void GitBlob::CreateFromBufferWork(uv_work_t *req) {
277283
CreateFromBufferBaton *baton = static_cast<CreateFromBufferBaton *>(req->data);
278-
int result = git_blob_create_frombuffer(
284+
int oid = git_blob_create_frombuffer(
279285
baton->oid,
280286
baton->repo,
281287
baton->buffer,
282288
baton->len
283289
);
284-
if (result != GIT_OK) {
290+
if (oid != GIT_OK) {
285291
baton->error = giterr_last();
286292
}
287293
}
@@ -319,14 +325,16 @@ void GitBlob::CreateFromBufferAfterWork(uv_work_t *req) {
319325
Handle<Value> GitBlob::IsBinary(const Arguments& args) {
320326
HandleScope scope;
321327

322-
int result = git_blob_is_binary(
328+
int result = git_blob_is_binary(
329+
323330

324331
ObjectWrap::Unwrap<GitBlob>(args.This())->GetValue()
325332
);
326333

327334
if (result != GIT_OK) {
328335
return ThrowException(GitError::WrapError(giterr_last()));
329336
}
337+
330338
return scope.Close(Boolean::New(result));
331339
}
332340

0 commit comments

Comments
 (0)