Sign in to follow this  
brightening-eyes

function registration is very very slow

Recommended Posts

i'm trying to make a game engine using AngelScript when i registered some of my functions, and tryed to testit, it show's a console window and nothing happens for a while what i have to do? this is the engine's source code:

http://amir-ramezani.3owl.com/AGC.zip

what i've done incorrectly?

what is the problem?

these are some of my functions that i've registered

i want to work on Artificial intelligence, 3d renderring and many many functions

if it wants to be slow, it can't be successfull

i want to make it very fast

thanks in advance

Share this post


Link to post
Share on other sites

You do know that -O3 doesn't guarantee more performance, don't you? In fact -O3 has a quite high probability of performing worse than -O2. At least that is what I've read on various forums, though I don't have personal experience with either.

Share this post


Link to post
Share on other sites

Sounds like the error occurs in one of the calls to register the interface. You're probably passing an invalid declaration that the parser doesn't understand.

 

Look for the function that returns an error. You're checking the return values, aren't you?

Share this post


Link to post
Share on other sites

The recommendation is that you at least do an assert to verify that the return code is not negative after each call. That way when running the application in debug mode the debugger will immediately on the call that caused the error, thus making it easy to find problems.

 

For example, take a look at how the std::string is registered in the add-on:

r = engine->RegisterObjectType("string", sizeof(string), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT,  "void f()",                    asFUNCTION(ConstructString), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT,  "void f(const string &in)",    asFUNCTION(CopyConstructString), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("string", asBEHAVE_DESTRUCT,   "void f()",                    asFUNCTION(DestructString),  asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "string &opAssign(const string &in)", asMETHODPR(string, operator =, (const string&), string&), asCALL_THISCALL); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "string &opAddAssign(const string &in)", asFUNCTION(AddAssignStringToString), asCALL_CDECL_OBJLAST); assert( r >= 0 );

I see you have registered the message callback, but alone it will not be able to tell you which call caused the error. I've tried to make the engine provide as much information as possible about the cause, but without checking the return code for each call it can be very difficult to locate the error.

 

Once you find the call that gives the error, I'm pretty sure you'll soon figure out how to fix the problem. If not, please post more detailed information about the problem so we can provide more specific help.

 

Regards,

Andreas

Edited by Andreas Jonsson

Share this post


Link to post
Share on other sites

I downloaded your code and see that you already have asserts to check the return value. I guess you're not compiling the code in debug mode which is why the assert doesn't break on the call that returns error. 

 

When compiling in release mode, the compiler removes the assert calls. Try switching to debug mode and run you application. I'm sure it will show you where the error is.

Share this post


Link to post
Share on other sites

Do you know what type the void* pointer is truly referring to in C++? If you do, then you can just register the function as returning a handle or reference to that type.

 

If you do not know what type the void* pointer is really referring to, and if you don't need to provide a true sandbox environment in the scripts, then you can register a value type to represent the void* pointer, e.g. 

 

r = engine->RegisterObjectType("void_ptr", sizeof(void*), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_PRIMITIVE); assert( r >= 0 );

 

Regards,

Andreas

Share this post


Link to post
Share on other sites
i tryed your code and it worked fine i fixed all of the errors and assert messages don't shown but, that error: expected identifier it doesn't give any assert message after that, i wrote a simple script and test it! but when i select compile from the compile menu (the gui of my engine), it hang's my computer what is the problem? and a request: please add function in the asSMessageInfo structure: it allow's to fined the errors better and it is very good for configuration now what should i do? at last, i have to remember that, i updated the source now i think these problems make me totaly blind

Share this post


Link to post
Share on other sites

If I knew what you were doing when the message show up I would definitely try to find a way to improve the information provided by AngelScript.

 

Try setting a breakpoint in your message callback to see what part of your code that triggers the message from AngelScript, then show me the call that you're making to AngelScript. This will allow me to figure out how to improve the message.

Share this post


Link to post
Share on other sites

i don't know where should i set a breakpoint

i don't know where this happen's

but, i changed some of the registered functions (provided by AngelScript): RegisterScriptArray and some others, and errors changed to 1 but my application crashe's after that error: i think the problem is there

it doesn't give any file, any line and any function or type!

now how can i fined it?

no "expected identifier" and any of the errors!

this happen's like this:

 

error

file:

line:

 

and an OK button that i provided (the errors shown in MessageBox)

 

 

i want to register more functions but first of all, i have to correct these

thanks

Share this post


Link to post
Share on other sites
I want to help, I truly do. But you're not giving me much information I can investigate.

At least debug the application to step through the execution line by line until you see there error and then tell me what line the crash happens on.

Alternatively comment out chunks of your code and test. Do this iteratively until the error goes away. Then you'll know the crash occurred in the last part you commented.

Share this post


Link to post
Share on other sites

why the compiler crashes?

i don't know about that: i'm working on that

this is my configuration Code:

/**
*allegro game creator
*copyright(se)2013 amir rezaa ramezani
*this file is part of AGC
*distributed under the boost software license, version 1.0
*please see license.txt file in the main directory of the project
***/
/*
*includes
*/
#include <angelscript.h>
#include <enet/enet.h>
#include <scriptany/scriptany.h>
#include <scriptarray/scriptarray.h>
#include <scriptbuilder/scriptbuilder.h>
#include <scriptdictionary/scriptdictionary.h>
#include <scriptfile/scriptfile.h>
#include <scripthandle/scripthandle.h>
#include <scriptmath/scriptmath.h>
#include <scriptmath/scriptmathcomplex.h>
#include <scriptstdstring/scriptstdstring.h>
#include <weakref/weakref.h>
#ifdef __MINGW32__
#include <_mingw.h>
#endif //__MINGW32__
#include <allegro5/allegro.h>
#include <allegro5/allegro_acodec.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_color.h>
#include <allegro5/allegro_direct3d.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_memfile.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_opengl.h>
#include <allegro5/allegro_physfs.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_ttf.h>
#ifdef __WINDOWS__
#include <allegro5/allegro_windows.h>
#endif //__WINDOWS__
#include <bcl/bcl.h>
#include "configure.h"
#include "functions.h"
#include "messagecallback.h"
/*
*configure the engine
*/
void configure(asIScriptEngine *scriptengine)
{
int r= scriptengine->SetMessageCallback(asFUNCTION(messagecallback), 0, asCALL_CDECL);
assert(r>=0);
r= scriptengine->SetEngineProperty(asEP_ALLOW_MULTILINE_STRINGS, true);
assert(r>=0);
r=scriptengine->SetEngineProperty(asEP_ALLOW_IMPLICIT_HANDLE_TYPES, true);
assert(r>=0);
r=scriptengine->SetEngineProperty(asEP_REQUIRE_ENUM_SCOPE, true);
assert(r>=0);
r=scriptengine->SetEngineProperty(asEP_INCLUDE_JIT_INSTRUCTIONS , true);
assert(r>=0);
r=scriptengine->SetEngineProperty(asEP_EXPAND_DEF_ARRAY_TO_TMPL , true);
assert(r>=0);
r=scriptengine->SetEngineProperty(asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT , true);
assert(r>=0);
r=scriptengine->SetJITCompiler(scripting::scriptcompiler);
assert(r>=0);
RegisterScriptArray(scriptengine, true);
RegisterStdString(scriptengine);
RegisterStdStringUtils(scriptengine);
RegisterScriptAny(scriptengine);
RegisterScriptDictionary(scriptengine);
RegisterScriptFile(scriptengine);
RegisterScriptHandle(scriptengine);
RegisterScriptMath(scriptengine);
RegisterScriptMathComplex(scriptengine);
RegisterScriptWeakRef(scriptengine);
r = scriptengine->RegisterObjectType("voidptr", sizeof(void*), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_PRIMITIVE);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_huffman_compress(string input, string output, uint insize)", asFUNCTION(Huffman_Compress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_huffman_uncompress(string input, string output, uint insize, uint outsize)", asFUNCTION(Huffman_Uncompress), asCALL_CDECL);
r=scriptengine->RegisterGlobalFunction("void agc_huffman_uncompress(string input, string output, uint insize, uint outsize)", asFUNCTION(Huffman_Uncompress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_lz_compress(string input, string output, uint insize)", asFUNCTION(LZ_Compress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_lz_compressfast(string input, string output, uint insize, uint work)", asFUNCTION(LZ_CompressFast), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_lz_uncompress(string input, string output, uint insize)", asFUNCTION(LZ_Uncompress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_rice_compress(voidptr input, voidptr output, uint insize, int f)", asFUNCTION(Rice_Compress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_rice_uncompress(voidptr input, voidptr output, uint insize, uint outsize, int f)", asFUNCTION(Rice_Uncompress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_rle_compress(string input, string output, uint insize)", asFUNCTION(RLE_Compress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_rle_uncompress(string input, string output, uint insize)", asFUNCTION(RLE_Uncompress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_sf_compress(string input, string output, uint insize)", asFUNCTION(SF_Compress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_sf_uncompress(string input, string output, uint insize, uint outsize)", asFUNCTION(SF_Uncompress), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_init_timer()", asFUNCTION(InitTimer), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("double agc_get_time()", asFUNCTION(GetTime), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_initialize()", asFUNCTION(initialize), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_uninitialize()", asFUNCTION(uninitialize), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_get_website(string url)", asFUNCTION(GetWebsite), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_hostname()", asFUNCTION(GetHostname), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_current_user_directory()", asFUNCTION(GetCurrentUserDir), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_user_id()", asFUNCTION(GetUserID), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_username()", asFUNCTION(GetUsername), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_file_exists(string filename)", asFUNCTION(FileExists), asCALL_CDECL);
assert(r>=0);
#ifdef __WXMSW__
r=scriptengine->RegisterGlobalFunction("string agc_get_windows_directory()", asFUNCTION(GetWinDirectory), asCALL_CDECL);
assert(r>=0);
#endif // __WXMSW__
r=scriptengine->RegisterGlobalFunction("bool agc_directory_exists(string path)", asFUNCTION(DirectoryExists), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_copy_file(string source, string dest, bool override)", asFUNCTION(FileCopy), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_working_directory()", asFUNCTION(GetWorkingDir), asCALL_CDECL);
assert(r>=0);
#ifdef __WXMSW__
r=scriptengine->RegisterGlobalFunction("bool agc_create_directory(string path)", asFUNCTION(MakeDirectory), asCALL_CDECL);
assert(r>=0);
#else
r=scriptengine->RegisterGlobalFunction("bool agc_create_directory(string path, int Mod)", asFUNCTION(CreateDirectory), asCALL_CDECL);
assert(r>=0);
#endif // __WXMSW__
r=scriptengine->RegisterGlobalFunction("bool agc_remove_file(string filename)", asFUNCTION(FileRemove), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_rename_file(string source, string dest, bool override)", asFUNCTION(FileRename), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_remove_directory(string dir)", asFUNCTION(DirectoryRemove), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_set_working_directory(string dir)", asFUNCTION(SetWorkingDirectory), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_wait_Time(int seconds)", asFUNCTION(WaitTime), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_PATH", sizeof(ALLEGRO_PATH*), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterEnum("AGC_PATHS");
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_RESOURCES_PATH", ALLEGRO_RESOURCES_PATH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_TEMP_PATH", ALLEGRO_TEMP_PATH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_USER_HOME_PATH", ALLEGRO_USER_HOME_PATH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_USER_DOCUMENTS_PATH", ALLEGRO_USER_DOCUMENTS_PATH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_USER_DATA_PATH", ALLEGRO_USER_DATA_PATH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_USER_SETTINGS_PATH", ALLEGRO_USER_SETTINGS_PATH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_PATHS", "AGC_EXENAME_PATH", ALLEGRO_EXENAME_PATH);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_PATH @agc_get_standard_path(AGC_PATHS path)", asFUNCTION(al_get_standard_path), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_exe_name(string path)", asFUNCTION(al_set_exe_name), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_app_name(string app_name)", asFUNCTION(al_set_app_name), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_org_name(string org_name)", asFUNCTION(al_set_org_name), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_app_name()", asFUNCTION(al_get_app_name), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_org_name()", asFUNCTION(al_get_org_name), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_CONFIG", sizeof(ALLEGRO_CONFIG *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_CONFIG@ agc_get_system_config()", asFUNCTION(al_get_system_config), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_PATH @agc_create_path(string path)", asFUNCTION(al_create_path), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_PATH @agc_create_path_for_directory(string path)", asFUNCTION(al_create_path_for_directory), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_path(AGC_PATH @path)", asFUNCTION(al_destroy_path), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_PATH @agc_clone_path(AGC_PATH @path)", asFUNCTION(al_clone_path), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_join_paths(AGC_PATH @path, const AGC_PATH @tail)", asFUNCTION(al_join_paths), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_rebase_path(const AGC_PATH @head, AGC_PATH @tail)", asFUNCTION(al_rebase_path), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_path_drive(const AGC_PATH @path)", asFUNCTION(al_get_path_drive), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_path_num_components(const AGC_PATH @path)", asFUNCTION(al_get_path_num_components), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_path_component(const AGC_PATH @path, int i)", asFUNCTION(al_get_path_component), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_path_tail(const AGC_PATH @path)", asFUNCTION(al_get_path_tail), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_path_filename(const AGC_PATH @path)", asFUNCTION(al_get_path_filename), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_path_basename(const AGC_PATH @path)", asFUNCTION(al_get_path_basename), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_path_extension(const AGC_PATH @path)", asFUNCTION(al_get_path_extension), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_path_drive(AGC_PATH @path, const string drive)", asFUNCTION(al_set_path_drive), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_append_path_component(AGC_PATH @path, const string s)", asFUNCTION(al_append_path_component), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_insert_path_component(AGC_PATH @path, int i, const string s)", asFUNCTION(al_insert_path_component), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_replace_path_component(AGC_PATH @path, int i, const string s)", asFUNCTION(al_replace_path_component), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_remove_path_component(AGC_PATH @path, int i)", asFUNCTION(al_remove_path_component), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_drop_path_tail(AGC_PATH @path)", asFUNCTION(al_drop_path_tail), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_path_filename(AGC_PATH @path, const string filename)", asFUNCTION(al_set_path_filename), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_set_path_extension(AGC_PATH @path, string extension)", asFUNCTION(al_set_path_extension), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_path_cstr(AGC_PATH @path, string delim)", asFUNCTION(al_path_cstr), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_make_path_canonical(AGC_PATH @path)", asFUNCTION(al_make_path_canonical), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_STATE", sizeof(ALLEGRO_STATE *), asOBJ_REF);
assert(r>=0);
r= scriptengine->RegisterEnum("AGC_STATES");
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_NEW_DISPLAY_PARAMETERS", ALLEGRO_STATE_NEW_DISPLAY_PARAMETERS);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_NEW_BITMAP_PARAMETERS", ALLEGRO_STATE_NEW_BITMAP_PARAMETERS);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_DISPLAY", ALLEGRO_STATE_DISPLAY);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_TARGET_BITMAP", ALLEGRO_STATE_TARGET_BITMAP);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_BLENDER", ALLEGRO_STATE_BLENDER);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_TRANSFORM", ALLEGRO_STATE_TRANSFORM);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_NEW_FILE_INTERFACE", ALLEGRO_STATE_NEW_FILE_INTERFACE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_BITMAP", ALLEGRO_STATE_BITMAP);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_STATES", "AGC_STATE_ALL", ALLEGRO_STATE_ALL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_restore_state(AGC_STATES state)", asFUNCTION(al_restore_state), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_errno()", asFUNCTION(al_get_errno), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_errno(int errnum)", asFUNCTION(al_set_errno), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_THREAD", sizeof(ALLEGRO_THREAD *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_MUTEX", sizeof(ALLEGRO_MUTEX *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_COND", sizeof(ALLEGRO_COND *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_THREAD @agc_create_thread(voidptr proc, AGC_THREAD @thread, voidptr arg, voidptr arg2)", asFUNCTION(al_create_thread), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_start_thread(AGC_THREAD @thread)", asFUNCTION(al_start_thread), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_join_thread(AGC_THREAD @thread, voidptr ret_value)", asFUNCTION(al_join_thread), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_thread_should_stop(AGC_THREAD @thread)", asFUNCTION(al_set_thread_should_stop), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_get_thread_should_stop(AGC_THREAD @thread)", asFUNCTION(al_get_thread_should_stop), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_thread(AGC_THREAD @thread)", asFUNCTION(al_destroy_thread), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_run_detached_thread(voidptr proc, AGC_THREAD @thread, voidptr arg, voidptr arg2)", asFUNCTION(al_run_detached_thread), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_MUTEX @agc_create_mutex()", asFUNCTION(al_create_mutex), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_MUTEX @agc_create_mutex_recursive()", asFUNCTION(al_create_mutex_recursive), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_lock_mutex(AGC_MUTEX @mutex)", asFUNCTION(al_lock_mutex), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_unlock_mutex(AGC_MUTEX@ mutex)", asFUNCTION(al_unlock_mutex), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_mutex(AGC_MUTEX @mutex)", asFUNCTION(al_destroy_mutex), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_COND @agc_create_cond()", asFUNCTION(al_create_cond), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_cond(AGC_COND @cond)", asFUNCTION(al_destroy_cond), asCALL_CDECL);
assert(r>=0);
r= scriptengine->RegisterGlobalFunction("void agc_wait_cond(AGC_COND @cond, AGC_MUTEX @mutex)", asFUNCTION(al_wait_cond), asCALL_CDECL);
assert(r>=0);
r= scriptengine->RegisterObjectType("AGC_TIMEOUT", sizeof(ALLEGRO_TIMEOUT *), asOBJ_REF);
r=scriptengine->RegisterGlobalFunction("int agc_wait_cond_until(AGC_COND @cond, AGC_MUTEX @mutex, const AGC_TIMEOUT @timeout)", asFUNCTION(al_wait_cond_until), asCALL_CDECL);
assert(r>=0);
r= scriptengine->RegisterGlobalFunction("void agc_broadcast_cond(AGC_COND @cond)", asFUNCTION(al_broadcast_cond), asCALL_CDECL);
assert(r>=0);
r= scriptengine->RegisterGlobalFunction("void agc_signal_cond(AGC_COND @cond)", asFUNCTION(al_signal_cond), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_DISPLAY", sizeof(ALLEGRO_DISPLAY *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_DISPLAY @agc_create_display(int w, int h)", asFUNCTION(al_create_display), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_display(AGC_DISPLAY @display)", asFUNCTION(al_destroy_display), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_new_display_flags()", asFUNCTION(al_get_new_display_flags), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_new_display_refresh_rate()", asFUNCTION(al_get_new_display_refresh_rate), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_get_new_window_position(int x, int y)", asFUNCTION(al_get_new_window_position), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterEnum("AGC_DISPLAY_OPTIONS");
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_COLOR_SIZE", ALLEGRO_COLOR_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_RED_SIZE", ALLEGRO_RED_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_GREEN_SIZE", ALLEGRO_GREEN_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_BLUE_SIZE", ALLEGRO_BLUE_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_ALPHA_SIZE", ALLEGRO_ALPHA_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_RED_SHIFT", ALLEGRO_RED_SHIFT);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_GREEN_SHIFT", ALLEGRO_GREEN_SHIFT);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_BLUE_SHIFT", ALLEGRO_BLUE_SHIFT);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_ALPHA_SHIFT", ALLEGRO_ALPHA_SHIFT);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_ACC_RED_SIZE", ALLEGRO_ACC_RED_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_ACC_GREEN_SIZE", ALLEGRO_ACC_GREEN_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_ACC_BLUE_SIZE", ALLEGRO_ACC_BLUE_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_ACC_ALPHA_SIZE", ALLEGRO_ACC_ALPHA_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_STEREO", ALLEGRO_STEREO);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_AUX_BUFFERS", ALLEGRO_AUX_BUFFERS);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_DEPTH_SIZE", ALLEGRO_DEPTH_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_STENCIL_SIZE", ALLEGRO_STENCIL_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_SAMPLE_BUFFERS", ALLEGRO_SAMPLE_BUFFERS);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_SAMPLES", ALLEGRO_SAMPLES);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_RENDER_METHOD", ALLEGRO_RENDER_METHOD);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_FLOAT_COLOR", ALLEGRO_FLOAT_COLOR);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_FLOAT_DEPTH", ALLEGRO_FLOAT_DEPTH);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_SINGLE_BUFFER", ALLEGRO_SINGLE_BUFFER);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_SWAP_METHOD", ALLEGRO_SWAP_METHOD);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_COMPATIBLE_DISPLAY", ALLEGRO_COMPATIBLE_DISPLAY);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_UPDATE_DISPLAY_REGION", ALLEGRO_UPDATE_DISPLAY_REGION);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_VSYNC", ALLEGRO_VSYNC);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_MAX_BITMAP_SIZE", ALLEGRO_MAX_BITMAP_SIZE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_SUPPORT_NPOT_BITMAP", ALLEGRO_SUPPORT_NPOT_BITMAP);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_CAN_DRAW_INTO_BITMAP", ALLEGRO_CAN_DRAW_INTO_BITMAP);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_OPTIONS", "AGC_SUPPORT_SEPARATE_ALPHA", ALLEGRO_SUPPORT_SEPARATE_ALPHA);
assert(r>=0);
r=scriptengine->RegisterEnum("AGC_IMPORTANCE");
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_IMPORTANCE", "AGC_REQUIRE", ALLEGRO_REQUIRE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_IMPORTANCE", "AGC_SUGGEST", ALLEGRO_SUGGEST);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_IMPORTANCE", "AGC_DONTCARE", ALLEGRO_DONTCARE);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_new_display_option(AGC_DISPLAY_OPTIONS option, int value, AGC_IMPORTANCE imp)", asFUNCTION(al_set_new_display_option), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_new_display_option(int option, int imp)", asFUNCTION(al_get_new_display_option), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_reset_new_display_options()", asFUNCTION(al_reset_new_display_options), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterEnum("AGC_DISPLAY_FLAGS");
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_WINDOWED", ALLEGRO_WINDOWED);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_FULLSCREEN", ALLEGRO_FULLSCREEN);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_FULLSCREEN_WINDOW", ALLEGRO_FULLSCREEN_WINDOW);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_RESIZABLE", ALLEGRO_RESIZABLE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_OPENGL", ALLEGRO_OPENGL);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_OPENGL_3_0", ALLEGRO_OPENGL_3_0);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_OPENGL_FORWARD_COMPATIBLE", ALLEGRO_OPENGL_FORWARD_COMPATIBLE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_DIRECT3D", ALLEGRO_DIRECT3D);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_FRAMELESS", ALLEGRO_FRAMELESS);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_NOFRAME", ALLEGRO_NOFRAME);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_DISPLAY_FLAGS", "AGC_GENERATE_EXPOSE_EVENTS", ALLEGRO_GENERATE_EXPOSE_EVENTS);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_new_display_flags(AGC_DISPLAY_FLAGS flags)", asFUNCTION(al_set_new_display_flags), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_new_display_refresh_rate(int refresh_rate)", asFUNCTION(al_set_new_display_refresh_rate), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_new_window_position(int x, int y)", asFUNCTION(al_set_new_window_position), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_acknowledge_resize(AGC_DISPLAY @display)", asFUNCTION(al_acknowledge_resize), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_flip_display()", asFUNCTION(al_flip_display), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_BITMAP", sizeof(ALLEGRO_BITMAP *), asOBJ_REF);
r=scriptengine->RegisterGlobalFunction("AGC_BITMAP @agc_get_backbuffer(AGC_DISPLAY @display)", asFUNCTION(al_get_backbuffer), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_DISPLAY_FLAGS agc_get_display_flags(AGC_DISPLAY @display)", asFUNCTION(al_get_display_flags), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_display_format(AGC_DISPLAY @display)", asFUNCTION(al_get_display_format), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_display_height(AGC_DISPLAY @display)", asFUNCTION(al_get_display_height), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_display_refresh_rate(AGC_DISPLAY @display)", asFUNCTION(al_get_display_refresh_rate), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_display_width(AGC_DISPLAY @display)", asFUNCTION(al_get_display_width), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_get_window_position(AGC_DISPLAY @display, int x, int y)", asFUNCTION(al_get_window_position), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_inhibit_screensaver(bool inhibit)", asFUNCTION(al_inhibit_screensaver), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_resize_display(AGC_DISPLAY @display, int width, int height)", asFUNCTION(al_resize_display), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_display_icon(AGC_DISPLAY @display, AGC_BITMAP @bitmap)", asFUNCTION(al_set_display_icon), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_DISPLAY_OPTIONS agc_get_display_option(AGC_DISPLAY @display, int option)", asFUNCTION(al_get_display_option), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_window_position(AGC_DISPLAY @display, int x, int y)", asFUNCTION(al_set_window_position), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_window_title(AGC_DISPLAY @display, const string title)", asFUNCTION(al_set_window_title), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_set_display_flag(AGC_DISPLAY @display, AGC_DISPLAY_FLAGS flag, bool onoff)", asFUNCTION(al_set_display_flag), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_update_display_region(int x, int y, int width, int height)", asFUNCTION(al_update_display_region), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_wait_for_vsync()", asFUNCTION(al_wait_for_vsync), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_EVENT_SOURCE", sizeof(ALLEGRO_EVENT_SOURCE *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_EVENT_SOURCE @agc_get_display_event_source(AGC_DISPLAY @display)", asFUNCTION(al_get_display_event_source), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_DISPLAY_MODE", sizeof(ALLEGRO_DISPLAY_MODE *), asOBJ_REF);
r=scriptengine->RegisterObjectProperty("AGC_DISPLAY_MODE", "int width", asOFFSET(ALLEGRO_DISPLAY_MODE, width));
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_DISPLAY_MODE", "int height", asOFFSET(ALLEGRO_DISPLAY_MODE, height));
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_DISPLAY_MODE", "int format", asOFFSET(ALLEGRO_DISPLAY_MODE, format));
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_DISPLAY_MODE", "int refresh_rate", asOFFSET(ALLEGRO_DISPLAY_MODE, refresh_rate));
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_DISPLAY_MODE @agc_get_display_mode(int index, AGC_DISPLAY @display)", asFUNCTION(al_get_display_mode), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_get_num_display_modes()", asFUNCTION(al_get_num_display_modes), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_MONITOR_INFO", sizeof(ALLEGRO_MONITOR_INFO *), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_MONITOR_INFO", "int x1", asOFFSET(ALLEGRO_MONITOR_INFO, x1));
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_MONITOR_INFO", "int y1", asOFFSET(ALLEGRO_MONITOR_INFO, y1));
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_MONITOR_INFO", "int x2", asOFFSET(ALLEGRO_MONITOR_INFO, x2));
assert(r>=0);
r=scriptengine->RegisterObjectProperty("AGC_MONITOR_INFO", "int y2", asOFFSET(ALLEGRO_MONITOR_INFO, y2));
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_new_display_adapter()", asFUNCTION(al_get_new_display_adapter), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_new_display_adapter(int adapter)", asFUNCTION(al_set_new_display_adapter), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_get_monitor_info(int adapter, AGC_MONITOR_INFO @info)", asFUNCTION(al_get_monitor_info), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("int agc_get_num_video_adapters()", asFUNCTION(al_get_num_video_adapters), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_CONFIG @agc_create_config()", asFUNCTION(al_create_config), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_config(AGC_CONFIG @config)", asFUNCTION(al_destroy_config), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_CONFIG @agc_load_config_file(const string filename)", asFUNCTION(al_load_config_file), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_FILE", sizeof(ALLEGRO_FILE*), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_CONFIG @agc_load_config_file_f(AGC_FILE @f)", asFUNCTION(al_load_config_file_f), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_save_config_file(const string filename, const AGC_CONFIG @config)", asFUNCTION(al_save_config_file), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_save_config_file_f(AGC_FILE @file, const AGC_CONFIG @config)", asFUNCTION(al_save_config_file_f), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_add_config_section(AGC_CONFIG @config, const string name)", asFUNCTION(al_add_config_section), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_add_config_comment(AGC_CONFIG @config, const string section, const string comment)", asFUNCTION(al_add_config_comment), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_config_value(AGC_CONFIG @config, const string section, const string key)", asFUNCTION(al_get_config_value), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_set_config_value(AGC_CONFIG @config, string section, string key, string value)", asFUNCTION(al_set_config_value), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_CONFIG_SECTION", sizeof(ALLEGRO_CONFIG_SECTION*), asOBJ_VALUE);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_first_config_section(AGC_CONFIG @config, AGC_CONFIG_SECTION[] iterator)", asFUNCTION(al_get_first_config_section), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_next_config_section(AGC_CONFIG_SECTION[] iterator)", asFUNCTION(al_get_next_config_section), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_CONFIG_ENTRY", sizeof(ALLEGRO_CONFIG_ENTRY*), asOBJ_VALUE);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_first_config_entry(AGC_CONFIG @config, string section, AGC_CONFIG_ENTRY[] iterator)", asFUNCTION(al_get_first_config_entry), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("string agc_get_next_config_entry(AGC_CONFIG_ENTRY[] iterator)", asFUNCTION(al_get_next_config_entry), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_CONFIG @agc_merge_config(const AGC_CONFIG @cfg1, const AGC_CONFIG @cfg2)", asFUNCTION(al_merge_config), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_merge_config_into(AGC_CONFIG @master, const AGC_CONFIG @add)", asFUNCTION(al_merge_config_into), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterObjectType("AGC_FS_ENTRY", sizeof(ALLEGRO_FS_ENTRY), asOBJ_REF);
assert(r>=0);
r=scriptengine->RegisterEnum("AGC_FILE_MODE");
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_FILE_MODE", "AGC_FILEMODE_READ", ALLEGRO_FILEMODE_READ);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_FILE_MODE", "AGC_FILEMODE_WRITE", ALLEGRO_FILEMODE_WRITE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_FILE_MODE", "AGC_FILEMODE_EXECUTE", ALLEGRO_FILEMODE_EXECUTE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_FILE_MODE", "AGC_FILEMODE_HIDDEN", ALLEGRO_FILEMODE_HIDDEN);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_FILE_MODE", "AGC_FILEMODE_ISFILE", ALLEGRO_FILEMODE_ISFILE);
assert(r>=0);
r=scriptengine->RegisterEnumValue("AGC_FILE_MODE", "AGC_FILEMODE_ISDIR", ALLEGRO_FILEMODE_ISDIR);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("AGC_FS_ENTRY @agc_create_fs_entry(string path)", asFUNCTION(al_create_fs_entry), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("void agc_destroy_fs_entry(AGC_FS_ENTRY @fh)", asFUNCTION(al_destroy_fs_entry), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("const string agc_get_fs_entry_name(AGC_FS_ENTRY @e)", asFUNCTION(al_get_fs_entry_name), asCALL_CDECL);
assert(r>=0);
r=scriptengine->RegisterGlobalFunction("bool agc_update_fs_entry(AGC_FS_ENTRY @e)", asFUNCTION(al_update_fs_entry), asCALL_CDECL);
assert(r>=0);
r=scriptengine->AddRef();
assert(r>=0);
}

please help: if you can

i think: the problems is from the registering the String, Array, Any, Math, etc

do i set the engine properties correctly?

Share this post


Link to post
Share on other sites

Make sure you have the latest code for the add-ons. When you update the library you also need to update the add-ons so you don't get errors due to out-of-date code.

 

 

I tested executing the code you have for configuring the engine, and the first call that fails is the following:

 

[source]

r=scriptengine->RegisterGlobalFunction("void agc_huffman_uncompress(string input, string output, uint insize, uint outsize)", asFUNCTION(Huffman_Uncompress), asCALL_CDECL);

[/source]

 

The error sent to message callback in this case is the following:

 

 (0, 0) : Error   : Failed in call to function 'RegisterGlobalFunction' with 'void agc_huffman_uncompress(string input, string output, uint insize, uint outsize)' (Code: -13)
 
Which I hope is clear enough to tell you where the problem is. The error code -13 means asALREADY_REGISTERED, which is exactly the error you did here. 
Edited by Andreas Jonsson

Share this post


Link to post
Share on other sites

Aside from that error in the registration I don't get any other errors from this code and no crashes.

 

Once you start compiling scripts you're going to see errors though, as you've registered most of your types with asOBJ_REF, but you're not registering the asBEHAVE_ADDREF and asBEHAVE_RELEASE behaviours that are required for objects with this flag.

 

If you don't care about reference counting and plan to handle the memory management some other way, then you can use the combination asOBJ_REF | asOBJ_NOCOUNT to register a reference type and tell AngelScript that it shouldn't bother calling addref and release on the pointer.

Share this post


Link to post
Share on other sites

thank's!

the configuration errors have been fixed(i didn't see that)!

thanks in advance!

but:

when i'm trying to compile a script, the compiler crashe's

this is the compiler code:

compiler.h

/**
*allegro game creator
*copyright(se)2013 amir rezaa ramezani
*this file is part of AGC
*distributed under the boost software license, version 1.0
*please see license.txt file in the main directory of the project
***/
/*
*includes
*/
#ifndef _AGC_COMPILER_H
#define _AGC_COMPILER_H
#include <angelscript.h>
#include <wx/file.h>
/*
*the compiler class that is to be used for compile the scripts
*/
class compilerstream: public asIBinaryStream
{
public:
compilerstream()
{
f=0;
}
int Open(wxString filename)
{
f->Open(filename, wxFile::read_write);
return 0;
}
void Write(const void *ptr, asUINT size)
{
f->Write(ptr, size);
}
void Read(void *, asUINT) {}
private:
wxFile *f;
};
int save_byet(wxString filename);
#endif // _AGC_COMPILER_H

compiler.cpp

/**
*allegro game creator
*copyright(se)2013 amir rezaa ramezani
*this file is part of AGC
*distributed under the boost software license, version 1.0
*please see license.txt file in the main directory of the project
***/
/*
*includes
*/
#include "configure.h"
#include "main.h"
#include "compiler.h"
/*
*the function for compile the script
*/
int mainwin::save_byet(wxString filename)
{
compilerstream scriptcomp;
scripting::builder->StartNewModule(scripting::scriptengine, "build");
scripting::builder->AddSectionFromMemory("sec", txt->GetText(), txt->GetTextLength());
int r= scripting::builder->BuildModule();
r=scriptcomp.Open(filename);
asIScriptModule *mod=scripting::scriptengine->GetModule("build");
mod->SaveByteCode(&scriptcomp);
}

please help: why it crashe's?

Share this post


Link to post
Share on other sites

Is it crashing while compiling the script, or while saving the bytecode?

 

What does the script look like?

 

Does the script declare any global variables? These will be initialized right after the build (unless you turn off the automatic initialization with asEP_INIT_GLOBAL_VARS_AFTER_BUILD). If the initialization of the global variables calls any function that has been registered incorrectly (e.g. wrong declaration for a function) then this may very well crash the application, and unfortunately there is no way for AngelScript to detect this in a friendly manner.

 

 

I noticed in your code that you're not handling errors when compiling the script. If BuildModule() returns a negative value then the compilation failed, and you shouldn't try to save the bytecode. This is not the cause of the crash though.

Share this post


Link to post
Share on other sites

Thanks for the script. I'll see if I can reproduce the problem.

 

In the future try to be more specific when reporting errors. Provide as much information as possible and I'll be able to help you faster.

 

It would really help seeing the callstack when the crash occurs, so I can figure exactly in which part of the code the problem is.

 

 

PS. You may also want to take extra care with your writing so as not to offend anyone by mistake.

Share this post


Link to post
Share on other sites

The script you're trying to compile should compile just fine, except that it has a couple of warnings:

 

test (1, 1) : Info    : Compiling void main()
test (3, 27) : Warning : Invalid escape sequence
test (3, 19) : Warning : Invalid escape sequence
 

The warnings are because of the \a in the paths.

 

I didn't get any crashes, though.

 

 

I took a look at your message callback and I believe I found the cause of your crash.

 

The wxString you're using has no operator += that takes an int. As there is no such operator, nor a constructor that the compiler can use to convert the int to a wxString the C++ compiler is likely converting the int to a pointer. The crash probably happens when wxString tries to copy from this invalid pointer.

 

void messagecallback(const asSMessageInfo *info, void *param)
{
    wxString type;
    if(info->type==asMSGTYPE_ERROR)
    {
        type="error";
    }
    else if(info->type==asMSGTYPE_WARNING)
    {
        type="worning";
    }
    else if(info->type==asMSGTYPE_INFORMATION)
    {
        type="information";
    }
    else
    {
        type="unknown";
    }
    wxString message="file: ";
    message+=info->section;
    message+="\nline: ";
    message+=info->row;   // <<<--- this is wrong, wxString has no operator+=(int) 
    message+="\nColumn: ";
    message+=info->col;   // <<<--- this is wrong,  wxString has no operator+=(int)
    message+="\n";
    message+=type;
    message+=": ";
    message+=info->message;
    wxMessageBox(message, type, wxOK, NULL, -1, -1);
}

 

I've never used wxWidgets myself, but from the manual it appears to have the operator<<(int) that does what you intended to do with the +=, i.e formats the integer into a string and appends it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this