Removes GraphToCPlusPlus from Gems/ScriptCanvas
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "GraphToCPlusPlus.h"
|
||||
|
||||
#include <ScriptCanvas/Grammar/AbstractCodeModel.h>
|
||||
#include <ScriptCanvas/Grammar/Primitives.h>
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
namespace Translation
|
||||
{
|
||||
Configuration CreateCPlusPluseConfig()
|
||||
{
|
||||
Configuration configuration;
|
||||
configuration.m_blockCommentClose = "*/";
|
||||
configuration.m_blockCommentOpen = "/*";
|
||||
configuration.m_namespaceClose = "}";
|
||||
configuration.m_namespaceOpen = "{";
|
||||
configuration.m_namespaceOpenPrefix = "namespace";
|
||||
configuration.m_scopeClose = "}";
|
||||
configuration.m_scopeOpen = "{";
|
||||
configuration.m_singleLineComment = "//";
|
||||
return configuration;
|
||||
}
|
||||
|
||||
GraphToCPlusPlus::GraphToCPlusPlus(const Grammar::AbstractCodeModel& model)
|
||||
: GraphToX(CreateCPlusPluseConfig(), model)
|
||||
{
|
||||
WriteHeaderDotH();
|
||||
WriteHeaderDotCPP();
|
||||
|
||||
TranslateDependenciesDotH();
|
||||
TranslateDependenciesDotCPP();
|
||||
|
||||
TranslateNamespaceOpen();
|
||||
{
|
||||
TranslateClassOpen();
|
||||
{
|
||||
TranslateVariables();
|
||||
TranslateHandlers();
|
||||
TranslateConstruction();
|
||||
TranslateDestruction();
|
||||
TranslateStartNode();
|
||||
}
|
||||
TranslateClassClose();
|
||||
}
|
||||
TranslateNamespaceClose();
|
||||
}
|
||||
|
||||
AZ::Outcome<void, AZStd::pair<AZStd::string, AZStd::string>> GraphToCPlusPlus::Translate(const Grammar::AbstractCodeModel& model, AZStd::string& dotH, AZStd::string& dotCPP)
|
||||
{
|
||||
GraphToCPlusPlus translation(model);
|
||||
|
||||
if (translation.IsSuccessfull())
|
||||
{
|
||||
dotH = AZStd::move(translation.m_dotH.MoveOutput());
|
||||
dotCPP = AZStd::move(translation.m_dotCPP.MoveOutput());
|
||||
return AZ::Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure(AZStd::make_pair(AZStd::string(".h errors"), AZStd::string(".cpp errors")));
|
||||
}
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateClassClose()
|
||||
{
|
||||
m_dotH.Outdent();
|
||||
m_dotH.WriteIndent();
|
||||
m_dotH.Write("};");
|
||||
m_dotH.WriteSpace();
|
||||
SingleLineComment(m_dotH);
|
||||
m_dotH.WriteSpace();
|
||||
m_dotH.WriteLine("class %s", GetGraphName().data());
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateClassOpen()
|
||||
{
|
||||
m_dotH.WriteIndent();
|
||||
m_dotH.WriteLine("class %s", GetGraphName().data());
|
||||
m_dotH.WriteIndent();
|
||||
m_dotH.WriteLine("{");
|
||||
m_dotH.Indent();
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateConstruction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateDependencies()
|
||||
{
|
||||
TranslateDependenciesDotH();
|
||||
TranslateDependenciesDotCPP();
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateDependenciesDotH()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateDependenciesDotCPP()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateDestruction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateHandlers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateNamespaceOpen()
|
||||
{
|
||||
OpenNamespace(m_dotH, "ScriptCanvas");
|
||||
OpenNamespace(m_dotH, GetAutoNativeNamespace());
|
||||
OpenNamespace(m_dotCPP, "ScriptCanvas");
|
||||
OpenNamespace(m_dotCPP, GetAutoNativeNamespace());
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateNamespaceClose()
|
||||
{
|
||||
CloseNamespace(m_dotH, "ScriptCanvas");
|
||||
CloseNamespace(m_dotH, GetAutoNativeNamespace());
|
||||
CloseNamespace(m_dotCPP, "ScriptCanvas");
|
||||
CloseNamespace(m_dotCPP, GetAutoNativeNamespace());
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateStartNode()
|
||||
{
|
||||
// write a start function
|
||||
const Node* startNode = nullptr;
|
||||
|
||||
if (startNode)
|
||||
{
|
||||
{ // .h
|
||||
m_dotH.WriteIndent();
|
||||
m_dotH.WriteLine("public: static void %s(const RuntimeContext& context);", Grammar::k_OnGraphStartFunctionName);
|
||||
}
|
||||
|
||||
{ // .cpp
|
||||
m_dotCPP.WriteIndent();
|
||||
m_dotCPP.WriteLine("void %s::%s(const RuntimeContext& context)", GetGraphName().data(), Grammar::k_OnGraphStartFunctionName);
|
||||
OpenScope(m_dotCPP);
|
||||
{
|
||||
m_dotCPP.WriteIndent();
|
||||
m_dotCPP.WriteLine("AZ_TracePrintf(\"ScriptCanvas\", \"This call wasn't generated from parsing a print node!\");");
|
||||
m_dotCPP.WriteLine("LogNotificationBus::Event(context.GetGraphId(), &LogNotifications::LogMessage, \"This call wasn't generated from parsing a print node!\");");
|
||||
// get the related function call and call it
|
||||
// with possible appropriate variables
|
||||
}
|
||||
CloseScope(m_dotCPP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::TranslateVariables()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::WriteHeader()
|
||||
{
|
||||
WriteHeaderDotH();
|
||||
WriteHeaderDotCPP();
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::WriteHeaderDotCPP()
|
||||
{
|
||||
WriteCopyright(m_dotCPP);
|
||||
m_dotCPP.WriteNewLine();
|
||||
WriteDoNotModify(m_dotCPP);
|
||||
m_dotCPP.WriteNewLine();
|
||||
m_dotCPP.WriteLine("#include \"%s.h\"", GetGraphName().data());
|
||||
m_dotCPP.WriteNewLine();
|
||||
}
|
||||
|
||||
void GraphToCPlusPlus::WriteHeaderDotH()
|
||||
{
|
||||
WriteCopyright(m_dotH);
|
||||
m_dotH.WriteNewLine();
|
||||
m_dotH.WriteLine("#pragma once");
|
||||
m_dotH.WriteNewLine();
|
||||
WriteDoNotModify(m_dotH);
|
||||
m_dotH.WriteNewLine();
|
||||
m_dotH.WriteLine("#include <Execution/NativeHostDeclarations.h>");
|
||||
m_dotH.WriteNewLine();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
|
||||
#include "TranslationUtilities.h"
|
||||
#include "GraphToX.h"
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
class Graph;
|
||||
|
||||
namespace Grammar
|
||||
{
|
||||
class AbstractCodeModel;
|
||||
}
|
||||
|
||||
namespace Translation
|
||||
{
|
||||
class GraphToCPlusPlus
|
||||
: public GraphToX
|
||||
{
|
||||
public:
|
||||
static AZ::Outcome<void, AZStd::pair<AZStd::string, AZStd::string>> Translate(const Grammar::AbstractCodeModel& model, AZStd::string& dotH, AZStd::string& dotCPP);
|
||||
|
||||
AZ_INLINE bool IsSuccessfull() const { return false; }
|
||||
private:
|
||||
// cpp only
|
||||
Writer m_dotH;
|
||||
Writer m_dotCPP;
|
||||
|
||||
GraphToCPlusPlus(const Grammar::AbstractCodeModel& model);
|
||||
|
||||
void TranslateClassClose();
|
||||
void TranslateClassOpen();
|
||||
void TranslateConstruction();
|
||||
void TranslateDependencies();
|
||||
void TranslateDependenciesDotH();
|
||||
void TranslateDependenciesDotCPP();
|
||||
void TranslateDestruction();
|
||||
void TranslateFunctions();
|
||||
void TranslateHandlers();
|
||||
void TranslateNamespaceOpen();
|
||||
void TranslateNamespaceClose();
|
||||
void TranslateStartNode();
|
||||
void TranslateVariables();
|
||||
void WriteHeader(); // Write, not translate, because this should be less dependent on the contents of the graph
|
||||
void WriteHeaderDotH(); // Write, not translate, because this should be less dependent on the contents of the graph
|
||||
void WriteHeaderDotCPP(); // Write, not translate, because this should be less dependent on the contents of the graph
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <ScriptCanvas/Grammar/PrimitivesDeclarations.h>
|
||||
#include <ScriptCanvas/Grammar/AbstractCodeModel.h>
|
||||
#include <ScriptCanvas/Translation/GraphToCPlusPlus.h>
|
||||
#include <ScriptCanvas/Translation/GraphToLua.h>
|
||||
#include <ScriptCanvas/Core/Graph.h>
|
||||
|
||||
@@ -27,41 +26,6 @@ namespace TranslationCPP
|
||||
using namespace ScriptCanvas;
|
||||
using namespace ScriptCanvas::Translation;
|
||||
|
||||
/*
|
||||
AZ::Outcome<AZStd::pair<AZStd::string, AZStd::string>, AZStd::pair<AZStd::string, AZStd::string>> ToCPlusPlus(const Grammar::AbstractCodeModel& model, bool rawSave = false)
|
||||
{
|
||||
AZStd::string dotH, dotCPP;
|
||||
auto outcome = GraphToCPlusPlus::Translate(model, dotH, dotCPP);
|
||||
if (outcome.IsSuccess())
|
||||
{
|
||||
#if defined(SCRIPT_CANVAS_PRINT_FILES_CONSOLE)
|
||||
AZ_TracePrintf("ScriptCanvas", "\n\n *** .h file ***\n\n");
|
||||
AZ_TracePrintf("ScriptCanvas", dotH.data());
|
||||
AZ_TracePrintf("ScriptCanvas", "\n\n *** .cpp file *\n\n");
|
||||
AZ_TracePrintf("ScriptCanvas", dotCPP.data());
|
||||
AZ_TracePrintf("ScriptCanvas", "\n\n");
|
||||
#endif
|
||||
if (rawSave)
|
||||
{
|
||||
auto saveOutcome = SaveDotH(model.GetSource(), dotH);
|
||||
if (saveOutcome.IsSuccess())
|
||||
{
|
||||
saveOutcome = SaveDotCPP(model.GetSource(), dotCPP);
|
||||
}
|
||||
if (!saveOutcome.IsSuccess())
|
||||
{
|
||||
AZ_TracePrintf("Save failed %s", saveOutcome.GetError().data());
|
||||
}
|
||||
}
|
||||
return AZ::Success(AZStd::make_pair(AZStd::move(dotH), AZStd::move(dotCPP)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure(outcome.TakeError());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
AZ::Outcome<TargetResult, ErrorList> ToLua(const Grammar::AbstractCodeModel& model, bool rawSave = false)
|
||||
{
|
||||
auto outcome = GraphToLua::Translate(model);
|
||||
|
||||
Reference in New Issue
Block a user