Announcement

Collapse
No announcement yet.

Misuse Interface as jump table?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • John Petty
    replied
    Seems the proper way to create callback fuctions. Of course if you are an anti global person then the adresses could be passed as a series of variables in the init routine.
    Can't see any benefit in trying to use classes.

    Leave a comment:


  • Michael Mattias
    replied
    You can misuse or abuse anything.

    BTW, I don't find your current design ugly at all; it sounds quite clean, actually.

    Of course, I'm not the guy on the "C" side who has to use it.

    Leave a comment:


  • David Buckley
    started a topic Misuse Interface as jump table?

    Misuse Interface as jump table?

    I like to write text parsers using a parser generator tool which makes it very easy to create reliable solid parsers. It produces its output as a C source file, which I compile into a DLL. I then call that DLL from PB, all easy stuff.

    The fun comes when the parser wants to call back to PB to pass it some data or invoke some function. What I have been doing to date is to create a UDT in PB with a long for the address of each function. I then create a global instance of the UDT and in PBmain do a series of assignment to put the address of each function into the UDT variable.

    In the C side I have an identical structure.

    When I call the parser I pass the address of the UDT instance, and then in C do something like (*x.FunctionName)(parm1, parm2); It all works but its ugly.

    The question is, can I misuse the PB9 interface / end interface to replace the UDT? I've had a play, and cant get further than exceptions. I dont want to go as far as "proper" COM.
Working...
X