asCString asCDataType::Format(bool includeNamespace) const { if( IsNullHandle() ) return "<null handle>"; asCString str; if( isReadOnly ) str = "const "; if( includeNamespace ) { if( objectType ) str += objectType->nameSpace->name + "::"; else if( funcDef ) str += funcDef->nameSpace->name + "::"; } if( tokenType != ttIdentifier ) { str += asCTokenizer::GetDefinition(tokenType); } else if( IsArrayType() && objectType && !objectType->engine->ep.expandDefaultArrayToTemplate ) { str += objectType->templateSubType.Format(includeNamespace); str += "[]"; } else if( funcDef ) { str += funcDef->name; } else if( objectType ) { str += objectType->name; if( objectType->flags & asOBJ_TEMPLATE ) { str += "<"; str += objectType->templateSubType.Format(includeNamespace); str += ">"; } } else { str = "<unknown>"; } if( isObjectHandle ) { str += "@"; if( isConstHandle ) str += "const"; } if( isReference ) str += "&"; return str; }
//++ ------------------------------------------------------------------------------------ // Details: Retrieve from the LLDB SB Value object the value of the variable described in // text if it has a simple format (not composite). // Type: Method. // Args: vwrValue - (W) The SBValue in a string format. // Return: MIstatus::success - Function succeeded. // MIstatus::failure - Function failed. // Throws: None. //-- bool CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilString &vwrValue) const { const MIuint nChildren = m_rValue.GetNumChildren(); if (nChildren == 0) { if (m_bHandleCharType && IsCharType()) { vwrValue = GetSimpleValueChar(); return MIstatus::success; } else { const char *pValue = m_rValue.GetValue(); vwrValue = pValue != nullptr ? pValue : m_pUnkwn; return MIstatus::success; } } else if (IsPointerType()) { if (m_bHandleCharType && IsFirstChildCharType()) { vwrValue = GetSimpleValueCStringPointer(); return MIstatus::success; } else { const char *pValue = m_rValue.GetValue(); vwrValue = pValue != nullptr ? pValue : m_pUnkwn; return MIstatus::success; } } else if (IsArrayType()) { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); bool bPrintCharArrayAsString = false; bPrintCharArrayAsString = rSessionInfo.SharedDataRetrieve<bool>(rSessionInfo.m_constStrPrintCharArrayAsString, bPrintCharArrayAsString) && bPrintCharArrayAsString; if (bPrintCharArrayAsString && m_bHandleCharType && IsFirstChildCharType()) { vwrValue = GetSimpleValueCStringArray(); return MIstatus::success; } else if (vbHandleArrayType) { vwrValue = CMIUtilString::Format("[%u]", nChildren); return MIstatus::success; } } // Composite variable type i.e. struct return MIstatus::failure; }
asCString asCDataType::Format() const { if( IsNullHandle() ) return "<null handle>"; asCString str; if( isReadOnly ) str = "const "; if( tokenType != ttIdentifier ) { str += asGetTokenDefinition(tokenType); } else if( IsArrayType() ) { str += objectType->templateSubType.Format(); str += "[]"; } else if( funcDef ) { str += funcDef->name; } else if( objectType ) { str += objectType->name; if( objectType->flags & asOBJ_TEMPLATE ) { str += "<"; str += objectType->templateSubType.Format(); str += ">"; } } else { str = "<unknown>"; } if( isObjectHandle ) { str += "@"; if( isConstHandle ) str += "const"; } if( isReference ) str += "&"; return str; }
//++ //------------------------------------------------------------------------------------ // Details: Retrieve from the LLDB SB Value object the value of the variable // described in // text if it has a simple format (not composite). // Type: Method. // Args: vwrValue - (W) The SBValue in a string format. // Return: MIstatus::success - Function succeeded. // MIstatus::failure - Function failed. // Throws: None. //-- bool CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilString &vwrValue) const { const MIuint nChildren = m_rValue.GetNumChildren(); if (nChildren == 0) { vwrValue = GetValueSummary(!m_bHandleCharType && IsCharType(), m_pUnkwn); return MIstatus::success; } else if (IsPointerType()) { vwrValue = GetValueSummary(!m_bHandleCharType && IsPointeeCharType(), m_pUnkwn); return MIstatus::success; } else if (IsArrayType()) { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); bool bPrintCharArrayAsString = false; bPrintCharArrayAsString = rSessionInfo.SharedDataRetrieve<bool>( rSessionInfo.m_constStrPrintCharArrayAsString, bPrintCharArrayAsString) && bPrintCharArrayAsString; if (bPrintCharArrayAsString && m_bHandleCharType && IsFirstChildCharType()) { vwrValue = GetValueSummary(false); return MIstatus::success; } else if (vbHandleArrayType) { vwrValue = CMIUtilString::Format("[%u]", nChildren); return MIstatus::success; } } else { // Treat composite value which has registered summary // (for example with AddCXXSummary) as simple value vwrValue = GetValueSummary(false); if (!vwrValue.empty()) return MIstatus::success; } // Composite variable type i.e. struct return MIstatus::failure; }
asCString asCDataType::Format(bool includeNamespace) const { if( IsNullHandle() ) return "<null handle>"; asCString str; if( isReadOnly ) str = "const "; if( includeNamespace ) { if( objectType ) str += objectType->nameSpace->name + "::"; else if( funcDef ) str += funcDef->nameSpace->name + "::"; } if( tokenType != ttIdentifier ) { str += asCTokenizer::GetDefinition(tokenType); } else if( IsArrayType() && objectType && !objectType->engine->ep.expandDefaultArrayToTemplate ) { asASSERT( objectType->templateSubTypes.GetLength() == 1 ); str += objectType->templateSubTypes[0].Format(includeNamespace); str += "[]"; } else if( funcDef ) { str += funcDef->name; } else if( objectType ) { str += objectType->name; if( objectType->templateSubTypes.GetLength() > 0 ) { str += "<"; for( asUINT subtypeIndex = 0; subtypeIndex < objectType->templateSubTypes.GetLength(); subtypeIndex++ ) { str += objectType->templateSubTypes[subtypeIndex].Format(includeNamespace); if( subtypeIndex != objectType->templateSubTypes.GetLength()-1 ) str += ","; } str += ">"; } } else { str = "<unknown>"; } if( isObjectHandle ) { str += "@"; if( isConstHandle ) str += "const"; } if( isReference ) str += "&"; return str; }
asCString asCDataType::Format(asSNameSpace *currNs, bool includeNamespace) const { if( IsNullHandle() ) return "<null handle>"; asCString str; if( isReadOnly ) str = "const "; // If the type is not declared in the current namespace, then the namespace // must always be informed to guarantee that the correct type is informed if (includeNamespace || (typeInfo && typeInfo->nameSpace != currNs)) { if (typeInfo && typeInfo->nameSpace && typeInfo->nameSpace->name != "") str += typeInfo->nameSpace->name + "::"; } if (typeInfo && typeInfo->nameSpace == 0) { // If funcDef->nameSpace is null it means the funcDef was declared as member of // another type, in which case the scope should be built with the name of that type str += typeInfo->CastToFuncdefType()->parentClass->name + "::"; } if( tokenType != ttIdentifier ) { str += asCTokenizer::GetDefinition(tokenType); } else if( IsArrayType() && typeInfo && !typeInfo->engine->ep.expandDefaultArrayToTemplate ) { asCObjectType *ot = typeInfo->CastToObjectType(); asASSERT( ot && ot->templateSubTypes.GetLength() == 1 ); str += ot->templateSubTypes[0].Format(currNs, includeNamespace); str += "[]"; } else if(typeInfo) { str += typeInfo->name; asCObjectType *ot = typeInfo->CastToObjectType(); if( ot && ot->templateSubTypes.GetLength() > 0 ) { str += "<"; for( asUINT subtypeIndex = 0; subtypeIndex < ot->templateSubTypes.GetLength(); subtypeIndex++ ) { str += ot->templateSubTypes[subtypeIndex].Format(currNs, includeNamespace); if( subtypeIndex != ot->templateSubTypes.GetLength()-1 ) str += ","; } str += ">"; } } else if( isAuto ) { str += "<auto>"; } else { str = "<unknown>"; } if( isObjectHandle ) { str += "@"; if( isConstHandle ) str += "const"; } if( isReference ) str += "&"; return str; }
static AwaOpaque MakeOpaqueValue(const char * value, int length) { return (AwaOpaque) { .Data = (void *)value, length }; } static int AddTargetWithValue(const AwaServerSession * session, AwaServerWriteOperation * operation, const Target * target, const char * value) { int result = 0; if (operation != NULL) { if (target != NULL) { if (value != NULL) { if (Server_IsResourceDefined(session, target->Path)) { AwaResourceType resourceType = Server_GetResourceType(session, target->Path); if (resourceType != AwaResourceType_Invalid ) { if (IsIDValid(target->ResourceInstanceID)) { Verbose("Set %s %s/%d <- %s\n", ResourceTypeToString(resourceType), target->Path, target->ResourceInstanceID, value); if (!IsArrayType(resourceType)) { Error("Error: resource %s is not an array; do not specify a resource instance ID\n", target->Path); result = -1; } } else { Verbose("Set %s %s <- %s\n", ResourceTypeToString(resourceType), target->Path, value); if (IsArrayType(resourceType)) { Error("Error: resource is an array; specify a resource instance ID: %s/x\n", target->Path); result = -1; } } if (result == 0) { switch (resourceType) { case AwaResourceType_None: { Error("Resource %s is of type None and cannot be set\n", target->Path); result = -1; break; } case AwaResourceType_String: { if (AwaServerWriteOperation_AddValueAsCString(operation, target->Path, value) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsCString failed\n"); result = -1; } break; } case AwaResourceType_Integer: { AwaInteger tmp = strtoimax(value, NULL, 10); if (AwaServerWriteOperation_AddValueAsInteger(operation, target->Path, tmp) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsInteger failed\n"); result = -1; } break; } case AwaResourceType_Float: { AwaFloat tmp = 0.0; sscanf(value, "%20lf", &tmp); if (AwaServerWriteOperation_AddValueAsFloat(operation, target->Path, tmp) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsFloat failed\n"); result = -1; } break; } case AwaResourceType_Boolean: { AwaBoolean boolValue = GetBooleanValue(value); if (AwaServerWriteOperation_AddValueAsBoolean(operation, target->Path, boolValue) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsBoolean failed\n"); result = -1; } break; } case AwaResourceType_Opaque: { AwaOpaque opaqueValue = MakeOpaqueValue(value, strlen(value)); if (AwaServerWriteOperation_AddValueAsOpaque(operation, target->Path, opaqueValue) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsOpaque failed\n"); result = -1; } break; } case AwaResourceType_Time: { AwaTime tmp = strtoimax(value, NULL, 10); if (AwaServerWriteOperation_AddValueAsTime(operation, target->Path, tmp) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsTime failed\n"); result = -1; } break; } case AwaResourceType_ObjectLink: { AwaObjectLink objectLink; if (!SetObjectLinkFromInput(&objectLink, value)) { Error("AwaServerWriteOperation_AddValueAsObjectLink failed\n"); result = -1; break; } if (AwaServerWriteOperation_AddValueAsObjectLink(operation, target->Path, objectLink) != AwaError_Success) { Error("AwaServerWriteOperation_AddValueAsObjectLink failed\n"); result = -1; } break; } case AwaResourceType_IntegerArray: { AwaInteger tmp = strtoimax(value, NULL, 10); if (AwaServerWriteOperation_AddArrayValueAsInteger(operation, target->Path, target->ResourceInstanceID, tmp) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsInteger failed\n"); result = -1; } break; } case AwaResourceType_StringArray: { if (AwaServerWriteOperation_AddArrayValueAsCString(operation, target->Path, target->ResourceInstanceID, value) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsCString failed\n"); result = -1; } break; } case AwaResourceType_FloatArray: { AwaFloat tmp = 0.0; sscanf(value, "%20lf", &tmp); if (AwaServerWriteOperation_AddArrayValueAsFloat(operation, target->Path, target->ResourceInstanceID, tmp) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsFloat failed\n"); result = -1; } break; } case AwaResourceType_BooleanArray: { AwaBoolean boolValue = GetBooleanValue(value); if (AwaServerWriteOperation_AddArrayValueAsBoolean(operation, target->Path, target->ResourceInstanceID, boolValue) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsBoolean failed\n"); result = -1; } break; } case AwaResourceType_OpaqueArray: { AwaOpaque opaqueValue = MakeOpaqueValue(value, strlen(value)); if (AwaServerWriteOperation_AddArrayValueAsOpaque(operation, target->Path, target->ResourceInstanceID, opaqueValue) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsOpaque failed\n"); result = -1; } break; } case AwaResourceType_TimeArray: { AwaTime tmp = strtoimax(value, NULL, 10); if (AwaServerWriteOperation_AddArrayValueAsTime(operation, target->Path, target->ResourceInstanceID, tmp) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsTime failed\n"); result = -1; } break; } case AwaResourceType_ObjectLinkArray: { AwaObjectLink objectLink; if (!SetObjectLinkFromInput(&objectLink, value)) { Error("AwaServerWriteOperation_AddArrayValueAsObjectLink failed\n"); result = -1; break; } if (AwaServerWriteOperation_AddArrayValueAsObjectLink(operation, target->Path, target->ResourceInstanceID, objectLink) != AwaError_Success) { Error("AwaServerWriteOperation_AddArrayValueAsObjectLink failed\n"); result = -1; } break; } default: Error("Unhandled type\n"); result = -1; } } } } else { Error("%s is not defined\n", target->Path); result = -1; } } else { Error("value is NULL\n"); result = -1; } } else { Error("target is NULL\n"); result = -1; } } else { Error("operation is NULL\n"); result = -1; } return result; }
//----------------------------------------------------------------------------- // Returns true if an element is equal //----------------------------------------------------------------------------- static bool IsScalarAttributesEqual( CDmElement *pElement1, CDmElement *pElement2 ) { int nCount = pElement1->AttributeCount(); if ( nCount != pElement2->AttributeCount() ) return false; for ( CDmAttribute *pAtt1 = pElement1->FirstAttribute(); pAtt1; pAtt1 = pAtt1->NextAttribute() ) { CDmAttribute *pAtt2 = pElement2->GetAttribute( pAtt1->GetName() ); if ( !pAtt2 ) return false; if ( pAtt1->GetType() != pAtt2->GetType() ) return false; if ( IsArrayType( pAtt1->GetType() ) ) continue; switch( pAtt1->GetType() ) { case AT_FLOAT: if ( pAtt1->GetValue<float>() != pAtt2->GetValue<float>() ) return false; break; case AT_BOOL: if ( pAtt1->GetValue<bool>() != pAtt2->GetValue<bool>() ) return false; break; case AT_INT: if ( pAtt1->GetValue<int>() != pAtt2->GetValue<int>() ) return false; break; case AT_STRING: if ( Q_stricmp( pAtt1->GetValueString(), pAtt2->GetValueString() ) ) return false; break; case AT_VECTOR2: if ( pAtt1->GetValue<Vector2D>() != pAtt2->GetValue<Vector2D>() ) return false; break; case AT_VECTOR3: if ( pAtt1->GetValue<Vector>() != pAtt2->GetValue<Vector>() ) return false; break; case AT_VECTOR4: if ( pAtt1->GetValue<Vector4D>() != pAtt2->GetValue<Vector4D>() ) return false; break; case AT_COLOR: if ( pAtt1->GetValue<Color>() != pAtt2->GetValue<Color>() ) return false; break; } } return true; }
asCString asCDataType::Format(asSNameSpace *currNs, bool includeNamespace) const { if( IsNullHandle() ) return "<null handle>"; asCString str; if( isReadOnly ) str = "const "; // If the type is not declared in the current namespace, then the namespace // must always be informed to guarantee that the correct type is informed if( includeNamespace || (objectType && objectType->nameSpace != currNs) || (funcDef && funcDef->nameSpace != currNs) ) { if( objectType && objectType->nameSpace->name != "" ) str += objectType->nameSpace->name + "::"; else if( funcDef && funcDef->nameSpace->name != "" ) str += funcDef->nameSpace->name + "::"; } if( tokenType != ttIdentifier ) { str += asCTokenizer::GetDefinition(tokenType); } else if( IsArrayType() && objectType && !objectType->engine->ep.expandDefaultArrayToTemplate ) { asASSERT( objectType->templateSubTypes.GetLength() == 1 ); str += objectType->templateSubTypes[0].Format(currNs, includeNamespace); str += "[]"; } else if( funcDef ) { str += funcDef->name; } else if( objectType ) { str += objectType->name; if( objectType->templateSubTypes.GetLength() > 0 ) { str += "<"; for( asUINT subtypeIndex = 0; subtypeIndex < objectType->templateSubTypes.GetLength(); subtypeIndex++ ) { str += objectType->templateSubTypes[subtypeIndex].Format(currNs, includeNamespace); if( subtypeIndex != objectType->templateSubTypes.GetLength()-1 ) str += ","; } str += ">"; } } else if( isAuto ) { if( isObjectHandle ) str += "<auto@>"; else str += "<auto>"; } else { str = "<unknown>"; } if( isObjectHandle ) { str += "@"; if( isConstHandle ) str += "const"; } if( isReference ) str += "&"; return str; }