Bug 10693 - Convert JavaScript arrays to AppleScript lists
Summary: Convert JavaScript arrays to AppleScript lists
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on: 7012
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-02 12:55 PDT by Alexey Proskuryakov
Modified: 2006-09-03 12:04 PDT (History)
0 users

See Also:


Attachments
proposed patch (12.20 KB, patch)
2006-09-02 13:11 PDT, Alexey Proskuryakov
timothy: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2006-09-02 12:55:46 PDT
Bug 7012 didn't include support for arrays, because I thought that those are too different between JS and AS. I think I've been misunderstanding it.

The attached patch doesn't map circular dependencies (falling back to toString() instead), not sure if that would be desired or not.
Comment 1 Alexey Proskuryakov 2006-09-02 13:11:37 PDT
Created attachment 10367 [details]
proposed patch
Comment 2 Timothy Hatcher 2006-09-02 23:12:47 PDT
Looking good.. one comment.

+                    unsigned numItems = array->getLength();
+                    for (unsigned i = 0; i < numItems; ++i)
+                        [aeDesc insertDescriptor:aeDescFromJSValue(exec, array->getItem(i)) atIndex:0];

Should this be atIndex:i?
Comment 3 Alexey Proskuryakov 2006-09-03 00:08:39 PDT
(In reply to comment #2)
> Should this be atIndex:i?

It could be atIndex:i+1 (AE lists are one-based), but zero also works: "Specifying an index of 0 or count + 1 causes appending to the end of the list."

BTW, on a second thought, it seems that it's impossible to create circular dependencies in AE lists anyway, as elements are stored by value, rather than by reference.
Comment 4 Timothy Hatcher 2006-09-03 11:38:30 PDT
Comment on attachment 10367 [details]
proposed patch

Great, r=me
Comment 5 Alexey Proskuryakov 2006-09-03 12:04:29 PDT
Committed revision 16200.