Fortunately this is quite easy to fix (changing the AngelScript type to 1 byte as well, should fix the problem), and the next release will have this fix.
In the sample code, available from the angelscript page, there are some functions that return bstrs to the script. Example:
asBSTR bstrFormatInt(int number)
// We must allocate a new bstr that the script engine will free afterwards
asBSTR bstr = asBStrAlloc(str.GetLength());
memcpy(bstr, str, str.GetLength());
Remember that if you receive a bstr by value in the parameters you are responsible to releasing the memory. Therefore I recommend that you always declare your functions to receive bstrs by reference, it would also avoid an internal copy of the bstr. www.AngelCode.com
- game development and more...AngelScript
- free scripting library
I did some debugging, and as it happens you stumbled upon a bug or perhaps a design flaw in AngelScript. MSVC C++ treats the bool type as a 1 byte boolean type, whereas AngelScript treats it as a 4 byte boolean type. When C++ returns the boolean value it does so in the lower 8 bits of EAX, leaving the higher 24 bits with their previous value, meaning that EAX will almost always be different from 0.