[cairo-commit] cairo-java/src/jni org_freedesktop_cairo_Cairo.c, 1.6, 1.7

Jeffrey Morgan commit at pdx.freedesktop.org
Thu Mar 10 11:04:19 PST 2005


Committed by: kuzman

Update of /cvs/cairo/cairo-java/src/jni
In directory gabe:/tmp/cvs-serv7847/src/jni

Modified Files:
	org_freedesktop_cairo_Cairo.c 
Log Message:
current path work

Index: org_freedesktop_cairo_Cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Cairo.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- org_freedesktop_cairo_Cairo.c	10 Mar 2005 14:50:34 -0000	1.6
+++ org_freedesktop_cairo_Cairo.c	10 Mar 2005 19:04:14 -0000	1.7
@@ -1161,62 +1161,27 @@
   jmethodID close_path;
 } CairoCallback;
 
-CairoCallback* callback_data(JNIEnv *env, jobject cb)
+CairoCallback* callback_data(JNIEnv *env, jclass cls, jobject cb)
 {
   	jthrowable exc;
   	jclass Exception;
   	CairoCallback *cbdata;
-  	jclass currentPath;
   	
-  	currentPath = (*env)->FindClass(env, "org/freedesktop/cairo/CurrentPath");
-
 	cbdata = g_new(CairoCallback, 1);
+	cbdata->env = env;
 	cbdata->obj = (*env)->NewGlobalRef(env, cb);
 
 	cbdata->move_to = 
-		(*env)->GetMethodID(env, currentPath, "moveTo", "(DD)V");
-	exc = (*env)->ExceptionOccurred(env);
-	if (exc) {
-		g_warning("cairo-java - cannot find callback method moveTo\n");
-		(*env)->ExceptionClear(env);
-		Exception = (* env)->FindClass(env, "java/lang/RuntimeException");
-		(* env)->ThrowNew(env, Exception, "" );
-		return NULL;
-	}
+		(*env)->GetMethodID(env, cls, "move_to", "(DD)V");
 
 	cbdata->line_to = 
-		(*env)->GetMethodID(env, currentPath, "lineTo", "(DD)V");
-	exc = (*env)->ExceptionOccurred(env);
-	if (exc) {
-		g_warning("cairo-java - cannot find callback method lineTo\n");
-		(*env)->ExceptionClear(env);
-		Exception = (* env)->FindClass(env, "java/lang/RuntimeException");
-		(* env)->ThrowNew(env, Exception, "" );
-		return NULL;
-	}
+		(*env)->GetMethodID(env, cls, "line_to", "(DD)V");
 
 	cbdata->curve_to = 
-		(*env)->GetMethodID(env, currentPath, "curveTo", "(DDDDDD)V");
-	if (exc) {
-		g_warning("cairo-java - cannot find callback method curveTo\n");
-		(*env)->ExceptionClear(env);
-		Exception = (* env)->FindClass(env, "java/lang/RuntimeException");
-		(* env)->ThrowNew(env, Exception, "" );
-		return NULL;
-	}
+		(*env)->GetMethodID(env, cls, "curve_to", "(DDDDDD)V");
 
 	cbdata->close_path = 
-		(*env)->GetMethodID(env, currentPath, "closePath", "()V");
-	exc = (*env)->ExceptionOccurred(env);
-	if (exc) {
-		g_warning("cairo-java - cannot find callback method closePath\n");
-		(*env)->ExceptionClear(env);
-		Exception = (* env)->FindClass(env, "java/lang/RuntimeException");
-		(* env)->ThrowNew(env, Exception, "" );
-		return NULL;
-	}
-
-	cbdata->env = env;
+		(*env)->GetMethodID(env, cls, "close_path", "()V");
 }
 
 void move_to_callback(void *data, double x, double y)
@@ -1302,7 +1267,7 @@
   (JNIEnv *env, jclass cls, jobject obj, jobject cb)
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	CairoCallback *cbdata = callback_data(env, cb);
+	CairoCallback *cbdata = callback_data(env, cls, cb);
 	cairo_current_path(cr, move_to_callback, line_to_callback,
 			curve_to_callback, close_path_callback, cbdata);	
 }
@@ -1316,7 +1281,7 @@
   (JNIEnv *env, jclass cls, jobject obj, jobject cb)
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	CairoCallback *cbdata = callback_data(env, cb);
+	CairoCallback *cbdata = callback_data(env, cls, cb);
 	printf("path_flat\n");
 	cairo_current_path_flat(cr, move_to_callback, line_to_callback,
 			close_path_callback, cbdata);




More information about the cairo-commit mailing list