// 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/merge_file_result.h"
#include "nodegit_wrapper.cc"

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

  GitMergeFileResult::GitMergeFileResult() : NodeGitWrapper<GitMergeFileResultTraits>(NULL, true, v8::Local<v8::Object>())
  {
    this->raw = new git_merge_file_result;
 
    this->ConstructFields();
  }

  GitMergeFileResult::GitMergeFileResult(git_merge_file_result* raw, bool selfFreeing, v8::Local<v8::Object> owner)
   : NodeGitWrapper<GitMergeFileResultTraits>(raw, selfFreeing, owner)
  {
    this->ConstructFields();
  }

  GitMergeFileResult::~GitMergeFileResult() {
                  }

  void GitMergeFileResult::ConstructFields() {
                  }

  void GitMergeFileResult::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("MergeFileResult").ToLocalChecked());

        Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("automergeable").ToLocalChecked(), GetAutomergeable, SetAutomergeable, nodegitExternal);
          Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("path").ToLocalChecked(), GetPath, SetPath, nodegitExternal);
          Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("mode").ToLocalChecked(), GetMode, SetMode, nodegitExternal);
          Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("ptr").ToLocalChecked(), GetPtr, SetPtr, nodegitExternal);
          Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("len").ToLocalChecked(), GetLen, SetLen, nodegitExternal);
   
    InitializeTemplate(tpl);

    v8::Local<Function> constructor_template = Nan::GetFunction(tpl).ToLocalChecked();
    nodegitContext->SaveToPersistent("GitMergeFileResult::Template", constructor_template);
  }

    NAN_GETTER(GitMergeFileResult::GetAutomergeable) {

      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        info.GetReturnValue().Set(Nan::New<Number>(wrapper->GetValue()->automergeable));
     }

    NAN_SETTER(GitMergeFileResult::SetAutomergeable) {
      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->automergeable = (unsigned int) Nan::To<int32_t>(value).FromJust();
        }
     }
     NAN_GETTER(GitMergeFileResult::GetPath) {

      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        if (wrapper->GetValue()->path) {
          info.GetReturnValue().Set(Nan::New<String>(wrapper->GetValue()->path).ToLocalChecked());
        }
        else {
          return;
        }

     }

    NAN_SETTER(GitMergeFileResult::SetPath) {
      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        if (wrapper->GetValue()->path) {
        }

        Nan::Utf8String str(value);
        wrapper->GetValue()->path = strdup(*str);

     }
     NAN_GETTER(GitMergeFileResult::GetMode) {

      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        info.GetReturnValue().Set(Nan::New<Number>(wrapper->GetValue()->mode));
     }

    NAN_SETTER(GitMergeFileResult::SetMode) {
      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->mode = (unsigned int) Nan::To<int32_t>(value).FromJust();
        }
     }
     NAN_GETTER(GitMergeFileResult::GetPtr) {

      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        if (wrapper->GetValue()->ptr) {
          info.GetReturnValue().Set(Nan::New<String>(wrapper->GetValue()->ptr).ToLocalChecked());
        }
        else {
          return;
        }

     }

    NAN_SETTER(GitMergeFileResult::SetPtr) {
      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        if (wrapper->GetValue()->ptr) {
        }

        Nan::Utf8String str(value);
        wrapper->GetValue()->ptr = strdup(*str);

     }
     NAN_GETTER(GitMergeFileResult::GetLen) {

      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

        info.GetReturnValue().Set(Nan::New<Number>(wrapper->GetValue()->len));
     }

    NAN_SETTER(GitMergeFileResult::SetLen) {
      GitMergeFileResult *wrapper = Nan::ObjectWrap::Unwrap<GitMergeFileResult>(info.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->len = (size_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<GitMergeFileResultTraits>;

 
ConfigurableGitMergeFileResult::ConfigurableGitMergeFileResult(nodegit::Context *nodegitContext)
  : nodegit::ConfigurableClassWrapper<GitMergeFileResultTraits>(nodegitContext)
{
    this->raw = new git_merge_file_result;
 }

ConfigurableGitMergeFileResult::~ConfigurableGitMergeFileResult() {
          delete this->raw->path;
            delete this->raw->ptr;
     }

nodegit::ConfigurableClassWrapper<GitMergeFileResultTraits>::v8ConversionResult ConfigurableGitMergeFileResult::fromJavascript(nodegit::Context *nodegitContext, v8::Local<v8::Value> input) {
  if (!input->IsObject()) {
    return {
      "Must pass object for ConfigurableGitMergeFileResult"
    };
  }

  Nan::HandleScope scope;
  v8::Local<v8::Object> inputObj = input.As<v8::Object>();
  std::shared_ptr<ConfigurableGitMergeFileResult> output(new ConfigurableGitMergeFileResult(nodegitContext));

  // unpack the data into the correct fields
         {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "automergeable");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to automergeable"
              };
            }

            output->raw->automergeable = static_cast<unsigned int>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
          output->raw->path = nullptr;
        {
          v8::Local<v8::Value> maybeString = nodegit::safeGetField(inputObj, "path");
          if (!maybeString.IsEmpty() && !maybeString->IsUndefined() && !maybeString->IsNull()) {
            if (!maybeString->IsString()) {
              return {
                "Must pass string to path"
              };
            }

            Nan::Utf8String utf8String(maybeString.As<v8::String>());
            output->raw->path = strdup(*utf8String);
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "mode");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to mode"
              };
            }

            output->raw->mode = static_cast<unsigned int>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
          output->raw->ptr = nullptr;
        {
          v8::Local<v8::Value> maybeString = nodegit::safeGetField(inputObj, "ptr");
          if (!maybeString.IsEmpty() && !maybeString->IsUndefined() && !maybeString->IsNull()) {
            if (!maybeString->IsString()) {
              return {
                "Must pass string to ptr"
              };
            }

            Nan::Utf8String utf8String(maybeString.As<v8::String>());
            output->raw->ptr = strdup(*utf8String);
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "len");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to len"
              };
            }

            output->raw->len = static_cast<size_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<GitMergeFileResultTraits>;
