mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-math: rename mrb_math variable to math
unify declaration with initialization for cleaner code. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -697,56 +697,55 @@ math_erfc(mrb_state *mrb, mrb_value obj)
|
||||
void
|
||||
mrb_mruby_math_gem_init(mrb_state* mrb)
|
||||
{
|
||||
struct RClass *mrb_math;
|
||||
mrb_math = mrb_define_module(mrb, "Math");
|
||||
struct RClass *math = mrb_define_module(mrb, "Math");
|
||||
|
||||
mrb_define_class_under_id(mrb, mrb_math, MRB_SYM(DomainError), E_STANDARD_ERROR);
|
||||
mrb_define_class_under_id(mrb, math, MRB_SYM(DomainError), E_STANDARD_ERROR);
|
||||
|
||||
#ifdef M_PI
|
||||
mrb_define_const_id(mrb, mrb_math, MRB_SYM(PI), mrb_float_value(mrb, M_PI));
|
||||
mrb_define_const_id(mrb, math, MRB_SYM(PI), mrb_float_value(mrb, M_PI));
|
||||
#else
|
||||
mrb_define_const_id(mrb, mrb_math, MRB_SYM(PI), mrb_float_value(mrb, atan(1.0)*4.0));
|
||||
mrb_define_const_id(mrb, math, MRB_SYM(PI), mrb_float_value(mrb, atan(1.0)*4.0));
|
||||
#endif
|
||||
|
||||
#ifdef M_E
|
||||
mrb_define_const_id(mrb, mrb_math, MRB_SYM(E), mrb_float_value(mrb, M_E));
|
||||
mrb_define_const_id(mrb, math, MRB_SYM(E), mrb_float_value(mrb, M_E));
|
||||
#else
|
||||
mrb_define_const_id(mrb, mrb_math, MRB_SYM(E), mrb_float_value(mrb, exp(1.0)));
|
||||
mrb_define_const_id(mrb, math, MRB_SYM(E), mrb_float_value(mrb, exp(1.0)));
|
||||
#endif
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(sin), math_sin, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(cos), math_cos, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(tan), math_tan, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(sin), math_sin, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(cos), math_cos, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(tan), math_tan, MRB_ARGS_REQ(1));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(asin), math_asin, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(acos), math_acos, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(atan), math_atan, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(atan2), math_atan2, MRB_ARGS_REQ(2));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(asin), math_asin, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(acos), math_acos, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(atan), math_atan, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(atan2), math_atan2, MRB_ARGS_REQ(2));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(sinh), math_sinh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(cosh), math_cosh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(tanh), math_tanh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(sinh), math_sinh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(cosh), math_cosh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(tanh), math_tanh, MRB_ARGS_REQ(1));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(asinh), math_asinh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(acosh), math_acosh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(atanh), math_atanh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(asinh), math_asinh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(acosh), math_acosh, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(atanh), math_atanh, MRB_ARGS_REQ(1));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(exp), math_exp, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(expm1), math_expm1, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(log1p), math_log1p, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(log), math_log, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(log2), math_log2, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(log10), math_log10, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(sqrt), math_sqrt, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(cbrt), math_cbrt, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(exp), math_exp, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(expm1), math_expm1, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(log1p), math_log1p, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(log), math_log, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(log2), math_log2, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(log10), math_log10, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(sqrt), math_sqrt, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(cbrt), math_cbrt, MRB_ARGS_REQ(1));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(frexp), math_frexp, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(ldexp), math_ldexp, MRB_ARGS_REQ(2));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(frexp), math_frexp, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(ldexp), math_ldexp, MRB_ARGS_REQ(2));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(hypot), math_hypot, MRB_ARGS_REQ(2));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(hypot), math_hypot, MRB_ARGS_REQ(2));
|
||||
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(erf), math_erf, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, mrb_math, MRB_SYM(erfc), math_erfc, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(erf), math_erf, MRB_ARGS_REQ(1));
|
||||
mrb_define_module_function_id(mrb, math, MRB_SYM(erfc), math_erfc, MRB_ARGS_REQ(1));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user