Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
/src/*
!/src/functions/copy.cc
!/src/wrapper.cc
!/src/nodegit.cc

/include/*
!/include/functions/copy.h
!/include/wrapper.h

/generate/idefs.json
/binding.gyp
4 changes: 0 additions & 4 deletions 4 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ git:
branches:
only:
- master
matrix:
fast_finish: true
allow_failures:
- node_js: 0.11
4 changes: 0 additions & 4 deletions 4 appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ environment:
- nodejs_version: 0.11
- nodejs_version: 0.10

matrix:
allow_failures:
- nodejs_version: 0.11

# Get the latest stable version of Node 0.STABLE.latest
install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
Expand Down
104 changes: 0 additions & 104 deletions 104 binding.gyp

This file was deleted.

27 changes: 4 additions & 23 deletions 27 generate/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,29 +254,6 @@
"../include/diff.h",
"../include/oid.h",
"../include/types.h"
],

"fields": [
{
"name": "oid",
"cType": "git_oid"
},
{
"name": "path",
"cType": "const char *"
},
{
"name": "size",
"cType": "git_off_t"
},
{
"name": "flags",
"cType": "uint32_t"
},
{
"name": "mode",
"cType": "uint16_t"
}
]
},

Expand Down Expand Up @@ -375,6 +352,8 @@
},

"filter": {
"forwardDeclare": true,
"fields": []
},

"graph": {
Expand Down Expand Up @@ -420,6 +399,8 @@
},

"oid": {
"fields": [],

"functions": {
"git_oid_fromstr": {
"isAsync": false,
Expand Down
24 changes: 18 additions & 6 deletions 24 generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const ejs = require("ejs");
const path = require("path");
const idefs = require("./idefs");


var local = path.join.bind(null, __dirname);

var classTemplate = ejs.compile(
Expand All @@ -17,16 +16,29 @@ var headerTemplate = ejs.compile(
filename: "header.h"
});

Object.keys(idefs).forEach(function(keyName) {
var idef = idefs[keyName];
var bindingTemplate = ejs.compile(
"" + fs.readFileSync(local("templates/binding.gyp.ejs")), {});

var nodegitSourceTemplate = ejs.compile(
"" + fs.readFileSync(local("templates/nodegit.cc.ejs")), {});

if (idef.ignore) {
return;
}
var enabled = idefs.filter(function(idef) {
idef.name = path.basename(idef.filename, ".h");
return !idef.ignore;
});

enabled.forEach(function(idef) {
fs.writeFileSync(local("../include/", idef.filename), headerTemplate(idef));

fs.writeFileSync(
local("../src/", path.basename(idef.filename, ".h")) + ".cc",
classTemplate(idef));

fs.writeFileSync(local("../binding.gyp"), bindingTemplate({
idefs: idefs
}));

fs.writeFileSync(local("../src/nodegit.cc"), nodegitSourceTemplate({
idefs: idefs
}));
});
21 changes: 18 additions & 3 deletions 21 generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ var version = require("../package.json").libgit2.version;
var descriptor = require("./descriptor.json");
var libgit2 = require("./v" + version + ".json");

var structs = libgit2.types.reduce(function(memo, current) {
return memo[current[0]] = current[1], memo;
}, {});

// Extracted types.
var typeMap = require("./types.json");

Expand All @@ -29,7 +33,15 @@ typeMap.__proto__ = {
"git_branch_iterator **": { cpp: "BranchIterator", js: "Iterator" },
"git_branch_t *": { cpp: "GitBranch", js: "Branch" },
"const git_commit *[]": { cpp: "Array", js: "Array" },
"git_diff_file": { cpp: "GitDiffFile", js: "DiffFile" }
"git_diff_file": { cpp: "GitDiffFile", js: "DiffFile" },
"git_strarray": { cpp: "Array", js: "Array" },
"git_diff_notify_cb": { cpp: "GitDiffNotifyCb", js: "DiffNotifyCb" },
"unsigned char [20]": { cpp: "Array", js: "Array" },
"git_filter_init_fn": { cpp: "Function", js: "Function" },
"git_filter_shutdown_fn": { cpp: "Function", js: "Function" },
"git_filter_check_fn": { cpp: "Function", js: "Function" },
"git_filter_apply_fn": { cpp: "Function", js: "Function" },
"git_filter_cleanup_fn": { cpp: "Function", js: "Function" },
};

var files = [];
Expand Down Expand Up @@ -58,6 +70,7 @@ var fileNames = Object.keys(descriptor);

fileNames.forEach(function(fileName, index) {
var file = descriptor[fileName];
var structFile = structs["git_" + fileName];

// Constants.
file.filename = fileName + ".h";
Expand Down Expand Up @@ -90,6 +103,7 @@ fileNames.forEach(function(fileName, index) {
// No functions.
cFile = Object.create(file);
cFile.functions = [];
cFile.fields = descriptor[fileName].fields || structFile.fields;
}

// Doesn't actually exist.
Expand Down Expand Up @@ -146,17 +160,18 @@ fileNames.forEach(function(fileName, index) {
js: file.jsClassName
};

var fields = file.fields || [];
var fields = file.fields || cFile.fields || (structFile ? structFile.fields || [] : []);

// Decorate fields.
file.fields = fields.map(function(field) {
try {
field.cType = field.cType || field.type;
field.cppFunctionName = titleCase(field.name);
field.jsFunctionName = camelCase(field.name);
field.cppClassName = typeMap[field.cType].cpp;
field.jsClassName = typeMap[field.cType].js;
} catch (ex) {
console.error(field.name + " is missing a definition.");
console.error(file.filename, field.cType + " is missing a definition.");
}

return field;
Expand Down
44 changes: 44 additions & 0 deletions 44 generate/templates/binding.gyp.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This is a generated file, modify: generate/templates/binding.gyp.ejs.
{
"targets": [
{
"target_name": "nodegit",

"dependencies": [
"<(module_root_dir)/vendor/libgit2.gyp:libgit2"
],

"sources": [
"src/nodegit.cc",
"src/wrapper.cc",
"src/functions/copy.cc",
<% idefs.forEach(function(idef) { -%>
"src/<%- idef.name %>.cc",
<% }); -%>
],

"include_dirs": [
"vendor/libv8-convert",
"<!(node -e \"require('nan')\")"
],

"cflags": [
"-Wall",
],

"conditions": [
[
"OS=='mac'", {
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",

"WARNING_CFLAGS": [
"-Wno-unused-variable",
],
}
}
]
]
},
]
}
8 changes: 4 additions & 4 deletions 8 generate/templates/class.cc.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
else { return '0'; }
}
-%>
/**
* This code is auto-generated; unless you know what you're doing, do not modify!
**/
// This is a generated file, modify: generate/templates/class.cc.ejs.
#include <nan.h>
#include <string.h>

