[cairo-commit] cairo-java/src/jni org_freedesktop_cairo_PsSurface.c, 1.1, 1.2

Jeffrey Morgan commit at pdx.freedesktop.org
Tue Mar 8 12:47:47 PST 2005


Committed by: kuzman

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

Modified Files:
	org_freedesktop_cairo_PsSurface.c 
Log Message:
Completed PsSurface

Index: org_freedesktop_cairo_PsSurface.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_PsSurface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- org_freedesktop_cairo_PsSurface.c	23 Feb 2005 18:17:52 -0000	1.1
+++ org_freedesktop_cairo_PsSurface.c	8 Mar 2005 20:47:44 -0000	1.2
@@ -1,56 +1,76 @@
-/*
- * Java-Gnome Bindings Library
- *
- * Copyright 1998-2004 the Java-Gnome Team, all rights reserved.
- *
- * The Java-Gnome bindings library is free software distributed under
- * the terms of the GNU Library General Public License version 2.
- */
-
-#include <stdio.h>
-#include <jni.h>
-#include <cairo.h>
-#include <jg_jnu.h>
-
-#ifndef _Included_org_freedesktop_cairo_PsSurface
-#define _Included_org_freedesktop_cairo_PsSurface
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Class:     org_freedesktop_cairo_PsSurface
- * Method:    cairo_set_target_ps
- * Signature: (Lorg/gnu/glib/Handle;Ljava/lang/String;DDDD)V
- */
-JNIEXPORT void JNICALL Java_org_freedesktop_cairo_PsSurface_cairo_1set_1target_1ps
-  (JNIEnv *env, jclass cls, jobject cr, jstring filename, jdouble width, jdouble height, 
-  		jdouble x, jdouble y)
-{
-	cairo_t *cr_g = (cairo_t*)getPointerFromHandle(env, cr);
-	char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
-	FILE *f = fopen(fn, "w");
-	cairo_set_target_ps(cr_g, f, width, height, x, y);
-	(*env)->ReleaseStringUTFChars(env, filename, fn);
-}
-
-/*
- * Class:     org_freedesktop_cairo_PsSurface
- * Method:    cairo_ps_surface_create
- * Signature: (Ljava/lang/String;DDDD)Lorg/gnu/glib/Handle;
- */
-JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_PsSurface_cairo_1ps_1surface_1create
-  (JNIEnv *env, jclass cls, jstring filename, jdouble width, jdouble height, 
-  		jdouble x, jdouble y)
-{
-	char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
-	FILE *f = fopen(fn, "w");
-	cairo_surface_t *sur = cairo_ps_surface_create(f, width, height, x, y);
-	(*env)->ReleaseStringUTFChars(env, filename, fn);
-	return getHandleFromPointer(env, sur);
-}
-
-#ifdef __cplusplus
-}
-#endif
-#endif
+/*
+ * Java-Gnome Bindings Library
+ *
+ * Copyright 1998-2004 the Java-Gnome Team, all rights reserved.
+ *
+ * The Java-Gnome bindings library is free software distributed under
+ * the terms of the GNU Library General Public License version 2.
+ */
+
+#include <stdio.h>
+#include <jni.h>
+#include <cairo.h>
+#include <jg_jnu.h>
+
+#ifndef _Included_org_freedesktop_cairo_PsSurface
+#define _Included_org_freedesktop_cairo_PsSurface
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct jg_pssurface {
+	cairo_surface_t *surface;
+	FILE *file;
+} jg_pssurface_t;
+
+/*
+ * Class:     org_freedesktop_cairo_PsSurface
+ * Method:    cairo_set_target_ps
+ * Signature: (Lorg/gnu/glib/Handle;Ljava/lang/String;DDDD)V
+ */
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_PsSurface_cairo_1set_1target_1ps
+  (JNIEnv *env, jclass cls, jobject cr, jobject sur, jdouble width, jdouble height, 
+  		jdouble x, jdouble y)
+{
+	cairo_t *cr_g = (cairo_t*)getPointerFromHandle(env, cr);
+	jg_pssurface_t *s = (jg_pssurface_t*)getPointerFromHandle(env, sur);
+	cairo_set_target_ps(cr_g, s->file, width, height, x, y);
+}
+
+/*
+ * Class:     org_freedesktop_cairo_PsSurface
+ * Method:    cairo_ps_surface_create
+ * Signature: (Ljava/lang/String;DDDD)Lorg/gnu/glib/Handle;
+ */
+JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_PsSurface_cairo_1ps_1surface_1create
+  (JNIEnv *env, jclass cls, jstring filename, jdouble width, jdouble height, 
+  		jdouble x, jdouble y)
+{
+	jg_pssurface_t *s = malloc(sizeof(jg_pssurface_t));
+	char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
+	FILE *f = fopen(fn, "w");
+	cairo_surface_t *sur = cairo_ps_surface_create(f, width, height, x, y);
+	(*env)->ReleaseStringUTFChars(env, filename, fn);
+	s->surface = sur;
+	s->file = f;
+	return getHandleFromPointer(env, s);
+}
+
+/*
+ * Class:     org_freedesktop_cairo_PsSurface
+ * Method:    close
+ * Signature: (Lorg/gnu/glib/Handle;)V
+ */
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_PsSurface_close
+  (JNIEnv *env, jclass cls, jobject sur)
+{
+	jg_pssurface_t *s = (jg_pssurface_t*)getPointerFromHandle(env, sur);
+	fclose(s->file);
+	free(s);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif




More information about the cairo-commit mailing list