Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created August 18, 2011 07:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TooTallNate/1153609 to your computer and use it in GitHub Desktop.
Save TooTallNate/1153609 to your computer and use it in GitHub Desktop.
var ffi = require('node-ffi')
, objc = new ffi.Library('libobjc', {
objc_msgSend: [ 'pointer', [ 'pointer', 'pointer', ] ]
, objc_getClass: [ 'pointer', [ 'string' ] ]
, sel_registerName: [ 'pointer', [ 'string' ] ]
// try/catch
, objc_begin_catch: [ 'pointer', [ 'pointer' ] ]
, objc_end_catch: [ 'void', [] ]
})
, NSObject = objc.objc_getClass('NSObject')
, badSelector = objc.sel_registerName('nonexistantMethod')
// Set up an @try/@catch
var exc_buf = new ffi.Pointer(1024 * 8) // WTF is this for?
, rtn = objc.objc_begin_catch(exc_buf)
console.error(exc_buf)
console.error(rtn) // returning NULL
// Invoke an exception
objc.objc_msgSend(NSObject, badSelector)
objc.objc_end_catch()
console.error('Did we get to here?')
@joedaniels29
Copy link

var exc_buf = new ffi.Pointer(1024 * 8) // WTF is this for?

ever figure it out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment