Hi,

In message "[ruby-talk:04519] a question about extension modules"
    on 00/08/21, Jon Aseltine <aseltine / cs.umass.edu> writes:

|I asked once, but perhaps I wasn't clear enough. Is it possible to
|implement an extension module for a C++ library (for example,
|TrollTech's QT library)? The README.EXT file focuses on C libraries, not
|C++.

Possible.  The only clue you need is enclose Init_ funciton by extern "C".
swigruby and its generated code may help you.

							matz.
--- qt.i
// Minimum Qt interface for hello world
%module qt
%{
#include <qapplication.h>
#include <qpushbutton.h>
%}
%include typemaps.i

class QObject {};
class QPaintDevice {};
class QWidget : public QObject, public QPaintDevice {
public:
    void show();
};
class QButton : public QWidget {};

class QPushButton : public QButton {
public:
    QPushButton( const char *text, QWidget *parent=0, const char *name=0 );
    void resize( int w, int h );
};

class QApplication : public QObject {
public:
    %addmethods {
#ifdef SWIGRUBY
    QApplication(VALUE vargv) {
	if (TYPE(vargv) != T_ARRAY) rb_raise(rb_eArgError, "Array expected");
	int argc = RARRAY(vargv)->len;
	char **argv = new char*[argc];
	for (int i = 0; i < argc; i++) {
	    VALUE v = RARRAY(vargv)->ptr[i];
	    if (TYPE(v) != T_STRING)
		rb_raise(rb_eArgError, "Array of String expected");
	    argv[i] = new char[RSTRING(v)->len + 1];
	    strcpy(argv[i], RSTRING(v)->ptr);
	}
	return new QApplication(argc, argv);
    }
#endif
    }
    void setMainWidget( QWidget * );
    int exec();
};
--- qt_wrap.c
/*
 * FILE : qt_wrap.cc
 * 
 * This file was automatically generated by :
 * Simplified Wrapper and Interface Generator (SWIG)
 * Version 1.1 (Patch 5)
 * 
 * Portions Copyright (c) 1995-1998
 * The University of Utah and The Regents of the University of California.
 * Permission is granted to distribute this file in any manner provided
 * this notice remains intact.
 * 
 * Do not make changes to this file--changes will be lost!
 *
 */


#define SWIGCODE
/* Implementation : RUBY */

#define SWIGRUBY
#include "ruby.h"

#define UINT2NUM(v) rb_uint2inum(v)
#define NUM2USHRT(n) NUM2UINT(n)
#define NUM2SHRT(n) (\
    (SHRT_MIN <= NUM2INT(n) && NUM2INT(n) <= SHRT_MAX)\
    ? (short)NUM2INT(n)\
    : (rb_raise(rb_eArgError, "integer %d out of range of `short'",\
               NUM2INT(n)), (short)0)\
)

#ifdef __cplusplus
# define VALUEFUNC(f) ((VALUE (*)(...))f)
# define VOIDFUNC(f) ((void (*)(...))f)
#else
# define VALUEFUNC(f) (f)
# define VOIDFUNC(f) (f)
#endif

/*****************************************************************************
 * $Header:$
 *
 * swigptr.swg
 *
 * This file contains supporting code for the SWIG run-time type checking
 * mechanism.  The following functions are available :
 *
 * SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *));
 *
 *      Registers a new type-mapping with the type-checker.  origtype is the
 *      original datatype and newtype is an equivalent type.  cast is optional
 *      pointer to a function to cast pointer values between types (this
 *      is typically used to cast pointers from derived classes to base classes in C++)
 *      
 * SWIG_MakePtr(char *buffer, void *ptr, char *typestring);
 *     
 *      Makes a pointer string from a pointer and typestring.  The result is returned
 *      in buffer which is assumed to hold enough space for the result.
 *
 * char * SWIG_GetPtr(char *buffer, void **ptr, char *type)
 *
 *      Gets a pointer value from a string.  If there is a type-mismatch, returns
 *      a character string to the received type.  On success, returns NULL.
 *
 *
 * You can remap these functions by making a file called "swigptr.swg" in
 * your the same directory as the interface file you are wrapping.
 *
 * These functions are normally declared static, but this file can be
 * can be used in a multi-module environment by redefining the symbol
 * SWIGSTATIC.
 *****************************************************************************/

