mozart/mozart2 — pull request #7 by kennytm (2012-09-09 20:03:49+00:00)
Title: Fix `build(VM, bool)` and add `build(VM, const char*)`.

Because C++ allows implicitly converting a pointer to bool, the following program will wrongly create a Boolean instead of an Atom or emit a compile-time error. This, for example, makes `OS.getEnv` returns just `true` instead of a real String/Atom.

```c++
#include
#include

using namespace mozart;

struct TestEnvironment : VirtualMachineEnvironment {
TestEnvironment() : VirtualMachineEnvironment(true) {}

virtual UUID genUUID() {
return UUID("{8303bb2b-2d34-42e6-9726-7834ede651f1}");
}
};

int main() {
TestEnvironment environment;
VirtualMachine virtual_machine (environment);
VM vm (&virtual_machine);

const char* foo = "1234";
auto node = build(vm, foo);
std::cout << repr(vm, node) << std::endl; // prints 'true'

return 0;
}
```

This pull request fixes the signature of `build` to only accept real booleans in `build(vm, bool)`. Also, I added `build(vm, const char*)` to perform the UTF-8-to-16 conversion and produce an atom.