breeze-bindgen 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -149,6 +149,7 @@ var cTypeToTypeScript = (str, namespace) => {
149
149
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
150
150
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
151
151
  var DEFAULT_NAME_FILTER = "breeze::js::";
152
+ var RETRIEVE_COMMENTS_USING_AST = true;
152
153
  function parseFunctionQualType(type) {
153
154
  let State;
154
155
  ((State2) => {
@@ -248,33 +249,46 @@ declare module '${tsModuleName}' {
248
249
  if (node.name?.startsWith("$")) continue;
249
250
  const lineNum = node.loc?.line;
250
251
  let comment = "";
251
- if (lineNum) {
252
- let rangeCommentCnt = 0;
253
- for (let i = lineNum - 2; i >= 0; i--) {
254
- const line = origFileContent[i];
255
- if (!line) continue;
256
- if (line.startsWith("//")) {
257
- comment = line.substring(2) + "\n" + comment;
258
- continue;
252
+ if (RETRIEVE_COMMENTS_USING_AST) {
253
+ const dfsForComment = (node2) => {
254
+ if (node2.kind === "TextComment") {
255
+ return node2.text || "";
256
+ }
257
+ if (node2.inner) {
258
+ return node2.inner.map(dfsForComment).filter(Boolean).join("\n");
259
259
  }
260
- if (line.startsWith("/*")) rangeCommentCnt++;
261
- if (line.endsWith("*/")) rangeCommentCnt--;
262
- if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
263
- if (line.startsWith("/*") && line.endsWith("*/")) {
264
- comment = line.substring(2, line.length - 2) + "\n" + comment;
265
- } else if (line.startsWith("/*")) {
266
- } else if (line.endsWith("*/")) {
267
- comment = line.substring(0, line.length - 2) + "\n" + comment;
260
+ return "";
261
+ };
262
+ comment = dfsForComment(node);
263
+ } else {
264
+ if (lineNum) {
265
+ let rangeCommentCnt = 0;
266
+ for (let i = lineNum - 2; i >= 0; i--) {
267
+ const line = origFileContent[i];
268
+ if (!line) continue;
269
+ if (line.startsWith("//")) {
270
+ comment = line.substring(2) + "\n" + comment;
271
+ continue;
272
+ }
273
+ if (line.startsWith("/*")) rangeCommentCnt++;
274
+ if (line.endsWith("*/")) rangeCommentCnt--;
275
+ if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
276
+ if (line.startsWith("/*") && line.endsWith("*/")) {
277
+ comment = line.substring(2, line.length - 2) + "\n" + comment;
278
+ } else if (line.startsWith("/*")) {
279
+ } else if (line.endsWith("*/")) {
280
+ comment = line.substring(0, line.length - 2) + "\n" + comment;
281
+ }
282
+ break;
283
+ } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
284
+ comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
285
+ } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
286
+ break;
268
287
  }
269
- break;
270
- } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
271
- comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
272
- } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
273
- break;
274
288
  }
275
289
  }
290
+ comment = comment.trim();
276
291
  }
277
- comment = comment.trim();
278
292
  if (node.kind === "FieldDecl") {
279
293
  fields.push({
280
294
  name: node.name,
@@ -446,14 +460,15 @@ function generateBindingsAndDefinitions(config) {
446
460
  const clangArgs = [
447
461
  "-Xclang",
448
462
  "-ast-dump=json",
449
- "-fsyntax-only",
450
463
  "-Xclang",
451
464
  `-ast-dump-filter=${nameFilter.slice(0, -2)}`,
452
465
  "-std=c++2c",
466
+ "-fsyntax-only",
467
+ "-fparse-all-comments",
453
468
  absoluteCppFilePath
454
469
  ];
455
470
  log(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
456
- const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", shell: true });
471
+ const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", maxBuffer: 200 * 1024 * 1024 });
457
472
  if (clangProcess.error) {
458
473
  log.error(`Failed to start clang++: ${clangProcess.error.message}`);
459
474
  if (clangProcess.error.code === "ENOENT") {
package/dist/core.cjs CHANGED
@@ -359,6 +359,7 @@ var cTypeToTypeScript = (str, namespace) => {
359
359
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
360
360
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
361
361
  var DEFAULT_NAME_FILTER = "breeze::js::";
362
+ var RETRIEVE_COMMENTS_USING_AST = true;
362
363
  function parseFunctionQualType(type) {
363
364
  let State;
364
365
  ((State2) => {
@@ -458,33 +459,46 @@ declare module '${tsModuleName}' {
458
459
  if (node.name?.startsWith("$")) continue;
459
460
  const lineNum = node.loc?.line;
460
461
  let comment = "";
461
- if (lineNum) {
462
- let rangeCommentCnt = 0;
463
- for (let i = lineNum - 2; i >= 0; i--) {
464
- const line = origFileContent[i];
465
- if (!line) continue;
466
- if (line.startsWith("//")) {
467
- comment = line.substring(2) + "\n" + comment;
468
- continue;
462
+ if (RETRIEVE_COMMENTS_USING_AST) {
463
+ const dfsForComment = (node2) => {
464
+ if (node2.kind === "TextComment") {
465
+ return node2.text || "";
469
466
  }
470
- if (line.startsWith("/*")) rangeCommentCnt++;
471
- if (line.endsWith("*/")) rangeCommentCnt--;
472
- if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
473
- if (line.startsWith("/*") && line.endsWith("*/")) {
474
- comment = line.substring(2, line.length - 2) + "\n" + comment;
475
- } else if (line.startsWith("/*")) {
476
- } else if (line.endsWith("*/")) {
477
- comment = line.substring(0, line.length - 2) + "\n" + comment;
467
+ if (node2.inner) {
468
+ return node2.inner.map(dfsForComment).filter(Boolean).join("\n");
469
+ }
470
+ return "";
471
+ };
472
+ comment = dfsForComment(node);
473
+ } else {
474
+ if (lineNum) {
475
+ let rangeCommentCnt = 0;
476
+ for (let i = lineNum - 2; i >= 0; i--) {
477
+ const line = origFileContent[i];
478
+ if (!line) continue;
479
+ if (line.startsWith("//")) {
480
+ comment = line.substring(2) + "\n" + comment;
481
+ continue;
482
+ }
483
+ if (line.startsWith("/*")) rangeCommentCnt++;
484
+ if (line.endsWith("*/")) rangeCommentCnt--;
485
+ if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
486
+ if (line.startsWith("/*") && line.endsWith("*/")) {
487
+ comment = line.substring(2, line.length - 2) + "\n" + comment;
488
+ } else if (line.startsWith("/*")) {
489
+ } else if (line.endsWith("*/")) {
490
+ comment = line.substring(0, line.length - 2) + "\n" + comment;
491
+ }
492
+ break;
493
+ } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
494
+ comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
495
+ } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
496
+ break;
478
497
  }
479
- break;
480
- } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
481
- comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
482
- } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
483
- break;
484
498
  }
485
499
  }
500
+ comment = comment.trim();
486
501
  }
487
- comment = comment.trim();
488
502
  if (node.kind === "FieldDecl") {
489
503
  fields.push({
490
504
  name: node.name,
@@ -656,14 +670,15 @@ function generateBindingsAndDefinitions(config) {
656
670
  const clangArgs = [
657
671
  "-Xclang",
658
672
  "-ast-dump=json",
659
- "-fsyntax-only",
660
673
  "-Xclang",
661
674
  `-ast-dump-filter=${nameFilter.slice(0, -2)}`,
662
675
  "-std=c++2c",
676
+ "-fsyntax-only",
677
+ "-fparse-all-comments",
663
678
  absoluteCppFilePath
664
679
  ];
665
680
  (0, import_fancy_log.default)(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
666
- const clangProcess = (0, import_node_child_process.spawnSync)(clangPath, clangArgs, { encoding: "utf-8", shell: true });
681
+ const clangProcess = (0, import_node_child_process.spawnSync)(clangPath, clangArgs, { encoding: "utf-8", maxBuffer: 200 * 1024 * 1024 });
667
682
  if (clangProcess.error) {
668
683
  import_fancy_log.default.error(`Failed to start clang++: ${clangProcess.error.message}`);
669
684
  if (clangProcess.error.code === "ENOENT") {
package/dist/core.mjs CHANGED
@@ -355,6 +355,7 @@ var cTypeToTypeScript = (str, namespace) => {
355
355
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
356
356
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
357
357
  var DEFAULT_NAME_FILTER = "breeze::js::";
358
+ var RETRIEVE_COMMENTS_USING_AST = true;
358
359
  function parseFunctionQualType(type) {
359
360
  let State;
360
361
  ((State2) => {
@@ -454,33 +455,46 @@ declare module '${tsModuleName}' {
454
455
  if (node.name?.startsWith("$")) continue;
455
456
  const lineNum = node.loc?.line;
456
457
  let comment = "";
457
- if (lineNum) {
458
- let rangeCommentCnt = 0;
459
- for (let i = lineNum - 2; i >= 0; i--) {
460
- const line = origFileContent[i];
461
- if (!line) continue;
462
- if (line.startsWith("//")) {
463
- comment = line.substring(2) + "\n" + comment;
464
- continue;
458
+ if (RETRIEVE_COMMENTS_USING_AST) {
459
+ const dfsForComment = (node2) => {
460
+ if (node2.kind === "TextComment") {
461
+ return node2.text || "";
465
462
  }
466
- if (line.startsWith("/*")) rangeCommentCnt++;
467
- if (line.endsWith("*/")) rangeCommentCnt--;
468
- if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
469
- if (line.startsWith("/*") && line.endsWith("*/")) {
470
- comment = line.substring(2, line.length - 2) + "\n" + comment;
471
- } else if (line.startsWith("/*")) {
472
- } else if (line.endsWith("*/")) {
473
- comment = line.substring(0, line.length - 2) + "\n" + comment;
463
+ if (node2.inner) {
464
+ return node2.inner.map(dfsForComment).filter(Boolean).join("\n");
465
+ }
466
+ return "";
467
+ };
468
+ comment = dfsForComment(node);
469
+ } else {
470
+ if (lineNum) {
471
+ let rangeCommentCnt = 0;
472
+ for (let i = lineNum - 2; i >= 0; i--) {
473
+ const line = origFileContent[i];
474
+ if (!line) continue;
475
+ if (line.startsWith("//")) {
476
+ comment = line.substring(2) + "\n" + comment;
477
+ continue;
478
+ }
479
+ if (line.startsWith("/*")) rangeCommentCnt++;
480
+ if (line.endsWith("*/")) rangeCommentCnt--;
481
+ if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
482
+ if (line.startsWith("/*") && line.endsWith("*/")) {
483
+ comment = line.substring(2, line.length - 2) + "\n" + comment;
484
+ } else if (line.startsWith("/*")) {
485
+ } else if (line.endsWith("*/")) {
486
+ comment = line.substring(0, line.length - 2) + "\n" + comment;
487
+ }
488
+ break;
489
+ } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
490
+ comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
491
+ } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
492
+ break;
474
493
  }
475
- break;
476
- } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
477
- comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
478
- } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
479
- break;
480
494
  }
481
495
  }
496
+ comment = comment.trim();
482
497
  }
483
- comment = comment.trim();
484
498
  if (node.kind === "FieldDecl") {
485
499
  fields.push({
486
500
  name: node.name,
@@ -652,14 +666,15 @@ function generateBindingsAndDefinitions(config) {
652
666
  const clangArgs = [
653
667
  "-Xclang",
654
668
  "-ast-dump=json",
655
- "-fsyntax-only",
656
669
  "-Xclang",
657
670
  `-ast-dump-filter=${nameFilter.slice(0, -2)}`,
658
671
  "-std=c++2c",
672
+ "-fsyntax-only",
673
+ "-fparse-all-comments",
659
674
  absoluteCppFilePath
660
675
  ];
661
676
  (0, import_fancy_log.default)(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
662
- const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", shell: true });
677
+ const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", maxBuffer: 200 * 1024 * 1024 });
663
678
  if (clangProcess.error) {
664
679
  import_fancy_log.default.error(`Failed to start clang++: ${clangProcess.error.message}`);
665
680
  if (clangProcess.error.code === "ENOENT") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
3
3
  "name": "breeze-bindgen",
4
- "version": "1.1.7",
4
+ "version": "1.1.8",
5
5
  "main": "dist/core.cjs",
6
6
  "module": "dist/core.mjs",
7
7
  "types": "dist/core.d.ts",
@@ -30,6 +30,7 @@
30
30
  "cli": "node -r esbuild-register src/cli.ts",
31
31
  "typegen": "node -r esbuild-register src/typegen.ts",
32
32
  "parser-test": "node -r esbuild-register src/c-type-parser.ts",
33
- "build-types": "tsc -p ./tsconfig.json --emitDeclarationOnly --declaration --outdir dist"
33
+ "build-types": "tsc -p ./tsconfig.json --emitDeclarationOnly --declaration --outdir dist",
34
+ "test": "yarn cli -i D:\\breeze-shell\\src\\shell\\script\\binding_types.hpp -o test --nameFilter mb_shell::js"
34
35
  }
35
36
  }