Add ability to read data from V8 JS object
Closed this issue · 6 comments
Right now when class is "injected" to V8, it's methods could have arguments as
- primitives & String
- or another Java class, which was injected from Java to V8 previously.
For example, there is no way to read data from JS object {y: 'done'}
when it passed to java method - following exception is thrown:
IllegalArgumentException: No signature exists for readJsObjectAsJavaObjectAndTryGetY with parameters [[object Object], ].
Instead, when there is call similar to x.readJsObjectAsMapAndGetY({y: 'done'})
, it should try to "translate" the content of the JS object to Java object, e.g. Map.
Here x is our Java class.
Awesome, will review your PR and leave any comments on this feature there. Please do look into arrays; I remember them being a complicated problem that I couldn't justify work for at the time...would be interested to see what you find.
I've responded to #5 just now; it looks like it can be solved using our dynamic interface generation feature, so I am going to close it for now.
@crahda thanks for taking care of this pull request for fast.
For the array
I have only added possibility to be read as list (and V8Array just in case). I will look once again on all the array's code later.
Concerning #5 - I don't see how we can call v8 function with native JS code from Java now without using V8Function
(having only Functional interface). But I will try to add unit test and check if it's actually working.
Btw, all the changes in the pull request - #9
Excellent! I will review #9 ; there's a lot of code there.
Refer to this test:
For an example of dynamic function injection.
@crahda I have checked this Junit test and related functionality and it's great.
(Looks like since I have not used yet this JS call-backs - I have missed it.)
Awesome, glad to hear it!