forked from tjanczuk/edge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
49 lines (43 loc) · 1.27 KB
/
Copy pathutils.cpp
File metadata and controls
49 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "edge.h"
Handle<v8::String> stringCLR2V8(System::String^ text)
{
HandleScope scope;
pin_ptr<const wchar_t> message = PtrToStringChars(text);
return scope.Close(v8::String::New((uint16_t*)message));
}
System::String^ stringV82CLR(Handle<v8::String> text)
{
HandleScope scope;
String::Utf8Value utf8text(text);
return gcnew System::String(*utf8text);
}
System::String^ exceptionV82stringCLR(Handle<v8::Value> exception)
{
HandleScope scope;
if (exception->IsObject())
{
Handle<Value> stack = exception->ToObject()->Get(v8::String::NewSymbol("stack"));
if (stack->IsString())
{
return gcnew System::String(stringV82CLR(stack->ToString()));
}
}
return gcnew System::String(stringV82CLR(Handle<v8::String>::Cast(exception)));
}
Handle<String> exceptionCLR2stringV8(System::Exception^ exception)
{
HandleScope scope;
if (exception == nullptr)
{
return scope.Close(v8::String::New("Unrecognized exception thrown by CLR."));
}
else
{
return scope.Close(stringCLR2V8(exception->ToString()));
}
}
Handle<Value> throwV8Exception(System::Exception^ exception)
{
HandleScope scope;
return scope.Close(ThrowException(exceptionCLR2stringV8(exception)));
}