Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    ref-strictpublic

    ref-strict

    adds strict typing layer on to ffi on a per type basis, especially helpful if you are binding a library with opqaue pointers and want to ensure that what is being passed to the native layer is indeed the proper type

    var voidPtr = ref.refType(ref.types.void)
    var myType = StrictType(voidPtr)
     
    var l = ffi.Library(mylib, {
      myType_init: [myType, []],
      otherType_init: [voidPtr, []],
      some_method: [ref.type.void, [myType]],
    })
     
    var m = l.myType_init()
    var o = l.otherType_init()
     
    // will throw 
    l.some_method(o)
     
    // will succeed 
    l.some_method(m)
     
    // will succeed but cause you all kinds of pain 
    l.some_method(myType.cast(o))

    Keywords

    none

    install

    npm i ref-strict

    Downloadslast 7 days

    3

    version

    0.0.2

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar