welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
module.hpp
Go to the documentation of this file.
1#pragma once
15#include <welder/module.hpp> // the backend-agnostic WELDER_MODULE dispatch
16
27#ifndef WELDER_DETAIL_LUAOPEN_EXPORT
28# if defined(_WIN32)
29# define WELDER_DETAIL_LUAOPEN_EXPORT __declspec(dllexport)
30# else
31# define WELDER_DETAIL_LUAOPEN_EXPORT __attribute__((visibility("default")))
32# endif
33#endif
34
51#define WELDER_DETAIL_MODULE_ENTRY_luabridge(ns, ...) \
52 static void welder_glue_##ns##_luabridge( \
53 ::welder::rods::luabridge::rod::module_type&); \
54 extern "C" WELDER_DETAIL_LUAOPEN_EXPORT int luaopen_##ns( \
55 lua_State* welder_lua_state_) { \
56 ::welder::rods::luabridge::rod::module_type welder_module_var_{ \
57 welder_lua_state_, {#ns}}; \
58 using welder_weld_ = ::welder::detail::module_welder_t< \
59 ::welder::welder<::welder::rods::luabridge::rod> \
60 __VA_OPT__(, ) __VA_ARGS__>; \
61 static_assert( \
62 ::std::is_same_v<typename welder_weld_::module_type, \
63 ::welder::rods::luabridge::rod::module_type>, \
64 "WELDER_MODULE(ns, luabridge, W): W must be a welder::welder over a " \
65 "rod whose module handle is the LuaBridge3 rod's module_type"); \
66 welder_weld_::weld_module<^^ns>( \
67 welder_module_var_, welder_weld_::noop, \
68 [](::welder::rods::luabridge::rod::module_type& welder_glue_m_) { \
69 welder_glue_##ns##_luabridge(welder_glue_m_); \
70 }); \
71 lua_getglobal(welder_lua_state_, #ns); /* the module table */ \
72 lua_pushnil(welder_lua_state_); \
73 lua_setglobal(welder_lua_state_, #ns); /* keep _G clean */ \
74 return 1; \
75 } \
76 static void welder_glue_##ns##_luabridge( \
77 ::welder::rods::luabridge::rod::module_type& module)
welder LuaBridge3 Lua rod (header-only).
Rod-agnostic module entry point — the WELDER_MODULE macro.