CEFInterfaceJSStructSerializerBackend.h
2.9 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Engine/Source/Runtime/WebBrowser/Private/CEF/CEFJSStructSerializerBackend.h
#pragma once
#include "CoreMinimal.h"
#if WITH_CEF3
#include "Containers/UnrealString.h"
#include "WebInterfaceBrowserSingleton.h"
#include "UObject/UnrealType.h"
#include "IStructSerializerBackend.h"
#include "CEFInterfaceJSScripting.h"
#if PLATFORM_WINDOWS
#include "Windows/WindowsHWrapper.h"
#include "Windows/AllowWindowsPlatformTypes.h"
#endif
#pragma push_macro("OVERRIDE")
#undef OVERRIDE // cef headers provide their own OVERRIDE macro
THIRD_PARTY_INCLUDES_START
#if PLATFORM_APPLE
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#endif
#include "include/cef_values.h"
#if PLATFORM_APPLE
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#endif
THIRD_PARTY_INCLUDES_END
#pragma pop_macro("OVERRIDE")
#if PLATFORM_WINDOWS
#include "Windows/HideWindowsPlatformTypes.h"
#endif
#endif
class FCEFInterfaceJSScripting;
class IStructSerializerBackend;
struct FStructSerializerState;
class FWebJSScripting;
class UObject;
class FProperty;
class UStruct;
#if WITH_CEF3
/**
* Implements a writer for UStruct serialization using CefDictionary.
*/
class FCEFInterfaceJSStructSerializerBackend
: public IStructSerializerBackend
{
public:
/**
* Creates and initializes a new instance.
* */
FCEFInterfaceJSStructSerializerBackend(TSharedPtr<FCEFInterfaceJSScripting> InScripting)
: Scripting(InScripting), Stack(), Result()
{ }
CefRefPtr<CefDictionaryValue> GetResult()
{
return Result;
}
public:
// IStructSerializerBackend interface
virtual void BeginArray(const FStructSerializerState& State) override;
virtual void BeginStructure(const FStructSerializerState& State) override;
virtual void EndArray(const FStructSerializerState& State) override;
virtual void EndStructure(const FStructSerializerState& State) override;
virtual void WriteComment(const FString& Comment) override;
virtual void WriteProperty(const FStructSerializerState& State, int32 ArrayIndex = 0) override;
private:
struct StackItem
{
enum {STYPE_DICTIONARY, STYPE_LIST} Kind;
FString Name;
CefRefPtr<CefDictionaryValue> DictionaryValue;
CefRefPtr<CefListValue> ListValue;
StackItem(const FString& InName, CefRefPtr<CefDictionaryValue> InDictionary)
: Kind(STYPE_DICTIONARY)
, Name(InName)
, DictionaryValue(InDictionary)
, ListValue()
{}
StackItem(const FString& InName, CefRefPtr<CefListValue> InList)
: Kind(STYPE_LIST)
, Name(InName)
, DictionaryValue()
, ListValue(InList)
{}
};
TSharedPtr<FCEFInterfaceJSScripting> Scripting;
TArray<StackItem> Stack;
CefRefPtr<CefDictionaryValue> Result;
void AddNull(const FStructSerializerState& State);
void Add(const FStructSerializerState& State, bool Value);
void Add(const FStructSerializerState& State, int32 Value);
void Add(const FStructSerializerState& State, double Value);
void Add(const FStructSerializerState& State, FString Value);
void Add(const FStructSerializerState& State, UObject* Value);
};
#endif