Move meta and random to "aux" modules.
Wren now has three classes of modules: - The one magic "core" module that's built in and always needed. - Auxiliary libraries like "meta" and "random". These do not have any dependencies, so can be used even when you embed Wren inside an application. But they're also optional and can be disabled if you don't need them. - CLI modules. These ones need libuv and are tied to the CLI wrapper around the VM.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// Generated automatically from src/module/random.wren. Do not edit.
|
||||
static const char* randomModuleSource =
|
||||
"foreign class Random {\n"
|
||||
" construct new() {\n"
|
||||
" seed_()\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" construct new(seed) {\n"
|
||||
" if (seed is Num) {\n"
|
||||
" seed_(seed)\n"
|
||||
" } else if (seed is Sequence) {\n"
|
||||
" if (seed.isEmpty) Fiber.abort(\"Sequence cannot be empty.\")\n"
|
||||
"\n"
|
||||
" // TODO: Empty sequence.\n"
|
||||
" var seeds = []\n"
|
||||
" for (element in seed) {\n"
|
||||
" if (!(element is Num)) Fiber.abort(\"Sequence elements must all be numbers.\")\n"
|
||||
"\n"
|
||||
" seeds.add(element)\n"
|
||||
" if (seeds.count == 16) break\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" // Cycle the values to fill in any missing slots.\n"
|
||||
" var i = 0\n"
|
||||
" while (seeds.count < 16) {\n"
|
||||
" seeds.add(seeds[i])\n"
|
||||
" i = i + 1\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" seed_(\n"
|
||||
" seeds[0], seeds[1], seeds[2], seeds[3],\n"
|
||||
" seeds[4], seeds[5], seeds[6], seeds[7],\n"
|
||||
" seeds[8], seeds[9], seeds[10], seeds[11],\n"
|
||||
" seeds[12], seeds[13], seeds[14], seeds[15])\n"
|
||||
" } else {\n"
|
||||
" Fiber.abort(\"Seed must be a number or a sequence of numbers.\")\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" foreign seed_()\n"
|
||||
" foreign seed_(seed)\n"
|
||||
" foreign seed_(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16)\n"
|
||||
"\n"
|
||||
" foreign float()\n"
|
||||
" float(max) { float() * max }\n"
|
||||
" float(min, max) { float() * (max - min) + min }\n"
|
||||
"\n"
|
||||
" foreign int()\n"
|
||||
" int(max) { (float() * max).floor }\n"
|
||||
" int(min, max) { (float() * (max - min)).floor + min }\n"
|
||||
"}\n";
|
||||
Reference in New Issue
Block a user