parent
3b183854ff
commit
2d3c65beca
31 changed files with 200 additions and 152 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "base/files/file_path.h"
|
||||
#include "gin/converter.h"
|
||||
#include "shell/common/gin_converters/std_converter.h"
|
||||
|
||||
namespace gin {
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
#include "gin/converter.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/strings/string_util_win.h"
|
||||
#endif
|
||||
|
||||
namespace gin {
|
||||
|
||||
// Make it possible to convert move-only types.
|
||||
|
@ -182,6 +186,30 @@ struct Converter<std::map<K, V>> {
|
|||
}
|
||||
};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template <>
|
||||
struct Converter<std::wstring> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const std::wstring& val) {
|
||||
return Converter<std::u16string>::ToV8(isolate, base::AsString16(val));
|
||||
}
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
std::wstring* out) {
|
||||
if (!val->IsString())
|
||||
return false;
|
||||
|
||||
std::u16string str;
|
||||
if (Converter<std::u16string>::FromV8(isolate, val, &str)) {
|
||||
*out = base::AsWString(str);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace gin
|
||||
|
||||
#endif // SHELL_COMMON_GIN_CONVERTERS_STD_CONVERTER_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue