// 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/cred_helpers.h"


using namespace v8;
using namespace node;

GitCredHelpers::GitCredHelpers(git_cred *raw) {
  this->raw = raw;
}

GitCredHelpers::~GitCredHelpers() {
  }

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

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

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

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

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

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

  NanReturnValue(args.This());
}

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

git_cred *GitCredHelpers::GetValue() {
  return this->raw;
}



Persistent<Function> GitCredHelpers::constructor_template;
