Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About johannesg

  • Rank

Personal Information

  • Interests
  1. johannesg

    Question about nullptrs

    Ok, thanks for the info. I'll make the necessary changes to ensure I'm not invoking UB. Could I do this instead: object @O = makeobject ("foo"); and have that potentially return a nullptr?
  2. johannesg

    Question about nullptrs

    I think the reasoning more or less went like this: "In C++ I'd just make a constructor and then throw when I can't get the resource... Angelscript doesn't have exceptions (back then)... Ah wait, it lets me return a nullptr instead so it's all good." The whole development cycle happened under a lot of time pressure, unfortunately, so once I had something that worked, I didn't spend too much time playing around with it to see if there was a better option. Of course that's now coming back to bite me... And we did this for an external customer, so I should endeavour to keep the interface stable. Anyway, it's kinda surprising that the two snippets I posted aren't equivalent.
  3. johannesg

    Question about nullptrs

    I have an object that may end up returning a null reference: object O1 ("foo"); // O1 is null object @O2 = @O1; // all ok! This works fine: both O2 and O2 are null. So surely I can join those statements together? object @O3 = object ("foo"); // nullptr error But no, that doesn't work: in this case the script aborts with a nullptr error. Am I doing something wrong? Am I just misunderstanding how it is supposed to work? Is it ok to return null from a constructor? It's doing a lookup for an object with id 'foo', which may or may not exist... Thanks for any enlightenment offered!
  4. johannesg

    PDF manual?

    Thanks, I'll give that a try.
  5. johannesg

    Catching two in a row

  6. johannesg

    PDF manual?

    Just a quick question... Is there a PDF manual somewhere that describes the scripting language? I am of course familiar with the website, and it contains pretty much exactly what I need, but the dark forces of the universe (*cough*QA*cough*) love to see their printed, or at least printable, manuals... Thanks!
  7. ScriptThrow and ScriptGetExceptionInfo assume that the user-declared string type is always std::string. If you are using your own string class, that is obviously not going to end well. It's not a huge deal, since you can implement them yourself easily enough, but a warning might not be a bad idea... For the rest, thanks for this new release! ๐Ÿ™‚
  8. johannesg

    Catching two in a row

    It seems if I have two try/catch blocks in a row in a function, the second one doesn't seem to catch anything. For example, this script: void main() { try { throw ("1"); } catch { print ("Exception 1"); } try { throw ("2"); } catch { print ("Exception 2"); } try { throw ("3"); } catch { print ("Exception 3"); } } prints only this: Exception 1 2 So the first exception is caught and handled correctly, and the second one aborts the script (which prints the aborting exception, in my case, so you see the "2").
  9. johannesg


    Ah, I didn't realize there was already a version supporting exceptions. Is the WIP version suitable for use in a production environment? Or would it be better to wait for a formal release?
  10. johannesg


    Am I correct in thinking that Angelscript does not currently support the 'using' keyword? If so, that is a bit of a shame: it would allow us to stick the whole library in a namespace, without actually having to bother the user with having to prefix everything with 'std::'. Right now this isn't a big deal for us yet, since there is only one version of our tool and the user can easily avoid name clashes in their scripts, but I'm thinking about future updates that will have additional library classes and functions. Ideally those would live in their own namespace, so as not to cause any name clashes, but I'd still like the ability to bring them into a script using either a single `using namespace <name>`, or, should that result in a clash, a more targeted `using <object name>`. So uhh, could I request for this to be added to the Angelscript wish list? ๐Ÿ™‚ While I'm at it, I certainly wouldn't say no to the ability to catch exceptions in scripts either ๐Ÿ˜€
  11. johannesg

    Some implementation questions

    I'm having a hard time making this work. Is this the correct approach? Engine.RegisterObjectMethod ("foo", "void bar()", asFUNCTION ([] (foo &Foo) { Foo.Bar (); }), asCALL_CDECL_OBJFIRST); ...because this doesn't compile, with error C2440: '<function-style-cast>': cannot convert from 'T' to 'size_t' Ok. I was hoping there was a way I could use those {repeat} statements in normal functions as well ๐Ÿ™‚ I think I understand the problem: both threads are accessing the string factory, and that one is marked as "not thread safe". Sorry - it took me a while to notice that. I now have mutex protection around the discard call, so it isn't a problem anymore. Odd: I have plenty of reference types around. Is it object creation that creates garbage, or more specifically creating cycles between objects that does? Anyway, thanks for the help!
  12. johannesg

    Some implementation questions

    Sorry for the lousy title, but I don't really want to post half a dozen separate threads. Hope that's ok! I'm implementing an angelcode interface to our software. I'm generally very happy with both the API and language itself, but I still have some questions. 1. Is there a way to pass a C++ lambda to RegisterObjectBehaviour? I find myself writing numerous one-liners when existing functions don't _quite_ match what I want to expose to the script. A lambda would save a bit of code. 2. Is it possible to create a script function that takes something like an initializer_list (from C++)? I have some cases where being able to pass any number of arguments (all of the same type) would be very useful. 3. I have asEP_USE_CHARACTER_LITERALS set to true. However, the engine still accepts multiple characters between single quotes. Is this intended behaviour? 4. Am I correct in assuming that DiscardModule also changes the internals of the engine, and should therefore also only be called from one thread? Or at least be protected by a mutex? 5. I'm still a little unclear on how often I should be collecting garbage. When I call GetGCStatistics() all five parameters always return 0, even though quite a bit of script activity has been going on by then. Our use case involves running scripts for up to six months at a time, so I'd like to make sure we do the garbage collection correctly and not run out of memory halfway through. Thanks in advance!
  • Advertisement

Important Information

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

GameDev.net 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!