[Gridflow-cvs] [svn] commit: r3449 - in /trunk: base/main.rb rubyext.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 4 01:57:38 EDT 2008


Author: matju
Date: Fri Apr  4 01:57:38 2008
New Revision: 3449

Log:
remove FObject[]

Modified:
    trunk/base/main.rb
    trunk/rubyext.c

Modified: trunk/base/main.rb
==============================================================================
--- trunk/base/main.rb (original)
+++ trunk/base/main.rb Fri Apr  4 01:57:38 2008
@@ -108,17 +108,6 @@
 		qlass.instance_eval{qlass.module_eval(&b)}
 	end
 	def initialize2; end
-	def self.[](*m)
-		GridFlow.handle_braces!(m)
-		ms = m.split ','.intern
-		m = ms.shift
-		qlass = m.shift
-		qlassname = qlass.to_s
-		qlass = GridFlow.name_lookup qlass.to_s unless Class===qlass
-		r = qlass.new(*m)
-		for x in ms do r.send_in(0,*x) end
-		r
-	end
 	def initialize(*) end
 	def _0_help; self.class.help end
 	def _0_get(s=nil)

Modified: trunk/rubyext.c
==============================================================================
--- trunk/rubyext.c (original)
+++ trunk/rubyext.c Fri Apr  4 01:57:38 2008
@@ -186,6 +186,8 @@
 }
 
 static Ruby GridFlow_s_handle_braces(Ruby rself, Ruby argv);
+
+static int handle_braces(int ac, Ruby *av);
 
 static Ruby BFObject_init_1 (FMessage *fm) {
 	int argc=fm->ac+1;
@@ -203,7 +205,10 @@
 	int j;
 	Ruby comma = ID2SYM(rb_intern(","));
 	for (j=0; j<argc; j++) if (argv[j]==comma) break;
-	Ruby rself = rb_funcall2(rb_const_get(mGridFlow,SI(FObject)),SI([]),j,argv);
+
+	int jj = handle_braces(j,argv);
+	Ruby rself = rb_funcall2(fclasses[string(rb_str_ptr(argv[0]))]->rself,SI(new),jj-1,argv+1);
+
 	DGS(FObject);
 	self->bself = bself;
 	bself->rself = rself;
@@ -626,12 +631,10 @@
 Ruby GridFlow_s_rdtsc (Ruby rself) { return R(rdtsc()).r; }
 
 /* This code handles nested lists because PureData (all versions including 0.40) doesn't do it */
-static Ruby GridFlow_s_handle_braces(Ruby rself, Ruby argv) {
+static int handle_braces(int ac, Ruby *av) {
     try {
 	int stack[16];
 	int stackn=0;
-	Ruby *av = rb_ary_ptr(argv);
-	int ac = rb_ary_len(argv);
 	int j=0;
 	for (int i=0; i<ac; ) {
 		int close=0;
@@ -646,7 +649,7 @@
 			while (se>s && se[-1]==')') {se--; close++;}
 			if (s!=se) {
 				Ruby u = rb_str_new(s,se-s);
-				av[j++] = rb_funcall(rself,SI(FloatOrSymbol),1,u);
+				av[j++] = rb_funcall(mGridFlow,SI(FloatOrSymbol),1,u);
 			}
 		} else {
 			av[j++]=av[i];
@@ -662,11 +665,15 @@
 		}
 	}
 	if (stackn) RAISE("too many open-paren (%d)",stackn);
-	while (rb_ary_len(argv)>j) rb_ary_pop(argv);
-	return rself;
+	return ac;
     } catch (Barf *oozy) {
         rb_raise(rb_eArgError,"%s",oozy->text);
     }
+}
+static Ruby GridFlow_s_handle_braces(Ruby rself, Ruby args) {
+	int argc = handle_braces(rb_ary_len(args),rb_ary_ptr(args));
+	while (rb_ary_len(args)>argc) rb_ary_pop(args);
+	return rself;
 }
 
 \classinfo {}



More information about the Gridflow-cvs mailing list