Adds problem with closure variables when generating JSO bridge functions

This commit is contained in:
Alexey Andreev 2014-03-22 23:25:51 +04:00
parent 6901e1282a
commit 8286ad9289

View File

@ -137,14 +137,14 @@ public class JSNativeGenerator implements Generator, Injector, DependencyPlugin
private void generateFunction(InjectorContext context) throws IOException {
SourceWriter writer = context.getWriter();
writer.append("(function()").ws().append("{").indent().softNewLine();
writer.append("return ");
writer.append("(function($instance, $property) { return function()").ws().append("{").indent().softNewLine();
writer.append("return $property.apply($instance, arguments);").softNewLine();
writer.outdent().append("};})(");
context.writeExpr(context.getArgument(0));
writer.append(", ");
context.writeExpr(context.getArgument(0));
renderProperty(context.getArgument(1), context);
writer.append(".apply(");
context.writeExpr(context.getArgument(0));
writer.append(",").ws().append("arguments);").softNewLine();
writer.outdent().append("})");
writer.append(")");
}
private void renderProperty(Expr property, InjectorContext context) throws IOException {