#include <stdlib.h>

#ifdef SWIG_GLOBAL
#ifdef __cplusplus
#define SWIGSTATIC extern "C"
#else
#define SWIGSTATIC
#endif
#endif

#ifndef SWIGSTATIC
#define SWIGSTATIC static
#endif


/* SWIG pointer structure */

typedef struct SwigPtrType {
  char               *name;               /* Datatype name                  */
  int                 len;                /* Length (used for optimization) */
  void               *(*cast)(void *);    /* Pointer casting function       */
  struct SwigPtrType *next;               /* Linked list pointer            */
} SwigPtrType;

/* Pointer cache structure */

typedef struct {
  int                 stat;               /* Status (valid) bit             */
  SwigPtrType        *tp;                 /* Pointer to type structure      */
  char                name[256];          /* Given datatype name            */
  char                mapped[256];        /* Equivalent name                */
} SwigCacheType;

/* Some variables  */

static int SwigPtrMax  = 64;           /* Max entries that can be currently held */
                                       /* This value may be adjusted dynamically */
static int SwigPtrN    = 0;            /* Current number of entries              */
static int SwigPtrSort = 0;            /* Status flag indicating sort            */
static int SwigStart[256];             /* Starting positions of types            */

/* Pointer table */
static SwigPtrType *SwigPtrTable = 0;  /* Table containing pointer equivalences  */

/* Cached values */

#define SWIG_CACHESIZE  8
#define SWIG_CACHEMASK  0x7
static SwigCacheType SwigCache[SWIG_CACHESIZE];  
static int SwigCacheIndex = 0;
static int SwigLastCache = 0;

/* Sort comparison function */
static int swigsort(const void *data1, const void *data2) {
	SwigPtrType *d1 = (SwigPtrType *) data1;
	SwigPtrType *d2 = (SwigPtrType *) data2;
	return strcmp(d1->name,d2->name);
}

/* Binary Search function */
static int swigcmp(const void *key, const void *data) {
  char *k = (char *) key;
  SwigPtrType *d = (SwigPtrType *) data;
  return strncmp(k,d->name,d->len);
}

/* Register a new datatype with the type-checker */

SWIGSTATIC 
void SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) {

  int i;
  SwigPtrType *t = 0,*t1;

  /* Allocate the pointer table if necessary */

  if (!SwigPtrTable) {     
    SwigPtrTable = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType));
    SwigPtrN = 0;
  }
  /* Grow the table */
  if (SwigPtrN >= SwigPtrMax) {
    SwigPtrMax = 2*SwigPtrMax;
    SwigPtrTable = (SwigPtrType *) realloc((char *) SwigPtrTable,SwigPtrMax*sizeof(SwigPtrType));
  }
  for (i = 0; i < SwigPtrN; i++)
    if (strcmp(SwigPtrTable[i].name,origtype) == 0) {
      t = &SwigPtrTable[i];
      break;
    }
  if (!t) {
    t = &SwigPtrTable[SwigPtrN];
    t->name = origtype;
    t->len = strlen(t->name);
    t->cast = 0;
    t->next = 0;
    SwigPtrN++;
  }

  /* Check for existing entry */

  while (t->next) {
    if ((strcmp(t->name,newtype) == 0)) {
      if (cast) t->cast = cast;
      return;
    }
    t = t->next;
  }
  
  /* Now place entry (in sorted order) */

  t1 = (SwigPtrType *) malloc(sizeof(SwigPtrType));
  t1->name = newtype;
  t1->len = strlen(t1->name);
  t1->cast = cast;
  t1->next = 0;            
  t->next = t1;           
  SwigPtrSort = 0;
}

/* Make a pointer value string */

