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

// generated from struct_content.cc
#include <nan.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif // win32

extern "C" {
  #include <git2.h>
 }

#include <iostream>
#include "../include/nodegit.h"
#include "../include/lock_master.h"
#include "../include/functions/copy.h"
#include "../include/index_time.h"
#include "nodegit_wrapper.cc"

 
using namespace v8;
using namespace node;
using namespace std;

  GitIndexTime::GitIndexTime() : NodeGitWrapper<GitIndexTimeTraits>(NULL, true, v8::Local<v8::Object>())
  {
    this->raw = new git_index_time;
 
    this->ConstructFields();
  }

  GitIndexTime::GitIndexTime(git_index_time* raw, bool selfFreeing, v8::Local<v8::Object> owner)
   : NodeGitWrapper<GitIndexTimeTraits>(raw, selfFreeing, owner)
  {
    this->ConstructFields();
  }

  GitIndexTime::~GitIndexTime() {
         }

  void GitIndexTime::ConstructFields() {
         }

  void GitIndexTime::InitializeComponent(Local<Object> target, nodegit::Context *nodegitContext) {
    Nan::HandleScope scope;

    Local<External> nodegitExternal = Nan::New<External>(nodegitContext);
    Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(JSNewFunction, nodegitExternal);

    tpl->InstanceTemplate()->SetInternalFieldCount(1);
    tpl->SetClassName(Nan::New("IndexTime").ToLocalChecked());

        Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("seconds").ToLocalChecked(), GetSeconds, SetSeconds, nodegitExternal);
          Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("nanoseconds").ToLocalChecked(), GetNanoseconds, SetNanoseconds, nodegitExternal);
   
    InitializeTemplate(tpl);

    v8::Local<Function> constructor_template = Nan::GetFunction(tpl).ToLocalChecked();
    nodegitContext->SaveToPersistent("GitIndexTime::Template", constructor_template);
  }

    NAN_GETTER(GitIndexTime::GetSeconds) {

      GitIndexTime *wrapper = Nan::ObjectWrap::Unwrap<GitIndexTime>(info.This());

        info.GetReturnValue().Set(Nan::New<Number>(wrapper->GetValue()->seconds));
     }

    NAN_SETTER(GitIndexTime::SetSeconds) {
      GitIndexTime *wrapper = Nan::ObjectWrap::Unwrap<GitIndexTime>(info.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->seconds = (int32_t) Nan::To<int32_t>(value).FromJust();
        }
     }
     NAN_GETTER(GitIndexTime::GetNanoseconds) {

      GitIndexTime *wrapper = Nan::ObjectWrap::Unwrap<GitIndexTime>(info.This());

        info.GetReturnValue().Set(Nan::New<Number>(wrapper->GetValue()->nanoseconds));
     }

    NAN_SETTER(GitIndexTime::SetNanoseconds) {
      GitIndexTime *wrapper = Nan::ObjectWrap::Unwrap<GitIndexTime>(info.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->nanoseconds = (uint32_t) Nan::To<int32_t>(value).FromJust();
        }
     }
  
  // force base class template instantiation, to make sure we get all the
  // methods, statics, etc.
  template class NodeGitWrapper<GitIndexTimeTraits>;

 
ConfigurableGitIndexTime::ConfigurableGitIndexTime(nodegit::Context *nodegitContext)
  : nodegit::ConfigurableClassWrapper<GitIndexTimeTraits>(nodegitContext)
{
    this->raw = new git_index_time;
 }

ConfigurableGitIndexTime::~ConfigurableGitIndexTime() {
     }

nodegit::ConfigurableClassWrapper<GitIndexTimeTraits>::v8ConversionResult ConfigurableGitIndexTime::fromJavascript(nodegit::Context *nodegitContext, v8::Local<v8::Value> input) {
  if (!input->IsObject()) {
    return {
      "Must pass object for ConfigurableGitIndexTime"
    };
  }

  Nan::HandleScope scope;
  v8::Local<v8::Object> inputObj = input.As<v8::Object>();
  std::shared_ptr<ConfigurableGitIndexTime> output(new ConfigurableGitIndexTime(nodegitContext));

  // unpack the data into the correct fields
         {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "seconds");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to seconds"
              };
            }

            output->raw->seconds = static_cast<int32_t>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "nanoseconds");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to nanoseconds"
              };
            }

            output->raw->nanoseconds = static_cast<uint32_t>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
    
  return {
    output
  };
}

     
// force base class template instantiation, to make sure we get all the
// methods, statics, etc.
template class nodegit::ConfigurableClassWrapper<GitIndexTimeTraits>;
