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

  #include "../include/submodule.h"
  #include "../include/repository.h"
  #include "../include/oid.h"
 
#include <iostream>

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

  GitSubmodule::GitSubmodule(git_submodule *raw, bool selfFreeing) {
    this->raw = raw;
    this->selfFreeing = selfFreeing;
  }

  GitSubmodule::~GitSubmodule() {
      if (this->selfFreeing) {
        git_submodule_free(this->raw);
      }
   }

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

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

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

          NODE_SET_PROTOTYPE_METHOD(tpl, "addFinalize", AddFinalize);
             NODE_SET_METHOD(tpl, "addSetup", AddSetup);
            NODE_SET_PROTOTYPE_METHOD(tpl, "addToIndex", AddToIndex);
            NODE_SET_PROTOTYPE_METHOD(tpl, "branch", Branch);
            NODE_SET_PROTOTYPE_METHOD(tpl, "fetchRecurseSubmodules", FetchRecurseSubmodules);
            NODE_SET_PROTOTYPE_METHOD(tpl, "headId", HeadId);
            NODE_SET_PROTOTYPE_METHOD(tpl, "ignore", Ignore);
            NODE_SET_PROTOTYPE_METHOD(tpl, "indexId", IndexId);
            NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init);
             NODE_SET_METHOD(tpl, "lookup", Lookup);
            NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name);
            NODE_SET_PROTOTYPE_METHOD(tpl, "open", Open);
            NODE_SET_PROTOTYPE_METHOD(tpl, "owner", Owner);
            NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path);
            NODE_SET_PROTOTYPE_METHOD(tpl, "reload", Reload);
             NODE_SET_METHOD(tpl, "reloadAll", ReloadAll);
            NODE_SET_PROTOTYPE_METHOD(tpl, "save", Save);
            NODE_SET_PROTOTYPE_METHOD(tpl, "setFetchRecurseSubmodules", SetFetchRecurseSubmodules);
            NODE_SET_PROTOTYPE_METHOD(tpl, "setIgnore", SetIgnore);
            NODE_SET_PROTOTYPE_METHOD(tpl, "setUpdate", SetUpdate);
            NODE_SET_PROTOTYPE_METHOD(tpl, "setUrl", SetUrl);
            NODE_SET_PROTOTYPE_METHOD(tpl, "sync", Sync);
            NODE_SET_PROTOTYPE_METHOD(tpl, "update", Update);
            NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url);
            NODE_SET_PROTOTYPE_METHOD(tpl, "wdId", WdId);
    
    Local<Function> _constructor_template = tpl->GetFunction();
    NanAssignPersistent(constructor_template, _constructor_template);
    target->Set(NanNew<String>("Submodule"), _constructor_template);
  }

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

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

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

    NanReturnValue(args.This());
  }

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

  git_submodule *GitSubmodule::GetValue() {
    return this->raw;
  }

  git_submodule **GitSubmodule::GetRefValue() {
    return &this->raw;
  }

  
/*
     * @return Number  result    */
