improve C header compatibility

This commit is contained in:
Folling 2025-01-05 18:48:24 +01:00
parent 24335a0a1f
commit 9ea02d5cb1
No known key found for this signature in database
9 changed files with 151 additions and 165 deletions

View file

@ -1,15 +1,19 @@
#pragma once
#include <ikarus/errors.h>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \file entity.h
/// \author Folling <mail@folling.io>
/// \defgroup entities Entities
/// \brief Entities are the core building blocks of Ikarus.
#include <ikarus/errors.h>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
struct IkarusProject;
struct IkarusEntity;
struct IkarusProperty;
IKARUS_BEGIN_HEADER
/// \brief Entities are the core building blocks of Ikarus.
@ -38,8 +42,7 @@ enum IkarusEntityCreateFlags {
/// \pre \li Must not be null.
/// \param error_out \see errors.h
/// \return True if the entity exists, false otherwise or if an error occurs.
IKA_API bool
ikarus_entity_exists(IkarusEntity * entity, IkarusErrorData * error_out);
IKA_API bool ikarus_entity_exists(struct IkarusEntity * entity, struct IkarusErrorData * error_out);
/// \brief Creates a new entity.
/// \param project The project to create the entity in.
@ -51,11 +54,11 @@ ikarus_entity_exists(IkarusEntity * entity, IkarusErrorData * error_out);
/// \param flags Flags for creating the entity.
/// \param error_out \see errors.h
/// \return The created entity or null if an error occurs.
IKA_API IkarusEntity * ikarus_entity_create(
IKA_API struct IkarusEntity * ikarus_entity_create(
struct IkarusProject * project,
char const * name,
IkarusEntityCreateFlags flags,
IkarusErrorData * error_out
enum IkarusEntityCreateFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for deleting an entity.
@ -71,9 +74,9 @@ enum IkarusEntityDeleteFlags {
/// \param flags Flags for deleting the entity.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_delete(
IkarusEntity * entity,
IkarusEntityDeleteFlags flags,
IkarusErrorData * error_out
struct IkarusEntity * entity,
enum IkarusEntityDeleteFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for copying an entity.
@ -89,11 +92,8 @@ enum IkarusEntityCopyFlags {
/// \param flags Flags for copying the entity.
/// \param error_out \see errors.h
/// \return The copied entity or null if an error occurs.
IKA_API IkarusEntity * ikarus_entity_copy(
IkarusEntity * entity,
IkarusEntityCopyFlags flags,
IkarusErrorData * error_out
);
IKA_API struct IkarusEntity *
ikarus_entity_copy(struct IkarusEntity * entity, enum IkarusEntityCopyFlags flags, struct IkarusErrorData * error_out);
/// \brief Gets the project an entity belongs to.
/// \param entity The entity to get the project of.
@ -102,7 +102,7 @@ IKA_API IkarusEntity * ikarus_entity_copy(
/// \param error_out \see errors.h
/// \return The project the entity belongs to.
IKA_API struct IkarusProject *
ikarus_entity_get_project(IkarusEntity * entity, IkarusErrorData * error_out);
ikarus_entity_get_project(struct IkarusEntity * entity, struct IkarusErrorData * error_out);
/// \brief Gets the name of an entity.
/// \param entity The entity to get the name of.
@ -110,8 +110,7 @@ ikarus_entity_get_project(IkarusEntity * entity, IkarusErrorData * error_out);
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The name of the entity.
IKA_API char const *
ikarus_entity_get_name(IkarusEntity * entity, IkarusErrorData * error_out);
IKA_API char const * ikarus_entity_get_name(struct IkarusEntity * entity, struct IkarusErrorData * error_out);
/// \brief Flags for setting the name of an entity.
enum IkarusEntitySetNameFlags {
@ -129,10 +128,10 @@ enum IkarusEntitySetNameFlags {
/// \param flags Flags for setting the name of the entity.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_set_name(
IkarusEntity * entity,
struct IkarusEntity * entity,
char const * name,
IkarusEntitySetNameFlags flags,
IkarusErrorData * error_out
enum IkarusEntitySetNameFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Gets whether an entity is linked to a blueprint.
@ -146,9 +145,9 @@ IKA_API void ikarus_entity_set_name(
/// \param error_out \see errors.h
/// \return True if the entity is linked to the blueprint, false otherwise or if an error occurs.
IKA_API bool ikarus_entity_is_linked_to_blueprint(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusBlueprint * blueprint,
IkarusErrorData * error_out
struct IkarusErrorData * error_out
);
/// \brief Gets the blueprints an entity is linked to.
@ -159,9 +158,9 @@ IKA_API bool ikarus_entity_is_linked_to_blueprint(
/// or undefined if an error occurs.
/// \param error_out \see errors.h
IKA_API struct IkarusBlueprint ** ikarus_entity_get_linked_blueprints(
IkarusEntity * entity,
struct IkarusEntity * entity,
size_t * size_out,
IkarusErrorData * error_out
struct IkarusErrorData * error_out
);
/// \brief Gets the number of blueprints an entity is linked to.
@ -170,10 +169,8 @@ IKA_API struct IkarusBlueprint ** ikarus_entity_get_linked_blueprints(
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The number of linked blueprints or 0 if an error occurs.
IKA_API size_t ikarus_entity_get_linked_blueprints_count(
IkarusEntity * entity,
IkarusErrorData * error_out
);
IKA_API size_t
ikarus_entity_get_linked_blueprints_count(struct IkarusEntity * entity, struct IkarusErrorData * error_out);
/// \brief Flags for linking an entity to a blueprint.
enum IkarusEntityLinkBlueprintFlags {
@ -195,10 +192,10 @@ enum IkarusEntityLinkBlueprintFlags {
/// \param flags Flags for linking the entity to the blueprint.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_link_blueprint(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusBlueprint * blueprint,
IkarusEntityLinkBlueprintFlags flags,
IkarusErrorData * error_out
enum IkarusEntityLinkBlueprintFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for unlinking an entity from a blueprint.
@ -220,10 +217,10 @@ enum IkarusEntityUnlinkBlueprintFlags {
/// \param flags Flags for unlinking the entity from the blueprint.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_unlink_blueprint(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusBlueprint * blueprint,
IkarusEntityUnlinkBlueprintFlags flags,
IkarusErrorData * error_out
enum IkarusEntityUnlinkBlueprintFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Gets whether an entity has a value.
@ -234,11 +231,8 @@ IKA_API void ikarus_entity_unlink_blueprint(
/// \pre \li Must not be null.
/// \param error_out \see errors.h
/// \return True if the entity has a value with the name, false otherwise or if an error occurs.
IKA_API bool ikarus_entity_has_value(
IkarusEntity * entity,
char const * name,
IkarusErrorData * error_out
);
IKA_API bool
ikarus_entity_has_value(struct IkarusEntity * entity, char const * name, struct IkarusErrorData * error_out);
/// \brief Struct for an entity value.
struct IkarusEntityValue {
@ -256,11 +250,8 @@ struct IkarusEntityValue {
/// or undefined if an error occurs.
/// \param error_out \see errors.h
/// \return The values or null if an error occurs.
IKA_API IkarusEntityValue * ikarus_entity_get_values(
IkarusEntity * entity,
size_t * size_out,
IkarusErrorData * error_out
);
IKA_API struct IkarusEntityValue *
ikarus_entity_get_values(struct IkarusEntity * entity, size_t * size_out, struct IkarusErrorData * error_out);
/// \brief Gets a value of an entity.
/// \param entity The entity to get the value of.
@ -271,11 +262,8 @@ IKA_API IkarusEntityValue * ikarus_entity_get_values(
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The value, in json format of or null if an error occurs. \see value.h
IKA_API char const * ikarus_entity_get_value(
IkarusEntity * entity,
char const * name,
IkarusErrorData * error_out
);
IKA_API char const *
ikarus_entity_get_value(struct IkarusEntity * entity, char const * name, struct IkarusErrorData * error_out);
/// \brief Flags for setting a value of an entity.
enum IkarusEntitySetValueFlags {
@ -297,11 +285,11 @@ enum IkarusEntitySetValueFlags {
/// \param flags Flags for setting the value.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_set_value(
IkarusEntity * entity,
struct IkarusEntity * entity,
char const * name,
char const * value,
IkarusEntitySetValueFlags flags,
IkarusErrorData * error_out
enum IkarusEntitySetValueFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for deleting a value of an entity.
@ -320,10 +308,10 @@ enum IkarusEntityDeleteValueFlags {
/// \param flags Flags for deleting the value.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_delete_value(
IkarusEntity * entity,
struct IkarusEntity * entity,
char const * name,
IkarusEntityDeleteValueFlags flags,
IkarusErrorData * error_out
enum IkarusEntityDeleteValueFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Gets whether an entity has a property value.
@ -337,9 +325,9 @@ IKA_API void ikarus_entity_delete_value(
/// \param error_out \see errors.h
/// \return True if the entity has a value for the property, false otherwise or if an error occurs.
IKA_API bool ikarus_entity_has_property_value(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusProperty * property,
IkarusErrorData * error_out
struct IkarusErrorData * error_out
);
/// \brief Struct for an entity property value.
@ -358,11 +346,8 @@ struct IkarusEntityPropertyValue {
/// returned array or undefined if an error occurs.
/// \param error_out \see errors.h
/// \return The property values, or null if an error occurs.
IKA_API IkarusEntityPropertyValue * ikarus_entity_get_property_values(
IkarusEntity * entity,
size_t * size_out,
IkarusErrorData * error_out
);
IKA_API struct IkarusEntityPropertyValue *
ikarus_entity_get_property_values(struct IkarusEntity * entity, size_t * size_out, struct IkarusErrorData * error_out);
/// \brief Gets the value of a property of an entity.
/// \param entity The entity to get the value of.
@ -376,9 +361,9 @@ IKA_API IkarusEntityPropertyValue * ikarus_entity_get_property_values(
/// \return The value, in json format of or null if an error occurs. \see
/// value.h
IKA_API char const * ikarus_entity_get_property_value(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusProperty * property,
IkarusErrorData * error_out
struct IkarusErrorData * error_out
);
/// \brief Flags for setting the value of a property of an entity.
@ -403,11 +388,11 @@ enum IkarusEntitySetPropertyValueFlags {
/// \param flags Flags for setting the property value.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_set_property_value(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusProperty * property,
char const * value,
IkarusEntitySetPropertyValueFlags flags,
IkarusErrorData * error_out
enum IkarusEntitySetPropertyValueFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for clearing the value of a property of an entity.
@ -427,10 +412,10 @@ enum IkarusEntityClearPropertyValueFlags {
/// \param flags Flags for clearing the property value.
/// \param error_out \see errors.h
IKA_API void ikarus_entity_clear_property_value(
IkarusEntity * entity,
struct IkarusEntity * entity,
struct IkarusProperty * property,
IkarusEntitySetPropertyValueFlags flags,
IkarusErrorData * error_out
enum IkarusEntitySetPropertyValueFlags flags,
struct IkarusErrorData * error_out
);
IKARUS_END_HEADER