Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed object

  • Loading branch information...
commit 628a944e831efd95d9adebfd85873da666b078bc 1 parent 0c2abc9
@faceleg faceleg authored
View
1  binding.gyp
@@ -7,7 +7,6 @@
'src/blob.cc',
'src/commit.cc',
'src/error.cc',
- 'src/object.cc',
'src/oid.cc',
'src/reference.cc',
'src/repo.cc',
View
1  include/blob.h
@@ -15,6 +15,7 @@
#include "git2.h"
#include "repo.h"
+#include "oid.h"
using namespace v8;
using namespace node;
View
3  include/diff_list.h
@@ -13,7 +13,8 @@
#include "git2.h"
-#include "../include/repo.h"
+#include "repo.h"
+#include "oid.h"
using namespace node;
using namespace v8;
View
95 include/object.h
@@ -1,95 +0,0 @@
-/*
- * Copyright 2013, Tim Branyen @tbranyen <tim@tabdeveloper.com>
- * @author Michael Robinson @codeofinterest <mike@pagesofinterest.net>
- *
- * Dual licensed under the MIT and GPL licenses.
- */
-
-#ifndef OBJ_H
-#define OBJ_H
-
-#include <v8.h>
-#include <node.h>
-
-#include "git2.h"
-
-#include "repo.h"
-#include "oid.h"
-
-using namespace node;
-
-/**
- * Class wrapper for libgit2 git_object
- */
-class GitObject : public ObjectWrap {
- public:
- /**
- * v8::FunctionTemplate used to create Node.js constructor
- */
- static Persistent<Function> constructor_template;
-
- /**
- * Used to intialize the EventEmitter from Node.js
- *
- * @param target v8::Object the Node.js module object
- */
- static void Initialize(Handle<v8::Object> target);
-
- /**
- * Accessor for Object
- *
- * @return the internal git_object reference
- */
- git_object* GetValue();
-
- /**
- * Mutator for Object
- *
- * @param obj a git_object object
- */
- void SetValue(git_object* obj);
-
- const git_oid* Id();
- git_otype Type();
-
- git_repository* Owner();
- const char* Type2String(git_otype type);
- git_otype String2Type(const char* type);
- int TypeIsLoose(git_otype type);
- size_t Size(git_otype type);
-
- protected:
- /**
- * Constructor
- */
- GitObject() {};
-
- /**
- * Deconstructor
- */
- ~GitObject() {};
-
- /**
- * Mutator for GitObject
- *
- * @param args v8::Arguments function call arguments from Node.js
- *
- * @return v8::Object args.This()
- */
- static Handle<Value> New(const Arguments& args);
- static Handle<Value> Id(const Arguments& args);
- static Handle<Value> Type(const Arguments& args);
- static Handle<Value> Owner(const Arguments& args);
- static Handle<Value> Type2String(const Arguments& args);
- static Handle<Value> String2Type(const Arguments& args);
- static Handle<Value> TypeIsLoose(const Arguments& args);
- static Handle<Value> Size(const Arguments& args);
-
- private:
- /**
- * Internal reference to git_object object
- */
- git_object* obj;
-};
-
-#endif
View
3  include/repo.h
@@ -14,8 +14,6 @@
#include "git2.h"
-#include "object.h"
-
using namespace node;
using namespace v8;
@@ -27,7 +25,6 @@ class GitRepo : public ObjectWrap {
git_repository* GetValue();
void SetValue(git_repository* repo);
- // Synchronous
void Free();
protected:
View
1  include/tree_entry.h
@@ -17,7 +17,6 @@
#include "repo.h"
#include "tree.h"
#include "oid.h"
-#include "object.h"
using namespace v8;
using namespace node;
View
1  lib/index.js
@@ -14,7 +14,6 @@ exports.blob = require('./blob.js').blob;
exports.repo = require('./repo.js').repo;
exports.signature = require('./signature.js').signature;
exports.oid = require('./oid.js').oid;
-exports.object = require('./object.js').object;
exports.reference = require('./reference.js').reference;
exports.revwalk = require('./revwalk.js').revwalk;
exports.commit = require('./commit.js').commit;
View
71 lib/object.js
@@ -1,71 +0,0 @@
-var git = require( '../' );
-
-var _Object = function( obj ) {
- var self = {};
-
- if( object instanceof git.raw.Object ) {
- self.object = obj;
- }
- else {
- self.object = new git.raw.Object();
- }
-
- Object.defineProperty( self, 'id', {
- get: function() {
- },
- enumerable: true
- });
-
- Object.defineProperty( self, 'type', {
- get: function() {
- return self.object.type();
- },
- enumerable: true
- });
-
- Object.defineProperty( self, 'length', {
- get: function() {
- return self.object.size();
- },
- enumerable: true
- });
-
- Object.defineProperty( self, 'isLoose', {
- get: function() {
- return self.object.typeIsLoose();
- },
- enumerable: true
- });
-
- self.id = function() {
- var oid = git.oid();
-
- self.object.id( oid.oid );
-
- return oid;
- };
-
- self.owner = function() {
- var repo = git.repo();
-
- self.object.owner( repo.repo );
-
- return repo;
- };
-
- self.toString = function() {
- return self.object.type2String();
- };
-
- self.toType = function( type ) {
- return self.object.toType( type );
- };
-
- self.free = function() {
- return self.object.free();
- };
-
- return self;
-};
-
-exports.object = _Object;
View
2  src/base.cc
@@ -16,7 +16,6 @@
#include "../include/blob.h"
#include "../include/repo.h"
#include "../include/oid.h"
-#include "../include/object.h"
#include "../include/commit.h"
#include "../include/revwalk.h"
#include "../include/tree.h"
@@ -33,7 +32,6 @@ extern "C" void init(Handle<v8::Object> target) {
GitSignature::Initialize(target);
GitBlob::Initialize(target);
GitOid::Initialize(target);
- GitObject::Initialize(target);
GitRepo::Initialize(target);
GitCommit::Initialize(target);
GitRevWalk::Initialize(target);
View
201 src/object.cc
@@ -1,201 +0,0 @@
-/*
- * Copyright 2013, Tim Branyen @tbranyen <tim@tabdeveloper.com>
- * @author Michael Robinson @codeofinterest <mike@pagesofinterest.net>
- *
- * Dual licensed under the MIT and GPL licenses.
- */
-
-#include <v8.h>
-#include <node.h>
-
-#include "cvv8/v8-convert.hpp"
-#include "git2.h"
-
-#include "../include/object.h"
-#include "../include/repo.h"
-#include "../include/oid.h"
-
-using namespace v8;
-using namespace node;
-
-namespace cvv8 {
- template <>
- struct NativeToJS<git_otype> : NativeToJS<int32_t> {};
-}
-
-void GitObject::Initialize (Handle<v8::Object> target) {
- Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
-
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- tpl->SetClassName(String::NewSymbol("Object"));
-
- NODE_SET_PROTOTYPE_METHOD(tpl, "id", Id);
- NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type);
- NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner);
- NODE_SET_PROTOTYPE_METHOD(tpl, "type2String", Type2String);
- NODE_SET_PROTOTYPE_METHOD(tpl, "string2Type", String2Type);
- NODE_SET_PROTOTYPE_METHOD(tpl, "typeIsLoose", TypeIsLoose);
- NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size);
-
- Local<Object> types = Object::New();
-
- types->Set(String::New("GIT_OBJ_ANY"), cvv8::CastToJS(GIT_OBJ_ANY));
- types->Set(String::New("GIT_OBJ_BAD"), cvv8::CastToJS(GIT_OBJ_BAD));
- types->Set(String::New("GIT_OBJ__EXT1"), cvv8::CastToJS(GIT_OBJ__EXT1));
- types->Set(String::New("GIT_OBJ_COMMIT"), cvv8::CastToJS(GIT_OBJ_COMMIT));
- types->Set(String::New("GIT_OBJ_TREE"), cvv8::CastToJS(GIT_OBJ_TREE));
- types->Set(String::New("GIT_OBJ_BLOB"), cvv8::CastToJS(GIT_OBJ_BLOB));
- types->Set(String::New("GIT_OBJ_TAG"), cvv8::CastToJS(GIT_OBJ_TAG));
- types->Set(String::New("GIT_OBJ__EXT2"), cvv8::CastToJS(GIT_OBJ__EXT2));
- types->Set(String::New("GIT_OBJ_OFS_DELTA"), cvv8::CastToJS(GIT_OBJ_OFS_DELTA));
- types->Set(String::New("GIT_OBJ_REF_DELTA"), cvv8::CastToJS(GIT_OBJ_REF_DELTA));
-
- tpl->Set(String::New("types"), types);
-
- constructor_template = Persistent<Function>::New(tpl->GetFunction());
- target->Set(String::NewSymbol("Object"), constructor_template);
-}
-
-git_object* GitObject::GetValue() {
- return this->obj;
-}
-
-void GitObject::SetValue(git_object* obj) {
- this->obj = obj;
-}
-
-const git_oid* GitObject::Id() {
- return git_object_id(this->obj);
-}
-
-git_otype GitObject::Type() {
- return git_object_type(this->obj);
-}
-
-git_repository* GitObject::Owner() {
- return git_object_owner(this->obj);
-}
-
-const char* GitObject::Type2String(git_otype type) {
- return git_object_type2string(type);
-}
-
-git_otype GitObject::String2Type(const char* type) {
- return git_object_string2type(type);
-}
-
-int GitObject::TypeIsLoose(git_otype type) {
- return git_object_typeisloose(type);
-}
-
-size_t GitObject::Size(git_otype type) {
- return git_object__size(type);
-}
-
-Handle<Value> GitObject::New(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = new GitObject();
-
- obj->Wrap(args.This());
-
- return scope.Close( args.This() );
-}
-
-Handle<Value> GitObject::Id(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- if(args.Length() == 0 || !args[0]->IsObject()) {
- return ThrowException(Exception::Error(String::New("Oid is required and must be an Object.")));
- }
-
- GitOid *oid = ObjectWrap::Unwrap<GitOid>(args[0]->ToObject());
-
- oid->SetValue(*const_cast<git_oid *>(obj->Id()));
-
- return scope.Close( Undefined() );
-}
-
-Handle<Value> GitObject::Type(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- return scope.Close( Integer::New(obj->Type()) );
-}
-
-Handle<Value> GitObject::Owner(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- if(args.Length() == 0 || !args[0]->IsObject()) {
- return ThrowException(Exception::Error(String::New("Repo is required and must be an Object.")));
- }
-
- GitRepo *repo = ObjectWrap::Unwrap<GitRepo>(args[0]->ToObject());
-
- repo->SetValue(obj->Owner());
-
- return scope.Close( Undefined() );
-}
-
-Handle<Value> GitObject::Type2String(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- if(args.Length() == 0 || !args[0]->IsNumber()) {
- return ThrowException(Exception::Error(String::New("Type is required and must be a Number.")));
- }
-
- git_otype type = (git_otype)args[0]->ToInteger()->Value();
-
- return scope.Close( String::New(obj->Type2String(type)) );
-}
-
-Handle<Value> GitObject::String2Type(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- if(args.Length() == 0 || !args[0]->IsString()) {
- return ThrowException(Exception::Error(String::New("Type is required and must be a String.")));
- }
-
- String::Utf8Value type(args[0]);
-
- return scope.Close( Integer::New(obj->String2Type(*type)) );
-}
-
-Handle<Value> GitObject::TypeIsLoose(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- if(args.Length() == 0 || !args[0]->IsNumber()) {
- return ThrowException(Exception::Error(String::New("Type is required and must be a Number.")));
- }
-
- git_otype type = (git_otype)args[0]->ToInteger()->Value();
-
- return scope.Close( Integer::New(obj->TypeIsLoose(type)) );
-}
-
-Handle<Value> GitObject::Size(const Arguments& args) {
- HandleScope scope;
-
- GitObject *obj = ObjectWrap::Unwrap<GitObject>(args.This());
-
- if(args.Length() == 0 || !args[0]->IsNumber()) {
- return ThrowException(Exception::Error(String::New("Type is required and must be a Number.")));
- }
-
- git_otype type = (git_otype)args[0]->ToInteger()->Value();
-
- return scope.Close( Integer::New(obj->Size(type)) );
-}
-
-Persistent<Function> GitObject::constructor_template;
View
1  src/repo.cc
@@ -10,7 +10,6 @@
#include "git2.h"
-#include "../include/object.h"
#include "../include/repo.h"
#include "../include/commit.h"
#include "../include/error.h"
View
1  src/tree_entry.cc
@@ -15,7 +15,6 @@
#include "../include/repo.h"
#include "../include/blob.h"
#include "../include/tree.h"
-#include "../include/object.h"
#include "../include/oid.h"
#include "../include/tree_entry.h"
#include "../include/error.h"
View
38 test/raw-object.js
@@ -1,38 +0,0 @@
-var git = require('../').raw,
- rimraf = require('rimraf');
-
-// Helper functions
-var helper = {
- // Test if obj is a true function
- testFunction: function(test, obj, label) {
- // The object reports itself as a function
- test(typeof obj, 'function', label +' reports as a function.');
- // This ensures the repo is actually a derivative of the Function [[Class]]
- test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.');
- },
- // Test code and handle exception thrown
- testException: function(test, fun, label) {
- try {
- fun();
- test(false, label);
- }
- catch (ex) {
- test(true, label);
- }
- }
-};
-
-var repo = new git.Repo();
-
-// Obj
-exports.constructor = function(test){
- test.expect(3);
-
- // Test for function
- helper.testFunction(test.equals, git.Object, 'GitObject');
-
- // Ensure we get an instance of Obj
- test.ok(new git.Object() instanceof git.Object, 'Invocation returns an instance of GitObject');
-
- test.done();
-};
Please sign in to comment.
Something went wrong with that request. Please try again.