Added empty implementations of all the system api functions to mac_4ed_functions.cpp

master
Yuval Dolev 2019-12-24 22:31:24 +02:00
parent 54f5e72aa5
commit e3e5f857ea
9 changed files with 518 additions and 109 deletions

View File

@ -94,7 +94,7 @@ char *includes[] = { "custom", FOREIGN "/freetype2", 0, };
char *windows_platform_layer[] = { "platform_win32/win32_4ed.cpp", 0 };
char *linux_platform_layer[] = { "platform_linux/linux_4ed.cpp", 0 };
char *mac_platform_layer[] = { "platform_mac/mac_4ed.mm", 0 };
char *mac_platform_layer[] = { "platform_mac/mac_4ed.mm", "platform_mac/mac_4ed.cpp", 0 };
char **platform_layers[Platform_COUNT] = {
windows_platform_layer,

View File

@ -93,53 +93,53 @@ typedef b32 system_set_fullscreen_type(b32 full_screen);
typedef b32 system_is_fullscreen_type(void);
typedef Input_Modifier_Set system_get_keyboard_modifiers_type(Arena* arena);
struct API_VTable_system{
system_get_path_type *get_path;
system_get_canonical_type *get_canonical;
system_get_file_list_type *get_file_list;
system_quick_file_attributes_type *quick_file_attributes;
system_load_handle_type *load_handle;
system_load_attributes_type *load_attributes;
system_load_file_type *load_file;
system_load_close_type *load_close;
system_save_file_type *save_file;
system_load_library_type *load_library;
system_release_library_type *release_library;
system_get_proc_type *get_proc;
system_now_time_type *now_time;
system_wake_up_timer_create_type *wake_up_timer_create;
system_wake_up_timer_release_type *wake_up_timer_release;
system_wake_up_timer_set_type *wake_up_timer_set;
system_signal_step_type *signal_step;
system_sleep_type *sleep;
system_post_clipboard_type *post_clipboard;
system_cli_call_type *cli_call;
system_cli_begin_update_type *cli_begin_update;
system_cli_update_step_type *cli_update_step;
system_cli_end_update_type *cli_end_update;
system_open_color_picker_type *open_color_picker;
system_get_screen_scale_factor_type *get_screen_scale_factor;
system_thread_launch_type *thread_launch;
system_thread_join_type *thread_join;
system_thread_free_type *thread_free;
system_thread_get_id_type *thread_get_id;
system_acquire_global_frame_mutex_type *acquire_global_frame_mutex;
system_release_global_frame_mutex_type *release_global_frame_mutex;
system_mutex_make_type *mutex_make;
system_mutex_acquire_type *mutex_acquire;
system_mutex_release_type *mutex_release;
system_mutex_free_type *mutex_free;
system_condition_variable_make_type *condition_variable_make;
system_condition_variable_wait_type *condition_variable_wait;
system_condition_variable_signal_type *condition_variable_signal;
system_condition_variable_free_type *condition_variable_free;
system_memory_allocate_type *memory_allocate;
system_memory_set_protection_type *memory_set_protection;
system_memory_free_type *memory_free;
system_memory_annotation_type *memory_annotation;
system_show_mouse_cursor_type *show_mouse_cursor;
system_set_fullscreen_type *set_fullscreen;
system_is_fullscreen_type *is_fullscreen;
system_get_keyboard_modifiers_type *get_keyboard_modifiers;
system_get_path_type *get_path;
system_get_canonical_type *get_canonical;
system_get_file_list_type *get_file_list;
system_quick_file_attributes_type *quick_file_attributes;
system_load_handle_type *load_handle;
system_load_attributes_type *load_attributes;
system_load_file_type *load_file;
system_load_close_type *load_close;
system_save_file_type *save_file;
system_load_library_type *load_library;
system_release_library_type *release_library;
system_get_proc_type *get_proc;
system_now_time_type *now_time;
system_wake_up_timer_create_type *wake_up_timer_create;
system_wake_up_timer_release_type *wake_up_timer_release;
system_wake_up_timer_set_type *wake_up_timer_set;
system_signal_step_type *signal_step;
system_sleep_type *sleep;
system_post_clipboard_type *post_clipboard;
system_cli_call_type *cli_call;
system_cli_begin_update_type *cli_begin_update;
system_cli_update_step_type *cli_update_step;
system_cli_end_update_type *cli_end_update;
system_open_color_picker_type *open_color_picker;
system_get_screen_scale_factor_type *get_screen_scale_factor;
system_thread_launch_type *thread_launch;
system_thread_join_type *thread_join;
system_thread_free_type *thread_free;
system_thread_get_id_type *thread_get_id;
system_acquire_global_frame_mutex_type *acquire_global_frame_mutex;
system_release_global_frame_mutex_type *release_global_frame_mutex;
system_mutex_make_type *mutex_make;
system_mutex_acquire_type *mutex_acquire;
system_mutex_release_type *mutex_release;
system_mutex_free_type *mutex_free;
system_condition_variable_make_type *condition_variable_make;
system_condition_variable_wait_type *condition_variable_wait;
system_condition_variable_signal_type *condition_variable_signal;
system_condition_variable_free_type *condition_variable_free;
system_memory_allocate_type *memory_allocate;
system_memory_set_protection_type *memory_set_protection;
system_memory_free_type *memory_free;
system_memory_annotation_type *memory_annotation;
system_show_mouse_cursor_type *show_mouse_cursor;
system_set_fullscreen_type *set_fullscreen;
system_is_fullscreen_type *is_fullscreen;
system_get_keyboard_modifiers_type *get_keyboard_modifiers;
};
#if defined(STATIC_LINK_API)
internal String_Const_u8 system_get_path(Arena* arena, System_Path_Code path_code);

View File

@ -1 +1,93 @@
/* Mac C++ layer for 4coder */
/* Mac C++ layer for 4coder */
#include "4coder_base_types.h"
#include "4coder_version.h"
#include "4coder_events.h"
#include "4coder_table.h"
#include "4coder_types.h"
#include "4coder_default_colors.h"
#include "4coder_system_types.h"
#define STATIC_LINK_API
#include "generated/system_api.h"
#include "4ed_font_interface.h"
#define STATIC_LINK_API
#include "generated/graphics_api.h"
#define STATIC_LINK_API
#include "generated/font_api.h"
#include "4ed_font_set.h"
#include "4ed_render_target.h"
#include "4ed_search_list.h"
#include "4ed.h"
#include "generated/system_api.cpp"
#include "generated/graphics_api.cpp"
#include "generated/font_api.cpp"
#include "4coder_base_types.cpp"
#include "4coder_stringf.cpp"
#include "4coder_events.cpp"
#include "4coder_hash_functions.cpp"
#include "4coder_table.cpp"
#include "4coder_log.cpp"
#include "4ed_search_list.cpp"
////////////////////////////////
#define SLASH '\\'
#define DLL "dll"
#include "4coder_hash_functions.cpp"
#include "4coder_system_allocator.cpp"
#include "4coder_codepoint_map.cpp"
#include "4ed_mem.cpp"
#include "4ed_font_set.cpp"
////////////////////////////////
struct Mac_Vars {
Thread_Context *tctx;
Arena* frame_arena;
};
////////////////////////////////
Mac_Vars global_mac_vars;
global Render_Target global_target;
////////////////////////////////
#include "mac_4ed_functions.cpp"
////////////////////////////////
external void
mac_init() {
// NOTE(yuval): Context Setup
Thread_Context _tctx = {};
thread_ctx_init(&_tctx, ThreadKind_Main,
get_base_allocator_system(),
get_base_allocator_system());
block_zero_struct(&global_mac_vars);
global_mac_vars.tctx = &_tctx;
API_VTable_system system_vtable = {};
system_api_fill_vtable(&system_vtable);
API_VTable_graphics graphics_vtable = {};
graphics_api_fill_vtable(&graphics_vtable);
API_VTable_font font_vtable = {};
font_api_fill_vtable(&font_vtable);
// NOTE(yuval): Memory
global_mac_vars.frame_arena = reserve_arena(global_mac_vars.tctx);
global_target.arena = make_arena_system(KB(256));
}

View File

@ -1,35 +1,13 @@
/* Mac Objective C layer for 4coder */
#include <Cocoa/Cocoa.h>
#define FPS 60
#define frame_useconds (1000000 / FPS)
#include "4coder_base_types.h"
#include "4coder_version.h"
#include "4coder_events.h"
#include "mac_objective_c_to_cpp_links.h"
#include "4coder_system_types.h"
#define STATIC_LINK_API
#include "generated/system_api.h"
#include "generated/system_api.cpp"
#include "4coder_base_types.cpp"
////////////////////////////////
#define SLASH '\\'
#define DLL "dll"
#include "4coder_hash_functions.cpp"
#include "4coder_system_allocator.cpp"
#include "4coder_codepoint_map.cpp"
#include "4ed_mem.cpp"
#include "4ed_font_set.cpp"
////////////////////////////////
#undef function
#undef internal
#undef global
#undef external
#include <Cocoa/Cocoa.h>
@interface App_Delegate : NSObject<NSApplicationDelegate, NSWindowDelegate>
@end
@ -67,32 +45,14 @@ main(int arg_count, char **args){
[NSApp finishLaunching];
// NOTE(yuval): Context Setup
Thread_Context _tctx = {};
thread_ctx_init(&_tctx, ThreadKind_Main,
get_base_allocator_system(),
get_base_allocator_system());
block_zero_struct(&global_mac_vars);
global_mac_vars.tctx = &_tctx;
API_VTable_system system_vtable = {};
system_api_fill_vtable(&system_vtable);
API_VTable_graphics graphics_vtable = {};
graphics_api_fill_vtable(&graphics_vtable);
API_VTable_font font_vtable = {};
font_api_fill_vtable(&font_vtable);
// NOTE(yuval): Memory
global_mac_vars.frame_arena = reserve_arena(global_mac_vars.tctx);
global_target.arean = make_arena_system(KB(256));
mac_init();
#if 0
// NOTE(yuval): Application Core Update
Application_Step_Result result = {};
if (app.step != 0){
result = app.step(mac_vars.tctx, &target, base_ptr, &input);
}
#endif
}
}

