Skip to content

Commit

Permalink
Update hashlink.
Browse files Browse the repository at this point in the history
  • Loading branch information
Apprentice-Alchemist committed Jan 24, 2022
1 parent 4595541 commit c5775c0
Show file tree
Hide file tree
Showing 43 changed files with 2,502 additions and 2,483 deletions.
85 changes: 52 additions & 33 deletions project/include/hl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
https://github.com/HaxeFoundation/hashlink/wiki/
**/

#define HL_VERSION 0x010A00
#define HL_VERSION 0x010C00

#if defined(_WIN32)
# define HL_WIN
Expand All @@ -53,10 +53,8 @@

#if defined(linux) || defined(__linux__)
# define HL_LINUX
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#endif

#if defined(HL_IOS) || defined(HL_ANDROID) || defined(HL_TVOS)
# define HL_MOBILE
Expand Down Expand Up @@ -184,17 +182,13 @@
#else
# define C_FUNCTION_BEGIN
# define C_FUNCTION_END
# ifndef true
# define true 1
# define false 0
typedef unsigned char bool;
# endif
#endif

typedef intptr_t int_val;
typedef long long int64;
typedef unsigned long long uint64;

#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
Expand All @@ -211,9 +205,9 @@ typedef unsigned long long uint64;

#if defined(HL_WIN) && !defined(HL_LLVM)
#if defined(HL_WIN_DESKTOP) && !defined(HL_MINGW)
// # include <Windows.h>
# include <Windows.h>
#elif defined(HL_WIN_DESKTOP) && defined(HL_MINGW)
// # include<windows.h>
# include<windows.h>
#else
# include <xdk.h>
#endif
Expand All @@ -226,8 +220,8 @@ typedef wchar_t uchar;
# define ustrlen wcslen
# define ustrdup _wcsdup
HL_API int uvszprintf( uchar *out, int out_size, const uchar *fmt, va_list arglist );
# define utod(s,end) wcstod(s,end)
# define utoi(s,end) wcstol(s,end,10)
# define _utod(s,end) wcstod(s,end)
# define _utoi(s,end) wcstol(s,end,10)
# define ucmp(a,b) wcscmp(a,b)
# define utostr(out,size,str) wcstombs(out,str,size)
#elif defined(HL_MAC)
Expand All @@ -239,39 +233,29 @@ typedef uint16_t uchar;
#if defined(HL_IOS) || defined(HL_TVOS) || defined(HL_MAC)
#include <stddef.h>
#include <stdint.h>
#ifdef HL_MAC
typedef uint16_t char16_t;
typedef uint32_t char32_t;
#endif
#elif defined(HL_NATIVE_UCHAR_FUN)
#else
# include <uchar.h>
#elif __cplusplus <= 199711L
# include <stdint.h>
typedef uint16_t uchar16_t;
typedef uint32_t uchar32_t;
#ifndef EMSCRIPTEN
typedef int32_t char32_t;
typedef int16_t char16_t;
#endif
#endif
typedef char16_t uchar;
# undef USTR
# define USTR(str) u##str
#endif

#ifndef HL_NATIVE_UCHAR_FUN
C_FUNCTION_BEGIN
HL_API int ustrlen( const uchar *str );
HL_API uchar *ustrdup( const uchar *str );
HL_API double utod( const uchar *str, uchar **end );
HL_API int utoi( const uchar *str, uchar **end );
#ifndef HL_NATIVE_UCHAR_FUN
HL_API int ustrlen( const uchar *str );
HL_API uchar *ustrdup( const uchar *str );
HL_API int ucmp( const uchar *a, const uchar *b );
HL_API int utostr( char *out, int out_size, const uchar *str );
HL_API int usprintf( uchar *out, int out_size, const uchar *fmt, ... );
HL_API int uvszprintf( uchar *out, int out_size, const uchar *fmt, va_list arglist );
HL_API void uprintf( const uchar *fmt, const uchar *str );
C_FUNCTION_END
#endif
C_FUNCTION_END

