[cairo-commit] cairo-java/src/jni org_freedesktop_cairo_Cairo.c, 1.4, 1.5

Jeffrey Morgan commit at pdx.freedesktop.org
Tue Mar 8 16:58:38 PST 2005


Committed by: kuzman

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

Modified Files:
	org_freedesktop_cairo_Cairo.c 
Log Message:
still working on the current_path callbacks

Index: org_freedesktop_cairo_Cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Cairo.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- org_freedesktop_cairo_Cairo.c	8 Mar 2005 21:31:59 -0000	1.4
+++ org_freedesktop_cairo_Cairo.c	9 Mar 2005 00:58:36 -0000	1.5
@@ -1166,14 +1166,15 @@
   	jthrowable exc;
   	jclass Exception;
   	CairoCallback *cbdata;
+  	jclass currentPath;
+  	
+  	currentPath = (*env)->FindClass(env, "org/freedesktop/cairo/CurrentPath");
 
 	cbdata = g_new(CairoCallback, 1);
-	/* add the target object to the struct */
 	cbdata->obj = (*env)->NewGlobalRef(env, cb);
 
 	cbdata->move_to = 
-		(*env)->GetMethodID(env, (*env)->GetObjectClass(env, cb), 
-				"moveTo", "(DD)V");
+		(*env)->GetMethodID(env, currentPath, "moveTo", "(DD)V");
 	exc = (*env)->ExceptionOccurred(env);
 	if (exc) {
 		g_warning("cairo-java - cannot find callback method moveTo\n");
@@ -1184,8 +1185,7 @@
 	}
 
 	cbdata->line_to = 
-		(*env)->GetMethodID(env, (*env)->GetObjectClass(env, cb), 
-				"lineTo", "(DD)V");
+		(*env)->GetMethodID(env, currentPath, "lineTo", "(DD)V");
 	exc = (*env)->ExceptionOccurred(env);
 	if (exc) {
 		g_warning("cairo-java - cannot find callback method lineTo\n");
@@ -1196,9 +1196,7 @@
 	}
 
 	cbdata->curve_to = 
-		(*env)->GetMethodID(env, (*env)->GetObjectClass(env, cb), 
-				"curveTo", "(DDDDDD)V");
-	exc = (*env)->ExceptionOccurred(env);
+		(*env)->GetMethodID(env, currentPath, "curveTo", "(DDDDDD)V");
 	if (exc) {
 		g_warning("cairo-java - cannot find callback method curveTo\n");
 		(*env)->ExceptionClear(env);
@@ -1208,8 +1206,7 @@
 	}
 
 	cbdata->close_path = 
-		(*env)->GetMethodID(env, (*env)->GetObjectClass(env, cb), 
-				"closePath", "()V");
+		(*env)->GetMethodID(env, currentPath, "closePath", "()V");
 	exc = (*env)->ExceptionOccurred(env);
 	if (exc) {
 		g_warning("cairo-java - cannot find callback method closePath\n");
@@ -1219,25 +1216,21 @@
 		return NULL;
 	}
 
-	/* add the env to the struct */
 	cbdata->env = env;
 }
 
-void
-move_to_callback(void *data, double x, double y)
+void move_to_callback(void *data, double x, double y)
 {
-	jvalue *jargs;
 	CairoCallback* cbdata = data;
 	jthrowable exc;
-	
-	jargs = alloca(2 * sizeof(jvalue));
-	jargs[0].d = x;
-	jargs[1].d = y;
-	
-	(*cbdata->env)->CallVoidMethodA(cbdata->env, 
+
+	printf("in move_to\n");	
+	printf("calling method\n");
+	(*cbdata->env)->CallVoidMethod(cbdata->env, 
 				       cbdata->obj, 
-				       cbdata->move_to, 
-				       jargs);
+				       cbdata->move_to,
+				       x, y); 
+	printf("called method\n");
 	if (exc) {
 		/* Print stack trace */
 		(* cbdata->env)->ExceptionDescribe(cbdata->env);
@@ -1246,21 +1239,16 @@
 	}
 }
 
-void
-line_to_callback(void *data, double x, double y)
+void line_to_callback(void *data, double x, double y)
 {
-	jvalue *jargs;
 	CairoCallback* cbdata = data;
 	jthrowable exc;
 	
-	jargs = alloca(2 * sizeof(jvalue));
-	jargs[0].d = x;
-	jargs[1].d = y;
-	
-	(*cbdata->env)->CallVoidMethodA(cbdata->env, 
+	(*cbdata->env)->CallVoidMethod(cbdata->env, 
 				       cbdata->obj, 
 				       cbdata->line_to, 
-				       jargs);
+				       x, y);
+
 	if (exc) {
 		/* Print stack trace */
 		(* cbdata->env)->ExceptionDescribe(cbdata->env);
@@ -1269,26 +1257,16 @@
 	}
 }
 
-void
-curve_to_callback(void *data, double x1, double y1, double x2, double y2,
+void curve_to_callback(void *data, double x1, double y1, double x2, double y2,
 		double x3, double y3)
 {
-	jvalue *jargs;
 	CairoCallback* cbdata = data;
 	jthrowable exc;
 	
-	jargs = alloca(6 * sizeof(jvalue));
-	jargs[0].d = x1;
-	jargs[1].d = y1;
-	jargs[2].d = x2;
-	jargs[3].d = y2;
-	jargs[4].d = x3;
-	jargs[5].d = y3;
-	
-	(*cbdata->env)->CallVoidMethodA(cbdata->env, 
+	(*cbdata->env)->CallVoidMethod(cbdata->env, 
 				       cbdata->obj, 
 				       cbdata->curve_to, 
-				       jargs);
+				       x1, y1, x2, y2, x3, y3);
 	if (exc) {
 		/* Print stack trace */
 		(* cbdata->env)->ExceptionDescribe(cbdata->env);
@@ -1297,8 +1275,7 @@
 	}
 }
 
-void
-close_path_callback(void *data)
+void close_path_callback(void *data)
 {
 	CairoCallback* cbdata = data;
 	jthrowable exc;
@@ -1340,8 +1317,10 @@
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
 	CairoCallback *cbdata = callback_data(env, cb);
+	printf("path_flat\n");
 	cairo_current_path_flat(cr, move_to_callback, line_to_callback,
-			close_path_callback, cbdata);	
+			close_path_callback, cbdata);
+	printf("return\n");	
 }
 
 #ifdef __cplusplus




More information about the cairo-commit mailing list