SWIGSTATIC 
void SWIG_MakePtr(char *_c, const void *_ptr, char *type) {
  static char _hex[16] =
  {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
   'a', 'b', 'c', 'd', 'e', 'f'};
  unsigned long _p, _s;
  char _result[20], *_r;    /* Note : a 64-bit hex number = 16 digits */
  _r = _result;
  _p = (unsigned long) _ptr;
  if (_p > 0) {
    while (_p > 0) {
      _s = _p & 0xf;
      *(_r++) = _hex[_s];
      _p = _p >> 4;
    }
    *_r = '_';
    while (_r >= _result)
      *(_c++) = *(_r--);
  } else {
    strcpy (_c, "NULL");
  }
  if (_ptr)
    strcpy (_c, type);
}

/* Define for backwards compatibility */

#define _swig_make_hex   SWIG_MakePtr 

/* Function for getting a pointer value */

SWIGSTATIC 
char *SWIG_GetPtr(char *_c, void **ptr, char *_t)
{
  unsigned long _p;
  char temp_type[256];
  char *name;
  int  i, len;
  SwigPtrType *sp,*tp;
  SwigCacheType *cache;
  int  start, end;
  _p = 0;

  /* Pointer values must start with leading underscore */
  if (*_c == '_') {
      _c++;
      /* Extract hex value from pointer */
      while (*_c) {
	  if ((*_c >= '0') && (*_c <= '9'))
	    _p = (_p << 4) + (*_c - '0');
	  else if ((*_c >= 'a') && (*_c <= 'f'))
	    _p = (_p << 4) + ((*_c - 'a') + 10);
	  else
	    break;
	  _c++;
      }

      if (_t) {
	if (strcmp(_t,_c)) { 
	  if (!SwigPtrSort) {
	    qsort((void *) SwigPtrTable, SwigPtrN, sizeof(SwigPtrType), swigsort); 
	    for (i = 0; i < 256; i++) {
	      SwigStart[i] = SwigPtrN;
	    }
	    for (i = SwigPtrN-1; i >= 0; i--) {
	      SwigStart[(int) (SwigPtrTable[i].name[1])] = i;
	    }
	    for (i = 255; i >= 1; i--) {
	      if (SwigStart[i-1] > SwigStart[i])
		SwigStart[i-1] = SwigStart[i];
	    }
	    SwigPtrSort = 1;
	    for (i = 0; i < SWIG_CACHESIZE; i++)  
	      SwigCache[i].stat = 0;
	  }
	  
	  /* First check cache for matches.  Uses last cache value as starting point */
	  cache = &SwigCache[SwigLastCache];
	  for (i = 0; i < SWIG_CACHESIZE; i++) {
	    if (cache->stat) {
	      if (strcmp(_t,cache->name) == 0) {
		if (strcmp(_c,cache->mapped) == 0) {
		  cache->stat++;
		  *ptr = (void *) _p;
		  if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr);
		  return (char *) 0;
		}
	      }
	    }
	    SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK;
	    if (!SwigLastCache) cache = SwigCache;
	    else cache++;
	  }
	  /* We have a type mismatch.  Will have to look through our type
	     mapping table to figure out whether or not we can accept this datatype */

	  start = SwigStart[(int) _t[1]];
	  end = SwigStart[(int) _t[1]+1];
	  sp = &SwigPtrTable[start];
	  while (start < end) {
	    if (swigcmp(_t,sp) == 0) break;
	    sp++;
	    start++;
	  }
	  if (start >= end) sp = 0;
	  /* Try to find a match for this */
	  if (sp) {
	    while (swigcmp(_t,sp) == 0) {
	      name = sp->name;
	      len = sp->len;
	      tp = sp->next;
	      /* Try to find entry for our given datatype */
	      while(tp) {
		if (tp->len >= 255) {
		  return _c;
		}
		strcpy(temp_type,tp->name);
		strncat(temp_type,_t+len,255-tp->len);
		if (strcmp(_c,temp_type) == 0) {
		  
		  strcpy(SwigCache[SwigCacheIndex].mapped,_c);
		  strcpy(SwigCache[SwigCacheIndex].name,_t);
		  SwigCache[SwigCacheIndex].stat = 1;
		  SwigCache[SwigCacheIndex].tp = tp;
		  SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK;
		  
		  /* Get pointer value */
		  *ptr = (void *) _p;
		  if (tp->cast) *ptr = (*(tp->cast))(*ptr);
		  return (char *) 0;
		}
		tp = tp->next;
	      }
	      sp++;
	      /* Hmmm. Didn't find it this time */
	    }
	  }
	  /* Didn't find any sort of match for this data.  
	     Get the pointer value and return the received type */
	  *ptr = (void *) _p;
	  return _c;
	} else {
	  /* Found a match on the first try.  Return pointer value */
	  *ptr = (void *) _p;
	  return (char *) 0;
	}
      } else {
	/* No type specified.  Good luck */
	*ptr = (void *) _p;
	return (char *) 0;
      }
  } else {
    if (strcmp (_c, "NULL") == 0) {
	*ptr = (void *) 0;
	return (char *) 0;
    }
    *ptr = (void *) 0;	
    return _c;
  }
}

