Reimplement the PropList data structure in Rust.

While this large change has some unit tests, it has not been integration tested
thoroughly. Removing the global case insensitivity flag may be an issue in
particular.

A few of PropList API functions have been modified (mostly to get rid of
varargs). The definition of one such function has been left in C for cleanup
later.
This commit is contained in:
2025-10-23 14:46:56 -04:00
parent 5b593fb19a
commit f3961ba66f
32 changed files with 3417 additions and 1966 deletions
+1 -1
View File
@@ -1360,7 +1360,7 @@ static void wApplicationSaveIconPathFor(const char *iconPath, const char *wm_ins
val = WMGetFromPLDictionary(adict, iconk);
} else {
/* no dictionary for app, so create one */
adict = WMCreatePLDictionary(NULL, NULL);
adict = WMCreateEmptyPLDictionary();
WMPutInPLDictionary(dict, key, adict);
WMReleasePropList(adict);
val = NULL;
+6 -1
View File
@@ -862,7 +862,12 @@ static void initDefaults(void)
unsigned int i;
WDefaultEntry *entry;
WMPLSetCaseSensitive(False);
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* WMPLSetCaseSensitive(False); */
for (i = 0; i < wlengthof(optionList); i++) {
entry = &optionList[i];
+1 -1
View File
@@ -250,7 +250,7 @@ static void SaveHistory(WMArray * history, const char *filename)
int i;
WMPropList *plhistory;
plhistory = WMCreatePLArray(NULL);
plhistory = WMCreateEmptyPLArray();
for (i = 0; i < WMGetArrayItemCount(history); ++i)
WMAddToPLArray(plhistory, WMCreatePLString(WMGetFromArray(history, i)));
+11 -9
View File
@@ -1603,11 +1603,13 @@ static WMPropList *make_icon_state(WAppIcon *btn)
snprintf(buffer, sizeof(buffer), "%hi,%hi", wAppIconGetXIndex(btn), wAppIconGetYIndex(btn));
position = WMCreatePLString(buffer);
node = WMCreatePLDictionary(dCommand, command,
dName, name,
dAutoLaunch, autolaunch,
dLock, lock,
dForced, forced, dBuggyApplication, buggy, dPosition, position, NULL);
node = WMCreatePLDictionary(dCommand, command);
WMPutInPLDictionary(node, dName, name);
WMPutInPLDictionary(node, dAutoLaunch, autolaunch);
WMPutInPLDictionary(node, dLock, lock);
WMPutInPLDictionary(node, dForced, forced);
WMPutInPLDictionary(node, dBuggyApplication, buggy);
WMPutInPLDictionary(node, dPosition, position);
WMReleasePropList(command);
WMReleasePropList(name);
WMReleasePropList(position);
@@ -1642,7 +1644,7 @@ static WMPropList *dockSaveState(WDock *dock)
WMPropList *value, *key;
char buffer[256];
list = WMCreatePLArray(NULL);
list = WMCreateEmptyPLArray();
for (i = (dock->type == WM_DOCK ? 0 : 1); i < dock->max_icons; i++) {
WAppIcon *btn = dock->icon_array[i];
@@ -1657,7 +1659,7 @@ static WMPropList *dockSaveState(WDock *dock)
}
}
dock_state = WMCreatePLDictionary(dApplications, list, NULL);
dock_state = WMCreatePLDictionary(dApplications, list);
if (dock->type == WM_DOCK) {
snprintf(buffer, sizeof(buffer), "Applications%i", dock->screen_ptr->scr_height);
@@ -5072,7 +5074,7 @@ static WMPropList *drawerSaveState(WDock *drawer)
ai = drawer->icon_array[0];
/* Store its name */
pstr = WMCreatePLString(wAppIconGetWmInstance(ai));
drawer_state = WMCreatePLDictionary(dName, pstr, NULL); /* we need this final NULL */
drawer_state = WMCreatePLDictionary(dName, pstr);
WMReleasePropList(pstr);
/* Store its position */
@@ -5114,7 +5116,7 @@ void wDrawersSaveState(WScreen *scr)
make_keys();
all_drawers = WMCreatePLArray(NULL);
all_drawers = WMCreateEmptyPLArray();
for (i=0, dc = scr->drawers;
i < scr->drawer_count;
i++, dc = dc->next) {
+3 -2
View File
@@ -2309,7 +2309,8 @@ static void saveMenuInfo(WMPropList * dict, WMenu * menu, WMPropList * key)
snprintf(buffer, sizeof(buffer), "%i,%i", menu->frame_x, menu->frame_y);
value = WMCreatePLString(buffer);
list = WMCreatePLArray(value, NULL);
list = WMCreateEmptyPLArray();
WMAddToPLArray(list, value);
if (menu->flags.lowered)
WMAddToPLArray(list, WMCreatePLString("lowered"));
WMPutInPLDictionary(dict, key, list);
@@ -2322,7 +2323,7 @@ void wMenuSaveState(WScreen * scr)
WMPropList *menus, *key;
int save_menus = 0;
menus = WMCreatePLDictionary(NULL, NULL);
menus = WMCreateEmptyPLDictionary();
if (scr->switch_menu && scr->switch_menu->flags.buttoned) {
key = WMCreatePLString("SwitchMenu");
+6 -3
View File
@@ -968,8 +968,6 @@ void wScreenSaveState(WScreen * scr)
old_state = scr->session_state;
scr->session_state = WMCreatePLDictionary(NULL, NULL);
WMPLSetCaseSensitive(True);
/* save dock state to file */
if (!wPreferences.flags.nodock) {
wDockSaveState(scr, old_state);
@@ -1009,8 +1007,13 @@ void wScreenSaveState(WScreen * scr)
WMPutInPLDictionary(scr->session_state, dWorkspace, foo);
}
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* clean up */
WMPLSetCaseSensitive(False);
/* WMPLSetCaseSensitive(False); */
wMenuSaveState(scr);
+22 -15
View File
@@ -241,14 +241,15 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
snprintf(buffer, sizeof(buffer), "%u", mask);
shortcut = WMCreatePLString(buffer);
win_state = WMCreatePLDictionary(sName, name,
sCommand, cmd,
sWorkspace, workspace,
sShaded, shaded,
sMiniaturized, miniaturized,
sMaximized, maximized,
sHidden, hidden,
sShortcutMask, shortcut, sGeometry, geometry, NULL);
win_state = WMCreatePLDictionary(sName, name);
WMPutInPLDictionary(win_state, sCommand, cmd);
WMPutInPLDictionary(win_state, sWorkspace, workspace);
WMPutInPLDictionary(win_state, sShaded, shaded);
WMPutInPLDictionary(win_state, sMiniaturized, miniaturized);
WMPutInPLDictionary(win_state, sMaximized, maximized);
WMPutInPLDictionary(win_state, sHidden, hidden);
WMPutInPLDictionary(win_state, sShortcutMask, shortcut);
WMPutInPLDictionary(win_state, sGeometry, geometry);
WMReleasePropList(name);
WMReleasePropList(cmd);
@@ -313,7 +314,7 @@ void wSessionSaveState(WScreen * scr)
return;
}
list = WMCreatePLArray(NULL);
list = WMCreateEmptyPLArray();
wapp_list = WMCreateArray(16);
@@ -487,8 +488,6 @@ void wSessionRestoreState(WScreen *scr)
if (!scr->session_state)
return;
WMPLSetCaseSensitive(True);
apps = WMGetFromPLDictionary(scr->session_state, sApplications);
if (!apps)
return;
@@ -579,8 +578,13 @@ void wSessionRestoreState(WScreen *scr)
if (class)
wfree(class);
}
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* clean up */
WMPLSetCaseSensitive(False);
/* WMPLSetCaseSensitive(False); */
}
void wSessionRestoreLastWorkspace(WScreen * scr)
@@ -594,8 +598,6 @@ void wSessionRestoreLastWorkspace(WScreen * scr)
if (!scr->session_state)
return;
WMPLSetCaseSensitive(True);
wks = WMGetFromPLDictionary(scr->session_state, sWorkspace);
if (!wks || !WMIsPLString(wks))
return;
@@ -605,8 +607,13 @@ void wSessionRestoreLastWorkspace(WScreen * scr)
if (!value)
return;
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* clean up */
WMPLSetCaseSensitive(False);
/* WMPLSetCaseSensitive(False); */
/* Get the workspace number for the workspace name */
w = wGetWorkspaceNumber(scr, value);
+32 -17
View File
@@ -174,15 +174,18 @@ static WMPropList *get_value_from_instanceclass(const char *value)
key = WMCreatePLString(value);
WMPLSetCaseSensitive(True);
if (w_global.domain.window_attr->dictionary)
val = key ? WMGetFromPLDictionary(w_global.domain.window_attr->dictionary, key) : NULL;
if (key)
WMReleasePropList(key);
WMPLSetCaseSensitive(False);
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* WMPLSetCaseSensitive(False); */
return val;
}
@@ -219,8 +222,6 @@ void wDefaultFillAttributes(const char *instance, const char *class,
dn = get_value_from_instanceclass(instance);
dc = get_value_from_instanceclass(class);
WMPLSetCaseSensitive(True);
if ((w_global.domain.window_attr->dictionary) && (useGlobalDefault))
da = WMGetFromPLDictionary(w_global.domain.window_attr->dictionary, AnyWindow);
@@ -311,8 +312,13 @@ void wDefaultFillAttributes(const char *instance, const char *class,
APPLY_VAL(value, no_language_button, ANoLanguageButton);
#endif
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* clean up */
WMPLSetCaseSensitive(False);
/* WMPLSetCaseSensitive(False); */
}
static WMPropList *get_generic_value(const char *instance, const char *class,
@@ -322,8 +328,6 @@ static WMPropList *get_generic_value(const char *instance, const char *class,
value = NULL;
WMPLSetCaseSensitive(True);
/* Search the icon name using class and instance */
if (class && instance) {
char *buffer;
@@ -371,7 +375,12 @@ static WMPropList *get_generic_value(const char *instance, const char *class,
value = WMGetFromPLDictionary(dict, option);
}
WMPLSetCaseSensitive(False);
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* WMPLSetCaseSensitive(False); */
return value;
}
@@ -545,15 +554,13 @@ void wDefaultChangeIcon(const char *instance, const char *class, const char *fil
int same = 0;
if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL);
dict = WMCreateEmptyPLDictionary();
if (dict)
db->dictionary = dict;
else
return;
}
WMPLSetCaseSensitive(True);
if (instance && class) {
char *buffer;
@@ -570,7 +577,7 @@ void wDefaultChangeIcon(const char *instance, const char *class, const char *fil
if (file) {
value = WMCreatePLString(file);
icon_value = WMCreatePLDictionary(AIcon, value, NULL);
icon_value = WMCreatePLDictionary(AIcon, value);
WMReleasePropList(value);
def_win = WMGetFromPLDictionary(dict, AnyWindow);
@@ -600,7 +607,12 @@ void wDefaultChangeIcon(const char *instance, const char *class, const char *fil
if (icon_value)
WMReleasePropList(icon_value);
WMPLSetCaseSensitive(False);
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* WMPLSetCaseSensitive(False); */
}
void wDefaultPurgeInfo(const char *instance, const char *class)
@@ -612,8 +624,6 @@ void wDefaultPurgeInfo(const char *instance, const char *class)
init_wdefaults();
}
WMPLSetCaseSensitive(True);
buffer = wmalloc(strlen(class) + strlen(instance) + 2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
@@ -631,7 +641,12 @@ void wDefaultPurgeInfo(const char *instance, const char *class)
wfree(buffer);
WMReleasePropList(key);
WMPLSetCaseSensitive(False);
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* WMPLSetCaseSensitive(False); */
}
/* --------------------------- Local ----------------------- */
+9 -6
View File
@@ -597,7 +597,7 @@ static void saveSettings(WMWidget *button, void *client_data)
dict = db->dictionary;
if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL);
dict = WMCreateEmptyPLDictionary();
if (dict) {
db->dictionary = dict;
} else {
@@ -609,10 +609,8 @@ static void saveSettings(WMWidget *button, void *client_data)
if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD) < 0)
return;
WMPLSetCaseSensitive(True);
winDic = WMCreatePLDictionary(NULL, NULL);
appDic = WMCreatePLDictionary(NULL, NULL);
winDic = WMCreateEmptyPLDictionary();
appDic = WMCreateEmptyPLDictionary();
/* Save the icon info */
/* The flag "Ignore client suplied icon is not selected" */
@@ -709,8 +707,13 @@ static void saveSettings(WMWidget *button, void *client_data)
UpdateDomainFile(db);
/*
* Rust rewrite note: this API surface has been removed, but we leave in
* a record of where it was invoked to set a value other than the
* default, in case it helps to track down bugs in the future.
*/
/* clean up */
WMPLSetCaseSensitive(False);
/* WMPLSetCaseSensitive(False); */
}
static void applySettings(WMWidget *button, void *client_data)
+2 -2
View File
@@ -852,10 +852,10 @@ void wWorkspaceSaveState(WScreen * scr, WMPropList * old_state)
make_keys();
old_wks_state = WMGetFromPLDictionary(old_state, dWorkspaces);
parr = WMCreatePLArray(NULL);
parr = WMCreateEmptyPLArray();
for (i = 0; i < scr->workspace_count; i++) {
pstr = WMCreatePLString(scr->workspaces[i]->name);
wks_state = WMCreatePLDictionary(dName, pstr, NULL);
wks_state = WMCreatePLDictionary(dName, pstr);
WMReleasePropList(pstr);
if (!wPreferences.flags.noclip) {
pstr = wClipSaveWorkspaceState(scr, i);