--i0/AhcQY5QxfSsSZ
Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh"
Content-Disposition: inline


--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

hi all,

I've prepared a short proposal on how to quickly (but without loosing
features) create qt3 extension module for ruby, ..., if you are interested
please read on and comment. This proposal came from the fact that we have
actually gcc-xml output of all qt3 headers that can be reused somehow...

note that such proposal does not include any talk about signals and slots,
these have to come yet, but it hopefully covers the c++ overloading problem...

rgds,
martin

p.s. there are some issues left, curious if someone is going to point them out
;-))

-- 
Brian: Have I got a big nose, Mum?
Mandy: Stop thinking about sex!
Brian: I wasn't!
Mandy: You're always on about it.  "Will the girls like this?
  Will the girls like that?  Is it too big?  Is it too small?"
					-- Life of Brian, Monty Python

--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename=README
Content-Transfer-Encoding: quoted-printable

                          Ruby C++ glue code generator
                       Martin Man <Martin.Man / seznam.cz>
                       ---------------------------------

1) Take an XML representation (gcc-xml) of some C++ class
2) generate wrapper class that
   - reimplements all public methods
   - implements ptcd_XXX public methods for each virtual protected method
   - reimplements all protected virtual methods so that they call public 
     ptcd_XXX counterparts

3) this wrapper class will get a VALUE representing the Ruby object instance
4) every virtual method will ask instance VALUE whether it implements given
   method and if so calls it, otherwise the default implementation from 
   superclass (the original class) is called

example wrapper, QObject is the original class, RQObject its wrapper
---------------------------------------------------------------------

class QObject : public Qt {
    public:
        QObject ();
        ~QObject ();
        virtual vpub ();
    protected:
        virtual vprot ();
};

class RObject : public QObject {
    public:
        RQObject () : QObject {};

	~RQObject () {};

	virtual vpub () {
            // pseudo code
	    if rb_instance.respond_to? "vpub"
	        rb_funcall (rb_instance, "vpub");
	    else
	        QObject::vpub ();
	    end
	}

	virtual ptcd_vprot () {
	    // see vpub
	}

	void setRubyInstance (VALUE inst) { rb_instance = inst; }

    protected:
        virtual vprot () { ptcd_vprot (); }

    private:
        VALUE rb_instance;
};


5) ok, now we have a c++ class that reimplements all virtual methods so that
   they call their ruby implementation (if exists) or the default 
   implementation from the original c++ class.
6) I hope we can pass such class directly to swig-3.1.12 to generate real ruby 
   extension, then the only necessary thing is to modify each 
   wrap_new_XXX call to include call to setRubyInstance,
   possibly the swig can be patched to do this automatically for us

example addition to swig produced wrapper
-----------------------------------------
   static VALUE
   _wrap_new_QObject(int argc, VALUE *argv, VALUE self) {
       QObject *result;
  
       if ((argc < 0) || (argc > 0))
       rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc);

       result = (QObject *)new QObject();

+      result->setRubyInstance (self)

       DATA_PTR(self) = result;
       return self;
   }


--NzB8fVQJ5HfG6fxh--

--i0/AhcQY5QxfSsSZ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9BeCXYgJwJG4GAiMRAseMAJ9wmAWQJJyt3vnhu95RPB7uzDkvTwCfTa8K
HhNNDoLX+piWiASNDko+JZIWq
-----END PGP SIGNATURE-----

--i0/AhcQY5QxfSsSZ--