fixed gc protection

This commit is contained in:
frese 2003-05-02 13:20:45 +00:00
parent 992c2aa830
commit 427d755fae
3 changed files with 26 additions and 8 deletions

View File

@ -133,8 +133,9 @@ s48_value scx_Display_Flush(s48_value display) {
}
s48_value scx_Display_Sync(s48_value display, s48_value discard) {
S48_DECLARE_GC_PROTECT_2(display, discard);
XSync(scx_extract_display(display), S48_EXTRACT_BOOLEAN(discard));
return S48_UNSPECIFIC;
S48_GC_RETURN(S48_UNSPECIFIC);
}
s48_value scx_No_Op(s48_value display) {
@ -144,10 +145,11 @@ s48_value scx_No_Op(s48_value display) {
s48_value scx_Display_Select_Input(s48_value display, s48_value window,
s48_value event_mask) {
S48_DECLARE_GC_PROTECT_3(display, window, event_mask);
XSelectInput(scx_extract_display(display),
scx_extract_window(window),
scx_extract_event_mask(event_mask));
return S48_UNSPECIFIC;
S48_GC_RETURN(S48_UNSPECIFIC);
}
void scx_init_display(void) {

View File

@ -42,6 +42,7 @@ s48_value scx_enter_x_error(XErrorEvent* xe) {
}
void scx_extract_x_error(s48_value e, XErrorEvent* xe) {
S48_DECLARE_GC_PROTECT_1(e);
s48_check_record_type(e, scx_x_error_binding);
xe->type = 1;
xe->display = scx_extract_display(S48_RECORD_REF(e, 0));
@ -50,6 +51,7 @@ void scx_extract_x_error(s48_value e, XErrorEvent* xe) {
xe->request_code = s48_extract_integer(S48_RECORD_REF(e, 3));
xe->minor_code = s48_extract_integer(S48_RECORD_REF(e, 4));
xe->resourceid = s48_extract_integer(S48_RECORD_REF(e, 5));
S48_GC_UNPROTECT();
}
/* Default error handlers of the Xlib */
@ -62,12 +64,15 @@ static int error_handler_wrapper(Display* dpy, XErrorEvent* e) {
char handled = 0;
if ((internal_x_error_handler_binding != S48_FALSE) &&
(S48_SHARED_BINDING_REF(internal_x_error_handler_binding) != S48_FALSE)){
s48_value v =
s48_value v = S48_FALSE, display = S48_FALSE, err = S48_FALSE;
S48_DECLARE_GC_PROTECT_3(v, display, err);
display = scx_enter_display(dpy);
err = scx_enter_x_error(e);
v =
s48_call_scheme(S48_SHARED_BINDING_REF(internal_x_error_handler_binding),
2,
scx_enter_display(dpy),
scx_enter_x_error(e));
2, display, err);
handled = (v != S48_FALSE);
S48_GC_UNPROTECT();
}
if (!handled)
_XDefaultError(dpy, e);
@ -76,22 +81,24 @@ static int error_handler_wrapper(Display* dpy, XErrorEvent* e) {
s48_value scx_Get_Error_Text(s48_value display, s48_value code) {
char buf[1024];
S48_DECLARE_GC_PROTECT_2(display, code);
XGetErrorText(scx_extract_display(display), scx_extract_error_code(code),
buf, 1024);
buf[1023] = 0;
return s48_enter_string(buf);
S48_GC_RETURN(s48_enter_string(buf));
}
s48_value scx_Get_Error_Database_Text(s48_value display, s48_value name,
s48_value message, s48_value def) {
char buf[1024];
S48_DECLARE_GC_PROTECT_4(display, name, message, def);
XGetErrorDatabaseText(scx_extract_display(display),
s48_extract_string(name),
s48_extract_string(message),
s48_extract_string(def),
buf, 1024);
buf[1023] = 0;
return s48_enter_string(buf);
S48_GC_RETURN(s48_enter_string(buf));
}
s48_value internal_x_fatal_error_handler_binding = S48_FALSE;

View File

@ -32,6 +32,15 @@
S48_DECLARE_GC_PROTECT(4); S48_GC_PROTECT_4(v0, v1, v2, v3)
#define S48_DECLARE_GC_PROTECT_5(v0, v1, v2, v3, v4) \
S48_DECLARE_GC_PROTECT(5); S48_GC_PROTECT_5(v0, v1, v2, v3, v4)
#define S48_DECLARE_GC_PROTECT_6(v0, v1, v2, v3, v4, v5) \
S48_DECLARE_GC_PROTECT(6); S48_GC_PROTECT_6(v0, v1, v2, v3, v4, v5)
#define S48_DECLARE_GC_PROTECT_7(v0, v1, v2, v3, v4, v5, v6) \
S48_DECLARE_GC_PROTECT(7); S48_GC_PROTECT_7(v0, v1, v2, v3, v4, v5, v6)
#define S48_DECLARE_GC_PROTECT_8(v0, v1, v2, v3, v4, v5, v6, v7) \
S48_DECLARE_GC_PROTECT(8); S48_GC_PROTECT_8(v0, v1, v2, v3, v4, v5, v6, v7)
#define S48_DECLARE_GC_PROTECT_9(v0, v1, v2, v3, v4, v5, v6, v7, v8) \
S48_DECLARE_GC_PROTECT(9); \
S48_GC_PROTECT_9(v0, v1, v2, v3, v4, v5, v6, v7, v8)
#define S48_GC_RETURN(v) do { S48_GC_UNPROTECT(); return(v); } while(0)