dbd/oracle/connection.c

changeset 32
03ed0ca09837
parent 22
fd78e9cdc6e9
--- a/dbd/oracle/connection.c	Sat Jun 13 08:55:44 2009 +0000
+++ b/dbd/oracle/connection.c	Tue Sep 01 13:15:02 2009 +0000
@@ -216,6 +216,17 @@
     return 0;
 }
 
+/*
+ * __tostring
+ */
+static int connection_tostring(lua_State *L) {
+    connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_ORACLE_CONNECTION);
+
+    lua_pushfstring(L, "%s: %p", DBD_ORACLE_CONNECTION, conn);
+
+    return 1;
+}
+
 int dbd_oracle_connection(lua_State *L) {
     /*
      * instance methods
@@ -247,6 +258,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_ORACLE_CONNECTION, connection_class_methods);
 
     return 1;    

mercurial