omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Anyone using ObjCBlocks?

    Pythonista
    blocks objc
    2
    2
    2450
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JonB
      JonB last edited by

      Has anyone been using ObjCBlocks that take multiple arguments in any APIs? I stumbled across what might be a pythonista bug, but it could easily just as well be my own stupidity.

      I have started tackling AudioUnits to experiment with real time audio processing. To that end, I am using
      AVAudioEngine
      and installing a data tap, which takes a Block of this form

      https://developer.apple.com/reference/avfoundation/avaudionodetapblock?language=objc

      typedef void (^AVAudioNodeTapBlock)(
           AVAudioPCMBuffer *buffer, AVAudioTime *when);
      

      The Python function I tried to use was

       def tap(_self, _sel, buffer, when)
      

      however, the proper method seemed to be

       def tap(_self, when, buffer, _sel)
      

      In other words, the argument order was backwards, except for the block itself. does the runtime swap arguments on us? Or is pythonista objc_utils doing something funny?

      1 Reply Last reply Reply Quote 1
      • dgelessus
        dgelessus last edited by

        Maybe this has something to do with iOS's 64-bit vararg calling conventions being different from normal 64-bit ARM. I think we were discussing that issue on Slack once, when @lukaskollmer tried to get NSLog working on a 64-bit device.

        The only reason I can think of why the argument order is so strange is that maybe _self is "early" enough in the list that it's passed as a register, and the rest of the arguments go on the stack, but somehow are in the wrong order?

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors