Skip to content

Commit

Permalink
Updated Pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
muit committed Aug 4, 2023
1 parent 72f7ff6 commit 54b5798
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 78 deletions.
4 changes: 0 additions & 4 deletions Apps/CLI/Src/CLIModule.cpp

This file was deleted.

3 changes: 3 additions & 0 deletions Apps/CLI/Src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright 2015-2023 Piperift - All rights reserved

// #include <Pipe/Memory/NewDelete.h>
// Override as first include

#include <AST/Utils/ModuleUtils.h>
#include <Compiler/Compiler.h>
#include <Compiler/Utils/BackendUtils.h>
Expand Down
4 changes: 0 additions & 4 deletions Apps/Editor/Src/EditorExeModule.cpp

This file was deleted.

3 changes: 3 additions & 0 deletions Apps/Editor/Src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright 2015-2023 Piperift - All rights reserved

// #include <Pipe/Memory/NewDelete.h>
// Override as first include

#include <Editor.h>
#include <FrameworkModule.h>
#include <GraphViewModule.h>
Expand Down
8 changes: 4 additions & 4 deletions Libs/Backends/LLVM/Compiler/Include/LLVMBackend/LLVMHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ namespace rift::LLVM
{
using namespace p::core;

inline llvm::StringRef ToLLVM(StringView string)
inline llvm::StringRef ToLLVM(p::StringView string)
{
return {string.data(), string.size()};
}
inline llvm::StringRef ToLLVM(const String& string)
inline llvm::StringRef ToLLVM(const p::String& string)
{
return ToLLVM(StringView{string});
return ToLLVM(p::StringView{string});
}
inline llvm::StringRef ToLLVM(p::Tag name)
{
return ToLLVM(StringView{name.AsString()});
return ToLLVM(p::StringView{name.AsString()});
}

template<typename T>
Expand Down
1 change: 0 additions & 1 deletion Libs/Backends/LLVM/Compiler/Src/LLVMBackendModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <NativeBindingModule.h>
#include <Pipe/Core/Log.h>
#include <Pipe/Files/Files.h>
#include <Pipe/Memory/NewDelete.h>

#if LLVM_VERSION_MAJOR >= 14
# include <llvm/MC/TargetRegistry.h>
Expand Down
1 change: 0 additions & 1 deletion Libs/Bindings/Native/Compiler/Src/NativeBindingModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <AST/Utils/ModuleUtils.h>
#include <AST/Utils/TypeUtils.h>
#include <clang-c/Index.h>
#include <Pipe/Memory/NewDelete.h>
#include <Pipe/PipeArrays.h>
#include <Pipe/PipeECS.h>

Expand Down
30 changes: 15 additions & 15 deletions Libs/Editor/Src/Tools/ASTDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace rift::Editor

void DrawEntityInspector(AST::Tree& ast, AST::Id entityId, bool* open = nullptr)
{
String name = "Entity Inspector";
p::String name = "Entity Inspector";
if (!IsNone(entityId))
Strings::FormatTo(name, " (id:{})", entityId);
Strings::FormatTo(name, "###Entity Inspector");
p::Strings::FormatTo(name, " (id:{})", entityId);
p::Strings::FormatTo(name, "###Entity Inspector");
UI::Begin(name.c_str(), open);
if (IsNone(entityId))
{
Expand All @@ -40,7 +40,7 @@ namespace rift::Editor
}

void* data = poolInstance.GetPool()->TryGetVoid(entityId);
static String typeName;
static p::String typeName;
typeName = type->GetName();

ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_DefaultOpen;
Expand Down Expand Up @@ -92,9 +92,9 @@ namespace rift::Editor

UI::TableNextColumn(); // Id

static String idText;
static p::String idText;
idText.clear();
Strings::FormatTo(idText, "{}", it.second);
p::Strings::FormatTo(idText, "{}", it.second);
UI::Text(idText);
}

Expand Down Expand Up @@ -188,36 +188,36 @@ namespace rift::Editor

void ASTDebugger::DrawNode(DrawNodeAccess access, AST::Id nodeId, bool showChildren)
{
static String idText;
static p::String idText;
idText.clear();
if (nodeId == AST::NoId)
{
idText = "No Id";
}
else if (auto version = p::GetIdVersion(nodeId); version > 0)
{
Strings::FormatTo(idText, "{} (v{})", p::GetIdIndex(nodeId), version);
p::Strings::FormatTo(idText, "{} (v{})", p::GetIdIndex(nodeId), version);
}
else
{
Strings::FormatTo(idText, "{}", p::GetIdIndex(nodeId));
p::Strings::FormatTo(idText, "{}", p::GetIdIndex(nodeId));
}

static String name;
static p::String name;
name.clear();
if (const auto* id = access.TryGet<const AST::CNamespace>(nodeId))
{
name = id->name.AsString();
}

static String path;
static p::String path;
path.clear();
if (const auto* file = access.TryGet<const AST::CFileRef>(nodeId))
{
path = p::ToString(file->path);

StringView filename = p::GetFilename(path);
Strings::FormatTo(name, name.empty() ? "file: {}" : " (file: {})", filename);
p::StringView filename = p::GetFilename(path);
p::Strings::FormatTo(name, name.empty() ? "file: {}" : " (file: {})", filename);
}

if (!filter.PassFilter(idText.c_str(), idText.c_str() + idText.size())
Expand All @@ -228,9 +228,9 @@ namespace rift::Editor

ImGui::TableNextRow();
ImGui::TableNextColumn();
static String inspectLabel;
static p::String inspectLabel;
inspectLabel.clear();
Strings::FormatTo(inspectLabel, ICON_FA_SEARCH "##{}", nodeId);
p::Strings::FormatTo(inspectLabel, ICON_FA_SEARCH "##{}", nodeId);
UI::PushButtonColor(UI::GetNeutralColor(1));
UI::PushTextColor(
selectedNode == nodeId ? UI::whiteTextColor : UI::whiteTextColor.Translucency(0.3f));
Expand Down
2 changes: 1 addition & 1 deletion Libs/Editor/Src/Tools/MemoryDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace rift::Editor

if (UI::BeginChild("Allocations"))
{
const sizet shown = math::Min<sizet>(10000, stats->allocations.size());
const sizet shown = math::Min<sizet>(10000, stats->allocations.Size());
for (i32 i = 0; i < shown; ++i)
{
const auto& allocation = stats->allocations[i];
Expand Down
7 changes: 2 additions & 5 deletions Libs/Editor/Src/Utils/Widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

namespace rift::Editor
{
using namespace p::core;


void ListTypesFromFilter(p::TAccessRef<AST::CNamespace> access, p::TArray<AST::Id> typeIds,
AST::Id& selectedId, ImGuiTextFilter& searchFilter)
{
Expand All @@ -23,7 +20,7 @@ namespace rift::Editor
continue;
}

UI::PushID(u32(id));
UI::PushID(p::u32(id));
if (UI::Selectable(name.data(), id == selectedId))
{
selectedId = id;
Expand Down Expand Up @@ -101,7 +98,7 @@ namespace rift::Editor
return selectedId != lastId;
}

bool InputLiteralValue(AST::Tree& ast, StringView label, AST::Id literalId)
bool InputLiteralValue(AST::Tree& ast, p::StringView label, AST::Id literalId)
{
return false;
}
Expand Down
24 changes: 12 additions & 12 deletions Libs/Framework/Src/AST/Utils/ModuleUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

namespace rift::AST
{
static p::TArray<ModuleBinding> moduleBindings;
TBroadcast<EntityReader&> onReadModulePools;
TBroadcast<EntityWriter&> onWriteModulePools;
static p::TArray<ModuleBinding> gModuleBindings;
TBroadcast<EntityReader&> gOnReadModulePools;
TBroadcast<EntityWriter&> gOnWriteModulePools;


bool ValidateModulePath(p::String& path, p::String& error)
Expand Down Expand Up @@ -204,7 +204,7 @@ namespace rift::AST
JsonFormatWriter writer{};
p::EntityWriter w{writer.GetWriter(), ast};
w.BeginObject();
w.SerializeSingleEntity(id, onWriteModulePools);
w.SerializeSingleEntity(id, gOnWriteModulePools);

data = writer.ToString();
}
Expand All @@ -217,26 +217,26 @@ namespace rift::AST
{
p::EntityReader r{formatReader, ast};
r.BeginObject();
r.SerializeSingleEntity(id, onReadModulePools);
r.SerializeSingleEntity(id, gOnReadModulePools);
}
}
const TBroadcast<EntityReader&>& OnReadModulePools()
{
return onReadModulePools;
return gOnReadModulePools;
}
const TBroadcast<EntityWriter&>& OnWriteModulePools()
{
return onWriteModulePools;
return gOnWriteModulePools;
}


void RegisterModuleBinding(ModuleBinding binding)
{
moduleBindings.AddUniqueSorted(Move(binding));
gModuleBindings.AddUniqueSorted(Move(binding));
}
void UnregisterModuleBinding(p::Tag bindingId)
{
moduleBindings.RemoveSorted(bindingId);
gModuleBindings.RemoveSorted(bindingId);
}
void AddBindingToModule(AST::Tree& ast, AST::Id id, p::Tag bindingId)
{
Expand All @@ -255,12 +255,12 @@ namespace rift::AST

const ModuleBinding* FindModuleBinding(p::Tag id)
{
const i32 index = moduleBindings.FindSortedEqual(id);
return index != NO_INDEX ? moduleBindings.Data() + index : nullptr;
const i32 index = gModuleBindings.FindSortedEqual(id);
return index != NO_INDEX ? gModuleBindings.Data() + index : nullptr;
}

p::TView<const ModuleBinding> GetModuleBindings()
{
return moduleBindings;
return gModuleBindings;
}
} // namespace rift::AST
18 changes: 9 additions & 9 deletions Libs/Framework/Src/AST/Utils/TypeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

namespace rift::AST
{
static p::TArray<RiftType> fileTypes;
static p::TArray<RiftType> gFileTypes;

auto typeComponents = [](auto& rw) {
auto gTypeComponents = [](auto& rw) {
rw.template SerializePools<CChild, CDeclVariable, CDeclFunction, CExprBinaryOperator,
CExprCall, CExprDeclRefId, CExprOutputs, CExprInputs, CStmtReturn, CExprType,
CExprUnaryOperator, CNodePosition, CNamespace, CParent, CLiteralBool, CLiteralFloating,
Expand Down Expand Up @@ -111,7 +111,7 @@ namespace rift::AST
w.BeginObject();

w.Next("type", ast.Get<CDeclType>(id).typeId);
w.SerializeEntity(id, typeComponents);
w.SerializeEntity(id, gTypeComponents);

data = writer.ToString();
}
Expand All @@ -133,7 +133,7 @@ namespace rift::AST
r.Next("type", typeId);
InitTypeFromFileType(ast, id, typeId);

r.SerializeEntity(id, typeComponents);
r.SerializeEntity(id, gTypeComponents);
}


Expand Down Expand Up @@ -490,22 +490,22 @@ namespace rift::AST

void RegisterFileType(RiftType&& type)
{
fileTypes.AddUniqueSorted(Move(type));
gFileTypes.AddUniqueSorted(Move(type));
}
void UnregisterFileType(p::Tag typeId)
{
fileTypes.RemoveSorted(typeId);
gFileTypes.RemoveSorted(typeId);
}

p::TView<const RiftType> GetFileTypes()
{
return fileTypes;
return gFileTypes;
}

const RiftType* FindFileType(p::Tag typeId)
{
const i32 index = fileTypes.FindSortedEqual(typeId);
return index != NO_INDEX ? fileTypes.Data() + index : nullptr;
const i32 index = gFileTypes.FindSortedEqual(typeId);
return index != NO_INDEX ? gFileTypes.Data() + index : nullptr;
}

const RiftType* FindFileType(p::TAccessRef<AST::CDeclType> access, AST::Id typeId)
Expand Down
4 changes: 0 additions & 4 deletions Libs/Framework/Src/FrameworkModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include "AST/Utils/ModuleUtils.h"
#include "AST/Utils/TypeUtils.h"

#include <Pipe/Memory/NewDelete.h>


P_OVERRIDE_NEW_DELETE

namespace rift
{
Expand Down
14 changes: 7 additions & 7 deletions Libs/Framework/Src/Rift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@

namespace rift
{
static p::TMap<p::ClassType*, p::TOwnPtr<class Module>> modules{};
static p::TArray<View> views{};
static p::TMap<p::ClassType*, p::TOwnPtr<class Module>> gModules{};
static p::TArray<View> gViews{};


void EnableModule(p::ClassType* type)
{
Check(Module::GetStaticType()->IsParentOf(type));

if (!modules.Contains(type))
if (!gModules.Contains(type))
{
auto module = MakeOwned<Module>(type);
module->DoLoad();
modules.Insert(type, Move(module));
gModules.Insert(type, Move(module));
}
}

void DisableModule(p::ClassType* type)
{
modules.Remove(type);
gModules.Remove(type);
}

p::TPtr<Module> GetModule(p::ClassType* type)
{
if (auto* module = modules.Find(type))
if (auto* module = gModules.Find(type))
{
return *module;
}
Expand All @@ -39,6 +39,6 @@ namespace rift

void RegisterView(View view)
{
views.Add(Move(view));
gViews.Add(Move(view));
}
}; // namespace rift
2 changes: 1 addition & 1 deletion Libs/Pipe
Submodule Pipe updated 53 files
+13 −2 .clang-tidy
+72 −72 Benchmarks/Arenas.bench.h
+2 −2 Benchmarks/main.cpp
+1 −1 Extern/robin-map
+1 −1 Extern/sparse-map
+25 −19 Include/Pipe/Core/Backward.h
+21 −32 Include/Pipe/Core/Checks.h
+16 −13 Include/Pipe/Core/Map.h
+8 −9 Include/Pipe/Core/PageBuffer.h
+33 −0 Include/Pipe/Core/Platform.h
+13 −16 Include/Pipe/Core/Set.h
+6 −13 Include/Pipe/Core/String.h
+1 −6 Include/Pipe/Core/StringView.h
+28 −0 Include/Pipe/Core/TypeTraits.h
+4 −26 Include/Pipe/Memory/Alloc.h
+15 −17 Include/Pipe/Memory/Arena.h
+0 −47 Include/Pipe/Memory/ArenaAllocator.h
+1 −2 Include/Pipe/Memory/HeapArena.h
+0 −36 Include/Pipe/Memory/IAllocator.h
+9 −10 Include/Pipe/Memory/Memory.h
+20 −11 Include/Pipe/Memory/MemoryStats.h
+3 −5 Include/Pipe/Memory/MonoLinearArena.h
+2 −3 Include/Pipe/Memory/MultiLinearArena.h
+60 −91 Include/Pipe/Memory/NewDelete.h
+58 −33 Include/Pipe/Memory/STLAllocator.h
+199 −198 Include/Pipe/PipeArrays.h
+12 −9 Include/Pipe/PipeECS.h
+1 −1 Include/Pipe/PipeECSFwd.h
+1 −1 Include/Pipe/Reflect/Builders/DataTypeBuilder.h
+1 −1 Include/Pipe/Reflect/ClassPtrBuilder.h
+1 −0 Include/Pipe/Reflect/EnumType.h
+1 −2 Include/Pipe/Reflect/ReflectionTraits.h
+2 −2 Include/Pipe/Reflect/TypeRegistry.h
+2 −5 Include/Pipe/Serialize/Formats/BinaryFormat.h
+2 −2 Src/Core/Checks.cpp
+28 −12 Src/Core/String.cpp
+2 −2 Src/Core/StringView.cpp
+1 −2 Src/Core/Tag.cpp
+1 −2 Src/Files/Paths.cpp
+5 −11 Src/Math/Math.cpp
+15 −13 Src/Memory/Alloc.cpp
+3 −4 Src/Memory/BestFitArena.cpp
+2 −3 Src/Memory/BigBestFitArena.cpp
+1 −1 Src/Memory/Memory.cpp
+66 −33 Src/Memory/MemoryStats.cpp
+3 −3 Src/Memory/MonoLinearArena.cpp
+5 −5 Src/Memory/MultiLinearArena.cpp
+4 −5 Src/Pipe.cpp
+5 −1 Src/PipeECS.cpp
+7 −3 Src/Serialize/Formats/BinaryFormat.cpp
+1 −0 Tests/CMakeLists.txt
+8 −5 Tests/Core/PageBuffer.spec.cpp
+6 −6 Tests/main.cpp
Loading

0 comments on commit 54b5798

Please sign in to comment.