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

#include "../include/functions/copy.h"
#include "../include/checkout.h"
#include "../include/checkout_options.h"
#include "../include/repository.h"
#include "../include/index.h"
#include "../include/object.h"
#include "../include/checkout_options.h"
#include "../include/repository.h"
#include "../include/index.h"

using namespace v8;
using namespace node;

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

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

        NODE_SET_METHOD(object, "initOptions", InitOptions);
            NODE_SET_METHOD(object, "head", Head);
            NODE_SET_METHOD(object, "index", Index);
            NODE_SET_METHOD(object, "tree", Tree);
      
  target->Set(NanNew<String>("Checkout"), object);
}

            /**
      * @param CheckoutOptions opts
            * @param Uint32 version
            * @return Int32 result  */
NAN_METHOD(GitCheckout::InitOptions) {
  NanScope();
            if (args.Length() == 0 || !args[0]->IsObject()) {
      return NanThrowError("CheckoutOptions opts is required.");
    }
                if (args.Length() == 1 || !args[1]->IsNumber()) {
      return NanThrowError("Uint32 version is required.");
    }
      
  
                      git_checkout_options * from_opts;
          from_opts = ObjectWrap::Unwrap<GitCheckoutOptions>(args[0]->ToObject())->GetValue();
  
                                  unsigned int from_version;
          from_version = (unsigned int)   args[1]->ToNumber()->Value();
  
              
  int result = git_checkout_init_options(
          from_opts
        ,          from_version
            );

    

  Handle<Value> to;
          to = NanNew<Number>(result);
            NanReturnValue(to);
  }
                  /**
      * @param Repository repo
            * @param CheckoutOptions opts
            * @return Int32 result  */
NAN_METHOD(GitCheckout::Head) {
  NanScope();
            if (args.Length() == 0 || !args[0]->IsObject()) {
      return NanThrowError("Repository repo is required.");
    }
                if (args.Length() == 1 || !args[1]->IsObject()) {
      return NanThrowError("CheckoutOptions opts is required.");
    }
      
  
                      git_repository * from_repo;
          from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetValue();
  
                                  const git_checkout_options * from_opts;
          from_opts = ObjectWrap::Unwrap<GitCheckoutOptions>(args[1]->ToObject())->GetValue();
  
              
  int result = git_checkout_head(
          from_repo
        ,          from_opts
            );

    

  Handle<Value> to;
          to = NanNew<Number>(result);
            NanReturnValue(to);
  }
                  /**
      * @param Repository repo
            * @param Index index
            * @param CheckoutOptions opts
            * @return Int32 result  */
NAN_METHOD(GitCheckout::Index) {
  NanScope();
            if (args.Length() == 0 || !args[0]->IsObject()) {
      return NanThrowError("Repository repo is required.");
    }
                if (args.Length() == 1 || !args[1]->IsObject()) {
      return NanThrowError("Index index is required.");
    }
                if (args.Length() == 2 || !args[2]->IsObject()) {
      return NanThrowError("CheckoutOptions opts is required.");
    }
      
  
                      git_repository * from_repo;
          from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetValue();
  
                                  git_index * from_index;
          from_index = ObjectWrap::Unwrap<GitIndex>(args[1]->ToObject())->GetValue();
  
                                  const git_checkout_options * from_opts;
          from_opts = ObjectWrap::Unwrap<GitCheckoutOptions>(args[2]->ToObject())->GetValue();
  
              
  int result = git_checkout_index(
          from_repo
        ,          from_index
        ,          from_opts
            );

      

  Handle<Value> to;
          to = NanNew<Number>(result);
            NanReturnValue(to);
  }
                  /**
      * @param Repository repo
            * @param Object treeish
            * @param CheckoutOptions opts
            * @return Int32 result  */
NAN_METHOD(GitCheckout::Tree) {
  NanScope();
            if (args.Length() == 0 || !args[0]->IsObject()) {
      return NanThrowError("Repository repo is required.");
    }
                if (args.Length() == 1 || !args[1]->IsObject()) {
      return NanThrowError("Object treeish is required.");
    }
                if (args.Length() == 2 || !args[2]->IsObject()) {
      return NanThrowError("CheckoutOptions opts is required.");
    }
      
  
                      git_repository * from_repo;
          from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetValue();
  
                                  const git_object * from_treeish;
          from_treeish = ObjectWrap::Unwrap<GitObject>(args[1]->ToObject())->GetValue();
  
                                  const git_checkout_options * from_opts;
          from_opts = ObjectWrap::Unwrap<GitCheckoutOptions>(args[2]->ToObject())->GetValue();
  
              
  int result = git_checkout_tree(
          from_repo
        ,          from_treeish
        ,          from_opts
            );

      

  Handle<Value> to;
          to = NanNew<Number>(result);
            NanReturnValue(to);
  }
      

Persistent<Function> GitCheckout::constructor_template;
