Some more error checking for class names and tangible IDs

This commit is contained in:
2024-02-28 14:19:59 -05:00
parent 32dae0df5a
commit 0c126e62d6
8 changed files with 77 additions and 21 deletions

View File

@@ -417,6 +417,15 @@ public:
int next(LuaSlot tab, LuaSlot key, LuaSlot value) const;
// Return true if the string is a valid lua identifier.
static bool valididentifier(std::string_view id);
// Return true if the int64 can be stored losslessly in a lua_Number.
static bool validint64(int64_t value);
// Return true if the int64 is storable in lua and is positive.
static bool validpositiveint64(int64_t value);
// Return true if the classname is legal.
bool validclassname(LuaSlot value) const;
static bool validclassname(std::string_view cname);
@@ -446,6 +455,9 @@ public:
// stub into a full blown tangible, and World::tangible_delete to turn
// a full-blown tangible back into a stub. A stub doesn't have a
// class or a thread table.
//
// Assert-fails if the tangible ID is not a validpositiveint64.
//
void maketan(LuaSlot tab, int64_t id) const;
// Return true if a tangible is empty (deleted or not yet created).
@@ -454,6 +466,9 @@ public:
// Get the ID of a tangible.
int64_t tanid(LuaSlot tab) const;
// Get the class of a tangible.
bool tangetclass(LuaSlot classobj, LuaSlot tan);
// Return true if the value is a sortable key (string, number, or boolean).
bool issortablekey(LuaSlot s) const;