consistency: use _proc everywhere instead of _function or _callback in procedure typedefs. Also remove unused oc_live_resize_callback

This commit is contained in:
Martin Fouilleul 2023-09-14 10:31:12 +02:00
parent 73717b5dd8
commit 0e680c989b
8 changed files with 79 additions and 100 deletions

View File

@ -316,9 +316,6 @@ ORCA_API void oc_set_cursor(oc_mouse_cursor cursor);
ORCA_API void oc_pump_events(f64 timeout);
ORCA_API oc_event* oc_next_event(oc_arena* arena);
typedef void (*oc_live_resize_callback)(oc_event event, void* data);
ORCA_API void oc_set_live_resize_callback(oc_live_resize_callback callback, void* data);
ORCA_API oc_key_code oc_scancode_to_keycode(oc_scan_code scanCode);
//--------------------------------------------------------------------

View File

@ -73,9 +73,6 @@ typedef struct oc_app
oc_window_data windowPool[OC_APP_MAX_WINDOWS];
oc_list windowFreeList;
oc_live_resize_callback liveResizeCallback;
void* liveResizeData;
oc_scan_code scanCodes[OC_SCANCODE_COUNT]; // native virtual key code to oc_scan_code
oc_key_code keyMap[OC_SCANCODE_COUNT]; // oc_scan_code to oc_key_code, as per current keyboard layout

View File

