-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutil.js
More file actions
35 lines (30 loc) · 661 Bytes
/
util.js
File metadata and controls
35 lines (30 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
function pick_one(symbol, name, cands) {
for (const [lib, CLS] of cands) {
try {
const inst = new CLS(lib);
const method = inst[symbol].bind(inst);
Object.defineProperty(method, "name", { value: name || CLS.name });
return method;
}
catch (ex) {
// ignore
}
}
return null;
}
const ffi = require("ffi");
const ref = require("ref");
const {int, int32, int64, void: void_t} = ref.types;
const void_ptr_t = ref.refType(void_t);
const SMALL = 4;
const off_guess_t = void_ptr_t.size > SMALL ? int64 : int32;
module.exports = {
ffi,
int,
int32,
int64,
off_guess_t,
pick_one,
ref,
};