Uploaded image for project: 'FireBreath Core'
  1. FireBreath Core
  2. FIREBREATH-18

Type Safe Javascript Event Function Calls

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: FireBreath 1.5.0rc1
    • Fix Version/s: FireBreath 1.5.0rc1
    • Operating System:
      Windows, Mac OS X, Linux/FreeBSD
    • Web Browser:
      Firefox 3.x, Firefox 4.x, Google Chrome, Apple Safari, Internet Explorer 6-8, Internet Explorer 9, Opera

      Description

      It's a common pitfall for users to miss an argument, or specify the wrong type when making an event call through FireEvent. Likewise, all events that I can think of are known at compile time.

      That said, I think we can put something together that can make it easy to declare events and add significant type safety to them.

      The biggest problem involved is static initialization. This can be by passed by using templates to do static initialization. Attached is an example of my Singleton pattern that does exactly this.

      I'm thinking that we could put something together like a template class that is derived from a PluginEventTemplate class, e.g.

      template <typename PluginAPI> MyPluginEvents : public PluginEventTemplate<PluginAPI> {
         DEFINE_EVENT("onevent", void (int,char,bool));
      };
      

      Then to make it part of the plugin api class, do it like enable_shared_from_this;

      class MyPluginAPI : public MyPluginEvents<MyPluginAPI> {
      };
      

      This should provide a means of which to statically define events with function prototypes.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                richard Richard Bateman
                Reporter:
                omnisip Dan Weber
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: