8000 math: Allow skipping some advanced functions · ChaiScript/ChaiScript_Extras@6d77ff3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d77ff3

Browse files
committed
math: Allow skipping some advanced functions
1 parent 76d21cd commit 6d77ff3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ chai.add(mathlib);
2828
var result = cos(0.5f)
2929
```
3030

31+
#### Options
32+
33+
Compile with one of the following flags to enable or disable features...
34+
- `CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED` When enabled, will skip some of the advanced math functions.
35+
3136
### String ID
3237

3338
Adds [String ID](https://github.com/foonathan/string_id) support to ChaiScript.
@@ -69,4 +74,4 @@ chai.add(stringmethods);
6974
var input = "Hello, World!"
7075
var output = input.replace("Hello", "Goodbye")
7176
// => "Goodbye, World!"
72-
```
77+
```

include/chaiscript/extras/math.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ namespace chaiscript {
7878
return m;
7979
}
8080

81+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
8182
template<typename Ret, typename Param>
8283
ModulePtr acosh(ModulePtr m = std::make_shared<Module>())
8384
{
@@ -98,6 +99,7 @@ namespace chaiscript {
9899
m->add(chaiscript::fun([](Param p){ return std::atanh(p); }), "atanh");
99100
return m;
100101
}
102+
#endif
101103

102104
// EXPONENTIAL AND LOGARITHMIC FUNCTIONS
103105
template<typename Ret, typename Param>
@@ -141,6 +143,8 @@ namespace chaiscript {
141143
m->add(chaiscript::fun([](Param1 p1, Param2 p2){ return std::modf(p1, p2); }), "modf");
142144
return m;
143145
}
146+
147+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
144148
template<typename Ret, typename Param>
145149
ModulePtr exp2(ModulePtr m = std::make_shared<Module>())
146150
{
@@ -196,6 +200,7 @@ namespace chaiscript {
196200
m->add(chaiscript::fun([](Param1 p1, Param2 p2){ return std::scalbln(p1, p2); }), "scalbln");
197201
return m;
198202
}
203+
#endif
199204

200205
// POWER FUNCTIONS
201206
template<typename Ret, typename Param1, typename Param2>
@@ -212,6 +217,7 @@ namespace chaiscript {
212217
return m;
213218
}
214219

220+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
215221
template<typename Ret, typename Param>
216222
ModulePtr cbrt(ModulePtr m = std::make_shared<Module>())
217223
{
@@ -254,6 +260,7 @@ namespace chaiscript {
254260
m->add(chaiscript::fun([](Param p){ return std::lgamma(p); }), "lgamma");
255261
return m;
256262
}
263+
#endif
257264

258265
// ROUNDING AND REMAINDER FUNCTIONS
259266
template<typename Ret, typename Param>
@@ -277,6 +284,7 @@ namespace chaiscript {
277284
return m;
278285
}
279286

287+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
280288
template<typename Ret, typename Param>
281289
ModulePtr trunc(ModulePtr m = std::make_shared<Module>())
282290
{
@@ -407,6 +415,7 @@ namespace chaiscript {
407415
m->add(chaiscript::fun([](Param p){ return std::fabs(p); }), "fabs");
408416
return m;
409417
}
418+
#endif
410419

411420
template<typename Ret, typename Param>
412421
ModulePtr abs(ModulePtr m = std::make_shared<Module>())
@@ -415,6 +424,7 @@ namespace chaiscript {
415424
return m;
416425
}
417426

427+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
418428
template<typename Ret, typename Param1, typename Param2, typename Param3>
419429
ModulePtr fma(ModulePtr m = std::make_shared<Module>())
420430
{
@@ -429,6 +439,7 @@ namespace chaiscript {
429439
m->add(chaiscript::fun([](Param p){ return std::fpclassify(p); }), "fpclassify");
430440
return m;
431441
}
442+
#endif
432443

433444
template<typename Ret, typename Param>
434445
ModulePtr isfinite(ModulePtr m = std::make_shared<Module>())
@@ -553,6 +564,7 @@ namespace chaiscript {
553564
tanh<float, float>(m);
554565
tanh<long double, long double>(m);
555566

567+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
556568
acosh<double, double>(m);
557569
acosh<float, float>(m);
558570
acosh<long double, long double>(m);
@@ -564,6 +576,7 @@ namespace chaiscript {
564576
atanh<double, double>(m);
565577
atanh<float, float>(m);
566578
atanh<long double, long double>(m);
579+
#endif
567580

568581
// EXPONENTIAL AND LOGARITHMIC FUNCTIONS
569582
exp<double, double>(m);
@@ -590,6 +603,7 @@ namespace chaiscript {
590603
modf<float, float, float *>(m);
591604
modf<long double, long double, long double *>(m);
592605

606+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
593607
exp2<double, double>(m);
594608
exp2<float, float>(m);
595609
exp2<long double, long double>(m);
@@ -621,6 +635,7 @@ namespace chaiscript {
621635
scalbln<double, double, long int>(m);
622636
scalbln<float, float, long int>(m);
623637
scalbln<long double, long double, long int>(m);
638+
#endif
624639

625640
// POWER FUNCTIONS
626641
pow<double, double, double>(m);
@@ -631,6 +646,7 @@ namespace chaiscript {
631646
sqrt<float, float>(m);
632647
sqrt<long double, long double>(m);
633648

649+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
634650
cbrt<double, double>(m);
635651
cbrt<float, float>(m);
636652
cbrt<long double, long double>(m);
@@ -655,6 +671,7 @@ namespace chaiscript {
655671
lgamma<double, double>(m);
656672
lgamma<float, float>(m);
657673
lgamma<long double, long double>(m);
674+
#endif
658675

659676
// ROUNDING AND REMAINDER FUNCTIONS
660677
ceil<double, double>(m);
@@ -669,6 +686,7 @@ namespace chaiscript {
669686
fmod<float, float, float>(m);
670687
fmod<long double, long double, long double>(m);
671688

689+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
672690
trunc<double, double>(m);
673691
trunc<float, float>(m);
674692
trunc<long double, long double>(m);
@@ -743,11 +761,13 @@ namespace chaiscript {
743761
fabs<double, double>(m);
744762
fabs<float, float>(m);
745763
fabs<long double, long double>(m);
764+
#endif
746765

747766
abs<double, double>(m);
748767
abs<float, float>(m);
749768
abs<long double, long double>(m);
750769

770+
#ifndef CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
751771
fma<double, double, double, double>(m);
752772
fma<float, float, float, float>(m);
753773
638E fma<long double, long double, long double, long double>(m);
@@ -756,6 +776,7 @@ namespace chaiscript {
756776
fpclassify<int, float>(m);
757777
fpclassify<int, double>(m);
758778
fpclassify<int, long double>(m);
779+
#endif
759780

760781
isfinite<bool, float>(m);
761782
isfinite<bool, double>(m);

0 commit comments

Comments
 (0)
0