/***************************************************************************
                          JavaSlot.h  -  description
                             -------------------
    begin                : Tue Oct 31 2000
    copyright            : (C) 2000 by Richard Dale
    email                : Richard_Dale@tipitina.demon.co.uk
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <stdio.h>

#include <qmetaobject.h>

#include "JavaSlot.moc"
#include <qtjava/QtSupport.h>

/*
 Converts a Java type signature, from a signal or slot, to the corresponding C++ Qt type.
 Used to connect a Java slot to a signal emitted by the underlying C++ Qt instance.
 Note that all Java slots and signals are of type jobjectArray, and so no conversion is needed for them.
*/
static const char * const javaToQtTypeSignatureMap[][2] = {
	{"()",														"()"},
	{"(boolean)",												"(bool)"},
	{"(byte)",													"(unsigned char)"},
	{"(char)",													"(const QChar)"},
	{"(short)",													"(short)"},
	{"(int)",													"(int)"},
	{"(long)",													"(long)"},
	{"(float)",													"(float)"},
	{"(double)",												"(double)"},
	{"(int)",													"(BarPosition)"},
	{"(int)",													"(Orientation)"},
	{"(QAction)",												"(QAction*)"},
	{"(Calendar)",												"(QDate)"},
	{"(QDockWindow)",											"(QDockWindow*)"},
	{"(int)",													"(QDockWindow::Place)"},
	{"(QDropEvent)",											"(QDropEvent*)"},
	{"(QDropEvent,QListViewItem)",								"(QDropEvent*,QListViewItem*)"},
	{"(QDropEvent,QListViewItem,ArrayList)",					"(QDropEvent*,QListViewItem*,QIconDragItemList*)"},
	{"(QDropEvent,ArrayList)",									"(QDropEvent*,const QValueList<QIconDragItem>&)"},
	{"(QIconViewItem)",											"(QIconViewItem*)"},
	{"(QIconViewItem,QPoint)",									"(QIconViewItem*,const QPoint&)"},
	{"(QIconViewItem,QPoint)",									"(QIconViewItem*,const QPoint)"},
	{"(QIconViewItem,String)",									"(QIconViewItem*,const QString)"},
	{"(QListViewItemList)",										"(QList<QListViewItem>)"},
	{"(QListViewItemList,QListViewItemList)",					"(QList<QListViewItem>,QList<QListViewItem>)"},
	{"(QListViewItemList,QListViewItemList,QListViewItemList)",	"(QList<QListViewItem>,QList<QListViewItem>,QList<QListViewItem>)"},
	{"(QListBoxItem)",											"(QListBoxItem*)"},
	{"(QListBoxItem,QPoint)",									"(QListBoxItem*,const QPoint)"},
	{"(QListViewItem)",											"(QListViewItem*)"},
	{"(QListViewItem,QListViewItem)",							"(QListViewItem*,QListViewItem*)"},
	{"(QListViewItem,QListViewItem,QListViewItem)",				"(QListViewItem*,QListViewItem*,QListViewItem*)"},
	{"(QListViewItem,QPoint)",									"(QListViewItem*,const QPoint&)"},
	{"(QListViewItem,QPoint,int)",								"(QListViewItem*,const QPoint&,int)"},
	{"(QListViewItem,QPoint,int)",								"(QListViewItem*,const QPoint,int)"},
	{"(QListViewItem,String,int)",								"(QListViewItem*,const QString,int)"},
	{"(QNetworkOperation)",										"(QNetworkOperation*)"},
	{"(QObject)",												"(QObject*)"},
	{"(int)",													"(QSql::Op)"},
	{"(int)",													"(QSqlCursor::Mode)"},
	{"(QSqlRecord)",											"(QSqlRecord*)"},
	{"(QToolBar)",												"(QToolBar*)"},
	{"(byte[])",												"(QByteArray&)"},
	{"(byte[],QNetworkOperation)",								"(QByteArray&,QNetworkOperation*)"},
	{"(QWidget)",												"(QWidget*)"},
	{"(QColor)",												"(const QColor&)"},
	{"(Calendar)",												"(const QDate&)"},
	{"(Calendar)",												"(const QDateTime&)"},
	{"(QFont)",													"(const QFont&)"},
	{"(QRect)",													"(const QRect&)"},
	{"(QSize)",													"(const QSize&)"},
	{"(QSqlRecord)",											"(const QSqlRecord*)"},
	{"(ArrayList)",												"(const QStringList&)"},
	{"(String)",												"(const QString&)"},
	{"(String)",												"(const QString)"},
	{"(String,int)",											"(const QString&,int)"},
	{"(String,String)",											"(const QString&,const QString&)"},
	{"(String,QLibrary)",										"(const QString&,QLibrary*)"},
	{"(String,QPoint)",											"(const QString,const QPoint)"},
	{"(String,String)",											"(const QString,const QString)"},
	{"(Date)",													"(const QTime&)"},
	{"(QUrlInfo,QNetworkOperation)",							"(const QUrlInfo&,QNetworkOperation*)"},
	{"(ArrayList,QNetworkOperation)",							"(const QValueList<QUrlInfo>&,QNetworkOperation*)"},
	{"(QVariant)",												"(const QVariant&)"},
	{"(int,QIconViewItem)",										"(int,QIconViewItem*)"},
	{"(int,QIconViewItem,QPoint)",								"(int,QIconViewItem*,const QPoint&)"},
	{"(int,QListBoxItem)",										"(int,QListBoxItem*)"},
	{"(int,QListBoxItem,QPoint)",								"(int,QListBoxItem*,const QPoint&)"},
	{"(int,QListViewItem,QPoint,int)",							"(int,QListViewItem*,const QPoint,int)"},
	{"(int,QPoint)",											"(int,QPoint)"},
	{"(int,String)",											"(int,const QString&)"},
	{"(int,boolean)",											"(int,bool)"},
	{"(int,int)",												"(int,int)"},
	{"(int,int,QNetworkOperation)",								"(int,int,QNetworkOperation*)"},
	{"(int,int,int)",											"(int,int,int)"},
	{"(int,int,QPoint)",										"(int,int,const QPoint&)"},
	{"(int,int,int,QPoint)",									"(int,int,int,const QPoint)"}
};

JavaSlot::JavaSlot(JNIEnv * env, jobject receiver, jstring slot)
{
	jobject		javaInvocation;
	jmethodID	cid;
	jclass		invocationClass;

	invocationClass = env->FindClass("org/kde/qt/Invocation");
	if (invocationClass == NULL) {
		return;
	}

	cid = env->GetMethodID(invocationClass, "<init>", "(Ljava/lang/Object;Ljava/lang/String;)V");
	if (cid == NULL) {
		return;
	}

	javaInvocation = env->NewObject(invocationClass, cid, receiver, slot);
	invocation = env->NewGlobalRef(javaInvocation);
	env->DeleteLocalRef(invocationClass);
}

JavaSlot::~JavaSlot()
{
	JNIEnv *	env;
	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	env->DeleteGlobalRef(invocation);
}

JavaSlotFactory * JavaSlot::_factory = 0L;
	
void
JavaSlot::setJavaSlotFactory(JavaSlotFactory * factory)
{
	if (_factory != 0L) {
		delete _factory;
	}
	
	_factory = factory;
}

JavaSlot *
JavaSlot::createJavaSlot(JNIEnv * env, jobject receiver, jstring slot)
{
	return _factory->createJavaSlot(env, receiver, slot);
}

const char *
JavaSlot::javaToQtSignalName(JNIEnv * env, jstring signal, QMetaObject * smeta)
{
	char	signalName[200];
	char 	javaTypeSignature[200];
	char *	signalString = (char*) env->GetStringUTFChars(signal, (jboolean *) 0);
	
	if (	signalString[0] == '2'
			&& sscanf(signalString, "%[^(]%s", signalName, javaTypeSignature) == 2 )
	{
		env->ReleaseStringUTFChars(signal, signalString);
		return javaToQtSignalType(signalName, javaTypeSignature, smeta);
	}
	
	env->ReleaseStringUTFChars(signal, signalString);
	return "";
}


const char *
JavaSlot::javaToQtSignalType(const char * signalName, const char * javaTypeSignature, QMetaObject * smeta)
{
static char qtSignalString[200];

	for (	unsigned int index = 0;
			index < sizeof(javaToQtTypeSignatureMap)/sizeof(*javaToQtTypeSignatureMap);
			index++ )
	{
		if (strcmp(javaTypeSignature, javaToQtTypeSignatureMap[index][0]) == 0) {
			(void) sprintf(qtSignalString, "%s%s", signalName, javaToQtTypeSignatureMap[index][1]);

			if (smeta == 0 || smeta->findSignal(((const char *) qtSignalString + 1), TRUE) >= 0) {
				return qtSignalString;
			}
		}
	}

	return "";
}

const char *
JavaSlot::javaToQtSlotName(JNIEnv * env, jstring slot, const char * signalString)
{
static char qtSlotString[200];
	char 	javaTypeSignature[200];
	char *	slotString = (char*) env->GetStringUTFChars(slot, (jboolean *) 0);

	if (sscanf(slotString, "%*[^(]%s", javaTypeSignature) == 1) {
		env->ReleaseStringUTFChars(slot, slotString);
		(void) sprintf(qtSlotString, "1invoke%s", javaToQtSlotType(javaTypeSignature, signalString));
		return qtSlotString;
	}

	(void) sprintf(qtSlotString, "1invoke%s", slotString);
	env->ReleaseStringUTFChars(slot, slotString);
	return qtSlotString;
}

