Skip to content

Restrict the usage of the (former) string table to resource names.

Richard M Kreuter requested to merge rkreuter/cmucl:bug-116 into master

Addresses bug #116.

tl;dr all resource names are strings in motifd, but not all strings are resource names. To whatever degree it's useful to communicate resource names by index, use a different code path for that than for strings.

Suggested bottom-up reading order:

src/motif/lisp/string-base.lisp: change the Lisp-side global table into a table of symbols, and encapsulate that table in a couple interfaces for the rest of the system.

src/motif/lisp/internals.lisp: remove the old string table variable & declare the interfaces from string-base.lisp as forward declarations for the rest of the system.

src/motif/lisp/xt-types.lisp: add "toolkit type" name, :RESOURCE-NAME, and get rid of :STRING-TOKEN.

src/motif/lisp/conversion.lisp: This is the heart of the matter. Add a case to TOOLKIT-WRITE-VALUE for :RESOURCE-NAME: resource names are written using MESSAGE-WRITE-RESOURCE-NAME. Change MESSAGE-WRITE-RESOURCE-LIST and MESSAGE-WRITE-RESOURCE-NAMES to call MESSAGE-WRITE-RESOURCE-NAME. Remove any "tokenization" from MESSAGE-WRITE-STRING. Add a case to TOOLKIT-READ-VALUE for :RESOURCE-NAME, & remove the case for :STRING-TOKEN. As far as Lisp is concerned above the level of this file's abstractions, there are only resource name symbols, no tokens, no strings.

src/motif/server/global.h: add a custom "resource representation name" for resource names, ExtRResourceName; and a fake one for resource names' indices in the global table. Also kill the representation name for string tokens.

src/motif/server/tables.h and src/motif/server/tables.c: add resource_name_tag, remove string_token_tag. Rename the string_table to resource_name_table. Remove tokenize_string (nobody needs it).

src/motif/server/server.c: add resource_name_tag's initialization, remove string_token_tag.

src/motif/server/datatrans.h and src/motif/server/datatrans.c: the counterparts of the changes in conversion.lisp. Add message_read_resource_name, and get toolkit_read_value to use it by supplying ExtRResourceName in message_read_resource_list and message_read_resource_names. Add error stub for writing resource names (nothing needs to write them back to Lisp). Remove "tokenizing" from the I/O path for strings. Get rid of the string_token I/O functions, but add a case in toolkit_read_value for the one code path where string_token was important (in callbacks.c, described below).

src/motif/lisp/prototypes.lisp: now that there's a "toolkit type" of :RESOURCE-NAME, use it as an annotation in any DEF-TOOLKIT-REQUEST forms that need it. (%GET-VALUES and %SET-VALUES already used :RESOURCE-LIST and :RESOURCE-NAMES respectively, so the changes in conversion.lisp take care of those.

src/motif/lisp/widgets.lisp: because conversion.lisp now knows how to turn resource name symbols into indices directly, CONVERT-RESOURCE-LIST and CONVERT-RESOURCE-NAMES, and any other runtime conversion of a resource name symbol into a string goes away.

src/motif/lisp/callbacks.lisp: because conversion.lisp now knows how to turn resource name symbols into indices directly, runtime conversion of resource name symbols into strings goes away. (And so most of the lines of diff in this file are just renaming arguments from SYM-NAME to NAME, since there's no longer a non-symbol name.)

src/motif/server/callbacks.c: this is the trickiest bit. (Context: when setting/removing/invoking callbacks, motifd uses the index of the callback list name, rather than the name itself, for the callback function's client_data. This is presumably an optimization: to avoid having to looking up a name when the callback gets invoked. This appears to have been the only reason the string_token "toolkit type" was present; since the uses of these indices is so contained, it seemed simplest to get rid of that type entirely.) In RXtAddCallback and RxtRemoveCallback, replace the use of the resource representation, ExtRStringToken, with ExtRResourceNameIndex, so that toolkit_read_value will return the index of a resource name sent from Lisp, rather than the resource name itself; and in CallbackHandler, bypass the toolkit_write/message_write layer, and instead tag and put the resource name index directly.

src/motif/lisp/interface-build.lisp: use the interfaces added to string-base.lisp for building the C-side header file, which is now named ResourceNameTable.h.

src/motif/server/GNUmakefile: change dependency from StringTable.h to ResourceNameTable.h.

Merge request reports