module: Re-implement using library constructors/destructors (#2018)

By using constructors/destructors we unify the case of static linking with
that of dynamic linking, and we reuse the build flag FEATURE_INIT_FINI. Using
constructors/destructors also allows us to cover the case where library
constructor/destructor functionality is unavailable, because we can expose the
module registration/unregistration functions as global symbols, to be called
explicitly from within the application.

Fixes https://github.com/jerryscript-project/jerryscript/issues/1952

JerryScript-DCO-1.0-Signed-off-by: Gabriel Schulhof gabriel.schulhof@intel.com
This commit is contained in:
Gabriel "_|Nix|_" Schulhof
2017-09-22 13:35:38 +03:00
committed by Zoltan Herczeg
parent 8d916a44f1
commit 81952f3cd0
11 changed files with 172 additions and 124 deletions
+2 -4
View File
@@ -16,7 +16,7 @@
#include "jerryscript.h"
#include "jerryscript-ext/module.h"
#ifdef JERRYX_NATIVE_MODULES_SUPPORTED
#define MODULE_NAME my_custom_module
static jerry_value_t
my_custom_module_on_resolve (void)
@@ -24,6 +24,4 @@ my_custom_module_on_resolve (void)
return jerry_create_number (42);
} /* my_custom_module_on_resolve */
JERRYX_NATIVE_MODULE (my_custom_module, my_custom_module_on_resolve)
#endif /* JERRYX_NATIVE_MODULES_SUPPORTED */
JERRYX_NATIVE_MODULE (MODULE_NAME, my_custom_module_on_resolve)