/* Compatibility mode */

#define _swig_get_hex  SWIG_GetPtr

#define SWIG_init    Init_qt
#define SWIG_name    "Qt"

static VALUE mQt;



#include <qapplication.h>
#include <qpushbutton.h>

static VALUE output_helper(VALUE target, VALUE o) {
    if (NIL_P(target)) {
	target = o;
    } else {
	if (TYPE(target) != T_ARRAY) {
	    VALUE o2 = target;
	    target = rb_ary_new();
	    rb_ary_push(target, o2);
	}
	rb_ary_push(target, o);
    }
    return target;
}

#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
struct timeval rb_time_timeval(VALUE);
#endif
#ifdef __cplusplus
}
#endif
extern VALUE cQObject;
extern VALUE cQPaintDevice;
extern VALUE cQWidget;
extern VALUE cQButton;
extern VALUE cQPushButton;
extern VALUE cQApplication;

VALUE cQObject;
#define Wrap_QObject(ptr) (\
    (ptr) ? Data_Wrap_Struct(cQObject, 0, 0, ptr) : Qnil )
#define Get_QObject(val, ptr) {\
    if (NIL_P(val)) ptr = NULL;\
    else {\
        if (!rb_obj_is_kind_of(val, cQObject))\
            rb_raise(rb_eTypeError, "wrong argument type (expected QObject)");\
        Data_Get_Struct(val, QObject, ptr);\
        if (!ptr) rb_raise(rb_eRuntimeError, "This QObject already released");\
    }\
}

VALUE cQPaintDevice;
#define Wrap_QPaintDevice(ptr) (\
    (ptr) ? Data_Wrap_Struct(cQPaintDevice, 0, 0, ptr) : Qnil )
#define Get_QPaintDevice(val, ptr) {\
    if (NIL_P(val)) ptr = NULL;\
    else {\
        if (!rb_obj_is_kind_of(val, cQPaintDevice))\
            rb_raise(rb_eTypeError, "wrong argument type (expected QPaintDevice)");\
        Data_Get_Struct(val, QPaintDevice, ptr);\
        if (!ptr) rb_raise(rb_eRuntimeError, "This QPaintDevice already released");\
    }\
}

VALUE cQWidget;
#define Wrap_QWidget(ptr) (\
    (ptr) ? Data_Wrap_Struct(cQWidget, 0, 0, ptr) : Qnil )
#define Get_QWidget(val, ptr) {\
    if (NIL_P(val)) ptr = NULL;\
    else {\
        if (!rb_obj_is_kind_of(val, cQWidget))\
            rb_raise(rb_eTypeError, "wrong argument type (expected QWidget)");\
        Data_Get_Struct(val, QWidget, ptr);\
        if (!ptr) rb_raise(rb_eRuntimeError, "This QWidget already released");\
    }\
}

