diff --git a/doc/site/embedding/index.markdown b/doc/site/embedding/index.markdown index 24bbbc26..6f89c214 100644 --- a/doc/site/embedding/index.markdown +++ b/doc/site/embedding/index.markdown @@ -102,13 +102,35 @@ this header handles the differences in calling conventions between C and C++: ## Creating a Wren VM Once you've integrated the code into your executable, you need to create a -virtual machine. To do that, you create a +virtual machine. To do that, you create a `WrenConfiguration` object and +initialize it. + +
WrenConfiguration config;
wrenInitConfiguration(&config);
+
This gives you a basic configuration that has reasonable defaults for
-everything. If you don't need to tweak stuff, you can leave it at that. We'll
-[learn more][configuration] about what you can configure later.
+everything. We'll [learn more][configuration] about what you can configure later,
+but for now we'll just add the `writeFn`, so that we can print text.
+
+First we need a function that will do something with the output
+that Wren sends us from `System.print` (or `System.write`). *Note that it doesn't
+include a newline in the output.*
+
+
+void writeFn(WrenVM* vm, const char* text) {
+ printf("%s", text);
+}
+
+
+And then, we update the configuration to point to it.
+
++ WrenConfiguration config; + config.writeFn = &writeFn; + wrenInitConfiguration(&config); +[configuration]: configuring-the-vm.html