Falcon::LiveModule Class Reference

Instance of a live module entity. More...

#include <livemodule.h>

Inheritance diagram for Falcon::LiveModule:

Inheritance graph
[legend]

List of all members.

Public Types


Public Member Functions

void detachModule ()
 Disengage a module after a module unlink.
virtual bool finalize ()
 Performs pre-delete finalization of the object.
ItemfindModuleItem (const String &symName) const
 Return a module item given a global symbol name.
void gcMark (uint32 mark)
 Applies mark to subclasses.
StringgetString (uint32 stringId) const
 Return the string in the module with the given ID.
ItemArrayglobals ()
const ItemArrayglobals () const
void initialized (t_initState tis)
t_initState initialized () const
bool isAlive () const
 Is this module still alive? Short for this->module() != 0.
bool isPrivate () const
 Returns the privacy status of this module.
 LiveModule (Module *mod, bool bPrivate=false)
const Modulemodule () const
const Stringname () const
 Just a shortcut to the name of the module held by this LiveModule.
void needsCompleteLink (bool l)
 True if this module requires a second link step.
bool needsCompleteLink () const
 True if this module requires a second link step.
void setPrivate (bool mode)
 Changes the privacy status of this module.
const ItemArrayuserItems () const
ItemArrayuserItems ()
 Returns the user items of this live modules.
ItemArraywkitems ()
const ItemArraywkitems () const
 ~LiveModule ()


Detailed Description

Instance of a live module entity.

The VM sees modules as a closed, read-only entity. Mutable data in a module is actually held in a per-module map in the VM.

This class helds a reference to a module known by the VM and to the variable data known in the module.

A module can be entered only once in the VM, and it is uniquely identified by a name.

This class acts also as a weak reference between live callable items and modules. When a live module is unlinked, the contents of this class are zeroed and every callable item referencing this module becomes a nil as isCallable() gets called.

The live module keeps also track of strings taken from the underlying module string table and injected in the live VM. In this way, the strings become independent from the underlying module, that can be unloaded while still sharing string data with the host VM.

This object is garbageable; it gets referenced when it's in the module map and by items holding a callable in this module. When a module is unlinked, the LiveModule may be destroyed when it is not referenced in garbage anymore, or at VM termination.

Note:
Although this is a Garbageable item, and as such, it resides in the memory pool, there isn't any need for precise accounting of related memory, as globals are allocated and destroyed when the module is linked or unlinked, and not (necessarily) when this item is collected. As the memory associated with this object is separately reclaimed by detachModule(), and it cannot possibly be reclaimed during a collection loop, there is no meaning in accounting it.

Member Enumeration Documentation

Enumerator:
init_none 
init_trav 
init_complete 


Constructor & Destructor Documentation

Falcon::LiveModule::LiveModule ( Module mod,
bool  bPrivate = false 
)

Falcon::LiveModule::~LiveModule (  ) 


Member Function Documentation

void Falcon::LiveModule::detachModule (  ) 

Disengage a module after a module unlink.

virtual bool Falcon::LiveModule::finalize (  )  [virtual]

Performs pre-delete finalization of the object.

If this function returns false, then the destructor is called. If it returns true, it means that the finalizer has somewhat reclaimed the memory in a clean way (i.e. deleting itself), so the delete on this garbageable won't be called.

Returns:
true to prevent destructor to be applied on this garbageable.

Reimplemented from Falcon::GarbageableBase.

Item* Falcon::LiveModule::findModuleItem ( const String symName  )  const

Return a module item given a global symbol name.

This is an utility funtion retreiving an global item declared by the module that is referenced in this live data.

Parameters:
symName the name of the global symbol for which this item must be found
Returns:
0 if not found or a pointer to the item which is indicated by the symbol

void Falcon::LiveModule::gcMark ( uint32  mk  )  [virtual]

Applies mark to subclasses.

By default, this method just changes the mark() value.

Subclasses having deep data may overload this to take care of marking it.

Reimplemented from Falcon::Garbageable.

String* Falcon::LiveModule::getString ( uint32  stringId  )  const

Return the string in the module with the given ID.

ItemArray& Falcon::LiveModule::globals (  )  [inline]

const ItemArray& Falcon::LiveModule::globals (  )  const [inline]

void Falcon::LiveModule::initialized ( t_initState  tis  )  [inline]

t_initState Falcon::LiveModule::initialized (  )  const [inline]

bool Falcon::LiveModule::isAlive (  )  const [inline]

Is this module still alive? Short for this->module() != 0.

Returns:
true if the module is still alive.

bool Falcon::LiveModule::isPrivate (  )  const [inline]

Returns the privacy status of this module.

If the module is not private, the VM will export all the exported symbol to the global namespace at link time.

Returns:
true if this module is private, and so, if didn't export any symbol.

const Module* Falcon::LiveModule::module (  )  const [inline]

const String& Falcon::LiveModule::name (  )  const [inline]

Just a shortcut to the name of the module held by this LiveModule.

void Falcon::LiveModule::needsCompleteLink ( bool  l  )  [inline]

True if this module requires a second link step.

bool Falcon::LiveModule::needsCompleteLink (  )  const [inline]

True if this module requires a second link step.

void Falcon::LiveModule::setPrivate ( bool  mode  )  [inline]

Changes the privacy status of this module.

If changing private to public, the VM funcrion exporting public symbols must be separately called.

const ItemArray& Falcon::LiveModule::userItems (  )  const [inline]

ItemArray& Falcon::LiveModule::userItems (  )  [inline]

Returns the user items of this live modules.

Modules often need a module-global storage. However, the virtual machine doesn't offer this space, and using global variables requires a bit of gym to get the variable ID and the item in the live module global array.

The module functions, at extension level (i.e. the C++ implementations) can take advantage of this item array which is dedicated to them.

The array is also autonomously GC marked.

ItemArray& Falcon::LiveModule::wkitems (  )  [inline]

const ItemArray& Falcon::LiveModule::wkitems (  )  const [inline]


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

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