Fake Native Modules
Fake native modules are a means of adding API to a script running within an application
with exactly the same method as a module. Rather than let ferite load the module, you simply
register the module, tell ferite to pre-load it, and away you go. The example below assumes
a module compiled into the application.
ferite_module_register_fake_module( "theapp.lib", theapp_register, theapp_unregister, theapp_init, theapp_deinit );
ferite_module_add_preload( "theapp.lib" );
|
The ferite_module_add_preload is important so that the module gets compiled
into the script at compile time and therefore allows for initialisation code that gets executed
to access the application. Please note that the .lib extension is very
important. This is so that ferite knows that it is a native module and can handle it correctly
[and also find it]. You should refer to the last chapter on writing native modules by hand for
the information on how to write the native module. For those of you feeling slightly more lazy,
read on, there is a cunning use of builder.
The above code should be placed before the calls to ferite_script_compile or
ferite_compile_string.