SciGUIConsole.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------------*/
00002 /* INRIA 2006 */
00003 /* Allan CORNET */
00004 /*-----------------------------------------------------------------------------------*/ 
00005 #include "SciGUIConsole.h"
00006 /*-----------------------------------------------------------------------------------*/ 
00007 static jobject SciGUIConsoleObject;
00008 /*-----------------------------------------------------------------------------------*/ 
00009 IMPORT_DLL JavaVM *Get_jvm_CONSOLE(void);
00010 /*-----------------------------------------------------------------------------------*/ 
00011 int PutString_SciGUIConsole(JNIEnv *env,char *Str);
00012 /*-----------------------------------------------------------------------------------*/ 
00013 IMPORT_EXPORT_SCIGUICONSOLE_DLL jobject Get_SciGUIConsole_Object(void)
00014 {
00015         return (jobject)SciGUIConsoleObject;
00016 }
00017 /*-----------------------------------------------------------------------------------*/ 
00018 IMPORT_EXPORT_SCIGUICONSOLE_DLL int JVM_Create_SciGUIConsole_Object(JNIEnv *env)
00019 {
00020         jclass cls=NULL;
00021         jmethodID mid=NULL;
00022         int bOK=FALSE;
00023 
00024         cls = (*env)->FindClass(env, "SciGUIConsole");
00025         if (cls)
00026         {
00027                 mid = (*env)->GetMethodID(env,cls,"<init>","()V");
00028                 if (mid)
00029                 {
00030                         SciGUIConsoleObject = (*env)->NewObject(env,cls,mid); 
00031                         if (SciGUIConsoleObject)
00032                         {
00033                                 bOK=TRUE;
00034                         }
00035                 }
00036         }
00037 
00038         return bOK;
00039 }
00040 /*-----------------------------------------------------------------------------------*/ 
00041 IMPORT_EXPORT_SCIGUICONSOLE_DLL int Initialize_SciGUIConsole_Object(JNIEnv *env)
00042 {
00043         int bOK=FALSE;
00044         jclass cls=NULL;
00045         jmethodID mid=NULL;
00046 
00047         cls = (*env)->FindClass(env, "SciGUIConsole");
00048         if (cls)
00049         {
00050                 mid = (*env)->GetMethodID(env, cls, "Initialize","()V");
00051                 if (mid)
00052                 {
00053                         (*env)->CallObjectMethod(env,(jobject)SciGUIConsoleObject, mid,NULL);
00054                         bOK=TRUE;
00055                 }
00056         }
00057         return bOK;
00058 }
00059 /*-----------------------------------------------------------------------------------*/ 
00060 IMPORT_EXPORT_SCIGUICONSOLE_DLL int Events_Loop_SciGUIConsole(JNIEnv *env)
00061 {
00062         int bOK=FALSE;
00063         jclass cls=NULL;
00064         jmethodID mid=NULL;
00065 
00066         cls = (*env)->FindClass(env, "SciGUIConsole");
00067         if (cls)
00068         {
00069                 mid = (*env)->GetMethodID(env, cls, "EventsLoop",  "()V");
00070                 if (mid)
00071                 {
00072                         (*env)->CallObjectMethod(env,(jobject)SciGUIConsoleObject, mid,NULL);
00073                         bOK=TRUE;
00074                 }
00075         }
00076         return bOK;
00077 }
00078 /*-----------------------------------------------------------------------------------*/ 
00079 int PutString_SciGUIConsole(JNIEnv *env,char *Str)
00080 {
00081         int bOK=FALSE;
00082         jclass cls=NULL;
00083         jmethodID mid=NULL;
00084         jstring jstr;
00085 
00086         cls = (*env)->FindClass(env, "SciGUIConsole");
00087         if (cls)
00088         {
00089                 mid = (*env)->GetMethodID(env, cls, "PutString",  "(Ljava/lang/String;)V");
00090                 if (mid)
00091                 {
00092                         jstr = (*env)->NewStringUTF(env, Str);
00093                         (*env)->CallObjectMethod(env,(jobject)SciGUIConsoleObject, mid,jstr );
00094                         bOK=TRUE;
00095                 }
00096         }
00097         return bOK;
00098 }
00099 /*-----------------------------------------------------------------------------------*/ 
00100 IMPORT_EXPORT_SCIGUICONSOLE_DLL int PutString(char *Str)
00101 {
00102         int bOK=FALSE;
00103         JavaVM *jvm_CONSOLE=NULL;
00104         JNIEnv *env=NULL;       
00105 
00106         jvm_CONSOLE=Get_jvm_CONSOLE();
00107         if (jvm_CONSOLE)
00108         {
00109                 (*jvm_CONSOLE)->GetEnv(jvm_CONSOLE, (void **)&env, JNI_VERSION_1_4);
00110                 if (env)
00111                 {
00112                         PutString_SciGUIConsole(env,Str);
00113                         bOK=TRUE;
00114                 }
00115         }
00116         return bOK;
00117 }
00118 /*-----------------------------------------------------------------------------------*/ 
00119 IMPORT_EXPORT_SCIGUICONSOLE_DLL int IsEnabled_SciGUIConsole(JNIEnv *env)
00120 {
00121         int bOK=FALSE;
00122         jclass cls=NULL;
00123         jmethodID mid=NULL;
00124 
00125         if (SciGUIConsoleObject)
00126         {
00127                 cls = (*env)->FindClass(env, "SciGUIConsole");
00128                 if (cls)
00129                 {
00130                         mid = (*env)->GetMethodID(env, cls, "IsEnabled",  "()Z");
00131                         if (mid)
00132                         {
00133                                 bOK=(*env)->CallBooleanMethod(env,SciGUIConsoleObject,mid);
00134                         }
00135                 }
00136         }
00137         return bOK;
00138 }
00139 /*-----------------------------------------------------------------------------------*/ 
00140 IMPORT_EXPORT_SCIGUICONSOLE_DLL int Dispose_SciGUIConsole(JNIEnv *env)
00141 {
00142         int bOK=FALSE;
00143         jclass cls=NULL;
00144         jmethodID mid=NULL;
00145 
00146         if (SciGUIConsoleObject)
00147         {
00148                 cls = (*env)->FindClass(env, "SciGUIConsole");
00149                 if (cls)
00150                 {
00151                         mid = (*env)->GetMethodID(env, cls, "dispose",  "()V");
00152                         if (mid)
00153                         {
00154                                 (*env)->CallVoidMethod(env,SciGUIConsoleObject,mid);
00155                                 bOK=TRUE;
00156                         }
00157                 }
00158         }
00159         return bOK;
00160 }
00161 /*-----------------------------------------------------------------------------------*/ 

Generated on Sun Mar 4 15:03:54 2007 for Scilab [trunk] by  doxygen 1.5.1