Changeset 36:fc2bc404fdb5 in rrlib_rtti_conversion


Ignore:
Timestamp:
04.05.2020 23:27:27 (19 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Children:
37:5bfa1458cd2c, 38:ae1ecd302f54
Phase:
public
Message:

Fixes compiler warning with gcc 9.3 (initialization with memset)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • defined_conversions.cpp

    r32 r36  
    377377    auto index_parameter = operation.GetParameterValue(); 
    378378    unsigned int index = index_parameter ? (*index_parameter.Get<unsigned int>()) : 0; 
    379     auto result = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().computation_types[0]).GetVectorElement(index); 
     379    auto result = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().ComputationTypes()[0]).GetVectorElement(index); 
    380380    if (!result) 
    381381    { 
     
    389389    auto index_parameter = operation.GetParameterValue(); 
    390390    unsigned int index = index_parameter ? (*index_parameter.Get<unsigned int>()) : 0; 
    391     auto intermediate = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().computation_types[0]).GetVectorElement(index); 
     391    auto intermediate = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().ComputationTypes()[0]).GetVectorElement(index); 
    392392    if (!intermediate) 
    393393    { 
     
    399399  virtual void OnCompile(const tConversionOption& conversion_option, tCustomOperationData& custom_data) const 
    400400  { 
    401     custom_data.computation_types[0] = conversion_option.source_type; 
    402     while (!(custom_data.computation_types[0].IsListType() || custom_data.computation_types[0].IsArray())) 
    403     { 
    404       custom_data.computation_types[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.computation_types[0]); 
    405       if (!custom_data.computation_types[0]) 
     401    custom_data.ComputationTypes()[0] = conversion_option.source_type; 
     402    while (!(custom_data.ComputationTypes()[0].IsListType() || custom_data.ComputationTypes()[0].IsArray())) 
     403    { 
     404      custom_data.ComputationTypes()[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.ComputationTypes()[0]); 
     405      if (!custom_data.ComputationTypes()[0]) 
    406406      { 
    407407        throw std::runtime_error("Source type must be list or array"); 
     
    434434  static void FirstConversionFunction(const tTypedConstPointer& source_object_original, const tTypedPointer& destination_object_original, const tCurrentConversionOperation& operation) 
    435435  { 
    436     tTypedConstPointer source_object = tTypedConstPointer(source_object_original.GetRawDataPointer(), operation.GetCustomData().computation_types[0]); 
     436    tTypedConstPointer source_object = tTypedConstPointer(source_object_original.GetRawDataPointer(), operation.GetCustomData().ComputationTypes()[0]); 
    437437    const tType& source_type = source_object.GetType(); 
    438438    tType destination_type = destination_object_original.GetType(); 
     
    650650  virtual void OnCompile(const tConversionOption& conversion_option, tCustomOperationData& custom_data) const 
    651651  { 
    652     custom_data.computation_types[0] = conversion_option.source_type; 
    653     while (!(custom_data.computation_types[0].IsListType() || custom_data.computation_types[0].IsArray())) 
    654     { 
    655       custom_data.computation_types[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.computation_types[0]); 
    656       if (!custom_data.computation_types[0]) 
     652    custom_data.ComputationTypes()[0] = conversion_option.source_type; 
     653    while (!(custom_data.ComputationTypes()[0].IsListType() || custom_data.ComputationTypes()[0].IsArray())) 
     654    { 
     655      custom_data.ComputationTypes()[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.ComputationTypes()[0]); 
     656      if (!custom_data.ComputationTypes()[0]) 
    657657      { 
    658658        throw std::runtime_error("Source type must be list or array"); 
     
    694694  static void FinalConversionFunction(const tTypedConstPointer& source_object, const tTypedPointer& destination_object, const tCurrentConversionOperation& operation) 
    695695  { 
    696     const tType& source_type = operation.GetCustomData().computation_types[0]; 
     696    const tType& source_type = operation.GetCustomData().ComputationTypes()[0]; 
    697697    const tType source_element_type = source_type.GetElementType(); 
    698698    size_t size = source_type.GetArraySize(); 
     
    722722  virtual void OnCompile(const tConversionOption& conversion_option, tCustomOperationData& custom_data) const 
    723723  { 
    724     custom_data.computation_types[0] = conversion_option.source_type; 
    725     while (!custom_data.computation_types[0].IsArray()) 
    726     { 
    727       custom_data.computation_types[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.computation_types[0]); 
    728       if (!custom_data.computation_types[0]) 
     724    custom_data.ComputationTypes()[0] = conversion_option.source_type; 
     725    while (!custom_data.ComputationTypes()[0].IsArray()) 
     726    { 
     727      custom_data.ComputationTypes()[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.ComputationTypes()[0]); 
     728      if (!custom_data.ComputationTypes()[0]) 
    729729      { 
    730730        throw std::runtime_error("Source type must be array"); 
     
    825825  static void FirstConversionFunction(const tTypedConstPointer& source_object, const tTypedPointer& destination_object, const tCurrentConversionOperation& operation) 
    826826  { 
    827     size_t size = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().computation_types[0]).GetVectorSize(); 
     827    size_t size = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().ComputationTypes()[0]).GetVectorSize(); 
    828828    operation.Continue(tTypedConstPointer(&size), destination_object); 
    829829  } 
     
    831831  static void FinalConversionFunction(const tTypedConstPointer& source_object, const tTypedPointer& destination_object, const tCurrentConversionOperation& operation) 
    832832  { 
    833     (*destination_object.Get<size_t>()) = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().computation_types[0]).GetVectorSize(); 
     833    (*destination_object.Get<size_t>()) = tTypedConstPointer(source_object.GetRawDataPointer(), operation.GetCustomData().ComputationTypes()[0]).GetVectorSize(); 
    834834  } 
    835835 
    836836  virtual void OnCompile(const tConversionOption& conversion_option, tCustomOperationData& custom_data) const 
    837837  { 
    838     custom_data.computation_types[0] = conversion_option.source_type; 
    839     while (!custom_data.computation_types[0].IsListType()) 
    840     { 
    841       custom_data.computation_types[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.computation_types[0]); 
    842       if (!custom_data.computation_types[0]) 
     838    custom_data.ComputationTypes()[0] = conversion_option.source_type; 
     839    while (!custom_data.ComputationTypes()[0].IsListType()) 
     840    { 
     841      custom_data.ComputationTypes()[0] = GetUnderlyingTypeOperationsAreInheritedFrom(custom_data.ComputationTypes()[0]); 
     842      if (!custom_data.ComputationTypes()[0]) 
    843843      { 
    844844        throw std::runtime_error("Source type must be list"); 
     
    952952  { 
    953953    auto& custom_data = operation.GetCustomData(); 
    954     const tType source_type = custom_data.computation_types[0]; 
    955     const tType destination_type = custom_data.computation_types[1]; 
     954    const tType source_type = custom_data.ComputationTypes()[0]; 
     955    const tType destination_type = custom_data.ComputationTypes()[1]; 
    956956    const tType element_type = source_type.GetElementType(); 
    957957    size_t element_size = element_type.GetSize(); 
     
    978978  { 
    979979    const std::vector<bool>* source = source_object.GetUnchecked<std::vector<bool>>(); 
    980     const tType destination_type = operation.GetCustomData().computation_types[1]; 
     980    const tType destination_type = operation.GetCustomData().ComputationTypes()[1]; 
    981981    size_t destination_elements = destination_type.GetArraySize(); 
    982982 
     
    995995  { 
    996996    auto& custom_data = operation.GetCustomData(); 
    997     const tType destination_type = custom_data.computation_types[1]; 
     997    const tType destination_type = custom_data.ComputationTypes()[1]; 
    998998    const tType element_type = destination_type.GetElementType(); 
    999     tTypedConstPointer source_object(source_object_original.GetRawDataPointer(), custom_data.computation_types[0]); 
     999    tTypedConstPointer source_object(source_object_original.GetRawDataPointer(), custom_data.ComputationTypes()[0]); 
    10001000 
    10011001    size_t copy_elements = std::min(source_object.GetVectorSize(), destination_type.GetArraySize()); 
     
    10631063  virtual void OnCompile(const tConversionOption& conversion_option, tCustomOperationData& custom_data) const 
    10641064  { 
    1065     custom_data.computation_types[0] = GetSupportedType(conversion_option.source_type, true); 
    1066     custom_data.computation_types[1] = GetSupportedType(conversion_option.destination_type, true); 
     1065    custom_data.ComputationTypes()[0] = GetSupportedType(conversion_option.source_type, true); 
     1066    custom_data.ComputationTypes()[1] = GetSupportedType(conversion_option.destination_type, true); 
    10671067  } 
    10681068 
  • tRegisteredConversionOperation.h

    r32 r36  
    9999{ 
    100100  typedef void (*tConversionFunction)(const tTypedConstPointer& source_object, const tTypedPointer& destination_object, const tCurrentConversionOperation& operation); 
     101  typedef tType tTypeArray[2]; 
     102  typedef const tType tConstTypeArray[2]; 
    101103 
    102104  union 
    103105  { 
    104106    tConversionFunction conversion_function; 
    105     rrlib::rtti::tType computation_types[2]; 
     107    void* raw_pointers[2] = { nullptr, nullptr }; 
    106108  }; 
    107109 
    108   tCustomOperationData() 
    109   { 
    110     memset(this, 0, sizeof(tCustomOperationData)); 
     110  /*! 
     111   * \return Array of two non-initialized types 
     112   */ 
     113  tTypeArray& ComputationTypes() 
     114  { 
     115    return reinterpret_cast<tTypeArray&>(raw_pointers); 
     116  } 
     117  tConstTypeArray& ComputationTypes() const 
     118  { 
     119    return reinterpret_cast<tConstTypeArray&>(raw_pointers); 
    111120  } 
    112121}; 
Note: See TracChangeset for help on using the changeset viewer.