[Gridflow-cvs] [svn] commit: r3365 - /trunk/base/main.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Sun Mar 30 18:31:16 EDT 2008


Author: matju
Date: Sun Mar 30 18:31:16 2008
New Revision: 3365

Log:
updated NumberTypeE_find (derubify)

Modified:
    trunk/base/main.c

Modified: trunk/base/main.c
==============================================================================
--- trunk/base/main.c (original)
+++ trunk/base/main.c Sun Mar 30 18:31:16 2008
@@ -311,12 +311,14 @@
 	return rself;
 }
 
+NumberTypeE NumberTypeE_find (string s) {
+	if (number_type_dict.find(s)==number_type_dict.end()) RAISE("unknown number type \"%s\"", s.data());
+	return number_type_dict[s]->index;
+}
+
 NumberTypeE NumberTypeE_find (Ruby sym) {
-	if (TYPE(sym)!=T_SYMBOL) RAISE("expected symbol (not %s)", rb_str_ptr(rb_inspect(rb_obj_class(sym))));
-	Ruby nt_dict = rb_ivar_get(mGridFlow,SI(@number_type_dict));
-	Ruby v = rb_hash_aref(nt_dict,sym);
-	if (v!=Qnil) return FIX2PTR(NumberType,v)->index;
-	RAISE("unknown number type \"%s\"", rb_sym_name(sym));
+	if (TYPE(sym)!=T_STRING) sym=rb_funcall(sym,SI(to_s),0);
+	return NumberTypeE_find(string(rb_str_ptr(sym)));
 }
 
 /* **************************************************************** */



More information about the Gridflow-cvs mailing list