Initial revision
[luabind.git] / examples / cln / cln_test.cpp
blobc6c38771cac6663dea3efb46eed3a0afa4990179
1 #include <sstream>
3 #include <cln/cln.h>
5 #define LUABIND_DONT_COPY_STRINGS
6 //#define LUABIND_NO_ERROR_CHECKING
8 extern "C"
10 #include "lua.h"
11 #include "lualib.h"
14 #include <luabind/luabind.hpp>
17 void bind_cln(lua_State* L)
19 using namespace luabind;
20 using namespace cln;
22 // real numbers
23 class_<cl_R>(L, "cl_R")
24 .def(constructor<>())
25 .def(constructor<const cl_I&>())
26 .def(constructor<float>())
27 .def(constructor<const char*>())
28 .def(tostring(const_self))
29 .def(-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(const_self <= const_self)
35 .def(const_self < const_self)
36 .def(const_self == const_self)
37 .def(other<int>() + const_self)
38 .def(other<int>() - const_self)
39 .def(other<int>() * const_self)
40 .def(other<int>() / const_self)
41 .def(other<int>() <= const_self)
42 .def(other<int>() < const_self)
43 .def(const_self + other<int>())
44 .def(const_self - other<int>())
45 .def(const_self * other<int>())
46 .def(const_self / other<int>())
47 .def(const_self <= other<int>())
48 .def(const_self < other<int>())
52 // rational numbers
53 class_<cl_RA, cl_R>(L, "cl_RA")
54 .def(constructor<>())
55 .def(constructor<const cl_I&>())
56 .def(constructor<int>())
57 .def(constructor<const char*>())
58 .def(tostring(const_self))
59 .def(-self)
60 .def(const_self + const_self)
61 .def(const_self - const_self)
62 .def(const_self * const_self)
63 .def(const_self / const_self)
64 .def(const_self <= const_self)
65 .def(const_self < const_self)
66 .def(const_self == const_self)
67 .def(other<int>() + const_self)
68 .def(other<int>() - const_self)
69 .def(other<int>() * const_self)
70 .def(other<int>() / const_self)
71 .def(other<int>() <= const_self)
72 .def(other<int>() < const_self)
73 .def(const_self + other<int>())
74 .def(const_self - other<int>())
75 .def(const_self * other<int>())
76 .def(const_self / other<int>())
77 .def(const_self <= other<int>())
78 .def(const_self < other<int>())
81 // integers
82 class_<cl_I, cl_RA>(L, "cl_I")
83 .def(constructor<>())
84 .def(constructor<const cl_I&>())
85 .def(constructor<int>())
86 .def(constructor<const char*>())
87 .def(tostring(const_self))
88 .def(-self)
89 .def(const_self + const_self)
90 .def(const_self - const_self)
91 .def(const_self * const_self)
92 .def(const_self <= const_self)
93 .def(const_self < const_self)
94 .def(const_self == const_self)
95 .def(other<int>() + const_self)
96 .def(other<int>() - const_self)
97 .def(other<int>() * const_self)
98 .def(other<int>() <= const_self)
99 .def(other<int>() < const_self)
100 .def(const_self + other<int>())
101 .def(const_self - other<int>())
102 .def(const_self * other<int>())
103 .def(const_self <= other<int>())
104 .def(const_self < other<int>())
107 function(L, "factorial", &factorial);
108 // function(L, "numerator", &numerator);
109 // function(L, "denominator", &denominator);
110 // function(L, "max", &max);
111 // function(L, "min", &min);
112 // function(L, "floor", &floor1);
113 // function(L, "ceiling", &ceiling1);
114 // function(L, "truncate", &truncate1);
115 // function(L, "round", &round1);
116 // function(L, "mod", &cln::mod);
117 // function(L, "rem", &rem);
118 // function(L, "sqrt", &sqrt);
119 // function(L, "exp", &exp);
120 // function(L, "ln", &ln);
121 // function(L, "log", &log);
124 int main()
126 lua_State* L = lua_open();
127 lua_baselibopen(L);
128 lua_mathlibopen(L);
129 luabind::open(L);
131 bind_cln(L);
133 lua_dofile(L, "cln_test.lua");
135 lua_close(L);
136 return 0;