• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JSA -- now I believe this is a bug (JSA or AS)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSA -- now I believe this is a bug (JSA or AS)


  • Subject: Re: JSA -- now I believe this is a bug (JSA or AS)
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 18 Dec 2014 23:04:40 +1100

On 18 Dec 2014, at 3:58 pm, Deivy Petrescu <email@hidden> wrote:

I wrote a script library to do a bunch of computations that are not there in Smile natively.

So I had a look at _javascript_Core, and it looks like you can call it directly using ASObjC, and without WebKit. That should let you avoid using the buggy bridge business, and as a bonus, it looks like the overhead is lower -- your sample line runs 3-4 times faster.

So instead of doing this:

set k to run script "Math.tan((Math.PI)/3)" in "_javascript_"

You do this:

use framework "Foundation"
use framework "_javascript_Core"

set theContext to current application's JSContext's alloc()'s init()
set theJSValue to theContext's evaluateScript:"Math.tan((Math.PI)/3)"
set k to theJSValue's toDouble()


If you're doing a bunch of computations, you could reuse the JSContext and do the rest in a single line.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Shane Stanley <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Shane Stanley <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)

  • Prev by Date: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Next by Date: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Previous by thread: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Next by thread: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Index(es):
    • Date
    • Thread