-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lua] added API macros. looks to be pretty nifty!
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef TZ_LUA_API_HPP | ||
#define TZ_LUA_API_HPP | ||
#include "tz/lua/state.hpp" | ||
#include "tz/core/debug.hpp" | ||
|
||
#define LUA_BEGIN(name) int luafn_##name(void* state){ | ||
|
||
#define LUA_END } | ||
#define LUA_REGISTER(name) tz::lua::for_all_states([](tz::lua::state& s){s.assign_func(#name, luafn_##name);}); | ||
|
||
// example: define in a TU | ||
//LUA_BEGIN(test_me_please) | ||
// tz::report("test successful!"); | ||
// return 0; | ||
//LUA_END | ||
|
||
// usage: somewhere during runtime, invoke: | ||
// LUA_REGISTER(test_me_please) | ||
// which makes the function resident to all lua states on both the main thread and the job system worker threads. | ||
|
||
#endif // TZ_LUA_API_HPP |