make code ANSI-C compliant

This commit is contained in:
frese 2003-04-17 14:53:27 +00:00
parent e7108c64ca
commit f12cd06a4e
15 changed files with 60 additions and 53 deletions

View File

@ -1,11 +1,11 @@
#include "scheme48.h" #include "scheme48.h"
extern void scx_init_xlib(); extern void scx_init_xlib();
//extern void scx_init_xpm(); /*extern void scx_init_xpm();*/
int main(int argc, char **argv) { int main(int argc, char **argv) {
s48_add_external_init(scx_init_xlib); s48_add_external_init(scx_init_xlib);
//s48_add_external_init(scx_init_xpm); /*s48_add_external_init(scx_init_xpm);*/
s48_main(8000000, 64000, s48_main(8000000, 64000,
SCSHIMAGE, SCSHIMAGE,

View File

@ -389,7 +389,7 @@ s48_value scx_Get_Wm_Normal_Hints(s48_value dpy, s48_value win) {
scx_extract_window(win), scx_extract_window(win),
&SH, &supplied_by_user)) &SH, &supplied_by_user))
return S48_FALSE; return S48_FALSE;
// ignoring supplied_by_user ... ?! /* ignoring supplied_by_user ... ?! */
return scx_enter_size_hint_alist(&SH); return scx_enter_size_hint_alist(&SH);
} }

View File

