Changeset 339:ef242de1fb2b in finroc_core-java


Ignore:
Timestamp:
21.03.2020 08:34:20 (12 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Adds support for composite port interface inheritance - and fixes glitches in computing remote type conversion ratings with port composite interfaces involved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • remote/RemoteRuntime.java

    r337 r339  
    610610        ratings.cachedConversionRatings = new byte[ratings.typeCount]; 
    611611        System.arraycopy(singleRatings.cachedConversionRatings, 0, ratings.cachedConversionRatings, 0, singleRatings.cachedConversionRatings.length); 
    612         if (getSerializationInfo().getRevision() != 0) { 
     612 
     613        if (type.getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && type.getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE) { 
     614            if (getSerializationInfo().getRevision() != 0) { 
     615                for (int i = 0; i < ratings.cachedConversionRatings.length; i++) { 
     616                    if (ratings.cachedConversionRatings[i] == 0 && remoteTypes.get(i).getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && remoteTypes.get(i).getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE) { 
     617                        ratings.cachedConversionRatings[i] = 1; // Deprecated binary conversion works for all types 
     618                    } 
     619                } 
     620            } 
     621            ratings.cachedConversionRatings[type.getHandle()] = (byte)TypeConversionRating.NO_CONVERSION.ordinal(); 
     622 
     623            // Continue from all single operation entries 
    613624            for (int i = 0; i < ratings.cachedConversionRatings.length; i++) { 
    614                 if (ratings.cachedConversionRatings[i] == 0 && remoteTypes.get(i).getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && remoteTypes.get(i).getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE) { 
    615                     ratings.cachedConversionRatings[i] = 1; // Deprecated binary conversion works for all types 
    616                 } 
    617             } 
    618         } 
    619         ratings.cachedConversionRatings[type.getHandle()] = (byte)TypeConversionRating.NO_CONVERSION.ordinal(); 
    620  
    621         // Continue from all single operation entries 
    622         for (int i = 0; i < ratings.cachedConversionRatings.length; i++) { 
    623             byte rating = ratings.cachedConversionRatings[i]; 
    624             if (isSingleOperationRating(rating)) { 
    625                 RemoteType.CachedConversionRatings intermediateRatings = getTypeSingleConversionRatings(remoteTypes.get(i)); 
    626                 for (int j = 0; j < ratings.cachedConversionRatings.length; j++) { 
    627                     byte rating2 = intermediateRatings.cachedConversionRatings[j]; 
    628                     if (isSingleOperationRating(rating2)) { 
    629                         int implicitCasts = (rating == Definitions.TypeConversionRating.IMPLICIT_CAST.ordinal() ? 1 : 0) + (rating2 == Definitions.TypeConversionRating.IMPLICIT_CAST.ordinal() ? 1 : 0); 
    630                         boolean deprecatedConversion = ((rating == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_FROM_GENERIC_TYPE.ordinal()) && (rating2 == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_TO_GENERIC_TYPE.ordinal())) || 
    631                                                        ((rating2 == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_FROM_GENERIC_TYPE.ordinal()) && (rating == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_TO_GENERIC_TYPE.ordinal())); 
    632                         updateConversionRating(ratings.cachedConversionRatings, j, deprecatedConversion ? Definitions.TypeConversionRating.UNUSUAL_CONVERSION : (implicitCasts == 2 ? Definitions.TypeConversionRating.TWO_IMPLICIT_CASTS : (implicitCasts == 1 ? Definitions.TypeConversionRating.EXPLICIT_CONVERSION_AND_IMPLICIT_CAST : Definitions.TypeConversionRating.TWO_EXPLICIT_CONVERSIONS))); 
     625                byte rating = ratings.cachedConversionRatings[i]; 
     626                if (isSingleOperationRating(rating)) { 
     627                    RemoteType.CachedConversionRatings intermediateRatings = getTypeSingleConversionRatings(remoteTypes.get(i)); 
     628                    for (int j = 0; j < ratings.cachedConversionRatings.length; j++) { 
     629                        byte rating2 = intermediateRatings.cachedConversionRatings[j]; 
     630                        if (isSingleOperationRating(rating2)) { 
     631                            int implicitCasts = (rating == Definitions.TypeConversionRating.IMPLICIT_CAST.ordinal() ? 1 : 0) + (rating2 == Definitions.TypeConversionRating.IMPLICIT_CAST.ordinal() ? 1 : 0); 
     632                            boolean deprecatedConversion = ((rating == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_FROM_GENERIC_TYPE.ordinal()) && (rating2 == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_TO_GENERIC_TYPE.ordinal())) || 
     633                                                           ((rating2 == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_FROM_GENERIC_TYPE.ordinal()) && (rating == Definitions.TypeConversionRating.EXPLICIT_CONVERSION_TO_GENERIC_TYPE.ordinal())); 
     634                            updateConversionRating(ratings.cachedConversionRatings, j, deprecatedConversion ? Definitions.TypeConversionRating.UNUSUAL_CONVERSION : (implicitCasts == 2 ? Definitions.TypeConversionRating.TWO_IMPLICIT_CASTS : (implicitCasts == 1 ? Definitions.TypeConversionRating.EXPLICIT_CONVERSION_AND_IMPLICIT_CAST : Definitions.TypeConversionRating.TWO_EXPLICIT_CONVERSIONS))); 
     635                        } 
    633636                    } 
    634637                } 
    635638            } 
    636         } 
    637  
    638         // For/each operation 
    639         if (type.getTypeClassification() == DataTypeBase.CLASSIFICATION_LIST || type.getTypeClassification() == DataTypeBase.CLASSIFICATION_ARRAY) { 
    640             RemoteType elementType = remoteTypes.get(type.getElementType()); 
    641             RemoteType.CachedConversionRatings intermediateRatings = getTypeSingleConversionRatings(elementType); 
    642             for (int i = 0; i < ratings.cachedConversionRatings.length; i++) { 
    643                 RemoteType destinationType = remoteTypes.get(i); 
    644                 if (destinationType.getTypeClassification() == DataTypeBase.CLASSIFICATION_LIST || (destinationType.getTypeClassification() == DataTypeBase.CLASSIFICATION_ARRAY && type.getTypeClassification() == DataTypeBase.CLASSIFICATION_ARRAY && type.getArraySize() == destinationType.getArraySize())) { 
    645                     RemoteType destinationElementType = remoteTypes.get(destinationType.getElementType()); 
    646                     byte rating = intermediateRatings.cachedConversionRatings[destinationElementType.getHandle()]; 
    647                     if (isSingleOperationRating(rating)) { 
    648                         updateConversionRating(ratings.cachedConversionRatings, destinationType.getHandle(), rating == Definitions.TypeConversionRating.IMPLICIT_CAST.ordinal() ? Definitions.TypeConversionRating.EXPLICIT_CONVERSION : Definitions.TypeConversionRating.TWO_EXPLICIT_CONVERSIONS); 
     639 
     640            // For/each operation 
     641            if (type.getTypeClassification() == DataTypeBase.CLASSIFICATION_LIST || type.getTypeClassification() == DataTypeBase.CLASSIFICATION_ARRAY) { 
     642                RemoteType elementType = remoteTypes.get(type.getElementType()); 
     643                RemoteType.CachedConversionRatings intermediateRatings = getTypeSingleConversionRatings(elementType); 
     644                for (int i = 0; i < ratings.cachedConversionRatings.length; i++) { 
     645                    RemoteType destinationType = remoteTypes.get(i); 
     646                    if (destinationType.getTypeClassification() == DataTypeBase.CLASSIFICATION_LIST || (destinationType.getTypeClassification() == DataTypeBase.CLASSIFICATION_ARRAY && type.getTypeClassification() == DataTypeBase.CLASSIFICATION_ARRAY && type.getArraySize() == destinationType.getArraySize())) { 
     647                        RemoteType destinationElementType = remoteTypes.get(destinationType.getElementType()); 
     648                        byte rating = intermediateRatings.cachedConversionRatings[destinationElementType.getHandle()]; 
     649                        if (isSingleOperationRating(rating)) { 
     650                            updateConversionRating(ratings.cachedConversionRatings, destinationType.getHandle(), rating == Definitions.TypeConversionRating.IMPLICIT_CAST.ordinal() ? Definitions.TypeConversionRating.EXPLICIT_CONVERSION : Definitions.TypeConversionRating.TWO_EXPLICIT_CONVERSIONS); 
     651                        } 
    649652                    } 
    650653                } 
     
    10641067     */ 
    10651068    private boolean isTypeSupported(RemoteType type, SupportedTypeFilter filter, RemoteType singleType) { 
    1066         return (filter == SupportedTypeFilter.ALL) || 
    1067                (filter == SupportedTypeFilter.BINARY_SERIALIZABLE && (type.getTypeTraits() & DataTypeBase.IS_BINARY_SERIALIZABLE) != 0) || 
    1068                (filter == SupportedTypeFilter.SINGLE && singleType == type) || 
    1069                (filter == SupportedTypeFilter.STRING_SERIALIZABLE && (type.getTypeTraits() & DataTypeBase.IS_STRING_SERIALIZABLE) != 0) || 
    1070                (filter == SupportedTypeFilter.LISTS && (type.getTypeClassification() == DataTypeBase.CLASSIFICATION_LIST)); 
     1069        return (type.getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && type.getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE && type.getTypeClassification() != DataTypeBase.CLASSIFICATION_NULL_TYPE) && ( 
     1070                   (filter == SupportedTypeFilter.ALL) || 
     1071                   (filter == SupportedTypeFilter.BINARY_SERIALIZABLE && (type.getTypeTraits() & DataTypeBase.IS_BINARY_SERIALIZABLE) != 0) || 
     1072                   (filter == SupportedTypeFilter.SINGLE && singleType == type) || 
     1073                   (filter == SupportedTypeFilter.STRING_SERIALIZABLE && (type.getTypeTraits() & DataTypeBase.IS_STRING_SERIALIZABLE) != 0) || 
     1074                   (filter == SupportedTypeFilter.LISTS && (type.getTypeClassification() == DataTypeBase.CLASSIFICATION_LIST))); 
    10711075    } 
    10721076 
     
    11131117            for (int i = 0; i < result.typeCount; i++) { 
    11141118                RemoteType type = remoteTypes.get(i); 
    1115                 if ((type.getTypeTraits() & requiredFlag) == requiredFlag && (requiredClassification == 0 || type.getTypeClassification() == requiredClassification)) { 
     1119                if ((type.getTypeTraits() & requiredFlag) == requiredFlag && (requiredClassification == 0 || type.getTypeClassification() == requiredClassification) && type.getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && type.getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE) { 
    11161120                    updateConversionRating(result.cachedConversionRatings, type.getHandle(), Definitions.TypeConversionRating.EXPLICIT_CONVERSION_FROM_GENERIC_TYPE); 
    11171121                } 
     
    12141218 
    12151219        // Process type conversion operations 
    1216         for (int i = 0; i < ratings.typeConversionOperationCount; i++) { 
    1217             RemoteTypeConversion conversion = remoteTypeConversions.get(i); 
    1218             if (isTypeSupported(type, conversion.getSupportedSourceTypes(), conversion.getSupportedSourceType())) { 
    1219                 addAllDestinationTypes(ratings, conversion); 
     1220        if (type.getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && type.getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE) { 
     1221            for (int i = 0; i < ratings.typeConversionOperationCount; i++) { 
     1222                RemoteTypeConversion conversion = remoteTypeConversions.get(i); 
     1223                if (isTypeSupported(type, conversion.getSupportedSourceTypes(), conversion.getSupportedSourceType())) { 
     1224                    addAllDestinationTypes(ratings, conversion); 
     1225                } 
    12201226            } 
    12211227        } 
Note: See TracChangeset for help on using the changeset viewer.