Instantiation a ByteString object in C++

6 views
Skip to first unread message

Stuart

unread,
Nov 16, 2010, 9:09:01 PM11/16/10
to v8cgi
Hi

Currently socket.cc uses string to pass pass received data into JS,
however I want to handle binary data and the v8::String object is not
suitable.

For example, line 413

v8::Handle<v8::Value> text = JS_STR(data, result);

What is the recommended practice for instantiating a ByteString object
in C++. I can't quite grasp the interface or whether it is possible.

Of course I could use an array of Numbers, but ByteString would be far
far superior! Is it possible?

Thanks for the great work,

Stuart.

Ondřej Žára

unread,
Nov 17, 2010, 4:35:05 AM11/17/10
to v8...@googlegroups.com
Hi Stuart,

if you check the latest SVN revision of socket.cc, you will see that
the mentioned line is still there, but obsolete (I will actually
remove it soon). I recently modified Socket::receive so it returns
either a JS string, or JS array of numbers (based on its second
argument). This approach is somewhat consistent with file reading via
File() object:

if (args.Length() > 1 && args[1]->IsTrue()) {
output = JS_CHARARRAY((char *) data, result);
} else {
output = JS_STR(data, result);
}

As for the ByteString: I plan on modifying all routines that can
handle binary data, so they use one of the CommonJS Binary proposals
(B or D). However, this is a longer-term task and I am still not sure
what version of the proposal should be used.

It would be best if you can create an issue here, formally requesting
some improvements regarding binary data handling. This will motivate
me the most to do something :)


Sincerely,
Ondrej Zara


2010/11/17 Stuart <hapal...@googlemail.com>:

> --
> You received this message because you are subscribed to the Google Groups "v8cgi" group.
> To post to this group, send email to v8...@googlegroups.com.
> To unsubscribe from this group, send email to v8cgi+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/v8cgi?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages