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:
hyunghwan.chung
2018-12-22 08:37:18 +00:00
parent f69b4c0881
commit 981882de7e
4 changed files with 29 additions and 25 deletions

View File

@ -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

View File

@ -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)) }.
}
}