Sign in to follow this  

Understanding some basics

This topic is 1733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm still rather new to Angel script but have managed to get most of it down. There are however a few things that I'm still unsure about.

The main one is the ref use in Angel script which from the looks of it is the same as a pointer or reference in c++. However when do I want to be using this over a value. For example if I am registering a class i wish to create within the script do I class it as a reference and set up (I believe)  a factory function for it to construct a new instance within c++ and then reference it back to angel script or should I just use a valve and let angel script deal with its construction of the instance.

The other thing that I am unsure about (though I should do some test first before asking) is what do I do for pointer array and template returns/parameters.

Thanks for the help

Share this post


Link to post
Share on other sites

Reference types are those that are allocated on the memory heap rather than on the stack. Basically you'll want to use reference types for any type that should be able to outlive the scope in which it is created. On the other hand value types are those that will be allocated on the stack (or as local members of other objects). As these types can't outlive the scope in which they are created they should be used for those types that are used for quick calculations and can then be discarded. Also, for value types you'll want to keep the size and complexity down to a minimum. If the type is large or complex it is an indicator that the type should probably be a reference type.

 

C++ pointer arrays unfortunately have no match in AngelScript, so the recommended way of handling them is by wrapping the function to copy the content to a CScriptArray (see the add-ons).

 

C++ templated types are determined at compile type. You'll need to register the template function for each combination of return type and parameter types you expect the scripts to use.

 

Regards,

Andreas

Share this post


Link to post
Share on other sites

This topic is 1733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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