A little more work on getclass and classname

This commit is contained in:
2026-02-21 23:58:33 -05:00
parent b1a132e252
commit f544888938
2 changed files with 47 additions and 14 deletions

View File

@@ -833,6 +833,20 @@ public:
//
static bool validpositiveinteger(int64_t value) { return (value <= MAXINT) && (value >= 1); }
// Get the class table and class name of X.
//
// The object passed in can be:
//
// * A valid class table.
// * A valid, existing class name.
// * A tangible that has a class.
// * A normal table with a class metatable.
//
// On success, sets classtab, classname, and clears error.
// On failure, sets classtab to nil, clears classname, and sets error.
//
void getclassinfo(LuaSlot classtab, eng::string &classname, eng::string &error, LuaSlot input) const;
// Get the class name of X.
//
// The object passed in can be:
@@ -853,12 +867,10 @@ public:
// * A valid class table.
// * A valid, existing class name.
// * A tangible that has a class.
// *
// * A normal table with a class metatable.
//
// If there is a problem, returns an error message.
// There are lots of error conditions, including such
// things as no such class, corrupted class, classname
// invalid, etc.
// If there is a problem, returns an error message
// and sets tab to nil.
//
eng::string getclass(LuaSlot tab, LuaSlot obj) const;
eng::string getclass(LuaSlot tab, std::string_view name) const;
@@ -1032,9 +1044,6 @@ public:
lua_rawseti(L_, tab, key);
}
private:
void getclassinfo(LuaSlot classtab, eng::string &classname, eng::string &error, LuaSlot input) const;
protected:
// Assign slots: this is used by the LuaDefStack and LuaExtStack