breeze-bindgen 1.1.10 → 1.1.12
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 +80 -11
- package/dist/core.cjs +80 -11
- package/dist/core.mjs +80 -11
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
@@ -29,7 +29,8 @@ var CTypeParser = class {
|
|
29
29
|
const c = str[i];
|
30
30
|
if (BREAK_TOKENS.includes(c)) {
|
31
31
|
if (current.length > 0) {
|
32
|
-
|
32
|
+
if (current !== "const" && current !== "volatile")
|
33
|
+
this.tokens.push(current);
|
33
34
|
current = "";
|
34
35
|
}
|
35
36
|
if (c !== " ") {
|
@@ -117,6 +118,22 @@ var CTypeParser = class {
|
|
117
118
|
"int": "number",
|
118
119
|
"float": "number",
|
119
120
|
"double": "number",
|
121
|
+
"size_t": "number",
|
122
|
+
"std.int8_t": "number",
|
123
|
+
"std.int16_t": "number",
|
124
|
+
"std.int32_t": "number",
|
125
|
+
"std.int64_t": "number",
|
126
|
+
"std.uint8_t": "number",
|
127
|
+
"std.uint16_t": "number",
|
128
|
+
"std.uint32_t": "number",
|
129
|
+
"std.uint64_t": "number",
|
130
|
+
"int8_t": "number",
|
131
|
+
"int16_t": "number",
|
132
|
+
"int32_t": "number",
|
133
|
+
"int64_t": "number",
|
134
|
+
"uint32_t": "number",
|
135
|
+
"uint64_t": "number",
|
136
|
+
"std.string_view": "string",
|
120
137
|
"std.string": "string",
|
121
138
|
"std.vector": "Array",
|
122
139
|
"bool": "boolean",
|
@@ -222,7 +239,6 @@ function processAstAndGenerateCode(astArr, originalCppFilePath, nameFilter, addi
|
|
222
239
|
|
223
240
|
#pragma once
|
224
241
|
#include "binding_types.h"
|
225
|
-
#include "quickjs.h"
|
226
242
|
#include "quickjspp.hpp"
|
227
243
|
|
228
244
|
template <typename T>
|
@@ -305,14 +321,41 @@ declare module '${tsModuleName}' {
|
|
305
321
|
if (arg.kind === "ParmVarDecl") argNames.push(arg.name);
|
306
322
|
}
|
307
323
|
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
324
|
+
const methodName = node.name;
|
325
|
+
if (methodName.startsWith("get_") && parsed.args.length === 0) {
|
326
|
+
const propName = methodName.substring(4);
|
327
|
+
methods.push({
|
328
|
+
name: methodName,
|
329
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
330
|
+
args: [],
|
331
|
+
static: false,
|
332
|
+
comment: comment.length > 0 ? comment : void 0,
|
333
|
+
argNames: [],
|
334
|
+
isGetter: true,
|
335
|
+
propertyName: propName
|
336
|
+
});
|
337
|
+
} else if (methodName.startsWith("set_") && parsed.args.length === 1) {
|
338
|
+
const propName = methodName.substring(4);
|
339
|
+
methods.push({
|
340
|
+
name: methodName,
|
341
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
342
|
+
args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
|
343
|
+
static: false,
|
344
|
+
comment: comment.length > 0 ? comment : void 0,
|
345
|
+
argNames,
|
346
|
+
isSetter: true,
|
347
|
+
propertyName: propName
|
348
|
+
});
|
349
|
+
} else {
|
350
|
+
methods.push({
|
351
|
+
name: methodName,
|
352
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
353
|
+
args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
|
354
|
+
static: node.storageClass === "static",
|
355
|
+
comment: comment.length > 0 ? comment : void 0,
|
356
|
+
argNames
|
357
|
+
});
|
358
|
+
}
|
316
359
|
}
|
317
360
|
}
|
318
361
|
const fullName = path.join("::") + "::" + structName;
|
@@ -354,9 +397,35 @@ template<> struct js_bind<${fullName}> {
|
|
354
397
|
binding += `
|
355
398
|
.base<${bases[0].type}>()`;
|
356
399
|
}
|
400
|
+
const properties = /* @__PURE__ */ new Map();
|
357
401
|
for (const method of methods) {
|
358
|
-
|
402
|
+
if (method.isGetter) {
|
403
|
+
const prop = properties.get(method.propertyName) || {};
|
404
|
+
prop.getter = method;
|
405
|
+
properties.set(method.propertyName, prop);
|
406
|
+
} else if (method.isSetter) {
|
407
|
+
const prop = properties.get(method.propertyName) || {};
|
408
|
+
prop.setter = method;
|
409
|
+
properties.set(method.propertyName, prop);
|
410
|
+
}
|
411
|
+
}
|
412
|
+
for (const [propName, { getter, setter }] of properties) {
|
413
|
+
if (!getter) {
|
414
|
+
throw new Error(`Found setter ${setter.name} without getter for property ${propName}`);
|
415
|
+
}
|
416
|
+
if (setter) {
|
417
|
+
binding += `
|
418
|
+
.property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
|
419
|
+
} else {
|
420
|
+
binding += `
|
421
|
+
.property<&${fullName}::${getter.name}>("${propName}")`;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
for (const method of methods) {
|
425
|
+
if (!method.isGetter && !method.isSetter) {
|
426
|
+
binding += `
|
359
427
|
.${method.static ? "static_" : ""}fun<&${fullName}::${method.name}>("${method.name}")`;
|
428
|
+
}
|
360
429
|
}
|
361
430
|
for (const field of fields) {
|
362
431
|
binding += `
|
package/dist/core.cjs
CHANGED
@@ -239,7 +239,8 @@ var CTypeParser = class {
|
|
239
239
|
const c = str[i];
|
240
240
|
if (BREAK_TOKENS.includes(c)) {
|
241
241
|
if (current.length > 0) {
|
242
|
-
|
242
|
+
if (current !== "const" && current !== "volatile")
|
243
|
+
this.tokens.push(current);
|
243
244
|
current = "";
|
244
245
|
}
|
245
246
|
if (c !== " ") {
|
@@ -327,6 +328,22 @@ var CTypeParser = class {
|
|
327
328
|
"int": "number",
|
328
329
|
"float": "number",
|
329
330
|
"double": "number",
|
331
|
+
"size_t": "number",
|
332
|
+
"std.int8_t": "number",
|
333
|
+
"std.int16_t": "number",
|
334
|
+
"std.int32_t": "number",
|
335
|
+
"std.int64_t": "number",
|
336
|
+
"std.uint8_t": "number",
|
337
|
+
"std.uint16_t": "number",
|
338
|
+
"std.uint32_t": "number",
|
339
|
+
"std.uint64_t": "number",
|
340
|
+
"int8_t": "number",
|
341
|
+
"int16_t": "number",
|
342
|
+
"int32_t": "number",
|
343
|
+
"int64_t": "number",
|
344
|
+
"uint32_t": "number",
|
345
|
+
"uint64_t": "number",
|
346
|
+
"std.string_view": "string",
|
330
347
|
"std.string": "string",
|
331
348
|
"std.vector": "Array",
|
332
349
|
"bool": "boolean",
|
@@ -432,7 +449,6 @@ function processAstAndGenerateCode(astArr, originalCppFilePath, nameFilter, addi
|
|
432
449
|
|
433
450
|
#pragma once
|
434
451
|
#include "binding_types.h"
|
435
|
-
#include "quickjs.h"
|
436
452
|
#include "quickjspp.hpp"
|
437
453
|
|
438
454
|
template <typename T>
|
@@ -515,14 +531,41 @@ declare module '${tsModuleName}' {
|
|
515
531
|
if (arg.kind === "ParmVarDecl") argNames.push(arg.name);
|
516
532
|
}
|
517
533
|
}
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
534
|
+
const methodName = node.name;
|
535
|
+
if (methodName.startsWith("get_") && parsed.args.length === 0) {
|
536
|
+
const propName = methodName.substring(4);
|
537
|
+
methods.push({
|
538
|
+
name: methodName,
|
539
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
540
|
+
args: [],
|
541
|
+
static: false,
|
542
|
+
comment: comment.length > 0 ? comment : void 0,
|
543
|
+
argNames: [],
|
544
|
+
isGetter: true,
|
545
|
+
propertyName: propName
|
546
|
+
});
|
547
|
+
} else if (methodName.startsWith("set_") && parsed.args.length === 1) {
|
548
|
+
const propName = methodName.substring(4);
|
549
|
+
methods.push({
|
550
|
+
name: methodName,
|
551
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
552
|
+
args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
|
553
|
+
static: false,
|
554
|
+
comment: comment.length > 0 ? comment : void 0,
|
555
|
+
argNames,
|
556
|
+
isSetter: true,
|
557
|
+
propertyName: propName
|
558
|
+
});
|
559
|
+
} else {
|
560
|
+
methods.push({
|
561
|
+
name: methodName,
|
562
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
563
|
+
args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
|
564
|
+
static: node.storageClass === "static",
|
565
|
+
comment: comment.length > 0 ? comment : void 0,
|
566
|
+
argNames
|
567
|
+
});
|
568
|
+
}
|
526
569
|
}
|
527
570
|
}
|
528
571
|
const fullName = path.join("::") + "::" + structName;
|
@@ -564,9 +607,35 @@ template<> struct js_bind<${fullName}> {
|
|
564
607
|
binding += `
|
565
608
|
.base<${bases[0].type}>()`;
|
566
609
|
}
|
610
|
+
const properties = /* @__PURE__ */ new Map();
|
567
611
|
for (const method of methods) {
|
568
|
-
|
612
|
+
if (method.isGetter) {
|
613
|
+
const prop = properties.get(method.propertyName) || {};
|
614
|
+
prop.getter = method;
|
615
|
+
properties.set(method.propertyName, prop);
|
616
|
+
} else if (method.isSetter) {
|
617
|
+
const prop = properties.get(method.propertyName) || {};
|
618
|
+
prop.setter = method;
|
619
|
+
properties.set(method.propertyName, prop);
|
620
|
+
}
|
621
|
+
}
|
622
|
+
for (const [propName, { getter, setter }] of properties) {
|
623
|
+
if (!getter) {
|
624
|
+
throw new Error(`Found setter ${setter.name} without getter for property ${propName}`);
|
625
|
+
}
|
626
|
+
if (setter) {
|
627
|
+
binding += `
|
628
|
+
.property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
|
629
|
+
} else {
|
630
|
+
binding += `
|
631
|
+
.property<&${fullName}::${getter.name}>("${propName}")`;
|
632
|
+
}
|
633
|
+
}
|
634
|
+
for (const method of methods) {
|
635
|
+
if (!method.isGetter && !method.isSetter) {
|
636
|
+
binding += `
|
569
637
|
.${method.static ? "static_" : ""}fun<&${fullName}::${method.name}>("${method.name}")`;
|
638
|
+
}
|
570
639
|
}
|
571
640
|
for (const field of fields) {
|
572
641
|
binding += `
|
package/dist/core.mjs
CHANGED
@@ -235,7 +235,8 @@ var CTypeParser = class {
|
|
235
235
|
const c = str[i];
|
236
236
|
if (BREAK_TOKENS.includes(c)) {
|
237
237
|
if (current.length > 0) {
|
238
|
-
|
238
|
+
if (current !== "const" && current !== "volatile")
|
239
|
+
this.tokens.push(current);
|
239
240
|
current = "";
|
240
241
|
}
|
241
242
|
if (c !== " ") {
|
@@ -323,6 +324,22 @@ var CTypeParser = class {
|
|
323
324
|
"int": "number",
|
324
325
|
"float": "number",
|
325
326
|
"double": "number",
|
327
|
+
"size_t": "number",
|
328
|
+
"std.int8_t": "number",
|
329
|
+
"std.int16_t": "number",
|
330
|
+
"std.int32_t": "number",
|
331
|
+
"std.int64_t": "number",
|
332
|
+
"std.uint8_t": "number",
|
333
|
+
"std.uint16_t": "number",
|
334
|
+
"std.uint32_t": "number",
|
335
|
+
"std.uint64_t": "number",
|
336
|
+
"int8_t": "number",
|
337
|
+
"int16_t": "number",
|
338
|
+
"int32_t": "number",
|
339
|
+
"int64_t": "number",
|
340
|
+
"uint32_t": "number",
|
341
|
+
"uint64_t": "number",
|
342
|
+
"std.string_view": "string",
|
326
343
|
"std.string": "string",
|
327
344
|
"std.vector": "Array",
|
328
345
|
"bool": "boolean",
|
@@ -428,7 +445,6 @@ function processAstAndGenerateCode(astArr, originalCppFilePath, nameFilter, addi
|
|
428
445
|
|
429
446
|
#pragma once
|
430
447
|
#include "binding_types.h"
|
431
|
-
#include "quickjs.h"
|
432
448
|
#include "quickjspp.hpp"
|
433
449
|
|
434
450
|
template <typename T>
|
@@ -511,14 +527,41 @@ declare module '${tsModuleName}' {
|
|
511
527
|
if (arg.kind === "ParmVarDecl") argNames.push(arg.name);
|
512
528
|
}
|
513
529
|
}
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
530
|
+
const methodName = node.name;
|
531
|
+
if (methodName.startsWith("get_") && parsed.args.length === 0) {
|
532
|
+
const propName = methodName.substring(4);
|
533
|
+
methods.push({
|
534
|
+
name: methodName,
|
535
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
536
|
+
args: [],
|
537
|
+
static: false,
|
538
|
+
comment: comment.length > 0 ? comment : void 0,
|
539
|
+
argNames: [],
|
540
|
+
isGetter: true,
|
541
|
+
propertyName: propName
|
542
|
+
});
|
543
|
+
} else if (methodName.startsWith("set_") && parsed.args.length === 1) {
|
544
|
+
const propName = methodName.substring(4);
|
545
|
+
methods.push({
|
546
|
+
name: methodName,
|
547
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
548
|
+
args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
|
549
|
+
static: false,
|
550
|
+
comment: comment.length > 0 ? comment : void 0,
|
551
|
+
argNames,
|
552
|
+
isSetter: true,
|
553
|
+
propertyName: propName
|
554
|
+
});
|
555
|
+
} else {
|
556
|
+
methods.push({
|
557
|
+
name: methodName,
|
558
|
+
returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
|
559
|
+
args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
|
560
|
+
static: node.storageClass === "static",
|
561
|
+
comment: comment.length > 0 ? comment : void 0,
|
562
|
+
argNames
|
563
|
+
});
|
564
|
+
}
|
522
565
|
}
|
523
566
|
}
|
524
567
|
const fullName = path.join("::") + "::" + structName;
|
@@ -560,9 +603,35 @@ template<> struct js_bind<${fullName}> {
|
|
560
603
|
binding += `
|
561
604
|
.base<${bases[0].type}>()`;
|
562
605
|
}
|
606
|
+
const properties = /* @__PURE__ */ new Map();
|
563
607
|
for (const method of methods) {
|
564
|
-
|
608
|
+
if (method.isGetter) {
|
609
|
+
const prop = properties.get(method.propertyName) || {};
|
610
|
+
prop.getter = method;
|
611
|
+
properties.set(method.propertyName, prop);
|
612
|
+
} else if (method.isSetter) {
|
613
|
+
const prop = properties.get(method.propertyName) || {};
|
614
|
+
prop.setter = method;
|
615
|
+
properties.set(method.propertyName, prop);
|
616
|
+
}
|
617
|
+
}
|
618
|
+
for (const [propName, { getter, setter }] of properties) {
|
619
|
+
if (!getter) {
|
620
|
+
throw new Error(`Found setter ${setter.name} without getter for property ${propName}`);
|
621
|
+
}
|
622
|
+
if (setter) {
|
623
|
+
binding += `
|
624
|
+
.property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
|
625
|
+
} else {
|
626
|
+
binding += `
|
627
|
+
.property<&${fullName}::${getter.name}>("${propName}")`;
|
628
|
+
}
|
629
|
+
}
|
630
|
+
for (const method of methods) {
|
631
|
+
if (!method.isGetter && !method.isSetter) {
|
632
|
+
binding += `
|
565
633
|
.${method.static ? "static_" : ""}fun<&${fullName}::${method.name}>("${method.name}")`;
|
634
|
+
}
|
566
635
|
}
|
567
636
|
for (const field of fields) {
|
568
637
|
binding += `
|
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.
|
4
|
+
"version": "1.1.12",
|
5
5
|
"main": "dist/core.cjs",
|
6
6
|
"module": "dist/core.mjs",
|
7
7
|
"types": "dist/core.d.ts",
|