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

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Tue Apr 15 22:55:02 EDT 2008


Author: matju
Date: Tue Apr 15 22:55:02 2008
New Revision: 3544

Log:
moved GridFlow.find_file to c++

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

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Tue Apr 15 22:55:02 2008
@@ -902,7 +902,8 @@
 	\decl 0 rewind ();
 };
 
-static inline string gf_find_file (string x) {return string(rb_str_ptr(rb_funcall(mGridFlow,SI(find_file),1,rb_str_new2(x.data()))));}
+extern std::vector<string> gf_data_path;
+string gf_find_file (string x);
 void pd_oprintf (std::ostream &o, const char *s, int argc, t_atom *argv);
 
 inline void set_atom (t_atom *a, uint8     v) {SETFLOAT(a,(float)v);}

Modified: trunk/base/main.c
==============================================================================
--- trunk/base/main.c (original)
+++ trunk/base/main.c Tue Apr 15 22:55:02 2008
@@ -452,3 +452,15 @@
 EACH_NUMBER_TYPE(FOO)
 #undef FOO
 }
+
+std::vector<string> gf_data_path;
+string gf_find_file (string x) {
+	if (strchr(x.data(),'/')) return x;
+	int n = gf_data_path.size();
+	struct stat dummy;
+	for (int i=0; i<n; i++) {
+		string s = gf_data_path[i]+"/"+x;
+		if (lstat(s.data(),&dummy)==0) return s;
+	}
+	return x;
+}

Modified: trunk/base/main.rb
==============================================================================
--- trunk/base/main.rb (original)
+++ trunk/base/main.rb Tue Apr 15 22:55:02 2008
@@ -1,13 +1,4 @@
 module GridFlow
-class << self; attr_accessor :data_path end
- at data_path=[GridFlow::DIR+"/images"]
-def GridFlow.find_file s
-	s=s.to_s
-	if s==File.basename(s) then
-		dir = GridFlow.data_path.find {|x| File.exist? "#{x}/#{s}" }
-		if dir then "#{dir}/#{s}" else s end
-	else s end
-end
 
 class ::Object; def FloatOrSymbol(x) Float(x) rescue x.intern end end
 end # module GridFlow

Modified: trunk/rubyext.c
==============================================================================
--- trunk/rubyext.c (original)
+++ trunk/rubyext.c Tue Apr 15 22:55:02 2008
@@ -587,8 +587,6 @@
 	delete self; // really!
 	return Qnil;
 }
-
-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 */
 int handle_braces(int ac, t_atom *av) {
@@ -704,15 +702,12 @@
 	BFProxy_class = class_new(gensym("ruby_proxy"),0,0,sizeof(BFProxy),CLASS_PD|CLASS_NOINLET, A_NULL);
 	class_addanything(BFProxy_class,BFProxy_method_missing);
 	mGridFlow = EVAL("module GridFlow; class<<self; end; Pd=GridFlow; end");
-	rb_const_set(mGridFlow,SI(DIR),rb_str_new2(dirresult));
-	post("DIR = %s",rb_str_ptr(EVAL("GridFlow::DIR.inspect")));
-	EVAL("$:.unshift GridFlow::DIR+'/..', GridFlow::DIR");
+	gf_data_path.push_back(string(dirresult)+"/images");
         srandom(rdtsc());
 #define FOO(_sym_,_name_) bsym._sym_ = gensym(_name_);
 BUILTIN_SYMBOLS(FOO)
 #undef FOO
 	mGridFlow = EVAL("module GridFlow; CObject = ::Object; self end");
-	SDEF2("rdtsc",rdtsc,0);
 	rb_ivar_set(mGridFlow, SI(@fobjects), rb_hash_new());
 	rb_define_const(mGridFlow, "GF_VERSION", rb_str_new2(GF_VERSION));
 	rb_define_const(mGridFlow, "GF_COMPILE_TIME", rb_str_new2(__DATE__", "__TIME__));



More information about the Gridflow-cvs mailing list