CEFInterfaceJSStructDeserializerBackend.h
4.2 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Engine/Source/Runtime/WebBrowser/Private/CEF/CEFJSStructDeserializerBackend.h
#pragma once
#include "CoreMinimal.h"
#if WITH_CEF3
#include "WebInterfaceBrowserSingleton.h"
#include "UObject/UnrealType.h"
#include "IStructDeserializerBackend.h"
#include "CEFInterfaceJSScripting.h"
#if PLATFORM_WINDOWS
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/AllowWindowsPlatformAtomics.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/HideWindowsPlatformAtomics.h"
#include "Windows/HideWindowsPlatformTypes.h"
#endif
#endif
class FCEFInterfaceJSScripting;
class IStructDeserializerBackend;
enum class EStructDeserializerBackendTokens;
class FProperty;
class UStruct;
#if WITH_CEF3
class ICefInterfaceContainerWalker
: public TSharedFromThis<ICefInterfaceContainerWalker>
{
public:
ICefInterfaceContainerWalker(TSharedPtr<ICefInterfaceContainerWalker> InParent)
: Parent(InParent)
{}
virtual ~ICefInterfaceContainerWalker() {}
virtual TSharedPtr<ICefInterfaceContainerWalker> GetNextToken( EStructDeserializerBackendTokens& OutToken, FString& PropertyName ) = 0;
virtual bool ReadProperty(TSharedPtr<FCEFInterfaceJSScripting> Scripting, FProperty* Property, FProperty* Outer, void* Data, int32 ArrayIndex) = 0;
TSharedPtr<ICefInterfaceContainerWalker> Parent;
};
class FCefInterfaceListValueWalker
: public ICefInterfaceContainerWalker
{
public:
FCefInterfaceListValueWalker(TSharedPtr<ICefInterfaceContainerWalker> InParent, CefRefPtr<CefListValue> InList)
: ICefInterfaceContainerWalker(InParent)
, List(InList)
, Index(-2)
{}
virtual TSharedPtr<ICefInterfaceContainerWalker> GetNextToken( EStructDeserializerBackendTokens& OutToken, FString& PropertyName ) override;
virtual bool ReadProperty(TSharedPtr<FCEFInterfaceJSScripting> Scripting, FProperty* Property, FProperty* Outer, void* Data, int32 ArrayIndex ) override;
CefRefPtr<CefListValue> List;
size_t Index;
};
class FCefInterfaceDictionaryValueWalker
: public ICefInterfaceContainerWalker
{
public:
FCefInterfaceDictionaryValueWalker(TSharedPtr<ICefInterfaceContainerWalker> InParent, CefRefPtr<CefDictionaryValue> InDictionary)
: ICefInterfaceContainerWalker(InParent)
, Dictionary(InDictionary)
, Index(-2)
{
Dictionary->GetKeys(Keys);
}
virtual TSharedPtr<ICefInterfaceContainerWalker> GetNextToken( EStructDeserializerBackendTokens& OutToken, FString& PropertyName ) override;
virtual bool ReadProperty(TSharedPtr<FCEFInterfaceJSScripting> Scripting, FProperty* Property, FProperty* Outer, void* Data, int32 ArrayIndex ) override;
private:
CefRefPtr<CefDictionaryValue> Dictionary;
size_t Index;
CefDictionaryValue::KeyList Keys;
};
/**
* Implements a writer for UStruct serialization using CefDictionary.
*/
class FCEFInterfaceJSStructDeserializerBackend
: public IStructDeserializerBackend
{
public:
/**
* Creates and initializes a new instance.
*
* @param Archive The archive to deserialize from.
*/
FCEFInterfaceJSStructDeserializerBackend(TSharedPtr<FCEFInterfaceJSScripting> InScripting, CefRefPtr<CefDictionaryValue> InDictionary)
: Scripting(InScripting)
, Walker(new FCefInterfaceDictionaryValueWalker(nullptr, InDictionary))
, CurrentPropertyName()
{ }
public:
// IStructDeserializerBackend interface
virtual const FString& GetCurrentPropertyName() const override;
virtual FString GetDebugString() const override;
virtual const FString& GetLastErrorMessage() const override;
virtual bool GetNextToken( EStructDeserializerBackendTokens& OutToken ) override;
virtual bool ReadProperty( FProperty* Property, FProperty* Outer, void* Data, int32 ArrayIndex ) override;
virtual void SkipArray() override;
virtual void SkipStructure() override;
private:
TSharedPtr<FCEFInterfaceJSScripting> Scripting;
/** Holds the source CEF dictionary containing a serialized verion of the structure. */
TSharedPtr<ICefInterfaceContainerWalker> Walker;
FString CurrentPropertyName;
};
#endif