setup cpp to m linkage correctly

master
Allen Webster 2017-06-29 21:13:20 -04:00
parent c0ceff4c26
commit d652cb46af
8 changed files with 150 additions and 97 deletions

View File

@ -127,6 +127,14 @@ OPEN_FILE_HOOK_SIG(default_file_settings){
parse_context_id = parse_context_language_cpp;
}
// TODO(NAME): Real Objective-C highlighting
if (match(ext, "m")){
if (parse_context_language_cpp == 0){
init_language_cpp(app);
}
parse_context_id = parse_context_language_cpp;
}
break;
}
}

View File

@ -422,7 +422,7 @@ buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){
#elif defined(IS_MAC)
# define PLAT_LAYER "platform_mac/mac_4ed.m"
# define PLAT_LAYER "platform_mac/mac_4ed.m platform_mac/mac_4ed.cpp"
# if defined(IS_GCC)
# define PLAT_INC "-I../code/platform_all -I../code/platform_unix"
# else

View File

@ -0,0 +1,71 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 06.29.2017
*
* Types and functions for communication between C++ and Objective-C layers.
*
*/
// TOP
#if !defined(OSX_OBJECTIVE_C_TO_CPP_LINKS_H)
#define OSX_OBJECTIVE_C_TO_CPP_LINKS_H
typedef enum OSX_Mouse_Event_Type{
MouseType_Move,
MouseType_Press,
MouseType_Release,
} OSX_Mouse_Event_Type;
typedef struct OSX_Keyboard_Modifiers{
b32 shift;
b32 command;
b32 control;
b32 option;
} OSX_Keyboard_Modifiers;
typedef struct OSX_Vars{
i32 width, height;
b32 running;
u32 key_count;
u32 keys[8];
u32 prev_clipboard_change_count;
b32 has_clipboard_item;
void *clipboard_data;
umem clipboard_size, clipboard_max;
b32 just_posted_to_clipboard;
} OSX_Vars;
// In C++ layer.
extern OSX_Vars osx;
void
osx_post_to_clipboard(char *str);
internal void*
osx_allocate(umem size);
internal void
osx_resize(int width, int height);
internal void
osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags);
internal void
osx_mouse(i32 mx, i32 my, u32 type);
internal void
osx_mouse_wheel(float dx, float dy);
internal void
osx_step();
internal void
osx_init();
#endif
// BOTTOM

View File

@ -1,89 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 06.28.2017
*
* Mac C layer for 4coder
*
*/
// TOP
#define WINDOW_TITLE "4coder"
#include "4tech_defines.h"
#include "4coder_API/version.h"
typedef enum OSX_Mouse_Event_Type{
MouseType_Move,
MouseType_Press,
MouseType_Release,
} OSX_Mouse_Event_Type;
typedef struct OSX_Keyboard_Modifiers{
b32 shift;
b32 command;
b32 control;
b32 option;
} OSX_Keyboard_Modifiers;
typedef struct OSX_Vars{
i32 width, height;
b32 running;
u32 key_count;
u32 keys[8];
u32 prev_clipboard_change_count;
b32 has_clipboard_item;
void *clipboard_data;
umem clipboard_size, clipboard_max;
b32 just_posted_to_clipboard;
} OSX_Vars;
internal OSX_Vars osx;
internal void
osx_post_to_clipboard(char *str);
// TODO(allen): Implement a real allocate
#include <stdlib.h>
internal void*
osx_allocate(umem size){
void *result = malloc(size);
return(result);
}
internal void
osx_resize(int width, int height){
osx.width = width;
osx.height = height;
// TODO
}
internal void
osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags){
// TODO
}
internal void
osx_mouse(i32 mx, i32 my, u32 type){
// TODO
}
internal void
osx_mouse_wheel(float dx, float dy){
// TODO
}
internal void
osx_step(){
// TODO
}
internal void
osx_init(){
// TODO
}
// BOTTOM

62
platform_mac/mac_4ed.cpp Normal file
View File

@ -0,0 +1,62 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 06.28.2017
*
* Mac C++ layer for 4coder
*
*/
// TOP
#include "4tech_defines.h"
#include "4coder_API/version.h"
#define WINDOW_TITLE "4coder" VERSION
#include "osx_objective_c_to_cpp_links.h"
OSX_Vars osx;
// TODO(allen): Implement a real allocate
#include <stdlib.h>
internal void*
osx_allocate(umem size){
void *result = malloc(size);
return(result);
}
internal void
osx_resize(int width, int height){
osx.width = width;
osx.height = height;
// TODO
}
internal void
osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags){
// TODO
}
internal void
osx_mouse(i32 mx, i32 my, u32 type){
// TODO
}
internal void
osx_mouse_wheel(float dx, float dy){
// TODO
}
internal void
osx_step(){
// TODO
}
internal void
osx_init(){
// TODO
}
// BOTTOM

View File

@ -9,7 +9,8 @@
// TOP
#include "mac_4ed.c"
#include "4tech_defines.h"
#include "osx_objective_c_to_cpp_links.h"
#undef internal
#undef global
@ -22,7 +23,7 @@
static void
osx_post_to_clipboard(char *str){
NSPasteboard *board = [NSPasteboard generalPasteboard];
NSPasteboard *board = [NSPasteboard generalPasteboard];
NSString *utf8_type = @"public.utf8-plain-text";
NSArray<NSString*> *typesArray = [NSArray arrayWithObjects: utf8_type, nil];
[board declareTypes:typesArray owner:nil];

View File

@ -1,4 +1,4 @@
extensions=".c.cpp.h.hpp.bat.sh.4coder";
extensions=".c.cpp.h.m.bat.sh.4coder";
open_recursively=true;
fkey_command_win[1] = {"echo build: x64 & build.bat", "*compilation*", true , true };

View File

@ -33,11 +33,13 @@
#define FPS 60
#define frame_useconds (1000000 / FPS)
#include <assert.h>
#include <string.h>
#include "4tech_defines.h"
#include "4coder_API/version.h"
#define WINDOW_NAME L"4coder: " L_VERSION
#include <assert.h>
#include <string.h>
#include "4coder_lib/4coder_utf8.h"
#if defined(FRED_SUPER)
@ -2199,8 +2201,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
window_style |= WS_MAXIMIZE;
}
#define WINDOW_NAME L"4coder-window: " L_VERSION
LOG(system, "Creating window... ");
win32vars.window_handle = CreateWindow(window_class.lpszClassName, WINDOW_NAME, window_style, window_x, window_y, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, 0, 0, hInstance, 0);