@@ -897,28 +897,47 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
897897 } else if (functionnodename == " returnValue" ) {
898898 if (const char *expr = functionnode->GetText ())
899899 mData ->mReturnValue [name] = expr;
900- if (const char *type = functionnode->Attribute (" type" ))
901- mData ->mReturnValueType [name] = type;
902- if (const char *container = functionnode->Attribute (" container" ))
903- mData ->mReturnValueContainer [name] = strToInt<int >(container);
904- // cppcheck-suppress shadowFunction - TODO: fix this
905- if (const char *unknownReturnValues = functionnode->Attribute (" unknownValues" )) {
906- if (std::strcmp (unknownReturnValues, " all" ) == 0 ) {
907- std::vector<MathLib::bigint> values{LLONG_MIN, LLONG_MAX};
908- mData ->mUnknownReturnValues [name] = std::move (values);
900+ for (const auto * attr = functionnode->FirstAttribute (); attr; attr = attr->Next ())
901+ {
902+ const char * const attr_n = attr->Name ();
903+ if (strcmp (attr_n, " type" ) == 0 )
904+ mData ->mReturnValueType [name] = attr->Value ();
905+ else if (strcmp (attr_n, " container" ) == 0 )
906+ mData ->mReturnValueContainer [name] = strToInt<int >(attr->Value ()); // TODO: use IntValue()?
907+ else if (strcmp (attr_n, " unknownValues" ) == 0 ) {
908+ if (std::strcmp (attr->Value (), " all" ) == 0 ) {
909+ std::vector<MathLib::bigint> values{LLONG_MIN, LLONG_MAX};
910+ mData ->mUnknownReturnValues [name] = std::move (values);
911+ }
909912 }
910913 }
911914 } else if (functionnodename == " arg" ) {
912- const char * argNrString = functionnode->Attribute (" nr" );
915+ const char * argNrString = nullptr ;
916+ const char * defaultString = nullptr ;
917+ const char * argDirection = nullptr ;
918+ const char * argIndirect = nullptr ;
919+
920+ for (const auto * attr = functionnode->FirstAttribute (); attr; attr = attr->Next ())
921+ {
922+ const char * const attr_n = attr->Name ();
923+ if (strcmp (attr_n, " nr" ) == 0 )
924+ argNrString = attr->Value ();
925+ else if (strcmp (attr_n, " default" ) == 0 )
926+ defaultString = attr->Value ();
927+ else if (strcmp (attr_n, " direction" ) == 0 )
928+ argDirection = attr->Value ();
929+ else if (strcmp (attr_n, " indirect" ) == 0 )
930+ argIndirect = attr->Value ();
931+ }
932+
913933 if (!argNrString)
914934 return Error (ErrorCode::MISSING_ATTRIBUTE, " nr" );
915935 const bool bAnyArg = strcmp (argNrString, " any" ) == 0 ;
916936 const bool bVariadicArg = strcmp (argNrString, " variadic" ) == 0 ;
917937 const int nr = (bAnyArg || bVariadicArg) ? -1 : strToInt<int >(argNrString);
918938 ArgumentChecks &ac = func.argumentChecks [nr];
919- ac.optional = functionnode-> Attribute ( " default " ) != nullptr ;
939+ ac.optional = defaultString != nullptr ;
920940 ac.variadic = bVariadicArg;
921- const char * const argDirection = functionnode->Attribute (" direction" );
922941 if (argDirection) {
923942 const size_t argDirLen = strlen (argDirection);
924943 ArgumentChecks::Direction dir = ArgumentChecks::Direction::DIR_UNKNOWN;
@@ -929,8 +948,8 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
929948 } else if (!strncmp (argDirection, " inout" , argDirLen)) {
930949 dir = ArgumentChecks::Direction::DIR_INOUT;
931950 }
932- if (const char * const argIndirect = functionnode-> Attribute ( " indirect " ) ) {
933- const int indirect = strToInt<int >(argIndirect);
951+ if (argIndirect) {
952+ const int indirect = strToInt<int >(argIndirect); // TODO: use IntValue()?
934953 ac.direction [indirect] = dir; // TODO: handle multiple directions/indirect levels
935954 }
936955 else
0 commit comments