dbd/postgresql/connection.c

changeset 32
03ed0ca09837
parent 22
fd78e9cdc6e9
child 44
aab3ed7d93fe
equal deleted inserted replaced
31:999ef93f0dbc 32:03ed0ca09837
255 connection_close(L); 255 connection_close(L);
256 256
257 return 0; 257 return 0;
258 } 258 }
259 259
260 /*
261 * __tostring
262 */
263 static int connection_tostring(lua_State *L) {
264 connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_POSTGRESQL_CONNECTION);
265
266 lua_pushfstring(L, "%s: %p", DBD_POSTGRESQL_CONNECTION, conn);
267
268 return 1;
269 }
270
260 int dbd_postgresql_connection(lua_State *L) { 271 int dbd_postgresql_connection(lua_State *L) {
261 static const luaL_Reg connection_methods[] = { 272 static const luaL_Reg connection_methods[] = {
262 {"autocommit", connection_autocommit}, 273 {"autocommit", connection_autocommit},
263 {"close", connection_close}, 274 {"close", connection_close},
264 {"commit", connection_commit}, 275 {"commit", connection_commit},
280 lua_setfield(L, -2, "__index"); 291 lua_setfield(L, -2, "__index");
281 292
282 lua_pushcfunction(L, connection_gc); 293 lua_pushcfunction(L, connection_gc);
283 lua_setfield(L, -2, "__gc"); 294 lua_setfield(L, -2, "__gc");
284 295
296 lua_pushcfunction(L, connection_tostring);
297 lua_setfield(L, -2, "__tostring");
298
285 luaL_register(L, DBD_POSTGRESQL_CONNECTION, connection_class_methods); 299 luaL_register(L, DBD_POSTGRESQL_CONNECTION, connection_class_methods);
286 300
287 return 1; 301 return 1;
288 } 302 }

mercurial