Skip to content

Commit fbcde0f

Browse files
committed
Initial check-in of chaiscript_extras with std::floor support
0 parents  commit fbcde0f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
In this repository will live user contributed wrappers
2+
for ChaiScript.
3+
4+

include/chaiscript/extras/math.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <cmath>
2+
3+
namespace chaiscript {
4+
namespace extras {
5+
namespace math {
6+
template<typename Ret, typename Param>
7+
ModulePtr floor(ModulePtr m = std::make_shared<Module>())
8+
{
9+
// using the overloads provided by C++11
10+
// http://www.cplusplus.com/reference/cmath/floor/
11+
m->add(chaiscript::fun(static_cast<Ret (Param)>(&std::floor)), "floor");
12+
return m;
13+
}
14+
15+
ModulePtr bootstrap(const std::string &type, ModulePtr m = std::make_shared<Module>())
16+
{
17+
floor<double, double>(m);
18+
floor<long double, long double>(m);
19+
floor<float, float>(m);
20+
21+
return m;
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)