Files
UnrealEngineUWP/Engine/Source/Runtime/WebBrowser/Public/WebJSFunction.h

231 lines
6.5 KiB
C
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Misc/Guid.h"
#include "UObject/Class.h"
#include "WebJSFunction.generated.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
class FWebJSScripting;
struct WEBBROWSER_API FWebJSParam
{
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
struct IStructWrapper
{
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
virtual ~IStructWrapper() {};
virtual UStruct* GetTypeInfo() = 0;
virtual const void* GetData() = 0;
virtual IStructWrapper* Clone() = 0;
};
template <typename T> struct FStructWrapper
: public IStructWrapper
{
T StructValue;
FStructWrapper(const T& InValue)
: StructValue(InValue)
{}
virtual ~FStructWrapper()
{}
virtual UStruct* GetTypeInfo() override
{
return T::StaticStruct();
}
virtual const void* GetData() override
{
return &StructValue;
}
virtual IStructWrapper* Clone() override
{
return new FStructWrapper<T>(StructValue);
}
};
FWebJSParam() : Tag(PTYPE_NULL) {}
FWebJSParam(bool Value) : Tag(PTYPE_BOOL), BoolValue(Value) {}
FWebJSParam(int8 Value) : Tag(PTYPE_INT), IntValue(Value) {}
FWebJSParam(int16 Value) : Tag(PTYPE_INT), IntValue(Value) {}
FWebJSParam(int32 Value) : Tag(PTYPE_INT), IntValue(Value) {}
FWebJSParam(uint8 Value) : Tag(PTYPE_INT), IntValue(Value) {}
FWebJSParam(uint16 Value) : Tag(PTYPE_INT), IntValue(Value) {}
FWebJSParam(uint32 Value) : Tag(PTYPE_DOUBLE), DoubleValue(Value) {}
FWebJSParam(int64 Value) : Tag(PTYPE_DOUBLE), DoubleValue(Value) {}
FWebJSParam(uint64 Value) : Tag(PTYPE_DOUBLE), DoubleValue(Value) {}
FWebJSParam(double Value) : Tag(PTYPE_DOUBLE), DoubleValue(Value) {}
FWebJSParam(float Value) : Tag(PTYPE_DOUBLE), DoubleValue(Value) {}
FWebJSParam(const FString& Value) : Tag(PTYPE_STRING), StringValue(new FString(Value)) {}
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
FWebJSParam(const FText& Value) : Tag(PTYPE_STRING), StringValue(new FString(Value.ToString())) {}
FWebJSParam(const FName& Value) : Tag(PTYPE_STRING), StringValue(new FString(Value.ToString())) {}
FWebJSParam(const TCHAR* Value) : Tag(PTYPE_STRING), StringValue(new FString(Value)) {}
FWebJSParam(UObject* Value) : Tag(PTYPE_OBJECT), ObjectValue(Value) {}
template <typename T> FWebJSParam(const T& Value,
Copying //UE4/Dev-Core to //UE4/Dev-Main (Source: //UE4/Dev-Core @ 3012371) ========================== MAJOR FEATURES + CHANGES ========================== Change 2970419 on 2016/05/09 by Steve.Robb Static analysis fixes: warning C6326: Potential comparison of a constant with another constant. warning C6011: Dereferencing NULL pointer '...'. warning C6385: Reading invalid data from '...': the readable size is '...' bytes, but '...' bytes may be read. warning C6386: Buffer overrun while writing to '...': the writable size is '...' bytes, but '...' bytes might be written. Change 2997665 on 2016/06/02 by Graeme.Thornton Fix parameter parsing bug in corrupt tool Change 2997947 on 2016/06/02 by Steve.Robb Fix for return value from FOnlineSessionMcp::UpdateSession. Change 3000182 on 2016/06/03 by John.Mahoney PR #2234: Fix NullReferenceException to connect to coordinator (Contributed by projectgheist) #jira UE-29063 Change 3000355 on 2016/06/03 by John.Mahoney Fix for crash caused by trying to serialize a package larger than 2 GB to memory while cooking, usually due to unusually large light maps. Replaced the TArray-based memory archives used in UPackage::SavePackage with a new FLargeMemoryWriter/Reader that uses a raw memory buffer internally. #jira UE-22912 Change 3001673 on 2016/06/06 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'KeyState' Change 3001963 on 2016/06/06 by John.Mahoney Fix for AutomationTool crash when deploying to default PS4 devkit. When a DeviceName is not specified on the command line, the PS4DevKitUtil.exe Detail command will return the details of the default connected device. If the device's filesystem is mapped by name instead of IP, the name should be parsed from the result and used to build the BaseTargetPath. Change 3001974 on 2016/06/06 by Steve.Robb Static analysis fixes: warning C6326: Potential comparison of a constant with another constant. Change 3003781 on 2016/06/07 by Steve.Robb New TWeakObjectPtrMapKeyFuncs to be used for maps containing TWeakObjectPtr keys, without invalidating the map when the pointer becomes stale. Fix for UNetConnection::ActorChannels which suffered from this problem. Change 3003855 on 2016/06/07 by Steve.Robb VS debugger visualization of TTuples up to 6 elements. Change 3003864 on 2016/06/07 by Steve.Robb Reapply optimizations to FString::MatchesWildcard reverted in CL# 2992738. Change 3003944 on 2016/06/07 by Steve.Robb Back out changelist 3003864 Change 3004198 on 2016/06/07 by Steve.Robb TIsTriviallyDestructible added, needed to move away from amalgamated type traits, which can cause spurious compile errors. DestructItem added. Change 3005586 on 2016/06/08 by Steve.Robb jpeg_decoder::stop_decoding made ((no_return)) again, but with an exit() call to ensure that it doesn't cause compile errors in Android builds. Change 3005633 on 2016/06/08 by Steve.Robb Static analysis fixes: warning C28216: The checkReturn annotation only applies to postconditions for function 'Func' _Param_(N) Change 3005839 on 2016/06/08 by Steve.Robb Fix for warning C6011: Dereferencing NULL pointer 'RepState'. Change 3005857 on 2016/06/08 by Steve.Robb Fix for warning C28182: Dereferencing NULL pointer. 'CinematicShotSection' contains the same NULL value as 'ShotSection' did. Change 3005860 on 2016/06/08 by Steve.Robb Fix for warning C6011: Dereferencing NULL pointer 'this->Keys[Index]'. Change 3006175 on 2016/06/08 by Steve.Robb Additional information about the class which is failing to reload. #jira UE-28599 Change 3006524 on 2016/06/08 by Ben.Marsh Fix compile error introduced in CL 3006175 Change 3006815 on 2016/06/08 by Ben.Marsh Enable static analysis as part of build process for dev branches. Change 3007606 on 2016/06/09 by Steve.Robb Fixes for 'inconsistent annotation warnings' in SDK code. Change 3007679 on 2016/06/09 by Steve.Robb Fixes for 'inconsistent annotation warnings' in SDK code. Change 3008125 on 2016/06/09 by John.Mahoney Fix for DLC paks mapping file paths relative to the GameDir instead of the RootDir. #jira UE-31250 Change 3008763 on 2016/06/10 by Steve.Robb New TArray::EmplaceAt function. Change 3008780 on 2016/06/10 by Steve.Robb Non-variadic delegate implementation deleted. Change 3008820 on 2016/06/10 by Robert.Manuszewski Merging UnrealHeaderTool optimizations from a partners branch. Change 3008850 on 2016/06/10 by Steve.Robb Removal of PLATFORM_COMPILER_HAS_VARIADIC_TEMPLATES. Change 3008905 on 2016/06/10 by Graeme.Thornton MemoryProfiler2 - Deselect current bar when clicking off the histogram. Allows user to see the top level group data again Change 3008933 on 2016/06/10 by Steve.Robb Removal of PLATFORM_COMPILER_HAS_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS. Change 3009130 on 2016/06/10 by John.Mahoney Fix for crash when pasting T3D data from the clipboard into the content browser. Since the content browser is only expecting a list of object paths, it should avoid trying to process pasted T3D altogether. #jira UE-31459 Change 3010712 on 2016/06/13 by Steve.Robb Splitting up of TTypeTraits into individual traits to avoid erroneous VC compilation errors. Use of TAnd/TOr to short-circuit many compile-time traits checks. Renaming of traits classes (except TIsPODType) to closer match the standard. Change 3010714 on 2016/06/13 by Steve.Robb *_Variadics.h delegate headers renamed to just *.h. Change 3010719 on 2016/06/13 by Steve.Robb Redundant suffixes removed from delegate macros. Change 3010720 on 2016/06/13 by Steve.Robb Fix for defaulted functions and other compiler settings. Workaround for spurious compiler errors in generated functions which ultimately reference other deleted functions. See: https://connect.microsoft.com/VisualStudio/feedback/details/2612308 Change 3010721 on 2016/06/13 by Steve.Robb Removal of TTuple::ApplyAfter_ExplicitReturnType in preparation of making TTuple a first class citizen of UE4. New MakeTuple and TransformTuple generator functions. New Lexicographical::ToString overloads for const CharType* and bool. Change 3010783 on 2016/06/13 by Steve.Robb Fix for TTransformTuple_Impl::Do return type. Fix for Clang error. Change 3010995 on 2016/06/13 by Robert.Manuszewski Fixing compile errors when leak detection and verify mallocs are enabled due to changes in their base class. Change 3012221 on 2016/06/14 by Graeme.Thornton Fixes for MemoryAnalyser2 solution - Upgraded to VS 2015 - Clean up solution configurations. Only leave "Any CPU" - Switch project to build with "Any CPU" rather than "x64". Change 3012328 on 2016/06/14 by Steve.Robb Make checks assume even in !DO_CHECK builds. This fixes some SA warnings as well as possibly making those builds more optimal. Change 3012363 on 2016/06/14 by Steve.Robb Static analysis fixes: warning C28251: Inconsistent annotation for 'Func' Change 3012371 on 2016/06/14 by Steve.Robb Static analysis fixes: warning C28251: Inconsistent annotation for 'Type' #lockdown Nick.Penwarden #rb none [CL 3012829 by Robert Manuszewski in Main branch]
2016-06-14 12:28:12 -04:00
typename TEnableIf<!TIsPointer<T>::Value, UStruct>::Type* InTypeInfo=T::StaticStruct())
: Tag(PTYPE_STRUCT)
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
, StructValue(new FStructWrapper<T>(Value))
{}
template <typename T> FWebJSParam(const TArray<T>& Value)
: Tag(PTYPE_ARRAY)
{
ArrayValue = new TArray<FWebJSParam>();
ArrayValue->Reserve(Value.Num());
for(T Item : Value)
{
ArrayValue->Add(FWebJSParam(Item));
}
}
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
template <typename T> FWebJSParam(const TMap<FString, T>& Value)
: Tag(PTYPE_MAP)
{
MapValue = new TMap<FString, FWebJSParam>();
MapValue->Reserve(Value.Num());
for(const auto& Pair : Value)
{
MapValue->Add(Pair.Key, FWebJSParam(Pair.Value));
}
}
template <typename K, typename T> FWebJSParam(const TMap<K, T>& Value)
: Tag(PTYPE_MAP)
{
MapValue = new TMap<FString, FWebJSParam>();
MapValue->Reserve(Value.Num());
for(const auto& Pair : Value)
{
MapValue->Add(Pair.Key.ToString(), FWebJSParam(Pair.Value));
}
}
FWebJSParam(const FWebJSParam& Other);
FWebJSParam(FWebJSParam&& Other);
~FWebJSParam();
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
enum { PTYPE_NULL, PTYPE_BOOL, PTYPE_INT, PTYPE_DOUBLE, PTYPE_STRING, PTYPE_OBJECT, PTYPE_STRUCT, PTYPE_ARRAY, PTYPE_MAP } Tag;
union
{
bool BoolValue;
double DoubleValue;
int32 IntValue;
UObject* ObjectValue;
const FString* StringValue;
IStructWrapper* StructValue;
TArray<FWebJSParam>* ArrayValue;
TMap<FString, FWebJSParam>* MapValue;
};
};
class FWebJSScripting;
/** Base class for JS callback objects. */
USTRUCT()
struct WEBBROWSER_API FWebJSCallbackBase
{
GENERATED_USTRUCT_BODY()
FWebJSCallbackBase()
{}
bool IsValid() const
{
return ScriptingPtr.IsValid();
}
protected:
FWebJSCallbackBase(TSharedPtr<FWebJSScripting> InScripting, const FGuid& InCallbackId)
: ScriptingPtr(InScripting)
, CallbackId(InCallbackId)
{}
void Invoke(int32 ArgCount, FWebJSParam Arguments[], bool bIsError = false) const;
private:
TWeakPtr<FWebJSScripting> ScriptingPtr;
FGuid CallbackId;
};
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
/**
* Representation of a remote JS function.
* FWebJSFunction objects represent a JS function and allow calling them from native code.
* FWebJSFunction objects can also be added to delegates and events using the Bind/AddLambda method.
*/
USTRUCT()
struct WEBBROWSER_API FWebJSFunction
: public FWebJSCallbackBase
{
GENERATED_USTRUCT_BODY()
FWebJSFunction()
: FWebJSCallbackBase()
{}
FWebJSFunction(TSharedPtr<FWebJSScripting> InScripting, const FGuid& InFunctionId)
: FWebJSCallbackBase(InScripting, InFunctionId)
{}
template<typename ...ArgTypes> void operator()(ArgTypes... Args) const
{
FWebJSParam ArgArray[sizeof...(Args)] = {FWebJSParam(Args)...};
Invoke(sizeof...(Args), ArgArray);
}
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
};
/**
* Representation of a remote JS async response object.
* UFUNCTIONs taking a FWebJSResponse will get it passed in automatically when called from a web browser.
* Pass a result or error back by invoking Success or Failure on the object.
* UFunctions accepting a FWebJSResponse should have a void return type, as any value returned from the function will be ignored.
* Calling the response methods does not have to happen before returning from the function, which means you can use this to implement asynchronous functionality.
*
* Note that the remote object will become invalid as soon as a result has been delivered, so you can only call either Success or Failure once.
*/
USTRUCT()
struct WEBBROWSER_API FWebJSResponse
: public FWebJSCallbackBase
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
{
GENERATED_USTRUCT_BODY()
FWebJSResponse()
: FWebJSCallbackBase()
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
{}
FWebJSResponse(TSharedPtr<FWebJSScripting> InScripting, const FGuid& InCallbackId)
: FWebJSCallbackBase(InScripting, InCallbackId)
[INTEGRATE] SWebBrowser refactor and cleanups: * Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
2015-07-28 18:59:27 -04:00
{}
/**
* Indicate successful completion without a return value.
* The remote Promise's then() handler will be executed without arguments.
*/
void Success() const
{
Invoke(0, nullptr, false);
}
/**
* Indicate successful completion passing a return value back.
* The remote Promise's then() handler will be executed with the value passed as its single argument.
*/
template<typename T>
void Success(T Arg) const
{
FWebJSParam ArgArray[1] = {FWebJSParam(Arg)};
Invoke(1, ArgArray, false);
}
/**
* Indicate failed completion, passing an error message back to JS.
* The remote Promise's catch() handler will be executed with the value passed as the error reason.
*/
template<typename T>
void Failure(T Arg) const
{
FWebJSParam ArgArray[1] = {FWebJSParam(Arg)};
Invoke(1, ArgArray, true);
}
};