[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[S8ObjC] function pointer

SwikiCodeRobot @> #testS8ObjCFunctionPointer

"Changes the top-level error handler"
| pool getter setter gotCallback handler |
gotCallback := false.
pool := (ObjCClass classNamed: #NSAutoreleasePool in: #Foundation) newInstanceHandle.
getter := S8ObjC value: #NSGetUncaughtExceptionHandler.
setter := S8ObjC value: #NSSetUncaughtExceptionHandler.
setter value: [:ex|
	gotCallback:= true.
	ex = #test ifFalse: [ self error: 'Wrong exception value ',ex ].
].
getter value: (S8ObjC value: #test).
NodeProcess current on: #exit do: [
	self print: 'gotCallback =',gotCallback
]