WAFFLE_API is used to define the symbol visibility and all functions provided by the API must be non-hidden. Thus the define should be used internally in conjunction with the compiler used in order to properly annotate the symbols.
Resolves #12: https://github.com/waffle-gl/waffle/issues/12 Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> --- include/waffle/waffle.h | 74 +++++++++++++++---------------------- src/waffle/api/api_priv.h | 14 +++++++ src/waffle/api/waffle_attrib_list.c | 10 +++-- src/waffle/api/waffle_config.c | 6 +-- src/waffle/api/waffle_context.c | 6 +-- src/waffle/api/waffle_display.c | 8 ++-- src/waffle/api/waffle_dl.c | 4 +- src/waffle/api/waffle_enum.c | 4 +- src/waffle/api/waffle_error.c | 8 ++-- src/waffle/api/waffle_gl_misc.c | 6 +-- src/waffle/api/waffle_init.c | 2 +- src/waffle/api/waffle_window.c | 12 +++--- 12 files changed, 80 insertions(+), 74 deletions(-) diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h index b5477f5..d43ddcf 100644 --- a/include/waffle/waffle.h +++ b/include/waffle/waffle.h @@ -36,20 +36,6 @@ extern "C" { #endif -// WAFFLE_API - Declare that a symbol is in Waffle's public API. -// -// See "GCC Wiki - Visibility". (http://gcc.gnu.org/wiki/Visibility). -// See "How to Write Shared Libraries. Ulrich Drepper. -// (http://www.akkadia.org/drepper/dsohowto.pdf). -// -// TODO: Implement WAFFLE_API for Apple. -// -#if defined(__GNUC__) && __GNUC__ >= 4 -# define WAFFLE_API __attribute__ ((visibility("default"))) -#else -# define WAFFLE_API -#endif - #if __STDC_VERSION__ < 199901L # define restrict #endif @@ -89,13 +75,13 @@ struct waffle_error_info { size_t message_length; }; -WAFFLE_API enum waffle_error +enum waffle_error waffle_error_get_code(void); -WAFFLE_API const struct waffle_error_info* +const struct waffle_error_info* waffle_error_get_info(void); -WAFFLE_API const char* +const char* waffle_error_to_string(enum waffle_error e); // --------------------------------------------------------------------------- @@ -169,23 +155,23 @@ enum waffle_enum { WAFFLE_DL_OPENGL_ES3 = 0x0304, }; -WAFFLE_API const char* +const char* waffle_enum_to_string(int32_t e); // --------------------------------------------------------------------------- -WAFFLE_API bool +bool waffle_init(const int32_t *attrib_list); -WAFFLE_API bool +bool waffle_make_current(struct waffle_display *dpy, struct waffle_window *window, struct waffle_context *ctx); -WAFFLE_API void* +void* waffle_get_proc_address(const char *name); -WAFFLE_API bool +bool waffle_is_extension_in_string(const char *restrict extension_string, const char *restrict extension_name); @@ -193,71 +179,71 @@ waffle_is_extension_in_string(const char *restrict extension_string, // waffle_display // --------------------------------------------------------------------------- -WAFFLE_API struct waffle_display* +struct waffle_display* waffle_display_connect(const char *name); -WAFFLE_API bool +bool waffle_display_disconnect(struct waffle_display *self); -WAFFLE_API bool +bool waffle_display_supports_context_api(struct waffle_display *self, int32_t context_api); -WAFFLE_API union waffle_native_display* +union waffle_native_display* waffle_display_get_native(struct waffle_display *self); // --------------------------------------------------------------------------- // waffle_config // --------------------------------------------------------------------------- -WAFFLE_API struct waffle_config* +struct waffle_config* waffle_config_choose(struct waffle_display *dpy, const int32_t attrib_list[]); -WAFFLE_API bool +bool waffle_config_destroy(struct waffle_config *self); -WAFFLE_API union waffle_native_config* +union waffle_native_config* waffle_config_get_native(struct waffle_config *self); // --------------------------------------------------------------------------- // waffle_context // --------------------------------------------------------------------------- -WAFFLE_API struct waffle_context* +struct waffle_context* waffle_context_create(struct waffle_config *config, struct waffle_context *shared_ctx); -WAFFLE_API bool +bool waffle_context_destroy(struct waffle_context *self); -WAFFLE_API union waffle_native_context* +union waffle_native_context* waffle_context_get_native(struct waffle_context *self); // --------------------------------------------------------------------------- // waffle_window // --------------------------------------------------------------------------- -WAFFLE_API struct waffle_window* +struct waffle_window* waffle_window_create( struct waffle_config *config, int32_t width, int32_t height); -WAFFLE_API bool +bool waffle_window_destroy(struct waffle_window *self); -WAFFLE_API bool +bool waffle_window_show(struct waffle_window *self); -WAFFLE_API bool +bool waffle_window_swap_buffers(struct waffle_window *self); -WAFFLE_API union waffle_native_window* +union waffle_native_window* waffle_window_get_native(struct waffle_window *self); #if defined(WAFFLE_API_EXPERIMENTAL) && WAFFLE_API_VERSION >= 0x0103 -WAFFLE_API bool +bool waffle_window_resize( struct waffle_window *self, int32_t width, @@ -268,10 +254,10 @@ waffle_window_resize( // waffle_dl // --------------------------------------------------------------------------- -WAFFLE_API bool +bool waffle_dl_can_open(int32_t dl); -WAFFLE_API void* +void* waffle_dl_sym(int32_t dl, const char *name); // --------------------------------------------------------------------------- @@ -327,23 +313,23 @@ union waffle_native_window { // waffle_attrib_list // --------------------------------------------------------------------------- -WAFFLE_API int32_t +int32_t waffle_attrib_list_length(const int32_t attrib_list[]); -WAFFLE_API bool +bool waffle_attrib_list_get( const int32_t attrib_list[], int32_t key, int32_t *value); -WAFFLE_API bool +bool waffle_attrib_list_get_with_default( const int32_t attrib_list[], int32_t key, int32_t *value, int32_t default_value); -WAFFLE_API bool +bool waffle_attrib_list_update( int32_t *attrib_list, int32_t key, diff --git a/src/waffle/api/api_priv.h b/src/waffle/api/api_priv.h index b8f177b..0bbeada 100644 --- a/src/waffle/api/api_priv.h +++ b/src/waffle/api/api_priv.h @@ -30,6 +30,20 @@ #include "waffle.h" +// WAFFLE_API - Declare that a symbol is in Waffle's public API. +// +// See "GCC Wiki - Visibility". (http://gcc.gnu.org/wiki/Visibility). +// See "How to Write Shared Libraries. Ulrich Drepper. +// (http://www.akkadia.org/drepper/dsohowto.pdf). +// +// TODO: Implement WAFFLE_API for Apple. +// +#if defined(__GNUC__) && __GNUC__ >= 4 +# define WAFFLE_API __attribute__ ((visibility("default"))) +#else +# define WAFFLE_API +#endif + struct api_object; struct wcore_platform; diff --git a/src/waffle/api/waffle_attrib_list.c b/src/waffle/api/waffle_attrib_list.c index d8d2f4b..94327bb 100644 --- a/src/waffle/api/waffle_attrib_list.c +++ b/src/waffle/api/waffle_attrib_list.c @@ -23,10 +23,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "api_priv.h" + #include "wcore_attrib_list.h" #include "wcore_error.h" -int32_t +WAFFLE_API int32_t waffle_attrib_list_length(const int32_t attrib_list[]) { @@ -34,7 +36,7 @@ waffle_attrib_list_length(const int32_t attrib_list[]) return wcore_attrib_list_length(attrib_list); } -bool +WAFFLE_API bool waffle_attrib_list_get( const int32_t *attrib_list, int32_t key, @@ -44,7 +46,7 @@ waffle_attrib_list_get( return wcore_attrib_list_get(attrib_list, key, value); } -bool +WAFFLE_API bool waffle_attrib_list_get_with_default( const int32_t attrib_list[], int32_t key, @@ -56,7 +58,7 @@ waffle_attrib_list_get_with_default( default_value); } -bool +WAFFLE_API bool waffle_attrib_list_update( int32_t *attrib_list, int32_t key, diff --git a/src/waffle/api/waffle_config.c b/src/waffle/api/waffle_config.c index a2ef941..107f07d 100644 --- a/src/waffle/api/waffle_config.c +++ b/src/waffle/api/waffle_config.c @@ -31,7 +31,7 @@ #include "wcore_error.h" #include "wcore_platform.h" -struct waffle_config* +WAFFLE_API struct waffle_config* waffle_config_choose( struct waffle_display *dpy, const int32_t attrib_list[]) @@ -59,7 +59,7 @@ waffle_config_choose( return &wc_self->wfl; } -bool +WAFFLE_API bool waffle_config_destroy(struct waffle_config *self) { struct wcore_config *wc_self = wcore_config(self); @@ -74,7 +74,7 @@ waffle_config_destroy(struct waffle_config *self) return api_platform->vtbl->config.destroy(wc_self); } -union waffle_native_config* +WAFFLE_API union waffle_native_config* waffle_config_get_native(struct waffle_config *self) { struct wcore_config *wc_self = wcore_config(self); diff --git a/src/waffle/api/waffle_context.c b/src/waffle/api/waffle_context.c index 026c484..b246a63 100644 --- a/src/waffle/api/waffle_context.c +++ b/src/waffle/api/waffle_context.c @@ -29,7 +29,7 @@ #include "wcore_error.h" #include "wcore_platform.h" -struct waffle_context* +WAFFLE_API struct waffle_context* waffle_context_create( struct waffle_config *config, struct waffle_context *shared_ctx) @@ -57,7 +57,7 @@ waffle_context_create( return &wc_self->wfl; } -bool +WAFFLE_API bool waffle_context_destroy(struct waffle_context *self) { struct wcore_context *wc_self = wcore_context(self); @@ -72,7 +72,7 @@ waffle_context_destroy(struct waffle_context *self) return api_platform->vtbl->context.destroy(wc_self); } -union waffle_native_context* +WAFFLE_API union waffle_native_context* waffle_context_get_native(struct waffle_context *self) { struct wcore_context *wc_self = wcore_context(self); diff --git a/src/waffle/api/waffle_display.c b/src/waffle/api/waffle_display.c index fb24e44..9d741e9 100644 --- a/src/waffle/api/waffle_display.c +++ b/src/waffle/api/waffle_display.c @@ -30,7 +30,7 @@ #include "wcore_platform.h" #include "wcore_util.h" -struct waffle_display* +WAFFLE_API struct waffle_display* waffle_display_connect(const char *name) { struct wcore_display *wc_self; @@ -45,7 +45,7 @@ waffle_display_connect(const char *name) return &wc_self->wfl; } -bool +WAFFLE_API bool waffle_display_disconnect(struct waffle_display *self) { struct wcore_display *wc_self = wcore_display(self); @@ -60,7 +60,7 @@ waffle_display_disconnect(struct waffle_display *self) return api_platform->vtbl->display.destroy(wc_self); } -bool +WAFFLE_API bool waffle_display_supports_context_api( struct waffle_display *self, int32_t context_api) @@ -90,7 +90,7 @@ waffle_display_supports_context_api( context_api); } -union waffle_native_display* +WAFFLE_API union waffle_native_display* waffle_display_get_native(struct waffle_display *self) { struct wcore_display *wc_self = wcore_display(self); diff --git a/src/waffle/api/waffle_dl.c b/src/waffle/api/waffle_dl.c index 7465cfa..b94c4c7 100644 --- a/src/waffle/api/waffle_dl.c +++ b/src/waffle/api/waffle_dl.c @@ -43,7 +43,7 @@ waffle_dl_check_enum(int32_t dl) } } -bool +WAFFLE_API bool waffle_dl_can_open(int32_t dl) { if (!api_check_entry(NULL, 0)) @@ -55,7 +55,7 @@ waffle_dl_can_open(int32_t dl) return api_platform->vtbl->dl_can_open(api_platform, dl); } -void* +WAFFLE_API void* waffle_dl_sym(int32_t dl, const char *name) { if (!api_check_entry(NULL, 0)) diff --git a/src/waffle/api/waffle_enum.c b/src/waffle/api/waffle_enum.c index dd0c84e..1b8dfbb 100644 --- a/src/waffle/api/waffle_enum.c +++ b/src/waffle/api/waffle_enum.c @@ -23,10 +23,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "api_priv.h" + #include "wcore_error.h" #include "wcore_util.h" -const char* +WAFFLE_API const char* waffle_enum_to_string(int32_t e) { wcore_error_reset(); diff --git a/src/waffle/api/waffle_error.c b/src/waffle/api/waffle_error.c index be265f3..f6ec45c 100644 --- a/src/waffle/api/waffle_error.c +++ b/src/waffle/api/waffle_error.c @@ -25,21 +25,23 @@ #include <string.h> +#include "api_priv.h" + #include "wcore_error.h" -enum waffle_error +WAFFLE_API enum waffle_error waffle_error_get_code(void) { return wcore_error_get_code(); } -const struct waffle_error_info* +WAFFLE_API const struct waffle_error_info* waffle_error_get_info(void) { return wcore_error_get_info(); } -const char* +WAFFLE_API const char* waffle_error_to_string(enum waffle_error e) { switch (e) { diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c index eabe3ee..f94b34b 100644 --- a/src/waffle/api/waffle_gl_misc.c +++ b/src/waffle/api/waffle_gl_misc.c @@ -34,7 +34,7 @@ #include "wcore_platform.h" #include "wcore_window.h" -bool +WAFFLE_API bool waffle_is_extension_in_string( const char *restrict extension_string, const char *restrict extension_name) @@ -71,7 +71,7 @@ waffle_is_extension_in_string( } } -bool +WAFFLE_API bool waffle_make_current( struct waffle_display *dpy, struct waffle_window *window, @@ -99,7 +99,7 @@ waffle_make_current( wc_ctx); } -void* +WAFFLE_API void* waffle_get_proc_address(const char *name) { if (!api_check_entry(NULL, 0)) diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c index b58fe9a..b45c3ba 100644 --- a/src/waffle/api/waffle_init.c +++ b/src/waffle/api/waffle_init.c @@ -159,7 +159,7 @@ waffle_init_create_platform(int32_t waffle_platform) } } -bool +WAFFLE_API bool waffle_init(const int32_t *attrib_list) { bool ok = true; diff --git a/src/waffle/api/waffle_window.c b/src/waffle/api/waffle_window.c index 7e5e1ea..1dbf823 100644 --- a/src/waffle/api/waffle_window.c +++ b/src/waffle/api/waffle_window.c @@ -32,7 +32,7 @@ #include "wcore_platform.h" #include "wcore_window.h" -struct waffle_window* +WAFFLE_API struct waffle_window* waffle_window_create( struct waffle_config *config, int width, int height) @@ -57,7 +57,7 @@ waffle_window_create( return &wc_self->wfl; } -bool +WAFFLE_API bool waffle_window_destroy(struct waffle_window *self) { struct wcore_window *wc_self = wcore_window(self); @@ -72,7 +72,7 @@ waffle_window_destroy(struct waffle_window *self) return api_platform->vtbl->window.destroy(wc_self); } -bool +WAFFLE_API bool waffle_window_show(struct waffle_window *self) { struct wcore_window *wc_self = wcore_window(self); @@ -87,7 +87,7 @@ waffle_window_show(struct waffle_window *self) return api_platform->vtbl->window.show(wc_self); } -bool +WAFFLE_API bool waffle_window_resize( struct waffle_window *self, int32_t width, @@ -111,7 +111,7 @@ waffle_window_resize( } } -bool +WAFFLE_API bool waffle_window_swap_buffers(struct waffle_window *self) { struct wcore_window *wc_self = wcore_window(self); @@ -126,7 +126,7 @@ waffle_window_swap_buffers(struct waffle_window *self) return api_platform->vtbl->window.swap_buffers(wc_self); } -union waffle_native_window* +WAFFLE_API union waffle_native_window* waffle_window_get_native(struct waffle_window *self) { struct wcore_window *wc_self = wcore_window(self); -- 1.9.3 _______________________________________________ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle