On Fri, Apr 15, 2016 at 5:13 AM, Jonas Maebe <jonas.ma...@elis.ugent.be> wrote:
> > The tests in the testsuite work at least, both for ARM and AArch64. Could it be run-time environment dependent then... > Even if that were the case, it wouldn't crash at that place in > objc_msgSend. r0 contains the "self" pointer of the Objective-C instance. > It's unrelated to the the value of any parameters. > I think it attempted to copy the block in some way, didn't find the proper reference and crashed or something like that. Again, without any useful debugging information (which i didn't provide), it's just impossible to say. > When using trunk, you should always use the latest version. > First all of - I am so sorry - I've not updated yet to the latest trunk. I decided to play with blocks first. Second - THANK YOU - for blockrtl unit. Instead of relying on FPC to do the block, I decided to make the block myself. 1) the declaration of GCExtendedGamepadValueChangedHandler = reference to procedure (gamepad: GCGamepad; element: GCControllerElement); cdecl; was changed back to: GCExtendedGamepadValueChangedHandler = OpaqueCBlock; 1.1) the method declaration GCExtendedGamepad = objcclass external (NSObject) ... procedure setValueChangedHandler(newValue: GCExtendedGamepadValueChangedHandler); message 'setValueChangedHandler:'; remains unchanged. 2) the main unit is now using "blockrtl". 3) the call has been adjusted as following: type Tblock = FPC_Block_literal_base Pblock = ^TBlock; var descr : FPC_Block_descriptor_complex; // global block description procedure joystickInit; var .. gc : GCController; block : tblock; ... fillchar(descr, sizeof(descr), 0); descr.Block_size:=sizeof(block); ... fillchar(block, sizeof(block), 0); block.isa:=@_NSConcreteStackBlock; // the block is on stack block.descriptor:=@descr; // pointing to description block.invoke:=@extendedGamePadChange_inblock; // point to the function ... gc.extendedGamepad.setValueChangedHandler(@block); 4) extendedGamePadChange_inblock() looks like this: procedure extendedGamePadChange_inblock(block: PBlock; gamepad: GCGamepad; element: GCControllerElement); cdecl; begin writeln('block is calling!'); writeln('A: ', gamepad.buttonA.isPressed); writeln('B: ', gamepad.buttonB.isPressed); writeln('X: ', gamepad.buttonX.isPressed); writeln('Y: ', gamepad.buttonY.isPressed); end; and that's it. The code works. The function is called as expected, providing accurate data. call to ssetValueChangedHandler() doesn't crash. darwin-arm7 I'm going to update to the latest FPC revision now. thanks, Dmitry
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel