🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

native array support

Started by
27 comments, last by Deyja 19 years, 8 months ago
I know this is a tired subject, but you mentioned that you would have native array support possibly in version 1.10.0 i believe, and was wondering if this is still on slate with all of the current events that have happened.
Advertisement
Hey Rain Dog,

Quote: I will now concentrate on implementing support for native arrays, and also writing testcases to cover the rest of the bytecode instructions.


This is a quote taken from the WIP 3 thread here .

Can't wait for this myself, it's been the one thing preventing me from committing completely to AS since I first started lurking here around v1.7 :)

I'd also just like to say, keep up the great work Andreas! ;) I'm amazed by how much progress you've managed to make in the last few weeks. Can't wait to get back into this again.

Cheers!

Adam
Yes, I'm working on it right now. It is the main goal with version 1.10.0. There's been a lot of other improvements that made it in to 1.10.0 before the arrays, but that is only because they were much easier to implement.

I hope I can finish the arrays until the end of the month, but I can't promise anything.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Sounds good.
Development of the arrays have progressed well during these last few days. This weekend I hope to release a WIP with working single dimensional arrays (working but severly limited).

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I have seen that struct/class are the next task in WIP.

Do you think (Andreas) that implementing struct would be a difficult task ?

I'm asking this because I'm waiting for beeing able to store arrays of structs that have been defined in AS.
if it is an array of structs or classes, i am assuming that with native array support you would be able to create an array of pointers, and then you would just have to register ->

Is this correct?

Also, i have a question about the array implementation: Multiple dimensions are one dimensional arrays with a neater syntax:

int array[5][10];
int *mp = array;

*(mp + 10) == array[1][0]
abrken:

I'm almost certain that I will come upon problems while developing the structs, but I'm absolutely certain that I will be able to overcome them. For simple structs I don't think there will be too much problems, but when I start including inheritance of C++ classes I'm sure there will be some difficulties. The biggest problem with script declared structs is their constructor/destructor, but I believe I have that covered.

I'm hoping to have simple structs without methods implemented by the end of November. I'll have to see then what I'll do next.

Rain Dog:

An array will be able to store any object that you can store locally on the stack. Thus an array of pointers is possible.

Because each array is an object in itself it is difficult to make that optimization for multiple dimensional arrays of fixed sizes. But I will see what can be done. For now, you'll have to do it manually, but doing the multiplication before accessing the single dimensional array.






AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

It's now possible to execute scripts like this:

void Test()                                     {                                                  string[] a;                                     a.resize(5);                                    a[0] = "Hello, ";                               a[1] = "my ";                                  a[2] = "name ";                                a[3] = "is ";                                  a[4] = "Andreas.";                             for( uint n = 0; n < a.length(); n++ )             print(a[n]);                              }                                               


As you can see, there are a few differences from C++ arrays. The first is how the array object is declared:

"string[] a;" instead of "string a[];"

I decided to do it like this, because it was easier, and I think it makes sense to think of the array as a separate type, not a type modifier. Also it's not possible to set the size of the array directly in the declaration. I'm thinking of having a constructor that takes an integer to do that, but this hasn't been decided yet.

string[] a(5);

I had initially thought to make the array object an externally registered object, just like the string object. But since the array object must be able to work with all object types this wasn't possible. I may allow the application to register specialized array objects, that override the default array for that data type.

There are a few things that I need to clean up before I can release this WIP, but everything is on track for a release this weekend.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Quote: Original post by Rain Dog
if it is an array of structs or classes, i am assuming that with native array support you would be able to create an array of pointers, and then you would just have to register ->

Is this correct?

Also, i have a question about the array implementation: Multiple dimensions are one dimensional arrays with a neater syntax:

int array[5][10];
int *mp = array;

*(mp + 10) == array[1][0]



*(mp + 10) == array[1][0]

there is no multiplication there, it is indirection and pointer arithmetic that is the equivalent of using bracket notation []

This topic is closed to new replies.

Advertisement