aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sol2/examples/source/c_call.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-08-19 19:48:10 -0400
committerClyne Sullivan <clyne@bitgloo.com>2022-08-19 19:48:10 -0400
commitc467671ae8b6ec161c17e86f3383fd0625f755b8 (patch)
treefd126d5721256b15c0d71e4c47033e341bdb7816 /lib/sol2/examples/source/c_call.cpp
parentda0913771538fd9b1ca538615fd9aa0388608466 (diff)
remove sol2 (will re-add as submodule)
Diffstat (limited to 'lib/sol2/examples/source/c_call.cpp')
-rw-r--r--lib/sol2/examples/source/c_call.cpp50
1 files changed, 0 insertions, 50 deletions
diff --git a/lib/sol2/examples/source/c_call.cpp b/lib/sol2/examples/source/c_call.cpp
deleted file mode 100644
index 4758705..0000000
--- a/lib/sol2/examples/source/c_call.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#define SOL_ALL_SAFETIES_ON 1
-#include <sol/sol.hpp>
-
-#include "assert.hpp"
-
-int f1(int) { return 32; }
-
-int f2(int, int) { return 1; }
-
-struct fer {
- double f3(int, int) {
- return 2.5;
- }
-};
-
-
-int main() {
-
- sol::state lua;
- // overloaded function f
- lua.set("f", sol::c_call<sol::wrap<decltype(&f1), &f1>, sol::wrap<decltype(&f2), &f2>, sol::wrap<decltype(&fer::f3), &fer::f3>>);
- // singly-wrapped function
- lua.set("g", sol::c_call<sol::wrap<decltype(&f1), &f1>>);
- // without the 'sol::wrap' boilerplate
- lua.set("h", sol::c_call<decltype(&f2), &f2>);
- // object used for the 'fer' member function call
- lua.set("obj", fer());
-
- // call them like any other bound function
- lua.script("r1 = f(1)");
- lua.script("r2 = f(1, 2)");
- lua.script("r3 = f(obj, 1, 2)");
- lua.script("r4 = g(1)");
- lua.script("r5 = h(1, 2)");
-
- // get the results and see
- // if it worked out
- int r1 = lua["r1"];
- c_assert(r1 == 32);
- int r2 = lua["r2"];
- c_assert(r2 == 1);
- double r3 = lua["r3"];
- c_assert(r3 == 2.5);
- int r4 = lua["r4"];
- c_assert(r4 == 32);
- int r5 = lua["r5"];
- c_assert(r5 == 1);
-
- return 0;
-}