🎉 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!

Changing the pointer of a class member

Started by
2 comments, last by WitchLord 16 years, 3 months ago
Alright say i have a class that looks like this: AngelScript

class Blah
{
  float x;
  float y;
}
Than i create an instance of it using CreateScriptObject() and i now want to change the pointer of the x and y to my own x and y. Like this: C++

float x, y;
(float*)instance->GetPropertyPointer(0) = &x
(float*)instance->GetPropertyPointer(1) = &y
What happens to the x and y that angel script created in CreateScriptObject()? Does it get freed?
Advertisement
GetPropertyPointer() returns a pointer to the property so that you can read it's value or overwrite it. It doesn't let you change the actual location of the property.

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

Oh yeah. I was actually wondering how could that be possible until i looked at the examples of "GetReturnPointer()" and saw they were actually changing the value, not the pointer. It was the pointers to pointers that was confusing me.
The name of the method doesn't help much either. I'm considering renaming it, e.g. to GetPointerToProperty().

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

This topic is closed to new replies.

Advertisement