1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 07:55:07 +00:00

LibJS+LibWeb: Move native JS functions into dedicated member functions

Instead of implementing every native function as a lambda function,
use static member functions instead.

This makes it easier to navigate the code + backtraces look nicer. :^)
This commit is contained in:
Andreas Kling 2020-03-28 23:10:37 +01:00
parent 7c4e53f31e
commit 56936b97d0
20 changed files with 233 additions and 149 deletions

View file

@ -32,18 +32,21 @@ namespace JS {
MathObject::MathObject()
{
put_native_function("random", [](Interpreter&) {
#ifdef __serenity__
double r = (double)arc4random() / (double)UINT32_MAX;
#else
double r = (double)rand() / (double)RAND_MAX;
#endif
return Value(r);
});
put_native_function("random", random);
}
MathObject::~MathObject()
{
}
Value MathObject::random(Interpreter&)
{
#ifdef __serenity__
double r = (double)arc4random() / (double)UINT32_MAX;
#else
double r = (double)rand() / (double)RAND_MAX;
#endif
return Value(r);
}
}