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

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 18 18:22:03 EDT 2008


Author: matju
Date: Fri Apr 18 18:22:03 2008
New Revision: 3608

Log:
remove type Ruby

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

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Fri Apr 18 18:22:03 2008
@@ -83,28 +83,6 @@
 
 // returns the size of a statically defined array
 #define COUNT(_array_) ((int)(sizeof(_array_) / sizeof((_array_)[0])))
-
-#ifdef USE_RUBY
-#ifdef RARRAY_LEN
-#if RUBY_VERSION_MAJOR > 1 || RUBY_VERSION_MINOR >= 9
-// T_SYMBOL stops existing when RARRAY_LEN was introduced in 1.9 mid-2006 ?
-// but at the same time you can't do this with 1.8.5 which has RARRAY_LEN too
-#undef T_SYMBOL
-#define T_SYMBOL T_STRING
-#endif // 1.9.0
-static inline long  rb_str_len(Ruby s) {return RSTRING_LEN(s);}
-static inline char *rb_str_ptr(Ruby s) {return RSTRING_PTR(s);}
-static inline long  rb_ary_len(Ruby s) {return  RARRAY_LEN(s);}
-static inline Ruby *rb_ary_ptr(Ruby s) {return  RARRAY_PTR(s);}
-#else
-static inline long  rb_str_len(Ruby s) {return RSTRING(s)->len;}
-static inline char *rb_str_ptr(Ruby s) {return RSTRING(s)->ptr;}
-static inline long  rb_ary_len(Ruby s) {return  RARRAY(s)->len;}
-static inline Ruby *rb_ary_ptr(Ruby s) {return  RARRAY(s)->ptr;}
-#endif // RARRAY_LEN
-static inline const char *rb_sym_name(Ruby sym) {return rb_id2name(SYM2ID(sym));}
-#else // USE_RUBY
-#endif // USE_RUBY
 
 #define IEVAL(_self_,s) rb_funcall(_self_,SI(instance_eval),1,rb_str_new2(s))
 #define EVAL(s) rb_eval_string(s)
@@ -857,7 +835,5 @@
 
 extern std::map<string,FClass *> fclasses;
 int handle_braces(int ac, t_atom *av);
-void ruby2pd (int argc, Ruby *argv, t_atom *at);
-void pd2ruby (int argc, Ruby *argv, t_atom *at);
 
 #endif // __GF_GRID_H

Modified: trunk/base/main.c
==============================================================================
--- trunk/base/main.c (original)
+++ trunk/base/main.c Fri Apr 18 18:22:03 2008
@@ -142,11 +142,6 @@
 	return number_type_dict[s]->index;
 }
 
-NumberTypeE NumberTypeE_find (Ruby sym) {
-	if (TYPE(sym)!=T_STRING) sym=rb_funcall(sym,SI(to_s),0);
-	return NumberTypeE_find(string(rb_str_ptr(sym)));
-}
-
 NumberTypeE NumberTypeE_find (const t_atom &x) {
 	if (x.a_type!=A_SYMBOL) RAISE("expected number-type (as symbol)");
 	return NumberTypeE_find(string(x.a_w.w_symbol->s_name));

Modified: trunk/rubyext.c
==============================================================================
--- trunk/rubyext.c (original)
+++ trunk/rubyext.c Fri Apr 18 18:22:03 2008
@@ -89,17 +89,6 @@
 	return self->p;
 }
 
