@yuuang/ffi-rs-linux-arm64-musl
Advanced tools
Comparing version 1.0.44 to 1.0.45
{ | ||
"name": "@yuuang/ffi-rs-linux-arm64-musl", | ||
"version": "1.0.44", | ||
"version": "1.0.45", | ||
"os": [ | ||
@@ -5,0 +5,0 @@ "linux" |
@@ -86,2 +86,4 @@ # ffi-rs | ||
View [test.ts](./test.ts) get the latest usage | ||
Here is an example of how to use ffi-rs: | ||
@@ -324,2 +326,43 @@ | ||
#### CreatePointer | ||
```js | ||
let bigDoubleArr = new Array(5).fill(1.1); | ||
deepStrictEqual( | ||
bigDoubleArr, | ||
load({ | ||
library: "libsum", | ||
funcName: "createArrayDouble", | ||
retType: arrayConstructor({ | ||
type: DataType.DoubleArray, | ||
length: bigDoubleArr.length, | ||
}), | ||
paramsType: [DataType.DoubleArray, DataType.I32], | ||
paramsValue: [bigDoubleArr, bigDoubleArr.length], | ||
}), | ||
); | ||
``` | ||
For the code above, we can use `createExternal` function to wrap a pointer data and send it as paramsValue | ||
```js | ||
const funcExternal: unknown[] = createExternal({ | ||
paramsType: [DataType.DoubleArray], | ||
paramsValue: [[1.1,2.2]] | ||
}) | ||
const ptr = funcExternal[0] | ||
load({ | ||
library: "libsum", | ||
funcName: "createArrayDouble", | ||
retType: arrayConstructor({ | ||
type: DataType.DoubleArray, | ||
length: bigDoubleArr.length, | ||
}), | ||
paramsType: [DataType.External, DataType.I32], | ||
paramsValue: [ptr, bigDoubleArr.length], | ||
}) | ||
``` | ||
The two pieces of code above are equivalent | ||
### Struct | ||
@@ -326,0 +369,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
609758
660