// 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/revspec.h"
#include "nodegit_wrapper.cc"

  #include "../include/object.h"
 
#include <iostream>

using namespace std;
using namespace v8;
using namespace node;

  GitRevspec::~GitRevspec() {
    // 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 GitRevspec::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(1);
    tpl->SetClassName(Nan::New("Revspec").ToLocalChecked());

         Nan::SetPrototypeMethod(tpl, "from", From, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "to", To, nodegitExternal);
         Nan::SetPrototypeMethod(tpl, "flags", Flags, nodegitExternal);
  
    InitializeTemplate(tpl);

    v8::Local<Function> constructor_template = Nan::GetFunction(tpl).ToLocalChecked();
    nodegitContext->SaveToPersistent("GitRevspec::Template", constructor_template);
    Nan::Set(target, Nan::New("Revspec").ToLocalChecked(), constructor_template);
  }

      // start field block
    NAN_METHOD(GitRevspec::From) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_object *
            from =
           Nan::ObjectWrap::Unwrap<GitRevspec>(info.This())->GetValue()->from;
 // start convert_to_v8 block
    if (from != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
         Nan::Set(
          owners,
          Nan::New<v8::Number>(owners->Length()),
          Nan::To<v8::Object>(GitRepository::New(
            git_object_owner(from),
            true
          )).ToLocalChecked()
        );
         v8ConversionSlot = GitObject::New(
        from,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitRevspec::To) {
      v8::Local<v8::Value> v8ConversionSlot;

            git_object *
            to =
           Nan::ObjectWrap::Unwrap<GitRevspec>(info.This())->GetValue()->to;
 // start convert_to_v8 block
    if (to != NULL) {
      v8::Local<v8::Array> owners = Nan::New<Array>(0);
         Nan::Set(owners, owners->Length(), info.This());
         Nan::Set(
          owners,
          Nan::New<v8::Number>(owners->Length()),
          Nan::To<v8::Object>(GitRepository::New(
            git_object_owner(to),
            true
          )).ToLocalChecked()
        );
         v8ConversionSlot = GitObject::New(
        to,
        true
          , owners
       );
   }
  else {
    v8ConversionSlot = Nan::Null();
  }
  // end convert_to_v8 block
      info.GetReturnValue().Set(v8ConversionSlot);
    }
    // end field block
     // start field block
    NAN_METHOD(GitRevspec::Flags) {
      v8::Local<v8::Value> v8ConversionSlot;

            unsigned int
           flags =
          Nan::ObjectWrap::Unwrap<GitRevspec>(info.This())->GetValue()->flags;
 // start convert_to_v8 block
     v8ConversionSlot = Nan::New<Number>( flags);
  // 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<GitRevspecTraits>;
 