Announcement

Collapse
No announcement yet.

Misuse Interface as jump table?

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

  • 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.

  • #2
    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.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      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.

      Comment

      Working...
      X