VALUE cQButton;
#define Wrap_QButton(ptr) (\
    (ptr) ? Data_Wrap_Struct(cQButton, 0, 0, ptr) : Qnil )
#define Get_QButton(val, ptr) {\
    if (NIL_P(val)) ptr = NULL;\
    else {\
        if (!rb_obj_is_kind_of(val, cQButton))\
            rb_raise(rb_eTypeError, "wrong argument type (expected QButton)");\
        Data_Get_Struct(val, QButton, ptr);\
        if (!ptr) rb_raise(rb_eRuntimeError, "This QButton already released");\
    }\
}

VALUE cQPushButton;
#define Wrap_QPushButton(ptr) (\
    (ptr) ? Data_Wrap_Struct(cQPushButton, 0, 0, ptr) : Qnil )
#define Get_QPushButton(val, ptr) {\
    if (NIL_P(val)) ptr = NULL;\
    else {\
        if (!rb_obj_is_kind_of(val, cQPushButton))\
            rb_raise(rb_eTypeError, "wrong argument type (expected QPushButton)");\
        Data_Get_Struct(val, QPushButton, ptr);\
        if (!ptr) rb_raise(rb_eRuntimeError, "This QPushButton already released");\
    }\
}

VALUE cQApplication;
#define Wrap_QApplication(ptr) (\
    (ptr) ? Data_Wrap_Struct(cQApplication, 0, 0, ptr) : Qnil )
#define Get_QApplication(val, ptr) {\
    if (NIL_P(val)) ptr = NULL;\
    else {\
        if (!rb_obj_is_kind_of(val, cQApplication))\
            rb_raise(rb_eTypeError, "wrong argument type (expected QApplication)");\
        Data_Get_Struct(val, QApplication, ptr);\
        if (!ptr) rb_raise(rb_eRuntimeError, "This QApplication already released");\
    }\
}
static void *SwigQWidgetToQObject(void *ptr) {
    QWidget *src;
    QObject *dest;
    src = (QWidget *) ptr;
    dest = (QObject *) src;
    return (void *) dest;
}

static void *SwigQWidgetToQPaintDevice(void *ptr) {
    QWidget *src;
    QPaintDevice *dest;
    src = (QWidget *) ptr;
    dest = (QPaintDevice *) src;
    return (void *) dest;
}

#define QWidget_show(_swigobj)  (_swigobj->show())
static VALUE
_wrap_QWidget_show(VALUE self) {
    VALUE vresult = Qnil;
    QWidget * _arg0;

    Get_QWidget(self, _arg0);
    QWidget_show(_arg0);
    return vresult;
}

static void *SwigQButtonToQWidget(void *ptr) {
    QButton *src;
    QWidget *dest;
    src = (QButton *) ptr;
    dest = (QWidget *) src;
    return (void *) dest;
}

static void *SwigQButtonToQObject(void *ptr) {
    QButton *src;
    QObject *dest;
    src = (QButton *) ptr;
    dest = (QObject *) src;
    return (void *) dest;
}

static void *SwigQButtonToQPaintDevice(void *ptr) {
    QButton *src;
    QPaintDevice *dest;
    src = (QButton *) ptr;
    dest = (QPaintDevice *) src;
    return (void *) dest;
}

static void *SwigQPushButtonToQButton(void *ptr) {
    QPushButton *src;
    QButton *dest;
    src = (QPushButton *) ptr;
    dest = (QButton *) src;
    return (void *) dest;
}

static void *SwigQPushButtonToQWidget(void *ptr) {
    QPushButton *src;
    QWidget *dest;
    src = (QPushButton *) ptr;
    dest = (QWidget *) src;
    return (void *) dest;
}

static void *SwigQPushButtonToQObject(void *ptr) {
    QPushButton *src;
    QObject *dest;
    src = (QPushButton *) ptr;
    dest = (QObject *) src;
    return (void *) dest;
}

