Falcon::ClassDef Class Reference

Class symbol abstraction. More...

#include <symbol.h>

Inheritance diagram for Falcon::ClassDef:

Inheritance graph
[legend]

List of all members.

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.
Symbolconstructor () const
void constructor (Symbol *ctor)
ObjectFactory factory () const
void factory (ObjectFactory om)
 Declares an object manager for this class.
VarDefgetProperty (const String &name) const
VarDefgetProperty (const String *name) const
bool hasProperty (const String &name)
InheritListinheritance ()
 Return a updateable version of the inheritance list.
const InheritListinheritance () 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)
Mapproperties ()
 Return a updateable version of the property map.
const Mapproperties () const
bool save (Stream *out) const
void setFinal (bool mod)
void setMetaclassFor (int ItemID)
 ~ClassDef ()


Detailed Description

Class symbol abstraction.

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.


Member Typedef Documentation


Constructor & Destructor Documentation

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.

Parameters:
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).

Parameters:
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 (  ) 


Member Function Documentation

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.

Returns:
true if the add is successful, false if the inheritance has been already added.

void Falcon::ClassDef::addProperty ( const String name,
Symbol method 
) [inline]

Shortcut to add a method to a class.

Parameters:
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.

Parameters:
name the name of the property that is considered a NIL variable.

void Falcon::ClassDef::addProperty ( const String name,
VarDef definition 
)

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.

Parameters:
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.

VarDef* Falcon::ClassDef::getProperty ( const String name  )  const [inline]

VarDef* Falcon::ClassDef::getProperty ( const String name  )  const

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]

bool Falcon::ClassDef::load ( Module mod,
Stream in 
)

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.


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 10:11:32 2009 for Falcon_Core by  doxygen 1.5.8