diff options
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -752,6 +752,21 @@ const TValue *luaH_getint (Table *t, lua_Integer key) { | |||
752 | } | 752 | } |
753 | 753 | ||
754 | 754 | ||
755 | static int finishnodeget (const TValue *val, TValue *res) { | ||
756 | if (!ttisnil(val)) { | ||
757 | setobj(((lua_State*)NULL), res, val); | ||
758 | return HOK; /* success */ | ||
759 | } | ||
760 | else | ||
761 | return HNOTFOUND; /* could not get value */ | ||
762 | } | ||
763 | |||
764 | |||
765 | int luaH_getint1 (Table *t, lua_Integer key, TValue *res) { | ||
766 | return finishnodeget(luaH_getint(t, key), res); | ||
767 | } | ||
768 | |||
769 | |||
755 | /* | 770 | /* |
756 | ** search function for short strings | 771 | ** search function for short strings |
757 | */ | 772 | */ |
@@ -771,6 +786,11 @@ const TValue *luaH_getshortstr (Table *t, TString *key) { | |||
771 | } | 786 | } |
772 | 787 | ||
773 | 788 | ||
789 | int luaH_getshortstr1 (Table *t, TString *key, TValue *res) { | ||
790 | return finishnodeget(luaH_getshortstr(t, key), res); | ||
791 | } | ||
792 | |||
793 | |||
774 | const TValue *luaH_getstr (Table *t, TString *key) { | 794 | const TValue *luaH_getstr (Table *t, TString *key) { |
775 | if (key->tt == LUA_VSHRSTR) | 795 | if (key->tt == LUA_VSHRSTR) |
776 | return luaH_getshortstr(t, key); | 796 | return luaH_getshortstr(t, key); |
@@ -782,6 +802,11 @@ const TValue *luaH_getstr (Table *t, TString *key) { | |||
782 | } | 802 | } |
783 | 803 | ||
784 | 804 | ||
805 | int luaH_getstr1 (Table *t, TString *key, TValue *res) { | ||
806 | return finishnodeget(luaH_getstr(t, key), res); | ||
807 | } | ||
808 | |||
809 | |||
785 | /* | 810 | /* |
786 | ** main search function | 811 | ** main search function |
787 | */ | 812 | */ |
@@ -802,6 +827,11 @@ const TValue *luaH_get (Table *t, const TValue *key) { | |||
802 | } | 827 | } |
803 | 828 | ||
804 | 829 | ||
830 | int luaH_get1 (Table *t, const TValue *key, TValue *res) { | ||
831 | return finishnodeget(luaH_get(t, key), res); | ||
832 | } | ||
833 | |||
834 | |||
805 | /* | 835 | /* |
806 | ** Finish a raw "set table" operation, where 'slot' is where the value | 836 | ** Finish a raw "set table" operation, where 'slot' is where the value |
807 | ** should have been (the result of a previous "get table"). | 837 | ** should have been (the result of a previous "get table"). |