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

Alexander Vassilev avasilev at voipgate.com
Mon Feb 9 20:07:17 PST 2009


Alexander Vassilev wrote:
> 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.
>   
I'm sorry, it seems that the problem is related to some memory
corruption, and nothing to do with the api.

Cheers
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/8e783878/attachment.vcf>


More information about the webkit-dev mailing list