mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-02-21 01:52:36 +01:00
Further refactor of plist.
This commit is contained in:
parent
2607bd4fbb
commit
85716960f9
@ -412,11 +412,11 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
|
|||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, (UINT32)PrefBufferLen);
|
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, (UINT32)PrefBufferLen);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
dict = GetProperty(PrefDict, "Custom Profile");
|
dict = PrefDict->dictPropertyForKey("Custom Profile");
|
||||||
if (dict) {
|
if (dict) {
|
||||||
dict2 = GetProperty(dict, "AC Power");
|
dict2 = dict->dictPropertyForKey("AC Power");
|
||||||
if (dict2) {
|
if (dict2) {
|
||||||
prop = GetProperty(dict2, "Hibernate File");
|
prop = dict2->dictPropertyForKey("Hibernate File");
|
||||||
if (prop && prop->isString() ) {
|
if (prop && prop->isString() ) {
|
||||||
if (prop->stringValue().contains("/Volumes/")) {
|
if (prop->stringValue().contains("/Volumes/")) {
|
||||||
CHAR8 *VolNameStart = NULL, *VolNameEnd = NULL;
|
CHAR8 *VolNameStart = NULL, *VolNameEnd = NULL;
|
||||||
@ -457,6 +457,7 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PrefDict->FreeTag();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,8 +1030,7 @@ VOID
|
|||||||
PutNvramPlistToRtVars ()
|
PutNvramPlistToRtVars ()
|
||||||
{
|
{
|
||||||
// EFI_STATUS Status;
|
// EFI_STATUS Status;
|
||||||
const TagStruct* ValTag;
|
size_t Size;
|
||||||
INTN Size, i;
|
|
||||||
const VOID *Value;
|
const VOID *Value;
|
||||||
|
|
||||||
if (gNvramDict == NULL) {
|
if (gNvramDict == NULL) {
|
||||||
@ -1041,37 +1040,44 @@ PutNvramPlistToRtVars ()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( !gNvramDict->isDict() ) {
|
||||||
|
DBG("PutNvramPlistToRtVars: MALFORMED PLIST nvram.plist. Root must be a dict\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
DbgHeader("PutNvramPlistToRtVars");
|
DbgHeader("PutNvramPlistToRtVars");
|
||||||
// DBG("PutNvramPlistToRtVars ...\n");
|
// DBG("PutNvramPlistToRtVars ...\n");
|
||||||
// iterate over dict elements
|
// iterate over dict elements
|
||||||
for (size_t tagIdx = 0 ; tagIdx < gNvramDict->dictOrArrayContent().size() ; tagIdx++ )
|
size_t count = gNvramDict->dictKeyCount(); // ok
|
||||||
|
for (size_t tagIdx = 0 ; tagIdx < count ; tagIdx++ )
|
||||||
{
|
{
|
||||||
const TagStruct& Tag = gNvramDict->dictOrArrayContent()[tagIdx];
|
const TagStruct* keyTag;
|
||||||
|
const TagStruct* valueTag;
|
||||||
|
if ( EFI_ERROR(gNvramDict->dictKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL
|
||||||
|
MsgLog("MALFORMED PLIST nvram.plist. A key is expected at pos : %zu\n", tagIdx);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
EFI_GUID *VendorGuid = &gEfiAppleBootGuid;
|
EFI_GUID *VendorGuid = &gEfiAppleBootGuid;
|
||||||
Value = NULL;
|
Value = NULL;
|
||||||
if ( Tag.isKey() )
|
if ( tagIdx + 1 < gNvramDict->dictContent().size() && !gNvramDict->dictContent()[tagIdx+1].isKey() ) valueTag = &gNvramDict->dictContent()[tagIdx+1];
|
||||||
{
|
|
||||||
ValTag = Tag.keyTagValue();
|
|
||||||
|
|
||||||
// process only valid <key> tags
|
// process only valid <key> tags
|
||||||
if (!Tag.isKey() || ValTag == NULL) {
|
if ( valueTag == NULL ) {
|
||||||
DBG(" ERROR: Tag is not <key> : type %s\n", ValTag->getTypeAsXString8().c_str());
|
DBG(" ERROR: ValTag is not NULL\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// DBG("tag: %s\n", Tag.stringValue());
|
// DBG("tag: %s\n", Tag.stringValue());
|
||||||
// skip OsxAptioFixDrv-RelocBase - appears and causes trouble
|
// skip OsxAptioFixDrv-RelocBase - appears and causes trouble
|
||||||
// in kernel and kext patcher when mixing UEFI and CloverEFI boot
|
// in kernel and kext patcher when mixing UEFI and CloverEFI boot
|
||||||
if ( Tag.keyValue() == "OsxAptioFixDrv-RelocBase"_XS8 ) {
|
if ( keyTag->keyStringValue() == "OsxAptioFixDrv-RelocBase"_XS8 ) {
|
||||||
DBG(" Skipping OsxAptioFixDrv-RelocBase\n");
|
DBG(" Skipping OsxAptioFixDrv-RelocBase\n");
|
||||||
continue;
|
continue;
|
||||||
} else if ( Tag.keyValue() == "OsxAptioFixDrv-ErrorExitingBootServices"_XS8 ) {
|
} else if ( keyTag->keyStringValue() == "OsxAptioFixDrv-ErrorExitingBootServices"_XS8 ) {
|
||||||
DBG(" Skipping OsxAptioFixDrv-ErrorExitingBootServices\n");
|
DBG(" Skipping OsxAptioFixDrv-ErrorExitingBootServices\n");
|
||||||
continue;
|
continue;
|
||||||
} else if ( Tag.keyValue() == "EmuVariableUefiPresent"_XS8 ) {
|
} else if ( keyTag->keyStringValue() == "EmuVariableUefiPresent"_XS8 ) {
|
||||||
DBG(" Skipping EmuVariableUefiPresent\n");
|
DBG(" Skipping EmuVariableUefiPresent\n");
|
||||||
continue;
|
continue;
|
||||||
} else if ( Tag.keyValue() == "aapl,panic-info"_XS8 ) {
|
} else if ( keyTag->keyStringValue() == "aapl,panic-info"_XS8 ) {
|
||||||
DBG(" Skipping aapl,panic-info\n");
|
DBG(" Skipping aapl,panic-info\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1082,36 +1088,36 @@ PutNvramPlistToRtVars ()
|
|||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if ( Tag.keyValue() == "Boot0082"_XS8 || Tag.keyValue() == "BootNext"_XS8 ) {
|
if ( keyTag->keyStringValue() == "Boot0082"_XS8 || keyTag->keyStringValue() == "BootNext"_XS8 ) {
|
||||||
VendorGuid = &gEfiGlobalVariableGuid;
|
VendorGuid = &gEfiGlobalVariableGuid;
|
||||||
// it may happen only in this case
|
// it may happen only in this case
|
||||||
GlobalConfig.HibernationFixup = TRUE;
|
GlobalConfig.HibernationFixup = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsciiStrToUnicodeStrS(Tag.stringValue(), KeyBuf, 128);
|
// AsciiStrToUnicodeStrS(Tag.stringValue(), KeyBuf, 128);
|
||||||
XStringW KeyBuf = Tag.keyValue();
|
XStringW KeyBuf = keyTag->keyStringValue();
|
||||||
if (!GlobalConfig.DebugLog) {
|
if (!GlobalConfig.DebugLog) {
|
||||||
DBG(" Adding Key: %ls: ", KeyBuf.wc_str());
|
DBG(" Adding Key: %ls: ", KeyBuf.wc_str());
|
||||||
}
|
}
|
||||||
// process value tag
|
// process value tag
|
||||||
|
|
||||||
if (ValTag->isString()) {
|
if (valueTag->isString()) {
|
||||||
|
|
||||||
// <string> element
|
// <string> element
|
||||||
Value = (void*)ValTag->stringValue().c_str();
|
Value = (void*)valueTag->stringValue().c_str();
|
||||||
Size = ValTag->stringValue().length();
|
Size = valueTag->stringValue().length();
|
||||||
if (!GlobalConfig.DebugLog) {
|
if (!GlobalConfig.DebugLog) {
|
||||||
DBG("String: Size = %lld, Val = '%s'\n", Size, ValTag->stringValue().c_str());
|
DBG("String: Size = %zu, Val = '%s'\n", Size, valueTag->stringValue().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ValTag->isData()) {
|
} else if (valueTag->isData()) {
|
||||||
|
|
||||||
// <data> element
|
// <data> element
|
||||||
Size = ValTag->dataLenValue();
|
Size = valueTag->dataLenValue();
|
||||||
Value = ValTag->dataValue();
|
Value = valueTag->dataValue();
|
||||||
if (!GlobalConfig.DebugLog) {
|
if (!GlobalConfig.DebugLog) {
|
||||||
DBG("Size = %lld, Data: ", Size);
|
DBG("Size = %zu, Data: ", Size);
|
||||||
for (i = 0; i < Size; i++) {
|
for (size_t i = 0; i < Size; i++) {
|
||||||
DBG("%02hhX ", *(((UINT8*)Value) + i));
|
DBG("%02hhX ", *(((UINT8*)Value) + i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1119,7 +1125,7 @@ PutNvramPlistToRtVars ()
|
|||||||
DBG("\n");
|
DBG("\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DBG("ERROR: Unsupported tag type: %s\n", ValTag->getTypeAsXString8().c_str());
|
DBG("ERROR: Unsupported tag type: %s\n", valueTag->getTypeAsXString8().c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,7 +1151,6 @@ PutNvramPlistToRtVars ()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Performs detailed search for Startup Disk or last Clover boot volume
|
/** Performs detailed search for Startup Disk or last Clover boot volume
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -111,14 +111,14 @@ VOID FillCardList(const TagStruct* CfgDict)
|
|||||||
for (Index = 0; Index < Count; Index++) {
|
for (Index = 0; Index < Count; Index++) {
|
||||||
CONST CHAR8 *key = VEN[Index];
|
CONST CHAR8 *key = VEN[Index];
|
||||||
|
|
||||||
prop = GetProperty(CfgDict, key);
|
prop = CfgDict->dictPropertyForKey(key);
|
||||||
if( prop && prop->isArray() ) {
|
if( prop && prop->isArray() ) {
|
||||||
INTN i;
|
INTN i;
|
||||||
INTN count;
|
INTN count;
|
||||||
|
|
||||||
const TagStruct* prop2 = 0;
|
const TagStruct* prop2 = 0;
|
||||||
const TagStruct* element = 0;
|
const TagStruct* element = 0;
|
||||||
count = GetTagCount(prop);
|
count = prop->arrayContent().size();
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
CONST CHAR8 *model_name = NULL;
|
CONST CHAR8 *model_name = NULL;
|
||||||
UINT32 dev_id = 0;
|
UINT32 dev_id = 0;
|
||||||
@ -126,31 +126,33 @@ VOID FillCardList(const TagStruct* CfgDict)
|
|||||||
UINT64 VramSize = 0;
|
UINT64 VramSize = 0;
|
||||||
UINTN VideoPorts = 0;
|
UINTN VideoPorts = 0;
|
||||||
BOOLEAN LoadVBios = FALSE;
|
BOOLEAN LoadVBios = FALSE;
|
||||||
EFI_STATUS status = GetElement(prop, i, &element);
|
element = &prop->arrayContent()[i];
|
||||||
|
if ( !element->isDict()) {
|
||||||
|
MsgLog("MALFORMED PLIST in FillCardList() : element is not a dict");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (status == EFI_SUCCESS) {
|
prop2 = element->dictPropertyForKey("Model");
|
||||||
if (element) {
|
|
||||||
prop2 = GetProperty(element, "Model");
|
|
||||||
if ( prop2->isString() && prop2->stringValue().notEmpty() ) {
|
if ( prop2->isString() && prop2->stringValue().notEmpty() ) {
|
||||||
model_name = prop2->stringValue().c_str();
|
model_name = prop2->stringValue().c_str();
|
||||||
} else {
|
} else {
|
||||||
model_name = "VideoCard";
|
model_name = "VideoCard";
|
||||||
}
|
}
|
||||||
|
|
||||||
prop2 = GetProperty(element, "IOPCIPrimaryMatch");
|
prop2 = element->dictPropertyForKey("IOPCIPrimaryMatch");
|
||||||
dev_id = (UINT32)GetPropertyInteger(prop2, 0);
|
dev_id = (UINT32)GetPropertyAsInteger(prop2, 0);
|
||||||
|
|
||||||
prop2 = GetProperty(element, "IOPCISubDevId");
|
prop2 = element->dictPropertyForKey("IOPCISubDevId");
|
||||||
subdev_id = (UINT32)GetPropertyInteger(prop2, 0);
|
subdev_id = (UINT32)GetPropertyAsInteger(prop2, 0);
|
||||||
|
|
||||||
prop2 = GetProperty(element, "VRAM");
|
prop2 = element->dictPropertyForKey("VRAM");
|
||||||
VramSize = LShiftU64((UINTN)GetPropertyInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes
|
VramSize = LShiftU64((UINTN)GetPropertyAsInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes
|
||||||
|
|
||||||
prop2 = GetProperty(element, "VideoPorts");
|
prop2 = element->dictPropertyForKey("VideoPorts");
|
||||||
VideoPorts = (UINT16)GetPropertyInteger(prop2, VideoPorts);
|
VideoPorts = (UINT16)GetPropertyAsInteger(prop2, VideoPorts);
|
||||||
|
|
||||||
prop2 = GetProperty(element, "LoadVBios");
|
prop2 = element->dictPropertyForKey("LoadVBios");
|
||||||
if (prop2 != NULL && IsPropertyTrue(prop2)) {
|
if (prop2 != NULL && IsPropertyNotNullAndTrue(prop2)) {
|
||||||
LoadVBios = TRUE;
|
LoadVBios = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,9 +160,6 @@ VOID FillCardList(const TagStruct* CfgDict)
|
|||||||
|
|
||||||
AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios);
|
AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ BOOLEAN checkOSBundleRequired(UINT8 loaderType, const TagStruct* dict)
|
|||||||
const TagStruct* osBundleRequiredTag;
|
const TagStruct* osBundleRequiredTag;
|
||||||
XString8 osbundlerequired;
|
XString8 osbundlerequired;
|
||||||
|
|
||||||
osBundleRequiredTag = GetProperty(dict,"OSBundleRequired");
|
osBundleRequiredTag = dict->dictPropertyForKey("OSBundleRequired");
|
||||||
if (osBundleRequiredTag) {
|
if (osBundleRequiredTag) {
|
||||||
osbundlerequired = osBundleRequiredTag->stringValue();
|
osbundlerequired = osBundleRequiredTag->stringValue();
|
||||||
osbundlerequired.lowerAscii();
|
osbundlerequired.lowerAscii();
|
||||||
@ -169,7 +169,7 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = GetProperty(dict,"CFBundleExecutable");
|
prop = dict->dictPropertyForKey("CFBundleExecutable");
|
||||||
if( prop != NULL && prop->isString() && prop->stringValue().notEmpty() ) {
|
if( prop != NULL && prop->isString() && prop->stringValue().notEmpty() ) {
|
||||||
Executable.takeValueFrom(prop->stringValue());
|
Executable.takeValueFrom(prop->stringValue());
|
||||||
// AsciiStrToUnicodeStrS(prop->stringValue(), Executable, 256);
|
// AsciiStrToUnicodeStrS(prop->stringValue(), Executable, 256);
|
||||||
@ -213,6 +213,7 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
|
|||||||
FreePool(infoDictBuffer);
|
FreePool(infoDictBuffer);
|
||||||
FreePool(executableFatBuffer);
|
FreePool(executableFatBuffer);
|
||||||
FreePool(bundlePathBuffer);
|
FreePool(bundlePathBuffer);
|
||||||
|
dict->FreeTag();
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "../libeg/FloatLib.h"
|
#include "../libeg/FloatLib.h"
|
||||||
|
|
||||||
#ifndef DEBUG_ALL
|
#ifndef DEBUG_ALL
|
||||||
#define DEBUG_PLIST 0
|
#define DEBUG_PLIST 1
|
||||||
#else
|
#else
|
||||||
#define DEBUG_PLIST DEBUG_ALL
|
#define DEBUG_PLIST DEBUG_ALL
|
||||||
#endif
|
#endif
|
||||||
@ -45,52 +45,6 @@
|
|||||||
#define DBG(...) DebugLog(DEBUG_PLIST, __VA_ARGS__)
|
#define DBG(...) DebugLog(DEBUG_PLIST, __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XObjArray<TagStruct> gTagsFree;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TagStruct::FreeTag()
|
|
||||||
{
|
|
||||||
// Clear and free the tag.
|
|
||||||
type = kTagTypeNone;
|
|
||||||
|
|
||||||
_string.setEmpty();
|
|
||||||
_intValue = 0;
|
|
||||||
_floatValue = 0;
|
|
||||||
|
|
||||||
if ( _data ) {
|
|
||||||
FreePool(_data);
|
|
||||||
_data = NULL;
|
|
||||||
}
|
|
||||||
_dataLen = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if ( _tag ) {
|
|
||||||
_tag->FreeTag();
|
|
||||||
_tag = NULL;
|
|
||||||
}
|
|
||||||
// while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
|
|
||||||
// _dictOrArrayContent[0].FreeTag();
|
|
||||||
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
|
|
||||||
// }
|
|
||||||
// this loop is better because removing objects from the end don't do any memory copying.
|
|
||||||
for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
|
|
||||||
tagIdx--;
|
|
||||||
_dictOrArrayContent[tagIdx].FreeTag();
|
|
||||||
_dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if ( _nextTag ) {
|
|
||||||
// _nextTag->FreeTag();
|
|
||||||
// _nextTag = NULL;
|
|
||||||
// }
|
|
||||||
|
|
||||||
gTagsFree.AddReference(this, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -112,22 +66,31 @@ EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32*
|
|||||||
|
|
||||||
EFI_STATUS XMLParseNextTag (CHAR8 *buffer, TagStruct**tag, UINT32 *lenPtr);
|
EFI_STATUS XMLParseNextTag (CHAR8 *buffer, TagStruct**tag, UINT32 *lenPtr);
|
||||||
|
|
||||||
TagStruct* NewTag( void );
|
|
||||||
EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr);
|
EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr);
|
||||||
|
|
||||||
/* Function for basic XML character entities parsing */
|
/* Function for basic XML character entities parsing */
|
||||||
typedef struct XMLEntity {
|
class XMLEntity
|
||||||
const CHAR8* name;
|
{
|
||||||
UINTN nameLen;
|
public:
|
||||||
|
const XString8 name;
|
||||||
|
size_t nameLen;
|
||||||
CHAR8 value;
|
CHAR8 value;
|
||||||
} XMLEntity;
|
|
||||||
|
|
||||||
/* This is ugly, but better than specifying the lengths by hand */
|
XMLEntity() : name(), nameLen(0), value(0) { }
|
||||||
#define _e(str,c) {str,sizeof(str)-1,c}
|
XMLEntity(const XString8& _name, CHAR8 _value) : name(_name), nameLen(name.length()), value(_value) { }
|
||||||
CONST XMLEntity ents[] = {
|
|
||||||
_e("quot;",'"'), _e("apos;",'\''),
|
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||||
_e("lt;", '<'), _e("gt;", '>'),
|
XMLEntity(const XMLEntity&) = delete;
|
||||||
_e("amp;", '&')
|
XMLEntity& operator=(const XMLEntity&) = delete;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const XMLEntity ents[] = {
|
||||||
|
{ "quot;"_XS8, '"' },
|
||||||
|
{"apos;"_XS8,'\''},
|
||||||
|
{"lt;"_XS8, '<'},
|
||||||
|
{"gt;"_XS8, '>'},
|
||||||
|
{"amp;"_XS8, '&'}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Replace XML entities by their value */
|
/* Replace XML entities by their value */
|
||||||
@ -163,7 +126,7 @@ XMLDecode(CHAR8* src)
|
|||||||
UINTN i;
|
UINTN i;
|
||||||
s++;
|
s++;
|
||||||
for (i = 0; i < sizeof(ents)/sizeof(ents[0]); i++) {
|
for (i = 0; i < sizeof(ents)/sizeof(ents[0]); i++) {
|
||||||
if ( strncmp(s, ents[i].name, ents[i].nameLen) == 0 ) {
|
if ( ents[i].name.strncmp(s, ents[i].nameLen) == 0 ) {
|
||||||
entFound = TRUE;
|
entFound = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -181,55 +144,154 @@ XMLDecode(CHAR8* src)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
INTN GetTagCount(const TagStruct* dict )
|
|
||||||
|
/**************************************** TagStruct ****************************************/
|
||||||
|
|
||||||
|
XObjArray<TagStruct> gTagsFree;
|
||||||
|
|
||||||
|
//UINTN newtagcount = 0;
|
||||||
|
//UINTN tagcachehit = 0;
|
||||||
|
TagStruct* TagStruct::getEmptyTag()
|
||||||
{
|
{
|
||||||
|
TagStruct* tag;
|
||||||
|
|
||||||
|
if ( gTagsFree.size() > 0 ) {
|
||||||
|
tag = &gTagsFree[0];
|
||||||
|
gTagsFree.RemoveWithoutFreeingAtIndex(0);
|
||||||
|
//tagcachehit++;
|
||||||
|
//DBG("tagcachehit=%lld\n", tagcachehit);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
tag = new TagStruct();
|
||||||
|
//newtagcount += 1;
|
||||||
|
//DBG("newtagcount=%lld\n", newtagcount);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
TagStruct* TagStruct::getEmptyDictTag()
|
||||||
|
{
|
||||||
|
TagStruct* newDictTag = getEmptyTag();
|
||||||
|
newDictTag->type = kTagTypeDict;
|
||||||
|
return newDictTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
TagStruct* TagStruct::getEmptyArrayTag()
|
||||||
|
{
|
||||||
|
TagStruct* newArrayTag = getEmptyTag();
|
||||||
|
newArrayTag->type = kTagTypeArray;
|
||||||
|
return newArrayTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TagStruct::FreeTag()
|
||||||
|
{
|
||||||
|
// Clear and free the tag.
|
||||||
|
type = kTagTypeNone;
|
||||||
|
|
||||||
|
_string.setEmpty();
|
||||||
|
_intValue = 0;
|
||||||
|
_floatValue = 0;
|
||||||
|
|
||||||
|
if ( _data ) {
|
||||||
|
FreePool(_data);
|
||||||
|
_data = NULL;
|
||||||
|
}
|
||||||
|
_dataLen = 0;
|
||||||
|
|
||||||
|
//while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
|
||||||
|
// _dictOrArrayContent[0].FreeTag();
|
||||||
|
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
|
||||||
|
//}
|
||||||
|
// this loop is better because removing objects from the end don't do any memory copying.
|
||||||
|
for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
|
||||||
|
tagIdx--;
|
||||||
|
_dictOrArrayContent[tagIdx].FreeTag();
|
||||||
|
_dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
gTagsFree.AddReference(this, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INTN TagStruct::dictKeyCount() const
|
||||||
|
{
|
||||||
|
if ( !isDict() ) panic("TagStruct::dictKeyCount() : !isDict() ");
|
||||||
INTN count = 0;
|
INTN count = 0;
|
||||||
|
for (size_t tagIdx = 0 ; tagIdx + 1 < _dictOrArrayContent.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
|
||||||
if ( !dict ) return 0;
|
if ( _dictOrArrayContent[tagIdx].isKey() && !_dictOrArrayContent[tagIdx+1].isKey() ) { // if this key is followed by another key, it'll be ignored
|
||||||
|
count++;
|
||||||
if ( dict->isArray() ) {
|
}
|
||||||
return dict->dictOrArrayContent().size(); // If we are an array, any element is valid
|
|
||||||
}else
|
|
||||||
if ( dict->isDict() ) {
|
|
||||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
|
||||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ ) {
|
|
||||||
if ( tagList[tagIdx].isKey() ) count++;
|
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}else{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS GetElement(const TagStruct* dict, INTN id, const TagStruct** dict1)
|
EFI_STATUS TagStruct::dictKeyAndValueAtIndex(INTN id, const TagStruct** key, const TagStruct** value) const
|
||||||
{
|
{
|
||||||
INTN element = 0;
|
INTN element = 0;
|
||||||
|
*key = NULL;
|
||||||
|
*value = NULL;
|
||||||
|
|
||||||
if ( !dict ) return EFI_UNSUPPORTED;
|
|
||||||
if ( id < 0 ) return EFI_UNSUPPORTED;
|
if ( id < 0 ) return EFI_UNSUPPORTED;
|
||||||
|
|
||||||
if ( dict->isArray() ) {
|
const XObjArray<TagStruct>& tagList = _dictOrArrayContent;
|
||||||
if ( (size_t)id < dict->dictOrArrayContent().size() ) {
|
|
||||||
*dict1 = &dict->dictOrArrayContent()[id];
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
if ( dict->isDict() ) {
|
|
||||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
|
||||||
size_t tagIdx;
|
size_t tagIdx;
|
||||||
for (tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ ) {
|
for (tagIdx = 0 ; tagIdx + 1 < tagList.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
|
||||||
if ( tagList[tagIdx].isKey() ) {
|
if ( tagList[tagIdx].isKey() && !tagList[tagIdx+1].isKey() ) {
|
||||||
if ( element == id ) {
|
if ( element == id ) {
|
||||||
*dict1 = &tagList[tagIdx];
|
*key = &tagList[tagIdx];
|
||||||
|
*value = &tagList[tagIdx+1];
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
element++;
|
element++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TagStruct* TagStruct::dictPropertyForKey(const CHAR8* key) const
|
||||||
|
{
|
||||||
|
const XObjArray<TagStruct>& tagList = _dictOrArrayContent;
|
||||||
|
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
|
||||||
|
{
|
||||||
|
if ( tagList[tagIdx].isKey() && tagList[tagIdx].keyStringValue().equalIC(key) ) {
|
||||||
|
if ( tagIdx+1 >= tagList.size() ) return NULL;
|
||||||
|
if ( tagList[tagIdx+1].isKey() ) return NULL;
|
||||||
|
return &tagList[tagIdx+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TagStruct* GetNextProperty(TagStruct* dict)
|
||||||
|
//{
|
||||||
|
// TagStruct* tagList, tag;
|
||||||
|
//
|
||||||
|
// if (dict->isDict()) {
|
||||||
|
// return NULL;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// tag = NULL;
|
||||||
|
// tagList = dict->tag;
|
||||||
|
// while (tagList)
|
||||||
|
// {
|
||||||
|
// tag = tagList;
|
||||||
|
// tagList = tag->tagNext;
|
||||||
|
//
|
||||||
|
// if ( !tag->isKey() || tag->keyValue().isEmpty() ) {
|
||||||
|
// continue;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// return tag->tag;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return NULL;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************** XML ****************************************/
|
||||||
|
|
||||||
// Expects to see one dictionary in the XML file, the final pos will be returned
|
// Expects to see one dictionary in the XML file, the final pos will be returned
|
||||||
// If the pos is not equal to the strlen, then there are multiple dicts
|
// If the pos is not equal to the strlen, then there are multiple dicts
|
||||||
// Puts the first dictionary it finds in the
|
// Puts the first dictionary it finds in the
|
||||||
@ -286,7 +348,8 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTag(tag); tag = NULL;
|
tag->FreeTag();
|
||||||
|
tag = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreePool(configBuffer);
|
// FreePool(configBuffer);
|
||||||
@ -305,48 +368,6 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
|
|||||||
|
|
||||||
#define DOFREE 1
|
#define DOFREE 1
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
// GetProperty
|
|
||||||
|
|
||||||
const TagStruct* GetProperty(const TagStruct* dict, const CHAR8* key )
|
|
||||||
{
|
|
||||||
if ( !dict->isDict() ) return NULL;
|
|
||||||
|
|
||||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
|
||||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
|
|
||||||
{
|
|
||||||
if ( tagList[tagIdx].isKey() && tagList[tagIdx].keyValue().equalIC(key) ) return tagList[tagIdx].keyTagValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TagStruct* GetNextProperty(TagStruct* dict)
|
|
||||||
//{
|
|
||||||
// TagStruct* tagList, tag;
|
|
||||||
//
|
|
||||||
// if (dict->isDict()) {
|
|
||||||
// return NULL;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// tag = NULL;
|
|
||||||
// tagList = dict->tag;
|
|
||||||
// while (tagList)
|
|
||||||
// {
|
|
||||||
// tag = tagList;
|
|
||||||
// tagList = tag->tagNext;
|
|
||||||
//
|
|
||||||
// if ( !tag->isKey() || tag->keyValue().isEmpty() ) {
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// return tag->tag;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return NULL;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
// ParseNextTag
|
// ParseNextTag
|
||||||
@ -502,13 +523,16 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 e
|
|||||||
tagTail = NULL;
|
tagTail = NULL;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
TagStruct* dictOrArrayTag = NewTag();
|
TagStruct* dictOrArrayTag;
|
||||||
|
XObjArray<TagStruct>* tagListPtr;
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
dictOrArrayTag->setArrayTagValue(NULL);
|
dictOrArrayTag = TagStruct::getEmptyArrayTag();
|
||||||
|
tagListPtr = &dictOrArrayTag->arrayContent();
|
||||||
} else {
|
} else {
|
||||||
dictOrArrayTag->setDictTagValue(NULL);
|
dictOrArrayTag = TagStruct::getEmptyDictTag();
|
||||||
|
tagListPtr = &dictOrArrayTag->dictContent();
|
||||||
}
|
}
|
||||||
XObjArray<TagStruct>& tagList = dictOrArrayTag->dictOrArrayContent();
|
XObjArray<TagStruct>& tagList = *tagListPtr;
|
||||||
|
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -529,7 +553,7 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 e
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
FreeTag(dictOrArrayTag);
|
dictOrArrayTag->FreeTag();
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,7 +583,7 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
|
|||||||
UINT32 length = 0;
|
UINT32 length = 0;
|
||||||
UINT32 length2 = 0;
|
UINT32 length2 = 0;
|
||||||
TagStruct* tmpTag;
|
TagStruct* tmpTag;
|
||||||
TagStruct* subTag = NULL;
|
// TagStruct* subTag = NULL;
|
||||||
|
|
||||||
Status = FixDataMatchingTag(buffer, kXMLTagKey, &length);
|
Status = FixDataMatchingTag(buffer, kXMLTagKey, &length);
|
||||||
DBG("fixing key len=%d status=%s\n", length, strerror(Status));
|
DBG("fixing key len=%d status=%s\n", length, strerror(Status));
|
||||||
@ -567,16 +591,16 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = XMLParseNextTag(buffer + length, &subTag, &length2);
|
// Status = XMLParseNextTag(buffer + length, &subTag, &length2);
|
||||||
if (EFI_ERROR(Status)) {
|
// if (EFI_ERROR(Status)) {
|
||||||
return Status;
|
// return Status;
|
||||||
}
|
// }
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
tmpTag->setKeyValue(LString8(buffer), subTag);
|
tmpTag->setKeyValue(LString8(buffer));
|
||||||
|
|
||||||
*tag = tmpTag;
|
*tag = tmpTag;
|
||||||
*lenPtr = length + length2;
|
*lenPtr = length + length2;
|
||||||
DBG("parse key '%s' success len=%d\n", tmpString, *lenPtr);
|
DBG("parse key '%s' success len=%d\n", tmpTag->keyStringValue().c_str(), *lenPtr);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,7 +618,7 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
if (tmpTag == NULL) {
|
if (tmpTag == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -602,7 +626,7 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
|||||||
tmpTag->setStringValue(LString8(XMLDecode(buffer)));
|
tmpTag->setStringValue(LString8(XMLDecode(buffer)));
|
||||||
*tag = tmpTag;
|
*tag = tmpTag;
|
||||||
*lenPtr = length;
|
*lenPtr = length;
|
||||||
DBG(" parse string %s\n", tmpString);
|
DBG(" parse string %s\n", tmpTag->stringValue().c_str());
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +648,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
tmpTag->setIntValue(0);
|
tmpTag->setIntValue(0);
|
||||||
|
|
||||||
size = length;
|
size = length;
|
||||||
@ -651,7 +675,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
|||||||
else {
|
else {
|
||||||
MsgLog("ParseTagInteger hex error (0x%hhX) in buffer %s\n", *val, buffer);
|
MsgLog("ParseTagInteger hex error (0x%hhX) in buffer %s\n", *val, buffer);
|
||||||
// getchar();
|
// getchar();
|
||||||
FreeTag(tmpTag);
|
tmpTag->FreeTag();
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -668,7 +692,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
|||||||
if (*val < '0' || *val > '9') {
|
if (*val < '0' || *val > '9') {
|
||||||
MsgLog("ParseTagInteger decimal error (0x%hhX) in buffer %s\n", *val, buffer);
|
MsgLog("ParseTagInteger decimal error (0x%hhX) in buffer %s\n", *val, buffer);
|
||||||
// getchar();
|
// getchar();
|
||||||
FreeTag(tmpTag);
|
tmpTag->FreeTag();
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
integer = (integer * 10) + (*val++ - '0');
|
integer = (integer * 10) + (*val++ - '0');
|
||||||
@ -702,7 +726,7 @@ EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
if (tmpTag == NULL) {
|
if (tmpTag == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -731,7 +755,7 @@ EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
if (tmpTag == NULL) {
|
if (tmpTag == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -763,7 +787,7 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
if (tmpTag == NULL) {
|
if (tmpTag == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -783,7 +807,7 @@ EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32*
|
|||||||
{
|
{
|
||||||
TagStruct* tmpTag;
|
TagStruct* tmpTag;
|
||||||
|
|
||||||
tmpTag = NewTag();
|
tmpTag = TagStruct::getEmptyTag();
|
||||||
if (tmpTag == NULL) {
|
if (tmpTag == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -883,34 +907,6 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
// NewTag
|
|
||||||
|
|
||||||
TagStruct* NewTag( void )
|
|
||||||
{
|
|
||||||
TagStruct* tag;
|
|
||||||
|
|
||||||
if ( gTagsFree.size() > 0 ) {
|
|
||||||
tag = &gTagsFree[0];
|
|
||||||
gTagsFree.RemoveWithoutFreeingAtIndex(0);
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
tag = new TagStruct();
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
// XMLFreeTag
|
|
||||||
|
|
||||||
void FreeTag( TagStruct* tag )
|
|
||||||
{
|
|
||||||
if (tag == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tag->FreeTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -918,7 +914,7 @@ void FreeTag( TagStruct* tag )
|
|||||||
else return FALSE
|
else return FALSE
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPropertyTrue(const TagStruct* Prop)
|
IsPropertyNotNullAndTrue(const TagStruct* Prop)
|
||||||
{
|
{
|
||||||
return Prop != NULL && Prop->isTrueOrYy();
|
return Prop != NULL && Prop->isTrueOrYy();
|
||||||
}
|
}
|
||||||
@ -928,7 +924,7 @@ IsPropertyTrue(const TagStruct* Prop)
|
|||||||
else return FALSE
|
else return FALSE
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPropertyFalse(const TagStruct* Prop)
|
IsPropertyNotNullAndFalse(const TagStruct* Prop)
|
||||||
{
|
{
|
||||||
return Prop != NULL && Prop->isFalseOrNn();
|
return Prop != NULL && Prop->isFalseOrNn();
|
||||||
}
|
}
|
||||||
@ -941,7 +937,7 @@ IsPropertyFalse(const TagStruct* Prop)
|
|||||||
<string>0x12abd</string>
|
<string>0x12abd</string>
|
||||||
*/
|
*/
|
||||||
INTN
|
INTN
|
||||||
GetPropertyInteger(
|
GetPropertyAsInteger(
|
||||||
const TagStruct* Prop,
|
const TagStruct* Prop,
|
||||||
INTN Default
|
INTN Default
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,6 @@ typedef enum {
|
|||||||
class TagStruct;
|
class TagStruct;
|
||||||
extern XObjArray<TagStruct> gTagsFree;
|
extern XObjArray<TagStruct> gTagsFree;
|
||||||
|
|
||||||
|
|
||||||
class TagStruct
|
class TagStruct
|
||||||
{
|
{
|
||||||
UINTN type; // type is private. Use is...() functions.
|
UINTN type; // type is private. Use is...() functions.
|
||||||
@ -51,16 +50,18 @@ class TagStruct
|
|||||||
float _floatValue;
|
float _floatValue;
|
||||||
UINT8 *_data;
|
UINT8 *_data;
|
||||||
UINTN _dataLen;
|
UINTN _dataLen;
|
||||||
TagStruct *_tag;
|
|
||||||
XObjArray<TagStruct> _dictOrArrayContent;
|
XObjArray<TagStruct> _dictOrArrayContent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), /*offset(0), */_tag(NULL), _dictOrArrayContent() {}
|
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), _dictOrArrayContent() {}
|
||||||
TagStruct(const TagStruct& other) = delete; // Can be defined if needed
|
TagStruct(const TagStruct& other) = delete; // Can be defined if needed
|
||||||
const TagStruct& operator = ( const TagStruct & ) = delete; // Can be defined if needed
|
const TagStruct& operator = ( const TagStruct & ) = delete; // Can be defined if needed
|
||||||
~TagStruct() { delete _data; delete _tag; }
|
~TagStruct() { delete _data; }
|
||||||
|
|
||||||
|
static TagStruct* getEmptyTag();
|
||||||
|
static TagStruct* getEmptyDictTag();
|
||||||
|
static TagStruct* getEmptyArrayTag();
|
||||||
void FreeTag();
|
void FreeTag();
|
||||||
|
|
||||||
// Property<XString8> string();
|
// Property<XString8> string();
|
||||||
@ -74,25 +75,6 @@ public:
|
|||||||
bool isDate() const { return type == kTagTypeDate; }
|
bool isDate() const { return type == kTagTypeDate; }
|
||||||
bool isArray() const { return type == kTagTypeArray; }
|
bool isArray() const { return type == kTagTypeArray; }
|
||||||
|
|
||||||
const XObjArray<TagStruct>& dictOrArrayContent() const
|
|
||||||
{
|
|
||||||
if ( isDict() ) return _dictOrArrayContent;
|
|
||||||
if ( isArray() ) return _dictOrArrayContent;
|
|
||||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
|
||||||
}
|
|
||||||
XObjArray<TagStruct>& dictOrArrayContent()
|
|
||||||
{
|
|
||||||
if ( isDict() ) return _dictOrArrayContent;
|
|
||||||
if ( isArray() ) return _dictOrArrayContent;
|
|
||||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
|
||||||
}
|
|
||||||
// void setNextTagValue(TagStruct* nextTag)
|
|
||||||
// {
|
|
||||||
// if ( nextTag == NULL ) panic("TagStruct::setDictNextTagValue() : nextTag == NULL ");
|
|
||||||
// if ( _nextTag != NULL ) panic("TagStruct::setDictNextTagValue() : _nextTag != NULL ");
|
|
||||||
// _nextTag = nextTag;
|
|
||||||
// }
|
|
||||||
|
|
||||||
const XString8 getTypeAsXString8() const {
|
const XString8 getTypeAsXString8() const {
|
||||||
if ( isDict() ) return "Dict"_XS8;
|
if ( isDict() ) return "Dict"_XS8;
|
||||||
if ( isKey() ) return "Dict"_XS8;
|
if ( isKey() ) return "Dict"_XS8;
|
||||||
@ -106,7 +88,11 @@ public:
|
|||||||
panic("Unknown type %lld : this is bug", type);
|
panic("Unknown type %lld : this is bug", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// getter and setter
|
/*
|
||||||
|
* getters and setters
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* data */
|
||||||
const UINT8* dataValue() const
|
const UINT8* dataValue() const
|
||||||
{
|
{
|
||||||
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
||||||
@ -117,11 +103,11 @@ public:
|
|||||||
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
const XString8& dataStringValue()
|
// const XString8& dataStringValue()
|
||||||
{
|
// {
|
||||||
if ( !isData() ) panic("TagStruct::dataStringValue() : !isData() ");
|
// if ( !isData() ) panic("TagStruct::dataStringValue() : !isData() ");
|
||||||
return _string;
|
// return _string;
|
||||||
}
|
// }
|
||||||
UINTN dataLenValue() const
|
UINTN dataLenValue() const
|
||||||
{
|
{
|
||||||
if ( !isData() ) panic("TagStruct::dataLenValue() : !isData() ");
|
if ( !isData() ) panic("TagStruct::dataLenValue() : !isData() ");
|
||||||
@ -135,6 +121,7 @@ public:
|
|||||||
type = kTagTypeData;
|
type = kTagTypeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* date */
|
||||||
const XString8& dateValue()
|
const XString8& dateValue()
|
||||||
{
|
{
|
||||||
if ( !isDict() ) panic("TagStruct::dictValue() : !isDict() ");
|
if ( !isDict() ) panic("TagStruct::dictValue() : !isDict() ");
|
||||||
@ -147,60 +134,52 @@ public:
|
|||||||
_string = xstring;
|
_string = xstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagStruct* dictTagValue()
|
/* dict */
|
||||||
|
const XObjArray<TagStruct>& dictContent() const
|
||||||
{
|
{
|
||||||
if ( !isDict() ) panic("TagStruct::dictValue() : !isDict() ");
|
if ( !isDict() ) panic("TagStruct::dictContent() : !isDict() ");
|
||||||
return _tag;
|
return _dictOrArrayContent;
|
||||||
}
|
}
|
||||||
void setDictTagValue(TagStruct* tagList)
|
XObjArray<TagStruct>& dictContent()
|
||||||
{
|
{
|
||||||
// empty dict is allowed
|
if ( !isDict() ) panic("TagStruct::dictContent() : !isDict() ");
|
||||||
//if ( tagList == NULL ) panic("TagStruct::setDictTagValue() : tagList == NULL ");
|
return _dictOrArrayContent;
|
||||||
if ( _tag != NULL ) panic("TagStruct::setDictTagValue() : _tag != NULL ");
|
}
|
||||||
if ( _dictOrArrayContent.notEmpty() ) panic("TagStruct::setDictTagValue() : __dictOrArrayContent.notEmpty() ");
|
INTN dictKeyCount() const;
|
||||||
_tag = tagList;
|
EFI_STATUS dictKeyAndValueAtIndex(INTN id, const TagStruct** key, const TagStruct** value) const;
|
||||||
type = kTagTypeDict;
|
const TagStruct* dictPropertyForKey(const CHAR8* key ) const;
|
||||||
|
|
||||||
|
/* array */
|
||||||
|
const XObjArray<TagStruct>& arrayContent() const
|
||||||
|
{
|
||||||
|
if ( isArray() ) return _dictOrArrayContent;
|
||||||
|
panic("TagStruct::arrayContent() const : !isArray() ");
|
||||||
|
}
|
||||||
|
XObjArray<TagStruct>& arrayContent()
|
||||||
|
{
|
||||||
|
if ( isArray() ) return _dictOrArrayContent;
|
||||||
|
panic("TagStruct::arrayContent() : !isDict() && !isArray() ");
|
||||||
}
|
}
|
||||||
|
|
||||||
TagStruct* arrayTagValue()
|
/* key */
|
||||||
|
const XString8& keyStringValue() const
|
||||||
{
|
{
|
||||||
if ( !isArray() ) panic("TagStruct::arrayValue() : !isArray() ");
|
if ( !isKey() ) panic("TagStruct::keyStringValue() const : !isKey() ");
|
||||||
return _tag;
|
|
||||||
}
|
|
||||||
void setArrayTagValue(TagStruct* tag)
|
|
||||||
{
|
|
||||||
// Array value with tagList = NULL is allowed
|
|
||||||
//if ( tag == NULL ) panic("TagStruct::setArrayValue() : tag == NULL ");
|
|
||||||
if ( _tag != NULL ) panic("TagStruct::setArrayValue() : _tag != NULL ");
|
|
||||||
if ( _dictOrArrayContent.notEmpty() ) panic("TagStruct::setArrayTagValue() : __dictOrArrayContent.notEmpty() ");
|
|
||||||
_tag = tag;
|
|
||||||
type = kTagTypeArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const XString8& keyValue() const
|
|
||||||
{
|
|
||||||
if ( !isKey() ) panic("TagStruct::keyValue() : !isKey() ");
|
|
||||||
return _string;
|
return _string;
|
||||||
}
|
}
|
||||||
XString8& keyValue()
|
XString8& keyStringValue()
|
||||||
{
|
{
|
||||||
if ( !isKey() ) panic("TagStruct::keyValue() : !isKey() ");
|
if ( !isKey() ) panic("TagStruct::keyStringValue() : !isKey() ");
|
||||||
return _string;
|
return _string;
|
||||||
}
|
}
|
||||||
const TagStruct* keyTagValue() const
|
void setKeyValue(const XString8& xstring)
|
||||||
{
|
|
||||||
if ( !isKey() ) panic("TagStruct::keyTagValue() : !isKey() ");
|
|
||||||
return _tag;
|
|
||||||
}
|
|
||||||
void setKeyValue(const XString8& xstring, TagStruct* subTag)
|
|
||||||
{
|
{
|
||||||
if ( xstring.isEmpty() ) panic("TagStruct::setKeyValue() : xstring.isEmpty() ");
|
if ( xstring.isEmpty() ) panic("TagStruct::setKeyValue() : xstring.isEmpty() ");
|
||||||
type = kTagTypeKey;
|
type = kTagTypeKey;
|
||||||
_string = xstring;
|
_string = xstring;
|
||||||
_tag = subTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* string */
|
||||||
const XString8& stringValue() const
|
const XString8& stringValue() const
|
||||||
{
|
{
|
||||||
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
|
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
|
||||||
@ -219,6 +198,7 @@ public:
|
|||||||
_string = xstring;
|
_string = xstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* int */
|
||||||
INTN intValue() const
|
INTN intValue() const
|
||||||
{
|
{
|
||||||
if ( !isInt() ) panic("TagStruct::intValue() : !isInt() ");
|
if ( !isInt() ) panic("TagStruct::intValue() : !isInt() ");
|
||||||
@ -230,6 +210,7 @@ public:
|
|||||||
_intValue = i;
|
_intValue = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* float */
|
||||||
float floatValue() const
|
float floatValue() const
|
||||||
{
|
{
|
||||||
if ( !isFloat() ) panic("TagStruct::floatValue() : !isFloat() ");
|
if ( !isFloat() ) panic("TagStruct::floatValue() : !isFloat() ");
|
||||||
@ -241,6 +222,7 @@ public:
|
|||||||
_floatValue = f;
|
_floatValue = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* bool */
|
||||||
INTN boolValue() const
|
INTN boolValue() const
|
||||||
{
|
{
|
||||||
if ( !isBool() ) panic("TagStruct::boolValue() : !isBool() ");
|
if ( !isBool() ) panic("TagStruct::boolValue() : !isBool() ");
|
||||||
@ -281,22 +263,8 @@ public:
|
|||||||
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'n' || stringValue()[0] == 'N') ) return true;
|
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'n' || stringValue()[0] == 'N') ) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TagStruct* dictOrArrayTagValue()
|
|
||||||
{
|
|
||||||
if ( isDict() ) return dictTagValue();
|
|
||||||
if ( isArray() ) return arrayTagValue();
|
|
||||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//typedef union {
|
|
||||||
// struct {
|
|
||||||
// float fNum; //4 bytes
|
|
||||||
// UINT32 pad; // else 4
|
|
||||||
// } B;
|
|
||||||
// CHAR8 *string;
|
|
||||||
//} FlMix;
|
|
||||||
|
|
||||||
|
|
||||||
CHAR8*
|
CHAR8*
|
||||||
XMLDecode (
|
XMLDecode (
|
||||||
@ -311,21 +279,6 @@ ParseXML(
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//VOID RenderSVGfont(NSVGfont *fontSVG);
|
|
||||||
|
|
||||||
const TagStruct*
|
|
||||||
GetProperty(
|
|
||||||
const TagStruct* dict,
|
|
||||||
CONST CHAR8* key
|
|
||||||
);
|
|
||||||
|
|
||||||
TagStruct* NewTag( void );
|
|
||||||
|
|
||||||
VOID
|
|
||||||
FreeTag (
|
|
||||||
TagStruct* tag
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetNextTag (
|
GetNextTag (
|
||||||
UINT8 *buffer,
|
UINT8 *buffer,
|
||||||
@ -334,30 +287,18 @@ GetNextTag (
|
|||||||
UINT32 *length
|
UINT32 *length
|
||||||
);
|
);
|
||||||
|
|
||||||
INTN
|
|
||||||
GetTagCount (
|
|
||||||
const TagStruct* dict
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
GetElement(
|
|
||||||
const TagStruct* dict,
|
|
||||||
INTN id,
|
|
||||||
const TagStruct** dict1
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPropertyTrue(
|
IsPropertyNotNullAndTrue(
|
||||||
const TagStruct* Prop
|
const TagStruct* Prop
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPropertyFalse(
|
IsPropertyNotNullAndFalse(
|
||||||
const TagStruct* Prop
|
const TagStruct* Prop
|
||||||
);
|
);
|
||||||
|
|
||||||
INTN
|
INTN
|
||||||
GetPropertyInteger(
|
GetPropertyAsInteger(
|
||||||
const TagStruct* Prop,
|
const TagStruct* Prop,
|
||||||
INTN Default
|
INTN Default
|
||||||
);
|
);
|
||||||
|
@ -27,7 +27,6 @@ class XArray
|
|||||||
TYPE* m_data;
|
TYPE* m_data;
|
||||||
size_t m_len;
|
size_t m_len;
|
||||||
size_t m_allocatedSize;
|
size_t m_allocatedSize;
|
||||||
// size_t _GrowBy;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// void Init();
|
// void Init();
|
||||||
|
@ -123,7 +123,26 @@ class XObjArray : public XObjArrayNC<TYPE>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XObjArray() : XObjArrayNC<TYPE>() {}
|
XObjArray() : XObjArrayNC<TYPE>() {}
|
||||||
|
|
||||||
|
XObjArray(bool FreeThem, TYPE* n1, ...);
|
||||||
|
|
||||||
|
XObjArray(const TYPE &n1, bool FreeIt = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem = true);
|
||||||
|
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem = true);
|
||||||
|
|
||||||
XObjArray(const XObjArray<TYPE> &anObjArray);
|
XObjArray(const XObjArray<TYPE> &anObjArray);
|
||||||
|
|
||||||
const XObjArray<TYPE> &operator =(const XObjArray<TYPE> &anObjArray);
|
const XObjArray<TYPE> &operator =(const XObjArray<TYPE> &anObjArray);
|
||||||
|
|
||||||
size_t AddCopy(const TYPE &newElement, bool FreeIt = true);
|
size_t AddCopy(const TYPE &newElement, bool FreeIt = true);
|
||||||
@ -169,6 +188,225 @@ void XObjArrayNC<TYPE>::Init()
|
|||||||
// }
|
// }
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
/* Constructeur */
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(bool FreeThem, TYPE* n1, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
|
||||||
|
va_start (va, n1);
|
||||||
|
size_t count = 0;
|
||||||
|
TYPE* t = VA_ARG(va, TYPE*);
|
||||||
|
while ( t != nullptr ) {
|
||||||
|
count++;
|
||||||
|
t = VA_ARG(va, TYPE*);
|
||||||
|
}
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(count+1, (size_t)0);
|
||||||
|
XObjArrayNC<TYPE>::AddReference(n1, FreeThem);
|
||||||
|
|
||||||
|
va_start (va, n1);
|
||||||
|
t = VA_ARG(va, TYPE*);
|
||||||
|
while ( t != nullptr ) {
|
||||||
|
XObjArrayNC<TYPE>::AddReference(t, FreeThem);
|
||||||
|
t = VA_ARG(va, TYPE*);
|
||||||
|
}
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, bool FreeIt)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(1, (size_t)0);
|
||||||
|
AddCopy(n1, FreeIt);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(2, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(3, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(4, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(5, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(6, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(7, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(8, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(9, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
AddCopy(n9, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(10, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
AddCopy(n9, FreeThem);
|
||||||
|
AddCopy(n10, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(11, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
AddCopy(n9, FreeThem);
|
||||||
|
AddCopy(n10, FreeThem);
|
||||||
|
AddCopy(n11, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(12, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
AddCopy(n9, FreeThem);
|
||||||
|
AddCopy(n10, FreeThem);
|
||||||
|
AddCopy(n11, FreeThem);
|
||||||
|
AddCopy(n12, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(13, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
AddCopy(n9, FreeThem);
|
||||||
|
AddCopy(n10, FreeThem);
|
||||||
|
AddCopy(n11, FreeThem);
|
||||||
|
AddCopy(n12, FreeThem);
|
||||||
|
AddCopy(n13, FreeThem);
|
||||||
|
}
|
||||||
|
template<class TYPE>
|
||||||
|
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem)
|
||||||
|
{
|
||||||
|
XObjArrayNC<TYPE>::Init();
|
||||||
|
this->CheckSize(14, (size_t)0);
|
||||||
|
AddCopy(n1, FreeThem);
|
||||||
|
AddCopy(n2, FreeThem);
|
||||||
|
AddCopy(n3, FreeThem);
|
||||||
|
AddCopy(n4, FreeThem);
|
||||||
|
AddCopy(n5, FreeThem);
|
||||||
|
AddCopy(n6, FreeThem);
|
||||||
|
AddCopy(n7, FreeThem);
|
||||||
|
AddCopy(n8, FreeThem);
|
||||||
|
AddCopy(n9, FreeThem);
|
||||||
|
AddCopy(n10, FreeThem);
|
||||||
|
AddCopy(n11, FreeThem);
|
||||||
|
AddCopy(n12, FreeThem);
|
||||||
|
AddCopy(n13, FreeThem);
|
||||||
|
AddCopy(n14, FreeThem);
|
||||||
|
}
|
||||||
|
|
||||||
/* Constructeur */
|
/* Constructeur */
|
||||||
template<class TYPE>
|
template<class TYPE>
|
||||||
|
@ -489,6 +489,10 @@ public:
|
|||||||
// int Compare(const char32_t* S) const { return ::Compare<T, char32_t>(m_data, S); };
|
// int Compare(const char32_t* S) const { return ::Compare<T, char32_t>(m_data, S); };
|
||||||
// int Compare(const wchar_t* S) const { return ::Compare<T, wchar_t>(m_data, S); };
|
// int Compare(const wchar_t* S) const { return ::Compare<T, wchar_t>(m_data, S); };
|
||||||
//
|
//
|
||||||
|
|
||||||
|
template<typename O>
|
||||||
|
int strncmp(const O* S, size_t n) const { return XStringAbstract__ncompare(m_data, S, n, false); }
|
||||||
|
|
||||||
template<typename O, class OtherXStringClass>
|
template<typename O, class OtherXStringClass>
|
||||||
bool equal(const __String<O, OtherXStringClass>& S) const { return XStringAbstract__compare(m_data, S.s(), false) == 0; }
|
bool equal(const __String<O, OtherXStringClass>& S) const { return XStringAbstract__compare(m_data, S.s(), false) == 0; }
|
||||||
template<typename O>
|
template<typename O>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
||||||
#include "../cpp_foundation/XObjArray.h"
|
#include "../cpp_foundation/XObjArray.h"
|
||||||
|
#include "../cpp_foundation/XArray.h"
|
||||||
|
|
||||||
class TestObjInt
|
class TestObjInt
|
||||||
{
|
{
|
||||||
@ -62,5 +63,11 @@ int XObjArray_tests()
|
|||||||
delete(obj14);
|
delete(obj14);
|
||||||
if ( !m_destructor_called14 ) return 11;
|
if ( !m_destructor_called14 ) return 11;
|
||||||
|
|
||||||
|
{
|
||||||
|
XObjArray<XString8> testCtor(true, new XString8("s1"_XS8), new XString8("s2"_XS8), new XString8("s3"_XS8), NULL);
|
||||||
|
if ( testCtor[0] != "s1"_XS8 ) return 20;
|
||||||
|
if ( testCtor[1] != "s2"_XS8 ) return 21;
|
||||||
|
if ( testCtor[2] != "s3"_XS8 ) return 22;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
|||||||
/*
|
/*
|
||||||
Dict = GetProperty(DictPointer, "Anime");
|
Dict = GetProperty(DictPointer, "Anime");
|
||||||
if (Dict != NULL) {
|
if (Dict != NULL) {
|
||||||
INTN Count = GetTagCount (Dict);
|
INTN Count = Get_TagCount (Dict);
|
||||||
for (INTN i = 0; i < Count; i++) {
|
for (INTN i = 0; i < Count; i++) {
|
||||||
FILM *NewFilm = new FILM();
|
FILM *NewFilm = new FILM();
|
||||||
if (EFI_ERROR(GetElement(Dict, i, &Dict3))) {
|
if (EFI_ERROR(GetElement(Dict, i, &Dict3))) {
|
||||||
|
@ -1952,7 +1952,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gConfigDict[1]) {
|
if (gConfigDict[1]) {
|
||||||
const TagStruct* UniteTag = GetProperty(gConfigDict[1], "Unite");
|
const TagStruct* UniteTag = gConfigDict[1]->dictPropertyForKey("Unite");
|
||||||
if(UniteTag) {
|
if(UniteTag) {
|
||||||
UniteConfigs = UniteTag->isTrueOrYy();
|
UniteConfigs = UniteTag->isTrueOrYy();
|
||||||
DBG("UniteConfigs = %ls", UniteConfigs ? L"TRUE\n": L"FALSE\n" );
|
DBG("UniteConfigs = %ls", UniteConfigs ? L"TRUE\n": L"FALSE\n" );
|
||||||
@ -2218,7 +2218,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
|||||||
// }
|
// }
|
||||||
// Load any extra SMBIOS information
|
// Load any extra SMBIOS information
|
||||||
if (!EFI_ERROR(LoadUserSettings(SelfRootDir, L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) {
|
if (!EFI_ERROR(LoadUserSettings(SelfRootDir, L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) {
|
||||||
const TagStruct* dictPointer = GetProperty(smbiosTags,"SMBIOS");
|
const TagStruct* dictPointer = smbiosTags->dictPropertyForKey("SMBIOS");
|
||||||
if (dictPointer) {
|
if (dictPointer) {
|
||||||
ParseSMBIOSSettings(dictPointer);
|
ParseSMBIOSSettings(dictPointer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -869,7 +869,7 @@ VOID ApplyInputs(VOID)
|
|||||||
gBootChanged = TRUE;
|
gBootChanged = TRUE;
|
||||||
gThemeChanged = TRUE;
|
gThemeChanged = TRUE;
|
||||||
Status = GetUserSettings(SelfRootDir, dict);
|
Status = GetUserSettings(SelfRootDir, dict);
|
||||||
if (gConfigDict[2]) FreeTag(gConfigDict[2]);
|
if (gConfigDict[2]) gConfigDict[2]->FreeTag();
|
||||||
gConfigDict[2] = dict;
|
gConfigDict[2] = dict;
|
||||||
snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]);
|
snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user