diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-09-30 22:57:35 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-06 23:52:40 +0100 |
commit | 9d89b64d59c94651922ec97a671eff347f2f64de (patch) | |
tree | 0ab133694e1873cad8f45d64af7b15cd26100487 /Userland | |
parent | a95b321bf10638fc93f5ca20134f3fc2d48d06ad (diff) | |
download | serenity-9d89b64d59c94651922ec97a671eff347f2f64de.zip |
LibSQL: Resolve cyclic dependency
Previously, class SQL::Key
depends on def class SQL::IndexDef (because inline def index())
depends on def class SQL::KeyPartDef (inline def key_definition())
depends on def class SQL::ColumnDef (because base class)
depends on def class SQL::Relation (because base class)
depends on def class SQL::Key (because inline def hash()).
This hasn't caused any problems so far because Meta.h happened to be
always included after Key.h (in part due to alphabetical ordering).
However, a compilation that for example only contains
#include <Userland/Libraries/LibSQL/Key.h>
would fail to compile.
This patch resolves this issue by pushing the inline definition of
SQL::Relation::hash() into a different file. Yes, this might reduce
performance marginally, but this gets it to compile again.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibSQL/Key.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/Meta.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/Meta.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/Row.h | 1 |
4 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Libraries/LibSQL/Key.h b/Userland/Libraries/LibSQL/Key.h index e05b017631..e9a3eb1a74 100644 --- a/Userland/Libraries/LibSQL/Key.h +++ b/Userland/Libraries/LibSQL/Key.h @@ -8,6 +8,7 @@ #include <AK/RefPtr.h> #include <LibSQL/Forward.h> +#include <LibSQL/Meta.h> #include <LibSQL/Tuple.h> namespace SQL { diff --git a/Userland/Libraries/LibSQL/Meta.cpp b/Userland/Libraries/LibSQL/Meta.cpp index 09fafad9c8..65859f0e76 100644 --- a/Userland/Libraries/LibSQL/Meta.cpp +++ b/Userland/Libraries/LibSQL/Meta.cpp @@ -10,6 +10,11 @@ namespace SQL { +u32 Relation::hash() const +{ + return key().hash(); +} + SchemaDef::SchemaDef(String name) : Relation(move(name)) { diff --git a/Userland/Libraries/LibSQL/Meta.h b/Userland/Libraries/LibSQL/Meta.h index 77fdfe0bd3..ec8cd367f7 100644 --- a/Userland/Libraries/LibSQL/Meta.h +++ b/Userland/Libraries/LibSQL/Meta.h @@ -14,8 +14,8 @@ #include <AK/Vector.h> #include <LibCore/Object.h> #include <LibSQL/Forward.h> -#include <LibSQL/Key.h> #include <LibSQL/Type.h> +#include <LibSQL/Value.h> namespace SQL { @@ -28,7 +28,7 @@ class Relation : public Core::Object { C_OBJECT_ABSTRACT(Relation); public: - u32 hash() const { return key().hash(); } + u32 hash() const; u32 pointer() const { return m_pointer; } void set_pointer(u32 pointer) { m_pointer = pointer; } ~Relation() override = default; diff --git a/Userland/Libraries/LibSQL/Row.h b/Userland/Libraries/LibSQL/Row.h index 25c6a8cab7..117c7ed613 100644 --- a/Userland/Libraries/LibSQL/Row.h +++ b/Userland/Libraries/LibSQL/Row.h @@ -10,6 +10,7 @@ #include <AK/RefPtr.h> #include <LibSQL/Forward.h> #include <LibSQL/Meta.h> +#include <LibSQL/Tuple.h> #include <LibSQL/Value.h> namespace SQL { |