Commit 999def9f authored by Raymond Toy's avatar Raymond Toy
Browse files

Merge branch 'clm-oids' of /Volumes/share2/src/clnet/rkreuter/cmucl into clm-oids

parents 1daac74f c18c16cd
......@@ -66,10 +66,16 @@
(message-write-string message value)))
(xlib:font (message-write-xid message (xlib:font-id value) :font))
(xlib:cursor (message-write-xid message (xlib:cursor-id value) :cursor))
;; Wart: events are written back to motifd through here as integers.
((unsigned-byte 24)
(message-put-dblword message (combine-type-and-data :short value)))
(if (eql type :event)
(progn
(message-put-dblword message (combine-type-and-data :event 0))
(message-put-dblword message value))
(message-put-dblword message (combine-type-and-data :short value))))
((or (signed-byte 32) (unsigned-byte 32))
(message-put-dblword message (combine-type-and-data :int 0))
(message-put-dblword
message (combine-type-and-data (if (eql type :event) :event :int) 0))
(message-put-dblword message value))
((member t nil)
(if (eq type t)
......
CFLAGS = -g -O2 -I/opt/local/include -I/sw/include -I/usr/local/include -I/usr/X11R6/include -I. -I$(VPATH)
LDFLAGS = -L/opt/local/lib -L/usr/X11R6/lib -L/sw/lib -L/usr/local/lib
LIBS = -lXm -lXt -lXext -lX11 -lSM -lICE
LIBS = -lXft -lXm -lXt -lXext -lX11 -lSM -lICE
#LIBS = -lXm -lXt -lXext -lX11 -lSM -lICE -llanginfo
# This def assumes you are building in the same or parallel
# tree to the CVS souce layout. Sites may need to customize
......
......@@ -5,7 +5,7 @@ LDFLAGS =
TARGET = motifd
OBJS = main.o server.o translations.o packet.o message.o datatrans.o \
requests.o callbacks.o widgets.o resources.o tables.o motif.o \
text.o xmstring.o list.o events.o
text.o xmstring.o list.o events.o oid.o
include Config
......
......@@ -51,6 +51,7 @@
#include "datatrans.h"
#include "types.h"
#include "tables.h"
#include "oid.h"
int end_callback_loop = 0;
extern message_t prepare_reply(message_t m);
......@@ -273,7 +274,7 @@ void CallbackHandler(Widget *w, int name_token, XmAnyCallbackStruct *info)
/* Now, we write the Reason structure into the message */
message_write_enum(reply,info?info->reason:0,callback_reason_tag);
message_write_int(reply,info?info->event:0,int_tag);
message_write_int(reply,info?intern_object(info->event):0,int_tag);
if( class==xmArrowButtonWidgetClass || class==xmArrowButtonGadgetClass ||
class==xmPushButtonWidgetClass || class==xmPushButtonGadgetClass )
......
......@@ -21,6 +21,10 @@
#include "types.h"
#include "datatrans.h"
#include "tables.h"
#include "oid.h"
void message_write_oid(message_t,void *,int);
void message_read_oid(message_t,caddr_t*,int,int);
void packet_write_string(packet_t packet,String string,int count)
{
......@@ -93,8 +97,7 @@ void message_write_function(message_t message, int value,int type_tag)
void message_write_widget(message_t message,Widget widget,int type_tag)
{
message_put_dblword(message,combine_type_and_data(type_tag,0));
message_put_dblword(message,(long)widget);
message_write_oid(message,widget,type_tag);
}
void message_write_widget_class(message_t message,WidgetClass class,int tag)
......@@ -117,10 +120,16 @@ void message_write_xid(message_t message,XID value,int tag)
message_put_dblword(message,value);
}
void message_write_atom(message_t message,Atom value,int tag)
void message_write_oid(message_t message,void *value,int tag)
{
int oid = intern_object(value);
message_put_dblword(message,combine_type_and_data(tag,0));
message_put_dblword(message,value);
message_put_dblword(message,oid);
}
void message_write_atom(message_t message,Atom value,int tag)
{
message_write_oid(message,(void*)value,tag);
}
void message_write_enum(message_t message,int enumval,int tag)
......@@ -208,26 +217,22 @@ void message_write_resource_names(message_t message,ResourceList *list,int tag)
void message_write_xm_string(message_t message,XmString xs,int tag)
{
message_put_dblword(message,combine_type_and_data(tag,0));
message_put_dblword(message,(long)xs);
message_write_oid(message,xs,tag);
}
void message_write_translation_table(message_t m,XtTranslations t,int tag)
{
message_put_dblword(m,combine_type_and_data(tag,0));
message_put_dblword(m,(unsigned long)t);
message_write_oid(m,t,tag);
}
void message_write_accelerator_table(message_t m,XtAccelerators a,int tag)
{
message_put_dblword(m,combine_type_and_data(tag,0));
message_put_dblword(m,(unsigned long)a);
message_write_oid(m,a,tag);
}
void message_write_font_list(message_t m,XmFontList flist,int tag)
{
message_put_dblword(m,combine_type_and_data(tag,0));
message_put_dblword(m,(unsigned long)flist);
message_write_oid(m,flist,tag);
}
void message_write_string_table(message_t m,StringTable *items,int tag)
......@@ -248,6 +253,11 @@ void message_write_xm_string_table(message_t m,StringTable *items,int tag)
message_write_xm_string(m,(XmString)items->data[i],xm_string_tag);
}
void message_write_event(message_t m,XEvent *event,int tag)
{
message_write_oid(m,event,tag);
}
void message_write_color(message_t m,XColor *color,int tag)
{
message_put_dblword(m,combine_type_and_data(tag,color->red));
......@@ -265,7 +275,7 @@ void message_write_float(message_t m,float f,int tag)
void message_read_widget(message_t message,Widget *w,int tag,int data)
{
*w = (Widget)message_get_dblword(message);
message_read_oid(message,(void*)w,tag,data);
}
void message_read_widget_class(message_t message,WidgetClass *c,
......@@ -340,7 +350,7 @@ void message_read_xm_string(message_t message,XmString *xs,int tag,int data)
register_garbage(xmstring,GarbageXmString);
}
else
*xs = (XmString)message_get_dblword(message);
message_read_oid(message,(void*)xs,tag,data);
}
/* used to be int *val here, but many places pass address of Boolean into
......@@ -371,9 +381,15 @@ void message_read_xid(message_t message,XID *id,int tag,int data)
*id = message_get_dblword(message);
}
void message_read_oid(message_t message,caddr_t *obj,int tag,int data)
{
int oid = message_get_dblword(message);
*obj = find_object(oid);
}
void message_read_atom(message_t message,Atom *a,int tag,int data)
{
*a = message_get_dblword(message);
message_read_oid(message,(void*)a,tag,data);
}
void message_read_enum(message_t message,int *enumval,int tag,int data)
......@@ -456,18 +472,18 @@ void message_read_int_list(message_t message,IntList *list,int tag,int length)
void message_read_translation_table(message_t m,XtTranslations *t,
int tag,int data)
{
*t = (XtTranslations)message_get_dblword(m);
message_read_oid(m,(void*)t,tag,data);
}
void message_read_accelerator_table(message_t m,XtAccelerators *a,
int tag,int data)
{
*a = (XtAccelerators)message_get_dblword(m);
message_read_oid(m,(void*)a,tag,data);
}
void message_read_font_list(message_t m,XmFontList *flist,int tag,int data)
{
*flist = (XmFontList)message_get_dblword(m);
message_read_oid(m,(void*)flist,tag,data);
}
void message_read_string_table(message_t m,StringTable *items,int tag,int len)
......@@ -493,6 +509,12 @@ void message_read_xm_string_table(message_t m,StringTable *items,
toolkit_read_value(m,&(items->data[i]),XmRXmString);
}
void message_read_event(message_t message,XEvent *event,int tag,int data)
{
message_read_oid(message,(void*)event,tag,data);
}
void message_read_color(message_t m,XColor *color,int tag, int red)
{
color->red = red;
......
......@@ -35,7 +35,7 @@ extern void message_write_font_list();
extern void message_write_string_table();
extern void message_write_xm_string_table();
extern void message_write_int_list();
#define message_write_event message_write_int
extern void message_write_event();
extern void message_write_color();
/* GCC complains without the full prototype */
extern void message_write_float(message_t,float,int);
......@@ -63,7 +63,7 @@ extern void message_read_font_list();
extern void message_read_string_table();
extern void message_read_xm_string_table();
extern void message_read_int_list();
#define message_read_event message_read_int
extern void message_read_event();
extern void message_read_color();
extern void message_read_float();
......
......@@ -23,8 +23,7 @@ extern int end_callback_loop;
void write_any_event(message_t reply,XEvent *event)
{
message_put_dblword(reply,combine_type_and_data(event_tag,0));
message_put_dblword(reply,(unsigned long)event);
message_write_event(reply,event,event_tag);
message_put_dblword(reply,event->xany.type);
message_put_dblword(reply,event->xany.serial);
message_put_dblword(reply,event->xany.send_event);
......
#include <stdio.h>
#include <X11/Intrinsic.h>
#include "global.h"
#include "oid.h"
/* OID generation. */
static unsigned int current_oid;
static void init_oids()
{
current_oid = (unsigned int)0;
}
static unsigned int next_oid()
{
if (current_oid == 0xffffffff)
fatal_error("next_oid: ran out of oids"); /* This should be smarter.*/
return (++current_oid);
}
/* For expediency of implementation, the table of pointer-to-OID
associations will be a doubly-linked list. */
typedef struct oblist oblist_t;
struct oblist {
oblist_t *next;
oblist_t *prev;
void *obj;
int oid;
};
static oblist_t *oblist = NULL;
static oblist_t *find_node_if(int(*fn)(oblist_t*,void*), void *datum)
{
oblist_t *ret = NULL;
oblist_t *node = oblist;
while (node != NULL) {
if (fn(node, datum)==1) {
ret = node;
break;
}
node = node->next;
}
return ret;
}
static int obj_eql(oblist_t *node, void *obj) {
return (node->obj == obj);
}
static int id_eql(oblist_t *node, void *oidp) {
return (node->oid == *(int*)oidp);
}
void *find_object(unsigned int oid)
{
oblist_t *node = find_node_if(&id_eql, &oid);
if (node != NULL)
return node->obj;
else
return NULL;
}
unsigned int intern_object(void *obj)
{
oblist_t *node = find_node_if(&obj_eql, obj);
if (node != NULL)
return node->oid;
if (oblist == NULL)
init_oids();
if ((node = (void*)XtCalloc(1, sizeof(oblist_t))) == NULL)
fatal_error("intern_object: out of memory");
node->next = oblist;
node->prev = NULL;
if (node->next) node->next->prev = node;
node->obj = obj;
node->oid = next_oid();
oblist = node;
return node->oid;
}
static int unintern_if(int(*fn)(oblist_t*,void*), void *datum)
{
oblist_t *node;
node = find_node_if(fn,datum);
if (node == NULL)
return 0;
if (node == oblist) oblist = node->next;
if (node->prev) (node->prev)->next = node->next;
if (node->next) (node->next)->prev = node->prev;
XtFree((char*)node);
return 1;
}
void unintern_object(void * obj)
{
if (unintern_if(&obj_eql, obj)==0) {
if( global_will_trace ) {
printf("unintern_object: couldn't unintern %p\n",obj);
fflush(stdout);}
}
}
void maybe_unintern_object(void * obj)
{
unintern_if(&obj_eql, obj);
}
extern unsigned int intern_object(void *);
extern void *find_object(unsigned int);
extern void unintern_object(void *);
extern void unintern_object(void *);
extern void maybe_unintern_object(void *);
......@@ -21,6 +21,7 @@
#include "types.h"
#include "functions.h"
#include "tables.h"
#include "oid.h"
typedef void (*request_f)(message_t);
Boolean must_confirm = False;
......@@ -60,11 +61,13 @@ void cleanup_garbage()
garbage_list = NULL;
while( current ) {
if( current->kind == GarbageXmString )
if( current->kind == GarbageXmString ) {
maybe_unintern_object(current->junk);
XmStringFree( (XmString)current->junk );
else
} else {
maybe_unintern_object(current->junk);
XtFree( current->junk );
}
doomed = current;
current = current->next;
XtFree( (char *)doomed );
......
......@@ -20,6 +20,7 @@
#include "global.h"
#include "datatrans.h"
#include "tables.h"
#include "oid.h"
extern WidgetClass overrideShellWidgetClass,transientShellWidgetClass,
topLevelShellWidgetClass,applicationShellWidgetClass;
......@@ -190,7 +191,9 @@ void record_class_resources(WidgetClass class,class_resources *r)
r->resource_count = resource_count;
r->constraint_count = constraint_count;
maybe_unintern_object(resource_list);
XtFree( (char *)resource_list );
maybe_unintern_object(resource_list);
XtFree( (char *)constraint_list );
}
......
......@@ -18,7 +18,7 @@
#include "types.h"
#include "tables.h"
#include "requests.h"
#include "oid.h"
/* Functions for building XmFontLists */
......@@ -61,6 +61,7 @@ void RXmFontListFree(message_t message)
XmFontList flist;
toolkit_read_value(message,&flist,XmRFontList);
unintern_object(flist);
XmFontListFree(flist);
}
......@@ -189,6 +190,7 @@ void RXmStringFree(message_t message)
XmString s;
toolkit_read_value(message,&s,XmRXmString);
unintern_object(s);
XmStringFree(s);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment