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

@ -3,13 +3,16 @@
/// \file property.h
/// \author Folling <mail@folling.io>
/// \defgroup properties Properties
/// \brief Properties define the structure and types of data.
/// @{
#include <ikarus/errors.h>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \defgroup properties Properties
/// \brief Properties define the structure and types of data.
/// @{
struct IkarusProject;
struct IkarusBlueprint;
IKARUS_BEGIN_HEADER
@ -41,7 +44,7 @@ struct IkarusProperty;
/// \pre \li Must not be null.
/// \param error_out \see errors.h
/// \return True if the property exists, false otherwise or if an error occurs.
IKA_API bool ikarus_property_exists(IkarusProperty * property, IkarusErrorData * error_out);
IKA_API bool ikarus_property_exists(struct IkarusProperty * property, struct IkarusErrorData * error_out);
/// \brief Flags for creating a property.
enum IkarusPropertyCreateFlags {
@ -69,13 +72,13 @@ enum IkarusPropertyCreateFlags {
/// \param error_out \see errors.h
/// \return The created property or NULL if an error occurred.
/// \remark Must only be deleted with #ikarus_property_delete.
IKA_API IkarusProperty * ikarus_property_create(
IKA_API struct IkarusProperty * ikarus_property_create(
struct IkarusBlueprint * blueprint,
char const * name,
char const * schema,
char const * default_value,
IkarusPropertyCreateFlags flags,
IkarusErrorData * error_out
enum IkarusPropertyCreateFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for copying a property.
@ -91,8 +94,11 @@ enum IkarusPropertyCopyFlags {
/// \param flags Flags for copying the property.
/// \param error_out \see errors.h
/// \return The copied property or NULL if an error occurred.
IKA_API IkarusProperty *
ikarus_property_copy(IkarusProperty * property, IkarusPropertyCopyFlags flags, IkarusErrorData * error_out);
IKA_API struct IkarusProperty * ikarus_property_copy(
struct IkarusProperty * property,
enum IkarusPropertyCopyFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Flags for deleting a property.
enum IkarusPropertyDeleteFlags {
@ -104,8 +110,11 @@ enum IkarusPropertyDeleteFlags {
/// \param property The property to delete.
/// \param flags Flags for deleting the property.
/// \param error_out \see errors.h
IKA_API void
ikarus_property_delete(IkarusProperty * property, IkarusPropertyDeleteFlags flags, IkarusErrorData * error_out);
IKA_API void ikarus_property_delete(
struct IkarusProperty * property,
enum IkarusPropertyDeleteFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Get the project a property belongs to.
/// \param property The property to get the project of.
@ -114,7 +123,8 @@ ikarus_property_delete(IkarusProperty * property, IkarusPropertyDeleteFlags flag
/// \param error_out \see errors.h
/// \return The project the property belongs to or null if an error occurred.
/// \remark Ownership remains with libikarus.
IKA_API struct IkarusProject * ikarus_property_get_project(IkarusProperty * property, IkarusErrorData * error_out);
IKA_API struct IkarusProject *
ikarus_property_get_project(struct IkarusProperty * property, struct IkarusErrorData * error_out);
/// \brief Get the name of a property.
/// \param property The property to get the name of.
@ -123,7 +133,7 @@ IKA_API struct IkarusProject * ikarus_property_get_project(IkarusProperty * prop
/// \param error_out \see errors.h
/// \return The name of the property or null if an error occurred.
/// \remark Ownership remains with libikarus.
IKA_API char const * ikarus_property_get_name(IkarusProperty * property, IkarusErrorData * error_out);
IKA_API char const * ikarus_property_get_name(struct IkarusProperty * property, struct IkarusErrorData * error_out);
/// \brief Flags for setting the name of a property.
enum IkarusPropertySetNameFlags {
@ -142,10 +152,10 @@ enum IkarusPropertySetNameFlags {
/// \param error_out \see errors.h
/// \remark Ownership remains with the caller.
IKA_API void ikarus_property_set_name(
IkarusProperty * property,
struct IkarusProperty * property,
char const * name,
IkarusPropertySetNameFlags flags,
IkarusErrorData * error_out
enum IkarusPropertySetNameFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Get the schema of a property.
@ -154,7 +164,7 @@ IKA_API void ikarus_property_set_name(
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The schema of the property in JSON format or null if an error occurred. \see schema.h
IKA_API char const * ikarus_property_get_schema(IkarusProperty * property, IkarusErrorData * error_out);
IKA_API char const * ikarus_property_get_schema(struct IkarusProperty * property, struct IkarusErrorData * error_out);
/// \brief Flags for setting the schema of a property.
enum IkarusPropertySetSchemaFlags {
@ -176,11 +186,11 @@ enum IkarusPropertySetSchemaFlags {
/// \param flags Flags for setting the schema of the property.
/// \param error_out \see errors.h
IKA_API void ikarus_property_set_schema(
IkarusProperty * property,
struct IkarusProperty * property,
char const * schema,
char const * new_default_value,
IkarusPropertySetSchemaFlags flags,
IkarusErrorData * error_out
enum IkarusPropertySetSchemaFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Get the default value of a property.
@ -189,7 +199,8 @@ IKA_API void ikarus_property_set_schema(
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The default value data of the property in JSON format or null if an error occurred. \see data.h
IKA_API char const * ikarus_property_get_default_value(IkarusProperty * property, IkarusErrorData * error_out);
IKA_API char const *
ikarus_property_get_default_value(struct IkarusProperty * property, struct IkarusErrorData * error_out);
/// \details The default value must match the schema of the property.
@ -210,10 +221,10 @@ enum IkarusPropertySetDefaultValueFlags {
/// \param flags Flags for setting the default value of the property.
/// \param error_out \see errors.h
IKA_API void ikarus_property_set_default_value(
IkarusProperty * property,
struct IkarusProperty * property,
char const * value,
IkarusPropertySetDefaultValueFlags flags,
IkarusErrorData * error_out
enum IkarusPropertySetDefaultValueFlags flags,
struct IkarusErrorData * error_out
);
/// \brief Gets all values for a property.