Fix input string handling in v8 typemaps.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13816 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
91fc0ff205
commit
da109ee764
1 changed files with 2 additions and 3 deletions
|
|
@ -9,13 +9,12 @@ SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize,
|
||||||
if(valRef->IsString()) {
|
if(valRef->IsString()) {
|
||||||
v8::Handle<v8::String> js_str = valRef->ToString();
|
v8::Handle<v8::String> js_str = valRef->ToString();
|
||||||
|
|
||||||
size_t len = js_str->Utf8Length();
|
size_t len = js_str->Utf8Length() + 1;
|
||||||
size_t abs_len = js_str->Length();
|
|
||||||
char* cstr = new char[len];
|
char* cstr = new char[len];
|
||||||
js_str->WriteUtf8(cstr, len);
|
js_str->WriteUtf8(cstr, len);
|
||||||
|
|
||||||
if(alloc) *alloc = SWIG_NEWOBJ;
|
if(alloc) *alloc = SWIG_NEWOBJ;
|
||||||
if(psize) *psize = abs_len + 1;
|
if(psize) *psize = len;
|
||||||
if(cptr) *cptr = cstr;
|
if(cptr) *cptr = cstr;
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue