@crossbind/port-expat-standalone-napi 2.0.0-beta.74 → 2.0.0-beta.76

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/LICENSE CHANGED
@@ -14,7 +14,7 @@ advice; the compliance assessment is yours.
14
14
 
15
15
  ## crossbind — MIT
16
16
 
17
- - package: crossbind@2.0.0-beta.74
17
+ - package: crossbind@2.0.0-beta.76
18
18
  - source: https://github.com/crossbind/crossbind
19
19
  - note: the embind-jsi and embind-napi runtime and the bindings crossbind generates
20
20
 
@@ -44,7 +44,7 @@ SOFTWARE.
44
44
 
45
45
  ## emscripten-embind — MIT OR NCSA
46
46
 
47
- - package: @crossbind/core-embind-jsi@2.0.0-beta.74
47
+ - package: @crossbind/core-embind-jsi@2.0.0-beta.76
48
48
  - source: https://github.com/emscripten-core/emscripten
49
49
  - no license election recorded; the declared expression applies and all texts are included
50
50
  - note: Emscripten's embind, adapted by @crossbind/core-embind-jsi
@@ -2101,6 +2101,33 @@ function ownHandle(handle) {
2101
2101
  }
2102
2102
  return handle;
2103
2103
  }
2104
+ // A pointer a member function or property hands out can point into the object it was called on, or name that
2105
+ // object: its handle holds a clone of the object's handle, on the count the pointer's clones share, so the object goes
2106
+ // with the last of them, as the wasm glue does after utils/embindPointerOwners.js. Only a raw pointer, a NativePointer
2107
+ // and an emscripten::val can borrow: a copy and a smart pointer hold what they point at.
2108
+ function mayBorrow(type) {
2109
+ if (!type) return false;
2110
+ if (type.name === 'emscripten::val') return true;
2111
+ var cls = type.registeredClass;
2112
+ return !!cls && !type.isReference && (!type.isSmartPointer || cls.name === 'NativePointer');
2113
+ }
2114
+ function keepOwner(value, owner) {
2115
+ var $$ = value && value.$$;
2116
+ var held = owner && owner.$$;
2117
+ if (!$$ || !$$.count || $$.count.owner || !held || !held.ptr || held.preservePointerOnDelete || $$.count === held.count) {
2118
+ return value;
2119
+ }
2120
+ if ($$.smartPtr ? $$.ptrType.registeredClass.name === 'NativePointer' : !$$.count.owned) $$.count.owner = owner.clone();
2121
+ return value;
2122
+ }
2123
+ function keepsOwner(fn, type) {
2124
+ if (!mayBorrow(type)) return fn;
2125
+ var kept = function () {
2126
+ return keepOwner(fn.apply(this, arguments), this);
2127
+ };
2128
+ Object.defineProperty(kept, 'name', { value: fn.name });
2129
+ return kept;
2130
+ }
2104
2131
  function ClassHandle_clone() {
2105
2132
  if (!this.$$.ptr) {
2106
2133
  throwInstanceAlreadyDeleted(this);
@@ -2660,7 +2687,7 @@ function __embind_register_class_function(rawClassType,
2660
2687
 
2661
2688
  whenDependentTypesAreResolved([], rawArgTypes, function (argTypes) {
2662
2689
  //console.log(methodName);
2663
- var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync);
2690
+ var memberFunction = keepsOwner(craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync), argTypes[0]);
2664
2691
 
2665
2692
  // Replace the initial unbound-handler-stub function with the appropriate member function, now that all types
2666
2693
  // are resolved. If multiple overloads are registered for this function, the function goes into an overload table.
@@ -2746,7 +2773,7 @@ function __embind_register_class_property(classType,
2746
2773
  get: function () {
2747
2774
  // console.log('get -> ', this.$$.ptr);
2748
2775
  var ptr = validateThis(this, classType, humanName + ' getter');
2749
- return getterReturnType['fromWireType'](getter(getterContext, ptr));
2776
+ return keepOwner(getterReturnType['fromWireType'](getter(getterContext, ptr)), this);
2750
2777
  },
2751
2778
  enumerable: true
2752
2779
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossbind/port-expat-standalone-napi",
3
- "version": "2.0.0-beta.74",
3
+ "version": "2.0.0-beta.76",
4
4
  "nativeVersion": "2.10.0",
5
5
  "homepage": "https://crossbind.dev/ports/expat/",
6
6
  "repository": {
@@ -27,21 +27,21 @@
27
27
  "sbom.cdx.json"
28
28
  ],
29
29
  "optionalDependencies": {
30
- "@crossbind/port-expat-standalone-napi-darwin-arm64": "2.0.0-beta.74",
31
- "@crossbind/port-expat-standalone-napi-darwin-x64": "2.0.0-beta.74",
32
- "@crossbind/port-expat-standalone-napi-linux-arm64": "2.0.0-beta.74",
33
- "@crossbind/port-expat-standalone-napi-linux-x64": "2.0.0-beta.74",
34
- "@crossbind/port-expat-standalone-napi-linuxmusl-arm64": "2.0.0-beta.74",
35
- "@crossbind/port-expat-standalone-napi-linuxmusl-x64": "2.0.0-beta.74",
36
- "@crossbind/port-expat-standalone-napi-win32-arm64": "2.0.0-beta.74",
37
- "@crossbind/port-expat-standalone-napi-win32-x64": "2.0.0-beta.74"
30
+ "@crossbind/port-expat-standalone-napi-darwin-arm64": "2.0.0-beta.76",
31
+ "@crossbind/port-expat-standalone-napi-darwin-x64": "2.0.0-beta.76",
32
+ "@crossbind/port-expat-standalone-napi-linux-arm64": "2.0.0-beta.76",
33
+ "@crossbind/port-expat-standalone-napi-linux-x64": "2.0.0-beta.76",
34
+ "@crossbind/port-expat-standalone-napi-linuxmusl-arm64": "2.0.0-beta.76",
35
+ "@crossbind/port-expat-standalone-napi-linuxmusl-x64": "2.0.0-beta.76",
36
+ "@crossbind/port-expat-standalone-napi-win32-arm64": "2.0.0-beta.76",
37
+ "@crossbind/port-expat-standalone-napi-win32-x64": "2.0.0-beta.76"
38
38
  },
39
39
  "devDependencies": {
40
- "crossbind": "^2.0.0-beta.74",
41
- "@crossbind/port-expat-darwin": "^2.0.0-beta.74",
42
- "@crossbind/port-expat-linux": "^2.0.0-beta.74",
43
- "@crossbind/port-expat-linuxmusl": "^2.0.0-beta.74",
44
- "@crossbind/port-expat-win32": "^2.0.0-beta.74"
40
+ "crossbind": "^2.0.0-beta.76",
41
+ "@crossbind/port-expat-darwin": "^2.0.0-beta.76",
42
+ "@crossbind/port-expat-linux": "^2.0.0-beta.76",
43
+ "@crossbind/port-expat-linuxmusl": "^2.0.0-beta.76",
44
+ "@crossbind/port-expat-win32": "^2.0.0-beta.76"
45
45
  },
46
46
  "keywords": [
47
47
  "expat",
package/sbom.cdx.json CHANGED
@@ -6,15 +6,15 @@
6
6
  "component": {
7
7
  "type": "library",
8
8
  "name": "@crossbind/port-expat-standalone-napi",
9
- "version": "2.0.0-beta.74"
9
+ "version": "2.0.0-beta.76"
10
10
  }
11
11
  },
12
12
  "components": [
13
13
  {
14
14
  "type": "library",
15
15
  "name": "crossbind",
16
- "version": "2.0.0-beta.74",
17
- "purl": "pkg:generic/crossbind@2.0.0-beta.74",
16
+ "version": "2.0.0-beta.76",
17
+ "purl": "pkg:generic/crossbind@2.0.0-beta.76",
18
18
  "licenses": [
19
19
  {
20
20
  "expression": "MIT"
@@ -30,8 +30,8 @@
30
30
  {
31
31
  "type": "library",
32
32
  "name": "emscripten-embind",
33
- "version": "2.0.0-beta.74",
34
- "purl": "pkg:generic/emscripten-embind@2.0.0-beta.74",
33
+ "version": "2.0.0-beta.76",
34
+ "purl": "pkg:generic/emscripten-embind@2.0.0-beta.76",
35
35
  "licenses": [
36
36
  {
37
37
  "expression": "MIT OR NCSA"