<div dir="ltr">On Fri, Apr 15, 2016 at 5:13 AM, Jonas Maebe <span dir="ltr"><<a href="mailto:jonas.maebe@elis.ugent.be" target="_blank">jonas.maebe@elis.ugent.be</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br></span>
The tests in the testsuite work at least, both for ARM and AArch64.</blockquote><div>Could it be run-time environment dependent then...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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.<br></blockquote><div>I think it attempted to copy the block in some way, didn't find the proper reference and crashed or something like that.</div><div>Again, without any useful debugging information (which i didn't provide), it's just impossible to say.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">When using trunk, you should always use the latest version.<br></blockquote><div>First all of - I am so sorry - I've not updated yet to the latest trunk. I decided to play with blocks first.<br></div><div>Second - THANK YOU - for blockrtl unit.</div><div> </div><div>Instead of relying on FPC to do the block, I decided to make the block myself.</div><div><br></div><div>1) the declaration of </div><div><div> GCExtendedGamepadValueChangedHandler = reference to procedure (gamepad: GCGamepad;</div><div> element: GCControllerElement); cdecl;</div></div><div>was changed back to:<br></div><div><br></div><div> GCExtendedGamepadValueChangedHandler = OpaqueCBlock;<br></div><div><div><br></div></div><div>1.1) </div><div>the method declaration</div><div> GCExtendedGamepad = objcclass external (NSObject) </div><div> ...</div><div><div> procedure setValueChangedHandler(newValue: GCExtendedGamepadValueChangedHandler); message 'setValueChangedHandler:'; </div></div><div><br></div><div>remains unchanged.</div><div><br></div><div>2) the main unit is now using "blockrtl". </div><div>3) the call has been adjusted as following:</div><div><br></div><div>type</div><div> Tblock = FPC_Block_literal_base</div><div> Pblock = ^TBlock;</div><div><br></div><div><div>var</div><div> descr : FPC_Block_descriptor_complex; // global block description</div><div> </div></div><div>procedure joystickInit;</div><div>var</div><div> ..</div><div> gc : GCController;</div><div> block : tblock; </div><div>...</div><div><div> fillchar(descr, sizeof(descr), 0);</div><div> descr.Block_size:=sizeof(block);</div><div>...</div><div> fillchar(block, sizeof(block), 0);</div><div> block.isa:=@_NSConcreteStackBlock; // the block is on stack</div><div> block.descriptor:=@descr; // pointing to description</div><div> block.invoke:=@extendedGamePadChange_inblock; // point to the function</div><div>...</div><div> gc.extendedGamepad.setValueChangedHandler(@block);</div></div><div><br></div><div>4) extendedGamePadChange_inblock() looks like this:</div><div><br></div><div><div>procedure extendedGamePadChange_inblock(block: PBlock; gamepad: GCGamepad; element: GCControllerElement); cdecl;</div><div>begin</div><div> writeln('block is calling!');</div><div> writeln('A: ', gamepad.buttonA.isPressed);</div><div> writeln('B: ', gamepad.buttonB.isPressed);</div><div> writeln('X: ', gamepad.buttonX.isPressed);</div><div> writeln('Y: ', gamepad.buttonY.isPressed);</div><div>end; <br></div></div><div><br></div><div>and that's it. The code works. The function is called as expected, providing accurate data.</div><div>call to ssetValueChangedHandler() doesn't crash. darwin-arm7</div><div><br></div><div>I'm going to update to the latest FPC revision now.<br></div><div><br></div><div>thanks,</div><div>Dmitry</div></div></div></div>