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


#include <iostream>

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


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

  Local<Object> object = NanNew<Object>();

  NODE_SET_METHOD(object, "features", Features);
  NODE_SET_METHOD(object, "opts", Opts);
  NODE_SET_METHOD(object, "version", Version);

  target->Set(NanNew<String>("Libgit2"), object);
}


/*
   * @return Number  result    */
NAN_METHOD(GitLibgit2::Features)
{
  NanEscapableScope();

  int result = git_libgit2_features(
               );

  Handle<Value> to;
// start convert_to_v8 block
  to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}

/*
 * @param Number option
     * @return Number  result    */
NAN_METHOD(GitLibgit2::Opts)
{
  NanEscapableScope();

  if (args.Length() == 0 || !args[0]->IsNumber()) {
    return NanThrowError("Number option is required.");
  }

// start convert_from_v8 block
  int from_option;
  from_option = (int)   args[0]->ToNumber()->Value();
// end convert_from_v8 block
  int result = git_libgit2_opts(
                 from_option
               );

  Handle<Value> to;
// start convert_to_v8 block
  to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}

/*
 * @param Number major
   * @param Number minor
   * @param Number rev
     */
NAN_METHOD(GitLibgit2::Version)
{
  NanEscapableScope();

  if (args.Length() == 0 || !args[0]->IsNumber()) {
    return NanThrowError("Number major is required.");
  }

  if (args.Length() == 1 || !args[1]->IsNumber()) {
    return NanThrowError("Number minor is required.");
  }

  if (args.Length() == 2 || !args[2]->IsNumber()) {
    return NanThrowError("Number rev is required.");
  }

// start convert_from_v8 block
  int * from_major;
  *from_major = (int)   args[0]->ToNumber()->Value();
// end convert_from_v8 block
// start convert_from_v8 block
  int * from_minor;
  *from_minor = (int)   args[1]->ToNumber()->Value();
// end convert_from_v8 block
// start convert_from_v8 block
  int * from_rev;
  *from_rev = (int)   args[2]->ToNumber()->Value();
// end convert_from_v8 block
  git_libgit2_version(
    from_major
    ,from_minor
    ,from_rev
  );
  NanReturnUndefined();
}
Persistent<Function> GitLibgit2::constructor_template;
