diff options
-rw-r--r-- | src/lfs.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -534,19 +534,18 @@ static int dir_iter_factory (lua_State *L) { | |||
534 | */ | 534 | */ |
535 | static int dir_create_meta (lua_State *L) { | 535 | static int dir_create_meta (lua_State *L) { |
536 | luaL_newmetatable (L, DIR_METATABLE); | 536 | luaL_newmetatable (L, DIR_METATABLE); |
537 | /* set its __gc field */ | 537 | |
538 | lua_pushstring (L, "__index"); | 538 | /* Method table */ |
539 | lua_newtable(L); | 539 | lua_newtable(L); |
540 | lua_pushstring (L, "next"); | ||
541 | lua_pushcfunction (L, dir_iter); | 540 | lua_pushcfunction (L, dir_iter); |
542 | lua_settable(L, -3); | 541 | lua_setfield(L, -2, "next"); |
543 | lua_pushstring (L, "close"); | ||
544 | lua_pushcfunction (L, dir_close); | 542 | lua_pushcfunction (L, dir_close); |
545 | lua_settable(L, -3); | 543 | lua_setfield(L, -2, "close"); |
546 | lua_settable (L, -3); | 544 | |
547 | lua_pushstring (L, "__gc"); | 545 | /* Metamethods */ |
546 | lua_setfield(L, -2, "__index"); | ||
548 | lua_pushcfunction (L, dir_close); | 547 | lua_pushcfunction (L, dir_close); |
549 | lua_settable (L, -3); | 548 | lua_setfield (L, -2, "__gc"); |
550 | return 1; | 549 | return 1; |
551 | } | 550 | } |
552 | 551 | ||
@@ -555,10 +554,13 @@ static int dir_create_meta (lua_State *L) { | |||
555 | */ | 554 | */ |
556 | static int lock_create_meta (lua_State *L) { | 555 | static int lock_create_meta (lua_State *L) { |
557 | luaL_newmetatable (L, LOCK_METATABLE); | 556 | luaL_newmetatable (L, LOCK_METATABLE); |
558 | /* set its __gc field */ | 557 | |
558 | /* Method table */ | ||
559 | lua_newtable(L); | 559 | lua_newtable(L); |
560 | lua_pushcfunction(L, lfs_unlock_dir); | 560 | lua_pushcfunction(L, lfs_unlock_dir); |
561 | lua_setfield(L, -2, "free"); | 561 | lua_setfield(L, -2, "free"); |
562 | |||
563 | /* Metamethods */ | ||
562 | lua_setfield(L, -2, "__index"); | 564 | lua_setfield(L, -2, "__index"); |
563 | lua_pushcfunction(L, lfs_unlock_dir); | 565 | lua_pushcfunction(L, lfs_unlock_dir); |
564 | lua_setfield(L, -2, "__gc"); | 566 | lua_setfield(L, -2, "__gc"); |