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

Feature/2.0.0 object interface need to release unused #70

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public void testNullExceptionWithEval() {
@Test
public void testNullExceptionWithCompile() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Source code cannot be null");
thrown.expectMessage("Script cannot be null with unknown.js");

QuickJSContext context = createContext();
context.compile(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ public Object evaluate(String script) {
}

public Object evaluate(String script, String fileName) {
if (script == null) {
throw new NullPointerException("Script cannot be null with " + fileName);
}

checkSameThread();
checkDestroyed();
return evaluate(context, script, fileName);
Expand Down Expand Up @@ -498,39 +502,54 @@ public Object parse(String json) {
return parseJSON(context, json);
}

public byte[] compile(String source) {
return compile(source, UNKNOWN_FILE);
public byte[] compile(String script) {
return compile(script, UNKNOWN_FILE);
}

public byte[] compile(String source, String fileName) {
public byte[] compile(String script, String fileName) {
if (script == null) {
throw new NullPointerException("Script cannot be null with " + fileName);
}

checkSameThread();
checkDestroyed();

return compile(context, source, fileName, false);
return compile(context, script, fileName, false);
}

public byte[] compileModule(String source) {
return compileModule(source, UNKNOWN_FILE);
public byte[] compileModule(String script) {
return compileModule(script, UNKNOWN_FILE);
}

public byte[] compileModule(String source, String fileName) {
public byte[] compileModule(String script, String fileName) {
if (script == null) {
throw new NullPointerException("Script cannot be null with " + fileName);
}

checkSameThread();
checkDestroyed();

return compile(context, source, fileName, true);
return compile(context, script, fileName, true);
}

public Object execute(byte[] code) {
if (code == null) {
throw new NullPointerException("Bytecode cannot be null");
}

checkSameThread();
checkDestroyed();

return execute(context, code);
}

public Object evaluateModule(String script, String moduleName) {
if (script == null) {
throw new NullPointerException("Script cannot be null with " + moduleName);
}

checkSameThread();
checkDestroyed();

return evaluateModule(context, script, moduleName);
}

Expand Down