Update version.hpp for v0.9.
[luabind.git] / examples / cln / cln_test.cpp
blob24c622af974974ae9bd4c4f327d0b2c0635b2b9a
1 #include <cln/cln.h>
3 extern "C"
5 #include "lua.h"
6 #include "lualib.h"
7 #include "lauxlib.h"
10 #include <luabind/luabind.hpp>
12 void bind_cln(lua_State* L)
14 using namespace luabind;
15 using namespace cln;
17 module(L)
19 // real numbers
20 class_<cl_R>("cl_R")
21 .def(constructor<>())
22 .def(constructor<const cl_I&>())
23 .def(constructor<float>())
24 .def(constructor<const char*>())
25 .def(tostring(const_self))
26 .def(-self)
27 .def(const_self + const_self)
28 .def(const_self - const_self)
29 .def(const_self * const_self)
30 .def(const_self / const_self)
31 .def(const_self <= const_self)
32 .def(const_self < const_self)
33 .def(const_self == const_self)
34 .def(other<int>() + const_self)
35 .def(other<int>() - const_self)
36 .def(other<int>() * const_self)
37 .def(other<int>() / const_self)
38 .def(other<int>() <= const_self)
39 .def(other<int>() < const_self)
40 .def(const_self + other<int>())
41 .def(const_self - other<int>())
42 .def(const_self * other<int>())
43 .def(const_self / other<int>())
44 .def(const_self <= other<int>())
45 .def(const_self < other<int>())
48 // rational numbers
49 class_<cl_RA, cl_R>("cl_RA")
50 .def(constructor<>())
51 .def(constructor<const cl_I&>())
52 .def(constructor<int>())
53 .def(constructor<const char*>())
54 .def(tostring(const_self))
55 .def(-self)
56 .def(const_self + const_self)
57 .def(const_self - const_self)
58 .def(const_self * const_self)
59 .def(const_self / const_self)
60 .def(const_self <= const_self)
61 .def(const_self < const_self)
62 .def(const_self == const_self)
63 .def(other<int>() + const_self)
64 .def(other<int>() - const_self)
65 .def(other<int>() * const_self)
66 .def(other<int>() / const_self)
67 .def(other<int>() <= const_self)
68 .def(other<int>() < const_self)
69 .def(const_self + other<int>())
70 .def(const_self - other<int>())
71 .def(const_self * other<int>())
72 .def(const_self / other<int>())
73 .def(const_self <= other<int>())
74 .def(const_self < other<int>())
77 // integers
78 class_<cl_I, cl_RA>("cl_I")
79 .def(constructor<>())
80 .def(constructor<const cl_I&>())
81 .def(constructor<int>())
82 .def(constructor<const char*>())
83 .def(tostring(const_self))
84 .def(-self)
85 .def(const_self + const_self)
86 .def(const_self - const_self)
87 .def(const_self * const_self)
88 .def(const_self <= const_self)
89 .def(const_self < const_self)
90 .def(const_self == const_self)
91 .def(other<int>() + const_self)
92 .def(other<int>() - const_self)
93 .def(other<int>() * const_self)
94 .def(other<int>() <= const_self)
95 .def(other<int>() < const_self)
96 .def(const_self + other<int>())
97 .def(const_self - other<int>())
98 .def(const_self * other<int>())
99 .def(const_self <= other<int>())
100 .def(const_self < other<int>())
103 def("factorial", &cln::factorial),
104 def("sqrt", (const cl_R(*)(const cl_R&))&cln::sqrt)
108 int main()
110 lua_State* L = lua_open();
111 lua_baselibopen(L);
112 lua_mathlibopen(L);
113 luabind::open(L);
115 bind_cln(L);
117 lua_dofile(L, "cln_test.lua");
119 lua_close(L);
120 return 0;