SDOM - Simple SDL Document Object Model
A lightweight, extensible Document Object Model for SDL-based applications.
Loading...
Searching...
No Matches
lua_BindHelpers.hpp
Go to the documentation of this file.
1// lua_BindHelpers.hpp --- Lua binding helpers
2#pragma once
3
4// #include <SDOM/SDOM.hpp>
5
6namespace SDOM
7{
8 class Event;
9
10
11 // Basic binders (usertype method, CoreForward table entry, and optional global alias)
12 // - objHandleType: sol::usertype<Core>&
13 // - coreTable: sol::table&
14 // - lua: sol::state_view
15
16 // Zero-arg void functions (quit, shutdown, etc.)
17 void bind_noarg(const std::string& name, std::function<void()> func,
18 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
19
20 // Single-table argument: void(const sol::table&)
21 void bind_table(const std::string& name, std::function<void(const sol::table&)> func,
22 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
23
24 // Single-string argument: void(const std::string&)
25 void bind_string(const std::string& name, std::function<void(const std::string&)> func,
26 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
27
28 // Single-bool argument: void(bool)
29 void bind_bool_arg(const std::string& name, std::function<void(bool)> func,
30 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
31
32 // Single-DisplayHandle (or name) argument: void(const DisplayHandle&)
33 void bind_do_arg(const std::string& name, std::function<void(const DisplayHandle&)> func,
34 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
35
36 // Single-sol::object argument: void(const sol::object&)
37 void bind_object_arg(const std::string& name, std::function<void(const sol::object&)> func,
38 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
39
40 // Returners (no-arg) -----------------------------------------------------------
41 // Return DisplayHandle: DisplayHandle ()
42 void bind_return_displayobject(const std::string& name, std::function<DisplayHandle()> func,
43 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
44
45 // Return bool: bool ()
46 void bind_return_bool(const std::string& name, std::function<bool()> func,
47 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
48
49 // Return string: std::string ()
50 void bind_return_string(const std::string& name, std::function<std::string()> func,
51 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
52
53 // Return float: float ()
54 void bind_return_float(const std::string& name, std::function<float()> func,
55 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
56
57 // Return int: int ()
58 void bind_return_int(const std::string& name, std::function<int()> func,
59 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
60
61 // Return vector<DisplayHandle>: std::vector<DisplayHandle> ()
62 void bind_return_vector_do(const std::string& name, std::function<std::vector<DisplayHandle>()> func,
63 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
64
65 // Return vector<string>: std::vector<std::string> ()
66 void bind_return_vector_string(const std::string& name, std::function<std::vector<std::string>()> func,
67 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
68
69 // String+table -> DisplayHandle
70 void bind_string_table_return_do(const std::string& name, std::function<DisplayHandle(const std::string&, const sol::table&)> func,
71 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
72
73 void bind_string_table_return_asset(const std::string& name, std::function<AssetHandle(const std::string&, const sol::table&)> func,
74 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
75
76 // String -> DisplayHandle
77 void bind_string_return_do(const std::string& name, std::function<DisplayHandle(const std::string&)> func,
78 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
79
80 void bind_string_return_asset(const std::string& name, std::function<AssetHandle(const std::string&)> func,
81 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
82
83 // String -> bool
84 void bind_string_return_bool(const std::string& name, std::function<bool(const std::string&)> func,
85 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
86
87 // Callback registration binders ------------------------------------------------
88 // Each accepts the registrar (a function that takes a std::function<...> to register the host callback).
89
90 // bool() callbacks (registerOnInit, registerOnUnitTest)
91 void bind_callback_bool(const std::string& name, std::function<void(std::function<bool()>)> registrar,
92 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
93
94 // void() callbacks (registerOnQuit, registerOnRender)
95 void bind_callback_void(const std::string& name, std::function<void(std::function<void()>)> registrar,
96 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
97
98 // update(float) callbacks
99 void bind_callback_update(const std::string& name, std::function<void(std::function<void(float)>)> registrar,
100 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
101
102 // event(const Event&) callbacks
103 void bind_callback_event(const std::string& name, std::function<void(std::function<void(const Event&)>)> registrar,
104 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
105
106 // resize(int,int) callbacks
107 void bind_callback_resize(const std::string& name, std::function<void(std::function<void(int,int)>)> registrar,
108 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
109
110 // Custom forwarder: string + function -> calls host function(registerOn style)
111 void bind_string_function_forwarder(const std::string& name, std::function<void(const std::string&, const sol::function&)> func,
112 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
113
114 // Bind a function that accepts either a name (string/table) or a DisplayHandle
115 // and dispatches to the appropriate host-side overload (e.g. setStage/setRootNode alias)
116 void bind_name_or_handle(const std::string& name, std::function<void(const std::string&)> nameFunc, std::function<void(const DisplayHandle&)> handleFunc,
117 sol::usertype<Core>& objHandleType, sol::table& coreTable, sol::state_view lua);
118
119
120} // namespace SDOM
Definition SDOM_AssetHandle.hpp:13
Definition SDOM_DisplayHandle.hpp:24
Definition SDOM_Event.hpp:55
Contains all core classes and utilities for the SDOM library.
Definition lua_BindHelpers.hpp:7
void bind_string_return_asset(const std::string &name, std::function< AssetHandle(const std::string &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:369
void bind_return_int(const std::string &name, std::function< int()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:245
void bind_bool_arg(const std::string &name, std::function< void(bool)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:80
void bind_do_arg(const std::string &name, std::function< void(const DisplayHandle &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:102
void bind_return_bool(const std::string &name, std::function< bool()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:188
void bind_string_return_do(const std::string &name, std::function< DisplayHandle(const std::string &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:348
void bind_string_table_return_asset(const std::string &name, std::function< AssetHandle(const std::string &, const sol::table &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:325
void bind_callback_void(const std::string &name, std::function< void(std::function< void()>)> registrar, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:440
void bind_callback_update(const std::string &name, std::function< void(std::function< void(float)>)> registrar, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:470
void bind_string_table_return_do(const std::string &name, std::function< DisplayHandle(const std::string &, const sol::table &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:302
void bind_return_float(const std::string &name, std::function< float()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:226
void bind_string_return_bool(const std::string &name, std::function< bool(const std::string &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:390
void bind_string(const std::string &name, std::function< void(const std::string &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:58
void bind_callback_resize(const std::string &name, std::function< void(std::function< void(int, int)>)> registrar, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:530
void bind_return_string(const std::string &name, std::function< std::string()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:207
void bind_object_arg(const std::string &name, std::function< void(const sol::object &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:145
void bind_callback_bool(const std::string &name, std::function< void(std::function< bool()>)> registrar, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:409
void bind_noarg(const std::string &name, std::function< void()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:14
void bind_return_vector_do(const std::string &name, std::function< std::vector< DisplayHandle >()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:264
void bind_return_displayobject(const std::string &name, std::function< DisplayHandle()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:167
void bind_return_vector_string(const std::string &name, std::function< std::vector< std::string >()> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:283
void bind_name_or_handle(const std::string &name, std::function< void(const std::string &)> nameFunc, std::function< void(const DisplayHandle &)> handleFunc, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:582
void bind_table(const std::string &name, std::function< void(const sol::table &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:36
void bind_callback_event(const std::string &name, std::function< void(std::function< void(const Event &)>)> registrar, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:500
void bind_string_function_forwarder(const std::string &name, std::function< void(const std::string &, const sol::function &)> func, sol::usertype< Core > &objHandleType, sol::table &coreTable, sol::state_view lua)
Definition lua_BindHelpers.cpp:560