Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

869 Good


About Solokiller

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Solokiller

    Operator assignment question

    What does operator* look like, and does that method get the right input values?
  2. Solokiller

    Read message from std::exception into script exception

    You could use C++11 and newer exception support to handle some of this more easily: More: You can use this to implement a callback to handle the exceptions without needing explicit support in Angelscript's code: void HandleASException( asIScriptContext* pContext ) { if( std::unhandled_exceptions() > 0 ) { try { std::rethrow_exception( std::current_exception() ); } catch( const std::exception& e ) { } catch( const MyException& e ) { } catch( ... ) { } } } (could also be a while ( std::unhandled_exceptions() > 0 ) loop) So what you need is a per-context or engine-global callback. This can be handled just like the line callback:
  3. Solokiller

    Git mirror for Angelscript SVN repository, CMake support

    I discovered that i used the wrong variable for config file generation. It seems that it causes no issues because the version is defined above as PROJECT_VERSION, but i've fixed it anyway to be sure. I've also added a CMake option to disable exceptions, since there is apparently no way to set preprocessor definitions from the command line. Both changes can be found in today's commits here:
  4. Solokiller

    Git mirror for Angelscript SVN repository, CMake support

    Thanks, i'm starting work on upgrades now for AngelscriptUtils. I do have to correct one of my earlier statements regarding library dependencies though: CMake only keeps track of what the dependencies are, but you still have to find them yourself. In this case, you need to do this yourself: find_package( Threads REQUIRED ) Otherwise it complains about a missing target. This does not appear to apply to targets that are defined in the current context, so for example in my AngelscriptUtils repository, the test program will implicitly link Angelscript::angelscript and Threads::Threads when it links with AngelscriptUtils.
  5. Solokiller

    Call function with primitive ref parameter from C++

    The documentation seems to disagree with itself, just below that is an example of a reference to an int: // The context has been prepared for a script // function with the following signature: // int function(int, double, bool, int &out) // Put the arguments on the context stack, starting with the first one ctx->SetArgDWord(0, 1); ctx->SetArgDouble(1, 3.141592); ctx->SetArgByte(2, true); int val; ctx->SetArgAddress(3, &val); I use SetArgAddress for these arguments.
  6. Solokiller

    Git mirror for Angelscript SVN repository, CMake support

    A friend of mine found this: Seems that the work has to be done on the Git side. A script could run once a day to sync it, but it would probably have to run on a server to make this all work. Regarding CMake versions, 3.5 is about 2 years old so most users should have no issues using it. Requiring the latest version isn't really a good idea since most users won't have it installed so soon. On Linux CMake tends to be a few versions behind in package repositories so unless new features are required it should be fine as-is.
  7. Solokiller

    Git mirror for Angelscript SVN repository, CMake support

    I was suggesting a way to synchronize a Git mirror with the SVN repository, so that any commits made in the SVN repository are mirrored in Git as well, including tags. I don't know how to set this up myself as i have limited experience with SVN, but if it's possible it would make things a bit easier. I updated the CMake project file, you can find the files here: What i've done is update the syntax to use the modern target_* commands, which are more explicit about how they work (the old commands can affect previously defined targets), let you specify how these properties are inherited and will avoid any issues if there are ever other libraries added to the Angelscript project. I've set the minimum CMake version required to 3.5, which is the last version to still support Visual Studio 1998 and 2002. I couldn't find any information on the minimum version that Angelscript supports, so i assumed the earliest version supported by modern versions of CMake. I've added installation rules to place the compiled binaries and the header file angelscript.h at the user defined installation path. The result is that 3 directories (2 if not building shared libraries) will be created: include, bin and lib. Additionally, several files are automatically placed in lib/cmake/Angelscript. These files are used by CMake's find_package command to locate the library and produce an imported target to link with. A user need only define Angelscript_DIR to point to the directory containing these files, and use the following CMake commands: find_package( Angelscript CONFIG REQUIRED ) target_link_libraries( MyProject Angelscript::angelscript ) This will locate the library and link with it. CMake takes care of the threading dependency on its own, so the Threads package is located and added automatically. You do not need to specify the include directory containing angelscript.h yourself, as this is also taken care of automatically. CMake also handles versioning automatically here, so it knows which version is specified by the file. For example: find_package( Angelscript CONFIG 2.32.1 REQUIRED ) Will give you this error: CMake Error at CMakeLists.txt:14 (find_package): Could not find a configuration file for package "Angelscript" that exactly matches requested version "2.32.1". The following configuration files were considered but not accepted: <install path>/lib/cmake/Angelscript/AngelscriptConfig.cmake, version: 2.32.0 This makes detecting version issues much easier since it won't even generate build files if the version has changed, so when using an automated build system you can detect compatibility issues right away (i use webhooks to get build failure notifications in Gitter). So yeah, this really makes using Angelscript with CMake a lot easier. I'm going to upgrade my own projects with this as well since it makes using them much easier.
  8. I'm looking to rework my Angelscript utility code to separate out the Angelscript library into its own repository. I figured that somebody else probably did it before, and so i searched for and found several repositories on Github containing old mirrors of the SDK, some with additional changes like CMake support. CMake support is provided in sdk/angelscript/projects/cmake, although it uses outdated syntax to support older versions of CMake. At least one of these ( was set up to automatically mirror the commits, but it seems that none of these repositories are still actively mirroring the commits. So i'm wondering if there are any plans to set this up as part of the SVN repository's commit handling. Basically, a Github repository automatically receives commits as the SVN repository does, with tags pushed for version releases. It seems that commits that update version numbers always follow the same format: "Releasing major.minor.patch", so a script could detect this and add a tag to it. It would make using Angelscript in projects easier and make the other mirrors obsolete (and prevent the creation of even more, as i almost did this myself), so it's a win-win for everybody. On the subject of the CMake project file: there is no setup for install targets, which would usually install the library and the header file somewhere to be used. I'd suggest installing to <target>/angelscript_major_minor_patch, optionally installing shared libraries in lib/shared and static libraries in lib/static, with a FindXXX.cmake file to locate it automatically based on this. This is how Boost does it (specifically, and lets you have multiple versions installed side by side. Of course, it is ultimately up to the end user so having it detect the version some other way (like parsing angelscript.h for ANGELSCRIPT_VERSION_STRING) might be better. Boost searches for config.hpp in paths that adhere to the version number approach i mentioned above: Here's Boost's FindBoost file: And here's the documentation for it: Ideally with this done, getting started with Angelscript would involve cloning the repository, setting it up with the desired compile settings (e.g. AS_NO_EXCEPTIONS, which should be possible using a CMake variable like CMAKE_CXX_FLAGS), installing it and then using it in your own projects by calling: #Find this exact version of Angelscript, error if not found find_package( Angelscript 2.32.0 EXACT REQUIRED ) target_link_libraries( my_executable optimized Angelscript::Angelscript debug Angelscript::Angelscriptd ) And then using an imported target to link with it automatically. This target could have angelscript.h specified by adding an interface_include_directories property, making it even easier. I'm assuming that a debug version would be provided as a separate target here. Having each release push a tag would make it easy to get the version you want, and you can switch to WIP by pulling the latest commit. Once set up it should be as simple as recompiling and executing the install target to bring your projects up to date. With such a repository set up on Github, it may be possible to have additional hooks triggered there to do other things, but i assume this requires write access to the repository to set up. It could allow for automatic builds to test for breaking changes or compiler/platform specific issues as well.
  9. Solokiller

    implementing partial templates

    So you want to register template specializations? That sounds good, it should complement the existing validation system, but then the callback wouldn't be invoked for specializations, right?
  10. Solokiller

    implementing partial templates

    I think what's confusing to people new to the language is that C++ templates and Angelscript templates aren't the same thing. In C++ it's a specialization that relies on compile time code generation, in Angelscript it relies on storing an object's type along with the object. Unfortunately you can't just register a type vector<T> and use std::vector for it, unless you have a class that can store an Angelscript object. Even if you did, it'd be more efficient to use a specially designed container that only stores type T's type info instead, since that takes up less memory.
  11. Did you also register the copy constructor and assignment operator? You specified these as being present (asOBJ_APP_CLASS_CDAK) but you didn't show them. You may be having issues there. Also, you showed the registration for length but not length2, could you show the code for that?
  12. Solokiller

    Variadic arguments support

    You can use the generic calling convention along with variable parameters. You'll have to register one for each number of parameters but it'll work like you want it to.
  13. Are you sure setupScene isn't being called more than once? That could explain the different addresses.
  14. How is the dbg global variable declared in C++? What is its class hierarchy, is it a class with no base classes, does it use multiple inheritance, etc. Also, try using a const reference to the string. There may be an issue with pass by value use:
  15. The WriteConfigToStream function in scripthelper.cpp fails to reset the namespace when it writes out the string factory and array type. This can result in the wrong namespace being used. For example: prop "const uint ClientDisconnect" namespace "Hooks::Game" prop "const uint MapChange" // String factory strfactory "string" // Default array type defarray "array<T>" These are the last few lines of a config i'm reading in.   Should be easy enough to fix, just add the same code to reset the namespace. I would recommend refactoring that code so the logic is in its own function, perhaps turn these helpers into classes so the current namespace is kept as a member. That's simpler than passing in a reference.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!