Reassembling the polygonal library

I’ve just finished restructuring my library into smaller parts – this was necessary because the previous monolithic approach has become really hard to maintain. Now, I can push updates more frequently and adding new stuff should be also much easier.
The various parts of the library are now hosted on github: https://github.com/polygonal.
I apologize for any inconvenience and hope the reorganization does not break that much code.
BTW, the library now fully supports Haxe 2.10 :)

17 Comments

  1. I’m actually using the ds library for my project because it has so many useful tools. One question, can the memory manager be used to help manage alchemy memory of other swfs? I’ve been thinking about it since I saw it and have been wondering for some time if I could use it for that purpose.

    chuck

  2. Michael

    Hey Chuck,
    I’m not sure… never tried this. But IMHO I think it’s not possible.

  3. I’ve also been using your library in a project of mine, and have had a couple of issues – it works great when I’m using the flash output target, but when I switch to using the CPP target, I get quite a few problems, mainly the compiler complains about ‘early returns’, (which as the documentation here says http://haxe.org/ref/inline isn’t allowed) – is this something you’re aware of? I’ve had to make changes to the code in the library to get it to export (mainly altering methods to not have early returns, or just remove the inline).

    Also, this latest version causes my project to crash instantly after it finished compiling, with no error output. Rolling back to the previous version fixed this.

    Sorry to be negative, it’s a great library – I just want to be able to use it in my windows project! If you’d like any more information, please ask.

    1. Michael

      Can you tell me which classes are affected? I want to fix this ASAP. best, michael

  4. I’m afraid I didn’t make a comprehensive list – and I’m only using the ds part, so there may be similar problems in other parts of the library, but as I recall, they were:

    Collection, DA, DLL, HashTable, HashSet, InHashTable, and IntIntHashTable.

    I’m currently only using HashSet, HashTable and DLL so it’s possible that these classes only came up because they are the ones needed to implement those classes (I assume that unused classes don’t get compiled?)

    If it would help, I could send you a zip of the changed (and working) version of version 1.22 that I have mode – although I should point out that as I said, most of my fixes were just remove the inline declaration, rather than actually restructure the method so it would be ‘inlineable’.

    Also, you were slightly inconsisent in whether optional arguments where marked with ‘?’s – again, flash was fine, but CPP gave compiler errors.

  5. Michael

    Hi,I found a bug in IntIntHashTable (it’s rather an unfinished feature) and fixed it in the github-dev branch of ds. Other than that all my unit-tests pass. I’m using hxcpp and nme from haxelib and haxe 2.10 (official installer).

    1. Ok, I don’t know why it’s passing your unit tests, but giving me compiler errors, but I’ll give you an example of the kind of errors i’m getting – in de.polygonal.ds.HashTable, you have the following method:

      inline public function setIfAbsent(key:K, val:T):Bool
      {
      if ((size() == getCapacity()))
      {
      if (_h.setIfAbsent(__key(key), size()))
      {
      _expand(getCapacity() >> 1);

      _vals[_free] = val;
      _keys[_free] = key;
      _free = __getNext(_free);
      return true;
      }
      else
      return false;
      }
      else
      {
      if (_h.setIfAbsent(__key(key), _free))
      {
      _vals[_free] = val;
      _keys[_free] = key;
      _free = __getNext(_free);
      return true;
      }
      else
      return false;
      }
      }

      Which I have had to change to the following in order to get it to compile:

      inline public function setIfAbsent(key:K, val:T):Bool
      {
      return if ((size() == getCapacity()))
      {
      if (_h.setIfAbsent(__key(key), size()))
      {
      _expand(getCapacity() >> 1);

      _vals[_free] = val;
      _keys[_free] = key;
      _free = __getNext(_free);
      true;
      }
      else
      {
      false;
      }
      }
      else
      {
      if (_h.setIfAbsent(__key(key), _free))
      {
      _vals[_free] = val;
      _keys[_free] = key;
      _free = __getNext(_free);
      true;
      }
      else
      {
      false;
      }
      }
      }

      Because you’re not allowed to have returns that aren’t at the end of the method, and changing the code to this does that

  6. Michael

    on my system everything compiles fine, otherwise I couldn’t run my unit tests. which compile flags do you use? btw, both versions of setIfAbsent are equivalent and have final returns.

  7. Well, here’s the thing that’s really odd – it doesn’t always complain about something, but once it starts it won’t stop. For instance, I’ve been working on my project using my modified version of your library for days now, and just now as I was looking at code to give you as examples of things that it complains about, it’s given another error in a mehtod that up until now it’s been happy about – here’s the error (along with my compile options):

    haxelib run nme build “D:\Users\Paul\HaXe\Flash Develop\NME RTS\application.nmml” windows
    C:\Motion-Twin\haxe\lib\polygonal/1,22/de/polygonal/ds/HashSet.hx:393: characters 3-14 : Cannot inline a not final return

    Here’s the method that it’s complaining about:

    inline public function remove(x:T):Bool
    {
    var i = _h.get(__key(x));
    if (i == IntIntHashTable.KEY_ABSENT)
    return false;
    else
    {
    _vals[i] = null;
    __setNext(i, _free);
    _free = i;

    var shrink = false;

    if (_sizeLevel > 0)
    if (size() – 1 == (capacity >> 2))
    if (_isResizable)
    shrink = true;

    _h.clr(__key(x));

    if (shrink) _shrink();

    return true;// 0)
    if (size() – 1 == (capacity >> 2))
    if (_isResizable)
    shrink = true;

    _h.clr(__key(x));

    if (shrink) _shrink();

    true;
    }
    }

    Now, looking at the error message, it appears to be coming from nme, rather than haxe itself. It’s possible it’s a bug with nme that is giving these error messages. I was under the impression that nme just ran a script to prepare assets, and then compiled like any other haxe project, ut maybe there is more to it than that?

  8. Michael

    Have you tried compiling with –no-inline flag?

  9. I have just tried it, and it compiles without error when I specify –no-inline, but it’s started giving me yet another error:

    C:\Motion-Twin\haxe\lib\polygonal/1,22/de/polygonal/ds/IntIntHashTable.hx:579: characters 4-28 : Cannot inline a not final return

    And I’m not even using the IntIntHashTable class. I can also fix this error by re-structuring in the way I did in the above example.

  10. lgstarn

    It seems all of the examples are now broken… for example

    de.polygonal.core.Root.init(function() _app = new SimpleExample());

    doesn’t work anymore as the Root class seems to have been changed to a simple logger… what is the new entry point for your classes??? Can you please fix your examples to work again?

    1. Michael

      Hi,
      sorry I have not found time yet to update the examples. Will try to fix them these days.

      1. lgstarn

        I am looking forward to using your polygonal library to do an interactive Voronoi Haxe program much like this:

        http://nodename.com/blog/2009/05/11/a-voronoi-toy/

        It would be great to have access to the GPC code through Haxe, but I’d like an example to work with! :-) Thank you for your hard work…

          1. lgstarn

            Perfect, thank you. :-)

Get Adobe Flash player