Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

src/jni/jvr.h

Go to the documentation of this file.
00001 /*
00002  * $Id: jvr.h,v 1.35 2005/06/11 21:13:14 kevino Exp $
00003  *
00004  * Copyright (c) 2003,2004 Kevin O'Donnell
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307,  USA.
00019  */
00020 
00021 static JavaVMAttachArgs attachArgs = { JNI_VERSION_1_2, NULL, NULL} ;
00022 
00023 // Use this macro as the boolean control in if() statements
00024 // when logging optional debugging information.  For example:
00025 //
00026 // if (JVR_DEBUG(JVR_INFO)) { /* logging info here */ }
00027 // becomes
00028 // if (1 <= jvr_getdebuglevel()) { /* logging ... */ }
00029 //
00030 #define JVR_NONE      0
00031 #define JVR_INFO      1
00032 #define JVR_WARNING   2
00033 #define JVR_ERROR     3
00034 #define JVR_ALL       99
00035 #define JVR_DEBUG(level) level <= jvr_getdebuglevel()
00036 // Convenience for jvr_log() arguments
00037 #define JVR_LOG e,__FILE__,__LINE__
00038 // ENTER function macro.
00039 #define JVR_ENTER JVR_EELOG("ENTER")
00040 #define JVR_EXIT  JVR_EELOG("EXIT ")
00041 #define JVR_EELOG(JVR_EE) do \
00042   { \
00043     if (JVR_DEBUG(JVR_ALL)) { \
00044       time_t now; \
00045       struct tm *t; \
00046       struct timeb tp; \
00047       char timebuf[1024]; \
00048       time(&now); \
00049       t = localtime(&now); \
00050       ftime(&tp); \
00051       strftime(timebuf,1000,"%Y.%m.%d %H:%M:%S",t); \
00052       jvr_log(JVR_LOG,"%s.%hd %s %s",timebuf,tp.millitm,JVR_EE,__PRETTY_FUNCTION__); \
00053     } \
00054   } while(0)
00055 #define JVR_LOG e,__FILE__,__LINE__
00056 
00057 // The default length of DV_TPT pointer arrays when passing
00058 // between callers and the convertion functions.
00059 #define JVR_DVTPT_MAXSIZE 10
00060 
00061 // The default maximum length of contiguous DX_IOTT structures
00062 #define JVR_DXIOTT_MAXSIZE 10
00063 
00064 // Maximum number of MS_CDT elements
00065 #define JVR_MSCDT_MAXSIZE 10
00066 
00067 /*
00068  * Get the one and only JVM instance.
00069  */
00070 JavaVM* jvr_getVM();
00071 
00072 /*
00073  * Throw a JNI exception.
00074  *
00075  * e   : Java Environment
00076  * file: The file in which the exception is being thrown.
00077  * line: The line number where the call to jvr_throw is located.
00078  * ... : See printf() family of functions.
00079  *
00080  * Note: use JVR_MARK macro to end up with __FILE__,__LINE__ for the first
00081  *       to arguments.
00082  *
00083  */
00084 void jvr_throw (JNIEnv *e, const char* exceptionClass, const char* file, int line, const char* format, ...);
00085 
00086 /**
00087  *
00088  */
00089 void jvr_log (JNIEnv *e, const char* file, int line, const char* format, ...);
00090 
00091 /**
00092  * Convert net.threebit.jvr.SC_TSINFO to the SC_TSINFO struct.
00093  * Return 0 on success, -1 on error (an exception will already have been thrown)
00094  */
00095 int jvr_convert_sctsinfo_j2n(JNIEnv *e, jobject jtsinfo, SC_TSINFO *tsinfo);
00096 /**
00097  * Convert from SC_TSINFO struct to net.threebit.jvr.SC_TSINFO;
00098  */
00099 int jvr_convert_sctsinfo_n2j(JNIEnv *e, jobject jtsinfo, SC_TSINFO *tsinfo);
00100 
00101 /**
00102  * Convert from net.threebit.jvr.DX_CAP to DX_CAP struct.
00103  */
00104 int jvr_convert_dxcap_j2n (JNIEnv *e, jobject jdxcap, DX_CAP *dxcap);
00105 
00106 /**
00107  * Convert from net.threebit.jvr.DX_CAP to DX_CAP struct.
00108  */
00109 int jvr_convert_tngen_n2j (JNIEnv *e, jobject jtngen, TN_GEN *tngen);
00110 
00111 /**
00112  * Convert from DV_TPT object to struct.
00113  *
00114  * The caller must guarantee that the size of (DV_TPT*) is at
00115  * least JVR_MAX_DVTPT.
00116  */
00117 int jvr_convert_dvtpt_j2n (JNIEnv *e, jobjectArray jtpt, DV_TPT *tpt);
00118 
00119 /**
00120  *
00121  */
00122 int jvr_convert_tngen_j2n (JNIEnv *e, jobject jtngen, TN_GEN *tngen);
00123 
00124 /**
00125  *
00126  */
00127 int jvr_convert_tngencad_j2n(JNIEnv *e, jobject jtngencad, TN_GENCAD *tngencad);
00128 
00129 /**
00130  *
00131  */
00132 int jvr_convert_dxxpb_j2n (JNIEnv *e, jobject jxpb, DX_XPB *xpb);
00133 
00134 // Number of native-context DX_IOTT structs available for allocation
00135 #define JVR_IOTT_SIZE 500
00136 
00137 /**
00138  *
00139  */
00140 int jvr_convert_dxiott_j2n(JNIEnv *e, jobjectArray jiott, DX_IOTT **iottp);
00141 
00142 /**
00143  *
00144  */
00145 int jvr_convert_mscdtarray_j2n (JNIEnv *e, jobjectArray jmscdt, MS_CDT *cdt, int *numParties);
00146 
00147 /**
00148  *
00149  */
00150 int jvr_convert_mscdtarray_n2j (JNIEnv *e, jobjectArray jmscdt, MS_CDT *cdt, int numParties);
00151 
00152 /**
00153  *
00154  */
00155 int jvr_convert_mscdt_j2n (JNIEnv *e, jobject jmscdt, MS_CDT *cdt);
00156 
00157 /**
00158  *
00159  */
00160 int jvr_convert_mscdt_n2j (JNIEnv *e, jobject jmscdt, MS_CDT *cdt);
00161 
00162 /**
00163  *
00164  */
00165 int jvr_convert_metaevent_n2j (JNIEnv *e, jobject jmeta, METAEVENT *meta);
00166 
00167 /**
00168  *
00169  */
00170 jobject jvr_convert_evtdatap_n2j (JNIEnv *e, long type, long len, void *datap, METAEVENT *meta);
00171 
00172 /**
00173  *
00174  */
00175 int jvr_convert_gcinfo_n2j (JNIEnv *e, jobject jgcinfo, GC_INFO *gcinfo);
00176 
00177 /**
00178  *
00179  */
00180 int jvr_convert_ctdevinfo_n2j (JNIEnv *e, jobject jdevinfo, CT_DEVINFO *devinfo);
00181 
00182 /**
00183  *
00184  */
00185 int jvr_convert_gccallackblk_j2n (JNIEnv *e, jobject jcallack, GC_CALLACK_BLK *callack);
00186 
00187 /**
00188  *
00189  */
00190 int jvr_convert_ieblk_j2n (JNIEnv *e, jobject jieblk, IE_BLK *ieblk);
00191 
00192 /**
00193  *
00194  */
00195 void jvr_setdebuglevel (int level);
00196 
00197 /**
00198  *
00199  */
00200 int jvr_getdebuglevel();
00201 
00202 /**
00203  *
00204  */
00205 int jvr_convert_gcparm_j2n (JNIEnv *e, jobject jgcparm, GC_PARM *gcparm);
00206 
00207 /**
00208  *
00209  */
00210 int jvr_convert_intValue (JNIEnv *e, jobject intObject);

Generated on Sat Jul 16 03:47:27 2005 for JVR by doxygen 1.3.5