breeze-bindgen 1.1.29 → 1.1.31

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
@@ -335,13 +335,14 @@ declare module '${tsModuleName}' {
335
335
  const methodName = node.name;
336
336
  const getterMatch = methodName.match(/^get_(.+)$/) || (methodName.match(/^get([A-Z].*)$/) ? [null, methodName[3].toLowerCase() + methodName.slice(4)] : null);
337
337
  const setterMatch = methodName.match(/^set_(.+)$/) || (methodName.match(/^set([A-Z].*)$/) ? [null, methodName[3].toLowerCase() + methodName.slice(4)] : null);
338
+ const isStatic = node.storageClass === "static";
338
339
  if (getterMatch && parsed.args.length === 0) {
339
340
  const propName = getterMatch[1];
340
341
  methods.push({
341
342
  name: methodName,
342
343
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
343
344
  args: [],
344
- static: false,
345
+ static: isStatic,
345
346
  comment: comment.length > 0 ? comment : void 0,
346
347
  argNames: [],
347
348
  isGetter: true,
@@ -353,7 +354,7 @@ declare module '${tsModuleName}' {
353
354
  name: methodName,
354
355
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
355
356
  args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
356
- static: false,
357
+ static: isStatic,
357
358
  comment: comment.length > 0 ? comment : void 0,
358
359
  argNames,
359
360
  isSetter: true,
@@ -364,7 +365,7 @@ declare module '${tsModuleName}' {
364
365
  name: methodName,
365
366
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
366
367
  args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
367
- static: node.storageClass === "static",
368
+ static: isStatic,
368
369
  comment: comment.length > 0 ? comment : void 0,
369
370
  argNames
370
371
  });
@@ -428,12 +429,25 @@ template<> struct js_bind<${fullName}> {
428
429
  }
429
430
  }
430
431
  for (const [propName, { getter, setter }] of properties) {
431
- if (setter) {
432
- binding += `
433
- .property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
432
+ if (setter.static !== getter.static) {
433
+ throw new Error(`Found setter ${setter.name} with different staticness than getter for property ${propName}`);
434
+ }
435
+ if (getter.static) {
436
+ if (setter) {
437
+ binding += `
438
+ .static_property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
439
+ } else {
440
+ binding += `
441
+ .static_property<&${fullName}::${getter.name}>("${propName}")`;
442
+ }
434
443
  } else {
435
- binding += `
436
- .property<&${fullName}::${getter.name}>("${propName}")`;
444
+ if (setter) {
445
+ binding += `
446
+ .property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
447
+ } else {
448
+ binding += `
449
+ .property<&${fullName}::${getter.name}>("${propName}")`;
450
+ }
437
451
  }
438
452
  }
439
453
  for (const method of methods) {
@@ -486,10 +500,11 @@ export class ${tsClassName}${bases.length > 0 ? ` extends ${bases.map((base) =>
486
500
  }
487
501
  }
488
502
  for (const [propName, { getter, setter }] of properties) {
489
- let propDef = `get ${propName}(): ${cTypeToTypeScript(getter.returnType, nameFilter)};`;
503
+ const staticFlag = getter?.static ? "static " : "";
504
+ let propDef = `${staticFlag}get ${propName}(): ${cTypeToTypeScript(getter.returnType, nameFilter)};`;
490
505
  if (setter) {
491
506
  propDef += `
492
- set ${propName}(value: ${cTypeToTypeScript(setter.args[0], nameFilter)});`;
507
+ ${staticFlag}set ${propName}(value: ${cTypeToTypeScript(setter.args[0], nameFilter)});`;
493
508
  }
494
509
  if (getter?.comment) {
495
510
  propDef = `
package/dist/core.cjs CHANGED
@@ -545,13 +545,14 @@ declare module '${tsModuleName}' {
545
545
  const methodName = node.name;
546
546
  const getterMatch = methodName.match(/^get_(.+)$/) || (methodName.match(/^get([A-Z].*)$/) ? [null, methodName[3].toLowerCase() + methodName.slice(4)] : null);
547
547
  const setterMatch = methodName.match(/^set_(.+)$/) || (methodName.match(/^set([A-Z].*)$/) ? [null, methodName[3].toLowerCase() + methodName.slice(4)] : null);
548
+ const isStatic = node.storageClass === "static";
548
549
  if (getterMatch && parsed.args.length === 0) {
549
550
  const propName = getterMatch[1];
550
551
  methods.push({
551
552
  name: methodName,
552
553
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
553
554
  args: [],
554
- static: false,
555
+ static: isStatic,
555
556
  comment: comment.length > 0 ? comment : void 0,
556
557
  argNames: [],
557
558
  isGetter: true,
@@ -563,7 +564,7 @@ declare module '${tsModuleName}' {
563
564
  name: methodName,
564
565
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
565
566
  args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
566
- static: false,
567
+ static: isStatic,
567
568
  comment: comment.length > 0 ? comment : void 0,
568
569
  argNames,
569
570
  isSetter: true,
@@ -574,7 +575,7 @@ declare module '${tsModuleName}' {
574
575
  name: methodName,
575
576
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
576
577
  args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
577
- static: node.storageClass === "static",
578
+ static: isStatic,
578
579
  comment: comment.length > 0 ? comment : void 0,
579
580
  argNames
580
581
  });
@@ -638,12 +639,25 @@ template<> struct js_bind<${fullName}> {
638
639
  }
639
640
  }
640
641
  for (const [propName, { getter, setter }] of properties) {
641
- if (setter) {
642
- binding += `
643
- .property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
642
+ if (setter.static !== getter.static) {
643
+ throw new Error(`Found setter ${setter.name} with different staticness than getter for property ${propName}`);
644
+ }
645
+ if (getter.static) {
646
+ if (setter) {
647
+ binding += `
648
+ .static_property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
649
+ } else {
650
+ binding += `
651
+ .static_property<&${fullName}::${getter.name}>("${propName}")`;
652
+ }
644
653
  } else {
645
- binding += `
646
- .property<&${fullName}::${getter.name}>("${propName}")`;
654
+ if (setter) {
655
+ binding += `
656
+ .property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
657
+ } else {
658
+ binding += `
659
+ .property<&${fullName}::${getter.name}>("${propName}")`;
660
+ }
647
661
  }
648
662
  }
649
663
  for (const method of methods) {
@@ -696,10 +710,11 @@ export class ${tsClassName}${bases.length > 0 ? ` extends ${bases.map((base) =>
696
710
  }
697
711
  }
698
712
  for (const [propName, { getter, setter }] of properties) {
699
- let propDef = `get ${propName}(): ${cTypeToTypeScript(getter.returnType, nameFilter)};`;
713
+ const staticFlag = getter?.static ? "static " : "";
714
+ let propDef = `${staticFlag}get ${propName}(): ${cTypeToTypeScript(getter.returnType, nameFilter)};`;
700
715
  if (setter) {
701
716
  propDef += `
702
- set ${propName}(value: ${cTypeToTypeScript(setter.args[0], nameFilter)});`;
717
+ ${staticFlag}set ${propName}(value: ${cTypeToTypeScript(setter.args[0], nameFilter)});`;
703
718
  }
704
719
  if (getter?.comment) {
705
720
  propDef = `
package/dist/core.mjs CHANGED
@@ -541,13 +541,14 @@ declare module '${tsModuleName}' {
541
541
  const methodName = node.name;
542
542
  const getterMatch = methodName.match(/^get_(.+)$/) || (methodName.match(/^get([A-Z].*)$/) ? [null, methodName[3].toLowerCase() + methodName.slice(4)] : null);
543
543
  const setterMatch = methodName.match(/^set_(.+)$/) || (methodName.match(/^set([A-Z].*)$/) ? [null, methodName[3].toLowerCase() + methodName.slice(4)] : null);
544
+ const isStatic = node.storageClass === "static";
544
545
  if (getterMatch && parsed.args.length === 0) {
545
546
  const propName = getterMatch[1];
546
547
  methods.push({
547
548
  name: methodName,
548
549
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
549
550
  args: [],
550
- static: false,
551
+ static: isStatic,
551
552
  comment: comment.length > 0 ? comment : void 0,
552
553
  argNames: [],
553
554
  isGetter: true,
@@ -559,7 +560,7 @@ declare module '${tsModuleName}' {
559
560
  name: methodName,
560
561
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
561
562
  args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
562
- static: false,
563
+ static: isStatic,
563
564
  comment: comment.length > 0 ? comment : void 0,
564
565
  argNames,
565
566
  isSetter: true,
@@ -570,7 +571,7 @@ declare module '${tsModuleName}' {
570
571
  name: methodName,
571
572
  returnType: ctypeToQualified(parsed.returnType, [...path, node.name]),
572
573
  args: parsed.args.map((arg) => ctypeToQualified(arg, [...path, node_struct.name])),
573
- static: node.storageClass === "static",
574
+ static: isStatic,
574
575
  comment: comment.length > 0 ? comment : void 0,
575
576
  argNames
576
577
  });
@@ -634,12 +635,25 @@ template<> struct js_bind<${fullName}> {
634
635
  }
635
636
  }
636
637
  for (const [propName, { getter, setter }] of properties) {
637
- if (setter) {
638
- binding += `
639
- .property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
638
+ if (setter.static !== getter.static) {
639
+ throw new Error(`Found setter ${setter.name} with different staticness than getter for property ${propName}`);
640
+ }
641
+ if (getter.static) {
642
+ if (setter) {
643
+ binding += `
644
+ .static_property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
645
+ } else {
646
+ binding += `
647
+ .static_property<&${fullName}::${getter.name}>("${propName}")`;
648
+ }
640
649
  } else {
641
- binding += `
642
- .property<&${fullName}::${getter.name}>("${propName}")`;
650
+ if (setter) {
651
+ binding += `
652
+ .property<&${fullName}::${getter.name}, &${fullName}::${setter.name}>("${propName}")`;
653
+ } else {
654
+ binding += `
655
+ .property<&${fullName}::${getter.name}>("${propName}")`;
656
+ }
643
657
  }
644
658
  }
645
659
  for (const method of methods) {
@@ -692,10 +706,11 @@ export class ${tsClassName}${bases.length > 0 ? ` extends ${bases.map((base) =>
692
706
  }
693
707
  }
694
708
  for (const [propName, { getter, setter }] of properties) {
695
- let propDef = `get ${propName}(): ${cTypeToTypeScript(getter.returnType, nameFilter)};`;
709
+ const staticFlag = getter?.static ? "static " : "";
710
+ let propDef = `${staticFlag}get ${propName}(): ${cTypeToTypeScript(getter.returnType, nameFilter)};`;
696
711
  if (setter) {
697
712
  propDef += `
698
- set ${propName}(value: ${cTypeToTypeScript(setter.args[0], nameFilter)});`;
713
+ ${staticFlag}set ${propName}(value: ${cTypeToTypeScript(setter.args[0], nameFilter)});`;
699
714
  }
700
715
  if (getter?.comment) {
701
716
  propDef = `
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.29",
4
+ "version": "1.1.31",
5
5
  "main": "dist/core.cjs",
6
6
  "module": "dist/core.mjs",
7
7
  "types": "dist/core.d.ts",