WebInterfaceJSFunction.cpp
3.0 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
// Engine/Source/Runtime/WebBrowser/Private/WebJSFunction.cpp
#include "WebInterfaceJSFunction.h"
#include "WebInterfaceJSScripting.h"
#if WITH_CEF3
#if PLATFORM_WINDOWS
#include "Windows/WindowsHWrapper.h"
#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
FWebInterfaceJSParam::~FWebInterfaceJSParam()
{
// Since the FString, StructWrapper, TArray, and TMap members are in a union, they may or may not be valid, so we have to call the destructors manually.
switch (Tag)
{
case PTYPE_STRING:
delete StringValue;
break;
case PTYPE_STRUCT:
delete StructValue;
break;
case PTYPE_ARRAY:
delete ArrayValue;
break;
case PTYPE_MAP:
delete MapValue;
break;
default:
break;
}
}
FWebInterfaceJSParam::FWebInterfaceJSParam(const FWebInterfaceJSParam& Other)
: Tag(Other.Tag)
{
switch (Other.Tag)
{
case PTYPE_BOOL:
BoolValue = Other.BoolValue;
break;
case PTYPE_DOUBLE:
DoubleValue = Other.DoubleValue;
break;
case PTYPE_INT:
IntValue = Other.IntValue;
break;
case PTYPE_STRING:
StringValue = new FString(*Other.StringValue);
break;
case PTYPE_NULL:
break;
case PTYPE_OBJECT:
ObjectValue = Other.ObjectValue;
break;
case PTYPE_STRUCT:
StructValue = Other.StructValue->Clone();
break;
case PTYPE_ARRAY:
ArrayValue = new TArray<FWebInterfaceJSParam>(*Other.ArrayValue);
break;
case PTYPE_MAP:
MapValue = new TMap<FString, FWebInterfaceJSParam>(*Other.MapValue);
break;
}
}
FWebInterfaceJSParam::FWebInterfaceJSParam(FWebInterfaceJSParam&& Other)
: Tag(Other.Tag)
{
switch (Other.Tag)
{
case PTYPE_BOOL:
BoolValue = Other.BoolValue;
break;
case PTYPE_DOUBLE:
DoubleValue = Other.DoubleValue;
break;
case PTYPE_INT:
IntValue = Other.IntValue;
break;
case PTYPE_STRING:
StringValue = Other.StringValue;
Other.StringValue = nullptr;
break;
case PTYPE_NULL:
break;
case PTYPE_OBJECT:
ObjectValue = Other.ObjectValue;
Other.ObjectValue = nullptr;
break;
case PTYPE_STRUCT:
StructValue = Other.StructValue;
Other.StructValue = nullptr;
break;
case PTYPE_ARRAY:
ArrayValue = Other.ArrayValue;
Other.ArrayValue = nullptr;
break;
case PTYPE_MAP:
MapValue = Other.MapValue;
Other.MapValue = nullptr;
break;
}
Other.Tag = PTYPE_NULL;
}
void FWebInterfaceJSCallbackBase::Invoke(int32 ArgCount, FWebInterfaceJSParam Arguments[], bool bIsError) const
{
TSharedPtr<FWebInterfaceJSScripting> Scripting = ScriptingPtr.Pin();
if (Scripting.IsValid())
{
Scripting->InvokeJSFunction(CallbackId, ArgCount, Arguments, bIsError);
}
}