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

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


#include "../include/functions/copy.h"
#include "../include/macros.h"
#include "../include/merge_result.h"

 
#include <iostream>

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

  GitMergeResult::GitMergeResult(git_merge_result *raw, bool selfFreeing) {
    this->raw = raw;
    this->selfFreeing = selfFreeing;
  }

  GitMergeResult::~GitMergeResult() {
   }

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

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

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

  
    Local<Function> _constructor_template = tpl->GetFunction();
    NanAssignPersistent(constructor_template, _constructor_template);
    target->Set(NanNew<String>("MergeResult"), _constructor_template);
  }

  NAN_METHOD(GitMergeResult::JSNewFunction) {
    NanScope();

    if (args.Length() == 0 || !args[0]->IsExternal()) {
         return NanThrowError("A new GitMergeResult cannot be instantiated.");
     }

    GitMergeResult* object = new GitMergeResult(static_cast<git_merge_result *>(Handle<External>::Cast(args[0])->Value()), args[1]->BooleanValue());
    object->Wrap(args.This());

    NanReturnValue(args.This());
  }

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

  git_merge_result *GitMergeResult::GetValue() {
    return this->raw;
  }

  git_merge_result **GitMergeResult::GetRefValue() {
    return &this->raw;
  }

     Persistent<Function> GitMergeResult::constructor_template;
 