@ -67,7 +67,8 @@ s48_value scx_enter_display(Display* dpy) {
d = s48_make_record(scx_display); d = s48_make_record(scx_display);
S48_GC_PROTECT_2(d, l); S48_GC_PROTECT_2(d, l);
// have to do this first, because screens want to reference their display /* have to do this first, because screens want to reference their
display */
scx_struct_cache_set(dpy, &scx_display_list, d); scx_struct_cache_set(dpy, &scx_display_list, d);
S48_RECORD_SET(d, 0, s48_enter_integer((long)dpy)); S48_RECORD_SET(d, 0, s48_enter_integer((long)dpy));
@ -89,7 +90,7 @@ s48_value scx_enter_display(Display* dpy) {
S48_RECORD_SET(d, 13, l); S48_RECORD_SET(d, 13, l);
S48_RECORD_SET(d, 14, S48_FALSE); S48_RECORD_SET(d, 14, S48_FALSE);
XSetAfterFunction(dpy, &scx_after_function_wrapper); XSetAfterFunction(dpy, &scx_after_function_wrapper);
S48_RECORD_SET(d, 15, S48_FALSE); // wakeup placeholder S48_RECORD_SET(d, 15, S48_FALSE);
s48_call_scheme(S48_SHARED_BINDING_REF(s48_get_imported_binding( s48_call_scheme(S48_SHARED_BINDING_REF(s48_get_imported_binding(
"scx-initialize-display")), 1, d); "scx-initialize-display")), 1, d);
S48_GC_UNPROTECT(); S48_GC_UNPROTECT();

View File

@ -7,7 +7,7 @@ s48_value scx_enter_error_code(int code) {
if (code < S48_VECTOR_LENGTH(v)) if (code < S48_VECTOR_LENGTH(v))
return S48_VECTOR_REF(v, code); return S48_VECTOR_REF(v, code);
else else
return s48_enter_integer(code); // Extension Errors return s48_enter_integer(code); /* Extension Errors */
} }
s48_value scx_extract_error_code(s48_value code) { s48_value scx_extract_error_code(s48_value code) {
@ -94,16 +94,17 @@ s48_value scx_Get_Error_Database_Text(s48_value display, s48_value name,
s48_value internal_x_fatal_error_handler_binding = S48_FALSE; s48_value internal_x_fatal_error_handler_binding = S48_FALSE;
static int fatal_error_handler_wrapper(Display* d) { static int fatal_error_handler_wrapper(Display* d) {
// call the scheme-func internal-x-fatal-error-handler, which does the rest. /* call the scheme-func internal-x-fatal-error-handler, which does
the rest. */
if ((internal_x_fatal_error_handler_binding != S48_FALSE) && if ((internal_x_fatal_error_handler_binding != S48_FALSE) &&
(S48_SHARED_BINDING_REF(internal_x_fatal_error_handler_binding) (S48_SHARED_BINDING_REF(internal_x_fatal_error_handler_binding)
!= S48_FALSE)) != S48_FALSE))
s48_call_scheme(S48_SHARED_BINDING_REF( s48_call_scheme(S48_SHARED_BINDING_REF(
internal_x_fatal_error_handler_binding), internal_x_fatal_error_handler_binding),
1, scx_enter_display(d)); 1, scx_enter_display(d));
// In case the scheme error handler does not exit (or none exists): /* In case the scheme error handler does not exit (or none exists): */
_XDefaultIOError (d); _XDefaultIOError (d);
// And if even the default handler does not exit: /* And if even the default handler does not exit: */
exit(1); exit(1);
/*NOTREACHED*/ /*NOTREACHED*/
return 0; return 0;

View File

@ -382,10 +382,10 @@ s48_value scx_enter_event(XEvent* e) {
case MappingNotify : case MappingNotify :
return scx_enter_mapping_event((XMappingEvent*)e); return scx_enter_mapping_event((XMappingEvent*)e);
default: return S48_FALSE; default: return S48_FALSE;
} // switch end } /* switch end */
} }
// *** extraction **************************************************** /*** extraction ****************************************************/
#define EEXTRACT(i, name, f) xe->name = f(S48_RECORD_REF(e, i)) #define EEXTRACT(i, name, f) xe->name = f(S48_RECORD_REF(e, i))
#define EEXTRACT_START(stype) \ #define EEXTRACT_START(stype) \
@ -674,10 +674,10 @@ void scx_extract_colormap_event(s48_value e, XColormapEvent* xe) {
} }
void scx_extract_client_message_event(s48_value e, XClientMessageEvent* xe) { void scx_extract_client_message_event(s48_value e, XClientMessageEvent* xe) {
EEXTRACT_START("scx-client-message-event");
EEXTRACT(4, window, scx_extract_window);
int nelements, i; int nelements, i;
char* data; char* data;
EEXTRACT_START("scx-client-message-event");
EEXTRACT(4, window, scx_extract_window);
scx_extract_property(S48_RECORD_REF(e, 5), &xe->message_type, &xe->format, scx_extract_property(S48_RECORD_REF(e, 5), &xe->message_type, &xe->format,
&data, &nelements); &data, &nelements);
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
@ -701,7 +701,7 @@ void scx_extract_mapping_event(s48_value e, XMappingEvent* xe) {
void scx_extract_keymap_event(s48_value e, XKeymapEvent* xe) { void scx_extract_keymap_event(s48_value e, XKeymapEvent* xe) {
s48_value temp; int i; s48_value temp; int i;
EEXTRACT_START("scx-keymap-event"); EEXTRACT_START("scx-keymap-event");
xe->window = (Window)0; // not used. xe->window = (Window)0;
temp = S48_RECORD_REF(e, 4); temp = S48_RECORD_REF(e, 4);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
int j; char* b = &xe->key_vector[i]; int j; char* b = &xe->key_vector[i];

View File

@ -53,9 +53,10 @@ s48_value scx_Send_Event(s48_value display, s48_value window,
s48_value propagate, s48_value propagate,
s48_value event_mask, s48_value event) { s48_value event_mask, s48_value event) {
XEvent e; XEvent e;
Status r;
scx_extract_event(event, &e); scx_extract_event(event, &e);
Status r = XSendEvent(scx_extract_display(display), r = XSendEvent(scx_extract_display(display),
scx_extract_window(window), scx_extract_window(window),
S48_EXTRACT_BOOLEAN(propagate), S48_EXTRACT_BOOLEAN(propagate),
scx_extract_event_mask(event_mask), scx_extract_event_mask(event_mask),
@ -68,7 +69,7 @@ s48_value scx_add_pending_channel(channel) {
S48_CHECK_CHANNEL(channel); S48_CHECK_CHANNEL(channel);
socket_fd = S48_UNSAFE_EXTRACT_FIXNUM(S48_UNSAFE_CHANNEL_OS_INDEX(channel)); socket_fd = S48_UNSAFE_EXTRACT_FIXNUM(S48_UNSAFE_CHANNEL_OS_INDEX(channel));
if (! s48_add_pending_fd(socket_fd, 1)) // 1 for: yes, is input if (! s48_add_pending_fd(socket_fd, 1)) /* 1 for: yes, is input */
s48_raise_out_of_memory_error(); s48_raise_out_of_memory_error();
return S48_UNSPECIFIC; return S48_UNSPECIFIC;

View File

@ -72,7 +72,7 @@ s48_value scx_List_Fonts_With_Info(s48_value display, s48_value pattern,
res = s48_cons(cell, res); res = s48_cons(cell, res);
} }
S48_GC_UNPROTECT(); S48_GC_UNPROTECT();
XFreeFontNames(fonts); // FontStructs have to be freed later XFreeFontNames(fonts); /* FontStructs have to be freed later */
return res; return res;
} }
@ -95,7 +95,6 @@ s48_value scx_Get_Font_Path(s48_value display) {
s48_value res = S48_NULL; s48_value res = S48_NULL;
S48_DECLARE_GC_PROTECT(1); S48_DECLARE_GC_PROTECT(1);
// Enable/Disable Interrupts ??
sa = XGetFontPath(scx_extract_display(display), &n); sa = XGetFontPath(scx_extract_display(display), &n);
S48_GC_PROTECT_1(res); S48_GC_PROTECT_1(res);

View File

@ -290,7 +290,6 @@ s48_value scx_Set_Dashes(s48_value display, s48_value gc, s48_value dashoffset,
s48_value scx_Set_Clip_Rectangles(s48_value display, s48_value gc, s48_value scx_Set_Clip_Rectangles(s48_value display, s48_value gc,
s48_value x_origin, s48_value y_origin, s48_value x_origin, s48_value y_origin,
s48_value rects, s48_value ordering) { s48_value rects, s48_value ordering) {
//TODO
int i, n = s48_list_length(rects); int i, n = s48_list_length(rects);
XRectangle crects[n]; XRectangle crects[n];
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {

View File

@ -71,8 +71,10 @@ void scx_init_xlib(void) {
} }
//#if defined(XLIB_RELEASE_5_OR_LATER) && (defined(sun) || defined(__sun__)) &&\ /*
// defined(__svr4__) #if defined(XLIB_RELEASE_5_OR_LATER) && (defined(sun) || defined(__sun__)) &&\
defined(__svr4__)
*/
/* /*
* Stub interface to dynamic linker routines * Stub interface to dynamic linker routines
* that SunOS uses but didn't ship with 4.1. * that SunOS uses but didn't ship with 4.1.
@ -81,7 +83,9 @@ void scx_init_xlib(void) {
* load some routines using the dlsym interface, described in dlsym(3x). * load some routines using the dlsym interface, described in dlsym(3x).
* Unfortunately SunOS 4.1 does not include the necessary library, libdl. * Unfortunately SunOS 4.1 does not include the necessary library, libdl.
*/ */
//void *dlopen() { return 0; } /*
//void *dlsym() { return 0; } void *dlopen() { return 0; }
//int dlclose() { return -1; } void *dlsym() { return 0; }
//#endif int dlclose() { return -1; }
#endif
*/

View File

@ -86,7 +86,7 @@ s48_value scx_Set_Modifier_Mapping(s48_value display, s48_value modmap) {
s48_value l2 = S48_CDR(S48_CAR(l)); s48_value l2 = S48_CDR(S48_CAR(l));
int j = 0; int j = 0;
for (j = 0; j < max; j++) { for (j = 0; j < max; j++) {
if ((mod < 0) || (mod > 7)) continue; // TODO: error?? if ((mod < 0) || (mod > 7)) continue; /* TODO: error?? */
if (l2 != S48_NULL) { if (l2 != S48_NULL) {
ks[mod*max + j] = s48_extract_integer(S48_CAR(l2)); ks[mod*max + j] = s48_extract_integer(S48_CAR(l2));
l2 = S48_CDR(l2); l2 = S48_CDR(l2);

View File

@ -141,7 +141,7 @@ s48_value scx_enter_property(Atom type, int format, char* data,
l = s48_cons(s48_enter_integer(((long*)data)[i]), l); l = s48_cons(s48_enter_integer(((long*)data)[i]), l);
S48_RECORD_SET(p, 2, l); S48_RECORD_SET(p, 2, l);
break; break;
default: // should not be possible default: /* should not be possible */
S48_RECORD_SET(p, 1, s48_enter_integer(format)); S48_RECORD_SET(p, 1, s48_enter_integer(format));
S48_RECORD_SET(p, 2, S48_FALSE); S48_RECORD_SET(p, 2, S48_FALSE);
} }
@ -176,7 +176,7 @@ s48_value scx_Get_Window_Property(s48_value display, s48_value window,
S48_GC_UNPROTECT(); S48_GC_UNPROTECT();
return res; return res;
} else } else
// Property does not exists /* Property does not exists */
return S48_FALSE; return S48_FALSE;
} }

View File

@ -48,7 +48,7 @@ void scx_extract_text_item(s48_value v, XTextItem* ti) {
} }
ti->delta = s48_extract_integer(S48_RECORD_REF(v, 1)); ti->delta = s48_extract_integer(S48_RECORD_REF(v, 1));
ti->font = scx_extract_font(S48_RECORD_REF(v, 2)); ti->font = scx_extract_font(S48_RECORD_REF(v, 2));
// Free all chars arrays! /* Free all chars arrays! */
} }
void scx_extract_text_item_16(s48_value v, XTextItem16* ti) { void scx_extract_text_item_16(s48_value v, XTextItem16* ti) {
@ -70,7 +70,7 @@ void scx_extract_text_item_16(s48_value v, XTextItem16* ti) {
ti->delta = s48_extract_integer(S48_RECORD_REF(v, 1)); ti->delta = s48_extract_integer(S48_RECORD_REF(v, 1));
ti->font = scx_extract_font(S48_RECORD_REF(v, 2)); ti->font = scx_extract_font(S48_RECORD_REF(v, 2));
} }
// Free all chars arrays! /* Free all chars arrays! */
} }
s48_value scx_Draw_Text(s48_value display, s48_value drawable, s48_value scx_Draw_Text(s48_value display, s48_value drawable,

View File

@ -17,6 +17,16 @@ int s48_list_length(s48_value list) {
return res; return res;
} }
extern unsigned long s48_extract_enum_set(s48_value v, char* typestr) {
s48_value enum_set_type = s48_get_imported_binding("s48-enum-set-type");
s48_value type = s48_get_imported_binding(typestr);
s48_check_record_type(v, enum_set_type);
if (S48_UNSAFE_SHARED_BINDING_REF(type) !=
S48_UNSAFE_RECORD_REF(v, 0))
s48_raise_argument_type_error(v);
return s48_extract_integer(S48_UNSAFE_RECORD_REF(v, 1));
}
s48_value s48_enter_enum_set(unsigned long v, char* typestr) { s48_value s48_enter_enum_set(unsigned long v, char* typestr) {
s48_value r = s48_make_record(s48_get_imported_binding("s48-enum-set-type")); s48_value r = s48_make_record(s48_get_imported_binding("s48-enum-set-type"));
S48_DECLARE_GC_PROTECT(1); S48_DECLARE_GC_PROTECT(1);
@ -44,13 +54,13 @@ void scx_struct_cache_set(void* cpointer, s48_value* l, s48_value v) {
S48_DECLARE_GC_PROTECT(3); S48_DECLARE_GC_PROTECT(3);
S48_GC_PROTECT_3(list, pair, previous); S48_GC_PROTECT_3(list, pair, previous);
// create the new entry /* create the new entry */
pair = s48_make_weak_pointer(v); pair = s48_make_weak_pointer(v);
pair = s48_cons(S48_ENTER_POINTER(cpointer), pair); pair = s48_cons(S48_ENTER_POINTER(cpointer), pair);
*l = s48_cons(pair, *l); *l = s48_cons(pair, *l);
previous = *l; previous = *l;
// remove all empty and duplicate entries /* remove all empty and duplicate entries */
while (list != S48_NULL) { while (list != S48_NULL) {
s48_value entry = S48_CAR(list); s48_value entry = S48_CAR(list);
if ((S48_WEAK_POINTER_REF(S48_CDR(entry)) == S48_FALSE) || if ((S48_WEAK_POINTER_REF(S48_CDR(entry)) == S48_FALSE) ||

View File

@ -39,9 +39,6 @@ s48_value scx_Parse_Geometry(s48_value strg) {
return ret; return ret;
} }
// scx_Parse_Color is in colormap.c
void scx_init_util(void) { void scx_init_util(void) {
S48_EXPORT_FUNCTION(scx_Get_Default); S48_EXPORT_FUNCTION(scx_Get_Default);
S48_EXPORT_FUNCTION(scx_Resource_Manager_String); S48_EXPORT_FUNCTION(scx_Resource_Manager_String);

View File

@ -25,7 +25,7 @@
#define S48_NULL_P(x) S48_EQ(x, S48_NULL) #define S48_NULL_P(x) S48_EQ(x, S48_NULL)
#define S48_INTEGER_P(x) (S48_FIXNUM_P(x) || S48_BIGNUM_P(x)) #define S48_INTEGER_P(x) (S48_FIXNUM_P(x) || S48_BIGNUM_P(x))
// TODO: S48_x_POINTER already exitst ?! /* TODO: S48_x_POINTER already exitst ?!*/
#define S48_POINTER_P(x) S48_INTEGER_P(x) #define S48_POINTER_P(x) S48_INTEGER_P(x)
#define S48_ENTER_POINTER(x) s48_enter_integer((long)x) #define S48_ENTER_POINTER(x) s48_enter_integer((long)x)
#define S48_EXTRACT_POINTER(x) (void*)s48_extract_integer(x) #define S48_EXTRACT_POINTER(x) (void*)s48_extract_integer(x)
@ -38,18 +38,16 @@ extern int s48_list_length(s48_value list);
#define S48_EXTRACT_ENUM(x, typestr) \ #define S48_EXTRACT_ENUM(x, typestr) \
s48_extract_integer(s48_checked_record_ref(x, 1, \ s48_extract_integer(s48_checked_record_ref(x, 1, \
s48_get_imported_binding(typestr))) s48_get_imported_binding(typestr)))
// S48_SHARED_BINDING_REF(s48_get_imported_binding(typestr))))
#define S48_ENTER_ENUM(index, vvectorstr) \ #define S48_ENTER_ENUM(index, vvectorstr) \
S48_VECTOR_REF(S48_SHARED_BINDING_REF(s48_get_imported_binding(vvectorstr)),\ S48_VECTOR_REF(S48_SHARED_BINDING_REF(s48_get_imported_binding(vvectorstr)),\
index) index)
#define S48_EXTRACT_ENUM_SET(x, typestr) \ #define S48_EXTRACT_ENUM_SET(x, typestr) s48_extract_enum_set(x, typestr)
s48_extract_integer(s48_checked_record_ref(x, 1, \ extern unsigned long s48_extract_enum_set(s48_value v, char* typestr);
s48_get_imported_binding("s48-enum-set-type")))
// TODO check type in record-field 0
extern s48_value s48_enter_enum_set(unsigned long v, char* typestr); extern s48_value s48_enter_enum_set(unsigned long v, char* typestr);
// *** Extraction-Macros for the XIDs ******************************** /*** Extraction-Macros for the XIDs ********************************/
#define scx_extract_window(x) (Window)s48_extract_integer(x) #define scx_extract_window(x) (Window)s48_extract_integer(x)
#define scx_enter_window(x) s48_enter_integer((long)x) #define scx_enter_window(x) s48_enter_integer((long)x)
@ -68,7 +66,7 @@ extern s48_value s48_enter_enum_set(unsigned long v, char* typestr);
#define scx_extract_keysym(x) (GContext)s48_extract_integer(x) #define scx_extract_keysym(x) (GContext)s48_extract_integer(x)
#define scx_enter_keysym(x) s48_enter_integer((long)x) #define scx_enter_keysym(x) s48_enter_integer((long)x)
// other CARD32 /* other CARD32 */
#define scx_enter_atom(x) s48_enter_integer((long)x) #define scx_enter_atom(x) s48_enter_integer((long)x)
#define scx_extract_atom(x) (Atom)s48_extract_integer(x) #define scx_extract_atom(x) (Atom)s48_extract_integer(x)
@ -77,14 +75,14 @@ extern s48_value s48_enter_enum_set(unsigned long v, char* typestr);
#define scx_enter_time(x) s48_enter_integer(x) #define scx_enter_time(x) s48_enter_integer(x)
#define scx_extract_time(x) (Time)s48_extract_integer(x) #define scx_extract_time(x) (Time)s48_extract_integer(x)
// other ints /* other ints */
#define scx_enter_keycode(x) s48_enter_fixnum(x) #define scx_enter_keycode(x) s48_enter_fixnum(x)
#define scx_extract_keycode(x) (KeyCode)s48_extract_integer(x) #define scx_extract_keycode(x) (KeyCode)s48_extract_integer(x)
#define scx_extract_pixel(x) (Pixel)s48_extract_integer(x) #define scx_extract_pixel(x) (Pixel)s48_extract_integer(x)
#define scx_enter_pixel(x) s48_enter_integer((long)x) #define scx_enter_pixel(x) s48_enter_integer((long)x)
// records /* records */
#define scx_display s48_get_imported_binding("scx-display") #define scx_display s48_get_imported_binding("scx-display")
#define scx_extract_display(x) \ #define scx_extract_display(x) \
@ -140,10 +138,7 @@ extern unsigned long scx_extract_window_changes(s48_value changes,
extern s48_value scx_enter_x_error(XErrorEvent* xe); extern s48_value scx_enter_x_error(XErrorEvent* xe);
extern void scx_extract_x_error(s48_value e, XErrorEvent* xe); extern void scx_extract_x_error(s48_value e, XErrorEvent* xe);
//#define scx_enter_REGION(x) s48_enter_integer((long)x) /* more types */
//#define scx_extract_REGION(x) (Region)s48_extract_integer(x)
// more types
#define scx_extract_state(x) S48_EXTRACT_ENUM(x, "scx-state") #define scx_extract_state(x) S48_EXTRACT_ENUM(x, "scx-state")
#define scx_enter_state(x) S48_ENTER_ENUM(x, "scx-states") #define scx_enter_state(x) S48_ENTER_ENUM(x, "scx-states")