Started a new Haiku port.

This commit is contained in:
Pietro Gagliardi 2020-01-12 22:48:28 -05:00
parent a8d082fa79
commit d0edd9e738
7 changed files with 105 additions and 1 deletions

53
haiku/main.cpp Normal file
View File

@ -0,0 +1,53 @@
// 12 january 2020
#include "uipriv_haiku.hpp"
uiprivApplication *uiprivApp;
// TODO add format string warning detection to all these functions, where available
// TODO also see if we can convert this to a string, or use a known type for status_t instead of assuming it's int(32_t)
#define uiprivInitReturnStatus(err, msg, status) uiprivInitReturnErrorf(err, "%s: %d", msg, status)
static thread_id mainThread;
bool uiprivSysInit(void *options, uiInitError *err)
{
status_t status;
uiprivApp = new uiprivApplication("application/libui.TODO", &status);
if (status != B_OK)
return uiprivInitReturnStatus(err, "error creating BApplication", status);
mainThread = find_thread(NULL);
return true;
}
void uiMain(void)
{
if (!uiprivCheckInitializedAndThread())
return;
uiprivApp->Run();
}
// TODO if this is called beofre uiMain(), uiprivApp will be deleted; either ban doing this outright or catch this scenario
void uiQuit(void)
{
if (!uiprivCheckInitializedAndThread())
return;
uiprivApp->Quit();
}
void uiprivSysQueueMain(void (*f)(void *data), void *data)
{
// TODO
}
bool uiprivSysCheckThread(void)
{
return find_thread(NULL) == mainThread;
}
void uiprivReportError(const char *prefix, const char *msg, const char *suffix, bool internal)
{
fprintf(stderr, "*** %s: %s. %s\n", prefix, msg, suffix);
debugger("TODO");
abort(); // we shouldn't reach here
}

12
haiku/meson.build Normal file
View File

@ -0,0 +1,12 @@
# 12 january 2020
libui_sources += [
'haiku/main.cpp',
]
libui_deps += [
meson.get_compiler('cpp').find_library('root',
required: true),
meson.get_compiler('cpp').find_library('be',
required: true),
]

12
haiku/uipriv_haiku.hpp Normal file
View File

@ -0,0 +1,12 @@
// 12 january 2020
#include <os/AppKit.h>
#include <os/InterfaceKit.h>
#include <os/KernelKit.h>
#include <os/SupportKit.h>
#define uiprivOSHeader "../ui_haiku.h"
#include "../common/uipriv.h"
// main.cpp
class uiprivApplication : public BApplication {
};
extern uiprivApplication *uiprivApp;

View File

@ -152,6 +152,9 @@ if libui_OS == 'windows'
elif libui_OS == 'darwin'
subdir('darwin')
install_headers('ui_darwin.h')
elif libui_OS == 'haiku'
subdir('haiku')
install_headers('ui_haiku.h')
else
subdir('unix')
install_headers('ui_unix.h')

View File

@ -11,7 +11,7 @@ if libui_OS == 'windows'
'lib/thread_windows.c',
'lib/timer_windows.c',
]
else
else # including Haiku, since it's POSIX-compliant
libui_test_sources += [
'lib/thread_darwinunix.c',
'lib/timer_darwinunix.c'

View File

@ -21,6 +21,8 @@ elif libui_OS == 'darwin'
'controls_darwin.m',
'controls_darwin_errors.m',
]
elif libui_OS == 'haiku'
# TODO
else
libui_test_sources += [
'controls_unix.c',

22
ui_haiku.h Normal file
View File

@ -0,0 +1,22 @@
// 12 january 2020
/*
This file assumes that you have included TODO_insert_appropriate_Haiku_headers and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls in Windows.
*/
#ifndef uiprivIncludeGuard_ui_haiku_h
#define uiprivIncludeGuard_ui_haiku_h
#ifdef __cplusplus
extern "C" {
#endif
struct uiControlOSVtable {
size_t Size;
};
#ifdef __cplusplus
}
#endif
#endif