breeze-bindgen 1.1.4 → 1.1.6
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/README.md +2 -0
- package/dist/c-type-parser.d.ts +18 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +10 -13
- package/dist/core.cjs +3 -7
- package/dist/core.d.ts +12 -0
- package/dist/core.mjs +4 -7
- package/dist/typegen.d.ts +1 -0
- package/package.json +10 -10
package/README.md
CHANGED
@@ -37,6 +37,7 @@ The `breeze-bindgen` command-line tool can be used to generate bindings and defi
|
|
37
37
|
breeze-bindgen -i <input_header_file> [options]
|
38
38
|
```
|
39
39
|
|
40
|
+
```
|
40
41
|
**Options:**
|
41
42
|
|
42
43
|
--version Show version number [boolean]
|
@@ -56,6 +57,7 @@ breeze-bindgen -i <input_header_file> [options]
|
|
56
57
|
--nameFilter Clang AST dump filter for names (e.g.,
|
57
58
|
"breeze::js"). [string] [default: "breeze::js"]
|
58
59
|
-h, --help Show help [boolean]
|
60
|
+
```
|
59
61
|
|
60
62
|
**Example:**
|
61
63
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export interface CTypeNode {
|
2
|
+
function: boolean;
|
3
|
+
template: boolean;
|
4
|
+
type: string;
|
5
|
+
argsTemplate: CTypeNode[];
|
6
|
+
argsFunc: CTypeNode[];
|
7
|
+
}
|
8
|
+
export declare class CTypeParser {
|
9
|
+
tokens: string[];
|
10
|
+
cursor: number;
|
11
|
+
lex(str: string): void;
|
12
|
+
parse(str?: string | null, typeTransformer?: (orig: string) => string): CTypeNode;
|
13
|
+
eat(token: any, force?: boolean): boolean;
|
14
|
+
next(token?: string | null): string | false;
|
15
|
+
formatToC(node: CTypeNode): string;
|
16
|
+
formatToTypeScript(node: CTypeNode, namespace?: string): string;
|
17
|
+
}
|
18
|
+
export declare const cTypeToTypeScript: (str: string, namespace: string) => string;
|
package/dist/cli.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/dist/cli.mjs
CHANGED
@@ -6,17 +6,16 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
6
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
7
7
|
});
|
8
8
|
|
9
|
-
// cli.ts
|
9
|
+
// src/cli.ts
|
10
10
|
import log2 from "fancy-log";
|
11
11
|
|
12
|
-
// core.ts
|
12
|
+
// src/core.ts
|
13
13
|
import log from "fancy-log";
|
14
14
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
15
|
-
import { join,
|
16
|
-
import { fileURLToPath } from "node:url";
|
15
|
+
import { join, resolve as resolvePath } from "node:path";
|
17
16
|
import { spawnSync } from "node:child_process";
|
18
17
|
|
19
|
-
// c-type-parser.ts
|
18
|
+
// src/c-type-parser.ts
|
20
19
|
var CTypeParser = class {
|
21
20
|
constructor() {
|
22
21
|
this.tokens = [];
|
@@ -145,7 +144,7 @@ var cTypeToTypeScript = (str, namespace) => {
|
|
145
144
|
return parser2.formatToTypeScript(res, namespace);
|
146
145
|
};
|
147
146
|
|
148
|
-
// core.ts
|
147
|
+
// src/core.ts
|
149
148
|
var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
|
150
149
|
var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
|
151
150
|
var DEFAULT_NAME_FILTER = "breeze::js::";
|
@@ -443,8 +442,6 @@ function generateBindingsAndDefinitions(config) {
|
|
443
442
|
} = config;
|
444
443
|
const absoluteCppFilePath = resolvePath(cppFilePath);
|
445
444
|
const absoluteOutputDir = resolvePath(outputDir);
|
446
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
447
|
-
const bindgenDir = dirname(currentFilePath);
|
448
445
|
const clangArgs = [
|
449
446
|
"-Xclang",
|
450
447
|
"-ast-dump=json",
|
@@ -498,7 +495,7 @@ ${clangProcess.stderr}`);
|
|
498
495
|
log(`Bindings generated successfully in ${absoluteOutputDir}`);
|
499
496
|
}
|
500
497
|
|
501
|
-
// cli.ts
|
498
|
+
// src/cli.ts
|
502
499
|
import { resolve as resolvePath2, join as joinPath, dirname as dirname4 } from "node:path";
|
503
500
|
|
504
501
|
// node_modules/yargs/lib/platform-shims/esm.mjs
|
@@ -812,7 +809,7 @@ function sync_default(start, callback) {
|
|
812
809
|
// node_modules/yargs/lib/platform-shims/esm.mjs
|
813
810
|
import { format as format3, inspect } from "util";
|
814
811
|
import { readFileSync as readFileSync4 } from "fs";
|
815
|
-
import { fileURLToPath
|
812
|
+
import { fileURLToPath } from "url";
|
816
813
|
|
817
814
|
// node_modules/yargs-parser/build/lib/index.js
|
818
815
|
import { format } from "util";
|
@@ -2012,8 +2009,8 @@ var y18n_default = y18n2;
|
|
2012
2009
|
// node_modules/yargs/lib/platform-shims/esm.mjs
|
2013
2010
|
var REQUIRE_ERROR = "require is not supported by ESM";
|
2014
2011
|
var REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM";
|
2015
|
-
var mainFilename =
|
2016
|
-
var __dirname =
|
2012
|
+
var mainFilename = fileURLToPath(import.meta.url).split("node_modules")[0];
|
2013
|
+
var __dirname = fileURLToPath(import.meta.url);
|
2017
2014
|
var esm_default = {
|
2018
2015
|
assert: {
|
2019
2016
|
notStrictEqual,
|
@@ -5169,7 +5166,7 @@ function isYargsInstance(y) {
|
|
5169
5166
|
var Yargs = YargsFactory(esm_default);
|
5170
5167
|
var yargs_default = Yargs;
|
5171
5168
|
|
5172
|
-
// cli.ts
|
5169
|
+
// src/cli.ts
|
5173
5170
|
import { readFileSync as readFileSync5 } from "node:fs";
|
5174
5171
|
async function main() {
|
5175
5172
|
const argv = await yargs_default(hideBin(process.argv)).option("input", {
|
package/dist/core.cjs
CHANGED
@@ -214,7 +214,7 @@ var require_fancy_log = __commonJS({
|
|
214
214
|
}
|
215
215
|
});
|
216
216
|
|
217
|
-
// core.ts
|
217
|
+
// src/core.ts
|
218
218
|
var core_exports = {};
|
219
219
|
__export(core_exports, {
|
220
220
|
generateBindingsAndDefinitions: () => generateBindingsAndDefinitions
|
@@ -223,10 +223,9 @@ module.exports = __toCommonJS(core_exports);
|
|
223
223
|
var import_fancy_log = __toESM(require_fancy_log());
|
224
224
|
var import_node_fs = require("node:fs");
|
225
225
|
var import_node_path = require("node:path");
|
226
|
-
var import_node_url = require("node:url");
|
227
226
|
var import_node_child_process = require("node:child_process");
|
228
227
|
|
229
|
-
// c-type-parser.ts
|
228
|
+
// src/c-type-parser.ts
|
230
229
|
var CTypeParser = class {
|
231
230
|
constructor() {
|
232
231
|
this.tokens = [];
|
@@ -355,8 +354,7 @@ var cTypeToTypeScript = (str, namespace) => {
|
|
355
354
|
return parser.formatToTypeScript(res, namespace);
|
356
355
|
};
|
357
356
|
|
358
|
-
// core.ts
|
359
|
-
var import_meta = {};
|
357
|
+
// src/core.ts
|
360
358
|
var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
|
361
359
|
var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
|
362
360
|
var DEFAULT_NAME_FILTER = "breeze::js::";
|
@@ -654,8 +652,6 @@ function generateBindingsAndDefinitions(config) {
|
|
654
652
|
} = config;
|
655
653
|
const absoluteCppFilePath = (0, import_node_path.resolve)(cppFilePath);
|
656
654
|
const absoluteOutputDir = (0, import_node_path.resolve)(outputDir);
|
657
|
-
const currentFilePath = (0, import_node_url.fileURLToPath)(import_meta.url);
|
658
|
-
const bindgenDir = (0, import_node_path.dirname)(currentFilePath);
|
659
655
|
const clangArgs = [
|
660
656
|
"-Xclang",
|
661
657
|
"-ast-dump=json",
|
package/dist/core.d.ts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
interface BindgenConfig {
|
2
|
+
cppFilePath: string;
|
3
|
+
outputDir: string;
|
4
|
+
clangPath?: string;
|
5
|
+
cppBindingOutputFile?: string;
|
6
|
+
tsDefinitionOutputFile?: string;
|
7
|
+
additionalTypes?: string;
|
8
|
+
tsModuleName?: string;
|
9
|
+
nameFilter?: string;
|
10
|
+
}
|
11
|
+
export declare function generateBindingsAndDefinitions(config: BindgenConfig): void;
|
12
|
+
export {};
|
package/dist/core.mjs
CHANGED
@@ -215,14 +215,13 @@ var require_fancy_log = __commonJS({
|
|
215
215
|
}
|
216
216
|
});
|
217
217
|
|
218
|
-
// core.ts
|
218
|
+
// src/core.ts
|
219
219
|
var import_fancy_log = __toESM(require_fancy_log());
|
220
220
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
221
|
-
import { join,
|
222
|
-
import { fileURLToPath } from "node:url";
|
221
|
+
import { join, resolve as resolvePath } from "node:path";
|
223
222
|
import { spawnSync } from "node:child_process";
|
224
223
|
|
225
|
-
// c-type-parser.ts
|
224
|
+
// src/c-type-parser.ts
|
226
225
|
var CTypeParser = class {
|
227
226
|
constructor() {
|
228
227
|
this.tokens = [];
|
@@ -351,7 +350,7 @@ var cTypeToTypeScript = (str, namespace) => {
|
|
351
350
|
return parser.formatToTypeScript(res, namespace);
|
352
351
|
};
|
353
352
|
|
354
|
-
// core.ts
|
353
|
+
// src/core.ts
|
355
354
|
var DEFAULT_CPP_BINDING_OUTPUT_FILE = "binding_qjs.h";
|
356
355
|
var DEFAULT_TS_DEFINITION_OUTPUT_FILE = "binding_types.d.ts";
|
357
356
|
var DEFAULT_NAME_FILTER = "breeze::js::";
|
@@ -649,8 +648,6 @@ function generateBindingsAndDefinitions(config) {
|
|
649
648
|
} = config;
|
650
649
|
const absoluteCppFilePath = resolvePath(cppFilePath);
|
651
650
|
const absoluteOutputDir = resolvePath(outputDir);
|
652
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
653
|
-
const bindgenDir = dirname(currentFilePath);
|
654
651
|
const clangArgs = [
|
655
652
|
"-Xclang",
|
656
653
|
"-ast-dump=json",
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
3
3
|
"name": "breeze-bindgen",
|
4
|
-
"version": "1.1.
|
5
|
-
"main": "dist/
|
6
|
-
"module": "dist/
|
7
|
-
"types": "dist/
|
4
|
+
"version": "1.1.6",
|
5
|
+
"main": "dist/core.cjs",
|
6
|
+
"module": "dist/core.mjs",
|
7
|
+
"types": "dist/core.d.ts",
|
8
8
|
"bin": {
|
9
9
|
"breeze-bindgen": "./dist/cli.mjs"
|
10
10
|
},
|
@@ -24,12 +24,12 @@
|
|
24
24
|
"yargs": "17.1.1"
|
25
25
|
},
|
26
26
|
"scripts": {
|
27
|
-
"build": "esbuild core.ts --bundle --outfile=dist/core.cjs --platform=node --format=cjs && esbuild core.ts --bundle --outfile=dist/core.mjs --platform=node --format=esm && esbuild cli.ts --bundle --outfile=dist/cli.mjs --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\" --external:fancy-log --external:util",
|
27
|
+
"build": "esbuild src/core.ts --bundle --outfile=dist/core.cjs --platform=node --format=cjs && esbuild src/core.ts --bundle --outfile=dist/core.mjs --platform=node --format=esm && esbuild src/cli.ts --bundle --outfile=dist/cli.mjs --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\" --external:fancy-log --external:util && yarn build-types",
|
28
28
|
"prepublishOnly": "yarn build",
|
29
|
-
"build:cli": "esbuild cli.ts --bundle --outfile=cli.js --platform=node --format=esm --banner:js='#!/usr/bin/env node'",
|
30
|
-
"cli": "node -r esbuild-register cli.ts",
|
31
|
-
"typegen": "node -r esbuild-register typegen.ts",
|
32
|
-
"parser-test": "node -r esbuild-register c-type-parser.ts",
|
33
|
-
"build-types": "tsc
|
29
|
+
"build:cli": "esbuild src/cli.ts --bundle --outfile=cli.js --platform=node --format=esm --banner:js='#!/usr/bin/env node'",
|
30
|
+
"cli": "node -r esbuild-register src/cli.ts",
|
31
|
+
"typegen": "node -r esbuild-register src/typegen.ts",
|
32
|
+
"parser-test": "node -r esbuild-register src/c-type-parser.ts",
|
33
|
+
"build-types": "tsc -p ./tsconfig.json --emitDeclarationOnly --declaration --outdir dist"
|
34
34
|
}
|
35
35
|
}
|