Ecere SDK/eC Forums • View topic - class_property




Ecere SDK/eC Forums

Ecere Developers Community

class_property

General help with the eC language.

class_property

Postby redj » Wed Feb 09, 2011 11:25 am

Question from JF:
What is the purpose of class_property(...)?

-redj
redj
 
Posts: 107
Joined: Sun Jan 17, 2010 10:03 am

Re: class_property

Postby jerome » Wed Feb 09, 2011 2:02 pm

The class_property keyword, a rather 'internally used' feature so far, allows to associate a value (limited to a type that will fit in the size of an 'int' for the moment / an good example of a bad assumption that won't fly on 64 bit ) with that particular class.

It's somewhat analogous to an 'object property', where the property is associated with the instance of a class. Here it is the class itself that has that property. A class property has a set and a get as well. It is defined in a base class like this:

(Inside the Window class)
class_data char * icon;
class_property char * icon
{
set { class_data(icon) = value; }
get { return class_data(icon); }
}

You can them invoke the 'set' from a derived class by putting directly inside your class a statement like:
class Button { ...
class_property(icon) = "<:ecere>controls/button.png";
... }

It is currently most often retrieved using the eClass_GetProperty function (side note: We still need to OO'ify the set of base eC functions, GetProperty should be a method of the 'Class' class).

Note above the usage of 'class_data', which is most often used alongside the class_property.
class_data reserves storage space for a particular piece of data ( that is usually retrieved using class_property ) for all classes derived from this base class.

As said earlier, this class property feature is mostly used internally. In this particular case, to associate an icon with the common control classes. It is also used for specifying the properties of the DisplayDriver s, which is where I assumed you encountered it. Along with the instance-less virtual methods ('static' methods in C++), it forms a framework that resembles Java interfaces.
jerome
Site Admin
 
Posts: 622
Joined: Sat Jan 16, 2010 11:16 pm


Return to eC Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron