Skip to content

[Proposal] Introduce new jerry-ext methods to ease method/property registration #2715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

galpeter
Copy link
Contributor

New methods

  • jerryx_set_functions: Allows multiple method registration for via a single call
  • jerryx_set_property_str: Allows property registration without the need to
    create the property name JS value. The property name can be directly passed
    as a const char* value and must be zero terminated.

@galpeter galpeter added the jerry-ext Related to the jerry-ext library label Jan 18, 2019
@akosthekiss
Copy link
Member

I wonder whether this proposal could be merged into jerry-ext/handler somehow? That extension module contains oft-used native function implementations and a helper to register them into the global object. Couldn't that be extended with helper(s) to register functions 'elsewhere', too? (Property registration would be a bit of an outlier in jerry-ext/handler, I know. At least the name "handler" doesn't seem to fit perfectly.)

@zherczeg
Copy link
Member

I have no objection to have this function.

Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO when you using the Jerry API you always write similar registration functions for yourself for each type so the necessity of these functions is unquestionable. I belive that is the motivation of the PR so I higly support this idea.

Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In overall I think the basics are good now.

@galpeter galpeter force-pushed the ext-reg-funcs branch 3 times, most recently from bc33cf2 to 2198bdd Compare July 11, 2019 12:44
@galpeter galpeter force-pushed the ext-reg-funcs branch 2 times, most recently from 1b5f638 to c1fc4e8 Compare July 17, 2019 13:15
New methods
* jerryx_set_properties: Allows multiple property registration for via a single call
* jerryx_set_property_str: Allows property registration without the need to
    create the property name JS value. The property name can be directly passed
    as a `const char*` value and must be zero terminated.
* jerryx_get_property_str: Allows getting a property value on a given object.
    The property name can be directly passed as a `const char*` value.
* jerryx_has_property_str: Allows checking if a property exists on a given object.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
Copy link
Member

@dbatyai dbatyai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai dbatyai requested a review from rerobika July 25, 2019 15:14
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rerobika rerobika merged commit c64ee88 into jerryscript-project:master Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jerry-ext Related to the jerry-ext library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants