Last active
August 29, 2015 13:57
-
-
Save tjfontaine/9613567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct simpleStruct { | |
int a; | |
char* b; | |
}; | |
typedef struct simpleStruct s1; | |
struct myStruct { | |
int a; | |
char* b; | |
union { | |
int foo; | |
double bar; | |
}; | |
}; | |
typedef struct myStruct s2; | |
void foofunc(s2); | |
void unfunc(s1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FFI = require('ffi'), | |
ArrayType = require('ref-array'), | |
Struct = require('ref-struct'), | |
ref = require('ref'); | |
var voidPtr = ref.refType(ref.types.void); | |
exports.CONSTANTS = { | |
}; | |
var myStruct = exports.myStruct = Struct({ | |
a: ref.types.int32, | |
b: ref.types.CString, | |
union0: Union({ | |
foo: ref.types.int32, | |
bar: ref.types.double, | |
}), | |
}); | |
var myStructPtr = exports.myStructPtr = ref.refType(myStruct); | |
var simpleStruct = exports.simpleStruct = Struct({ | |
a: ref.types.int32, | |
b: ref.types.CString, | |
}); | |
var simpleStructPtr = exports.simpleStructPtr = ref.refType(simpleStruct); | |
exports.test = new FFI.Library('test', { | |
foofunc: [ref.types.void, [ | |
myStruct, | |
]], | |
unfunc: [ref.types.void, [ | |
simpleStruct, | |
]], | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment