check smptr check in pf_call() in ffi.c
changed FFI>>call:signature:arguments: to throw an FFIException exception upon failure added FFIException
This commit is contained in:
@ -1023,7 +1023,10 @@ class AssociativeCollection(Collection)
|
||||
|
||||
method associationAt: assoc
|
||||
{
|
||||
^self __find: (assoc key) or_upsert: false with: nil.
|
||||
| ass |
|
||||
ass := self __find: (assoc key) or_upsert: false with: nil.
|
||||
if (ass isError) { ^KeyNotFoundException signal: ('Unable to find ' & (assoc key asString)) }.
|
||||
^ass.
|
||||
}
|
||||
|
||||
method associationAt: assoc ifAbsent: error_block
|
||||
|
@ -8,6 +8,10 @@ class _FFI(Object) from 'ffi'
|
||||
method(#primitive) call(func, sig, args).
|
||||
}
|
||||
|
||||
class FFIException(Exception)
|
||||
{
|
||||
}
|
||||
|
||||
class FFI(Object)
|
||||
{
|
||||
var name, ffi, funcs.
|
||||
@ -42,11 +46,11 @@ class FFI(Object)
|
||||
|
||||
method call: name signature: sig arguments: args
|
||||
{
|
||||
| f |
|
||||
| f rc |
|
||||
|
||||
(* f := self.funcs at: name ifAbsent: [
|
||||
f := self.ffi getsym(name).
|
||||
if (f isError) { ^f }.
|
||||
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
|
||||
self.funcs at: name put: f.
|
||||
f. ## need this as at:put: returns an association
|
||||
]. *)
|
||||
@ -55,10 +59,11 @@ class FFI(Object)
|
||||
if (f isNil)
|
||||
{
|
||||
f := self.ffi getsym(name).
|
||||
if (f isError) { ^f }.
|
||||
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
|
||||
self.funcs at: name put: f.
|
||||
}.
|
||||
|
||||
^self.ffi call(f, sig, args)
|
||||
rc := self.ffi call(f, sig, args).
|
||||
if (rc isError) { FFIException signal: ('Unable to call %s' strfmt(name)) }.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user