static property of a class

Started by
3 comments, last by kunitoki 17 years, 11 months ago
i'm trying to attach some static member properties of the c++ classes of my library with RegisterObjectProperty and offsetof, but it seems that this is impossible, without create a copy of them in a new class published to script. there is a way to attach static properties to an object without the need to create an instance of it ? anyway would be cool if was possible to register a object property either with offsetof macro or with (void*), so i can attach a global const variable in the namespace of that object class... sometimes attaching enums and static properties to classes is very good for maintaining large projects and have all global (or object specific global) variables stored in containers, so you don't have all the global namespace filled in (and sometimes when u got a lot, is preferred to group static constants in the objects the live into)... any chance to have this implemented ?
Advertisement
It's not working because a static member isn't really a member, it's a global; offsetof can't work if the member isn't actually inside the class's memory.
i understood that after i've tried compiling those crap lines... ah was thinking about gurls with big tits when coding that ;)
i still want to hear what the Lord thinks about this...
Well, you already found out why it didn't work so I don't have to answer that. :)

Now for the possibility of registering a global property as a static member of a class in the script, this might be something to think about. I'll add it to my to-think-about list. For now I think it's rather superfluous and there are certainly other things that are more important to implement first. Still, it's not a bad idea at all, thanks for bringing it up.

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

yeah, sure there are a lot of other things to do first, so i won't bother too much with this ideas... anyway i think sometimes this will come in handy. think about instantiating objects in scripts that have construction parameters (like enums, but class specific)

// with globals or global enums:
Object o(isVisible & isBiggerThanMe);
Something s();
s.prepare(Something_isVisible);

i can't use isVisible for other object types than object without declaring variables and append "ClassName_" before.

// with static properties:
Object o(Object.isVisible & Object.isBiggerThanMe);
Something s();
s.prepare(Something.isVisible);

i still can have declared a global "bool isVisible", which is then different than Object.isVisible or Something.isVisible, without having to dirty
the global namespace with a lot of "ClassName_staticProperty" variables...

This topic is closed to new replies.

Advertisement