const char *
JavaSlot::javaToQtSlotType(const char * javaTypeSignature, const char * signalString)
{
	for (	unsigned int index = 0;
			index < sizeof(javaToQtTypeSignatureMap)/sizeof(*javaToQtTypeSignatureMap);
			index++ )
	{
		if (	strcmp(javaTypeSignature, javaToQtTypeSignatureMap[index][0]) == 0
				&& (	signalString == 0
						|| QObject::checkConnectArgs(signalString, (const QObject *) 0, javaToQtTypeSignatureMap[index][1]) ) )
		{
			return javaToQtTypeSignatureMap[index][1];
		}
	}
	
	// If no matching C++ type signature is found, then just return the java one
	return javaTypeSignature;
}

void JavaSlot::invoke()
{
	invoke((jobjectArray) 0);
}

void
JavaSlot::invoke(bool arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Z)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(unsigned char arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(B)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(char arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(C)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(short arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(S)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(long arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(J)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(float arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(F)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(double arg)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(D)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, arg);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(jobjectArray args)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;
	
	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "([Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, args);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(Orientation arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QAction * arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QAction"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QDockWindow * arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QDockWindow"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QDockWindow::Place arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QDropEvent* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QDropEvent"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QDropEvent* arg1,QListViewItem*arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QDropEvent"),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QListViewItem") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QDropEvent*arg1,QListViewItem*arg2,QListViewItem*arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QDropEvent"),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QListViewItem"),
									QtSupport::objectForQtKey(env, (void *) arg3, "org.kde.qt.QListViewItem") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QDropEvent* arg1,const QValueList<QIconDragItem>& arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QDropEvent"),
									QtSupport::arrayWithQIconDragItemList(env, (QValueList<QIconDragItem> *) &arg2) );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QIconViewItem* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QIconViewItem"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QIconViewItem* arg1,const QPoint& arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QIconViewItem"),
									QtSupport::objectForQtKey(env, (void *) &arg2, "org.kde.qt.QPoint") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QIconViewItem* arg1,const QString arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QIconViewItem"),
									QtSupport::fromQString(env, (QString *) &arg2) );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QList<QListViewItem> arg1,QList<QListViewItem> arg2,QList<QListViewItem> arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QList"),
									QtSupport::objectForQtKey(env, (void *) &arg2, "org.kde.qt.QList"),
									QtSupport::objectForQtKey(env, (void *) &arg3, "org.kde.qt.QList") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListBoxItem* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListBoxItem"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListBoxItem* arg1,const QPoint arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListBoxItem"),
									QtSupport::objectForQtKey(env, (void *) &arg2, "org.kde.qt.QPoint") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListViewItem*arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListViewItem"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListViewItem* arg1, int arg2, const QString arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation,
									mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListViewItem"),
									(jint) arg2,
									QtSupport::fromQString(env, (QString *) &arg3) );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListViewItem* arg1,QListViewItem*arg2,QListViewItem*arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListViewItem"),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QListViewItem"),
									QtSupport::objectForQtKey(env, (void *) arg3, "org.kde.qt.QListViewItem") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListViewItem* arg1,const QPoint& arg2,int arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListBoxItem"),
									QtSupport::objectForQtKey(env, (void *) &arg2, "org.kde.qt.QPoint"),
									(jint) arg3 );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListViewItem* arg1,const QString arg2,int arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListViewItem"),
									QtSupport::fromQString(env, (QString *) &arg2),
									(jint) arg3 );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QListViewItem* arg1,int arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QListViewItem"),
									(jint) arg1 );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QNetworkOperation* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QNetworkOperation") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QObject* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QObject") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QSql::Op arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QSqlCursor::Mode arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QSqlRecord* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QSqlRecord") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QToolBar* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QToolBar"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(QWidget* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QWidget"));
	env->PopLocalFrame(0);
}


void
JavaSlot::invoke(const QByteArray& arg1,QNetworkOperation* arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "([BLjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::fromQByteArray(env, (QByteArray *) &arg1),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QNetworkOperation") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QColor& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QColor"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QDate& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::fromQDate(env, (QDate *) &arg1));
	env->PopLocalFrame(0);
}
	
