Skip to content

Commit 3d8d806

Browse files
author
Michail Pevnev
committed
Add overloads with GC enabled for functions accepting callbacks
Type aliases used for GC-enabled callbacks are the same as the ones before the change, `@nogc` callbacks have a `NOGC` part.
1 parent ca62f62 commit 3d8d806

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

source/deimos/ncurses/curses.d

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,8 @@ int vid_attr(chtype a, ...)
925925
* These functions are extensions - not in X/Open Curses.
926926
*/
927927
//TODO Check
928-
alias int function(WINDOW *, void *) NCURSES_WINDOW_CB;
929-
alias int function(SCREEN *, void *) NCURSES_SCREEN_CB;
928+
alias int function(WINDOW *, void *) @nogc NCURSES_WINDOW_NOGC_CB;
929+
alias int function(SCREEN *, void *) @nogc NCURSES_SCREEN_NOGC_CB;
930930

931931
bool is_term_resized(int lines, int columns);
932932
char* keybound(int keycode, int count);
@@ -945,8 +945,8 @@ int use_default_colors();
945945
int use_extended_names(bool enable);
946946
int use_legacy_coding(int i);
947947
//TODO check, I might not have gotten the function pointer alias correct.
948-
int use_screen(SCREEN* scr, NCURSES_SCREEN_CB, void* v);
949-
int use_window(WINDOW* win, NCURSES_WINDOW_CB, void* v);
948+
int use_screen(SCREEN* scr, NCURSES_SCREEN_NOGC_CB, void* v);
949+
int use_window(WINDOW* win, NCURSES_WINDOW_NOGC_CB, void* v);
950950
int wresize(WINDOW* win, int lines, int columns);
951951
void nofilter();
952952

@@ -1492,3 +1492,13 @@ body
14921492
}
14931493

14941494
}//end extern (C)
1495+
1496+
// This block is for functions that can require some GC to work.
1497+
extern (C) nothrow
1498+
{
1499+
alias int function(WINDOW *, void *) NCURSES_WINDOW_CB;
1500+
alias int function(SCREEN *, void *) NCURSES_SCREEN_CB;
1501+
1502+
int use_screen(SCREEN* scr, NCURSES_SCREEN_CB, void* v);
1503+
int use_window(WINDOW* win, NCURSES_WINDOW_CB, void* v);
1504+
}

0 commit comments

Comments
 (0)