-static Ruby make_error_message () {
-	char buf[1000];
-	sprintf(buf,"%s: %s",rb_class2name(rb_obj_class(ruby_errinfo)), rb_str_ptr(rb_funcall(ruby_errinfo,SI(to_s),0)));
-	Ruby ary = rb_ary_new();
-	Ruby backtrace = rb_funcall(ruby_errinfo,SI(backtrace),0);
-	rb_ary_push(ary,rb_str_new2(buf));
-	for (int i=0; i<2 && i<rb_ary_len(backtrace); i++) rb_ary_push(ary,rb_funcall(backtrace,SI([]),1,INT2NUM(i)));
-//	rb_ary_push(ary,rb_funcall(rb_funcall(backtrace,SI(length),0),SI(to_s),0));
-	return ary;
-}
-
 /* **************************************************************** */
 
 static RMethod funcall_lookup (BFObject *bself, const char *sel) {
@@ -122,8 +111,7 @@
 struct RMessage {BFObject *bself; const char *sel; int argc; t_atom *argv;};
 static void funcall_rescue_1(RMessage *rm) {funcall(rm->bself,rm->sel,rm->argc,rm->argv);}
 static Ruby funcall_rescue_2 (RMessage *rm) {
-	Ruby errmsg = rb_funcall(make_error_message(),SI(join),1,rb_str_new2("\n"));
-	pd_error(rm->bself,"%s",rb_str_ptr(errmsg));
+	pd_error(rm->bself,"%s","some ruby error...");
 	return Qnil;
 }
 static void funcall_rescue(BFObject *bself, const char *sel, int argc, t_atom *argv) {
@@ -151,44 +139,6 @@
 }
 
 static t_class *BFProxy_class;
-
-static void Bridge_export_value(Ruby arg, t_atom *at) {
-	if      (INTEGER_P(arg)) SETFLOAT(at,NUM2INT(arg));
-	else if ( SYMBOL_P(arg)) SETSYMBOL(at,gensym((char *)rb_sym_name(arg)));
-	else if (  FLOAT_P(arg)) SETFLOAT(at,RFLOAT(arg)->value);
-	else if (rb_obj_class(arg)==cPointer) SETPOINTER(at,(t_gpointer*)Pointer_get(arg));
-	else if (TYPE(arg)==T_ARRAY) {
-		t_binbuf *b = binbuf_new();
-		t_atom a;
-		int n=rb_ary_len(arg);
-		Ruby *p=rb_ary_ptr(arg);
-		for (int i=0; i<n; i++) {Bridge_export_value(p[i],&a); binbuf_add(b,1,&a);}
-		SETLIST(at,b);
-	} else RAISE("cannot convert argument of class '%s'",rb_str_ptr(rb_funcall(rb_funcall(arg,SI(class),0),SI(inspect),0)));
-}
-
-void ruby2pd (int argc, Ruby *argv, t_atom *at) {
-	for (int i=0; i<argc; i++) Bridge_export_value(argv[i],&at[i]);
-}
-
-static Ruby Bridge_import_value(const t_atom *at) {
-	t_atomtype t = at->a_type;
-	if (t==A_SYMBOL)  return ID2SYM(rb_intern(at->a_w.w_symbol->s_name));
-	if (t==A_FLOAT )  return rb_float_new(at->a_w.w_float);
-	if (t==A_POINTER) return Pointer_s_new(at->a_w.w_gpointer);
-	if (t==A_LIST) {
-		Ruby a = rb_ary_new();
-		t_binbuf *b = (t_binbuf *)at->a_w.w_gpointer;
-		int n = binbuf_getnatom(b);
-		for (int i=0; i<n; i++) rb_ary_push(a,Bridge_import_value(binbuf_getvec(b)+i));
-		return a;
-	}
-	return Qnil; /* unknown */
-}
-
-void pd2ruby (int argc, Ruby *argv, t_atom *at) {
-	for (int i=0; i<argc; i++) argv[i] = Bridge_import_value(&at[i]);
-}
 
 static Ruby BFObject_method_missing_1 (FMessage *fm) {
 	t_atom argv[fm->ac+1];
@@ -213,9 +163,7 @@
 }
 
 static Ruby BFObject_rescue (FMessage *fm) {
-	Ruby error_array = make_error_message();
-	if (fm->self) pd_error(fm->self,"%s",rb_str_ptr(rb_funcall(error_array,SI(join),1,rb_str_new2("\n"))));
-	fprintf(stderr,"%s\n",rb_str_ptr(rb_funcall(error_array,SI(join),1,rb_str_new2("\n"))));
+	if (fm->self) pd_error(fm->self,"some ruby error");
 	if (fm->self && fm->is_init) fm->self = 0;
 	return Qnil;
 }



More information about the Gridflow-cvs mailing list