breeze-bindgen 1.1.6 → 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
@@ -119,7 +119,8 @@ var CTypeParser = class {
119
119
  "double": "number",
120
120
  "std.string": "string",
121
121
  "std.vector": "Array",
122
- "bool": "boolean"
122
+ "bool": "boolean",
123
+ "async_simple.coro.Lazy": "Promise"
123
124
  };
124
125
  let tsBasicType = (typeMap[node.type] ?? node.type) + (node.template ? "<" + node.argsTemplate.map((a) => this.formatToTypeScript(a, namespace)).join(", ") + ">" : "");
125
126
  const ignoreTypes = ["std.variant", "std.shared_ptr", "std.function"];
@@ -148,6 +149,7 @@ var cTypeToTypeScript = (str, namespace) => {
148
149
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
149
150
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
150
151
  var DEFAULT_NAME_FILTER = "breeze::js::";
152
+ var RETRIEVE_COMMENTS_USING_AST = true;
151
153
  function parseFunctionQualType(type) {
152
154
  let State;
153
155
  ((State2) => {
@@ -247,33 +249,46 @@ declare module '${tsModuleName}' {
247
249
  if (node.name?.startsWith("$")) continue;
248
250
  const lineNum = node.loc?.line;
249
251
  let comment = "";
250
- if (lineNum) {
251
- let rangeCommentCnt = 0;
252
- for (let i = lineNum - 2; i >= 0; i--) {
253
- const line = origFileContent[i];
254
- if (!line) continue;
255
- if (line.startsWith("//")) {
256
- comment = line.substring(2) + "\n" + comment;
257
- 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");
258
259
  }
259
- if (line.startsWith("/*")) rangeCommentCnt++;
260
- if (line.endsWith("*/")) rangeCommentCnt--;
261
- if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
262
- if (line.startsWith("/*") && line.endsWith("*/")) {
263
- comment = line.substring(2, line.length - 2) + "\n" + comment;
264
- } else if (line.startsWith("/*")) {
265
- } else if (line.endsWith("*/")) {
266
- 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;
267
287
  }
268
- break;
269
- } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
270
- comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
271
- } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
272
- break;
273
288
  }
274
289
  }
290
+ comment = comment.trim();
275
291
  }
276
- comment = comment.trim();
277
292
  if (node.kind === "FieldDecl") {
278
293
  fields.push({
279
294
  name: node.name,
@@ -445,14 +460,15 @@ function generateBindingsAndDefinitions(config) {
445
460
  const clangArgs = [
446
461
  "-Xclang",
447
462
  "-ast-dump=json",
448
- "-fsyntax-only",
449
463
  "-Xclang",
450
464
  `-ast-dump-filter=${nameFilter.slice(0, -2)}`,
451
465
  "-std=c++2c",
466
+ "-fsyntax-only",
467
+ "-fparse-all-comments",
452
468
  absoluteCppFilePath
453
469
  ];
454
470
  log(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
455
- const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", shell: true });
471
+ const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", maxBuffer: 200 * 1024 * 1024 });
456
472
  if (clangProcess.error) {
457
473
  log.error(`Failed to start clang++: ${clangProcess.error.message}`);
458
474
  if (clangProcess.error.code === "ENOENT") {
package/dist/core.cjs CHANGED
@@ -329,7 +329,8 @@ var CTypeParser = class {
329
329
  "double": "number",
330
330
  "std.string": "string",
331
331
  "std.vector": "Array",
332
- "bool": "boolean"
332
+ "bool": "boolean",
333
+ "async_simple.coro.Lazy": "Promise"
333
334
  };
334
335
  let tsBasicType = (typeMap[node.type] ?? node.type) + (node.template ? "<" + node.argsTemplate.map((a) => this.formatToTypeScript(a, namespace)).join(", ") + ">" : "");
335
336
  const ignoreTypes = ["std.variant", "std.shared_ptr", "std.function"];
@@ -358,6 +359,7 @@ var cTypeToTypeScript = (str, namespace) => {
358
359
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
359
360
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
360
361
  var DEFAULT_NAME_FILTER = "breeze::js::";
362
+ var RETRIEVE_COMMENTS_USING_AST = true;
361
363
  function parseFunctionQualType(type) {
362
364
  let State;
363
365
  ((State2) => {
@@ -457,33 +459,46 @@ declare module '${tsModuleName}' {
457
459
  if (node.name?.startsWith("$")) continue;
458
460
  const lineNum = node.loc?.line;
459
461
  let comment = "";
460
- if (lineNum) {
461
- let rangeCommentCnt = 0;
462
- for (let i = lineNum - 2; i >= 0; i--) {
463
- const line = origFileContent[i];
464
- if (!line) continue;
465
- if (line.startsWith("//")) {
466
- comment = line.substring(2) + "\n" + comment;
467
- continue;
462
+ if (RETRIEVE_COMMENTS_USING_AST) {
463
+ const dfsForComment = (node2) => {
464
+ if (node2.kind === "TextComment") {
465
+ return node2.text || "";
468
466
  }
469
- if (line.startsWith("/*")) rangeCommentCnt++;
470
- if (line.endsWith("*/")) rangeCommentCnt--;
471
- if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
472
- if (line.startsWith("/*") && line.endsWith("*/")) {
473
- comment = line.substring(2, line.length - 2) + "\n" + comment;
474
- } else if (line.startsWith("/*")) {
475
- } else if (line.endsWith("*/")) {
476
- 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;
477
497
  }
478
- break;
479
- } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
480
- comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
481
- } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
482
- break;
483
498
  }
484
499
  }
500
+ comment = comment.trim();
485
501
  }
486
- comment = comment.trim();
487
502
  if (node.kind === "FieldDecl") {
488
503
  fields.push({
489
504
  name: node.name,
@@ -655,14 +670,15 @@ function generateBindingsAndDefinitions(config) {
655
670
  const clangArgs = [
656
671
  "-Xclang",
657
672
  "-ast-dump=json",
658
- "-fsyntax-only",
659
673
  "-Xclang",
660
674
  `-ast-dump-filter=${nameFilter.slice(0, -2)}`,
661
675
  "-std=c++2c",
676
+ "-fsyntax-only",
677
+ "-fparse-all-comments",
662
678
  absoluteCppFilePath
663
679
  ];
664
680
  (0, import_fancy_log.default)(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
665
- 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 });
666
682
  if (clangProcess.error) {
667
683
  import_fancy_log.default.error(`Failed to start clang++: ${clangProcess.error.message}`);
668
684
  if (clangProcess.error.code === "ENOENT") {
package/dist/core.mjs CHANGED
@@ -325,7 +325,8 @@ var CTypeParser = class {
325
325
  "double": "number",
326
326
  "std.string": "string",
327
327
  "std.vector": "Array",
328
- "bool": "boolean"
328
+ "bool": "boolean",
329
+ "async_simple.coro.Lazy": "Promise"
329
330
  };
330
331
  let tsBasicType = (typeMap[node.type] ?? node.type) + (node.template ? "<" + node.argsTemplate.map((a) => this.formatToTypeScript(a, namespace)).join(", ") + ">" : "");
331
332
  const ignoreTypes = ["std.variant", "std.shared_ptr", "std.function"];
@@ -354,6 +355,7 @@ var cTypeToTypeScript = (str, namespace) => {
354
355
  var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
355
356
  var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
356
357
  var DEFAULT_NAME_FILTER = "breeze::js::";
358
+ var RETRIEVE_COMMENTS_USING_AST = true;
357
359
  function parseFunctionQualType(type) {
358
360
  let State;
359
361
  ((State2) => {
@@ -453,33 +455,46 @@ declare module '${tsModuleName}' {
453
455
  if (node.name?.startsWith("$")) continue;
454
456
  const lineNum = node.loc?.line;
455
457
  let comment = "";
456
- if (lineNum) {
457
- let rangeCommentCnt = 0;
458
- for (let i = lineNum - 2; i >= 0; i--) {
459
- const line = origFileContent[i];
460
- if (!line) continue;
461
- if (line.startsWith("//")) {
462
- comment = line.substring(2) + "\n" + comment;
463
- continue;
458
+ if (RETRIEVE_COMMENTS_USING_AST) {
459
+ const dfsForComment = (node2) => {
460
+ if (node2.kind === "TextComment") {
461
+ return node2.text || "";
464
462
  }
465
- if (line.startsWith("/*")) rangeCommentCnt++;
466
- if (line.endsWith("*/")) rangeCommentCnt--;
467
- if (rangeCommentCnt === 0 && (line.startsWith("/*") || line.endsWith("*/"))) {
468
- if (line.startsWith("/*") && line.endsWith("*/")) {
469
- comment = line.substring(2, line.length - 2) + "\n" + comment;
470
- } else if (line.startsWith("/*")) {
471
- } else if (line.endsWith("*/")) {
472
- 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;
473
493
  }
474
- break;
475
- } else if (rangeCommentCnt > 0 || line.endsWith("*/")) {
476
- comment = line.replaceAll("/*", "").replaceAll("*/", "*") + "\n" + comment;
477
- } else if (rangeCommentCnt === 0 && !line.startsWith("//") && !line.startsWith("/*") && !line.endsWith("*/")) {
478
- break;
479
494
  }
480
495
  }
496
+ comment = comment.trim();
481
497
  }
482
- comment = comment.trim();
483
498
  if (node.kind === "FieldDecl") {
484
499
  fields.push({
485
500
  name: node.name,
@@ -651,14 +666,15 @@ function generateBindingsAndDefinitions(config) {
651
666
  const clangArgs = [
652
667
  "-Xclang",
653
668
  "-ast-dump=json",
654
- "-fsyntax-only",
655
669
  "-Xclang",
656
670
  `-ast-dump-filter=${nameFilter.slice(0, -2)}`,
657
671
  "-std=c++2c",
672
+ "-fsyntax-only",
673
+ "-fparse-all-comments",
658
674
  absoluteCppFilePath
659
675
  ];
660
676
  (0, import_fancy_log.default)(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
661
- const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", shell: true });
677
+ const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", maxBuffer: 200 * 1024 * 1024 });
662
678
  if (clangProcess.error) {
663
679
  import_fancy_log.default.error(`Failed to start clang++: ${clangProcess.error.message}`);
664
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.6",
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
  }