Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Script::ModuleLoader Class Reference

#include <ModuleLoader.h>

Classes

class  CompiledModule
 
class  Future
 The future is fulfilled once the evaluation of the module completes. More...
 
class  Result
 

Public Types

using AllowModuleFunc = std::function< bool(const VfsPath &)>
 
using RegistryType = std::unordered_map< VfsPath, CompiledModule >
 

Public Member Functions

 ModuleLoader (AllowModuleFunc allowModule)
 
 ModuleLoader (const ModuleLoader &)=delete
 
ModuleLoader & operator= (const ModuleLoader &)=delete
 
 ModuleLoader (ModuleLoader &&)=delete
 
ModuleLoader & operator= (ModuleLoader &&)=delete
 
 ~ModuleLoader ()
 
Result LoadModule (const Script::Request &rq, const VfsPath &modulePath)
 Load the specified module and all module it imports recursively. More...
 

Static Private Member Functions

static bool MetadataHook (JSContext *cx, JS::HandleValue privateValue, JS::HandleObject metaObject) noexcept
 This is only executed once per module. More...
 
static JSObject * ResolveHook (JSContext *cx, JS::HandleValue referencingPrivate, JS::HandleObject moduleRequest) noexcept
 
static bool DynamicImportHook (JSContext *cx, JS::HandleValue referencingPrivate, JS::HandleObject moduleRequest, JS::HandleObject promise) noexcept
 

Private Attributes

AllowModuleFunc m_AllowModule
 
RegistryType m_Registry
 

Member Typedef Documentation

◆ AllowModuleFunc

using Script::ModuleLoader::AllowModuleFunc = std::function<bool(const VfsPath&)>

◆ RegistryType

Constructor & Destructor Documentation

◆ ModuleLoader() [1/3]

Script::ModuleLoader::ModuleLoader ( ModuleLoader::AllowModuleFunc  allowModule)

◆ ModuleLoader() [2/3]

Script::ModuleLoader::ModuleLoader ( const ModuleLoader &  )
delete

◆ ModuleLoader() [3/3]

Script::ModuleLoader::ModuleLoader ( ModuleLoader &&  )
delete

◆ ~ModuleLoader()

Script::ModuleLoader::~ModuleLoader ( )

Member Function Documentation

◆ DynamicImportHook()

bool Script::ModuleLoader::DynamicImportHook ( JSContext *  cx,
JS::HandleValue  referencingPrivate,
JS::HandleObject  moduleRequest,
JS::HandleObject  promise 
)
staticprivatenoexcept

◆ LoadModule()

ModuleLoader::Result Script::ModuleLoader::LoadModule ( const Script::Request &  rq,
const VfsPath &  modulePath 
)

Load the specified module and all module it imports recursively.

Parameters
rqglobalThis is taken from this Script::Request.
modulePathThe path to the file which should be loaded as a module.
Returns
A range of futures. The compilation of the first future is already started. The evaluation of the subsequent futures start once the module file is edited.

◆ MetadataHook()

bool Script::ModuleLoader::MetadataHook ( JSContext *  cx,
JS::HandleValue  privateValue,
JS::HandleObject  metaObject 
)
staticprivatenoexcept

This is only executed once per module.

Following accesses of import.meta evaluate to the same object.

◆ operator=() [1/2]

ModuleLoader & Script::ModuleLoader::operator= ( const ModuleLoader &  )
delete

◆ operator=() [2/2]

ModuleLoader & Script::ModuleLoader::operator= ( ModuleLoader &&  )
delete

◆ ResolveHook()

JSObject * Script::ModuleLoader::ResolveHook ( JSContext *  cx,
JS::HandleValue  referencingPrivate,
JS::HandleObject  moduleRequest 
)
staticprivatenoexcept

Member Data Documentation

◆ m_AllowModule

AllowModuleFunc Script::ModuleLoader::m_AllowModule
private

◆ m_Registry

RegistryType Script::ModuleLoader::m_Registry
private

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