Describe C function prototypes in JSON.
const char* get_name(int id) {
// ...
}
=>
{
"get_name": {
"returns": "const char*",
"arguments": [
{
"type": "int",
"name": "id"
}
]
}
}
$ npm install cdefs -g
$ cdefs [-o output_file] [file1, [file2, [...]]]
Inspect ex1.c
and ex2.c
and print prototypes to stdout
.
$ cdefs example/ex1.c example/ex2.c
{
"ex1.c": {
"main": {
"returns": "int",
"arguments": [
{
"type": "int",
"name": "argc"
},
{
"type": "char**",
"name": "argv"
}
]
}
},
"ex2.c": {
"test": {
"returns": "float",
"arguments": []
},
"print": {
"returns": "void",
"arguments": [
{
"type": "char*",
"name": " str"
}
]
}
}
}
Inspect ex2.c
and save prototypes to ex2.json
:
$ cdefs example/ex2.c -o ex2.json
var cdefs = require('cdefs');
Get the prototypes for ex1.c
:
var prototypes = cdefs('./example/ex1.c');
Contributions are welcome.