[cairo-commit] cairo-java/src/jni org_freedesktop_cairo_Matrix.c, 1.9, 1.10 org_freedesktop_cairo_Pattern.c, 1.9, 1.10

Dan Williams commit at pdx.freedesktop.org
Thu Mar 23 10:32:03 PST 2006


Committed by: dcbw

Update of /cvs/cairo/cairo-java/src/jni
In directory kemper:/tmp/cvs-serv22452/src/jni

Modified Files:
	org_freedesktop_cairo_Matrix.c org_freedesktop_cairo_Pattern.c 
Log Message:
2006-03-23  Dan Williams  <dcbw at redhat.com>

    * src/java/org/freedesktop/cairo/Matrix.java
        - Add Matrix() constructor
        - Add finalize() for Matrix objects
        - Fix Matrix.multiply() to not crash

    * src/java/org/freedesktop/cairo/Pattern.java
        - Fix getMatrix() to not crash

    * src/jni/org_freedesktop_cairo_Matrix.c
        - Fix JNI function Signatures
        - (new_identity_matrix): new function; return a new
            allocated identity matrix
        - (free_matrix): new function; free memory associated with
            a matrix object
        - (cairo_matrix_multiply): allocate result matrix object, since
            cairo needs an allocated matrix, not NULL

    * src/jni/org_freedesktop_cairo_Pattern.c
        - (cairo_pattern_get_matrix): allocate result matrix object,
            since cairo needs an allocated matrix, not NULL



Index: org_freedesktop_cairo_Matrix.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Matrix.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- org_freedesktop_cairo_Matrix.c	28 Feb 2006 17:51:37 -0000	1.9
+++ org_freedesktop_cairo_Matrix.c	23 Mar 2006 18:32:01 -0000	1.10
@@ -7,6 +7,7 @@
  * the terms of the GNU Library General Public License version 2.
  */
 
+#include <stdlib.h>
 #include <jni.h>
 #include <cairo.h>
 #include <jg_jnu.h>
@@ -21,7 +22,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    getXX
- * Signature: (Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)D
  */
 JNIEXPORT jdouble JNICALL Java_org_freedesktop_cairo_Matrix_getXX
   (JNIEnv *env, jclass cls, jobject obj)
@@ -35,7 +36,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    getYX
- * Signature: (Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)D
  */
 JNIEXPORT jdouble JNICALL Java_org_freedesktop_cairo_Matrix_getYX
   (JNIEnv *env, jclass cls, jobject obj)
@@ -49,7 +50,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    getXY
- * Signature: (Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)D
  */
 JNIEXPORT jdouble JNICALL Java_org_freedesktop_cairo_Matrix_getXY
   (JNIEnv *env, jclass cls, jobject obj)
@@ -63,7 +64,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    getYY
- * Signature: (Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)D
  */
 JNIEXPORT jdouble JNICALL Java_org_freedesktop_cairo_Matrix_getYY
   (JNIEnv *env, jclass cls, jobject obj)
@@ -77,7 +78,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    getX0
- * Signature: (Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)D
  */
 JNIEXPORT jdouble JNICALL Java_org_freedesktop_cairo_Matrix_getX0
   (JNIEnv *env, jclass cls, jobject obj)
@@ -91,7 +92,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    getY0
- * Signature: (Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)D
  */
 JNIEXPORT jdouble JNICALL Java_org_freedesktop_cairo_Matrix_getY0
   (JNIEnv *env, jclass cls, jobject obj)
@@ -105,7 +106,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    setXX
- * Signature: (Lorg/gnu/glib/Handle;D)D
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_setXX
   (JNIEnv *env, jclass cls, jobject obj, jdouble value)
@@ -119,7 +120,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    setYX
- * Signature: (Lorg/gnu/glib/Handle;D)D
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_setYX
   (JNIEnv *env, jclass cls, jobject obj, jdouble value)
@@ -133,7 +134,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    setXY
- * Signature: (Lorg/gnu/glib/Handle;D)D
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_setXY
   (JNIEnv *env, jclass cls, jobject obj, jdouble value)
@@ -147,7 +148,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    setYY
- * Signature: (Lorg/gnu/glib/Handle;D)D
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_setYY
   (JNIEnv *env, jclass cls, jobject obj, jdouble value)
@@ -161,7 +162,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    setX0
- * Signature: (Lorg/gnu/glib/Handle;D)D
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_setX0
   (JNIEnv *env, jclass cls, jobject obj, jdouble value)
@@ -175,7 +176,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    setY0
- * Signature: (Lorg/gnu/glib/Handle;D)D
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_setY0
   (JNIEnv *env, jclass cls, jobject obj, jdouble value)
