// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program 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 General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================

#include <fennec/lang/types.h>

#ifndef FENNEC_LIB
#define FENNEC_LIB(...)
#endif

#ifndef FENNEC_SYMBOL
#define FENNEC_SYMBOL(...)
#endif

#ifndef FENNEC_GLOBAL
#define FENNEC_GLOBAL(...)
#endif


FENNEC_LIB(WAYLAND);

FENNEC_SYMBOL(void,                   wl_proxy_marshal,                       struct wl_proxy*, uint32_t, ...);
FENNEC_SYMBOL(struct wl_proxy*,       wl_proxy_marshal_flags,                 struct wl_proxy*, uint32_t, const struct wl_interface*, uint32_t, uint32_t, ...);
FENNEC_SYMBOL(struct wl_proxy*,       wl_proxy_create,                        struct wl_proxy*, const struct wl_interface*);
FENNEC_SYMBOL(void,                   wl_proxy_destroy,                       struct wl_proxy*);
FENNEC_SYMBOL(int,                    wl_proxy_add_listener,                  struct wl_proxy*, void (**)(void), void*);
FENNEC_SYMBOL(void,                   wl_proxy_set_user_data,                 struct wl_proxy*, void*);
FENNEC_SYMBOL(void*,                  wl_proxy_get_user_data,                 struct wl_proxy*);
FENNEC_SYMBOL(uint32_t,               wl_proxy_get_version,                   struct wl_proxy*);
FENNEC_SYMBOL(uint32_t,               wl_proxy_get_id,                        struct wl_proxy*);
FENNEC_SYMBOL(const char*,            wl_proxy_get_class,                     struct wl_proxy*);
FENNEC_SYMBOL(void,                   wl_proxy_set_queue,                     struct wl_proxy*, struct wl_event_queue*);
FENNEC_SYMBOL(void*,                  wl_proxy_create_wrapper,                void*);
FENNEC_SYMBOL(void,                   wl_proxy_wrapper_destroy,               void*);
FENNEC_SYMBOL(struct wl_proxy*,       wl_proxy_marshal_constructor,           struct wl_proxy*, uint32_t, const struct wl_interface*, ...);
FENNEC_SYMBOL(struct wl_proxy*,       wl_proxy_marshal_constructor_versioned, struct wl_proxy*, uint32_t, const struct wl_interface*, uint32_t, ...);
FENNEC_SYMBOL(void,                   wl_proxy_set_tag,                       struct wl_proxy*, const char* const*);
FENNEC_SYMBOL(const char* const*,     wl_proxy_get_tag,                       struct wl_proxy*);

FENNEC_SYMBOL(struct wl_display*,     wl_display_connect,                     const char*);
FENNEC_SYMBOL(struct wl_display*,     wl_display_connect_to_fd,               int);
FENNEC_SYMBOL(void,                   wl_display_disconnect,                  struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_get_fd,                      struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_dispatch,                    struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_dispatch_queue,              struct wl_display*, struct wl_event_queue*);
FENNEC_SYMBOL(int,                    wl_display_dispatch_queue_pending,      struct wl_display*, struct wl_event_queue*);
FENNEC_SYMBOL(int,                    wl_display_dispatch_pending,            struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_prepare_read,                struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_prepare_read_queue,          struct wl_display*, struct wl_event_queue*);
FENNEC_SYMBOL(int,                    wl_display_read_events,                 struct wl_display*);
FENNEC_SYMBOL(void,                   wl_display_cancel_read,                 struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_get_error,                   struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_flush,                       struct wl_display*);
FENNEC_SYMBOL(int,                    wl_display_roundtrip,                   struct wl_display*);
FENNEC_SYMBOL(struct wl_event_queue*, wl_display_create_queue,                struct wl_display*);

FENNEC_SYMBOL(void,                   wl_event_queue_destroy,                 struct wl_event_queue*);
FENNEC_SYMBOL(void,                   wl_log_set_handler_client,              wl_log_func_t);
FENNEC_SYMBOL(void,                   wl_list_init,                           struct wl_list*);
FENNEC_SYMBOL(void,                   wl_list_insert,                         struct wl_list*, struct wl_list*) ;
FENNEC_SYMBOL(void,                   wl_list_remove,                         struct wl_list*);
FENNEC_SYMBOL(int,                    wl_list_length,                         const struct wl_list*);
FENNEC_SYMBOL(int,                    wl_list_empty,                          const struct wl_list*);
FENNEC_SYMBOL(void,                   wl_list_insert_list,                    struct wl_list*, struct wl_list*);

FENNEC_GLOBAL(const struct wl_interface, wl_display_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_registry_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_callback_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_compositor_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_shm_pool_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_shm_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_buffer_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_data_offer_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_data_source_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_data_device_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_data_device_manager_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_shell_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_shell_surface_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_surface_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_seat_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_pointer_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_keyboard_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_touch_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_output_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_region_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_subcompositor_interface);
FENNEC_GLOBAL(const struct wl_interface, wl_subsurface_interface);

FENNEC_LIB(WAYLAND_EGL);

FENNEC_SYMBOL(struct wl_egl_window*, wl_egl_window_create,            struct wl_surface *surface, int width, int height);
FENNEC_SYMBOL(void,                  wl_egl_window_destroy,           struct wl_egl_window *egl_window);
FENNEC_SYMBOL(void,                  wl_egl_window_resize,            struct wl_egl_window *egl_window, int width, int height, int dx, int dy);
FENNEC_SYMBOL(void,                  wl_egl_window_get_attached_size, struct wl_egl_window *egl_window, int *width, int *height);

#undef FENNEC_LIB
#undef FENNEC_SYMBOL
#undef FENNEC_GLOBAL


