dbd/sqlite3/connection.c

changeset 32
03ed0ca09837
parent 22
fd78e9cdc6e9
child 41
e490414a391d
--- a/dbd/sqlite3/connection.c	Sat Jun 13 08:55:44 2009 +0000
+++ b/dbd/sqlite3/connection.c	Tue Sep 01 13:15:02 2009 +0000
@@ -198,6 +198,17 @@
     return 0;
 }
 
+/*
+ * __tostring
+ */
+static int connection_tostring(lua_State *L) {
+    connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_SQLITE_CONNECTION);
+
+    lua_pushfstring(L, "%s: %p", DBD_SQLITE_CONNECTION, conn);
+
+    return 1;
+}
+
 int dbd_sqlite3_connection(lua_State *L) {
     /*
      * instance methods
@@ -229,6 +240,9 @@
     lua_pushcfunction(L, connection_gc);
     lua_setfield(L, -2, "__gc");
 
+    lua_pushcfunction(L, connection_tostring);
+    lua_setfield(L, -2, "__tostring");
+
     luaL_register(L, DBD_SQLITE_CONNECTION, connection_class_methods);
 
     return 1;    

mercurial