Created
August 18, 2011 07:46
-
-
Save TooTallNate/1153609 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
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?') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var exc_buf = new ffi.Pointer(1024 * 8) // WTF is this for?
ever figure it out?