static void *SwigQPushButtonToQPaintDevice(void *ptr) {
    QPushButton *src;
    QPaintDevice *dest;
    src = (QPushButton *) ptr;
    dest = (QPaintDevice *) src;
    return (void *) dest;
}

#define new_QPushButton(_swigarg0,_swigarg1,_swigarg2) (new QPushButton(_swigarg0,_swigarg1,_swigarg2))
static VALUE
_wrap_new_QPushButton(int argc, VALUE *argv, VALUE self) {
    VALUE varg0;
    VALUE varg1;
    VALUE varg2;
    VALUE vresult = Qnil;
    QPushButton * _result;
    char * _arg0;
    QWidget * _arg1 = 0;
    char * _arg2 = 0;

    rb_scan_args(argc, argv, "12", &varg0, &varg1, &varg2);
    _arg0 = STR2CSTR(varg0);
    if (argc > 1) {
        Get_QWidget(varg1, _arg1);
    } 
    if (argc > 2) {
        _arg2 = STR2CSTR(varg2);
    } 
    _result = (QPushButton *)new_QPushButton(_arg0,_arg1,_arg2);
    vresult = Wrap_QPushButton(_result);
    return vresult;
}

#define QPushButton_resize(_swigobj,_swigarg0,_swigarg1)  (_swigobj->resize(_swigarg0,_swigarg1))
static VALUE
_wrap_QPushButton_resize(VALUE self, VALUE varg1, VALUE varg2) {
    VALUE vresult = Qnil;
    QPushButton * _arg0;
    int  _arg1;
    int  _arg2;

    Get_QPushButton(self, _arg0);
    _arg1 = NUM2INT(varg1);
    _arg2 = NUM2INT(varg2);
    QPushButton_resize(_arg0,_arg1,_arg2);
    return vresult;
}

static void *SwigQApplicationToQObject(void *ptr) {
    QApplication *src;
    QObject *dest;
    src = (QApplication *) ptr;
    dest = (QObject *) src;
    return (void *) dest;
}

static QApplication *new_QApplication(VALUE vargv) {
	if (TYPE(vargv) != T_ARRAY) rb_raise(rb_eArgError, "Array expected");
	int argc = RARRAY(vargv)->len;
	char **argv = new char*[argc];
	for (int i = 0; i < argc; i++) {
	    VALUE v = RARRAY(vargv)->ptr[i];
	    if (TYPE(v) != T_STRING)
		rb_raise(rb_eArgError, "Array of String expected");
	    argv[i] = new char[RSTRING(v)->len + 1];
	    strcpy(argv[i], RSTRING(v)->ptr);
	}
	return new QApplication(argc, argv);
    }

static VALUE
_wrap_new_QApplication(VALUE self, VALUE varg0) {
    VALUE vresult = Qnil;
    QApplication * _result;
    VALUE  _arg0;

    _arg0 = varg0;
    _result = (QApplication *)new_QApplication(_arg0);
    vresult = Wrap_QApplication(_result);
    return vresult;
}

#define QApplication_setMainWidget(_swigobj,_swigarg0)  (_swigobj->setMainWidget(_swigarg0))
static VALUE
_wrap_QApplication_setMainWidget(VALUE self, VALUE varg1) {
    VALUE vresult = Qnil;
    QApplication * _arg0;
    QWidget * _arg1;

    Get_QApplication(self, _arg0);
    Get_QWidget(varg1, _arg1);
    QApplication_setMainWidget(_arg0,_arg1);
    return vresult;
}

#define QApplication_exec(_swigobj)  (_swigobj->exec())
static VALUE
_wrap_QApplication_exec(VALUE self) {
    VALUE vresult = Qnil;
    int  _result;
    QApplication * _arg0;

    Get_QApplication(self, _arg0);
    _result = (int )QApplication_exec(_arg0);
    vresult = INT2NUM(_result);
    return vresult;
}


