mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-16 05:55:45 +01:00
Added old libPropList compatibility through proplist-compat.h
This commit is contained in:
@@ -5,5 +5,5 @@ AUTOMAKE_OPTIONS = no-dependencies
|
|||||||
# is this a kluge? if so, how should i do it?
|
# is this a kluge? if so, how should i do it?
|
||||||
includedir = @includedir@/WINGs
|
includedir = @includedir@/WINGs
|
||||||
|
|
||||||
include_HEADERS = WINGs.h WUtil.h WINGsP.h
|
include_HEADERS = WINGs.h WUtil.h WINGsP.h proplist-compat.h
|
||||||
|
|
||||||
|
|||||||
@@ -757,6 +757,10 @@ WMPropList* WMCreatePLArray(WMPropList *elem, ...);
|
|||||||
|
|
||||||
WMPropList* WMCreatePLDictionary(WMPropList *key, WMPropList *value, ...);
|
WMPropList* WMCreatePLDictionary(WMPropList *key, WMPropList *value, ...);
|
||||||
|
|
||||||
|
WMPropList* WMRetainPropList(WMPropList *plist);
|
||||||
|
|
||||||
|
void WMReleasePropList(WMPropList *plist);
|
||||||
|
|
||||||
void WMInsertInPLArray(WMPropList *plist, int index, WMPropList *item);
|
void WMInsertInPLArray(WMPropList *plist, int index, WMPropList *item);
|
||||||
|
|
||||||
void WMAddToPLArray(WMPropList *plist, WMPropList *item);
|
void WMAddToPLArray(WMPropList *plist, WMPropList *item);
|
||||||
@@ -771,9 +775,7 @@ void WMRemoveFromPLDictionary(WMPropList *plist, WMPropList *key);
|
|||||||
|
|
||||||
WMPropList* WMMergePLDictionaries(WMPropList *dest, WMPropList *source);
|
WMPropList* WMMergePLDictionaries(WMPropList *dest, WMPropList *source);
|
||||||
|
|
||||||
WMPropList* WMRetainPropList(WMPropList *plist);
|
int WMGetPropListItemCount(WMPropList *plist);
|
||||||
|
|
||||||
void WMReleasePropList(WMPropList *plist);
|
|
||||||
|
|
||||||
Bool WMIsPLString(WMPropList *plist);
|
Bool WMIsPLString(WMPropList *plist);
|
||||||
|
|
||||||
@@ -785,8 +787,6 @@ Bool WMIsPLDictionary(WMPropList *plist);
|
|||||||
|
|
||||||
Bool WMIsPropListEqualTo(WMPropList *plist, WMPropList *other);
|
Bool WMIsPropListEqualTo(WMPropList *plist, WMPropList *other);
|
||||||
|
|
||||||
int WMGetPropListItemCount(WMPropList *plist);
|
|
||||||
|
|
||||||
char* WMGetFromPLString(WMPropList *plist);
|
char* WMGetFromPLString(WMPropList *plist);
|
||||||
|
|
||||||
WMData* WMGetFromPLData(WMPropList *plist);
|
WMData* WMGetFromPLData(WMPropList *plist);
|
||||||
@@ -805,10 +805,10 @@ WMPropList* WMShallowCopyPropList(WMPropList *plist);
|
|||||||
|
|
||||||
WMPropList* WMDeepCopyPropList(WMPropList *plist);
|
WMPropList* WMDeepCopyPropList(WMPropList *plist);
|
||||||
|
|
||||||
char* WMGetPropListDescription(WMPropList *plist, Bool indented);
|
|
||||||
|
|
||||||
WMPropList* WMCreatePropListFromDescription(char *desc);
|
WMPropList* WMCreatePropListFromDescription(char *desc);
|
||||||
|
|
||||||
|
char* WMGetPropListDescription(WMPropList *plist, Bool indented);
|
||||||
|
|
||||||
WMPropList* WMReadPropListFromFile(char *file);
|
WMPropList* WMReadPropListFromFile(char *file);
|
||||||
|
|
||||||
Bool WMWritePropListToFile(WMPropList *plist, char *path, Bool atomically);
|
Bool WMWritePropListToFile(WMPropList *plist, char *path, Bool atomically);
|
||||||
|
|||||||
74
WINGs/WINGs/proplist-compat.h
Normal file
74
WINGs/WINGs/proplist-compat.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef _PROPLIST_COMPAT_H_
|
||||||
|
#define _PROPLIST_COMPAT_H_
|
||||||
|
|
||||||
|
#include <WINGs/WUtil.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef WMPropList* proplist_t;
|
||||||
|
|
||||||
|
#define PLSetCaseSensitive(c) WMPLSetCaseSensitive(c)
|
||||||
|
|
||||||
|
#define PLMakeString(bytes) WMCreatePLString(bytes)
|
||||||
|
#define PLMakeData(bytes, length) WMCreatePLDataFromBytes(bytes, length)
|
||||||
|
#define PLMakeArrayFromElements(pl, ...) WMCreatePLArray(pl, ...)
|
||||||
|
#define PLMakeDictionaryFromEntries(key, value, ...) WMCreatePLDictionary(key, value, ...)
|
||||||
|
|
||||||
|
#define PLRetain(pl) WMRetainPropList(pl)
|
||||||
|
#define PLRelease(pl) WMReleasePropList(pl)
|
||||||
|
|
||||||
|
#define PLInsertArrayElement(array, pl, pos) WMInsertInPLArray(array, pos, pl)
|
||||||
|
#define PLAppendArrayElement(array, pl) WMAddToPLArray(array, pl)
|
||||||
|
#define PLRemoveArrayElement(array, pos) WMDeleteFromPLArray(array, pos)
|
||||||
|
#define PLInsertDictionaryEntry(dict, key, value) WMPutInPLDictionary(dict, key, value)
|
||||||
|
#define PLRemoveDictionaryEntry(dict, key) WMRemoveFromPLDictionary(dict, key)
|
||||||
|
#define PLMergeDictionaries(dest, source) WMMergePLDictionaries(dest, source)
|
||||||
|
|
||||||
|
#define PLGetNumberOfElements(pl) WMGetPropListItemCount(pl)
|
||||||
|
|
||||||
|
#define PLIsString(pl) WMIsPLString(pl)
|
||||||
|
#define PLIsData(pl) WMIsPLData(pl)
|
||||||
|
#define PLIsArray(pl) WMIsPLArray(pl)
|
||||||
|
#define PLIsDictionary(pl) WMIsPLDictionary(pl)
|
||||||
|
#define PLIsSimple(pl) (WMIsPLString(pl) || WMIsPLData(pl))
|
||||||
|
#define PLIsCompound(pl) (WMIsPLArray(pl) || WMIsPLDictionary(pl))
|
||||||
|
#define PLIsEqual(pl1, pl2) WMIsPropListEqualTo(pl1, pl2)
|
||||||
|
|
||||||
|
#define PLGetString(pl) WMGetFromPLString(pl)
|
||||||
|
#define PLGetDataBytes(pl) WMGetPLDataBytes(pl)
|
||||||
|
#define PLGetDataLength(pl) WMGetPLDataLength(pl)
|
||||||
|
#define PLGetArrayElement(pl, index) WMGetFromArray(pl, index)
|
||||||
|
#define PLGetDictionaryEntry(pl, key) WMGetFromPLDictionary(pl, key)
|
||||||
|
#define PLGetAllDictionaryKeys(pl) WMGetPLDictionaryKeys(pl)
|
||||||
|
|
||||||
|
#define PLShallowCopy(pl) WMShallowCopyPropList(pl)
|
||||||
|
#define PLDeepCopy(pl) WMDeepCopyPropList(pl)
|
||||||
|
|
||||||
|
#define PLGetProplistWithDescription(desc) WMCreatePropListFromDescription(desc)
|
||||||
|
#define PLGetDescriptionIndent(pl, level) WMGetPropListDescription(pl, True)
|
||||||
|
#define PLGetDescription(pl) WMGetPropListDescription(pl, False)
|
||||||
|
#define PLGetStringDescription(pl) WMGetPropListDescription(pl, False)
|
||||||
|
#define PLGetDataDescription(pl) WMGetPropListDescription(pl, False)
|
||||||
|
|
||||||
|
#define PLGetProplistWithPath(file) WMReadPropListFromFile(file)
|
||||||
|
#define PLSave(pl, file, atm) WMWritePropListToFile(pl, file, atm)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define PLSetStringCmpHook(fn)
|
||||||
|
//#define PLDeepSynchronize(pl) PLDeepSynchronize_is_not_supported
|
||||||
|
//#define PLSynchronize(pl) PLSynchronize_is_not_supported
|
||||||
|
//#define PLShallowSynchronize(pl) error_PLShallowSynchronize_is_not_supported
|
||||||
|
//#define PLSetFilename(pl, filename) error_PLSetFilename_is_not_supported
|
||||||
|
//#define PLGetFilename(pl, filename) error_PLGetFilename_is_not_supported
|
||||||
|
//#define PLGetDomainNames()
|
||||||
|
//#define PLGetDomain(name)
|
||||||
|
//#define PLSetDomain(name, value, kickme)
|
||||||
|
//#define PLDeleteDomain(name, kickme)
|
||||||
|
//#define PLRegister(name, callback)
|
||||||
|
//#define PLUnregister(name)
|
||||||
|
//#define PLGetContainer(pl)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
198
WINGs/proplist.c
198
WINGs/proplist.c
@@ -1031,6 +1031,91 @@ WMCreatePLDictionary(WMPropList *key, WMPropList *value, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WMPropList*
|
||||||
|
WMRetainPropList(WMPropList *plist)
|
||||||
|
{
|
||||||
|
WMPropList *key, *value;
|
||||||
|
WMHashEnumerator e;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
plist->retainCount++;
|
||||||
|
|
||||||
|
switch(plist->type) {
|
||||||
|
case WPLString:
|
||||||
|
case WPLData:
|
||||||
|
break;
|
||||||
|
case WPLArray:
|
||||||
|
for (i=0; i<WMGetArrayItemCount(plist->d.array); i++) {
|
||||||
|
WMRetainPropList(WMGetFromArray(plist->d.array, i));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WPLDictionary:
|
||||||
|
e = WMEnumerateHashTable(plist->d.dict);
|
||||||
|
while (WMNextHashEnumeratorItemAndKey(&e, (void**)&value, (void**)&key)) {
|
||||||
|
WMRetainPropList(key);
|
||||||
|
WMRetainPropList(value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wwarning(_("Used proplist functions on non-WMPropLists objects"));
|
||||||
|
wassertrv(False, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return plist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMReleasePropList(WMPropList *plist)
|
||||||
|
{
|
||||||
|
WMPropList *key, *value;
|
||||||
|
WMHashEnumerator e;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
plist->retainCount--;
|
||||||
|
|
||||||
|
switch(plist->type) {
|
||||||
|
case WPLString:
|
||||||
|
if (plist->retainCount < 1) {
|
||||||
|
wfree(plist->d.string);
|
||||||
|
wfree(plist);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WPLData:
|
||||||
|
if (plist->retainCount < 1) {
|
||||||
|
WMReleaseData(plist->d.data);
|
||||||
|
wfree(plist);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WPLArray:
|
||||||
|
for (i=0; i<WMGetArrayItemCount(plist->d.array); i++) {
|
||||||
|
WMReleasePropList(WMGetFromArray(plist->d.array, i));
|
||||||
|
}
|
||||||
|
if (plist->retainCount < 1) {
|
||||||
|
WMFreeArray(plist->d.array);
|
||||||
|
wfree(plist);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WPLDictionary:
|
||||||
|
e = WMEnumerateHashTable(plist->d.dict);
|
||||||
|
while (WMNextHashEnumeratorItemAndKey(&e, (void**)&value, (void**)&key)) {
|
||||||
|
WMReleasePropList(key);
|
||||||
|
WMReleasePropList(value);
|
||||||
|
}
|
||||||
|
if (plist->retainCount < 1) {
|
||||||
|
WMFreeHashTable(plist->d.dict);
|
||||||
|
wfree(plist);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wwarning(_("Used proplist functions on non-WMPropLists objects"));
|
||||||
|
wassertr(False);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WMInsertInPLArray(WMPropList *plist, int index, WMPropList *item)
|
WMInsertInPLArray(WMPropList *plist, int index, WMPropList *item)
|
||||||
{
|
{
|
||||||
@@ -1129,88 +1214,24 @@ WMMergePLDictionaries(WMPropList *dest, WMPropList *source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WMPropList*
|
int
|
||||||
WMRetainPropList(WMPropList *plist)
|
WMGetPropListItemCount(WMPropList *plist)
|
||||||
{
|
{
|
||||||
WMPropList *key, *value;
|
|
||||||
WMHashEnumerator e;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
plist->retainCount++;
|
|
||||||
|
|
||||||
switch(plist->type) {
|
switch(plist->type) {
|
||||||
case WPLString:
|
case WPLString:
|
||||||
case WPLData:
|
case WPLData:
|
||||||
break;
|
return 0; /* should this be 1 instead? */
|
||||||
case WPLArray:
|
case WPLArray:
|
||||||
for (i=0; i<WMGetArrayItemCount(plist->d.array); i++) {
|
return WMGetArrayItemCount(plist->d.array);
|
||||||
WMRetainPropList(WMGetFromArray(plist->d.array, i));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WPLDictionary:
|
case WPLDictionary:
|
||||||
e = WMEnumerateHashTable(plist->d.dict);
|
return (int)WMCountHashTable(plist->d.dict);
|
||||||
while (WMNextHashEnumeratorItemAndKey(&e, (void**)&value, (void**)&key)) {
|
|
||||||
WMRetainPropList(key);
|
|
||||||
WMRetainPropList(value);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
wwarning(_("Used proplist functions on non-WMPropLists objects"));
|
wwarning(_("Used proplist functions on non-WMPropLists objects"));
|
||||||
wassertrv(False, NULL);
|
wassertrv(False, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return plist;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
WMReleasePropList(WMPropList *plist)
|
|
||||||
{
|
|
||||||
WMPropList *key, *value;
|
|
||||||
WMHashEnumerator e;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
plist->retainCount--;
|
|
||||||
|
|
||||||
switch(plist->type) {
|
|
||||||
case WPLString:
|
|
||||||
if (plist->retainCount < 1) {
|
|
||||||
wfree(plist->d.string);
|
|
||||||
wfree(plist);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WPLData:
|
|
||||||
if (plist->retainCount < 1) {
|
|
||||||
WMReleaseData(plist->d.data);
|
|
||||||
wfree(plist);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WPLArray:
|
|
||||||
for (i=0; i<WMGetArrayItemCount(plist->d.array); i++) {
|
|
||||||
WMReleasePropList(WMGetFromArray(plist->d.array, i));
|
|
||||||
}
|
|
||||||
if (plist->retainCount < 1) {
|
|
||||||
WMFreeArray(plist->d.array);
|
|
||||||
wfree(plist);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WPLDictionary:
|
|
||||||
e = WMEnumerateHashTable(plist->d.dict);
|
|
||||||
while (WMNextHashEnumeratorItemAndKey(&e, (void**)&value, (void**)&key)) {
|
|
||||||
WMReleasePropList(key);
|
|
||||||
WMReleasePropList(value);
|
|
||||||
}
|
|
||||||
if (plist->retainCount < 1) {
|
|
||||||
WMFreeHashTable(plist->d.dict);
|
|
||||||
wfree(plist);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
wwarning(_("Used proplist functions on non-WMPropLists objects"));
|
|
||||||
wassertr(False);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1293,27 +1314,6 @@ WMIsPropListEqualTo(WMPropList *plist, WMPropList *other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
WMGetPropListItemCount(WMPropList *plist)
|
|
||||||
{
|
|
||||||
switch(plist->type) {
|
|
||||||
case WPLString:
|
|
||||||
case WPLData:
|
|
||||||
return 0; /* should this be 1 instead? */
|
|
||||||
case WPLArray:
|
|
||||||
return WMGetArrayItemCount(plist->d.array);
|
|
||||||
case WPLDictionary:
|
|
||||||
return (int)WMCountHashTable(plist->d.dict);
|
|
||||||
default:
|
|
||||||
wwarning(_("Used proplist functions on non-WMPropLists objects"));
|
|
||||||
wassertrv(False, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
WMGetFromPLString(WMPropList *plist)
|
WMGetFromPLString(WMPropList *plist)
|
||||||
{
|
{
|
||||||
@@ -1482,13 +1482,6 @@ WMDeepCopyPropList(WMPropList *plist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char*
|
|
||||||
WMGetPropListDescription(WMPropList *plist, Bool indented)
|
|
||||||
{
|
|
||||||
return (indented ? indentedDescription(plist, 0) : description(plist));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WMPropList*
|
WMPropList*
|
||||||
WMCreatePropListFromDescription(char *desc)
|
WMCreatePropListFromDescription(char *desc)
|
||||||
{
|
{
|
||||||
@@ -1520,6 +1513,13 @@ WMCreatePropListFromDescription(char *desc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char*
|
||||||
|
WMGetPropListDescription(WMPropList *plist, Bool indented)
|
||||||
|
{
|
||||||
|
return (indented ? indentedDescription(plist, 0) : description(plist));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WMPropList*
|
WMPropList*
|
||||||
WMReadPropListFromFile(char *file)
|
WMReadPropListFromFile(char *file)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user