How about extending the C++ compiler ?

2009-05-31
2013-06-06
  • Ionut Popia

    Ionut Popia - 2009-05-31

    In Pascal there is a very powerful capability of the language: dynamic methods (or message-handling methods for those Pascal compilers which support Delphi). That is, virtual methods which are identified not by their name, but by an integer index which the programmer supplies when declaring the method. I think this would simplify VERY much writing a GUI toolkit library - in C++, because there are only virtual member functions, linking a message and a message-handling member function requires A LOT of artificial stuff. I say this because I don't like using the dedicated libraries like Borland OWL, Microsoft MFC etc etc which are huge as compared to what I need. I just want to make (and I made it) my own tiny GUI toolkit and use it. But in C++, I still find this very awkward - you cannot control the index that a virtual member function gets when it is declared, it just gets the next available value and you need to declare all the possible message handlers and also write the code to translate the message index to the index of the message handler member function.

     
    • Kai Tietz

      Kai Tietz - 2009-06-02

      Hi,

      The design of vtables is pretty much compiler specific. So if you want to provide such features, gcc project is maybe the best place for it. Possibly the new plugin-feature could be some help here for you.
      The otherway you can implement this, is using manual class-tables (like DCOM is using). So you can access the members via index. And by doing this, you are idependent of the compiler you are using.

      E.g.
      struct myVClass {
         void (*foo1)(void);
         int (*foo2)(struct mySecondClass *);
      ....
      };

      Cheers,
      Kai

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks