Sign in to follow this  
Khaos Dragon

std::vector bindings for angelscript

Recommended Posts

Khaos Dragon    196
I notice that Anthony Casteel (deyja) made an std::vector binding for angelscript version 1.10... however it does not seem to be up to date with the latest angelscript.

If anybody has any advice on how to port deyja's code to the lastest version of angelscript that would be widely appreciated. I very much like how bindings for math and std::string come packaged with angelscript, but I think eventually a vector addon should be packaged, as it is another one of those core library features that most c++ programmers use.

Share this post


Link to post
Share on other sites
WitchLord    4678
Anthony's std::vector binding is part of my regression test suite. You can find the updated version in the tests/test_feature/source/ folder in the sdk.

I haven't made a standard add_on as it overloads the built-in array type.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Khaos Dragon    196
Quote:
Original post by WitchLord
Anthony's std::vector binding is part of my regression test suite. You can find the updated version in the tests/test_feature/source/ folder in the sdk.

I haven't made a standard add_on as it overloads the built-in array type.

Regards,
Andreas


Thank you Andreas, the vector implementation there works perfectly. Eventually once I get comfortable in Angelscript, I can perhaps submit some bindings to some common types.

One more question, is the scriptstring type supposed to be a simpler implementation of the std::string? I notice there are bindings for a test std::string type.

Share this post


Link to post
Share on other sites
WitchLord    4678
std::string can be bound directly with AngelScript, but then you have to bind it as a value type, i.e. asOBJ_VALUE. asCScriptString is a light wrapper for the std::string that allow the std::string to be bound as a reference type, i.e. asOBJ_REF.

I'm planning on adding a standard add-on for registering std::string directly. But I haven't gotten around to converting the stdstring.h/cpp from the test_feature folder into a proper add-on yet.

Regards,
Andreas

Share this post


Link to post
Share on other sites
WitchLord    4678
Obviously you can't register the std::vector template as some generic type that AngelScript will derive from. Templates doesn't work that way, but what you do is that you register a vector type for each vector specialization you want.

With Anthony's implementation you register the std::vector for each element type with a call to RegisterVector, e.g:


// Register std::vector<int>
RegisterVector("intVector", "int", engine);

// Register std::vector<float>
RegisterVector("floatVector", "float", engine);



Share this post


Link to post
Share on other sites
Khaos Dragon    196
Quote:
Original post by WitchLord
Obviously you can't register the std::vector template as some generic type that AngelScript will derive from. Templates doesn't work that way, but what you do is that you register a vector type for each vector specialization you want.

With Anthony's implementation you register the std::vector for each element type with a call to RegisterVector, e.g:


// Register std::vector<int>
RegisterVector("intVector", "int", engine);

// Register std::vector<float>
RegisterVector("floatVector", "float", engine);


Yes that is pretty much exactly what I do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this