[Tomoe-cvs 1817] CVS update: tomoe/ext/ruby

Back to archive index

Kouhei Sutou kous****@users*****
2006年 12月 11日 (月) 13:39:43 JST


Index: tomoe/ext/ruby/tomoe-rb-dict.c
diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.19 tomoe/ext/ruby/tomoe-rb-dict.c:1.20
--- tomoe/ext/ruby/tomoe-rb-dict.c:1.19	Fri Dec  8 10:00:56 2006
+++ tomoe/ext/ruby/tomoe-rb-dict.c	Mon Dec 11 13:39:43 2006
@@ -23,6 +23,8 @@
     gchar *name;
 
     name = RVAL2CSTR(rb_name);
+    Check_Type(props, T_HASH);
+
     if (strcmp(name, "xml") == 0) {
         VALUE filename, editable;
         filename = rb_hash_aref(props, CSTR2RVAL("filename"));
@@ -57,6 +59,20 @@
                               NULL);
     } else if (strcmp(name, "ruby") == 0) {
         dict = tomoe_dict_new(name, NULL);
+    } else if (strcmp(name, "mysql") == 0) {
+        VALUE database, username, password, host, socket;
+        database = rb_hash_aref(props, CSTR2RVAL("database"));
+        username = rb_hash_aref(props, CSTR2RVAL("username"));
+        password = rb_hash_aref(props, CSTR2RVAL("password"));
+        host = rb_hash_aref(props, CSTR2RVAL("host"));
+        socket = rb_hash_aref(props, CSTR2RVAL("socket"));
+        dict = tomoe_dict_new(name,
+                              "database", RVAL2CSTR2(database),
+                              "user", RVAL2CSTR2(username),
+                              "password", RVAL2CSTR2(password),
+                              "host", RVAL2CSTR2(host),
+                              "socket", RVAL2CSTR2(socket),
+                              NULL);
     } else {
         rb_raise(rb_eArgError, "unknown dictionary type: %s", name);
         dict = NULL;
Index: tomoe/ext/ruby/tomoe-rb.h
diff -u tomoe/ext/ruby/tomoe-rb.h:1.9 tomoe/ext/ruby/tomoe-rb.h:1.10
--- tomoe/ext/ruby/tomoe-rb.h:1.9	Wed Dec  6 15:28:36 2006
+++ tomoe/ext/ruby/tomoe-rb.h	Mon Dec 11 13:39:43 2006
@@ -17,7 +17,7 @@
  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  *  Boston, MA  02111-1307  USA
  *
- *  $Id: tomoe-rb.h,v 1.9 2006/12/06 06:28:36 kous Exp $
+ *  $Id: tomoe-rb.h,v 1.10 2006/12/11 04:39:43 kous Exp $
  */
 
 #ifndef __TOMOE_RB_H__
@@ -36,6 +36,10 @@
 VALUE _tomoe_ruby_object_from_instance_with_unref(gpointer instance);
 #endif
 
+#ifndef RVAL2CSTR2
+#  define RVAL2CSTR2(v) (NIL_P(v) ? NULL : RVAL2CSTR(v))
+#endif
+
 void Init_tomoe(void);
 void Init_tomoe_candidate(VALUE mTomoe);
 void Init_tomoe_char(VALUE mTomoe);


tomoe-cvs メーリングリストの案内
Back to archive index