File: feature.h

package info (click to toggle)
libigloo 0.9.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,968 kB
  • sloc: ansic: 5,476; sh: 4,996; makefile: 62
file content (74 lines) | stat: -rw-r--r-- 2,828 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Copyright (C) 2020       Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */

#ifndef _LIBIGLOO__FEATURE_H_
#define _LIBIGLOO__FEATURE_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h> /* for size_t */
#include <stdbool.h>

#include <igloo/types.h>

/* ---[ PRIVATE ]--- */
/*
 * Those declarations are defined here as they must be known to the compiler.
 * Nobody should ever try to access them directly.
 */
struct igloo_feature_tag {
    /* Control structure */
    igloo_control_t             control;

    /* Name of feature */
    const char *                feature_name;

    /* STILL UNUSED: Feature description */
    const char *                feature_description;
    const char *                feature_uuid;
    const void *                type_reserved_ptr_0;
    const void *                type_reserved_ptr_1;
    const void *                type_reserved_ptr_2;
    const void *                type_reserved_ptr_3;
};

#define igloo_FEATURE__CONTROL_VERSION   igloo_CONTROL_VERSION_BUILD(1)
#define igloo_FEATURE__DEFINE_TYPE(name, suffix, ...) \
static igloo_feature_t igloo_feature__featuredef__ ## name = \
{ \
    .control = igloo_CONTROL_INIT3(igloo_FEATURE__CONTROL_VERSION, sizeof(igloo_feature_t), igloo_CONTROL_TYPE__FEATURE), \
    .feature_name = # name suffix, \
    , ## __VA_ARGS__ \
}
/* ---[ END PRIVATE ]--- */

#define igloo_FEATURE_FORWARD(name)         extern igloo_feature_t * name
#define igloo_FEATURE_PUBLIC(name, ...)     igloo_FEATURE__DEFINE_TYPE(name, "", ## __VA_ARGS__); igloo_feature_t * name = &(igloo_feature__featuredef__ ## name)
#define igloo_FEATURE_PRIVATE(name, ...)    igloo_FEATURE__DEFINE_TYPE(name, " (private)", ## __VA_ARGS__); static igloo_feature_t * name = &(igloo_feature__featuredef__ ## name)

igloo_error_t   igloo_feature_get_name(igloo_feature_t *feature, const char **name) igloo_ATTR_F_WARN_UNUSED_RESULT;
bool            igloo_feature_equal(igloo_feature_t *a, igloo_feature_t *b) igloo_ATTR_F_WARN_UNUSED_RESULT;


#ifdef __cplusplus
}
#endif

#endif /* ! _LIBIGLOO__FEATURE_H_ */