Add infrastructure to test embedding API.
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@
|
||||
|
||||
static int runRepl()
|
||||
{
|
||||
WrenVM* vm = createVM();
|
||||
WrenVM* vm = createVM(NULL);
|
||||
|
||||
printf("\\\\/\"-\n");
|
||||
printf(" \\_/ wren v0.0.0\n");
|
||||
@@ -50,7 +50,7 @@ int main(int argc, const char* argv[])
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
runFile(argv[1]);
|
||||
runFile(NULL, argv[1]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+4
-4
@@ -4,11 +4,11 @@
|
||||
#include "io.h"
|
||||
#include "vm.h"
|
||||
|
||||
WrenVM* createVM()
|
||||
WrenVM* createVM(WrenBindForeignMethodFn bindForeign)
|
||||
{
|
||||
WrenConfiguration config;
|
||||
|
||||
config.bindForeignMethodFn = NULL;
|
||||
config.bindForeignMethodFn = bindForeign;
|
||||
config.loadModuleFn = readModule;
|
||||
|
||||
// Since we're running in a standalone process, be generous with memory.
|
||||
@@ -22,7 +22,7 @@ WrenVM* createVM()
|
||||
return wrenNewVM(&config);
|
||||
}
|
||||
|
||||
void runFile(const char* path)
|
||||
void runFile(WrenBindForeignMethodFn bindForeign, const char* path)
|
||||
{
|
||||
// Use the directory where the file is as the root to resolve imports
|
||||
// relative to.
|
||||
@@ -42,7 +42,7 @@ void runFile(const char* path)
|
||||
exit(66);
|
||||
}
|
||||
|
||||
WrenVM* vm = createVM();
|
||||
WrenVM* vm = createVM(bindForeign);
|
||||
|
||||
WrenInterpretResult result = wrenInterpret(vm, path, source);
|
||||
|
||||
|
||||
+2
-2
@@ -4,11 +4,11 @@
|
||||
#include "wren.h"
|
||||
|
||||
// Creates a new Wren VM with the CLI's module loader and other configuration.
|
||||
WrenVM* createVM();
|
||||
WrenVM* createVM(WrenBindForeignMethodFn bindForeign);
|
||||
|
||||
// Executes the Wren script at [path] in a new VM.
|
||||
//
|
||||
// Exits if the script failed or could not be loaded.
|
||||
void runFile(const char* path);
|
||||
void runFile(WrenBindForeignMethodFn bindForeign, const char* path);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user