#if defined(HL_VCC)
# define hl_debug_break() if( IsDebuggerPresent() ) __debugbreak()
Expand All @@ -297,6 +281,11 @@ C_FUNCTION_END
".long 0b;" \
".popsection")
# endif
#elif defined(HL_MAC)
#include <signal.h>
# define hl_debug_break() \
if( hl_detect_debugger() ) \
raise(SIGTRAP);//__builtin_trap();
#else
# define hl_debug_break()
#endif
Expand Down Expand Up @@ -494,7 +483,7 @@ typedef struct _vclosure {
void *fun;
int hasValue;
# ifdef HL_64
int __pad;
int stackCount;
# endif
void *value;
} vclosure;
Expand Down Expand Up @@ -535,7 +524,9 @@ struct hl_runtime_obj {
vdynamic *(*getFieldFun)( vdynamic *obj, int hfield );
// relative
int nlookup;
int ninterfaces;
hl_field_lookup *lookup;
int *interfaces;
};

typedef struct {
Expand Down Expand Up @@ -601,6 +592,7 @@ HL_API vdynamic *hl_alloc_strbytes( const uchar *msg, ... );
HL_API void hl_assert( void );
HL_API HL_NO_RETURN( void hl_throw( vdynamic *v ) );
HL_API HL_NO_RETURN( void hl_rethrow( vdynamic *v ) );
HL_API HL_NO_RETURN( void hl_null_access( void ) );
HL_API void hl_setup_longjump( void *j );
HL_API void hl_setup_exception( void *resolve_symbol, void *capture_stack );
HL_API void hl_dump_stack( void );
Expand Down Expand Up @@ -661,7 +653,7 @@ HL_API vdynamic *hl_dyn_call_safe( vclosure *c, vdynamic **args, int nargs, bool
so you are sure it's of the used typed. Otherwise use hl_dyn_call
*/
#define hl_call0(ret,cl) \
(cl->hasValue ? ((ret(*)(vdynamic*))cl->fun)(cl->value) : ((ret(*)())cl->fun)())
(cl->hasValue ? ((ret(*)(vdynamic*))cl->fun)(cl->value) : ((ret(*)())cl->fun)())
#define hl_call1(ret,cl,t,v) \
(cl->hasValue ? ((ret(*)(vdynamic*,t))cl->fun)(cl->value,v) : ((ret(*)(t))cl->fun)(v))
#define hl_call2(ret,cl,t1,v1,t2,v2) \
Expand All @@ -675,9 +667,13 @@ HL_API vdynamic *hl_dyn_call_safe( vclosure *c, vdynamic **args, int nargs, bool

struct _hl_thread;
struct _hl_mutex;
struct _hl_semaphore;
struct _hl_condition;
struct _hl_tls;
typedef struct _hl_thread hl_thread;
typedef struct _hl_mutex hl_mutex;
typedef struct _hl_semaphore hl_semaphore;
typedef struct _hl_condition hl_condition;
typedef struct _hl_tls hl_tls;

HL_API hl_thread *hl_thread_start( void *callback, void *param, bool withGC );
Expand All @@ -692,6 +688,22 @@ HL_API bool hl_mutex_try_acquire( hl_mutex *l );
HL_API void hl_mutex_release( hl_mutex *l );
HL_API void hl_mutex_free( hl_mutex *l );

HL_API hl_semaphore *hl_semaphore_alloc(int value);
HL_API void hl_semaphore_acquire(hl_semaphore *sem);
HL_API bool hl_semaphore_try_acquire(hl_semaphore *sem, vdynamic *timeout);
HL_API void hl_semaphore_release(hl_semaphore *sem);
HL_API void hl_semaphore_free(hl_semaphore *sem);

HL_API hl_condition *hl_condition_alloc();
HL_API void hl_condition_acquire(hl_condition *cond);
HL_API bool hl_condition_try_acquire(hl_condition *cond);
HL_API void hl_condition_release(hl_condition *cond);
HL_API void hl_condition_wait(hl_condition *cond);
HL_API bool hl_condition_timed_wait(hl_condition *cond, double timeout);
HL_API void hl_condition_signal(hl_condition *cond);
HL_API void hl_condition_broadcast(hl_condition *cond);
HL_API void hl_condition_free(hl_condition *cond);

HL_API hl_tls *hl_tls_alloc( bool gc_value );
HL_API void hl_tls_set( hl_tls *l, void *value );
HL_API void *hl_tls_get( hl_tls *l );
Expand Down Expand Up @@ -754,7 +766,7 @@ HL_API void hl_throw_buffer( hl_buffer *b );
// ----------------------- FFI ------------------------------------------------------

// match GNU C++ mangling
#define TYPE_STR "vcsilfdbBDPOATR??X?N"
#define TYPE_STR "vcsilfdbBDPOATR??X?N?S"

#undef _VOID
#define _NO_ARG
Expand All @@ -776,6 +788,7 @@ HL_API void hl_throw_buffer( hl_buffer *b );
#define _ABSTRACT(name) "X" #name "_"
#undef _NULL
#define _NULL(t) "N" t
#define _STRUCT "S"

#undef _STRING
#define _STRING _OBJ(_BYTES _I32)
Expand All @@ -786,7 +799,7 @@ typedef struct {
int length;
} vstring;

// #define DEFINE_PRIM(t,name,args) DEFINE_PRIM_WITH_NAME(t,name,args,name)
// this macro has been renamed from DEFINE_PRIM to DEFINE_HL_PRIM, because DEFINE_PRIM is already used
#define DEFINE_HL_PRIM(t,name,args) DEFINE_PRIM_WITH_NAME(t,name,args,name)
#define _DEFINE_PRIM_WITH_NAME(t,name,args,realName) C_FUNCTION_BEGIN EXPORT void *hlp_##realName( const char **sign ) { *sign = _FUN(t,args); return (void*)(&HL_NAME(name)); } C_FUNCTION_END

Expand Down Expand Up @@ -838,6 +851,7 @@ HL_API void *hl_fatal_error( const char *msg, const char *file, int line );
HL_API void hl_fatal_fmt( const char *file, int line, const char *fmt, ...);
HL_API void hl_sys_init(void **args, int nargs, void *hlfile);
HL_API void hl_setup_callbacks(void *sc, void *gw);
HL_API void hl_setup_callbacks2(void *sc, void *gw, int flags);
HL_API void hl_setup_reload_check( void *freload, void *param );

#include <setjmp.h>
Expand All @@ -855,14 +869,17 @@ struct _hl_trap_ctx {
#define HL_EXC_CATCH_ALL 2
#define HL_EXC_IS_THROW 4
#define HL_THREAD_INVISIBLE 16
#define HL_TREAD_TRACK_SHIFT 5
#define HL_THREAD_PROFILER_PAUSED 32
#define HL_TREAD_TRACK_SHIFT 16

#define HL_TRACK_ALLOC 1
#define HL_TRACK_CAST 2
#define HL_TRACK_DYNFIELD 4
#define HL_TRACK_DYNCALL 8
#define HL_TRACK_MASK (HL_TRACK_ALLOC | HL_TRACK_CAST | HL_TRACK_DYNFIELD | HL_TRACK_DYNCALL)

#define HL_MAX_EXTRA_STACK 64

typedef struct {
int thread_id;
// gc vars
Expand All @@ -879,6 +896,8 @@ typedef struct {
// extra
jmp_buf gc_regs;
void *exc_stack_trace[HL_EXC_MAX_STACK];
void *extra_stack_data[HL_MAX_EXTRA_STACK];
int extra_stack_size;
} hl_thread_info;

HL_API hl_thread_info *hl_get_thread();
Expand All @@ -898,7 +917,7 @@ typedef struct {

HL_API hl_track_info hl_track;

#else
#else

#define hl_is_tracking(_) false
#define hl_track_call(a,b)
Expand Down
2 changes: 1 addition & 1 deletion project/include/system/CFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define LIME_SYSTEM_CFFI_H


#define HL_NAME(n) hl_##n
#define HL_NAME(n) lime_##n
#include <hl.h>

typedef vdynamic hl_vdynamic;
Expand Down
2 changes: 1 addition & 1 deletion project/include/ui/KeyEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace lime {
struct KeyEvent {

hl_type* t;
int keyCode;
double keyCode;
int modifier;
KeyEventType type;
int windowID;
Expand Down
Loading

0 comments on commit c5775c0

Please sign in to comment.