View File

@ -0,0 +1,348 @@
/* General macOS Functions */
function
system_get_path_sig(){
String_Const_u8 result = {};
NotImplemented;
return result;
}
function
system_get_canonical_sig(){
String_Const_u8 result = {};
NotImplemented;
return result;
}
function
system_get_file_list_sig(){
File_List result = {};
NotImplemented;
return result;
}
function
system_quick_file_attributes_sig(){
File_Attributes result = {};
NotImplemented;
return result;
}
function
system_load_handle_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_load_attributes_sig(){
File_Attributes result = {};
NotImplemented;
return result;
}
function
system_load_file_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_load_close_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_save_file_sig(){
File_Attributes result = {};
NotImplemented;
return result;
}
function
system_load_library_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_release_library_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_get_proc_sig(){
Void_Func* result = 0;
NotImplemented;
return result;
}
function
system_now_time_sig(){
u64 result = 0;
NotImplemented;
return result;
}
function
system_wake_up_timer_create_sig(){
Plat_Handle result = {};
NotImplemented;
return result;
}
function
system_wake_up_timer_release_sig(){
NotImplemented;
}
function
system_wake_up_timer_set_sig(){
NotImplemented;
}
function
system_signal_step_sig(){
NotImplemented;
}
function
system_sleep_sig(){
NotImplemented;
}
function
system_post_clipboard_sig(){
NotImplemented;
}
function
system_cli_call_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_cli_begin_update_sig(){
NotImplemented;
}
function
system_cli_update_step_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_cli_end_update_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_open_color_picker_sig(){
NotImplemented;
}
function
system_get_screen_scale_factor_sig(){
f32 result = 0.0f;
NotImplemented;
return result;
}
function
system_thread_launch_sig(){
System_Thread result = {};
NotImplemented;
return result;
}
function
system_thread_join_sig(){
NotImplemented;
}
function
system_thread_free_sig(){
NotImplemented;
}
function
system_thread_get_id_sig(){
i32 result = 0;
NotImplemented;
return result;
}
function
system_acquire_global_frame_mutex_sig(){
NotImplemented;
}
function
system_release_global_frame_mutex_sig(){
NotImplemented;
}
function
system_mutex_make_sig(){
System_Mutex result = {};
NotImplemented;
return result;
}
function
system_mutex_acquire_sig(){
NotImplemented;
}
function
system_mutex_release_sig(){
NotImplemented;
}
function
system_mutex_free_sig(){
NotImplemented;
}
function
system_condition_variable_make_sig(){
System_Condition_Variable result = {};
NotImplemented;
return result;
}
function
system_condition_variable_wait_sig(){
NotImplemented;
}
function
system_condition_variable_signal_sig(){
NotImplemented;
}
function
system_condition_variable_free_sig(){
NotImplemented;
}
function
system_memory_allocate_sig(){
void* result = 0;
NotImplemented;
return result;
}
function
system_memory_set_protection_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_memory_free_sig(){
NotImplemented;
}
function
system_memory_annotation_sig(){
Memory_Annotation result = {};
NotImplemented;
return result;
}
function
system_show_mouse_cursor_sig(){
NotImplemented;
}
function
system_set_fullscreen_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_is_fullscreen_sig(){
b32 result = false;
NotImplemented;
return result;
}
function
system_get_keyboard_modifiers_sig(){
Input_Modifier_Set result = {};
NotImplemented;
return result;
}