@@ -188,8 +189,34 @@
 
 /*
  * Class:     org_freedesktop_cairo_Matrix
+ * Method:    new_identity_matrix
+ * Signature: (V)Lorg/gnu/glib/Handle;
+ */
+JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_Matrix_new_1identity_1matrix
+  (JNIEnv *env, jclass cls)
+{
+	cairo_matrix_t *matrix = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_init_identity(matrix);
+	return getHandleFromPointer(env, matrix);
+}
+
+/*
+ * Class:     org_freedesktop_cairo_Matrix
+ * Method:    free_matrix
+ * Signature: (Lorg/gnu/glib/Handle;)V
+ */
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_free_1matrix
+  (JNIEnv *env, jclass cls, jobject obj)
+{
+	cairo_matrix_t *matrix;
+	matrix = (cairo_matrix_t*)getPointerFromHandle(env, obj);
+	free (matrix);
+}
+
+/*
+ * Class:     org_freedesktop_cairo_Matrix
  * Method:    cairo_matrix_init
- * Signature: (Lorg/gnu/javagnome/Handle;DDDDDD)V
+ * Signature: (Lorg/gnu/glib/Handle;DDDDDD)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1init
   (JNIEnv *env, jclass cls, jobject obj, jdouble xx, jdouble yx, 
@@ -204,7 +231,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    cairo_matrix_init_identity
- * Signature: (Lorg/gnu/javagnome/Handle;)V
+ * Signature: (Lorg/gnu/glib/Handle;)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1init_1identity
   (JNIEnv *env, jclass cls, jobject obj)
@@ -218,7 +245,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    cairo_matrix_init_translate
- * Signature: (Lorg/gnu/javagnome/Handle;DD)V
+ * Signature: (Lorg/gnu/glib/Handle;DD)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1init_1translate
   (JNIEnv *env, jclass cls, jobject obj, jdouble tx, jdouble ty)
@@ -232,7 +259,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    cairo_matrix_init_scale
- * Signature: (Lorg/gnu/javagnome/Handle;DD)V
+ * Signature: (Lorg/gnu/glib/Handle;DD)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1init_1scale
   (JNIEnv *env, jclass cls, jobject obj, jdouble sx, jdouble sy)
@@ -246,7 +273,7 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    cairo_matrix_init_rotate
- * Signature: (Lorg/gnu/javagnome/Handle;D)V
+ * Signature: (Lorg/gnu/glib/Handle;D)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1init_1rotate
   (JNIEnv *env, jclass cls, jobject obj, jdouble rad)
@@ -308,16 +335,17 @@
 /*
  * Class:     org_freedesktop_cairo_Matrix
  * Method:    cairo_matrix_multiply
- * Signature: (Lorg/gnu/glib/Handle;Lorg/gnu/glib/Handle;Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;Lorg/gnu/glib/Handle;Lorg/gnu/glib/Handle;)Lorg/gnu/glib/Handle;
  */
-JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1multiply
-  (JNIEnv *env, jclass cls, jobject dest, jobject one, jobject two)
+JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_Matrix_cairo_1matrix_1multiply
+  (JNIEnv *env, jclass cls, jobject one, jobject two)
 {
-	cairo_matrix_t *dest_g = (cairo_matrix_t*)getPointerFromHandle(env, dest);
+	cairo_matrix_t *result;
+	result = (cairo_matrix_t*) malloc(sizeof(cairo_matrix_t));
 	cairo_matrix_t *one_g = (cairo_matrix_t*)getPointerFromHandle(env, one);
 	cairo_matrix_t *two_g = (cairo_matrix_t*)getPointerFromHandle(env, two);
-	cairo_matrix_multiply(dest_g, one_g, two_g);
-	updateHandle(env, dest, dest_g);
+	cairo_matrix_multiply(result, one_g, two_g);
+	return getHandleFromPointer(env, result);
 }
 
 /*

Index: org_freedesktop_cairo_Pattern.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Pattern.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- org_freedesktop_cairo_Pattern.c	28 Feb 2006 17:51:37 -0000	1.9
+++ org_freedesktop_cairo_Pattern.c	23 Mar 2006 18:32:01 -0000	1.10
@@ -150,15 +150,16 @@
 /*
  * Class:     org_freedesktop_cairo_Pattern
  * Method:    cairo_pattern_get_matrix
- * Signature: (Lorg/gnu/glib/Handle;Lorg/gnu/glib/Handle;)I
+ * Signature: (Lorg/gnu/glib/Handle;)Lorg/gnu/glib/Handle;
  */
-JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Pattern_cairo_1pattern_1get_1matrix
-  (JNIEnv *env, jclass cls, jobject obj, jobject matrix)
+JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_Pattern_cairo_1pattern_1get_1matrix
+  (JNIEnv *env, jclass cls, jobject obj)
 {
+	cairo_matrix_t *matrix;
+	matrix = (cairo_matrix_t *) malloc(sizeof(cairo_matrix_t));
 	cairo_pattern_t *pat = (cairo_pattern_t*)getPointerFromHandle(env, obj);
-	cairo_matrix_t *matrix_g = (cairo_matrix_t*)getPointerFromHandle(env, matrix);
-	cairo_pattern_get_matrix(pat, matrix_g);
-	updateHandle(env, matrix, matrix_g);
+	cairo_pattern_get_matrix(pat, matrix);
+	return getHandleFromPointer(env, matrix);
 }
 
 /*



More information about the cairo-commit mailing list