Add fix for dependency issue when invoking callback from native JS

This commit is contained in:
konsoletyper 2014-09-30 18:13:45 +04:00
parent c0dc8f25d3
commit 50686c882d
2 changed files with 14 additions and 5 deletions

View File

@ -117,6 +117,7 @@ public final class JS {
public static native double unwrapDouble(JSObject obj);
@GeneratedBy(JSNativeGenerator.class)
@PluggableDependency(JSNativeGenerator.class)
public static native String unwrapString(JSObject obj);
@InjectedBy(JSNativeGenerator.class)

View File

@ -116,12 +116,20 @@ public class JSNativeGenerator implements Generator, Injector, DependencyPlugin
@Override
public void methodAchieved(final DependencyAgent agent, final MethodDependency method) {
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
method.getVariable(i).addConsumer(new DependencyConsumer() {
@Override public void consume(DependencyAgentType type) {
achieveFunctorMethods(agent, type.getName(), method);
switch (method.getReference().getName()) {
case "invoke":
case "instantiate":
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
method.getVariable(i).addConsumer(new DependencyConsumer() {
@Override public void consume(DependencyAgentType type) {
achieveFunctorMethods(agent, type.getName(), method);
}
});
}
});
break;
case "unwrapString":
method.getResult().propagate(agent.getType("java.lang.String"));
break;
}
}