Rewrite 'getclass' and 'classname' operators. These were flaky and inconsistent.
This commit is contained in:
@@ -833,28 +833,42 @@ public:
|
||||
//
|
||||
static bool validpositiveinteger(int64_t value) { return (value <= MAXINT) && (value >= 1); }
|
||||
|
||||
// Get the class name given a class table.
|
||||
// Get the class name of X.
|
||||
//
|
||||
// Return the class name if x is a valid class table. Otherwise, returns
|
||||
// empty string. If nonempty, the result is guaranteed to be a
|
||||
// validclassname. This can also function as an "isclass" operator.
|
||||
// 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.
|
||||
//
|
||||
// If the object is none of these, returns empty string.
|
||||
//
|
||||
eng::string classname(LuaSlot x) const;
|
||||
|
||||
// Look for a class by class-name.
|
||||
// Get the class table of X.
|
||||
//
|
||||
// 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.
|
||||
// The object passed in can be:
|
||||
//
|
||||
eng::string getclass(LuaSlot tab, LuaSlot name) const;
|
||||
// * A valid class table.
|
||||
// * A valid, existing class name.
|
||||
// * A tangible that has a class.
|
||||
// *
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
eng::string getclass(LuaSlot tab, LuaSlot obj) const;
|
||||
eng::string getclass(LuaSlot tab, std::string_view name) const;
|
||||
|
||||
// Create a class, or look up an existing class.
|
||||
//
|
||||
// Creates a new class, unless the class already exists. Stores the
|
||||
// class in the global environment table. This routine assert-fails if the
|
||||
// parameter is not a valid classname.
|
||||
// Creates a new class, unless the class already exists.
|
||||
// Stores the class in the global environment table, and
|
||||
// in the class database. This routine assert-fails if
|
||||
// the parameter is not a valid classname.
|
||||
//
|
||||
void makeclass(LuaSlot tab, LuaSlot name) const;
|
||||
void makeclass(LuaSlot tab, std::string_view name) const;
|
||||
@@ -1018,6 +1032,9 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user