MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / V8ToCefValue

Function V8ToCefValue

IntelPresentMon/AppCef/source/util/CefValues.cpp:10–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 using namespace std::literals;
9
10 CefRefPtr<CefValue> V8ToCefValue(CefV8Value& v8)
11 {
12 auto v = CefValue::Create();
13 if (v8.IsBool())
14 {
15 v->SetBool(v8.GetBoolValue());
16 }
17 else if (v8.IsInt())
18 {
19 v->SetInt(v8.GetIntValue());
20 }
21 else if (v8.IsUInt())
22 {
23 v->SetInt(v8.GetUIntValue());
24 }
25 else if (v8.IsNull())
26 {
27 v->SetNull();
28 }
29 else if (v8.IsDouble())
30 {
31 v->SetDouble(v8.GetDoubleValue());
32 }
33 else if (v8.IsString())
34 {
35 v->SetString(v8.GetStringValue());
36 }
37 else if (v8.IsArray())
38 {
39 auto list = CefListValue::Create();
40 for (int i = 0; i < v8.GetArrayLength(); i++)
41 {
42 list->SetValue(i, V8ToCefValue(*v8.GetValue(i)));
43 }
44 v->SetList(std::move(list));
45 }
46 else if (v8.IsObject())
47 {
48 auto dict = CefDictionaryValue::Create();
49 CefDictionaryValue::KeyList keys;
50 v8.GetKeys(keys);
51 for (auto& key : keys)
52 {
53 dict->SetValue(key, V8ToCefValue(*v8.GetValue(key)));
54 }
55 v->SetDictionary(std::move(dict));
56 }
57 else
58 {
59 pmlog_warn("Unknown V8 type cannot convert");
60 }
61 return v;
62 }
63
64 CefRefPtr<CefV8Value> CefToV8Value(CefValue& cef)
65 {

Callers 1

DispatchInvocationMethod · 0.85

Calls 2

IsNullMethod · 0.80
GetKeysMethod · 0.80

Tested by

no test coverage detected