Visitar URL original
Output warning in JSON generator if an unmatched argument is found in descriptor.json by rcjsuen · Pull Request #1467 · nodegit/nodegit · GitHub
Skip to content
Open
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
Output warning if unmatched arg name used in generator
When making additions to the NodeGit API, it is necessary to make
changes to the descriptor.json. Small typos can cause the generated
code to not match the expected output. We should generate a warning
if an argument name used in descriptor.json does not match the name
in the C function. This will help make it a lot easier to discover
problems in the handwritten descriptor.json file.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Mar 20, 2018
commit ae3523dcc46c0de4823facc40196095c57b3214c
14 changes: 14 additions & 0 deletions generate/scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,20 @@ var Helpers = {
}

var argOverrides = fnOverrides.args || {};
// loop over all the argument names explicitly written in descriptor.json
Object.keys(argOverrides).forEach(function(argOverride) {
// see if the argument names match a name in the C function
var found = fnDef.args.some(function(arg) {
return arg.name === argOverride;
});
if (!found) {
console.log(
"Found non-matching argument named %s in descriptor.json for C function %s",
argOverride,
fnDef.cFunctionName
);
}
});
fnDef.args.forEach(function(arg) {
Helpers.decorateArg(arg, fnDef.args, typeDef, fnDef, argOverrides[arg.name] || {}, enums);

Expand Down