In Ambly, created a new branch jsc-c-api
.
In that branch, switched everything over to use JSGlobalContextRef
, JSValueRef
, but actually commented out most of the implementation in each of the methods, except for one tiny bit in ABYServer
, where REPL-generated JavaScript is executed. I converted that over to a C-based approach:
// Evaluate the JavaScript
JSValueRef jsError = NULL;
JSStringRef javaScriptStringRef = JSStringCreateWithCFString((__bridge CFStringRef)javaScript);
JSValueRef result = JSEvaluateScript(_jsContext, javaScriptStringRef, NULL, NULL, 0, &jsError);
JSStringRelease(javaScriptStringRef);
If I "cheat" and temporarily revert back to the original implementation for [ABYContextManager setUpAmblyImportScript]
, then "basic" REPL functionality works. You can evaluate (+ 3 4)
and get back 7
.
I pushed up all of this to GitHub (without the "cheat" above), and then tried to see if things can link using this podfile:
platform :ios, '8.0'
pod 'Ambly', :git => 'https://github.com/omcljs/ambly', :branch => 'jsc-c-api', :commit => 'b25b8c8'
pod 'Ejecta', :git => 'https://github.com/swannodette/Ejecta', :branch => 'podspec', :commit => 'e8f3219b'
It does link, but produces what might be a concerning warning about ambiguity:
objc[48646]: Class JSWTFMainThreadCaller is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore and /Users/mfikes/Library/Developer/CoreSimulator/Devices/09FA3E0E-B6B4-47F8-B604-F4ED9367F8ED/data/Containers/Bundle/Application/40681C23-675A-4DA8-9770-64E5E75851EA/TestLink.app/TestLink. One of the two will be used. Which one is undefined.