Commit b3258508 authored by John Haley's avatar John Haley Committed by Maximiliano Korp

Nodegit now builds off of libgit2 docs

parent 12870ac3
......@@ -78,5 +78,25 @@
"returnNoResults": 1,
"returnSuccess": 0,
"returnError": -1
},
"git_diff_file_cb": {
"args": [
{
"name": "delta",
"cType": "const git_diff_delta *"
},
{
"name": "progress",
"cType": "float"
},
{
"name": "payload",
"cType": "void *"
}
],
"returnType": "int",
"returnNoResults": 1,
"returnSuccess": 0,
"returnError": -1
}
}
This diff is collapsed.
{
"types": [
[
"git_direction",
{
"type": "enum"
}
],
[
"git_merge_options",
{
"type": "struct",
"fields": [
{
"type": "unsigned int",
"name": "version"
},
{
"type": "git_merge_tree_flag_t",
"name": "flags"
},
{
"type": "unsigned int",
"name": "rename_threshold"
},
{
"type": "unsigned int",
"name": "target_limit"
},
{
"type": "git_diff_similarity_metric *",
"name": "metric",
"ignore": true
},
{
"type": "git_merge_file_favor_t",
"name": "file_favor"
}
],
"used": {
"needs": [
"git_merge_init_options"
]
}
}
],
[
"git_off_t",
{
"type": "enum"
}
],
[
"git_remote_autotag_option_t",
{
"type": "enum"
}
],
[
"git_time_t",
{
"type": "enum"
}
],
[
"git_trace_level_t",
{
"type": "enum"
}
]
]
}
......@@ -24,9 +24,17 @@
from_{{ name }} = Buffer::Data(args[{{ jsArg }}]->ToObject());
{%elsif cppClassName|isV8Value %}
{%if cType|isPointer %}
*from_{{ name }} = ({{ cType|unPointer }}) {{ additionalCast }} {{ cast }} args[{{ jsArg }}]->To{{ cppClassName }}()->Value();
{%else%}
from_{{ name }} = ({{ cType }}) {{ additionalCast }} {{ cast }} args[{{ jsArg }}]->To{{ cppClassName }}()->Value();
{%endif%}
{%else%}
from_{{ name }} = ObjectWrap::Unwrap<{{ cppClassName }}>(args[{{ jsArg }}]->ToObject())->GetValue();
{%if cType|isDoublePointer %}
from_{{ name }} = ObjectWrap::Unwrap<{{ cppClassName }}>(args[{{ jsArg }}]->ToObject())->GetRefValue();
{%else%}
from_{{ name }} = ObjectWrap::Unwrap<{{ cppClassName }}>(args[{{ jsArg }}]->ToObject())->GetValue();
{%endif%}
{%endif%}
{%if isOptional %}
......
......@@ -9,7 +9,7 @@ var libgit2 = require("./v" + version + ".json");
var supplement = require("./libgit2-supplement.json");
// libgit2's docs aren't complete so we'll add in what they're missing here
_.merge(libgit2, supplement);
libgit2.types = libgit2.types.concat(supplement.types);
// TODO: When libgit2's docs include callbacks we should be able to remove this
var callbackDefs = require("./callbacks.json");
......@@ -333,6 +333,10 @@ output.forEach(function (def) {
}
(prop.args || []).forEach(addDependencies);
if (prop.return) {
addDependencies(prop.return);
}
};
def.fields.forEach(addDependencies);
......
......@@ -47,26 +47,28 @@ using namespace std;
void {{ cppClassName }}::ConstructFields() {
{%each fields|fieldsInfo as field %}
{%if not field.isEnum %}
{%if field.hasConstructor %}
{%if not field.ignore %}
{%if not field.isEnum %}
{%if field.hasConstructor %}
Local<Object> {{ field.name }}Temp = {{ field.cppClassName }}::New(&this->raw->{{ field.name }}, false)->ToObject();
NanAssignPersistent(this->{{ field.name }}, {{ field.name }}Temp);
{%elsif field.isLibgitType %}
{%elsif field.isLibgitType %}
Local<Object> {{ field.name }}Temp = {{ field.cppClassName }}::New(&this->raw->{{ field.name }}, false)->ToObject();
NanAssignPersistent(this->{{ field.name }}, {{ field.name }}Temp);
{%elsif field.isCallbackFunction %}
{%elsif field.isCallbackFunction %}
// Set the static method call and set the payload for this function to be
// the current instance
this->raw->{{ field.name }} = ({{ field.cType }}){{ field.name }}_cppCallback;
this->raw->{{ fields|payloadFor field.name }} = (void *)this;
this->{{ field.name }} = new NanCallback();
{%elsif field.payloadFor %}
{%elsif field.payloadFor %}
Local<Value> {{ field.name }} = NanUndefined();
NanAssignPersistent(this->{{ field.name }}, {{ field.name }});
{%endif%}
{%endif%}
{%endif%}
{%endeach%}
......
......@@ -4,6 +4,7 @@ var callbackFunctionNamePattern = /\s*_cb/;
var cTypeMappings = {
"char": "String",
"short": "Number",
"int": "Number",
"int16_t": "Number",
"int32_t": "Number",
......@@ -48,6 +49,7 @@ var Utils = {
.toLowerCase()
.replace("const ", "")
.replace("unsigned ", "")
.replace("struct", "")
.replace(doublePointerRegex, "")
.replace(pointerRegex, "")
.trim();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment