Jump to content
  • Advertisement

Boost113

Member
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

109 Neutral

About Boost113

  • Rank
    Member

Personal Information

Social

  • Github
    hhyyrylainen
  1. Boost113

    Compiler error in svn trunk on linux

    I don't have experience with mingw on windows but I've used cygwin and (I just checked again from the documentation) that sets the UNIX flag in cmake. Not sure if a check for `NOT MSVC` would be better, then.
  2. Hi, I tried compiling the latest trunk version (2481). With gcc on linux and I got this error (I'm using cmake): Building CXX object CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o /usr/bin/c++ -D-fPIC -DANGELSCRIPT_EXPORT -D_LIB -I/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/projects/cmake/../../include -O2 -g -DNDEBUG -o CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o -c /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp <komentorivi>:0:1: virhe: makrojen nimien on oltava tunnisteita make[2]: *** [CMakeFiles/angelscript.dir/build.make:63: CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o] Virhe 1 make[2]: Poistutaan hakemistosta ”/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/build” make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/angelscript.dir/all] Virhe 2 make[1]: Poistutaan hakemistosta ”/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/build” make: *** [Makefile:130: all] Virhe 2 The interesting part here is `-D-fPIC` which is the cause of the error. I was able to fix this by changing this configuration `target_compile_definitions(${ANGELSCRIPT_LIBRARY_NAME} PRIVATE -fPIC)` to this: `target_compile_options(${ANGELSCRIPT_LIBRARY_NAME} PRIVATE -fPIC)`. I changed the compile definition to be compile option which correctly no longer adds `-D` in front of `-fPIC`. I Also added a check to the if condition that contains that setting to include check for UNIX as I think as it currently is it won't work on windows (I also use cmake with angelscript on windows, but didn't test that yet). I included a diff of the change. patch.diff
  3. I don't think that's completely necessary as (AFAIK) none of the changes I did to AngelScript depend on C++11. But that sample callback needs C++11 to work correctly. So there's probably not much use for the callback without C++11 support, but the library should compile fine, it would just be have an extra useless feature. I'd like to see this feature added to the svn version as soon as possible as I don't mid switching to a newer revision to use this (I've been using the svn latest branch for a long time now). So when the next actual release doesn't matter that much to me.
  4. I was initially going to argue that any self-respecting c++ library will use std::exception as a base type for all of their exceptions. But after cooling down for a while I can definitely see that allowing that might open the gates for requests of other exception types and a generic callback gives more flexibility. After looking at solokiller's suggestion I decided to attempt to implement such a callback. And I got it working. I attached a diff of my changes. I basically duplicated what asCContext::SetExceptionCallback does to make a new "Translate exception" callback, which I placed into a new method "HandleExceptionHappened", I had to add this as c++ exceptions were caught in multiple places. So now setting that callback to something like this: void ScriptTranslateExceptionCallback(asIScriptContext* context, void* userdata) { try { std::rethrow_exception(std::current_exception()); } catch(const std::exception& e) { context->SetException( (std::string("Caught application exception: ") + e.what()).c_str()); } } ctx->SetTranslateExceptionCallback(asFUNCTION(ScriptTranslateExceptionCallback), nullptr, asCALL_CDECL); Results in nicer script exception messages: "Caught application exception: Testing custom messages" as_exception_translate.diff
  5. That would not work for me as I extensively use third party libraries that report errors as exceptions, that are derived from std::exception. I think that this feature will only be useful if the exceptions that the script context can read messages from don't need to derive from or now about AngelScript types.
  6. I'd like to be able to read the messages from exceptions that AngelScript catches without the hassle of using gdb with break on throw. So I suggest adding the following code to as_context.cpp before the "catch (...)" part: catch (const std::exception &e) { SetExpection((TXT_EXCEPTION_CAUGHT ", with message: " + std::string(e.what()))c._str()); } This was the only relevant link to this that I found: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_cpp_exceptions.html But as almost all of my methods exposed to AngelScripts can throw exceptions it's not really possible (and probably bad for performance) to wrap them in extra wrappers that are there to just catch exception messages. I'm using Last Changed Rev: 2457 so hopefully this hasn't been done after that.
  7. Boost113

    Segmentation fault with dictionary retrieve to auto

    I'm using version 2.32.0 from svn: URL: http://svn.code.sf.net/p/angelscript/code/tags/2.32.0 Relative URL: ^/tags/2.32.0 Repository Root: http://svn.code.sf.net/p/angelscript/code Repository UUID: 404ce1b2-830e-0410-a2e2-b09542c77caf Revision: 2463 and I haven't made any changes to the add-ons
  8. Boost113

    Segmentation fault with dictionary retrieve to auto

    After going back in git history and playing around a bit I got this function to cause the crash: void setupSpecies(CellStageWorld@ world){ auto keys = STARTER_MICROBES.getKeys(); for(uint i = 0; i < keys.length(); ++i){ const string name = keys[i]; MicrobeTemplate@ data = cast<MicrobeTemplate@>(STARTER_MICROBES[name]); ObjectID speciesEntity = world.CreateEntity(); SpeciesComponent@ speciesComponent = world.Create_SpeciesComponent(speciesEntity, name); speciesComponent.avgCompoundAmounts = dictionary(); ProcessorComponent@ processorComponent = world.Create_ProcessorComponent( speciesEntity); speciesComponent.colour = data.colour; // iterates over all compounds, and sets amounts and priorities uint64 compoundCount = SimulationParameters::compoundRegistry().getSize(); for(uint a = 0; a < compoundCount; ++a){ auto compound = SimulationParameters::compoundRegistry().getTypeData(a); // int compoundData; // bool valid = data.compounds.get(compound.internalName, compoundData); auto compoundData = data.compounds[compound.internalName]; if(compoundData !is null){ int amount = compoundData.amount; speciesComponent.avgCompoundAmounts[formatUint(a)] = amount; } } } } Changing around the commented lines to this stops the crashing: int compoundData; bool valid = data.compounds.get(compound.internalName, compoundData); // auto compoundData = data.compounds[compound.internalName]; From my testing it seems that this line is also important in making the crash happen: "if(compoundData !is null){" That uses quite a few other classes and registered application functions so if they are needed for this to crash I can post a link to a tag in a repository with all the files.
  9. Hi, When I have this line in a script: `auto compoundData = data.compounds[compound.internalName];` I get a segmentation fault. Here: 0 in asCArray<int>::GetLength() const of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 1 in asCCompiler::CompileOverloadedDualOperator2(asCScriptNode*, char const*, asCExprContext*, asCExprContext*, bool, asCExprContext*, bool, asCDataType const&) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 2 in asCCompiler::CompileOperatorOnHandles(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 3 in asCCompiler::CompileOperator(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType, bool) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 4 in asCCompiler::CompilePostFixExpression(asCArray<asCScriptNode*>*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 5 in asCCompiler::CompileExpression(asCScriptNode*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 6 in asCCompiler::CompileCondition(asCScriptNode*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 7 in asCCompiler::CompileAssignment(asCScriptNode*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 8 in asCCompiler::CompileIfStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 9 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 10 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 11 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 12 in asCCompiler::CompileForStatement(asCScriptNode*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 13 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 14 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 15 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 16 in asCCompiler::CompileForStatement(asCScriptNode*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 17 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 18 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 19 in asCCompiler::CompileFunction(asCBuilder*, asCScriptCode*, asCArray<asCString>&, asCScriptNode*, asCScriptFunction*, sClassDeclaration*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 20 in asCBuilder::CompileFunctions() of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 21 in asCBuilder::Build() of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 22 in asCModule::Build() of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 23 in CScriptBuilder::Build of /home/hhyyrylainen/Projects/leviathan/build/ThirdParty/include/add_on/scriptbuilder/scriptbuilder.cpp:520 24 in CScriptBuilder::BuildModule of /home/hhyyrylainen/Projects/leviathan/build/ThirdParty/include/add_on/scriptbuilder/scriptbuilder.cpp:117 If I change the line to (change auto to int): `int compoundData = data.compounds[compound.internalName];` I get an compile error "Can't implicitly convert from 'dictionaryValue' to 'int'" instead of a segmentation fault. I know that the above example shouldn't compile either, but it would be nice to have an error message instead of a crash.
  10. This check in some of the add-ons: #ifdef AS_CAN_USE_CPP11 #include <chrono> #else #error Sorry, this requires C++11 which your compiler doesn't appear to support #endif Causes warnings about there being a missing ' character: /home/hhyyrylainen/Projects/leviathan/libraries/include/add_on/datetime/datetime.h:12:60: varoitus: päättävä merkki ' puuttuu #error Sorry, this requires C++11 which your compiler doesn't appear to support ^ This is nothing major, but it does cause annoying warnings when rebuilding files that include the add-on headers.
  11. Boost113

    GCC 5.1 Deprecated warnings

    That fixed it, thanks.
  12. Boost113

    GCC 5.1 Deprecated warnings

    Hi,   Compiling the latest angelscript release "2.30.0 WIP" with GCC 5.1 (in c++14 mode) gives these warnings: /home/hhyyrylainen/leviathan/AngelScript/include/angelscript.h: Funktio ”asUINT asGetTypeTraits()”: /home/hhyyrylainen/leviathan/AngelScript/include/angelscript.h:597:80: varoitus: ”template<class _Tp> struct std::has_trivial_default_constructor” is deprecated [-Wdeprecated-declarations]   bool hasConstructor        = std::is_default_constructible<T>::value && !std::has_trivial_defaul                                                                                 ^ In file included from /usr/include/c++/5.1.1/bits/move.h:57:0,                  from /usr/include/c++/5.1.1/bits/stl_pair.h:59,                  from /usr/include/c++/5.1.1/bits/stl_algobase.h:64,                  from /usr/include/c++/5.1.1/bits/char_traits.h:39,                  from /usr/include/c++/5.1.1/string:40,                  from /home/hhyyrylainen/leviathan/Engine/Define.h:13,                  from /home/hhyyrylainen/leviathan/Engine/Engine.h:3,                  from /home/hhyyrylainen/leviathan/Engine/Engine.cpp:2: /usr/include/c++/5.1.1/type_traits:1383:12: huom: esitelty täällä      struct has_trivial_default_constructor             ^ In file included from /home/hhyyrylainen/leviathan/Engine/Script/ScriptExecutor.h:11:0,                  from /home/hhyyrylainen/leviathan/Engine/Application/Application.h:7,                  from /home/hhyyrylainen/leviathan/Engine/Engine.cpp:6: /home/hhyyrylainen/leviathan/AngelScript/include/angelscript.h:599:80: varoitus: ”template<class _Tp> struct std::has_trivial_copy_assign” is deprecated [-Wdeprecated-declarations]   bool hasAssignmentOperator = std::is_copy_assignable<T>::value       && !std::has_trivial_copy_a   More warnings: http://pastebin.com/1gc26Rnt   This should be a pretty easy fix, just renaming the functions to is_trivially_default_constructible.  
  13. Somehow I must have missed that link...   Thanks
  14. I'd like to see the ability to specify starting line numbers in script builder AddSectionFromMemory. I've been doing my own changes to support this for a few versions now but it is kind of annoying to have to redo that every new version. Why I need this is because I have my own custom format for GUI files which contain angelscript code and it is much easier to debug when I can specify the line numbers that match with the actual file. Could this be supported in the future? It would be only like 5 changes.   The method definition I'm using right now:     int AddSectionFromMemory(const char *sectionName,                              const char *scriptCode,                              unsigned int startLine = 1,                              unsigned int scriptLength = 0); This works for me but the startLine argument being before the length could cause issues...   I can give you the lines I changed. I would have made a patch file or a pull request but as far as I can tell there isn't a repo for angelscript.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!