The Battle for Wesnoth  1.15.2+dev
Public Member Functions | Static Public Member Functions | Static Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
lua_jailbreak_exception Class Referenceabstract

Base class for exceptions that want to be thrown 'through' lua. More...

#include <lua_jailbreak_exception.hpp>

Inheritance diagram for lua_jailbreak_exception:
Inheritance graph

Public Member Functions

virtual ~lua_jailbreak_exception () noexcept
 
void store () const noexcept
 Stores a copy the current exception to be rethrown. More...
 

Static Public Member Functions

static void rethrow ()
 Rethrows the stored exception. More...
 

Static Protected Attributes

static lua_jailbreak_exceptionjailbreak_exception = nullptr
 The exception to be rethrown. More...
 

Private Member Functions

virtual lua_jailbreak_exceptionclone () const =0
 Creates a copy of the current exception. More...
 
virtual void execute ()=0
 Executes the exception. More...
 

Static Private Member Functions

static void clear () noexcept
 Clears the current exception. More...
 

Detailed Description

Base class for exceptions that want to be thrown 'through' lua.

Classes inheriting from this class need to use the IMPLEMENT_LUA_JAILBREAK_EXCEPTION macro in the class definition.

Definition at line 25 of file lua_jailbreak_exception.hpp.

Constructor & Destructor Documentation

◆ ~lua_jailbreak_exception()

virtual lua_jailbreak_exception::~lua_jailbreak_exception ( )
inlinevirtualnoexcept

Definition at line 28 of file lua_jailbreak_exception.hpp.

References rethrow(), and store().

Member Function Documentation

◆ clear()

void lua_jailbreak_exception::clear ( )
staticprivatenoexcept

Clears the current exception.

Definition at line 57 of file lua_jailbreak_exception.cpp.

References jailbreak_exception.

Referenced by rethrow().

◆ clone()

virtual lua_jailbreak_exception* lua_jailbreak_exception::clone ( ) const
privatepure virtual

Creates a copy of the current exception.

The copy is allocated with new and is implemented by the IMPLEMENT_LUA_JAILBREAK_EXCEPTION macro.

Note
it's implemented by the subclass to avoid slicing.
Returns
A pointer to a copy of the class on the heap.

Referenced by store().

◆ execute()

virtual void lua_jailbreak_exception::execute ( )
privatepure virtual

Executes the exception.

Throws a copy of the stored jailbreak_exception. The caller is responsible for clearing jailbreak_exception after the throw. The function is implemented by the IMPLEMENT_LUA_JAILBREAK_EXCEPTION macro.

Note
it's implemented by the subclass to avoid slicing.
Precondition
jailbreak_exception != nullptr

Referenced by rethrow().

◆ rethrow()

void lua_jailbreak_exception::rethrow ( )
static

Rethrows the stored exception.

It is safe to call this function is no exception is stored.

Definition at line 33 of file lua_jailbreak_exception.cpp.

References clear(), execute(), and jailbreak_exception.

Referenced by luaW_pcall_internal(), and ~lua_jailbreak_exception().

◆ store()

void lua_jailbreak_exception::store ( ) const
noexcept

Stores a copy the current exception to be rethrown.

Definition at line 21 of file lua_jailbreak_exception.cpp.

References clone(), and jailbreak_exception.

Referenced by ~lua_jailbreak_exception().

Member Data Documentation

◆ jailbreak_exception

lua_jailbreak_exception * lua_jailbreak_exception::jailbreak_exception = nullptr
staticprotected

The exception to be rethrown.

Definition at line 43 of file lua_jailbreak_exception.hpp.

Referenced by clear(), rethrow(), and store().


The documentation for this class was generated from the following files: