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

 
#include <iostream>

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

  GitBranchIterator::GitBranchIterator(git_branch_iterator *raw, bool selfFreeing) {
    this->raw = raw;
    this->selfFreeing = selfFreeing;
  }

  GitBranchIterator::~GitBranchIterator() {
   }

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

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

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

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

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

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

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

    NanReturnValue(args.This());
  }

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

  git_branch_iterator *GitBranchIterator::GetValue() {
    return this->raw;
  }

  git_branch_iterator **GitBranchIterator::GetRefValue() {
    return &this->raw;
  }

     Persistent<Function> GitBranchIterator::constructor_template;
 