Skip to content
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

Provide a way to override interop members #758

Merged
merged 2 commits into from Jul 16, 2020
Merged

Conversation

sebastienros
Copy link
Owner

Open to discussion. It might be better to refactor the internal type and dictionary to expose them directly.

@sebastienros sebastienros requested a review from lahma July 15, 2020 22:43
@sebastienros
Copy link
Owner Author

Thiking also that an overload that return a JsValue instead of a property descriptor, or an object, might be better suited since it's called in CLR land, for CLR instances.

Jint/Engine.cs Outdated
@@ -239,6 +239,12 @@ public Engine(Action<Engine, Options> options)
ClrTypeConverter = new DefaultTypeConverter(this);
}

public void SetMemberAccessor(Type type, string name, Func<Engine, object, PropertyDescriptor> accessor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a need to change behavior runtime or would it make sense to do these via options when initializing engine?

Copy link
Collaborator

@lahma lahma left a comment

Choose a reason for hiding this comment

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

I don't know what requirements there are behind, but looks good. Just a question about whether this should be added to main engine api or via options and some sort of callback.

@lahma
Copy link
Collaborator

lahma commented Jul 16, 2020

If you look at how object wrapping is configured:

https://github.com/sebastienros/jint/blob/dev/Jint/Options.cs#L78-L87

And then used:

https://github.com/sebastienros/jint/blob/dev/Jint/Native/JsValue.cs#L349-L351

I think allowing to call such callback and if it returns non-null the result should be used instead the one created in normal logic? It would make the API similar.

@sebastienros
Copy link
Owner Author

Will try to implement a callback instead.

@sebastienros
Copy link
Owner Author

Updated

@lahma
Copy link
Collaborator

lahma commented Jul 16, 2020

Looks good!

@sebastienros sebastienros merged commit 68733e1 into dev Jul 16, 2020
@sebastienros sebastienros deleted the sebros/membersoverride branch July 16, 2020 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants