Stub out the new global.set and global.get operators

This commit is contained in:
2023-03-01 17:35:06 -05:00
parent 9ce34d950b
commit db234c2934
6 changed files with 115 additions and 88 deletions

View File

@@ -589,7 +589,17 @@ LuaDefine(table_nextsortedpair, "sortedpairs,dummy", "next function used by sort
}
}
LuaDefine(table_sortedpairs, "table", "iterate over table, sorting all keys") {
LuaDefine(table_sortedpairs, "table",
"|Iterate over table, sorting all keys"
"|"
"|Some keys can't be sorted. For example, you can use a closure"
"|as a table key. If you try to iterate over a table containing"
"|a non-sortable key, the error 'Cannot sort the table keys' will"
"|be generated."
"|"
"|See doc(genlt) for information about the sort order."
"|"
"|") {
LuaArg tab;
LuaRet closure, rtab, key;
LuaStack LS(L, tab, closure, rtab, key);
@@ -602,7 +612,17 @@ LuaDefine(table_sortedpairs, "table", "iterate over table, sorting all keys") {
return LS.result();
}
LuaDefine(table_semisortedpairs, "table", "iterate over table, sorting those keys that can be sorted") {
LuaDefine(table_semisortedpairs, "table",
"|Iterate over table, sorting all the keys that can be sorted."
"|"
"|Some keys can't be sorted. For example, you can use a closure"
"|as a table key. If you try to iterate over a table containing"
"|a non-sortable key, the non-sortable elements will appear at"
"|the end of the iteration, after all the sortable elements. The"
"|non-sortable elements will be in an arbitrary order."
"|"
"|See doc(genlt) for information about the sort order."
"|") {
LuaArg tab;
LuaRet closure, rtab, key;
LuaStack LS(L, tab, closure, rtab, key);
@@ -612,7 +632,37 @@ LuaDefine(table_semisortedpairs, "table", "iterate over table, sorting those key
return LS.result();
}
LuaDefine(genlt, "obj1,obj2", "return true if obj1 is less than obj2 in general ordering") {
#define LUA_TNIL 0
#define LUA_TBOOLEAN 1
#define LUA_TLIGHTUSERDATA 2
#define LUA_TNUMBER 3
#define LUA_TSTRING 4
#define LUA_TTABLE 5
#define LUA_TFUNCTION 6
#define LUA_TUSERDATA 7
#define LUA_TTHREAD 8
#define LUA_NUMTAGS 9
LuaDefine(genlt, "obj1,obj2",
"|Generalized less-than function"
"|"
"|This comparison function can compare any two objects. The"
"|return value is as follows:"
"|"
"|* Numbers are compared in the obvious numeric manner."
"|* Strings are compared alphabetically."
"|* Booleans are compared with false being less than true."
"|* Tables are all considered equal to other tables."
"|* Functions are all considered equal to other functions."
"|* Coroutines are all considered equal to other coroutines."
"|"
"|* Numbers are less than strings."
"|* Strings are less than booleans."
"|* Booleans are less than functions."
"|* Functions are less than coroutines."
"|* Coroutines are less than tables."
"|") {
LuaArg o1,o2;
LuaRet lt;
LuaStack LS(L, o1, o2, lt);