// 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/describe_options.h"
#include "nodegit_wrapper.cc"

 
using namespace v8;
using namespace node;
using namespace std;

 
ConfigurableGitDescribeOptions::ConfigurableGitDescribeOptions(nodegit::Context *nodegitContext)
  : nodegit::ConfigurableClassWrapper<GitDescribeOptionsTraits>(nodegitContext)
{
     git_describe_options  wrappedValue = GIT_DESCRIBE_OPTIONS_INIT;
    this->raw = (git_describe_options*) malloc(sizeof(git_describe_options ));
    memcpy(this->raw, &wrappedValue, sizeof(git_describe_options ));
 }

ConfigurableGitDescribeOptions::~ConfigurableGitDescribeOptions() {
              delete this->raw->pattern;
       }

nodegit::ConfigurableClassWrapper<GitDescribeOptionsTraits>::v8ConversionResult ConfigurableGitDescribeOptions::fromJavascript(nodegit::Context *nodegitContext, v8::Local<v8::Value> input) {
  if (!input->IsObject()) {
    return {
      "Must pass object for ConfigurableGitDescribeOptions"
    };
  }

  Nan::HandleScope scope;
  v8::Local<v8::Object> inputObj = input.As<v8::Object>();
  std::shared_ptr<ConfigurableGitDescribeOptions> output(new ConfigurableGitDescribeOptions(nodegitContext));

  // unpack the data into the correct fields
         {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "version");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to version"
              };
            }

            output->raw->version = static_cast<unsigned int>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "maxCandidatesTags");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to maxCandidatesTags"
              };
            }

            output->raw->max_candidates_tags = static_cast<unsigned int>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "describeStrategy");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to describeStrategy"
              };
            }

            output->raw->describe_strategy = static_cast<unsigned int>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
          output->raw->pattern = nullptr;
        {
          v8::Local<v8::Value> maybeString = nodegit::safeGetField(inputObj, "pattern");
          if (!maybeString.IsEmpty() && !maybeString->IsUndefined() && !maybeString->IsNull()) {
            if (!maybeString->IsString()) {
              return {
                "Must pass string to pattern"
              };
            }

            Nan::Utf8String utf8String(maybeString.As<v8::String>());
            output->raw->pattern = strdup(*utf8String);
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "onlyFollowFirstParent");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to onlyFollowFirstParent"
              };
            }

            output->raw->only_follow_first_parent = static_cast<int>(maybeNumber->Int32Value(Nan::GetCurrentContext()).FromJust());
          }
        }
           {
          v8::Local<v8::Value> maybeNumber = nodegit::safeGetField(inputObj, "showCommitOidAsFallback");
          if (!maybeNumber.IsEmpty() && !maybeNumber->IsUndefined() && !maybeNumber->IsNull()) {
            if (!maybeNumber->IsNumber()) {
              return {
                "Must pass Int32 to showCommitOidAsFallback"
              };
            }

            output->raw->show_commit_oid_as_fallback = static_cast<int>(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<GitDescribeOptionsTraits>;
