Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
rename create{X} to create
  • Loading branch information
maxkorp committed Oct 22, 2014
commit f2a18f5f6de294eb4cb19c8129b0aed715ac8ded
13 changes: 11 additions & 2 deletions generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fileNames.forEach(function(fileName, index) {
}

file.freeFunctionName = "git_" + fileName + "_free";
file.createFunctionName = "git_" + fileName + "_create";
}

// TODO Obsolete this.
Expand All @@ -136,12 +137,14 @@ fileNames.forEach(function(fileName, index) {
return fnName === initFnName;
});

// Doesn't actually exist.
// Free function doesn't actually exist.
if (cFile.functions.indexOf(file.freeFunctionName) === -1) {
delete file.freeFunctionName;
}


if (cFile.functions.indexOf(file.createFunctionName) === -1) {
delete file.createFunctionName;
}
var legacyFile = {};

if (file.jsClassName.indexOf("Git") === 0) {
Expand Down Expand Up @@ -394,6 +397,12 @@ fileNames.forEach(function(fileName, index) {
}
});

if (file.createFunctionName) {
file.cppCreateFunctionName = typeMap[file.createFunctionName].cpp;
file.jsCreateFunctionName = typeMap[file.createFunctionName].js;
delete file.createFunctionName;
}

files.push(file);
});

Expand Down
6 changes: 5 additions & 1 deletion generate/templates/class_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ NAN_METHOD({{ cppClassName }}::New) {
NanScope();

if (args.Length() == 0 || !args[0]->IsExternal()) {
return NanThrowError("{{ cType }} is required.");
{%if createFunctionName%}
return NanThrowError("A new {{ cppClassName }} cannot be instantiated. Use {{ jsCreateFunctionName }} instead.");
{%else%}
return NanThrowError("A new {{ cppClassName }} cannot be instantiated.");
{%endif%}
}

{{ cppClassName }}* object = new {{ cppClassName }}(static_cast<{{ cType }} *>(Handle<External>::Cast(args[0])->Value()), args[1]->BooleanValue());
Expand Down
8 changes: 4 additions & 4 deletions test/tests/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ describe("Commit", function() {
history.on("commit", function(commit) {
historyCount++;
});

history.on("end", function(commits) {
assert.equal(historyCount, expectedHistoryCount);
assert.equal(commits.length, expectedHistoryCount);

done();
});

history.on("error", function(err) {
assert.ok(false);
});

history.start();
});

Expand Down Expand Up @@ -143,7 +143,7 @@ describe("Commit", function() {
treeWalker.on("error", function() {
assert.ok(false);
});

treeWalker.on("end", function(entries) {
assert.equal(commitTreeEntryCount, expectedCommitTreeEntryCount);
done();
Expand Down