#ifdef __cplusplus
extern "C"
#endif
void Init_qt(void) {
    mQt = rb_define_module("Qt");


    cQObject = rb_define_class_under(mQt, "QObject", rb_cObject);
    rb_undef_method(CLASS_OF(cQObject), "new");

    cQPaintDevice = rb_define_class_under(mQt, "QPaintDevice", rb_cObject);
    rb_undef_method(CLASS_OF(cQPaintDevice), "new");

    cQWidget = rb_define_class_under(mQt, "QWidget", cQObject);
    rb_undef_method(CLASS_OF(cQWidget), "new");
    rb_define_method(cQWidget, "show", VALUEFUNC(_wrap_QWidget_show), 0);

    cQButton = rb_define_class_under(mQt, "QButton", cQWidget);
    rb_undef_method(CLASS_OF(cQButton), "new");

    cQPushButton = rb_define_class_under(mQt, "QPushButton", cQButton);
    rb_define_singleton_method(cQPushButton, "new", VALUEFUNC(_wrap_new_QPushButton), -1);
    rb_define_method(cQPushButton, "resize", VALUEFUNC(_wrap_QPushButton_resize), 2);

    cQApplication = rb_define_class_under(mQt, "QApplication", cQObject);
    rb_define_singleton_method(cQApplication, "new", VALUEFUNC(_wrap_new_QApplication), 1);
    rb_define_method(cQApplication, "setMainWidget", VALUEFUNC(_wrap_QApplication_setMainWidget), 1);
    rb_define_method(cQApplication, "exec", VALUEFUNC(_wrap_QApplication_exec), 0);

/*
 * These are the pointer type-equivalency mappings. 
 * (Used by the SWIG pointer type-checker).
 */
	 SWIG_RegisterMapping("_signed_long","_long",0);
	 SWIG_RegisterMapping("_QObject","_class_QApplication",SwigQApplicationToQObject);
	 SWIG_RegisterMapping("_QObject","_QApplication",SwigQApplicationToQObject);
	 SWIG_RegisterMapping("_QObject","_class_QPushButton",SwigQPushButtonToQObject);
	 SWIG_RegisterMapping("_QObject","_QPushButton",SwigQPushButtonToQObject);
	 SWIG_RegisterMapping("_QObject","_class_QButton",SwigQButtonToQObject);
	 SWIG_RegisterMapping("_QObject","_QButton",SwigQButtonToQObject);
	 SWIG_RegisterMapping("_QObject","_class_QWidget",SwigQWidgetToQObject);
	 SWIG_RegisterMapping("_QObject","_QWidget",SwigQWidgetToQObject);
	 SWIG_RegisterMapping("_QObject","_class_QObject",0);
	 SWIG_RegisterMapping("_QApplication","_class_QApplication",0);
	 SWIG_RegisterMapping("_long","_unsigned_long",0);
	 SWIG_RegisterMapping("_long","_signed_long",0);
	 SWIG_RegisterMapping("_class_QPushButton","_QPushButton",0);
	 SWIG_RegisterMapping("_class_QApplication","_QApplication",0);
	 SWIG_RegisterMapping("_QButton","_class_QPushButton",SwigQPushButtonToQButton);
	 SWIG_RegisterMapping("_QButton","_QPushButton",SwigQPushButtonToQButton);
	 SWIG_RegisterMapping("_QButton","_class_QButton",0);
	 SWIG_RegisterMapping("_class_QObject","_class_QApplication",SwigQApplicationToQObject);
	 SWIG_RegisterMapping("_class_QObject","_QApplication",SwigQApplicationToQObject);
	 SWIG_RegisterMapping("_class_QObject","_class_QPushButton",SwigQPushButtonToQObject);
	 SWIG_RegisterMapping("_class_QObject","_QPushButton",SwigQPushButtonToQObject);
	 SWIG_RegisterMapping("_class_QObject","_class_QButton",SwigQButtonToQObject);
	 SWIG_RegisterMapping("_class_QObject","_QButton",SwigQButtonToQObject);
	 SWIG_RegisterMapping("_class_QObject","_class_QWidget",SwigQWidgetToQObject);
	 SWIG_RegisterMapping("_class_QObject","_QWidget",SwigQWidgetToQObject);
	 SWIG_RegisterMapping("_class_QObject","_QObject",0);
	 SWIG_RegisterMapping("_unsigned_long","_long",0);
	 SWIG_RegisterMapping("_QWidget","_class_QPushButton",SwigQPushButtonToQWidget);
	 SWIG_RegisterMapping("_QWidget","_QPushButton",SwigQPushButtonToQWidget);
	 SWIG_RegisterMapping("_QWidget","_class_QButton",SwigQButtonToQWidget);
	 SWIG_RegisterMapping("_QWidget","_QButton",SwigQButtonToQWidget);
	 SWIG_RegisterMapping("_QWidget","_class_QWidget",0);
	 SWIG_RegisterMapping("_signed_int","_int",0);
	 SWIG_RegisterMapping("_QPaintDevice","_class_QPushButton",SwigQPushButtonToQPaintDevice);
	 SWIG_RegisterMapping("_QPaintDevice","_QPushButton",SwigQPushButtonToQPaintDevice);
	 SWIG_RegisterMapping("_QPaintDevice","_class_QButton",SwigQButtonToQPaintDevice);
	 SWIG_RegisterMapping("_QPaintDevice","_QButton",SwigQButtonToQPaintDevice);
	 SWIG_RegisterMapping("_QPaintDevice","_class_QWidget",SwigQWidgetToQPaintDevice);
	 SWIG_RegisterMapping("_QPaintDevice","_QWidget",SwigQWidgetToQPaintDevice);
	 SWIG_RegisterMapping("_QPaintDevice","_class_QPaintDevice",0);
	 SWIG_RegisterMapping("_class_QButton","_class_QPushButton",SwigQPushButtonToQButton);
	 SWIG_RegisterMapping("_class_QButton","_QPushButton",SwigQPushButtonToQButton);
	 SWIG_RegisterMapping("_class_QButton","_QButton",0);
	 SWIG_RegisterMapping("_unsigned_short","_short",0);
	 SWIG_RegisterMapping("_signed_short","_short",0);
	 SWIG_RegisterMapping("_QPushButton","_class_QPushButton",0);
	 SWIG_RegisterMapping("_unsigned_int","_int",0);
	 SWIG_RegisterMapping("_class_QPaintDevice","_class_QPushButton",SwigQPushButtonToQPaintDevice);
	 SWIG_RegisterMapping("_class_QPaintDevice","_QPushButton",SwigQPushButtonToQPaintDevice);
	 SWIG_RegisterMapping("_class_QPaintDevice","_class_QButton",SwigQButtonToQPaintDevice);
	 SWIG_RegisterMapping("_class_QPaintDevice","_QButton",SwigQButtonToQPaintDevice);
	 SWIG_RegisterMapping("_class_QPaintDevice","_class_QWidget",SwigQWidgetToQPaintDevice);
	 SWIG_RegisterMapping("_class_QPaintDevice","_QWidget",SwigQWidgetToQPaintDevice);
	 SWIG_RegisterMapping("_class_QPaintDevice","_QPaintDevice",0);
	 SWIG_RegisterMapping("_short","_unsigned_short",0);
	 SWIG_RegisterMapping("_short","_signed_short",0);
	 SWIG_RegisterMapping("_int","_unsigned_int",0);
	 SWIG_RegisterMapping("_int","_signed_int",0);
	 SWIG_RegisterMapping("_class_QWidget","_class_QPushButton",SwigQPushButtonToQWidget);
	 SWIG_RegisterMapping("_class_QWidget","_QPushButton",SwigQPushButtonToQWidget);
	 SWIG_RegisterMapping("_class_QWidget","_class_QButton",SwigQButtonToQWidget);
	 SWIG_RegisterMapping("_class_QWidget","_QButton",SwigQButtonToQWidget);
	 SWIG_RegisterMapping("_class_QWidget","_QWidget",0);
}