QSwingUtilitiesBridge.h

00001 /*
00002  * @(#)QSwingUtilitiesBridge.h  0.2.0 / 2007-07-28
00003  *
00004  * Copyright (c) 2007, ETF and contributors. All rights reserved.
00005  *
00006  * This software is licensed under the LGPL, version 2.1, license.
00007  * A copy of the license is included in the file LICENSE-LGPL.txt.
00008  */
00009 #ifndef QSWINGUTILITIESBRIDGE_H
00010 #define QSWINGUTILITIESBRIDGE_H
00011 
00012 #include "JavaQxCore.h"
00013 
00014 /*^**************************************************************************^*/
00015 /*- QSwingUtilitiesBridge Class.                                             -*/
00016 /*^**************************************************************************^*/
00017 
00024 class JAVAQX_EXPORT QSwingUtilitiesBridge : public QObject
00025 {
00026   Q_OBJECT
00027 private:
00028   QSwingUtilitiesBridge();
00029   QSwingUtilitiesBridge(const QSwingUtilitiesBridge &);
00030   ~QSwingUtilitiesBridge();
00031 public: // native calls
00032   static void invokeLater(JNIEnv *env, jclass cls, jobject target);
00033   static void invokeAndWait(JNIEnv *env, jclass cls, jobject target);
00034   static void invokeSafeAndWait(JNIEnv *env, jclass cls, jobject safeTarget);
00035 public: // helper methods
00036   static void initialize(JNIEnv *env, jclass runnableClass, jclass iteClass);
00037   static jint invokeIntAndWait(JNIEnv *env, jobject obj, jmethodID mid, ...);
00038   static jlong invokeLongAndWait(JNIEnv *env, jobject obj, jmethodID mid, ...);
00039 private:
00040   struct TargetFrame {
00041     jobject target;
00042     jthrowable exception;
00043   };
00044   struct MethodFrame {
00045     jobject obj;
00046     jmethodID mid;
00047     va_list args;
00048   };
00049   struct IntMethodFrame : MethodFrame {
00050     jint result;
00051   };
00052   struct LongMethodFrame : MethodFrame {
00053     jlong result;
00054   };
00055 private:
00056   void invokeLater(jobject target);
00057   void invokeAndWait(TargetFrame *targetFrame);
00058   void invokeSafeAndWait(jobject safeTarget);
00059   void invokeIntAndWait(IntMethodFrame *methodFrame);
00060   void invokeLongAndWait(LongMethodFrame *methodFrame);
00061 private slots:
00062   void invokeLaterSlot(jobject target);
00063   void invokeAndWaitSlot(TargetFrame *targetFrame);
00064   void invokeIntAndWaitSlot(IntMethodFrame *methodFrame);
00065   void invokeLongAndWaitSlot(LongMethodFrame *methodFrame);
00066 signals:
00067   void invokeLaterSignal(jobject target);
00068   void invokeAndWaitSignal(TargetFrame *targetFrame);
00069   void invokeSafeAndWaitSignal(jobject safeTarget);
00070   void invokeIntAndWaitSignal(IntMethodFrame *methodFrame);
00071   void invokeLongAndWaitSignal(LongMethodFrame *methodFrame);
00072 private:
00073   static jmethodID sm_runMID;
00074   static jmethodID sm_iteConstructorMID;
00075   static QSwingUtilitiesBridge *qSwingUtilitiesBridge;
00076 };
00077 
00078 #endif //QSWINGUTILITIESBRIDGE_H
00079 
00080 /*^*****************************************************************************
00081   File History:
00082 
00083  - 2007-07-28 11:43:10 Slobodan
00084    Initial version
00085 
00086 *****************************************************************************^*/

Copyright © 2007 ETF and contributors. All Rights Reserved.