[Gridflow-cvs] [svn] commit: r3318 - in /trunk: base/grid.h format/main.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Mar 28 08:28:06 EDT 2008


Author: matju
Date: Fri Mar 28 08:28:05 2008
New Revision: 3318

Log:
fix initialisation of this->mode; add String to t_symbol* converter.

Modified:
    trunk/base/grid.h
    trunk/format/main.c

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Fri Mar 28 08:28:05 2008
@@ -67,8 +67,8 @@
 #define siglongjmp longjmp
 #endif
 
-#define _L_ post("%s:%d in %s",__FILE__,__LINE__,__PRETTY_FUNCTION__);
-//#define _L_ fprintf(stderr,"%s:%d in %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__);
+//#define _L_ post("%s:%d in %s",__FILE__,__LINE__,__PRETTY_FUNCTION__);
+#define _L_ fprintf(stderr,"%s:%d in %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
 #ifdef IS_BRIDGE
 #define RAISE(args...) rb_raise(rb_eArgError,"[rubypd] "args)
@@ -243,8 +243,9 @@
 		if (TYPE(r)!=T_FLOAT) RAISE("not a Float");
 		return ((RFloat*)r)->value;}
 	operator t_symbol * () const {
-		if (TYPE(r)!=T_SYMBOL) RAISE("not a Symbol");
-		return gensym((char *)rb_sym_name(r));
+		if (TYPE(r)==T_SYMBOL) return gensym((char *)rb_sym_name(r));
+		if (TYPE(r)==T_STRING) return gensym((char *)rb_str_ptr(r));
+ 		RAISE("want Symbol or String");
 	}
 	operator Pointer * () const {
 		if (CLASS_OF(r)!=cPointer) RAISE("not a Pointer");
@@ -929,7 +930,7 @@
 	NumberTypeE cast;
 	long frame;
 	Format() : mode(0), fd(-1), f(0), cast(int32_e), frame(0) {}
-	\decl void initialize (Symbol mode, ...);
+	\decl void initialize (t_symbol *mode, ...);
 	\decl 0 open (String mode, String filename);
 	\decl 0 close ();
 	\decl 0 cast (NumberTypeE nt);

Modified: trunk/format/main.c
==============================================================================
--- trunk/format/main.c (original)
+++ trunk/format/main.c Fri Mar 28 08:28:05 2008
@@ -103,9 +103,11 @@
 \end class FormatLookup {install("gf.format_lookup",1,1);}
 
 \class Format < GridObject
-\def void initialize (Symbol mode, ...) {
+\def void initialize (t_symbol *mode, ...) {
 	SUPER;
-	this->mode = mode;
+	if (mode==gensym("out")) this->mode=2; else
+	if (mode==gensym("in"))  this->mode=4; else
+		RAISE("unknown mode");
 	this->frame = 0;
 //	case mode
 //	when  :in; flags[2]==1
@@ -115,6 +117,7 @@
 }
 
 \def 0 open(Symbol mode, String filename) {
+	if (TYPE(mode)==T_STRING) mode=ID2SYM(rb_intern(rb_str_ptr(mode))); // source_filter doesn't figure this out.
 	const char *fmode;
 	if (mode==SYM(in))  fmode="r"; else
 	if (mode==SYM(out)) fmode="w"; else



More information about the Gridflow-cvs mailing list