Skip to content

Remove stringification of JERRYX_NATIVE_MODULE module_name argument? #1952

@martijnthe

Description

@martijnthe

See https://github.com/jerryscript-project/jerryscript/blob/master/jerry-ext/include/jerryscript-ext/module.h#L51

module_name is stringified, which will cause the argument to not be evaluated by the preprocessor but used verbatim.

After having used the macro in practice, I found that it's not desirable to stringify it, because:

  • it prevents one from creating macros that call the JERRYX_NATIVE_MODULE macro and pass in a variable module name

  • it makes it impossible to single-source the module name, i.e. I cannot write something like:

#define MY_MODULE_NAME my_module
#define MY_MODULE_NAME_STR STRINGIFY(MY_MODULE_NAME)

void
foo (void)
{
  const jerry_value_t m = call_require(MY_MODULE_NAME_STR);
  // ...
}

// module will actually be named "MY_MODULE_NAME"...
JERRYX_NATIVE_MODULE(MY_MODULE_NAME, ...)   

Therefore I propose to remove the stringification (#) from the macro.
I realize it's a breaking change, but the API is pretty new and the migration path is super simple.

Thoughts @gabrielschulhof ?

cc @jiangzidong

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions