Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
96 changes: 96 additions & 0 deletions generate/input/callbacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,102 @@
"error": -1
}
},
"git_filter_apply_fn": {
"args": [
{
"name": "self",
"cType": "git_filter *"
},
{
"name": "payload",
"cType": "void **"
},
{
"name": "to",
"cType": "git_buf *"
},
{
"name": "from",
"cType": "const git_buf *"
},
{
"name": "src",
"cType": "const git_filter_source *"
}
],
"return": {
"type": "int",
"noResults": -30,
"success": 0,
"error": -1
}
},
"git_filter_check_fn": {
"args": [
{
"name": "self",
"cType": "git_filter *"
},
{
"name": "payload",
"cType": "void **"
},
{
"name": "src",
"cType": "const git_filter_source *"
},
{
"name": "attr_values",
"cType": "const char **"
}
],
"return": {
"type": "int",
"noResults": -30,
"success": 0,
"error": -1
}
},
"git_filter_cleanup_fn": {
"args": [
{
"name": "self",
"cType": "git_filter *"
},
{
"name": "payload",
"cType": "void *"
}
],
"return": {
"type": "void"
}
},
"git_filter_init_fn": {
"args": [
{
"name": "self",
"cType": "git_filter *"
}
],
"return": {
"type": "int",
"noResults": 0,
"success": 0,
"error": -1
}
},
"git_filter_shutdown_fn": {
"args": [
{
"name": "self",
"cType": "git_filter *"
}
],
"return": {
"type": "void"
}
},
"git_index_matched_path_cb": {
"args": [
{
Expand Down
27 changes: 10 additions & 17 deletions generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@
}
},
"filter": {
"selfFreeing": false,
"hasConstructor": true,
"functions": {
"git_filter_list_apply_to_blob": {
"ignore": true
Expand Down Expand Up @@ -920,30 +922,21 @@
"ignore": true
}
},
"cDependencies": [
"git2/sys/filter.h"
],
"fields": {
"initialize": {
"ignore": true
},
"shutdown": {
"ignore": true
},
"check": {
"ignore": true
},
"apply": {
"ignore": true
},
"cleanup": {
"stream": {
"ignore": true
}
},
}
},
"filter_source": {
"ignore": false,
"cDependencies": [
"git2/sys/filter.h"
]
},
"filter_source": {
"ignore": true
},
"graph": {
"functions": {
"git_graph_ahead_behind": {
Expand Down
67 changes: 45 additions & 22 deletions generate/input/libgit2-supplement.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@
"git_annotated_commit_lookup"
]
],
[
"filter_source",
[
"git_filter_source_repo",
"git_filter_source_path",
"git_filter_source_filemode",
"git_filter_source_id",
"git_filter_source_mode",
"git_filter_source_flags"
]
],
[
"odb_object",
[
Expand Down Expand Up @@ -422,33 +433,23 @@
},
{
"type": "git_filter_init_fn",
"name": "initialize",
"ignore": true
"name": "initialize"
},
{
"type": "git_filter_shutdown_fn",
"name": "shutdown",
"ignore": true
"name": "shutdown"
},
{
"type": "git_filter_check_fn",
"name": "check",
"ignore": true
"name": "check"
},
{
"type": "git_filter_apply_fn",
"name": "apply",
"ignore": true
},
{
"type": "git_filter_stream_fn",
"name": "stream",
"ignore": true
"name": "apply"
},
{
"type": "git_filter_cleanup_fn",
"name": "cleanup",
"ignore": true
"name": "cleanup"
}
]
}
Expand Down Expand Up @@ -765,14 +766,26 @@
"git_annotated_commit_lookup"
]
},
"odb": {
"filter": {
"functions": [
"git_odb_object_data",
"git_odb_object_dup",
"git_odb_object_free",
"git_odb_object_id",
"git_odb_object_size",
"git_odb_object_type"
"git_filter_list_apply_to_blob",
"git_filter_list_apply_to_data",
"git_filter_list_apply_to_file",
"git_filter_list_contains",
"git_filter_list_free",
"git_filter_list_length",
"git_filter_list_load",
"git_filter_list_new",
"git_filter_list_push",
"git_filter_list_stream_blob",
"git_filter_list_stream_data",
"git_filter_list_stream_file",
"git_filter_source_filemode",
"git_filter_source_flags",
"git_filter_source_id",
"git_filter_source_mode",
"git_filter_source_path",
"git_filter_source_repo"
]
},
"merge": {
Expand All @@ -784,6 +797,16 @@
"git_merge_head_id"
]
},
"odb": {
"functions": [
"git_odb_object_data",
"git_odb_object_dup",
"git_odb_object_free",
"git_odb_object_id",
"git_odb_object_size",
"git_odb_object_type"
]
},
"reflog": {
"functions": [
"git_reflog_entry_committer",
Expand Down
11 changes: 10 additions & 1 deletion generate/scripts/generateJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module.exports = function generateJson() {
}, {}).valueOf();

// decorate the definitions with required data to build the C++ files
//TODO: add self ref tag here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment needed anymore?

types.forEach(function(typeDef) {
var typeName = typeDef.typeName;
typeDef.cType = typeName;
Expand Down Expand Up @@ -169,9 +170,18 @@ module.exports = function generateJson() {
}
};

var addSelfReferentialField = function(prop){
if (helpers.isSelfReferential(prop.type)) {
prop.isSelfReferential = true;
def.isExtendedStruct = true;
}
};

def.fields.forEach(addDependencies);
def.fields.forEach(addSelfReferentialField);
def.functions.forEach(addDependencies);


Object.keys(dependencies).forEach(function (dependencyFilename) {
def.dependencies.push("../include/" + dependencyFilename + ".h");
});
Expand All @@ -183,7 +193,6 @@ module.exports = function generateJson() {
fn.cppClassName = def.cppClassName;
});
});

