breeze-bindgen 1.1.11 → 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 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
- this.tokens.push(current);
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",
@@ -304,14 +321,41 @@ declare module '${tsModuleName}' {
304
321
  if (arg.kind === "ParmVarDecl") argNames.push(arg.name);
305
322
  }
306
323
  }
307
- methods.push({
308
- name: node.name,
309
- returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
310
- args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
311
- static: node.storageClass === "static",
312
- comment: comment.length > 0 ? comment : void 0,
313
- argNames
314
- });
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
+ }
315
359
  }
316
360
  }
317
361
  const fullName = path.join("::") + "::" + structName;
@@ -353,9 +397,35 @@ template<> struct js_bind<${fullName}> {
353
397
  binding += `
354
398
  .base<${bases[0].type}>()`;
355
399
  }
400
+ const properties = /* @__PURE__ */ new Map();
356
401
  for (const method of methods) {
357
- binding += `
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 += `
358
427
  .${method.static ? "static_" : ""}fun<&${fullName}::${method.name}>("${method.name}")`;
428
+ }
359
429
  }
360
430
  for (const field of fields) {
361
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
- this.tokens.push(current);
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",
@@ -514,14 +531,41 @@ declare module '${tsModuleName}' {
514
531
  if (arg.kind === "ParmVarDecl") argNames.push(arg.name);
515
532
  }
516
533
  }
517
- methods.push({
518
- name: node.name,
519
- returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
520
- args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
521
- static: node.storageClass === "static",
522
- comment: comment.length > 0 ? comment : void 0,
523
- argNames
524
- });
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
+ }
525
569
  }
526
570
  }
527
571
  const fullName = path.join("::") + "::" + structName;
@@ -563,9 +607,35 @@ template<> struct js_bind<${fullName}> {
563
607
  binding += `
564
608
  .base<${bases[0].type}>()`;
565
609
  }
610
+ const properties = /* @__PURE__ */ new Map();
566
611
  for (const method of methods) {
567
- binding += `
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 += `
568
637
  .${method.static ? "static_" : ""}fun<&${fullName}::${method.name}>("${method.name}")`;
638
+ }
569
639
  }
570
640
  for (const field of fields) {
571
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
- this.tokens.push(current);
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",
@@ -510,14 +527,41 @@ declare module '${tsModuleName}' {
510
527
  if (arg.kind === "ParmVarDecl") argNames.push(arg.name);
511
528
  }
512
529
  }
513
- methods.push({
514
- name: node.name,
515
- returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
516
- args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
517
- static: node.storageClass === "static",
518
- comment: comment.length > 0 ? comment : void 0,
519
- argNames
520
- });
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
+ }
521
565
  }
522
566
  }
523
567
  const fullName = path.join("::") + "::" + structName;
@@ -559,9 +603,35 @@ template<> struct js_bind<${fullName}> {
559
603
  binding += `
560
604
  .base<${bases[0].type}>()`;
561
605
  }
606
+ const properties = /* @__PURE__ */ new Map();
562
607
  for (const method of methods) {
563
- binding += `
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 += `
564
633
  .${method.static ? "static_" : ""}fun<&${fullName}::${method.name}>("${method.name}")`;
634
+ }
565
635
  }
566
636
  for (const field of fields) {
567
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.11",
4
+ "version": "1.1.12",
5
5
  "main": "dist/core.cjs",
6
6
  "module": "dist/core.mjs",
7
7
  "types": "dist/core.d.ts",