Installations
npm install nid-parser
Developer Guide
Typescript
No
Module System
CommonJS
NPM Version
1.4.9
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
CodeCharmLtd
Download Statistics
Total Downloads
16,727
Last Day
11
Last Week
65
Last Month
288
Last Year
5,786
GitHub Statistics
3 Stars
18 Commits
3 Forks
4 Watching
1 Branches
4 Contributors
Package Meta Information
Latest Version
0.0.5
Package Id
nid-parser@0.0.5
Size
10.45 kB
NPM Version
1.4.9
Total Downloads
Cumulative downloads
Total Downloads
16,727
Last day
-66.7%
11
Compared to previous day
Last week
-27%
65
Compared to previous week
Last month
-12.5%
288
Compared to previous month
Last year
277.7%
5,786
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Note: this is preliminary (version 0.0.1) and will undergo serious changes, breaking in format etc. Open issues for suggestions, bug reports etc.
Native Interface Definition
NID is a subset of C/C++ and the concept is inspired by tolua++
tool for the LUA language. The idea is to write a simplified C/C++ header with additional attributes which should convey the higher-level purpose of the API.
This software provides a parser component written in Node.JS which parses .nid
files into a JSON structure.
Couple of rules
- Comments are stripped.
- No preprocessor but
#include <header>
will be parsed and shown in JSON. - Function and variable declarations are parsed.
- C++11 attributes are shown in JSON and can be used to improve the bindings.
Usage
As executable:
# npm install -g nid-parser
# nid input.nid
As dependency:
# npm install --save nid-parser
1var nid = require('nid'); 2nid.parse(fs.readFileSync('sample.nid').toString('utf8'));
Example (taken from tests)
1#include <stdio.h> 2#include <math.h> 3 4FILE* stdin; 5FILE* stdout; 6 7int some_random_integer; 8 9namespace std { 10 11 double sqrt(double x); 12 float sqrtf(float x); 13 long double sqrtl(long double x); 14} 15 16[[handle,free(fclose)]] FILE* fopen(const char* filename, const char* mode); 17 18size_t fread([[cast(char*)]] void* ptr, size_t size, size_t nmemb, [[handle]] FILE* stream); 19 20[[destructor]] int fclose(FILE* f); 21 22class Rect { 23 24 Rect(int x, int y, int w, int h); 25 26 [[get(x)]] int x(); 27 [[set(x)]] void setX(int x); 28 [[get(y)]] int y(); 29 [[set(y)]] void setY(int y); 30 31 [[get(width)]] int width(); 32 [[set(width)]] void setWidth(int width); 33 34 [[get(height)]] int height(); 35 [[set(height)]] void setHeight(int height); 36 37 int area(); 38 39 static int sharedArea(Rect a, Rect b); 40}; 41 42
1{ 2 "declarations": [ 3 { 4 "pragma": "#include <stdio.h>" 5 }, 6 { 7 "pragma": "#include <math.h>" 8 }, 9 { 10 "variable": { 11 "type": "FILE", 12 "pointer": "*", 13 "attributes": {}, 14 "name": "stdin" 15 } 16 }, 17 { 18 "variable": { 19 "type": "FILE", 20 "pointer": "*", 21 "attributes": {}, 22 "name": "stdout" 23 } 24 }, 25 { 26 "variable": { 27 "type": "int", 28 "name": "some_random_integer", 29 "attributes": {} 30 } 31 }, 32 { 33 "namespace": { 34 "name": "std", 35 "declarations": [ 36 { 37 "function": { 38 "type": "double", 39 "name": "sqrt", 40 "attributes": {}, 41 "parameters": [ 42 { 43 "type": "double", 44 "name": "x", 45 "attributes": {} 46 } 47 ] 48 } 49 }, 50 { 51 "function": { 52 "type": "float", 53 "name": "sqrtf", 54 "attributes": {}, 55 "parameters": [ 56 { 57 "type": "float", 58 "name": "x", 59 "attributes": {} 60 } 61 ] 62 } 63 }, 64 { 65 "function": { 66 "type": "double long", 67 "name": "sqrtl", 68 "attributes": {}, 69 "parameters": [ 70 { 71 "type": "double long", 72 "name": "x", 73 "attributes": {} 74 } 75 ] 76 } 77 } 78 ] 79 } 80 }, 81 { 82 "variable": { 83 "type": "FILE", 84 "pointer": "*", 85 "attributes": { 86 "handle": true, 87 "free": "fclose" 88 }, 89 "name": "fopen", 90 "parameters": [ 91 { 92 "type": "const char", 93 "pointer": "*", 94 "attributes": {}, 95 "name": "filename" 96 }, 97 { 98 "type": "const char", 99 "pointer": "*", 100 "attributes": {}, 101 "name": "mode" 102 } 103 ] 104 } 105 }, 106 { 107 "function": { 108 "type": "size_t", 109 "name": "fread", 110 "attributes": {}, 111 "parameters": [ 112 { 113 "type": "void", 114 "pointer": "*", 115 "attributes": { 116 "cast": "char*" 117 }, 118 "name": "ptr" 119 }, 120 { 121 "type": "size_t", 122 "name": "size", 123 "attributes": {} 124 }, 125 { 126 "type": "size_t", 127 "name": "nmemb", 128 "attributes": {} 129 }, 130 { 131 "type": "FILE", 132 "pointer": "*", 133 "attributes": { 134 "handle": true 135 }, 136 "name": "stream" 137 } 138 ] 139 } 140 }, 141 { 142 "function": { 143 "type": "int", 144 "name": "fclose", 145 "attributes": { 146 "destructor": true 147 }, 148 "parameters": [ 149 { 150 "type": "FILE", 151 "pointer": "*", 152 "attributes": {}, 153 "name": "f" 154 } 155 ] 156 } 157 }, 158 { 159 "class": { 160 "name": "Rect", 161 "declarations": [ 162 { 163 "constructor": { 164 "name": "Rect", 165 "attributes": {}, 166 "parameters": [ 167 { 168 "type": "int", 169 "name": "x", 170 "attributes": {} 171 }, 172 { 173 "type": "int", 174 "name": "y", 175 "attributes": {} 176 }, 177 { 178 "type": "int", 179 "name": "w", 180 "attributes": {} 181 }, 182 { 183 "type": "int", 184 "name": "h", 185 "attributes": {} 186 } 187 ] 188 } 189 }, 190 { 191 "function": { 192 "type": "int", 193 "name": "x", 194 "attributes": { 195 "get": "x" 196 }, 197 "parameters": [] 198 } 199 }, 200 { 201 "function": { 202 "type": "void", 203 "name": "setX", 204 "attributes": { 205 "set": "x" 206 }, 207 "parameters": [ 208 { 209 "type": "int", 210 "name": "x", 211 "attributes": {} 212 } 213 ] 214 } 215 }, 216 { 217 "function": { 218 "type": "int", 219 "name": "y", 220 "attributes": { 221 "get": "y" 222 }, 223 "parameters": [] 224 } 225 }, 226 { 227 "function": { 228 "type": "void", 229 "name": "setY", 230 "attributes": { 231 "set": "y" 232 }, 233 "parameters": [ 234 { 235 "type": "int", 236 "name": "y", 237 "attributes": {} 238 } 239 ] 240 } 241 }, 242 { 243 "function": { 244 "type": "int", 245 "name": "width", 246 "attributes": { 247 "get": "width" 248 }, 249 "parameters": [] 250 } 251 }, 252 { 253 "function": { 254 "type": "void", 255 "name": "setWidth", 256 "attributes": { 257 "set": "width" 258 }, 259 "parameters": [ 260 { 261 "type": "int", 262 "name": "width", 263 "attributes": {} 264 } 265 ] 266 } 267 }, 268 { 269 "function": { 270 "type": "int", 271 "name": "height", 272 "attributes": { 273 "get": "height" 274 }, 275 "parameters": [] 276 } 277 }, 278 { 279 "function": { 280 "type": "void", 281 "name": "setHeight", 282 "attributes": { 283 "set": "height" 284 }, 285 "parameters": [ 286 { 287 "type": "int", 288 "name": "height", 289 "attributes": {} 290 } 291 ] 292 } 293 }, 294 { 295 "function": { 296 "type": "int", 297 "name": "area", 298 "attributes": {}, 299 "parameters": [] 300 } 301 }, 302 { 303 "function": { 304 "type": "int static", 305 "name": "sharedArea", 306 "attributes": {}, 307 "parameters": [ 308 { 309 "type": "Rect", 310 "name": "a", 311 "attributes": {} 312 }, 313 { 314 "type": "Rect", 315 "name": "b", 316 "attributes": {} 317 } 318 ] 319 } 320 } 321 ] 322 } 323 } 324 ] 325}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
Reason
Found 1/12 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
2.8
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More