// This is a generated file, modify: generate/templates/templates/class_content.cc

#include <nan.h>
#include <string.h>

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

#include "../include/nodegit.h"
#include "../include/lock_master.h"
#include "../include/functions/copy.h"
#include "../include/blame_hunk.h"
#include "nodegit_wrapper.cc"

  #include "../include/oid.h"
  #include "../include/signature.h"
 
#include <iostream>

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

  GitBlameHunk::~GitBlameHunk() {
    // this will cause an error if you have a non-self-freeing object that also needs
    // to save values. Since the object that will eventually free the object has no
    // way of knowing to free these values.
   }

  void GitBlameHunk::InitializeComponent(v8::Local<v8::Object> target, nodegit::Context *nodegitContext) {
    Nan::HandleScope scope;

    v8::Local<v8::External> nodegitExternal = Nan::New<v8::External>(nodegitContext);
    v8::Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(JSNewFunction, nodegitExternal);

    tpl->InstanceTemplate()->SetInternalFieldCount(2);
    tpl->SetClassName(Nan::New("BlameHunk").ToLocalChecked());

         Nan::SetPrototypeMethod(tpl, "linesInHunk", LinesInHunk, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "finalCommitId", FinalCommitId, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "finalStartLineNumber", FinalStartLineNumber, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "finalSignature", FinalSignature, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "finalCommitter", FinalCommitter, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "origCommitId", OrigCommitId, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "origPath", OrigPath, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "origStartLineNumber", OrigStartLineNumber, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "origSignature", OrigSignature, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "origCommitter", OrigCommitter, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "summary", Summary, nodegitExternal);
  
    InitializeTemplate(tpl);

    v8::Local<Function> constructor_template = Nan::GetFunction(tpl).ToLocalChecked();
    nodegitContext->SaveToPersistent("GitBlameHunk::Template", constructor_template);
    Nan::Set(target, Nan::New("BlameHunk").ToLocalChecked(), constructor_template);
  }

      // start field block
    NAN_METHOD(GitBlameHunk::LinesInHunk) {
      v8::Local<v8::Value> v8ConversionSlot;

            int
           lines_in_hunk =
          Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->lines_in_hunk;
 // start convert_to_v8 block
     v8ConversionSlot = Nan::New<Number>( lines_in_hunk);
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::FinalCommitId) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_oid
*            final_commit_id =
          &
           Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->final_commit_id;
 // start convert_to_v8 block
    if (final_commit_id != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
          v8ConversionSlot = GitOid::New(
        final_commit_id,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::FinalStartLineNumber) {
      v8::Local<v8::Value> v8ConversionSlot;

            size_t
           final_start_line_number =
          Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->final_start_line_number;
 // start convert_to_v8 block
     v8ConversionSlot = Nan::New<Number>( final_start_line_number);
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::FinalSignature) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_signature *
            final_signature =
           Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->final_signature;
 // start convert_to_v8 block
    if (final_signature != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
          v8ConversionSlot = GitSignature::New(
        final_signature,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::FinalCommitter) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_signature *
            final_committer =
           Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->final_committer;
 // start convert_to_v8 block
    if (final_committer != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
          v8ConversionSlot = GitSignature::New(
        final_committer,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::OrigCommitId) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_oid
*            orig_commit_id =
          &
           Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->orig_commit_id;
 // start convert_to_v8 block
    if (orig_commit_id != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
          v8ConversionSlot = GitOid::New(
        orig_commit_id,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::OrigPath) {
      v8::Local<v8::Value> v8ConversionSlot;

            const char *
           orig_path =
          Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->orig_path;
 // start convert_to_v8 block
  if (orig_path){
       v8ConversionSlot = Nan::New<v8::String>(orig_path).ToLocalChecked();
   }
  else {
    v8ConversionSlot = Nan::Null();
  }

  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::OrigStartLineNumber) {
      v8::Local<v8::Value> v8ConversionSlot;

            size_t
           orig_start_line_number =
          Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->orig_start_line_number;
 // start convert_to_v8 block
     v8ConversionSlot = Nan::New<Number>( orig_start_line_number);
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::OrigSignature) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_signature *
            orig_signature =
           Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->orig_signature;
 // start convert_to_v8 block
    if (orig_signature != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
          v8ConversionSlot = GitSignature::New(
        orig_signature,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::OrigCommitter) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_signature *
            orig_committer =
           Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->orig_committer;
 // start convert_to_v8 block
    if (orig_committer != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
          v8ConversionSlot = GitSignature::New(
        orig_committer,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitBlameHunk::Summary) {
      v8::Local<v8::Value> v8ConversionSlot;

            const char *
           summary =
          Nan::ObjectWrap::Unwrap<GitBlameHunk>(info.This())->GetValue()->summary;
 // start convert_to_v8 block
  if (summary){
       v8ConversionSlot = Nan::New<v8::String>(summary).ToLocalChecked();
   }
  else {
    v8ConversionSlot = Nan::Null();
  }

  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
  // force base class template instantiation, to make sure we get all the
// methods, statics, etc.
template class NodeGitWrapper<GitBlameHunkTraits>;
 