#include <livemodule.h>
Public Types | |
Public Member Functions | |
void | detachModule () |
Disengage a module after a module unlink. | |
virtual bool | finalize () |
Performs pre-delete finalization of the object. | |
Item * | findModuleItem (const String &symName) const |
Return a module item given a global symbol name. | |
void | gcMark (uint32 mark) |
Applies mark to subclasses. | |
String * | getString (uint32 stringId) const |
Return the string in the module with the given ID. | |
ItemArray & | globals () |
const ItemArray & | globals () 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 Module * | module () const |
const String & | name () 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 ItemArray & | userItems () const |
ItemArray & | userItems () |
Returns the user items of this live modules. | |
ItemArray & | wkitems () |
const ItemArray & | wkitems () const |
~LiveModule () |
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.
Falcon::LiveModule::LiveModule | ( | Module * | mod, | |
bool | bPrivate = false | |||
) |
Falcon::LiveModule::~LiveModule | ( | ) |
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.
Reimplemented from Falcon::GarbageableBase.
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.
symName | the name of the global symbol for which this item must be found |
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.
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.
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.
const Module* Falcon::LiveModule::module | ( | ) | const [inline] |
Referenced by Falcon::VMachine::currentModule().
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] |