// Process enums
_(enums).forEach(function(enumerable) {
output.some(function(obj) {
Expand Down
2 changes: 2 additions & 0 deletions generate/scripts/generateNativeCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ module.exports = function generateNativeCode() {
replace: require("../templates/filters/replace"),
returnsCount: require("../templates/filters/returns_count"),
returnsInfo: require("../templates/filters/returns_info"),
subtract: require("../templates/filters/subtract"),
titleCase: require("../templates/filters/title_case"),
toBool: require('../templates/filters/to_bool'),
unPointer: require("../templates/filters/un_pointer"),
setUnsigned: require("../templates/filters/unsigned"),
upper: require("../templates/filters/upper")
};

Expand Down
7 changes: 6 additions & 1 deletion generate/scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var callbackTypePattern = /\s*_cb/;
var callbackTypePattern = /\s*_(cb|fn)/,
selfReferentialTypePattern = /\s*_fn/;

var utils = require("./utils");
var _ = require("lodash");
Expand Down Expand Up @@ -93,6 +94,10 @@ var Helpers = {
&& ~cbField.name.indexOf(payloadName.replace("_payload", ""));
},

isSelfReferential: function(cType){
return selfReferentialTypePattern.test(cType);
},

getLibgitType: function(normalizedType, types) {
var libgitType;

Expand Down
6 changes: 6 additions & 0 deletions generate/templates/filters/args_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ module.exports = function(args) {

if (cArg === args.length -1) {
arg.lastArg = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire block is:

arg.lastArg = cArg === args.length - 1;
arg.firstArg = !arg.lastArg && cArg === 0;

arg.firstArg = false;
}
else if(cArg === 0){
arg.firstArg = true;
arg.lastArg = false;
}
else {
arg.lastArg = false;
arg.firstArg = false;
}

arg.cArg = cArg;
Expand Down
3 changes: 3 additions & 0 deletions generate/templates/filters/subtract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function(value, other) {
return (value - other);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need parentheses.

};
3 changes: 3 additions & 0 deletions generate/templates/filters/unsigned.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function(value) {
return value < 0 ? 0 : value;
};
36 changes: 36 additions & 0 deletions generate/templates/manual/include/async_baton.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,40 @@ struct AsyncBatonWithResult : public AsyncBaton {
}
};

struct AsyncBatonWithNoResult : public AsyncBaton {
/* ResultT result;
ResultT defaultResult;*/ // result returned if the callback doesn't return anything valid

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not apply to this structure.

void (*onCompletion)(AsyncBaton *);

void Done() {
if (onCompletion) {
onCompletion(this);
} else {
// signal completion
uv_sem_post(&semaphore);
}
}

void ExecuteAsync(ThreadPool::Callback asyncCallback, void (*onCompletion)(AsyncBaton *) = NULL) {
this->onCompletion = onCompletion;
if (!onCompletion) {
uv_sem_init(&semaphore, 0);
}

{
LockMaster::TemporaryUnlock temporaryUnlock;

libgit2ThreadPool.ExecuteReverseCallback(asyncCallback, this);

if (!onCompletion) {
// wait for completion
uv_sem_wait(&semaphore);
uv_sem_destroy(&semaphore);
}
}

return;
}
};

#endif
Loading