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

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

#include "../include/functions/copy.h"
#include "../include/pathspec.h"

#include "../include/pathspec.h"
#include "../include/repository.h"
#include "../include/index.h"
#include "../include/tree.h"
#include "../include/diff.h"

using namespace v8;
using namespace node;

GitPathspec::GitPathspec(git_pathspec *raw) {
  this->raw = raw;
}

GitPathspec::~GitPathspec() {
    git_pathspec_free(this->raw);
  }

void GitPathspec::Initialize(Handle<v8::Object> target) {
  NanScope();

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

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

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

NAN_METHOD(GitPathspec::New) {
  NanScope();

  if (args.Length() == 0 || !args[0]->IsExternal()) {
    return NanThrowError("git_pathspec is required.");
  }
  GitPathspec* object = new GitPathspec(static_cast<git_pathspec *>(Handle<External>::Cast(args[0])->Value()));
  object->Wrap(args.This());

  NanReturnValue(args.This());
}

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

git_pathspec *GitPathspec::GetValue() {
  return this->raw;
}



Persistent<Function> GitPathspec::constructor_template;