#include "git2.h"
extern "C" {
#include <git2.h>
}

#include "../include/functions/copy.h"

Expand Down
9 changes: 4 additions & 5 deletions 9 generate/templates/header.h.ejs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/**
* This code is auto-generated; unless you know what you're doing, do not modify!
**/

// This is a generated file, modify: generate/templates/header.h.ejs.
#ifndef <%- cppClassName.toUpperCase() %>_H
#define <%- cppClassName.toUpperCase() %>_H

#include <nan.h>
#include <string>

#include "git2.h"
extern "C" {
#include <git2.h>
}

<% if (typeof dependencies != 'undefined') { -%>
<% for (d in dependencies) { -%>
Expand Down
24 changes: 24 additions & 0 deletions 24 generate/templates/nodegit.cc.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This is a generated file, modify: generate/templates/nodegit.cc.ejs.
#include <v8.h>
#include <node.h>

#include "git2.h"

#include "../include/wrapper.h"
#include "../include/functions/copy.h"

<% idefs.forEach(function(idef) { -%>
#include "../include/<%- idef.filename %>"
<% }); -%>

extern "C" void init(Handle<v8::Object> target) {
NanScope();

Wrapper::Initialize(target);

<% idefs.forEach(function(idef) { -%>
<%- idef.cppClassName %>::Initialize(target);
<% }); -%>
}

NODE_MODULE(nodegit, init)
25,523 changes: 25,522 additions & 1 deletion 25,523 generate/v0.20.0.json

Large diffs are not rendered by default.

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.