NAN_METHOD(GitSubmodule::AddFinalize) {
  NanEscapableScope();

  int result = git_submodule_add_finalize(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
  
/*
  * @param Repository repo
   * @param String url
   * @param String path
   * @param Number use_gitlink
    * @param Submodule callback
   */
NAN_METHOD(GitSubmodule::AddSetup) {
  NanScope();

  if (args.Length() == 0 || !args[0]->IsObject()) {
    return NanThrowError("Repository repo is required.");
  }

  if (args.Length() == 1 || !args[1]->IsString()) {
    return NanThrowError("String url is required.");
  }

  if (args.Length() == 2 || !args[2]->IsString()) {
    return NanThrowError("String path is required.");
  }

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

  if (args.Length() == 4 || !args[4]->IsFunction()) {
    return NanThrowError("Callback is required and must be a Function.");
  }

  AddSetupBaton* baton = new AddSetupBaton;

  baton->error_code = GIT_OK;
  baton->error = NULL;

// start convert_from_v8 block
  git_repository * from_repo;
  from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetValue();
// end convert_from_v8 block
  baton->repo = from_repo;
// start convert_from_v8 block
  const char * from_url;

  String::Utf8Value url(args[1]->ToString());
  from_url = (const char *) strdup(*url);
// end convert_from_v8 block
  baton->url = from_url;
// start convert_from_v8 block
  const char * from_path;

  String::Utf8Value path(args[2]->ToString());
  from_path = (const char *) strdup(*path);
// end convert_from_v8 block
  baton->path = from_path;
// start convert_from_v8 block
  int from_use_gitlink;
  from_use_gitlink = (int)   args[3]->ToNumber()->Value();
// end convert_from_v8 block
  baton->use_gitlink = from_use_gitlink;

  NanCallback *callback = new NanCallback(Local<Function>::Cast(args[4]));
  AddSetupWorker *worker = new AddSetupWorker(baton, callback);
  if (!args[0]->IsUndefined() && !args[0]->IsNull())
    worker->SaveToPersistent("repo", args[0]->ToObject());
  if (!args[1]->IsUndefined() && !args[1]->IsNull())
    worker->SaveToPersistent("url", args[1]->ToObject());
  if (!args[2]->IsUndefined() && !args[2]->IsNull())
    worker->SaveToPersistent("path", args[2]->ToObject());
  if (!args[3]->IsUndefined() && !args[3]->IsNull())
    worker->SaveToPersistent("use_gitlink", args[3]->ToObject());

  NanAsyncQueueWorker(worker);
  NanReturnUndefined();
}

void GitSubmodule::AddSetupWorker::Execute() {
  int result = git_submodule_add_setup(
&baton->out,baton->repo,baton->url,baton->path,baton->use_gitlink    );

  baton->error_code = result;

  if (result != GIT_OK && giterr_last() != NULL) {
    baton->error = git_error_dup(giterr_last());
  }

}

void GitSubmodule::AddSetupWorker::HandleOKCallback() {
  TryCatch try_catch;

  if (baton->error_code == GIT_OK) {
    Handle<Value> to;
// start convert_to_v8 block
  
  if (baton->out != NULL) {
    // GitSubmodule baton->out
       to = GitSubmodule::New((void *)baton->out, false);
   }
  else {
    to = NanNull();
  }

 // end convert_to_v8 block
    Handle<Value> result = to;
    Handle<Value> argv[2] = {
      NanNull(),
      result
    };
    callback->Call(2, argv);
  } else {
    if (baton->error) {
      Handle<Value> argv[1] = {
        NanError(baton->error->message)
      };
      callback->Call(1, argv);
      if (baton->error->message)
        free((void *)baton->error->message);
      free((void *)baton->error);
    } else {
      callback->Call(0, NULL);
    }

  }

  if (try_catch.HasCaught()) {
    node::FatalException(try_catch);
  }

  free((void *)baton->url);
  free((void *)baton->path);

  delete baton;
}
   
/*
   * @param Number write_index
     * @return Number  result    */
NAN_METHOD(GitSubmodule::AddToIndex) {
  NanEscapableScope();

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

// start convert_from_v8 block
  int from_write_index;
  from_write_index = (int)   args[0]->ToNumber()->Value();
// end convert_from_v8 block
  int result = git_submodule_add_to_index(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_write_index
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return String  result    */
NAN_METHOD(GitSubmodule::Branch) {
  NanEscapableScope();

  const char * result = git_submodule_branch(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  if (result){
       to = NanNew<String>(result);
   }
  else {
    to = NanNull();
  }

  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Number  result    */
NAN_METHOD(GitSubmodule::FetchRecurseSubmodules) {
  NanEscapableScope();

  git_submodule_recurse_t result = git_submodule_fetch_recurse_submodules(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Oid  result    */
NAN_METHOD(GitSubmodule::HeadId) {
  NanEscapableScope();

  const git_oid * result = git_submodule_head_id(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  
  if (result != NULL) {
    // GitOid result
       to = GitOid::New((void *)result, false);
   }
  else {
    to = NanNull();
  }

 // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Number  result    */
NAN_METHOD(GitSubmodule::Ignore) {
  NanEscapableScope();

  git_submodule_ignore_t result = git_submodule_ignore(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Oid  result    */
NAN_METHOD(GitSubmodule::IndexId) {
  NanEscapableScope();

  const git_oid * result = git_submodule_index_id(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  
  if (result != NULL) {
    // GitOid result
       to = GitOid::New((void *)result, false);
   }
  else {
    to = NanNull();
  }

 // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
   * @param Number overwrite
     * @return Number  result    */
NAN_METHOD(GitSubmodule::Init) {
  NanEscapableScope();

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

// start convert_from_v8 block
  int from_overwrite;
  from_overwrite = (int)   args[0]->ToNumber()->Value();
// end convert_from_v8 block
  int result = git_submodule_init(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_overwrite
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
  
/*
  * @param Repository repo
   * @param String name
    * @param Submodule callback
   */
NAN_METHOD(GitSubmodule::Lookup) {
  NanScope();

  if (args.Length() == 0 || !args[0]->IsObject()) {
    return NanThrowError("Repository repo is required.");
  }

  if (args.Length() == 1 || !args[1]->IsString()) {
    return NanThrowError("String name is required.");
  }

  if (args.Length() == 2 || !args[2]->IsFunction()) {
    return NanThrowError("Callback is required and must be a Function.");
  }

  LookupBaton* baton = new LookupBaton;

  baton->error_code = GIT_OK;
  baton->error = NULL;

// start convert_from_v8 block
  git_repository * from_repo;
  from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetValue();
// end convert_from_v8 block
  baton->repo = from_repo;
// start convert_from_v8 block
  const char * from_name;

  String::Utf8Value name(args[1]->ToString());
  from_name = (const char *) strdup(*name);
// end convert_from_v8 block
  baton->name = from_name;

  NanCallback *callback = new NanCallback(Local<Function>::Cast(args[2]));
  LookupWorker *worker = new LookupWorker(baton, callback);
  if (!args[0]->IsUndefined() && !args[0]->IsNull())
    worker->SaveToPersistent("repo", args[0]->ToObject());
  if (!args[1]->IsUndefined() && !args[1]->IsNull())
    worker->SaveToPersistent("name", args[1]->ToObject());

  NanAsyncQueueWorker(worker);
  NanReturnUndefined();
}

void GitSubmodule::LookupWorker::Execute() {
  int result = git_submodule_lookup(
&baton->out,baton->repo,baton->name    );

  baton->error_code = result;

  if (result != GIT_OK && giterr_last() != NULL) {
    baton->error = git_error_dup(giterr_last());
  }

}

void GitSubmodule::LookupWorker::HandleOKCallback() {
  TryCatch try_catch;

  if (baton->error_code == GIT_OK) {
    Handle<Value> to;
// start convert_to_v8 block
  
  if (baton->out != NULL) {
    // GitSubmodule baton->out
       to = GitSubmodule::New((void *)baton->out, false);
   }
  else {
    to = NanNull();
  }

 // end convert_to_v8 block
    Handle<Value> result = to;
    Handle<Value> argv[2] = {
      NanNull(),
      result
    };
    callback->Call(2, argv);
  } else {
    if (baton->error) {
      Handle<Value> argv[1] = {
        NanError(baton->error->message)
      };
      callback->Call(1, argv);
      if (baton->error->message)
        free((void *)baton->error->message);
      free((void *)baton->error);
    } else {
      callback->Call(0, NULL);
    }

  }

  if (try_catch.HasCaught()) {
    node::FatalException(try_catch);
  }

  free((void *)baton->name);

  delete baton;
}
   
/*
     * @return String  result    */
NAN_METHOD(GitSubmodule::Name) {
  NanEscapableScope();

  const char * result = git_submodule_name(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  if (result){
       to = NanNew<String>(result);
   }
  else {
    to = NanNull();
  }

  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
 * @param Repository repo
       * @return Number  result    */
NAN_METHOD(GitSubmodule::Open) {
  NanEscapableScope();

  if (args.Length() == 0 || !args[0]->IsObject()) {
    return NanThrowError("Repository repo is required.");
  }

// start convert_from_v8 block
  git_repository ** from_repo;
  from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetRefValue();
// end convert_from_v8 block
  int result = git_submodule_open(
from_repo
,ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Repository  result    */
NAN_METHOD(GitSubmodule::Owner) {
  NanEscapableScope();

  git_repository * result = git_submodule_owner(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  
  if (result != NULL) {
    // GitRepository result
       to = GitRepository::New((void *)result, false);
   }
  else {
    to = NanNull();
  }

 // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return String  result    */
NAN_METHOD(GitSubmodule::Path) {
  NanEscapableScope();

  const char * result = git_submodule_path(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  if (result){
       to = NanNew<String>(result);
   }
  else {
    to = NanNull();
  }

  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
   * @param Number force
     * @return Number  result    */
NAN_METHOD(GitSubmodule::Reload) {
  NanEscapableScope();

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

// start convert_from_v8 block
  int from_force;
  from_force = (int)   args[0]->ToNumber()->Value();
// end convert_from_v8 block
  int result = git_submodule_reload(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_force
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
 * @param Repository repo
   * @param Number force
     * @return Number  result    */
NAN_METHOD(GitSubmodule::ReloadAll) {
  NanEscapableScope();

  if (args.Length() == 0 || !args[0]->IsObject()) {
    return NanThrowError("Repository repo is required.");
  }

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

// start convert_from_v8 block
  git_repository * from_repo;
  from_repo = ObjectWrap::Unwrap<GitRepository>(args[0]->ToObject())->GetValue();
// end convert_from_v8 block
// start convert_from_v8 block
  int from_force;
  from_force = (int)   args[1]->ToNumber()->Value();
// end convert_from_v8 block
  int result = git_submodule_reload_all(
from_repo
,from_force
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Number  result    */
NAN_METHOD(GitSubmodule::Save) {
  NanEscapableScope();

  int result = git_submodule_save(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
   * @param Number fetch_recurse_submodules
     * @return Number  result    */
NAN_METHOD(GitSubmodule::SetFetchRecurseSubmodules) {
  NanEscapableScope();

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

// start convert_from_v8 block
  git_submodule_recurse_t from_fetch_recurse_submodules;
  from_fetch_recurse_submodules = (git_submodule_recurse_t)  (int) args[0]->ToNumber()->Value();
// end convert_from_v8 block
  git_submodule_recurse_t result = git_submodule_set_fetch_recurse_submodules(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_fetch_recurse_submodules
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
   * @param Number ignore
     * @return Number  result    */
NAN_METHOD(GitSubmodule::SetIgnore) {
  NanEscapableScope();

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

// start convert_from_v8 block
  git_submodule_ignore_t from_ignore;
  from_ignore = (git_submodule_ignore_t)  (int) args[0]->ToNumber()->Value();
// end convert_from_v8 block
  git_submodule_ignore_t result = git_submodule_set_ignore(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_ignore
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
   * @param Number update
     * @return Number  result    */
NAN_METHOD(GitSubmodule::SetUpdate) {
  NanEscapableScope();

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

// start convert_from_v8 block
  git_submodule_update_t from_update;
  from_update = (git_submodule_update_t)  (int) args[0]->ToNumber()->Value();
// end convert_from_v8 block
  git_submodule_update_t result = git_submodule_set_update(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_update
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
   * @param String url
     * @return Number  result    */
NAN_METHOD(GitSubmodule::SetUrl) {
  NanEscapableScope();

  if (args.Length() == 0 || !args[0]->IsString()) {
    return NanThrowError("String url is required.");
  }

// start convert_from_v8 block
  const char * from_url;

  String::Utf8Value url(args[0]->ToString());
  from_url = (const char *) strdup(*url);
// end convert_from_v8 block
  int result = git_submodule_set_url(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
,from_url
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Number  result    */
NAN_METHOD(GitSubmodule::Sync) {
  NanEscapableScope();

  int result = git_submodule_sync(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Number  result    */
NAN_METHOD(GitSubmodule::Update) {
  NanEscapableScope();

  git_submodule_update_t result = git_submodule_update(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );

  Handle<Value> to;
// start convert_to_v8 block
     to = NanNew<Number>(result);
  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return String  result    */
NAN_METHOD(GitSubmodule::Url) {
  NanEscapableScope();

  const char * result = git_submodule_url(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  if (result){
       to = NanNew<String>(result);
   }
  else {
    to = NanNull();
  }

  // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
   
/*
     * @return Oid  result    */
NAN_METHOD(GitSubmodule::WdId) {
  NanEscapableScope();

  const git_oid * result = git_submodule_wd_id(
ObjectWrap::Unwrap<GitSubmodule>(args.This())->GetValue()
  );
  // null checks on pointers
  if (!result) {
    NodeGitPsueodoNanReturnEscapingValue(NanUndefined());
  }

  Handle<Value> to;
// start convert_to_v8 block
  
  if (result != NULL) {
    // GitOid result
       to = GitOid::New((void *)result, false);
   }
  else {
    to = NanNull();
  }

 // end convert_to_v8 block
  NodeGitPsueodoNanReturnEscapingValue(to);
}
      Persistent<Function> GitSubmodule::constructor_template;
 