On Sep 20, 4:45 pm, avasilev <
alxvasi...@gmail.com> wrote:
> 'std::string&()'
> I get an error from the compiler. When I try to bind a method that
> returns just a std::string the code compiles. Is it possibleto bind a
> method that returns a reference?
Yes and no. Yes, it can be done for most bound client types, but
std::string is a special case. It is very rare to pass a std::string
by pointer, so std::string is treated like a POD data type for
purposes of the bindings. Because of that, binding by reference won't
work in this particular case. Client-specified types are always passed
around by pointer, but std::string is simply treated as a "temporary"
v8::String proxy. In order to be able to pass it around by reference/
pointer, we would need somewhere to actually store the native string
object, which means we would have to dynamically allocate it and store
it somewhere in a v8::External.
JS won't allow us to change string data - we have to create a new
string - so a function returning a (string &) is not semantically
legal vis-a-vis JS.