Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Understanding some basics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Dekowta   Members   -  Reputation: 265

Like
0Likes
Like

Posted 18 April 2013 - 08:00 AM

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



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3375

Like
3Likes
Like

Posted 18 April 2013 - 06:51 PM

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


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

#3 Dekowta   Members   -  Reputation: 265

Like
0Likes
Like

Posted 19 April 2013 - 08:10 AM

Thanks for the reply that has cleared it up a lot form me.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS