Jump to content
  • Advertisement
Sign in to follow this  
SiCrane

User data

This topic is 3695 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

A couple questions: is there an equivalent for SetUserData()/GetUserData() for asIScriptEngine? Also, for asIScriptContext, is there a way to register a function to cleanup user data when the context is destroyed?

Share this post


Link to post
Share on other sites
Advertisement
Sounds good, but I have another question: is there any way to map a type id from GetVarTypeId() to the actual type for primitives? Right now it seems like the type ids depend on what types show up first when scripts are compiled. To put things in context, I decided to see how using AngelScript from .NET would work out and for a proof on concept application I choose to make the world's most primitive debugger. So if I use this script:

int calc(int a, float b) {
print("Received: " + a + ", " + b + "\n");
return a * b;
}

void main() {
calc(3, 2);
}

a shows up with type id of 1 and b shows up with a type id of 2. If I swap things around

int calc(float a, int b)

a shows up with a type id of 2 and b shows up with a type id of 1... until I restart the application, and then a becomes 1 and b becomes 2 again.

For reference, the MSVS 2008 solution for this project is available here. (It requires the addition of SetUserData()/GetUserData() to asIScriptEngine (included in the project) as well as Scintilla.NET.)

Share this post


Link to post
Share on other sites
The idea is that you should compare the type id from GetVarTypeId with the result from GetTypeIdByDecl, alternatively call GetTypeDeclaration and compare the names of the types.

Share this post


Link to post
Share on other sites
Ok, another question on this topic: is there any way to tell if a local variable has been constructed yet in a line callback or suspended thread?

Share this post


Link to post
Share on other sites
AngelScript currently does not keep the scope of the variables in the functions, so there is no direct way of knowing if the variable has been constructed yet.

All object type variables are however null until they have been constructed, so that might help a bit.

Share this post


Link to post
Share on other sites
Last two for today, I promise: Is there an equivalent of GetVarTypeId() for globals or do I have to parse the result from GetGlobalVarDeclaration()? Also, if I have a type Object registered as a value type, why does GetVarPointer() return an Object ** instead of an Object *?

Share this post


Link to post
Share on other sites
AngelScript is currently missing a GetGlobalVarTypeId. I just forgot to add this one, I'll do that for version 2.15.0.

You can however get the type by id by calling GetTypeIdByDecl(GetGlobalVarDeclaration()).

Currently AngelScript stores all registered types on the heap, whether they are value types or reference types. This is going to change in the near future (will improve both memory footprint and performance).

I'll also do with GetVarPointer what I did with GetGlobalVarPointer, i.e. deprecate it and create a GetAddressOfVar instead. GetAddressOfVar will return the address of the object directly, in the case of value types.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!