Skip to content

Commit

Permalink
Merge pull request #49 from ncsoft/4.23
Browse files Browse the repository at this point in the history
4.23
  • Loading branch information
crocuis authored Sep 7, 2019
2 parents b66d81c + c0064d5 commit beea905
Show file tree
Hide file tree
Showing 31 changed files with 4,736 additions and 649 deletions.
11 changes: 6 additions & 5 deletions Source/JavascriptEditor/JavascriptEditorViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class FJavascriptPreviewScene : public FAdvancedPreviewScene
{
return SkyComponent;
}

#if ENGINE_MINOR_VERSION < 23
class USphereReflectionCaptureComponent* GetDefaultSphereReflectionComponent()
{
return SphereReflectionComponent;
}

#endif
class UMaterialInstanceConstant* GetDefaultInstancedSkyMaterial()
{
return InstancedSkyMaterial;
Expand Down Expand Up @@ -495,12 +495,12 @@ class SAutoRefreshEditorViewport : public SEditorViewport
{
return PreviewScene.GetDefaultSkySphereComponent();
}

#if ENGINE_MINOR_VERSION < 23
class USphereReflectionCaptureComponent* GetDefaultSphereReflectionComponent()
{
return PreviewScene.GetDefaultSphereReflectionComponent();
}

#endif
class UMaterialInstanceConstant* GetDefaultInstancedSkyMaterial()
{
return PreviewScene.GetDefaultInstancedSkyMaterial();
Expand Down Expand Up @@ -949,11 +949,12 @@ class UStaticMeshComponent* UJavascriptEditorViewport::GetDefaultSkySphereCompon

class USphereReflectionCaptureComponent* UJavascriptEditorViewport::GetDefaultSphereReflectionComponent()
{
#if ENGINE_MINOR_VERSION < 23
if (ViewportWidget.IsValid())
{
return ViewportWidget->GetDefaultSphereReflectionComponent();
}

#endif
return nullptr;
}

Expand Down
12 changes: 10 additions & 2 deletions Source/JavascriptGraphEditor/JavascriptGraphEditorLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,21 @@ FJavascriptArrangedWidget UJavascriptGraphEditorLibrary::FindPinGeometries(FJava
FJavascriptPinWidget UJavascriptGraphEditorLibrary::FindPinToPinWidgetMap(FJavascriptDetermineLinkGeometryContainer Container, FJavascriptEdGraphPin Pin)
{
FJavascriptPinWidget Widget = FJavascriptPinWidget();

#if ENGINE_MINOR_VERSION > 22
TSharedPtr<SGraphPin>* SGraphPinHandle = Container.PinToPinWidgetMap->Find(Pin);
if (SGraphPinHandle)
{
TSharedRef<SWidget> SWidgetHandle = static_cast<SWidget&>(*SGraphPinHandle->Get()).AsShared();
Widget.Handle = &SWidgetHandle;
}
#else
TSharedRef<SGraphPin>* SGraphPinHandle = Container.PinToPinWidgetMap->Find(Pin);
if (SGraphPinHandle)
{
TSharedRef<SWidget> SWidgetHandle = static_cast<SWidget&>(SGraphPinHandle->Get()).AsShared();
TSharedRef<SWidget> SWidgetHandle = static_cast<SWidget&>(SGraphPinHandle->Get()).AsShared();
Widget.Handle = &SWidgetHandle;
}
#endif

return Widget;
}
Expand Down
17 changes: 16 additions & 1 deletion Source/JavascriptGraphEditor/JavascriptGraphEditorLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "SJavascriptGraphEdNode.h"
#include "ConnectionDrawingPolicy.h"
#include "EdGraph/EdGraph.h"
#include "../../Launch/Resources/Version.h"
#include "JavascriptGraphEditorLibrary.generated.h"

class UEdGraph;
Expand Down Expand Up @@ -99,7 +100,17 @@ struct FJavascriptDetermineLinkGeometryContainer
GENERATED_BODY()

FJavascriptDetermineLinkGeometryContainer() {}
FJavascriptDetermineLinkGeometryContainer(FArrangedChildren* InArrangedNodes, TSharedRef<SWidget>* InOutputPinWidget, TMap<UEdGraphNode*, int32>* InNodeWidgetMap, TMap<TSharedRef<SWidget>, FArrangedWidget>* InPinGeometries, TMap< UEdGraphPin*, TSharedRef<SGraphPin> >* InPinToPinWidgetMap)
FJavascriptDetermineLinkGeometryContainer(
FArrangedChildren* InArrangedNodes,
TSharedRef<SWidget>* InOutputPinWidget,
TMap<UEdGraphNode*, int32>* InNodeWidgetMap,
TMap<TSharedRef<SWidget>, FArrangedWidget>* InPinGeometries,
#if ENGINE_MINOR_VERSION > 22
TMap< UEdGraphPin*, TSharedPtr<SGraphPin> >* InPinToPinWidgetMap
#else
TMap< UEdGraphPin*, TSharedRef<SGraphPin> >* InPinToPinWidgetMap
#endif
)
: ArrangedNodes(InArrangedNodes)
, OutputPinWidget(InOutputPinWidget)
, NodeWidgetMap(InNodeWidgetMap)
Expand All @@ -113,7 +124,11 @@ struct FJavascriptDetermineLinkGeometryContainer
TMap<UEdGraphNode*, int32>* NodeWidgetMap;

TMap<TSharedRef<SWidget>, FArrangedWidget>* PinGeometries;
#if ENGINE_MINOR_VERSION > 22
TMap< UEdGraphPin*, TSharedPtr<SGraphPin> >* PinToPinWidgetMap;
#else
TMap< UEdGraphPin*, TSharedRef<SGraphPin> >* PinToPinWidgetMap;
#endif
};

USTRUCT(BlueprintType)
Expand Down
12 changes: 12 additions & 0 deletions Source/JavascriptGraphEditor/SJavascriptGraphEdNodePin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ void SJavascriptGraphPin::Construct(const FArguments& InArgs, UEdGraphPin* InPin
}
}
// Create the widget used for the pin body (status indicator, label, and value)
#if ENGINE_MINOR_VERSION > 22
LabelAndValue =
#else
TSharedRef<SWrapBox> LabelAndValue =
#endif
SNew(SWrapBox)
.PreferredWidth(150.f);

Expand Down Expand Up @@ -168,7 +172,11 @@ void SJavascriptGraphPin::Construct(const FArguments& InArgs, UEdGraphPin* InPin
.AutoWidth()
.VAlign(VAlign_Center)
[
#if ENGINE_MINOR_VERSION > 22
LabelAndValue.ToSharedRef()
#else
LabelAndValue
#endif
];
}
else
Expand All @@ -179,7 +187,11 @@ void SJavascriptGraphPin::Construct(const FArguments& InArgs, UEdGraphPin* InPin
.AutoWidth()
.VAlign(VAlign_Center)
[
#if ENGINE_MINOR_VERSION > 22
LabelAndValue.ToSharedRef()
#else
LabelAndValue
#endif
]
+ SHorizontalBox::Slot()
.AutoWidth()
Expand Down
5 changes: 5 additions & 0 deletions Source/JavascriptUMG/JavascriptMenuLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Components/Widget.h"
#include "Framework/Commands/GenericCommands.h"
#include "JavascriptUICommands.h"
#include "../../Launch/Resources/Version.h"

FJavascriptUICommandList UJavascriptMenuLibrary::CreateUICommandList()
{
Expand Down Expand Up @@ -242,7 +243,11 @@ FJavascriptUICommandInfo UJavascriptMenuLibrary::UI_COMMAND_Function(FJavascript
const FString DotOutCommandName = FString::Printf(TEXT(".%s"), *info.Id);
const TCHAR* FriendlyName = *info.FriendlyName;
const TCHAR* InDescription = *info.Description;
#if ENGINE_MINOR_VERSION > 22
const EUserInterfaceActionType CommandType = EUserInterfaceActionType(info.ActionType.GetValue());
#else
const EUserInterfaceActionType::Type CommandType = EUserInterfaceActionType::Type(info.ActionType.GetValue());
#endif
const FInputChord& InDefaultChord = info.DefaultChord;
const FInputChord& InAlternateDefaultChord = FInputChord();
const FString IconStyleName = *info.IconStyleName;
Expand Down
32 changes: 22 additions & 10 deletions Source/V8/Private/Delegates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "Translator.h"
#include "JavascriptStats.h"
#include "UObject/GCObject.h"
#include "../../Launch/Resources/Version.h"
#include "v8-version.h"

PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS

Expand Down Expand Up @@ -106,29 +108,31 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
auto toJSON = [](const FunctionCallbackInfo<Value>& info) {
auto payload = reinterpret_cast<FJavascriptDelegate*>(Local<External>::Cast(info.Data())->Value());

uint32_t Index = 0;
auto arr = Array::New(info.GetIsolate(), payload->DelegateObjects.Num());
uint32_t Index = 0;
auto isolate_ = info.GetIsolate();
auto context_ = isolate_->GetCurrentContext();
auto arr = Array::New(isolate_, payload->DelegateObjects.Num());
const bool bIsMulticastDelegate = payload->Property->IsA(UMulticastDelegateProperty::StaticClass());

for (auto DelegateObject : payload->DelegateObjects)
{
auto JavascriptFunction = payload->functions.Find(DelegateObject->UniqueId);
if (JavascriptFunction)
{
auto function = Local<Function>::New(info.GetIsolate(), *JavascriptFunction);
auto function = Local<Function>::New(isolate_, *JavascriptFunction);
if (!bIsMulticastDelegate)
{
info.GetReturnValue().Set(function);
return;
}

arr->Set(Index++, function);
arr->Set(context_, Index++, function);
}
}

if (!bIsMulticastDelegate)
{
info.GetReturnValue().Set(Null(info.GetIsolate()));
info.GetReturnValue().Set(Null(isolate_));
}
else
{
Expand Down Expand Up @@ -224,8 +228,12 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
FScriptDelegate Delegate;
Delegate.BindUFunction(DelegateObject, NAME_Fire);

#if ENGINE_MINOR_VERSION > 22
p->AddDelegate(Delegate, WeakObject.Get());
#else
auto Target = p->GetPropertyValuePtr_InContainer(WeakObject.Get());
Target->Add(Delegate);
#endif
}
else if (auto p = Cast<UDelegateProperty>(Property))
{
Expand All @@ -250,9 +258,12 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
{
FScriptDelegate Delegate;
Delegate.BindUFunction(DelegateObject, NAME_Fire);

#if ENGINE_MINOR_VERSION > 22
p->RemoveDelegate(Delegate, WeakObject.Get());
#else
auto Target = p->GetPropertyValuePtr_InContainer(WeakObject.Get());
Target->Remove(Delegate);
#endif
}
else if (auto p = Cast<UDelegateProperty>(Property))
{
Expand Down Expand Up @@ -374,17 +385,18 @@ struct FDelegateManager : IDelegateManager
virtual Local<Value> GetProxy(Local<Object> This, UObject* Object, UProperty* Property) override
{
auto cache_id = V8_KeywordString(isolate_, FString::Printf(TEXT("$internal_%s"), *(Property->GetName())));
auto cached = This->Get(cache_id);
if (cached.IsEmpty() || cached->IsUndefined())
auto context_ = isolate_->GetCurrentContext();
auto maybe_cached = This->Get(context_, cache_id);
if (maybe_cached.IsEmpty() || maybe_cached.ToLocalChecked()->IsUndefined())
{
auto created = CreateDelegate(Object, Property);

This->Set(cache_id, created);
This->Set(context_, cache_id, created);
return created;
}
else
{
return cached;
return maybe_cached.ToLocalChecked();
}
}
};
Expand Down
11 changes: 7 additions & 4 deletions Source/V8/Private/FunctionCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,22 @@ namespace v8
// pass return parameter as '$'
if (PropertyFlags & CPF_ReturnParm)
{
auto sub_value = Object->Get(I.Keyword("$"));
auto sub_value = Object->Get(context, I.Keyword("$"));

WriteProperty(isolate, ReturnParam, Buffer, sub_value, FNoPropertyOwner());
if (!sub_value.IsEmpty())
{
WriteProperty(isolate, ReturnParam, Buffer, sub_value.ToLocalChecked(), FNoPropertyOwner());
}
}
// rejects 'const T&' and pass 'T&' as its name
else if ((PropertyFlags & (CPF_ConstParm | CPF_OutParm)) == CPF_OutParm)
{
auto sub_value = Object->Get(I.Keyword(Param->GetName()));
auto sub_value = Object->Get(context, I.Keyword(Param->GetName()));

if (!sub_value.IsEmpty())
{
// value can be null if isolate is in trouble
WriteProperty(isolate, Param, Buffer, sub_value, FNoPropertyOwner());
WriteProperty(isolate, Param, Buffer, sub_value.ToLocalChecked(), FNoPropertyOwner());
}
}
}
Expand Down
59 changes: 36 additions & 23 deletions Source/V8/Private/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,11 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
FIsolateHelper I(isolate_);

{
auto console = InContext->Global()->Get(I.Keyword("console"));
InContext->Global()->Set(I.Keyword("$console"), console);
auto console = InContext->Global()->Get(InContext, I.Keyword("console"));
if (!console.IsEmpty())
{
InContext->Global()->Set(InContext, I.Keyword("$console"), console.ToLocalChecked());
}
}

v8inspector = v8_inspector::V8Inspector::create(isolate_, this);
Expand Down Expand Up @@ -487,33 +490,43 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
HandleScope handle_scope(isolate_);

FIsolateHelper I(isolate_);

auto context_ = context();
Isolate::Scope isolate_scope(isolate_);
Context::Scope context_scope(context());
Context::Scope context_scope(context_);

TryCatch try_catch(isolate_);

auto console = context()->Global()->Get(I.Keyword("console")).As<v8::Object>();
auto maybe_console = context_->Global()->Get(context_, I.Keyword("console"));
if (!maybe_console.IsEmpty())
{
auto console = maybe_console.ToLocalChecked().As<v8::Object>();

auto method =
Verbosity == ELogVerbosity::Fatal || Verbosity == ELogVerbosity::Error ? I.Keyword("$error") :
Verbosity == ELogVerbosity::Warning ? I.Keyword("$warn") :
Verbosity == ELogVerbosity::Display ? I.Keyword("info") :
I.Keyword("$log");
auto function = console->Get(method).As<v8::Function>();
auto method =
Verbosity == ELogVerbosity::Fatal || Verbosity == ELogVerbosity::Error ? I.Keyword("$error") :
Verbosity == ELogVerbosity::Warning ? I.Keyword("$warn") :
Verbosity == ELogVerbosity::Display ? I.Keyword("info") :
I.Keyword("$log");

if (Verbosity == ELogVerbosity::Display)
{
Handle<Value> argv[2];
argv[0] = I.String(FString::Printf(TEXT("%%c%s: %s"), *Category.ToString(), V));
argv[1] = I.String(TEXT("color:gray"));
(void)function->Call(context(), console, 2, argv);
}
else
{
Handle<Value> argv[1];
argv[0] = I.String(FString::Printf(TEXT("%s: %s"), *Category.ToString(), V));
(void)function->Call(context(), console, 1, argv);
auto maybe_function = console->Get(context_, method);

if (!maybe_function.IsEmpty())
{
auto function = maybe_function.ToLocalChecked().As<v8::Function>();

if (Verbosity == ELogVerbosity::Display)
{
Handle<Value> argv[2];
argv[0] = I.String(FString::Printf(TEXT("%%c%s: %s"), *Category.ToString(), V));
argv[1] = I.String(TEXT("color:gray"));
(void)function->Call(context(), console, 2, argv);
}
else
{
Handle<Value> argv[1];
argv[0] = I.String(FString::Printf(TEXT("%s: %s"), *Category.ToString(), V));
(void)function->Call(context(), console, 1, argv);
}
}
}
}
}
Expand Down
Loading

0 comments on commit beea905

Please sign in to comment.