@ -687,11 +687,6 @@ void oc_install_keyboard_layout_listener()
event.move.content.w = contentRect.size.width;
event.move.content.h = contentRect.size.height;
if(oc_appData.liveResizeCallback)
{
oc_appData.liveResizeCallback(event, oc_appData.liveResizeData);
}
//TODO: also ensure we don't overflow the queue during live resize...
oc_queue_event(&event);
}
@ -1874,12 +1869,6 @@ void oc_surface_init_for_window(oc_surface_data* surface, oc_window_data* window
// Events handling
//--------------------------------------------------------------------
void oc_set_live_resize_callback(oc_live_resize_callback callback, void* data)
{
oc_appData.liveResizeCallback = callback;
oc_appData.liveResizeData = data;
}
void oc_pump_events(f64 timeout)
{
@autoreleasepool

View File

@ -134,8 +134,6 @@ ORCA_API void oc_surface_send_to_back(oc_surface surface); //DOC: puts surface
//------------------------------------------------------------------------------------------
#if !defined(OC_PLATFORM_ORCA) || !OC_PLATFORM_ORCA
typedef void (*oc_vsync_callback)(void* data);
ORCA_API void oc_vsync_init(void);
ORCA_API void oc_vsync_wait(oc_window window);

View File

@ -1,9 +1,9 @@
/*************************************************************************
*
/*************************************************************************
*
* Orca
* Copyright 2023 Martin Fouilleul and the Orca project contributors
* See LICENSE.txt for licensing information
*
*
**************************************************************************/
#ifndef __PLATFORM_MEMORY_H_
#define __PLATFORM_MEMORY_H_
@ -12,28 +12,27 @@
#include "util/typedefs.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
//--------------------------------------------------------------------------------
//NOTE(martin): base allocator
//--------------------------------------------------------------------------------
typedef struct oc_base_allocator oc_base_allocator;
//--------------------------------------------------------------------------------
//NOTE(martin): base allocator
//--------------------------------------------------------------------------------
typedef struct oc_base_allocator oc_base_allocator;
typedef void* (*oc_mem_reserve_function)(oc_base_allocator* context, u64 size);
typedef void (*oc_mem_modify_function)(oc_base_allocator* context, void* ptr, u64 size);
typedef void* (*oc_mem_reserve_proc)(oc_base_allocator* context, u64 size);
typedef void (*oc_mem_modify_proc)(oc_base_allocator* context, void* ptr, u64 size);
typedef struct oc_base_allocator
{
oc_mem_reserve_function reserve;
oc_mem_modify_function commit;
oc_mem_modify_function decommit;
oc_mem_modify_function release;
typedef struct oc_base_allocator
{
oc_mem_reserve_proc reserve;
oc_mem_modify_proc commit;
oc_mem_modify_proc decommit;
oc_mem_modify_proc release;
} oc_base_allocator;
} oc_base_allocator;
ORCA_API oc_base_allocator* oc_base_allocator_default();
ORCA_API oc_base_allocator* oc_base_allocator_default();
#define oc_base_reserve(base, size) base->reserve(base, size)
#define oc_base_commit(base, ptr, size) base->commit(base, ptr, size)
@ -48,9 +47,9 @@ extern "C"
#define oc_malloc_type(type) ((type*)malloc(sizeof(type)))
#define oc_malloc_array(type, count) ((type*)malloc(sizeof(type) * count))
//--------------------------------------------------------------------------------
//NOTE(martin): memset / memcpy
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//NOTE(martin): memset / memcpy
//--------------------------------------------------------------------------------
#include <string.h>

View File

@ -18,74 +18,73 @@
#endif
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif // __cplusplus
//---------------------------------------------------------------
// Platform Thread API
//---------------------------------------------------------------
//---------------------------------------------------------------
// Platform Thread API
//---------------------------------------------------------------
enum
{
OC_THREAD_NAME_MAX_SIZE = 64, // including null terminator
};
enum
{
OC_THREAD_NAME_MAX_SIZE = 64, // including null terminator
};
typedef struct oc_thread oc_thread;
typedef struct oc_thread oc_thread;
typedef i32 (*oc_thread_start_function)(void* userPointer);
typedef i32 (*oc_thread_start_proc)(void* userPointer);
ORCA_API oc_thread* oc_thread_create(oc_thread_start_function start, void* userPointer);
ORCA_API oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* userPointer, oc_str8 name);
ORCA_API oc_str8 oc_thread_get_name(oc_thread* thread);
ORCA_API u64 oc_thread_unique_id(oc_thread* thread);
ORCA_API u64 oc_thread_self_id();
ORCA_API int oc_thread_signal(oc_thread* thread, int sig);
ORCA_API int oc_thread_join(oc_thread* thread, i64* exitCode);
ORCA_API int oc_thread_detach(oc_thread* thread);
ORCA_API oc_thread* oc_thread_create(oc_thread_start_proc start, void* userPointer);
ORCA_API oc_thread* oc_thread_create_with_name(oc_thread_start_proc start, void* userPointer, oc_str8 name);
ORCA_API oc_str8 oc_thread_get_name(oc_thread* thread);
ORCA_API u64 oc_thread_unique_id(oc_thread* thread);
ORCA_API u64 oc_thread_self_id();
ORCA_API int oc_thread_signal(oc_thread* thread, int sig);
ORCA_API int oc_thread_join(oc_thread* thread, i64* exitCode);
ORCA_API int oc_thread_detach(oc_thread* thread);
//---------------------------------------------------------------
// Platform Mutex API
//---------------------------------------------------------------
//---------------------------------------------------------------
// Platform Mutex API
//---------------------------------------------------------------
typedef struct oc_mutex oc_mutex;
typedef struct oc_mutex oc_mutex;
ORCA_API oc_mutex* oc_mutex_create();
ORCA_API int oc_mutex_destroy(oc_mutex* mutex);
ORCA_API int oc_mutex_lock(oc_mutex* mutex);
ORCA_API int oc_mutex_unlock(oc_mutex* mutex);
ORCA_API oc_mutex* oc_mutex_create();
ORCA_API int oc_mutex_destroy(oc_mutex* mutex);
ORCA_API int oc_mutex_lock(oc_mutex* mutex);
ORCA_API int oc_mutex_unlock(oc_mutex* mutex);
//---------------------------------------------------------------
// Lightweight ticket mutex API
//---------------------------------------------------------------
//---------------------------------------------------------------
// Lightweight ticket mutex API
//---------------------------------------------------------------
typedef struct oc_ticket
{
volatile _Atomic(u64) nextTicket;
volatile _Atomic(u64) serving;
} oc_ticket;
typedef struct oc_ticket
{
volatile _Atomic(u64) nextTicket;
volatile _Atomic(u64) serving;
} oc_ticket;
ORCA_API void oc_ticket_init(oc_ticket* mutex);
ORCA_API void oc_ticket_lock(oc_ticket* mutex);
ORCA_API void oc_ticket_unlock(oc_ticket* mutex);
ORCA_API void oc_ticket_init(oc_ticket* mutex);
ORCA_API void oc_ticket_lock(oc_ticket* mutex);
ORCA_API void oc_ticket_unlock(oc_ticket* mutex);
//---------------------------------------------------------------
// Platform condition variable API
//---------------------------------------------------------------
//---------------------------------------------------------------
// Platform condition variable API
//---------------------------------------------------------------
typedef struct oc_condition oc_condition;
typedef struct oc_condition oc_condition;
ORCA_API oc_condition* oc_condition_create();
ORCA_API int oc_condition_destroy(oc_condition* cond);
ORCA_API int oc_condition_wait(oc_condition* cond, oc_mutex* mutex);
ORCA_API int oc_condition_timedwait(oc_condition* cond, oc_mutex* mutex, f64 seconds);
ORCA_API int oc_condition_signal(oc_condition* cond);
ORCA_API int oc_condition_broadcast(oc_condition* cond);
ORCA_API oc_condition* oc_condition_create();
ORCA_API int oc_condition_destroy(oc_condition* cond);
ORCA_API int oc_condition_wait(oc_condition* cond, oc_mutex* mutex);
ORCA_API int oc_condition_timedwait(oc_condition* cond, oc_mutex* mutex, f64 seconds);
ORCA_API int oc_condition_signal(oc_condition* cond);
ORCA_API int oc_condition_broadcast(oc_condition* cond);
//---------------------------------------------------------------
// Putting threads to sleep
//---------------------------------------------------------------
ORCA_API void oc_sleep_nano(u64 nanoseconds); // sleep for a given number of nanoseconds
//---------------------------------------------------------------
// Putting threads to sleep
//---------------------------------------------------------------
ORCA_API void oc_sleep_nano(u64 nanoseconds); // sleep for a given number of nanoseconds
#ifdef __cplusplus
} // extern "C"