View File

@ -782,7 +782,7 @@ osx_init(){
osxvars.input.first_step = true;
//
// HACK(allen):
// HACK(allen):
// Previously zipped stuff is here, it should be zipped in the new pattern now.
//

View File

@ -9,7 +9,6 @@
// TOP
#if 0
#define IS_OBJC_LAYER
#include "4coder_base_types.h"
@ -24,8 +23,6 @@
#define external
#include "osx_objective_c_to_cpp_links.h"
#endif
#include <CoreServices/CoreServices.h>
#import <Cocoa/Cocoa.h>
@ -33,7 +30,7 @@
#import <IOKit/hid/IOHIDLib.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
#if 0
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
@ -817,9 +814,9 @@ osx_list_loadable_fonts(void){
NSString *font_n = fonts[i];
char *font_n_c = (char*)[font_n UTF8String];
NSFont *font = [font_manager
fontWithFamily:font_n
traits:NSUnboldFontMask|NSUnitalicFontMask
weight:5
fontWithFamily:font_n
traits:NSUnboldFontMask|NSUnitalicFontMask
weight:5
size:12];
NSString *path = get_font_path(font);
char *path_c = 0;
@ -843,10 +840,9 @@ OSX_Keyboard_Modifiers
osx_get_modifiers(void){
return(osx_mods_nsevent_to_struct([NSEvent modifierFlags]));
}
#endif
int
main(int argc, char **argv){
#if 0
memset(&osx_objc, 0, sizeof(osx_objc));
u32 clipboard_size = KB(16);
@ -891,7 +887,7 @@ main(int argc, char **argv){
[NSApp run];
}
#endif
return(0);
}

View File

@ -0,0 +1,13 @@
/* Types and functions for communication between C++ and Objective-C layers. */
#if !defined(MAC_OBJECTIVE_C_TO_CPP_LINKS_H)
#define MAC_OBJECTIVE_C_TO_CPP_LINKS_H
// In C++ layer.
external void*
mac_init();
// In Objective-C layer.
#endif