[Gridflow-cvs] [svn] commit: r3357 - in /trunk/base: flow_objects.c grid.h mmx.rb number.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Sun Mar 30 16:26:06 EDT 2008


Author: matju
Date: Sun Mar 30 16:26:05 2008
New Revision: 3357

Log:
number_type table and op/vop table switched to C++

Modified:
    trunk/base/flow_objects.c
    trunk/base/grid.h
    trunk/base/mmx.rb
    trunk/base/number.c

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Sun Mar 30 16:26:05 2008
@@ -198,7 +198,6 @@
 /* **************************************************************** */
 /*{ Dim[*As] -> ? }*/
 /* in0: integer nt */
-/* exporting floats may be crashy because [#export_list] doesn't handle GC */
 \class GridExportList : GridObject {
 	int n;
 	\grin 0
@@ -2354,7 +2353,7 @@
 
 //****************************************************************
 
-static Numop *OP(Ruby x) {return FIX2PTR(Numop,rb_hash_aref(op_dict,x));}
+#define OP(x) op_dict[string(#x)]
 void startup_flow_objects () {
 	op_add = OP(SYM(+));
 	op_sub = OP(SYM(-));

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Sun Mar 30 16:26:05 2008
@@ -570,8 +570,9 @@
 #endif
 
 extern NumberType number_type_table[];
-extern Ruby number_type_dict; // GridFlow. at number_type_dict={}
-extern Ruby op_dict; // GridFlow. at op_dict={}
+extern std::map<string,NumberType *> number_type_dict;
+extern std::map<string,Numop *> op_dict;
+extern std::map<string,Numop *> vop_dict;
 
 #ifdef USE_RUBY
 static inline NumberTypeE convert(Ruby x, NumberTypeE *bogus) {return NumberTypeE_find(x);}

Modified: trunk/base/mmx.rb
==============================================================================
--- trunk/base/mmx.rb (original)
+++ trunk/base/mmx.rb Sun Mar 30 16:26:05 2008
@@ -139,8 +139,7 @@
 		puts "emms"
 	}
 	$decls << "void #{s}(long,#{type}*,#{type});\n"
-	$install << "FIX2PTR(Numop,rb_hash_aref(op_dict,SYM(#{sym})))"
-	$install << "->on_#{type}.map = #{s};\n"
+	$install << "op_dict[string(\"#{sym})\")]->on_#{type}.map = #{s};\n"
 	$count += 1
 end
 
@@ -190,8 +189,7 @@
 	}
 	#$decls << "void #{s}(long,#{type}*,#{type}*,#{type}*);\n"
 	$decls << "void #{s}(long,#{type}*,#{type}*);\n"
-	$install << "FIX2PTR(Numop,rb_hash_aref(op_dict,SYM(#{sym})))"
-	$install << "->on_#{type}.zip = #{s};\n"
+	$install << "op_dict[string(\"#{sym}\")]->on_#{type}.zip = #{s};\n"
 	$count += 1
 end
 

Modified: trunk/base/number.c
==============================================================================
--- trunk/base/number.c (original)
+++ trunk/base/number.c Sun Mar 30 16:26:05 2008
@@ -402,13 +402,12 @@
 #endif
 
 // D=dictionary, A=table, A##_n=table count.
-#define INIT_TABLE(D,A) { D=IEVAL(mGridFlow,"@"#D" ||= {}"); \
-	for(int i=0; i<A##_n; i++) {rb_hash_aset(D,ID2SYM(rb_intern(A[i].name)),PTR2FIX((A+i)));}}
+#define INIT_TABLE(D,A) for(int i=0; i<A##_n; i++) D[string(A[i].name)]=&A[i];
 
 #ifdef PASS1
-Ruby  op_dict = Qnil;
-Ruby vop_dict = Qnil;
-Ruby number_type_dict = Qnil;
+std::map<string,NumberType *> number_type_dict;
+std::map<string,Numop *> op_dict;
+std::map<string,Numop *> vop_dict;
 void startup_number () {
 	INIT_TABLE( op_dict,op_table1)
 	INIT_TABLE( op_dict,op_table2)
@@ -423,15 +422,13 @@
 		char *b = strchr(a,',');
 		if (b) {
 			*b=0;
-			rb_hash_aset(number_type_dict, ID2SYM(rb_intern(b+1)),
-				PTR2FIX(&number_type_table[i]));
+			number_type_dict[string(b+1)]=&number_type_table[i];
 		}
-		rb_hash_aset(number_type_dict, ID2SYM(rb_intern(a)),
-				PTR2FIX(&number_type_table[i]));
+		number_type_dict[string(a)]=&number_type_table[i];
 	}
 // S:name; M:mode; F:replacement function;
 #define OVERRIDE_INT(S,M,F) { \
-	Numop *foo = FIX2PTR(Numop,rb_hash_aref(op_dict,SYM(S))); \
+	Numop *foo = op_dict[string(#S)]; \
 	foo->on_uint8.M=F; \
 	foo->on_int16.M=F; \
 	foo->on_int32.M=F; }



More information about the Gridflow-cvs mailing list