// This is a generated file, modify: generate/templates/struct_content.cc.
#include <nan.h>
#include <string.h>
#include <chrono>
#include <thread>

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

#include <iostream>
#include "../include/functions/copy.h"
#include "../include/repository_init_options.h"

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


// generated from struct_content.cc
GitRepositoryInitOptions::GitRepositoryInitOptions() {
  git_repository_init_options wrappedValue = GIT_REPOSITORY_INIT_OPTIONS_INIT;
  this->raw = (git_repository_init_options*) malloc(sizeof(git_repository_init_options));
  memcpy(this->raw, &wrappedValue, sizeof(git_repository_init_options));

  this->ConstructFields();
  this->selfFreeing = true;
}

GitRepositoryInitOptions::GitRepositoryInitOptions(git_repository_init_options* raw, bool selfFreeing) {
  this->raw = raw;
  this->ConstructFields();
  this->selfFreeing = selfFreeing;
}

GitRepositoryInitOptions::~GitRepositoryInitOptions() {
  // This is going to cause memory leaks. We'll have to solve that later
  // TODO: Clean up memory better
  if (this->selfFreeing) {
    free(this->raw);
  }
}

void GitRepositoryInitOptions::ConstructFields() {
                         }

void GitRepositoryInitOptions::InitializeComponent(Handle<v8::Object> target) {
  NanScope();

  Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(JSNewFunction);

  tpl->InstanceTemplate()->SetInternalFieldCount(1);
  tpl->SetClassName(NanNew<String>("RepositoryInitOptions"));

      tpl->InstanceTemplate()->SetAccessor(NanNew<String>("version"), GetVersion, SetVersion);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("flags"), GetFlags, SetFlags);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("mode"), GetMode, SetMode);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("workdirPath"), GetWorkdirPath, SetWorkdirPath);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("description"), GetDescription, SetDescription);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("templatePath"), GetTemplatePath, SetTemplatePath);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("initialHead"), GetInitialHead, SetInitialHead);
       tpl->InstanceTemplate()->SetAccessor(NanNew<String>("originUrl"), GetOriginUrl, SetOriginUrl);
  
  Local<Function> _constructor_template = tpl->GetFunction();
  NanAssignPersistent(constructor_template, _constructor_template);
  target->Set(NanNew<String>("RepositoryInitOptions"), _constructor_template);
}

NAN_METHOD(GitRepositoryInitOptions::JSNewFunction) {
  NanScope();
  GitRepositoryInitOptions* instance;

  if (args.Length() == 0 || !args[0]->IsExternal()) {
    instance = new GitRepositoryInitOptions();
  }
  else {
    instance = new GitRepositoryInitOptions(static_cast<git_repository_init_options*>(Handle<External>::Cast(args[0])->Value()), args[1]->BooleanValue());
  }

  instance->Wrap(args.This());

  NanReturnValue(args.This());
}

Handle<Value> GitRepositoryInitOptions::New(void* raw, bool selfFreeing) {
  NanEscapableScope();

  Handle<Value> argv[2] = { NanNew<External>((void *)raw), NanNew<Boolean>(selfFreeing) };
  return NanEscapeScope(NanNew<Function>(GitRepositoryInitOptions::constructor_template)->NewInstance(2, argv));
}

git_repository_init_options *GitRepositoryInitOptions::GetValue() {
  return this->raw;
}

git_repository_init_options **GitRepositoryInitOptions::GetRefValue() {
  return &this->raw;
}

    NAN_GETTER(GitRepositoryInitOptions::GetVersion) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        NanReturnValue(NanNew<Number>(wrapper->GetValue()->version));
     }

    NAN_SETTER(GitRepositoryInitOptions::SetVersion) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->version = (unsigned int) value->Int32Value();
        }
     }

      NAN_GETTER(GitRepositoryInitOptions::GetFlags) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        NanReturnValue(NanNew<Number>(wrapper->GetValue()->flags));
     }

    NAN_SETTER(GitRepositoryInitOptions::SetFlags) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->flags = (uint32_t) value->Int32Value();
        }
     }

      NAN_GETTER(GitRepositoryInitOptions::GetMode) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        NanReturnValue(NanNew<Number>(wrapper->GetValue()->mode));
     }

    NAN_SETTER(GitRepositoryInitOptions::SetMode) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

         if (value->IsNumber()) {
          wrapper->GetValue()->mode = (uint32_t) value->Int32Value();
        }
     }

      NAN_GETTER(GitRepositoryInitOptions::GetWorkdirPath) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        if (wrapper->GetValue()->workdir_path) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->workdir_path));
        }
        else {
          NanReturnUndefined();
        }

     }

    NAN_SETTER(GitRepositoryInitOptions::SetWorkdirPath) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

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

        String::Utf8Value str(value);
        wrapper->GetValue()->workdir_path = strdup(*str);

     }

      NAN_GETTER(GitRepositoryInitOptions::GetDescription) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        if (wrapper->GetValue()->description) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->description));
        }
        else {
          NanReturnUndefined();
        }

     }

    NAN_SETTER(GitRepositoryInitOptions::SetDescription) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

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

        String::Utf8Value str(value);
        wrapper->GetValue()->description = strdup(*str);

     }

      NAN_GETTER(GitRepositoryInitOptions::GetTemplatePath) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        if (wrapper->GetValue()->template_path) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->template_path));
        }
        else {
          NanReturnUndefined();
        }

     }

    NAN_SETTER(GitRepositoryInitOptions::SetTemplatePath) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

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

        String::Utf8Value str(value);
        wrapper->GetValue()->template_path = strdup(*str);

     }

      NAN_GETTER(GitRepositoryInitOptions::GetInitialHead) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        if (wrapper->GetValue()->initial_head) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->initial_head));
        }
        else {
          NanReturnUndefined();
        }

     }

    NAN_SETTER(GitRepositoryInitOptions::SetInitialHead) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

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

        String::Utf8Value str(value);
        wrapper->GetValue()->initial_head = strdup(*str);

     }

      NAN_GETTER(GitRepositoryInitOptions::GetOriginUrl) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

        if (wrapper->GetValue()->origin_url) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->origin_url));
        }
        else {
          NanReturnUndefined();
        }

     }

    NAN_SETTER(GitRepositoryInitOptions::SetOriginUrl) {
      NanScope();

      GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());

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

        String::Utf8Value str(value);
        wrapper->GetValue()->origin_url = strdup(*str);

     }

   
Persistent<Function> GitRepositoryInitOptions::constructor_template;
