Permalink
Browse files

updated to use scope.Close everywhere fixes #19

  • Loading branch information...
1 parent 06b8da9 commit 9cd642e9995d899a65a9b384fd8384059d3dc400 @tbranyen tbranyen committed May 14, 2011
Showing with 98 additions and 91 deletions.
  1. +3 −0 Makefile
  2. +1 −1 include/oid.h
  3. +12 −12 src/commit.cc
  4. +4 −4 src/error.cc
  5. +8 −8 src/object.cc
  6. +23 −20 src/oid.cc
  7. +6 −5 src/reference.cc
  8. +13 −13 src/repo.cc
  9. +10 −10 src/revwalk.cc
  10. +5 −5 src/sig.cc
  11. +8 −8 src/tree.cc
  12. +5 −5 src/tree_entry.cc
View
@@ -17,6 +17,9 @@ config:
build:
@@$(NODE_BLD) build
+debug:
+ @@$(NODE_BLD) debug
+
install:
@@mkdir -p $(INSTALL_PATH)
@@mkdir -p $(INSTALL_PATH)/build/default
View
@@ -24,7 +24,7 @@ class GitOid : public EventEmitter {
int Mkstr(const char* str);
void Mkraw(const unsigned char* raw);
- char* Fmt(char* buffer);
+ void Fmt(char* buffer);
void PathFmt(char *str);
char* AllocFmt();
char* ToString(char* buffer, size_t bufferSize);
View
@@ -143,7 +143,7 @@ Handle<Value> GitCommit::Lookup(const Arguments& args) {
eio_custom(EIO_Lookup, EIO_PRI_DEFAULT, EIO_AfterLookup, ar);
ev_ref(EV_DEFAULT_UC);
- return Undefined();
+ return scope.Close( Undefined() );
}
int GitCommit::EIO_Lookup(eio_req *req) {
@@ -185,7 +185,7 @@ Handle<Value> GitCommit::Close(const Arguments& args) {
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());
commit->Close();
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitCommit::Id(const Arguments& args) {
@@ -201,39 +201,39 @@ Handle<Value> GitCommit::Id(const Arguments& args) {
oid->SetValue(*const_cast<git_oid *>(commit->Id()));
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitCommit::MessageShort(const Arguments& args) {
HandleScope scope;
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());
- return String::New(commit->MessageShort());
+ return scope.Close( String::New(commit->MessageShort()) );
}
Handle<Value> GitCommit::Message(const Arguments& args) {
HandleScope scope;
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());
- return String::New(commit->Message());
+ return scope.Close( String::New(commit->Message()) );
}
Handle<Value> GitCommit::Time(const Arguments& args) {
HandleScope scope;
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());
- return Integer::New(commit->Time());
+ return scope.Close( Integer::New(commit->Time()) );
}
Handle<Value> GitCommit::TimeOffset(const Arguments& args) {
HandleScope scope;
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());
- return Integer::New(commit->TimeOffset());
+ return scope.Close( Integer::New(commit->TimeOffset()) );
}
Handle<Value> GitCommit::Committer(const Arguments& args) {
@@ -249,7 +249,7 @@ Handle<Value> GitCommit::Committer(const Arguments& args) {
sig->SetValue(const_cast<git_signature *>(commit->Committer()));
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitCommit::Author(const Arguments& args) {
@@ -265,7 +265,7 @@ Handle<Value> GitCommit::Author(const Arguments& args) {
sig->SetValue(const_cast<git_signature *>(commit->Author()));
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitCommit::Tree(const Arguments& args) {
@@ -283,7 +283,7 @@ Handle<Value> GitCommit::Tree(const Arguments& args) {
int err = commit->Tree(&tree);
g_tree->SetValue(tree);
- return scope.Close(Integer::New(err));
+ return scope.Close( Integer::New(err) );
}
Handle<Value> GitCommit::ParentCount(const Arguments& args) {
@@ -293,7 +293,7 @@ Handle<Value> GitCommit::ParentCount(const Arguments& args) {
unsigned int count = commit->ParentCount();
- return Integer::New(count);
+ return scope.Close( Integer::New(count) );
}
Handle<Value> GitCommit::Parent(const Arguments& args) {
@@ -316,7 +316,7 @@ Handle<Value> GitCommit::Parent(const Arguments& args) {
int err = commit->Parent(&in, index);
out->SetValue(in);
- return Integer::New(err);
+ return scope.Close( Integer::New(err) );
}
Persistent<FunctionTemplate> GitCommit::constructor_template;
View
@@ -38,21 +38,21 @@ Handle<Value> GitError::New(const Arguments& args) {
GitError *error = new GitError();
error->Wrap(args.This());
- return args.This();
+ return scope.Close( args.This() );
}
Handle<Value> GitError::StrError(const Arguments& args) {
- GitError* error = ObjectWrap::Unwrap<GitError>(args.This());
-
HandleScope scope;
+ GitError* error = ObjectWrap::Unwrap<GitError>(args.This());
+
if(args.Length() == 0 || !args[0]->IsNumber()) {
return ThrowException(Exception::Error(String::New("Error is required and must be a Number.")));
}
Local<Integer> err = Local<Integer>::Cast(args[0]);
- return String::New(error->StrError(err->Value()));
+ return scope.Close( String::New(error->StrError(err->Value())) );
}
Persistent<FunctionTemplate> GitError::constructor_template;
View
@@ -93,7 +93,7 @@ Handle<Value> GitObject::New(const Arguments& args) {
obj->Wrap(args.This());
- return args.This();
+ return scope.Close( args.This() );
}
Handle<Value> GitObject::Id(const Arguments& args) {
@@ -109,15 +109,15 @@ Handle<Value> GitObject::Id(const Arguments& args) {
oid->SetValue(*const_cast<git_oid *>(obj->Id()));
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitObject::Type(const Arguments& args) {
HandleScope scope;
GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
- return Integer::New(obj->Type());
+ return scope.Close( Integer::New(obj->Type()) );
}
Handle<Value> GitObject::Owner(const Arguments& args) {
@@ -133,7 +133,7 @@ Handle<Value> GitObject::Owner(const Arguments& args) {
repo->SetValue(obj->Owner());
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitObject::Type2String(const Arguments& args) {
@@ -147,7 +147,7 @@ Handle<Value> GitObject::Type2String(const Arguments& args) {
git_otype type = (git_otype)args[0]->ToInteger()->Value();
- return String::New(obj->Type2String(type));
+ return scope.Close( String::New(obj->Type2String(type)) );
}
Handle<Value> GitObject::String2Type(const Arguments& args) {
@@ -161,7 +161,7 @@ Handle<Value> GitObject::String2Type(const Arguments& args) {
String::Utf8Value type(args[0]);
- return Integer::New(obj->String2Type(*type));
+ return scope.Close( Integer::New(obj->String2Type(*type)) );
}
Handle<Value> GitObject::TypeIsLoose(const Arguments& args) {
@@ -175,7 +175,7 @@ Handle<Value> GitObject::TypeIsLoose(const Arguments& args) {
git_otype type = (git_otype)args[0]->ToInteger()->Value();
- return Integer::New(obj->TypeIsLoose(type));
+ return scope.Close( Integer::New(obj->TypeIsLoose(type)) );
}
Handle<Value> GitObject::Size(const Arguments& args) {
@@ -189,7 +189,7 @@ Handle<Value> GitObject::Size(const Arguments& args) {
git_otype type = (git_otype)args[0]->ToInteger()->Value();
- return Integer::New(obj->Size(type));
+ return scope.Close( Integer::New(obj->Size(type)) );
}
Persistent<FunctionTemplate> GitObject::constructor_template;
View
@@ -50,7 +50,7 @@ void GitOid::Mkraw(const unsigned char* raw) {
git_oid_mkraw(&this->oid, raw);
}
-char* GitOid::Fmt(char* buffer) {
+void GitOid::Fmt(char* buffer) {
git_oid_fmt(buffer, &this->oid);
}
@@ -98,60 +98,63 @@ Handle<Value> GitOid::Mkstr(const Arguments& args) {
}
Handle<Value> GitOid::Mkraw(const Arguments& args) {
- GitOid* oid = ObjectWrap::Unwrap<GitOid>(args.This());
-
HandleScope scope;
+ GitOid* oid = ObjectWrap::Unwrap<GitOid>(args.This());
+
if(args.Length() == 0 || !args[0]->IsString()) {
return ThrowException(Exception::Error(String::New("Raw object id is required.")));
}
- String::Utf8Value raw(Local<Value>::New(args[0]));
+ String::Utf8Value raw(args[0]);
oid->Mkraw((const unsigned char*)*raw);
- return Local<Value>::New(args.This());
+ return scope.Close( args.This() );
}
Handle<Value> GitOid::Fmt(const Arguments& args) {
- GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
-
HandleScope scope;
- char buffer[32];
+ GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
+
+ char buffer[40];
oid->Fmt(buffer);
- return String::New(buffer);
+
+ return scope.Close( String::New(buffer) );
}
Handle<Value> GitOid::PathFmt(const Arguments& args) {
- GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
-
HandleScope scope;
+ GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
+
char buffer[41];
oid->PathFmt(buffer);
- return String::New(buffer);
+
+ return scope.Close( String::New(buffer) );
}
Handle<Value> GitOid::AllocFmt(const Arguments& args) {
- GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
-
HandleScope scope;
- return String::New(oid->AllocFmt());
+ GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
+
+ return scope.Close( String::New(oid->AllocFmt()) );
}
Handle<Value> GitOid::ToString(const Arguments& args) {
- GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
-
HandleScope scope;
+
+ GitOid *oid = ObjectWrap::Unwrap<GitOid>(args.This());
if(args.Length() == 0 || !args[0]->IsNumber()) {
return ThrowException(Exception::Error(String::New("Length argument is required and must be a Number.")));
}
char buffer[Int32::Cast(*args[0])->Value()+1];
oid->ToString(buffer, sizeof(buffer));
- return String::New(buffer);
+
+ return scope.Close( String::New(buffer) );
}
Handle<Value> GitOid::Cpy(const Arguments& args) {
@@ -169,7 +172,7 @@ Handle<Value> GitOid::Cpy(const Arguments& args) {
oid->Cpy(out);
clone->SetValue(*out);
- return Undefined();
+ return scope.Close( Undefined() );
}
Handle<Value> GitOid::Cmp(const Arguments& args) {
@@ -191,6 +194,6 @@ Handle<Value> GitOid::Cmp(const Arguments& args) {
//int cmp = oid->Cmp(&a->GetValue(), &b->GetValue());
int cmp = 0;
- return Integer::New(cmp);
+ return scope.Close( Integer::New(cmp) );
}
Persistent<FunctionTemplate> GitOid::constructor_template;
View
@@ -58,11 +58,11 @@ Handle<Value> GitReference::New(const Arguments& args) {
}
Handle<Value> GitReference::Lookup(const Arguments& args) {
+ HandleScope scope;
+
GitReference *ref = ObjectWrap::Unwrap<GitReference>(args.This());
Local<Function> callback;
- HandleScope scope;
-
if(args.Length() == 0 || !args[0]->IsObject()) {
return ThrowException(Exception::Error(String::New("Repo is required and must be a Object.")));
}
@@ -91,7 +91,7 @@ Handle<Value> GitReference::Lookup(const Arguments& args) {
eio_custom(EIO_Lookup, EIO_PRI_DEFAULT, EIO_AfterLookup, ar);
ev_ref(EV_DEFAULT_UC);
- return Undefined();
+ return scope.Close( Undefined() );
}
int GitReference::EIO_Lookup(eio_req *req) {
@@ -129,9 +129,10 @@ int GitReference::EIO_AfterLookup(eio_req *req) {
}
Handle<Value> GitReference::Oid(const Arguments& args) {
- GitReference *ref = ObjectWrap::Unwrap<GitReference>(args.This());
HandleScope scope;
+ GitReference *ref = ObjectWrap::Unwrap<GitReference>(args.This());
+
if(args.Length() == 0 || !args[0]->IsObject()) {
return ThrowException(Exception::Error(String::New("Oid is required and must be an Object.")));
}
@@ -140,6 +141,6 @@ Handle<Value> GitReference::Oid(const Arguments& args) {
git_oid* in = const_cast<git_oid *>(ref->Oid());
oid->SetValue(*in);
- return Undefined();
+ return scope.Close( Undefined() );
}
Persistent<FunctionTemplate> GitReference::constructor_template;
Oops, something went wrong.

0 comments on commit 9cd642e

Please sign in to comment.