[Gridflow-cvs] [svn] commit: r3300 - in /trunk/format: aalib.c jpeg.c netpbm.c png.c videodev.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Wed Mar 26 21:14:47 EDT 2008


Author: matju
Date: Wed Mar 26 21:14:47 2008
New Revision: 3300

Log:
cleanup

Modified:
    trunk/format/aalib.c
    trunk/format/jpeg.c
    trunk/format/netpbm.c
    trunk/format/png.c
    trunk/format/videodev.c

Modified: trunk/format/aalib.c
==============================================================================
--- trunk/format/aalib.c (original)
+++ trunk/format/aalib.c Wed Mar 26 21:14:47 2008
@@ -128,15 +128,13 @@
 	SUPER;
 	argc-=2; argv+=2;
 	char *argv2[argc];
-	for (int i=0; i<argc; i++)
-		argv2[i] = strdup(rb_str_ptr(rb_funcall(argv[i],SI(to_s),0)));
+	for (int i=0; i<argc; i++) argv2[i] = strdup(rb_str_ptr(rb_funcall(argv[i],SI(to_s),0)));
 	if (mode!=SYM(out)) RAISE("write-only, sorry");
 	aa_parseoptions(0,0,&argc,argv2);
 	for (int i=0; i<argc; i++) free(argv2[i]);
 	Ruby drivers = rb_ivar_get(rb_obj_class(rself),SI(@drivers));
 	Ruby driver_address = rb_hash_aref(drivers,target);
-	if (driver_address==Qnil)
-		RAISE("unknown aalib driver '%s'",rb_sym_name(target));
+	if (driver_address==Qnil) RAISE("unknown aalib driver '%s'",rb_sym_name(target));
 	aa_driver *driver = FIX2PTR(aa_driver,driver_address);
 	context = aa_init(driver,&aa_defparams,0);
 	rparams = aa_getrenderparams();

Modified: trunk/format/jpeg.c
==============================================================================
--- trunk/format/jpeg.c (original)
+++ trunk/format/jpeg.c Wed Mar 26 21:14:47 2008
@@ -43,7 +43,6 @@
 	\decl void initialize (Symbol mode, String filename);
 	\decl 0 bang ();
 	\decl 0 quality (short quality);
-	\decl 0 close ();
 	\grin 0 int
 };
 
@@ -87,8 +86,8 @@
 }
 
 \def 0 bang () {
-	off_t off = NUM2LONG(rb_funcall(rb_ivar_get(rself,SI(@stream)),SI(tell),0));
-	fseek(f,off,SEEK_SET);
+	//off_t off = ftell(f);
+	//fseek(f,off,SEEK_SET);
 	if (gfeof(f)) {outlet_bang(bself->out[1]); return;}
 	djpeg.err = jpeg_std_error(&jerr);
 	jpeg_create_decompress(&djpeg);
@@ -115,17 +114,9 @@
 	jpeg_set_quality(&cjpeg,quality,false);
 }
 
-\def 0 close () {
-	if (f) {fclose(f); f=0;}
-	//if (f) {rb_funcall(stream,SI(close),0); f=0; fd=-1;}
-}
-
 \def void initialize (Symbol mode, String filename) {
 	SUPER;
-	rb_funcall(rself,SI(raw_open),3,mode,filename);
-	Ruby stream = rb_ivar_get(rself,SI(@stream));
-	fd = NUM2INT(rb_funcall(stream,SI(fileno),0));
-	f = fdopen(fd,mode==SYM(in)?"r":"w");
+	Format::_0_open(0,0,mode,filename);
 	uint32 mask[3] = {0x0000ff,0x00ff00,0xff0000};
 	bit_packing = new BitPacking(is_le(),3,3,mask);
 }

Modified: trunk/format/netpbm.c
==============================================================================
--- trunk/format/netpbm.c (original)
+++ trunk/format/netpbm.c Wed Mar 26 21:14:47 2008
@@ -31,12 +31,12 @@
 	int fd;
 	FILE *f;
 	\grin 0
-	\decl void initialize(Symbol mode, String filename);
+	\decl void initialize(String mode, String filename);
 	\decl 0 bang ();
 };
-\def void initialize(Symbol mode, String filename) {
+\def void initialize(String mode, String filename) {
 	SUPER;
-	rb_funcall(rself,SI(raw_open),3,mode,filename);
+	Format::_0_open(0,0,mode,filename);
 	Ruby stream = rb_ivar_get(rself,SI(@stream));
 	fd = NUM2INT(rb_funcall(stream,SI(fileno),0));
 	f = fdopen(fd,mode==SYM(in)?"r":"w");

Modified: trunk/format/png.c
==============================================================================
--- trunk/format/png.c (original)
+++ trunk/format/png.c Wed Mar 26 21:14:47 2008
@@ -38,7 +38,6 @@
 	FormatPNG () : bit_packing(0), png(0), f(0) {}
 	\decl void initialize (Symbol mode, String filename);
 	\decl 0 bang ();
-	\decl 0 close ();
 	\grin 0 int
 };
 
@@ -109,14 +108,9 @@
 	png_destroy_read_struct(&png, &info, NULL);
 }
 
-\def 0 close () {if (f) {fclose(f); f=0;}}
-
 \def void initialize (Symbol mode, String filename) {
 	SUPER;
-	rb_funcall(rself,SI(raw_open),3,mode,filename);
-	Ruby stream = rb_ivar_get(rself,SI(@stream));
-	fd = NUM2INT(rb_funcall(stream,SI(fileno),0));
-	f = fdopen(fd,mode==SYM(in)?"r":"w");
+	Format::_0_open(0,0,mode,filename);
 	uint32 mask[3] = {0x0000ff,0x00ff00,0xff0000};
 	bit_packing = new BitPacking(is_le(),3,3,mask);
 }

Modified: trunk/format/videodev.c
==============================================================================
--- trunk/format/videodev.c (original)
+++ trunk/format/videodev.c Wed Mar 26 21:14:47 2008
@@ -283,8 +283,6 @@
   (IOCTL(F,NAME,ARG)<0 && (error("ioctl %s: %s",#NAME,strerror(errno)),1))
 #define WIOCTL2(F,NAME,ARG) \
   (IOCTL(F,NAME,ARG)<0 && (error("ioctl %s: %s",#NAME,strerror(errno)), RAISE("ioctl error"), 0))
-
-#define GETFD NUM2INT(rb_funcall(rb_ivar_get(rself,SI(@stream)),SI(fileno),0))
 
 \def 0 size (int sy, int sx) {
 	VideoWindow grab_win;
@@ -751,10 +749,8 @@
 \def void initialize (Symbol mode, String filename, Symbol option=Qnil) {
 	SUPER;
 	image=0;
-	rb_ivar_set(rself,SI(@stream),
-		rb_funcall(rb_cFile,SI(open),2,filename,rb_str_new2("r+")));
-	fd = GETFD;
-	rb_funcall(rself,SI(initialize2),0);
+	f = fopen(rb_str_ptr(filename),"r+");
+	rb_funcall(rself,SI(initialize2),0); // name conflict...
 }
 
 \end class FormatVideoDev {install_format("#io:videodev",1,2,4,"");}



More information about the Gridflow-cvs mailing list