UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ugdk::script::InheritableLangWrapper< loader_t > Class Template Reference

Wraps a scripting language. More...

#include <ugdk/script.h>

Inheritance diagram for ugdk::script::InheritableLangWrapper< loader_t >:
Collaboration diagram for ugdk::script::InheritableLangWrapper< loader_t >:

Public Member Functions

bool RegisterModule (const Module< loader_t > &module)
 
- Public Member Functions inherited from ugdk::script::LangWrapper
virtual ~LangWrapper ()
 
const std::string & file_extension ()
 
virtual bool Initialize ()=0
 Initializes the LangWrapper. More...
 
virtual void Finalize ()=0
 Finalizes the LangWrapper, finalizing any language specific stuff. More...
 
virtual VirtualData::Ptr NewData ()=0
 
virtual void ExecuteCode (const std::string &code)=0
 
virtual VirtualObj LoadModule (const std::string &name)=0
 
LangID lang_id ()
 
const std::string & lang_name () const
 

Protected Member Functions

 InheritableLangWrapper (const std::string &file_extension, const LangID id, const std::string &name)
 

Protected Attributes

std::vector< Module< loader_t > > modules_
 

Detailed Description

template<class loader_t>
class ugdk::script::InheritableLangWrapper< loader_t >

Wraps a scripting language.

Classes derived from this should implement it's methods to wrap a given language in the system.

Besides this interface, derived classes should implement a method

bool RegisterModule(const string& moduleName, T initFunction)

where moduleName is the name of the module, as to be imported from the language; T is a language specific module init function type; initFunction is the pointer to a function of the said type to initialize the module in the language (SWIG generates these functions in the wrappers) and the bool return value tells if the module was registered correctly.

Also, in order to properly add a scripting language to the system, besides implementing this class, you need to derive the VirtualData class (like this, implementing it specific to your language), modify whatever compiling mechanisms you use to make SWIG generate the wrappers to your language; and finally, when using the scripting system, properly registering your specific wrapper in the ScriptManager and the wrapper modules you want in your LangWrapper.

Constructor & Destructor Documentation

template<class loader_t >
ugdk::script::InheritableLangWrapper< loader_t >::InheritableLangWrapper ( const std::string &  file_extension,
const LangID  id,
const std::string &  name 
)
inlineprotected

Member Function Documentation

template<class loader_t >
bool ugdk::script::InheritableLangWrapper< loader_t >::RegisterModule ( const Module< loader_t > &  module)
inline

Member Data Documentation

template<class loader_t >
std::vector< Module<loader_t> > ugdk::script::InheritableLangWrapper< loader_t >::modules_
protected

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