[Gridflow-cvs] [svn] commit: r3319 - /trunk/base/grid.h

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Mar 28 10:44:21 EDT 2008


Author: matju
Date: Fri Mar 28 10:44:20 2008
New Revision: 3319

Log:
add converter from R to std::string

Modified:
    trunk/base/grid.h

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Fri Mar 28 10:44:20 2008
@@ -154,6 +154,7 @@
 #define Qnil 0
 typedef void *(*RMethod)(...); /* !@#$ fishy */
 #endif // USE_RUBY
+typedef std::string string;
 
 #define BUILTIN_SYMBOLS(MACRO) \
 	MACRO(_grid,"grid") MACRO(_bang,"bang") MACRO(_float,"float") \
@@ -247,6 +248,11 @@
 		if (TYPE(r)==T_STRING) return gensym((char *)rb_str_ptr(r));
  		RAISE("want Symbol or String");
 	}
+	operator std::string () const {
+		if (TYPE(r)==T_SYMBOL) return std::string(rb_sym_name(r));
+		if (TYPE(r)==T_STRING) return std::string(rb_str_ptr(r));
+ 		RAISE("want Symbol or String");
+	}
 	operator Pointer * () const {
 		if (CLASS_OF(r)!=cPointer) RAISE("not a Pointer");
 		return (Pointer *)NUM2ULONG(rb_funcall(r,SI(ptr),0));



More information about the Gridflow-cvs mailing list