On Fri, Nov 09, 2007 at 01:28:08AM +0100, Chris Brody-GMail <[EMAIL PROTECTED]> 
wrote:
> Your new archive built OK on my OSX machine-thanks again!

Great. I am about to check in a change that allwos you to override header
locations e.g. like this:

   #define EV_H <ev_ev.h>
   #include "ev.c"
   #define EV_EVENT_H <event.h>
   #include "event.c"

> > I also wondered about (optionally, when embedding, so not directly
> > relevant to eventxx) having a member pointer + object instead of a
> > callback when compiling libev as C++.
> 
> I will need some time to think about a clear solution-should be
> possible with a "pure inline" wrapper class.

There are basically two options:

- when embedding (and only then) optionally allow use of c++ features, making
  libev a full c++ library incompatible with the c interface.

  this saves a pointer, thunking code, makes the code safer etc. but loses
  c compatibility.

  this is something I might likely go after for purely personal reasons - I
  have a lot of c++ programs currently using iom.C which could be converted
  to a libev c++ lib.

  this would be done using real subclassing etc:

  struct ev_io : ev_watcher_list {
     ...
     start ()
     stop ()

  and would complement libev nicely as its quite object-oriented in design.

- take the c interface and adapt it, very rough proof of concept:

  namespace ev {
     #include <ev.h>

     extern "C" void thunk_io_cb (struct ev_io *w, int revents)
     {
       static_cast<io *>(w)->(revents);
     }

     template<class base, class start, class stop>
     struct adaptor : callback<ev_io *, int> {
        adaptor ()
        {
          ev_watcher_init (static_cast<base> this, thunk_io_cb);
        }
        void start () { start (static_cast<base> this); }
        ...
     };

     struct io : ev_io, adaptor<ev_io, evio_start, evio_stop> {
        void set (int fd, int events) { ev_io_set (...); }
     };

     #undef ev_watcher_init /* dangerous in c++ */
     ...
  };

  /* I'll spare you the details of how callback<> is defined */

This would also allow a relatively natural usage, like:

   ev::io w (fd, EV_READ);
   w.start ();

   etc.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      [EMAIL PROTECTED]
      -=====/_/_//_/\_,_/ /_/\_\
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to