-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep and check types for objects transferred between C++ and Lua.
Keep type information for objects transferred from C++ to Lua. Check types transferring back to C++. Crossing the border from C++ to Lua keeps type information for instances of registered classes: - as parameter to Lua functions - as return value of C++ callbacks Obtaining references or pointers to instances of registered classes from Lua fails if the actual type is not the requested: - as parameter to C++ callbacks (raises an error in Lua) - as return value of Lua functions - for pointers (returns nullptr) - for references (throws sel::TypeError) Move datastructures of sel::MetatableRegistry to Lua. This reduces the need to pass the MetatableRegistry through several layers down to the few places it is really used.
- Loading branch information
1 parent
da094ec
commit e4512a2
Showing
19 changed files
with
594 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <exception> | ||
#include <utility> | ||
|
||
namespace sel { | ||
|
||
class SeleneException : public std::exception {}; | ||
|
||
class TypeError : public SeleneException { | ||
std::string _message; | ||
public: | ||
explicit TypeError(std::string expected) | ||
: _message(std::move(expected) | ||
+ " expected, got no object.") {} | ||
explicit TypeError(std::string expected, std::string const & actual) | ||
: _message(std::move(expected) | ||
+ " expected, got " + actual + '.') {} | ||
char const * what() const noexcept override { | ||
return _message.c_str(); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.