Objective: My goal is to implement JSLint within JavaScriptCore.
Previous Iteration
Earlier versions of JSLint featured a global function named JSLINT
, defined as follows:
var JSLINT = (function () {
...
}
Accessing and executing this function in JavaScriptCore was straightforward:
// Assuming 'ctx' is a JSGlobalContextRef
// Assuming JSEvaluateScript() has already been called
JSStringRef jsFunctionName = JSStringCreateWithUTF8CString("JSLINT");
JSValueRef jsLintFunctionValue = JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx), jsFunctionName, NULL);
JSStringRelease(jsFunctionName);
JSObjectRef jsLintFunction = JSValueToObject(ctx, jsLintFunctionValue, &exception);
Having obtained this reference, I could then utilize JSObjectCallAsFunction()
to execute the function with success.
Current Version
Presently, JSLint has transitioned to the following structure:
export default Object.freeze(function jslint(
source = "",
option_object = empty(),
global_array = []
) {
...
});
The resources for JavaScriptCore are lacking in clarity. Despite multiple attempts, I am evidently overlooking some essential aspect. How can I retrieve and run the jslint
function now?