Quote:
script (1, 1) : INFO : Compiling void print_bool(bool)
script (1, 45) : ERROR : No conversion from 'string@&' to math type available.
Build() failed.
Here is a example that shows it:
// Comment out to see expected behavior with uint8#define BUG_BOOL#include "angelscript.h"#include "scriptstring.h"#include <cassert>asIScriptEngine * engine = 0;asIScriptContext * ctx = 0;void Cleanup(){ if(ctx) { ctx->Release(); ctx = 0; } if(engine) { engine->Release(); engine = 0; }}void MessageCallback(const asSMessageInfo *msg, void *param){ std::string type = "UNKNOWN"; if( msg->type == asMSGTYPE_ERROR ) { type = "ERROR"; } else if( msg->type == asMSGTYPE_WARNING ) { type = "WARN"; } else if( msg->type == asMSGTYPE_INFORMATION ) { type = "INFO"; } printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type.c_str(), msg->message);}void PrintString(std::string & str){ printf("%s\n", str.c_str());}int main(int argc, char **argv){ int r; atexit(Cleanup); engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); if( engine == 0 ) { printf("Failed to create script engine.\n"); return -1; } r = engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true); assert( r >= 0 ); r = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); assert( r >= 0 ); RegisterScriptString(engine); std::string options = asGetLibraryOptions(); if(options.find("AS_MAX_PORTABILITY") != std::string::npos) { printf("This configuration is not being supported. [%s]\n", options.c_str()); return -1; } r = engine->RegisterGlobalFunction("void Print(string &in)", asFUNCTION(PrintString), asCALL_CDECL); assert( r >= 0 );#ifdef BUG_BOOL std::string script = "void print_bool(bool bval) { Print('bval: ' + bval + '\\n'); }";#else std::string script = "void print_bool(uint8 bval) { Print('bval: ' + bval + '\\n'); }";#endif asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE); r = mod->AddScriptSection("script", script.c_str(), script.size()); if( r < 0 ) { printf("AddScriptSection() failed.\n"); return -1; } r = mod->Build(); if( r < 0 ) { printf("Build() failed.\n"); return -1; } ctx = engine->CreateContext(); if( ctx == 0 ) { printf("Failed to create the context.\n"); return -1; }#ifdef BUG_BOOL int funcId = engine->GetModule(0)->GetFunctionIdByDecl("void print_bool(bool bval)");#else int funcId = engine->GetModule(0)->GetFunctionIdByDecl("void print_bool(uint8 bval)");#endif if( funcId < 0 ) { printf("The function was not found.\n"); return -1; } r = ctx->Prepare(funcId); if( r < 0 ) { printf("Failed to prepare the context.\n"); return -1; }#ifdef BUG_BOOL bool val = true;#else unsigned char val = 1;#endif ctx->SetArgByte(0, val); r = ctx->Execute(); if( r != asEXECUTION_FINISHED ) { if( r == asEXECUTION_ABORTED ) { printf("The script was aborted before it could finish. Probably it timed out.\n"); } else if( r == asEXECUTION_EXCEPTION ) { printf("The script ended with an exception.\n"); int funcID = ctx->GetExceptionFunction(); asIScriptFunction *func = engine->GetFunctionDescriptorById(funcID); printf("func: %s\n", func->GetDeclaration()); printf("modl: %s\n", func->GetModuleName()); printf("sect: %s\n", func->GetScriptSectionName()); printf("line: %i\n", ctx->GetExceptionLineNumber()); printf("desc: %s\n", ctx->GetExceptionString()); } else { printf("The script ended for some unforeseen reason (%i).\n", r); } } else { } return 0;}
I am on Windows XP, Visual Studio 2008 (w/ SP1), using version 2.19.1 compiling with source as part of the project. Thanks ahead of time for any advice on this issue!