We currently have static and const external onebyte strings, but these effectively leak memory (and so we can't use them extensively. This PR adds an ExternalOneByteString class which frees the underlying memory when V8 destroys the string (it's just a matter of overriding the destructor really). This allows passing latin1 rust strings created at runtime to v8 without copying (or leaking memory).
Additionally, this adds an API to get an external one byte string and call virtual methods on it.
Also fixes some issues with the existing get_external_string_resource_base function, which was using an Encoding type with incorrect enum values (which caused a segfault whenever you tried to actually read the encoding from rust).
We currently have static and const external onebyte strings, but these effectively leak memory (and so we can't use them extensively. This PR adds an
ExternalOneByteString
class which frees the underlying memory when V8 destroys the string (it's just a matter of overriding the destructor really). This allows passing latin1 rust strings created at runtime to v8 without copying (or leaking memory).Additionally, this adds an API to get an external one byte string and call virtual methods on it.
Also fixes some issues with the existing
get_external_string_resource_base
function, which was using anEncoding
type with incorrect enum values (which caused a segfault whenever you tried to actually read the encoding from rust).