Skip to content

Commit 37ea456

Browse files
committed
core: Add api.h
Add api.h that defines CLAP_API for API function prototypes. Apply it to all clap.h function prototypes. Signed-off-by: Alexander Shishkin <alex@ash.works>
1 parent 324b2e4 commit 37ea456

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

core/api.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
#ifndef __CLAP_API_H__
3+
#define __CLAP_API_H__
4+
5+
#ifdef __cplusplus
6+
#define CLAP_API extern "C"
7+
#else
8+
#define CLAP_API extern
9+
#endif /* !__cplusplus */
10+
11+
#endif /* !__CLAP_API_H__ */

core/clap.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef __CLAP_CLAP_H__
33
#define __CLAP_CLAP_H__
44

5+
#include "api.h"
56
#include "lut.h"
67
#include "render.h"
78

@@ -35,6 +36,7 @@ typedef struct clap_os_info {
3536
* Get information about the platform/OS where this code is running.
3637
* Return: struct clap_os_info pointer (nonnull).
3738
*/
39+
CLAP_API
3840
clap_os_info *clap_get_os(clap_context *ctx);
3941

4042
/**
@@ -44,6 +46,7 @@ clap_os_info *clap_get_os(clap_context *ctx);
4446
* If physics engine was initialized, get a physics handle (struct phys *).
4547
* Return: struct phys pointer or NULL if physics was not initialized.
4648
*/
49+
CLAP_API
4750
struct phys *clap_get_phys(struct clap_context *ctx) __nonnull_params((1));
4851

4952
/**
@@ -53,6 +56,7 @@ struct phys *clap_get_phys(struct clap_context *ctx) __nonnull_params((1));
5356
* Get clap configuration with which clap_init() was initialized.
5457
* Return: struct clap_config pointer (nonnull).
5558
*/
59+
CLAP_API
5660
struct clap_config *clap_get_config(struct clap_context *ctx) __returns_nonnull __nonnull_params((1));
5761

5862
/**
@@ -61,6 +65,7 @@ struct clap_config *clap_get_config(struct clap_context *ctx) __returns_nonnull
6165
*
6266
* Return: messagebus pointer (nonnull).
6367
*/
68+
CLAP_API
6469
struct messagebus *clap_get_messagebus(struct clap_context *ctx) __returns_nonnull __nonnull_params((1));
6570

6671
/**
@@ -70,6 +75,7 @@ struct messagebus *clap_get_messagebus(struct clap_context *ctx) __returns_nonnu
7075
* If graphics was initialized, return graphics renderer's main object.
7176
* Return: renderer_t pointer or NULL if graphics is not used.
7277
*/
78+
CLAP_API
7379
renderer_t *clap_get_renderer(struct clap_context *ctx) __nonnull_params((1));
7480

7581
/**
@@ -83,6 +89,7 @@ renderer_t *clap_get_renderer(struct clap_context *ctx) __nonnull_params((1));
8389
* If graphics was initialized, return viewport's position and size in the
8490
* non-NULL pointers, leave them unchanged otherwise.
8591
*/
92+
CLAP_API
8693
void clap_get_viewport(struct clap_context *ctx, int *px, int *py, int *pw, int *ph);
8794

8895
/**
@@ -92,6 +99,7 @@ void clap_get_viewport(struct clap_context *ctx, int *px, int *py, int *pw, int
9299
* If graphics was initialized, return the scene object.
93100
* Return: struct scene pointer or NULL if graphics is not used.
94101
*/
102+
CLAP_API
95103
struct scene *clap_get_scene(struct clap_context *ctx) __nonnull_params((1));
96104

97105
/**
@@ -102,6 +110,7 @@ struct scene *clap_get_scene(struct clap_context *ctx) __nonnull_params((1));
102110
* in the model rendering pipeline.
103111
* Return: struct render_options pointer (nonnull).
104112
*/
113+
CLAP_API
105114
render_options *clap_get_render_options(struct clap_context *ctx) __returns_nonnull __nonnull_params((1));
106115

107116
/**
@@ -115,6 +124,7 @@ render_options *clap_get_render_options(struct clap_context *ctx) __returns_nonn
115124
* On the other hand, if a rebuild may be required, skip this altogether and
116125
* let the clap_frame() take care of it automatically.
117126
*/
127+
CLAP_API
118128
void clap_sync_render_options(clap_context *ctx, bool may_rebuild) __nonnull_params((1));
119129

120130
/**
@@ -127,6 +137,7 @@ void clap_sync_render_options(clap_context *ctx, bool may_rebuild) __nonnull_par
127137
* in core/shader.c for details.
128138
* Return: struct shader_context pointer or NULL if graphics is not used.
129139
*/
140+
CLAP_API
130141
shader_context *clap_get_shaders(struct clap_context *ctx) __nonnull_params((1));
131142

132143
/**
@@ -136,6 +147,7 @@ shader_context *clap_get_shaders(struct clap_context *ctx) __nonnull_params((1))
136147
* If graphics was initialized, return the rendering pipeline.
137148
* Return: pipeline pointer or NULL if graphics is not used.
138149
*/
150+
CLAP_API
139151
pipeline *clap_get_pipeline(struct clap_context *ctx) __nonnull_params((1));
140152

141153
/**
@@ -146,6 +158,7 @@ pipeline *clap_get_pipeline(struct clap_context *ctx) __nonnull_params((1));
146158
* or UI were initialized.
147159
* Return: struct ui pointer (nonnull).
148160
*/
161+
CLAP_API
149162
struct ui *clap_get_ui(clap_context *ctx) __returns_nonnull __nonnull_params((1));
150163

151164
/**
@@ -155,6 +168,7 @@ struct ui *clap_get_ui(clap_context *ctx) __returns_nonnull __nonnull_params((1)
155168
* If font subsystem was initialized, return its handle object.
156169
* Return: struct font_context pointer or NULL if fonts are not used.
157170
*/
171+
CLAP_API
158172
font_context *clap_get_font(clap_context *ctx) __nonnull_params((1));
159173

160174
/**
@@ -164,6 +178,7 @@ font_context *clap_get_font(clap_context *ctx) __nonnull_params((1));
164178
* If sound subsystem was initialized, return its context handle.
165179
* Return: struct sound_context pointer or NULL if sound is not used.
166180
*/
181+
CLAP_API
167182
sound_context *clap_get_sound(struct clap_context *ctx) __nonnull_params((1));
168183

169184
/**
@@ -173,6 +188,7 @@ sound_context *clap_get_sound(struct clap_context *ctx) __nonnull_params((1));
173188
* If settings subsystem was initialized, return its context handle.
174189
* Return: struct settings pointer or NULL if settings are not used.
175190
*/
191+
CLAP_API
176192
struct settings *clap_get_settings(struct clap_context *ctx) __nonnull_params((1));
177193

178194
/**
@@ -187,6 +203,7 @@ struct settings *clap_get_settings(struct clap_context *ctx) __nonnull_params((1
187203
* undefined.
188204
* Return: current time in struct timespec.
189205
*/
206+
CLAP_API
190207
struct timespec clap_get_current_timespec(struct clap_context *ctx) __nonnull_params((1));
191208

192209
/**
@@ -199,6 +216,7 @@ struct timespec clap_get_current_timespec(struct clap_context *ctx) __nonnull_pa
199216
* undefined.
200217
* Return: current time as double.
201218
*/
219+
CLAP_API
202220
double clap_get_current_time(struct clap_context *ctx) __nonnull_params((1));
203221

204222
/**
@@ -210,6 +228,7 @@ double clap_get_current_time(struct clap_context *ctx) __nonnull_params((1));
210228
*
211229
* Return: true if paused, false otherwise
212230
*/
231+
CLAP_API
213232
bool clap_is_paused(clap_context *ctx);
214233

215234
typedef void (*clap_timer_fn)(void *data);
@@ -233,7 +252,8 @@ cresp_ret(clap_timer);
233252
* * CERR_NOMEM on allocation failure
234253
* * CERR_INVALID_ARGUMENTS if @dt is negative or @fn is NULL
235254
*/
236-
cresp(clap_timer) clap_timer_set(clap_context *ctx, double dt, clap_timer *timer,
255+
CLAP_API
256+
cresp(clap_timer) clap_timer_set(clap_context *ctx, double dt, clap_timer *timer,
237257
clap_timer_fn fn, void *data) __nonnull_params((1));
238258

239259
/**
@@ -244,6 +264,7 @@ cresp_ret(clap_timer);
244264
* Cancel a timer.
245265
* Context: inside the frame path.
246266
*/
267+
CLAP_API
247268
void clap_timer_cancel(clap_context *ctx, clap_timer *timer) __nonnull_params((1, 2));
248269

249270
/**
@@ -254,6 +275,7 @@ void clap_timer_cancel(clap_context *ctx, clap_timer *timer) __nonnull_params((1
254275
* Context: inside the frame path.
255276
* Return: time delta since the previous frame as timespec.
256277
*/
278+
CLAP_API
257279
struct timespec clap_get_fps_delta(struct clap_context *ctx) __nonnull_params((1));
258280

259281
/**
@@ -264,6 +286,7 @@ struct timespec clap_get_fps_delta(struct clap_context *ctx) __nonnull_params((1
264286
* Context: inside the frame path.
265287
* Return: FPS value as a number of frames.
266288
*/
289+
CLAP_API
267290
unsigned long clap_get_fps_fine(struct clap_context *ctx) __nonnull_params((1));
268291

269292
/**
@@ -275,6 +298,7 @@ unsigned long clap_get_fps_fine(struct clap_context *ctx) __nonnull_params((1));
275298
* Context: inside the frame path.
276299
* Return: FPS value as a number of frames.
277300
*/
301+
CLAP_API
278302
unsigned long clap_get_fps_coarse(struct clap_context *ctx) __nonnull_params((1));
279303

280304
/**
@@ -284,6 +308,7 @@ unsigned long clap_get_fps_coarse(struct clap_context *ctx) __nonnull_params((1)
284308
* Get the clap_context's internal LUT list head. TODO: phase out.
285309
* Return: LUT list head pointer.
286310
*/
311+
CLAP_API
287312
struct list *clap_lut_list(clap_context *ctx) __nonnull_params((1));
288313

289314
/**
@@ -295,6 +320,7 @@ struct list *clap_lut_list(clap_context *ctx) __nonnull_params((1));
295320
* * struct lut pointer on success
296321
* * CERR_NOT_FOUND on failure to find LUT
297322
*/
323+
CLAP_API
298324
cresp(lut) clap_lut_find(clap_context *ctx, const char *name) __nonnull_params((1, 2));
299325

300326
/**
@@ -307,6 +333,7 @@ cresp(lut) clap_lut_find(clap_context *ctx, const char *name) __nonnull_params((
307333
* * CERR_OK on success
308334
* * CERR_NOT_FOUND on failure to find LUT
309335
*/
336+
CLAP_API
310337
cerr clap_set_lighting_lut(clap_context *ctx, const char *name) __nonnull_params((1, 2));
311338

312339
enum clap_cli_opt_bits {
@@ -335,6 +362,7 @@ typedef enum clap_cli_opts {
335362
#endif /* !CONFIG_FINAL */
336363
} clap_cli_opts;
337364

365+
CLAP_API
338366
const char *clap_get_argv(clap_context *ctx, int idx);
339367

340368
/**
@@ -410,6 +438,7 @@ cresp_struct_ret(clap_context);
410438
* Initialize the engine with subsystems enabled in @cfg, see struct clap_config.
411439
* Return: clap_context pointer on success or a CERR code on error.
412440
*/
441+
CLAP_API
413442
cresp_check(clap_context) clap_init(struct clap_config *cfg, int argc, char **argv, char **envp);
414443

415444
/**
@@ -419,6 +448,7 @@ cresp_check(clap_context) clap_init(struct clap_config *cfg, int argc, char **ar
419448
*
420449
* Deinitialize subsystems enabled by clap_init().
421450
*/
451+
CLAP_API
422452
void clap_done(struct clap_context *ctx, int status) __nonnull_params((1));
423453

424454
/**
@@ -431,6 +461,7 @@ void clap_done(struct clap_context *ctx, int status) __nonnull_params((1));
431461
* * an integer exec*() syscall return code, if it fails
432462
* * on success, does not return
433463
*/
464+
CLAP_API
434465
cres(int) clap_restart(struct clap_context *ctx) __nonnull_params((1));
435466

436467
#endif /* __CLAP_CLAP_H__ */

0 commit comments

Comments
 (0)