implementation for scheme48.
This commit is contained in:
parent
3a36140b69
commit
780cc2f939
127
c/xlib/error.c
127
c/xlib/error.c
|
@ -1,92 +1,67 @@
|
||||||
#include "xlib.h"
|
#include "xlib.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
static s48_value V_X_Error_Handler, V_X_Fatal_Error_Handler;
|
s48_value internal_x_error_handler_binding = S48_FALSE;
|
||||||
|
s48_value internal_x_fatal_error_handler_binding = S48_FALSE;
|
||||||
|
|
||||||
/* Default error handlers of the Xlib */
|
/* Default error handlers of the Xlib */
|
||||||
extern int _XDefaultIOError();
|
extern int _XDefaultIOError();
|
||||||
extern int _XDefaultError();
|
extern int _XDefaultError();
|
||||||
|
|
||||||
static X_Fatal_Error (d) Display *d; {
|
static X_Fatal_Error (Display* d) {
|
||||||
s48_value args, fun;
|
//Reset_IO (0); //??
|
||||||
S48_DECLARE_GC_PROTECT(1);
|
|
||||||
|
|
||||||
Reset_IO (0);
|
// call the scheme-func internal-x-fatal-error-handler, which does the rest.
|
||||||
args = Make_Display (0, d);
|
s48_call_scheme(S48_SHARED_BINDING_REF(internal_x_fatal_error_handler_binding),
|
||||||
S48_GC_PROTECT_1 (args);
|
1, SCX_ENTER_DISPLAY(d));
|
||||||
args = s48_cons (args, S48_NULL);
|
|
||||||
S48_GC_UNPROTECT;
|
// In case the scheme error handler does not exit (or none exists):
|
||||||
fun = Var_Get (V_X_Fatal_Error_Handler);
|
_XDefaultIOError (d);
|
||||||
if (TYPE(fun) == T_Compound)
|
// And if event the default handler does not exit:
|
||||||
(void)Funcall (fun, args, 0);
|
exit (1);
|
||||||
_XDefaultIOError (d);
|
/*NOTREACHED*/
|
||||||
exit (1); /* In case the default handler doesn't exit() */
|
|
||||||
/*NOTREACHED*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static X_Error (d, ep) Display *d; XErrorEvent *ep; {
|
static X_Error(Display* d, XErrorEvent* ep) {
|
||||||
s48_value args, a, fun;
|
s48_value args = s48_make_vector(7, S48_FALSE);
|
||||||
S48_DECLARE_GC_PROTECT(1);
|
s48_value a = S48_FALSE, r = S48_FALSE;
|
||||||
|
int max_s = 1024;
|
||||||
|
char s[max_s];
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
Reset_IO (0);
|
//Reset_IO (0); //??
|
||||||
args = s48_enter_integer ((unsigned long)ep->resourceid);
|
|
||||||
S48_GC_PROTECT_1 (args);
|
S48_GC_PROTECT_2(args, a);
|
||||||
args = s48_cons (args, S48_NULL);
|
S48_VECTOR_SET(args, 0, SCX_ENTER_DISPLAY(d));
|
||||||
a = s48_enter_integer (ep->minor_code);
|
S48_VECTOR_SET(args, 1, s48_enter_integer(ep->serial));
|
||||||
args = s48_cons (a, args);
|
a = Bit_To_Symbol ((unsigned long)ep->error_code, Error_Syms);
|
||||||
a = s48_enter_integer (ep->request_code);
|
if (S48_NULL_P (a))
|
||||||
args = s48_cons (a, args);
|
a = s48_enter_integer (ep->error_code);
|
||||||
a = Bits_To_Symbols ((unsigned long)ep->error_code, 0, Error_Syms);
|
S48_VECTOR_SET(args, 2, a);
|
||||||
if (S48_NULL_P (a))
|
S48_VECTOR_SET(args, 3, s48_enter_integer (ep->request_code));
|
||||||
a = s48_enter_integer (ep->error_code);
|
S48_VECTOR_SET(args, 4, s48_enter_integer (ep->minor_code));
|
||||||
args = s48_cons (a, args);
|
S48_VECTOR_SET(args, 5, s48_enter_integer ((unsigned long)ep->resourceid));
|
||||||
a = s48_enter_integer (ep->serial);
|
XGetErrorText(d, ep->error_code, s, max_s);
|
||||||
args = s48_cons (a, args);
|
S48_VECTOR_SET(args, 6, s48_enter_string(s));
|
||||||
a = Make_Display (0, ep->display);
|
|
||||||
args = s48_cons (a, args);
|
r = s48_call_scheme(S48_SHARED_BINDING_REF(internal_x_error_handler_binding),
|
||||||
S48_GC_UNPROTECT;
|
1, args);
|
||||||
fun = Var_Get (V_X_Error_Handler);
|
|
||||||
if (TYPE(fun) == T_Compound)
|
S48_GC_UNPROTECT();
|
||||||
(void)Funcall (fun, args, 0);
|
|
||||||
else
|
if S48_FALSE_P( r )
|
||||||
_XDefaultError (d, ep);
|
_XDefaultError (d, ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
static X_After_Function (d) Display *d; {
|
void scx_init_error() {
|
||||||
s48_value args;
|
S48_GC_PROTECT_GLOBAL(internal_x_error_handler_binding);
|
||||||
S48_DECLARE_GC_PROTECT(1);
|
S48_GC_PROTECT_GLOBAL(internal_x_fatal_error_handler_binding);
|
||||||
|
internal_x_error_handler_binding =
|
||||||
|
s48_get_imported_binding("internal-x-error-handler");
|
||||||
|
internal_x_fatal_error_handler_binding =
|
||||||
|
s48_get_imported_binding("internal-x-fatal-error-handler");
|
||||||
|
|
||||||
args = Make_Display (0, d);
|
(void)XSetIOErrorHandler (X_Fatal_Error);
|
||||||
S48_GC_PROTECT_1 (args);
|
(void)XSetErrorHandler (X_Error);
|
||||||
args = s48_cons (args, S48_NULL);
|
|
||||||
S48_GC_UNPROTECT;
|
|
||||||
(void)Funcall (DISPLAY(S48_CAR (args))->after, args, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static s48_value P_Set_After_Function (d, f) s48_value d, f; {
|
|
||||||
s48_value old;
|
|
||||||
|
|
||||||
Check_Type (d, T_Display);
|
|
||||||
if (S48_EQ_P(f, S48_FALSE)) {
|
|
||||||
(void)XSetAfterFunction (DISPLAY(d)->dpy, (int (*)())0);
|
|
||||||
} else {
|
|
||||||
Check_Procedure (f);
|
|
||||||
(void)XSetAfterFunction (DISPLAY(d)->dpy, X_After_Function);
|
|
||||||
}
|
|
||||||
old = DISPLAY(d)->after;
|
|
||||||
DISPLAY(d)->after = f;
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
static s48_value P_After_Function (d) s48_value d; {
|
|
||||||
Check_Type (d, T_Display);
|
|
||||||
return DISPLAY(d)->after;
|
|
||||||
}
|
|
||||||
|
|
||||||
elk_init_xlib_error () {
|
|
||||||
Define_Variable (&V_X_Fatal_Error_Handler, "x-fatal-error-handler", S48_NULL);
|
|
||||||
Define_Variable (&V_X_Error_Handler, "x-error-handler", S48_NULL);
|
|
||||||
(void)XSetIOErrorHandler (X_Fatal_Error);
|
|
||||||
(void)XSetErrorHandler (X_Error);
|
|
||||||
Define_Primitive (P_Set_After_Function, "set-after-function!", 2, 2, EVAL);
|
|
||||||
Define_Primitive (P_After_Function, "after-function", 1, 1, EVAL);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,46 @@
|
||||||
#include "xlib.h"
|
#include "xlib.h"
|
||||||
|
|
||||||
static s48_value P_List_Extensions (d) s48_value d; {
|
s48_value scx_List_Extensions (s48_value d) {
|
||||||
s48_value ret;
|
s48_value ret;
|
||||||
int n;
|
int n, i;
|
||||||
register i;
|
char **p;
|
||||||
register char **p;
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
S48_DECLARE_GC_PROTECT(1);
|
|
||||||
|
//Disable_Interrupts;
|
||||||
Check_Type (d, T_Display);
|
p = XListExtensions (SCX_EXTRACT_DISPLAY(d), &n);
|
||||||
Disable_Interrupts;
|
//Enable_Interrupts;
|
||||||
p = XListExtensions (DISPLAY(d)->dpy, &n);
|
ret = s48_make_vector (n, S48_FALSE);
|
||||||
Enable_Interrupts;
|
S48_GC_PROTECT_1 (ret);
|
||||||
ret = s48_make_vector (n, S48_NULL);
|
for (i = 0; i < n; i++) {
|
||||||
S48_GC_PROTECT_1 (ret);
|
S48_VECTOR_SET(ret, i, s48_enter_string(p[i]));
|
||||||
for (i = 0; i < n; i++) {
|
}
|
||||||
s48_value e;
|
S48_GC_UNPROTECT();
|
||||||
|
XFreeExtensionList (p);
|
||||||
e = Make_String (p[i], strlen (p[i]));
|
return ret;
|
||||||
S48_VECTOR_SET(ret, i, e;)
|
|
||||||
}
|
|
||||||
S48_GC_UNPROTECT;
|
|
||||||
XFreeExtensionList (p);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Query_Extension (d, name) s48_value d, name; {
|
s48_value scx_Query_Extension (s48_value d, s48_value name) {
|
||||||
int opcode, event, error;
|
int opcode, event, error;
|
||||||
s48_value ret, t;
|
s48_value ret;
|
||||||
S48_DECLARE_GC_PROTECT(2);
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
Check_Type (d, T_Display);
|
if (!XQueryExtension (SCX_EXTRACT_DISPLAY(d),
|
||||||
if (!XQueryExtension (DISPLAY(d)->dpy, Get_Strsym (name), &opcode,
|
s48_extract_string(name),
|
||||||
&event, &error))
|
&opcode, &event, &error))
|
||||||
return S48_FALSE;
|
return S48_FALSE;
|
||||||
t = ret = P_Make_List (s48_enter_integer (3), S48_NULL);
|
|
||||||
S48_GC_PROTECT_2 (ret, t);
|
ret = s48_make_vector(3, S48_FALSE);
|
||||||
S48_CAR (t) = (opcode ? s48_enter_integer (opcode) : S48_FALSE); t = S48_CDR (t);
|
S48_GC_PROTECT_1(ret);
|
||||||
S48_CAR (t) = (event ? s48_enter_integer (event) : S48_FALSE); t = S48_CDR (t);
|
|
||||||
S48_CAR (t) = (error ? s48_enter_integer (error) : S48_FALSE);
|
S48_VECTOR_SET(ret, 0, opcode ? s48_enter_integer (opcode) : S48_FALSE);
|
||||||
S48_GC_UNPROTECT;
|
S48_VECTOR_SET(ret, 1, event ? s48_enter_integer (event) : S48_FALSE);
|
||||||
return ret;
|
S48_VECTOR_SET(ret, 2, error ? s48_enter_integer (error) : S48_FALSE);
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
elk_init_xlib_extension () {
|
scx_init_extension () {
|
||||||
Define_Primitive (P_List_Extensions, "list-extensions", 1, 1, EVAL);
|
S48_EXPORT_FUNCTION(scx_List_Extensions);
|
||||||
Define_Primitive (P_Query_Extension, "query-extension", 2, 2, EVAL);
|
S48_EXPORT_FUNCTION(scx_Query_Extension);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ s48_value scx_Allow_Events (s48_value Xdpy, s48_value mode, s48_value time){
|
||||||
|
|
||||||
|
|
||||||
s48_value scx_Grab_Server (s48_value Xdpy){
|
s48_value scx_Grab_Server (s48_value Xdpy){
|
||||||
XGravServer(SCX_EXTRACT_DISPLAY(Xdpy));
|
XGrabServer(SCX_EXTRACT_DISPLAY(Xdpy));
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void scx_init_grab(void) {
|
||||||
S48_EXPORT_FUNCTION(scx_Change_Active_Pointer_Grab);
|
S48_EXPORT_FUNCTION(scx_Change_Active_Pointer_Grab);
|
||||||
S48_EXPORT_FUNCTION(scx_Grab_Keyboard);
|
S48_EXPORT_FUNCTION(scx_Grab_Keyboard);
|
||||||
S48_EXPORT_FUNCTION(scx_Ungrab_Keyboard);
|
S48_EXPORT_FUNCTION(scx_Ungrab_Keyboard);
|
||||||
S48_EXPORT_FUNCITON(scx_Grab_Key);
|
S48_EXPORT_FUNCTION(scx_Grab_Key);
|
||||||
S48_EXPORT_FUNCTION(scx_Ungrab_Key);
|
S48_EXPORT_FUNCTION(scx_Ungrab_Key);
|
||||||
S48_EXPORT_FUNCTION(scx_Allow_Events);
|
S48_EXPORT_FUNCTION(scx_Allow_Events);
|
||||||
S48_EXPORT_FUNCTION(scx_Grab_Server);
|
S48_EXPORT_FUNCTION(scx_Grab_Server);
|
||||||
|
|
Loading…
Reference in New Issue