View File

@ -18,7 +18,7 @@ struct oc_thread
{
bool valid;
pthread_t pthread;
oc_thread_start_function start;
oc_thread_start_proc start;
void* userPointer;
oc_str8 name;
char nameBuffer[OC_THREAD_NAME_MAX_SIZE];
@ -35,7 +35,7 @@ static void* oc_thread_bootstrap(void* data)
return ((void*)(ptrdiff_t)exitCode);
}
oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* userPointer, oc_str8 name)
oc_thread* oc_thread_create_with_name(oc_thread_start_proc start, void* userPointer, oc_str8 name)
{
oc_thread* thread = (oc_thread*)malloc(sizeof(oc_thread));
if(!thread)
@ -69,7 +69,7 @@ oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* user
}
}
oc_thread* oc_thread_create(oc_thread_start_function start, void* userPointer)
oc_thread* oc_thread_create(oc_thread_start_proc start, void* userPointer)
{
return (oc_thread_create_with_name(start, userPointer, (oc_str8){ 0 }));
}

View File

@ -5,7 +5,7 @@
* See LICENSE.txt for licensing information
*
**************************************************************************/
#include <math.h> //INFINITY
#include <math.h> //INFINITY
#include <processthreadsapi.h>
#include <synchapi.h>
#include <winuser.h> // PostMessage
@ -14,7 +14,7 @@
struct oc_thread
{
oc_thread_start_function start;
oc_thread_start_proc start;
HANDLE handle;
DWORD threadId;
void* userPointer;
@ -29,7 +29,7 @@ static DWORD WINAPI oc_thread_bootstrap(LPVOID lpParameter)
return (exitCode);
}
oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* userPointer, oc_str8 name)
oc_thread* oc_thread_create_with_name(oc_thread_start_proc start, void* userPointer, oc_str8 name)
{
oc_thread* thread = (oc_thread*)malloc(sizeof(oc_thread));
thread->start = start;
@ -75,7 +75,7 @@ oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* user
return (thread);
}
oc_thread* oc_thread_create(oc_thread_start_function start, void* userPointer)
oc_thread* oc_thread_create(oc_thread_start_proc start, void* userPointer)
{
return (oc_thread_create_with_name(start, userPointer, (oc_str8){ 0 }));
}