Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (27 sloc) 0.867 kB
#include "stdafx.h"
#include "JSValue.h"
#include "JSObject.h"
#include "JSCoreMarshal.h"
JSStringRef JSCoreMarshal::StringToJSString(String ^ value)
{
if (value != nullptr)
{
JSChar * chars = (JSChar *) Marshal::StringToBSTR(value).ToPointer();
JSStringRef str = JSStringCreateWithCharacters(chars, wcslen(chars));
Marshal::FreeBSTR(IntPtr(chars));
// TODO: find out if we should return JSStringRetain(str) instead
return str;
}
else
{
return NULL;
}
}
String ^ JSCoreMarshal::JSStringToString(JSStringRef string)
{
size_t len = JSStringGetLength(string);
JSChar * cStr = (JSChar *) JSStringGetCharactersPtr(string);
// TODO: does this copy the string, or point to it?
// Do we need to clean up afterwards?
return Marshal::PtrToStringAuto(IntPtr((void *)cStr), len);
}
Jump to Line
Something went wrong with that request. Please try again.