dbd/oracle/connection.c

changeset 32
03ed0ca09837
parent 22
fd78e9cdc6e9
equal deleted inserted replaced
31:999ef93f0dbc 32:03ed0ca09837
214 connection_close(L); 214 connection_close(L);
215 215
216 return 0; 216 return 0;
217 } 217 }
218 218
219 /*
220 * __tostring
221 */
222 static int connection_tostring(lua_State *L) {
223 connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_ORACLE_CONNECTION);
224
225 lua_pushfstring(L, "%s: %p", DBD_ORACLE_CONNECTION, conn);
226
227 return 1;
228 }
229
219 int dbd_oracle_connection(lua_State *L) { 230 int dbd_oracle_connection(lua_State *L) {
220 /* 231 /*
221 * instance methods 232 * instance methods
222 */ 233 */
223 static const luaL_Reg connection_methods[] = { 234 static const luaL_Reg connection_methods[] = {
245 lua_setfield(L, -2, "__index"); 256 lua_setfield(L, -2, "__index");
246 257
247 lua_pushcfunction(L, connection_gc); 258 lua_pushcfunction(L, connection_gc);
248 lua_setfield(L, -2, "__gc"); 259 lua_setfield(L, -2, "__gc");
249 260
261 lua_pushcfunction(L, connection_tostring);
262 lua_setfield(L, -2, "__tostring");
263
250 luaL_register(L, DBD_ORACLE_CONNECTION, connection_class_methods); 264 luaL_register(L, DBD_ORACLE_CONNECTION, connection_class_methods);
251 265
252 return 1; 266 return 1;
253 } 267 }

mercurial