void
JavaSlot::invoke(const QDateTime& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::fromQDateTime(env, (QDateTime *) &arg1));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QFont& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QFont"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QRect& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QRect"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QSize& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QSize"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QSqlRecord* arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) arg1, "org.kde.qt.QSqlRecord"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QString& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	
	result = env->CallObjectMethod(	invocation, mid, QtSupport::fromQString(env, (QString *) &arg1));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QString& arg1,QLibrary* arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::fromQString(env, (QString *) &arg1),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QLibrary") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QStringList& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::arrayWithQStringList(env, (QStringList *) &arg1));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QTime& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QTime"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QUrlInfo& arg1,QNetworkOperation* arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QUrlInfo"),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QNetworkOperation") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QValueList<QUrlInfo>& arg1,QNetworkOperation* arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::arrayWithQUrlInfoList(env, (QValueList<QUrlInfo> *) &arg1),
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QNetworkOperation") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QVariant& arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::objectForQtKey(env, (void *) &arg1, "org.kde.qt.QVariant"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QChar arg1)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(C)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, QtSupport::fromQChar(env, (QChar *) &arg1));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QString& arg1,int arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::fromQString(env, (QString *) &arg1),
									(jint) arg2 );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(const QString& arg1,const QString& arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									QtSupport::fromQString(env, (QString *) &arg1),
									QtSupport::fromQString(env, (QString *) &arg2) );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,QIconViewItem* arg2,const QPoint& arg3)
{

	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									(jint) arg1,
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QIconViewItem"),
									QtSupport::objectForQtKey(env, (void *) &arg3, "org.kde.qt.QPoint") );

	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,QListBoxItem* arg2,const QPoint arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									(jint) arg1,
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QListBoxItem"),
									QtSupport::objectForQtKey(env, (void *) &arg3, "org.kde.qt.QPoint") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,QListViewItem* arg2,const QPoint arg3,int arg4)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(ILjava/lang/Object;Ljava/lang/Object;I)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									(jint) arg1,
									QtSupport::objectForQtKey(env, (void *) arg2, "org.kde.qt.QListBoxItem"),
									QtSupport::objectForQtKey(env, (void *) &arg3, "org.kde.qt.QPoint"),
									(jint) arg4 );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,QPoint arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(ILjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									(jint) arg1,
									QtSupport::objectForQtKey(env, (void *) &arg2, "org.kde.qt.QPoint") );
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,bool arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(IZ)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1, (jboolean) arg2);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,int arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(II)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1, (jint) arg2);
	env->PopLocalFrame(0);
}
	
void
JavaSlot::invoke(int arg1,int arg2,QNetworkOperation* arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(IILjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation,
									mid,
									arg1,
									arg2,
									QtSupport::objectForQtKey(env, (void *) arg3, "org.kde.qt.QNetworkOperation") );
	env->PopLocalFrame(0);
}
	
void
JavaSlot::invoke(int arg1,int arg2,const QPoint& arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(IILjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation,
									mid,
									arg1,
									arg2,
									QtSupport::objectForQtKey(env, (void *) &arg3, "org.kde.qt.QPoint") );
	env->PopLocalFrame(0);
}


void
JavaSlot::invoke(int arg1,int arg2,int arg3)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(III)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(invocation, mid, (jint) arg1, (jint) arg2, (jint) arg3);
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1,int arg2,int arg3,const QPoint arg4)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(IIILjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									(jint) arg1,
									(jint) arg2,
									(jint) arg3,
									QtSupport::objectForQtKey(env, (void *) &arg4, "org.kde.qt.QPoint"));
	env->PopLocalFrame(0);
}

void
JavaSlot::invoke(int arg1, const QString& arg2)
{
	JNIEnv *	env;
	jclass		cls;
	jmethodID	mid;
	jobject		result;

	env = QtSupport::GetEnv();
	env->PushLocalFrame(10);

	cls = env->GetObjectClass(invocation);
	mid = env->GetMethodID(cls, "invoke", "(ILjava/lang/Object;)Ljava/lang/Object;");
	if (mid == NULL) {
		return;
	}
	result = env->CallObjectMethod(	invocation, mid,
									(jint) arg1,
									QtSupport::fromQString(env, (QString *) &arg2) );
	env->PopLocalFrame(0);
}

JavaSlotFactory::JavaSlotFactory()
{
}

JavaSlot *
JavaSlotFactory::createJavaSlot(JNIEnv * env, jobject receiver, jstring slot)
{
	return new JavaSlot(env, receiver, slot);
}

JavaSignal::JavaSignal()
{
}

JavaSignal::~JavaSignal()
{
}

void
JavaSignal::emitArgs(jobjectArray args)
{
	emit signalJava(args);
}


