#include <symbol.h>
Public Types | |
typedef List | InheritList |
Public Member Functions | |
bool | addInheritance (InheritDef *parent_class) |
Adds a symbol as an inheritance instance. | |
void | addProperty (const String *name, Symbol *method) |
Shortcut to add a method to a class. | |
void | addProperty (const String *name) |
Shortcut to add a variable property. | |
void | addProperty (const String *name, VarDef *definition) |
Adds a property to a class. | |
ClassDef (Symbol *ext_ctor, ObjectFactory factory=0) | |
Creates the definition of this class an external constructor. | |
ClassDef (ObjectFactory factory=0) | |
Creates a class definition without a constructor. | |
Symbol * | constructor () const |
void | constructor (Symbol *ctor) |
ObjectFactory | factory () const |
void | factory (ObjectFactory om) |
Declares an object manager for this class. | |
VarDef * | getProperty (const String &name) const |
VarDef * | getProperty (const String *name) const |
bool | hasProperty (const String &name) |
InheritList & | inheritance () |
Return a updateable version of the inheritance list. | |
const InheritList & | inheritance () const |
bool | inheritsFrom (const String &find_name) const |
Returns true if one of the base classes of this one has the given name. | |
bool | isFinal () const |
int | isMetaclassFor () const |
bool | load (Module *mod, Stream *in) |
Map & | properties () |
Return a updateable version of the property map. | |
const Map & | properties () const |
bool | save (Stream *out) const |
void | setFinal (bool mod) |
void | setMetaclassFor (int ItemID) |
~ClassDef () |
A class symbol has multiple lives: it looks like a function, and if used as a function it has the effect to create an object instance. The class constructor is in fact the "function" held by the symbol. Other than that, the class symbol stores also symbol tables for variables (properties) and functions (methods), other than the local + params symbol table as any other callable. Finally, the ClassSymbol holds a vector of direct parent pointers, each of which being a ClassSymbol.
Class symbols can be "reflective". They can be linked with a "user data manager".
As reflection status cannot be properly serialized (atm), only user-provided and binary modules can declare reflective classes.
typedef List Falcon::ClassDef::InheritList |
Falcon::ClassDef::ClassDef | ( | ObjectFactory | factory = 0 |
) |
Creates a class definition without a constructor.
This constructor creates a class definition for those classes which doesn't require an "init" method declared at Falcon level, nor an external C method used to provide an "init" feature.
manager | The object factory used to manipulate externally provided user_data of this class. If not provided, the factory will depend on added properties. |
Falcon::ClassDef::ClassDef | ( | Symbol * | ext_ctor, | |
ObjectFactory | factory = 0 | |||
) |
Creates the definition of this class an external constructor.
This constructor creates a class that has an init method provided by an external symbol (a C function).
offset | the start offset of the constructor, if this class as a Falcon code constructor. | |
manager | The object factory used to manipulate externally provided user_data of this class. If not provided, the factory will depend on added properties. |
Falcon::ClassDef::~ClassDef | ( | ) |
bool Falcon::ClassDef::addInheritance | ( | InheritDef * | parent_class | ) |
Adds a symbol as an inheritance instance.
It also takes care to store it in the property table.
Shortcut to add a method to a class.
name | the name of the method. | |
method | the Symbol holding the method call. |
void Falcon::ClassDef::addProperty | ( | const String * | name | ) | [inline] |
Shortcut to add a variable property.
name | the name of the property that is considered a NIL variable. |
Adds a property to a class.
If the a property with the same name already existed, the content is destroyed and then overwritten.
The name is a string pointer that should be contained int the module string table.
name | the name of the property | |
definition | the definition of the property as a VarDef |
Symbol* Falcon::ClassDef::constructor | ( | ) | const [inline] |
void Falcon::ClassDef::constructor | ( | Symbol * | ctor | ) | [inline] |
ObjectFactory Falcon::ClassDef::factory | ( | ) | const [inline] |
void Falcon::ClassDef::factory | ( | ObjectFactory | om | ) | [inline] |
Declares an object manager for this class.
The instance of the object manager should be allocated in the user application or in the binary modules. The classes never dispose them.
bool Falcon::ClassDef::hasProperty | ( | const String & | name | ) | [inline] |
InheritList& Falcon::ClassDef::inheritance | ( | ) | [inline] |
Return a updateable version of the inheritance list.
const InheritList& Falcon::ClassDef::inheritance | ( | ) | const [inline] |
bool Falcon::ClassDef::inheritsFrom | ( | const String & | find_name | ) | const |
Returns true if one of the base classes of this one has the given name.
bool Falcon::ClassDef::isFinal | ( | ) | const [inline] |
int Falcon::ClassDef::isMetaclassFor | ( | ) | const [inline] |
Reimplemented from Falcon::FuncDef.
Map& Falcon::ClassDef::properties | ( | ) | [inline] |
Return a updateable version of the property map.
const Map& Falcon::ClassDef::properties | ( | ) | const [inline] |
bool Falcon::ClassDef::save | ( | Stream * | out | ) | const |
Reimplemented from Falcon::FuncDef.
void Falcon::ClassDef::setFinal | ( | bool | mod | ) | [inline] |
void Falcon::ClassDef::setMetaclassFor | ( | int | ItemID | ) | [inline] |
References fassert, and FLC_ITEM_COUNT.