fix various issues
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
3c250702b9
commit
c289344880
12 changed files with 33 additions and 50 deletions
|
|
@ -101,7 +101,7 @@ IKA_API void ikarus_project_get_blueprints(
|
||||||
/// \pre \li Must exist.
|
/// \pre \li Must exist.
|
||||||
/// \param error_out \see errors.h
|
/// \param error_out \see errors.h
|
||||||
/// \return The number of blueprints or undefined if an error occurs.
|
/// \return The number of blueprints or undefined if an error occurs.
|
||||||
IKA_API size_t ikarus_project_get_blueprint_count(IkarusProject * project, IkarusErrorData * error_out);
|
IKA_API size_t ikarus_project_get_blueprint_count(IkarusProject const * project, IkarusErrorData * error_out);
|
||||||
|
|
||||||
/// \brief Gets the entities of a project.
|
/// \brief Gets the entities of a project.
|
||||||
/// \param project The project to get the entities of.
|
/// \param project The project to get the entities of.
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
// NOLINTNEXTLINE(google-global-names-in-headers)
|
|
||||||
using std::size_t;
|
using std::size_t;
|
||||||
#else
|
#else
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
7
src/global.cpp
Normal file
7
src/global.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "ikarus/global.h"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
void ikarus_free(void * ptr) {
|
||||||
|
std::free(ptr);
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
#include "ikarus/id.h"
|
#include "ikarus/id.h"
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
|
|
||||||
#include <ikarus/objects/object_type.h>
|
#include <ikarus/objects/object_type.h>
|
||||||
|
|
||||||
constexpr uint64_t IKARUS_ID_OBJECT_TYPE_BITS = 8;
|
constexpr uint64_t IKARUS_ID_OBJECT_TYPE_BITS = 8;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project, char c
|
||||||
"failed to create blueprint: {}",
|
"failed to create blueprint: {}",
|
||||||
IkarusErrorInfo_Database_QueryFailed,
|
IkarusErrorInfo_Database_QueryFailed,
|
||||||
project->db->transact([name](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
project->db->transact([name](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`) VALUES(?, ?, ?)", IkarusObjectType_Blueprint, name));
|
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Blueprint, name, ""));
|
||||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Blueprint);
|
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Blueprint);
|
||||||
TRY(db->execute("INSERT INTO `blueprints`(`id`) VALUES(?)", id));
|
TRY(db->execute("INSERT INTO `blueprints`(`id`) VALUES(?)", id));
|
||||||
return cppbase::ok(id);
|
return cppbase::ok(id);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char const *
|
||||||
"failed to create entity: {}",
|
"failed to create entity: {}",
|
||||||
IkarusErrorInfo_Database_QueryFailed,
|
IkarusErrorInfo_Database_QueryFailed,
|
||||||
project->db->transact([name](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
project->db->transact([name](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`) VALUES(?, ?, ?)", IkarusObjectType_Entity, name));
|
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Entity, name, ""));
|
||||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Entity);
|
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Entity);
|
||||||
TRY(db->execute("INSERT INTO `entities`(`id`) VALUES(?)", id));
|
TRY(db->execute("INSERT INTO `entities`(`id`) VALUES(?)", id));
|
||||||
return cppbase::ok(id);
|
return cppbase::ok(id);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ T * create_property(
|
||||||
"failed to create property: {}",
|
"failed to create property: {}",
|
||||||
IkarusErrorInfo_Database_QueryFailed,
|
IkarusErrorInfo_Database_QueryFailed,
|
||||||
project->db->transact([name, property_source](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
project->db->transact([name, property_source](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`) VALUES(?, ?, ?)", IkarusObjectType_Property, name));
|
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Property, name, ""));
|
||||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Property);
|
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Property);
|
||||||
TRY(db->execute(
|
TRY(db->execute(
|
||||||
"INSERT INTO `properties`(`id`, `type`, `source`) VALUES(?, ?, ?)",
|
"INSERT INTO `properties`(`id`, `type`, `source`) VALUES(?, ?, ?)",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include <sqlitecpp/connection.hpp>
|
#include <sqlitecpp/connection.hpp>
|
||||||
|
|
||||||
namespace ikarus {
|
namespace ikarus {
|
||||||
CPPBASE_ASSET(m1_initial_layout, "persistence/migrations/m1_initial_layout.sql");
|
CPPBASE_ASSET(m0_initial_layout, "persistence/migrations/m0_initial_layout.sql");
|
||||||
|
|
||||||
class Migration : public sqlitecpp::Migration {
|
class Migration : public sqlitecpp::Migration {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
CREATE TABLE `metadata`
|
|
||||||
(
|
|
||||||
`key` VARCHAR(255) NOT NULL,
|
|
||||||
`value` VARCHAR(255) NOT NULL,
|
|
||||||
|
|
||||||
PRIMARY KEY (`key`)
|
|
||||||
)
|
|
||||||
|
|
@ -1,27 +1,22 @@
|
||||||
CREATE TABLE `objects`
|
CREATE TABLE `objects`
|
||||||
(
|
(
|
||||||
`do_not_access_rowid_alias` INTEGER PRIMARY KEY,
|
`do_not_access_rowid_alias` INTEGER PRIMARY KEY,
|
||||||
`object_type` INT NOT NULL,
|
`type` INT NOT NULL,
|
||||||
`id` INT GENERATED ALWAYS AS (`do_not_access_rowid_alias` | (`object_type` << 56)
|
`id` INT GENERATED ALWAYS AS (`do_not_access_rowid_alias` | (`type` << 56)) VIRTUAL,
|
||||||
) VIRTUAL,
|
|
||||||
`name` TEXT NOT NULL,
|
`name` TEXT NOT NULL,
|
||||||
`information` TEXT NOT NULL
|
`information` TEXT NOT NULL
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE UNIQUE INDEX `object_id` ON `objects` (`id`);
|
CREATE UNIQUE INDEX `object_id` ON `objects` (`id`);
|
||||||
CREATE INDEX `object_type` ON `objects` (`object_type`);
|
CREATE INDEX `object_type` ON `objects` (`type`);
|
||||||
|
|
||||||
CREATE
|
CREATE VIRTUAL TABLE `objects_fts` USING fts5
|
||||||
VIRTUAL TABLE `objects_fts` USING fts5
|
|
||||||
(
|
(
|
||||||
`name`,
|
`name`,
|
||||||
`information`,
|
`information`,
|
||||||
content=
|
content='objects',
|
||||||
'objects',
|
content_rowid='id',
|
||||||
content_rowid=
|
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||||
'id',
|
|
||||||
tokenize=
|
|
||||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `entities`
|
CREATE TABLE `entities`
|
||||||
|
|
@ -73,24 +68,18 @@ CREATE
|
||||||
VIRTUAL TABLE `property_default_value_fts` USING fts5
|
VIRTUAL TABLE `property_default_value_fts` USING fts5
|
||||||
(
|
(
|
||||||
`default_value`,
|
`default_value`,
|
||||||
content=
|
content='properties',
|
||||||
'properties',
|
content_rowid='object_id',
|
||||||
content_rowid=
|
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||||
'object_id',
|
|
||||||
tokenize=
|
|
||||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE
|
CREATE
|
||||||
VIRTUAL TABLE `property_settings_fts` USING fts5
|
VIRTUAL TABLE `property_settings_fts` USING fts5
|
||||||
(
|
(
|
||||||
`settings`,
|
`settings`,
|
||||||
content=
|
content='properties',
|
||||||
'properties',
|
content_rowid='object_id',
|
||||||
content_rowid=
|
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||||
'object_id',
|
|
||||||
tokenize=
|
|
||||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `values`
|
CREATE TABLE `values`
|
||||||
|
|
@ -108,8 +97,6 @@ CREATE
|
||||||
VIRTUAL TABLE `values_fts` USING fts5
|
VIRTUAL TABLE `values_fts` USING fts5
|
||||||
(
|
(
|
||||||
`value`,
|
`value`,
|
||||||
content=
|
content='values',
|
||||||
'values',
|
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||||
tokenize=
|
);
|
||||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
|
||||||
)
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
#include "project.hpp"
|
#include "ikarus/persistence/project.h"
|
||||||
|
|
||||||
#include "migrations.hpp"
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <cppbase/strings.hpp>
|
#include <cppbase/strings.hpp>
|
||||||
|
|
||||||
#include <ikarus/persistence/project.h>
|
|
||||||
|
|
||||||
#include <objects/blueprint.hpp>
|
#include <objects/blueprint.hpp>
|
||||||
#include <objects/entity.hpp>
|
#include <objects/entity.hpp>
|
||||||
#include <objects/properties/number_property.hpp>
|
#include <objects/properties/number_property.hpp>
|
||||||
#include <objects/properties/property.hpp>
|
#include <objects/properties/property.hpp>
|
||||||
#include <objects/properties/text_property.hpp>
|
#include <objects/properties/text_property.hpp>
|
||||||
#include <objects/properties/toggle_property.hpp>
|
#include <objects/properties/toggle_property.hpp>
|
||||||
|
#include <persistence/migrations.hpp>
|
||||||
|
#include <persistence/project.hpp>
|
||||||
|
|
||||||
IkarusProject::IkarusProject(std::string_view name, std::string_view path, std::unique_ptr<sqlitecpp::Connection> && db):
|
IkarusProject::IkarusProject(std::string_view name, std::string_view path, std::unique_ptr<sqlitecpp::Connection> && db):
|
||||||
name{name},
|
name{name},
|
||||||
|
|
|
||||||
2
vendor/sqlitecpp
vendored
2
vendor/sqlitecpp
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit e41d51ed750c5f0a37fc1894c5dd382df32ead26
|
Subproject commit 66f5747f1ad3e43960e9a77755e770229b90004e
|
||||||
Loading…
Add table
Add a link
Reference in a new issue