[webkit-dev] How to set a string element in an array from C++

Alexander Vassilev avasilev at voipgate.com
Mon Feb 9 19:09:22 PST 2009


Hi all,
I am trying to add a string to a js array in C++, like this:

    n->arr->setIndex(0, jsString(globalExec, "test"));

where arr is of type JSC::JSArray*
and initialized with JSC::constructEmptyArray();

The javascript code sees the array as a sequence of characters: arr[0]
becomes 't', arr[1] becomes 'e', arr[2] becomes 's', etc.
The js code that is used to observe this is:
    alert('myobj.arr[0] = '+myobj.arr[0]);
    alert('myobj.arr[1] = '+myobj.arr[1]);
    alert('myobj.arr[2] = '+myobj.arr[2]);

How can I set arr[0] to contain the whole  string 'test' instead of
spreading this string over the array elements. I hope this is something
trivial, but I have no clue at the moment.

Regards
Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avasilev.vcf
Type: text/x-vcard
Size: 134 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090210/3ed8384c/attachment.vcf>


More information about the webkit-dev mailing list