|
|
|
|
@ -8,18 +8,18 @@ import com.whl.quickjs.wrapper.QuickJSContext; |
|
|
|
|
|
|
|
|
|
public class JSDemo extends Spider { |
|
|
|
|
|
|
|
|
|
private QuickJSContext jsContext; |
|
|
|
|
private QuickJSContext ctx; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void init(Context context, String extend) { |
|
|
|
|
jsContext = QuickJSContext.create(); |
|
|
|
|
jsContext.evaluate("var text = 'Hello QuickJS';"); |
|
|
|
|
String text = jsContext.getGlobalObject().getString("text"); |
|
|
|
|
ctx = QuickJSContext.create(); |
|
|
|
|
ctx.evaluate("var text = 'Hello QuickJS';"); |
|
|
|
|
String text = ctx.getGlobalObject().getString("text"); |
|
|
|
|
SpiderDebug.log(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void destroy() { |
|
|
|
|
jsContext.destroy(); |
|
|
|
|
ctx.destroy(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|