Oh, I see, I will try later, have to go for now. Thank you so much :)
Le 03/11/2014 02:12, Igor Stasenko a écrit :
NBExternalArray instances cannot be passed directly to functions expecting pointers. use 'myarray address' for arguments. On 3 November 2014 00:20, Alain Rastoul <[email protected] <mailto:[email protected]>> wrote: Hi, I have a problem with a nativeboost call, but I don't see what I do wrong. library function prototype is: int zmq_getsockopt (void *socket, int option_name, void *option_value, size_t *option_len); my calling method in pharo is: zmq_getsockopt: socket option_name: option_name option_value: option_value option_len: option_len <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode> ^self nbCall: #(int zmq_getsockopt (void *socket, int option_name, void * option_value, size_t* option_len) ) when I call it with ... optionValue := (NBExternalArray ofType: 'int') externalNew: 1. optionLen := (NBExternalArray ofType: 'size_t' ) externalNew: 1. [ optionValue at: 1 put: 0 . optionLen at: 1 put: (NBExternalType sizeOf: 'int') . rc := self zmq_getsockopt: socket option_name: option_name option_value: optionValue option_len: optionLen . value := optionValue at: 1 . ] ensure: [ optionValue free. optionLen free ]. ... I allways get an exception: "error during FFI call : nil" After stepping in NBFFICallout generation, I found something strange, the code generation seems not to be called because lastError stays at nil ? handleFailureIn: aContext nativeCode: aBlock lastError := self getErrorFrom: aContext lastError: NativeBoost lastError. >>getErrorFrom: aContext lastError: errorCode ... checks pragmas etc >>getErrorFrom: aContext lastError: errorCode ... lastError := aContext tempAt: method numTemps. => lastError = nil ??? shouldn't be ErrNoNativeCodeInMethod ? "install native code and retry the send" lastError = ErrNoNativeCodeInMethod ifTrue: [ ^ self generateCode: aBlock andRetry: aContext ]. never gets called ... "ok, we're out of options, signal an error here" ^ self signalError: lastError Could it be because I use this image on windows and unix ? Or because I had an exception at prototype parsing the first time because I forgot a ; at the end of the prototype ? Is my prototype correct or is it the origin of the error ? Is there a way to reset the lastError (aContext tempAt: method numTemps) ? I will try to reset it in debugger but may be there is a cleaner way ? would it be ok to change the test in handleFailure to (lastError = ErrNoNativeCodeInMethod) or:[ lastError isNil ] ? (I can open a bug in this case ) Any idea or comment is welcome Thanks in advance Alain -- Best regards, Igor Stasenko.
