2015-06-25 16:56:38 -04:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
# include "WebBrowserPrivatePCH.h"
# include "WebJSFunction.h"
# include "WebJSScripting.h"
# if WITH_CEF3
# if PLATFORM_WINDOWS
# include "AllowWindowsPlatformTypes.h"
# endif
# pragma push_macro("OVERRIDE")
# undef OVERRIDE // cef headers provide their own OVERRIDE macro
# include "include/cef_values.h"
# pragma pop_macro("OVERRIDE")
# if PLATFORM_WINDOWS
# include "HideWindowsPlatformTypes.h"
# endif
# endif
FWebJSParam : : ~ FWebJSParam ( )
{
2015-07-28 18:59:27 -04:00
// 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.
2015-07-27 11:09:14 -04:00
switch ( Tag )
2015-06-25 16:56:38 -04:00
{
2015-07-27 11:09:14 -04:00
case PTYPE_STRING :
delete StringValue ;
break ;
2015-07-28 18:59:27 -04:00
case PTYPE_STRUCT :
delete StructValue ;
break ;
2015-07-27 11:09:14 -04:00
case PTYPE_ARRAY :
delete ArrayValue ;
break ;
2015-07-28 18:59:27 -04:00
case PTYPE_MAP :
delete MapValue ;
break ;
2015-07-27 11:09:14 -04:00
default :
break ;
2015-06-25 16:56:38 -04:00
}
}
FWebJSParam : : FWebJSParam ( const FWebJSParam & 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 :
2015-07-28 18:59:27 -04:00
StructValue = Other . StructValue - > Clone ( ) ;
2015-06-25 16:56:38 -04:00
break ;
2015-07-27 11:09:14 -04:00
case PTYPE_ARRAY :
ArrayValue = new TArray < FWebJSParam > ( * Other . ArrayValue ) ;
break ;
2015-07-28 18:59:27 -04:00
case PTYPE_MAP :
MapValue = new TMap < FString , FWebJSParam > ( * Other . MapValue ) ;
break ;
2015-06-25 16:56:38 -04:00
}
}
2015-08-05 14:14:40 -04:00
void FWebJSCallbackBase : : Invoke ( int32 ArgCount , FWebJSParam Arguments [ ] , bool bIsError ) const
2015-07-28 18:59:27 -04:00
{
# if WITH_CEF3
TSharedPtr < FWebJSScripting > Scripting = ScriptingPtr . Pin ( ) ;
if ( Scripting . IsValid ( ) )
{
Scripting - > InvokeJSFunction ( CallbackId , ArgCount , Arguments , bIsError ) ;
}
# endif
2015-06-25 16:56:38 -04:00
}