Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Zylann

Member Since 24 May 2012
Offline Last Active Nov 27 2014 08:32 AM

Posts I've Made

In Topic: Template containers angelscript addon library release!

26 November 2014 - 07:19 PM

 

The script:

unordered_map<Vector2i,string> spacehash;

should compile if you register a template specialization of the aatc hashing function as described at the bottom of that manual page. The manual page also tells you that the "Vector2i" type should have an equals operator. Spacehashes for everyone.

 

But the doc says:

 

map and unordered_map are not available because they take 2 template parameters and that would require partial template specialization which angelscript probably doesnt support.

So I thought it was not possible, and I didn't found aatc_register_container_tempspec_unordered_map. Or maybe I'm not doing it right?


In Topic: Template containers angelscript addon library release!

26 November 2014 - 05:50 PM

Yay, it works, thank you!

 

Then, I tried various random things, and I got errors in some cases:

        for(vector_iterator<int> it(@karabraxos); ++it;)

The engine complains about a missing pre-increment operator. However it's not that bad after all, let's just write it++ at the moment.

    class Block
    {
        string name;
        Block(const string &in name_)
        {
            name = name_;
        }
    }
//...
        set<Block> bag;

Does not compile, as well as the following:

// Vector2i is a C++ class
        unordered_map<Vector2i,string> spacehash;

They say

E: ../projects/samples/helloworld/HelloWorld.ac: (112, 7): Attempting to instantiate invalid template type 'set<Block>'

and

E: ../projects/samples/helloworld/HelloWorld.ac: (126, 3): An exception Type 'Vector2i' has no method required for container's 'unordered_map::insert' method. occurred.

 

EDIT: I tried adding a default constructor to Block, the error turned to:

E: ../projects/samples/helloworld/HelloWorld.ac: (117, 3): An exception Type 'Block' has no method required for container's 'set::insert' method. occurred.

 

I assume I have to write a specialization for each C++ types I could put as a key of the containers... oh no, we can't do this for maps and unordered_maps? No template space hashs yet, then tongue.png

 

How could we use script classes as keys, then? Maybe defining an uint someFunctionNameToGetHashCode(const T &in v) function overload?

And how could we use object handles as keys, but STILL using someFunctionNameToGetHashCode for those? (sorry, I like to find edge cases...)

 

Finally, a bit of syntax:

to access the key and the value of a map_iterator, we have to write:

it.current_key();
it.current_value();

But it could be shorter to write like this:

it.key
it.value

Where key and value are actually properties returning references, and we could assign them transparently if needed (oh. But what happens if we assign the key of a map while iterating?).

 

The auto syntax works pretty well, maybe we're close to a foreach mechanism? Just a macro and here you go tongue.png

#define foreach(iterator_name, container) for(auto iterator_name = container.begin(); it++;)

In Topic: Template containers angelscript addon library release!

26 November 2014 - 04:28 PM

Wow, that was quick smile.png

I tried to include your code in my project to see if it works, however I noticed you used an as:: alias of the AngelScript namespace, while I don't in the rest of my code...

 

// In aatc_config.hpp

namespace as = AngelScript;

 

This line fails because the AngelScript namespace is not defined (on purpose, I didn't added AS_USE_NAMESPACE to my preprocessor definitions).


In Topic: Template containers angelscript addon library release!

24 November 2014 - 07:45 PM

This is exactly what I've been searching for. I'm building a modular game engine with AngelScript as main scripting language, so I'm definitely going to have a look to your work. Thank you for sharing this :D

Just one comment about iterator syntax:

We should be able to use auto instead of rewriting the container type, like we can in C++. Do you think it could be implemented?


In Topic: Problem implementing a BMFont renderer

21 December 2012 - 08:22 AM

Oh. Yes, I inverted the Y axis and it works !

That's actually logic, we read a text from top to bottom...

 

Thanks for your help smile.png


PARTNERS