// This is a generated file, modify: generate/templates/class_content.cc.
#include <nan.h>
#include <string.h>

extern "C" {
  #include <git2.h>
 }


#include "../include/functions/copy.h"
#include "../include/macros.h"
#include "../include/time.h"

 
#include <iostream>

using namespace std;
using namespace v8;
using namespace node;

  GitTime::GitTime(git_time *raw, bool selfFreeing) {
    this->raw = raw;
    this->selfFreeing = selfFreeing;
  }

  GitTime::~GitTime() {
   }

  void GitTime::InitializeComponent(Handle<v8::Object> target) {
    NanScope();

    Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(JSNewFunction);

    tpl->InstanceTemplate()->SetInternalFieldCount(1);
    tpl->SetClassName(NanNew<String>("Time"));

         NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time);
         NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset);
  
    Local<Function> _constructor_template = tpl->GetFunction();
    NanAssignPersistent(constructor_template, _constructor_template);
    target->Set(NanNew<String>("Time"), _constructor_template);
  }

  NAN_METHOD(GitTime::JSNewFunction) {
    NanScope();

    if (args.Length() == 0 || !args[0]->IsExternal()) {
         return NanThrowError("A new GitTime cannot be instantiated.");
     }

    GitTime* object = new GitTime(static_cast<git_time *>(Handle<External>::Cast(args[0])->Value()), args[1]->BooleanValue());
    object->Wrap(args.This());

    NanReturnValue(args.This());
  }

  Handle<Value> GitTime::New(void *raw, bool selfFreeing) {
    NanEscapableScope();
    Handle<Value> argv[2] = { NanNew<External>((void *)raw), NanNew<Boolean>(selfFreeing) };
    return NanEscapeScope(NanNew<Function>(GitTime::constructor_template)->NewInstance(2, argv));
  }

  git_time *GitTime::GetValue() {
    return this->raw;
  }

  git_time **GitTime::GetRefValue() {
    return &this->raw;
  }

      NAN_METHOD(GitTime::Time) {
      NanScope();
      Handle<Value> to;

      git_time_t  time =
 ObjectWrap::Unwrap<GitTime>(args.This())->GetValue()->time;

// start convert_to_v8 block
     to = NanNew<Number>(time);
  // end convert_to_v8 block
      NanReturnValue(to);
    }
     NAN_METHOD(GitTime::Offset) {
      NanScope();
      Handle<Value> to;

      int  offset =
 ObjectWrap::Unwrap<GitTime>(args.This())->GetValue()->offset;

// start convert_to_v8 block
     to = NanNew<Number>(offset);
  // end convert_to_v8 block
      NanReturnValue(to);
    }
    Persistent<Function> GitTime::constructor_template;
 