public override bool SupportsSourceMapping(ASSourceMappingDescriptor descriptor) { ASTypeKind sourceKind = descriptor.SourceKind; return(descriptor.TargetNativeType.IsEnum && (sourceKind == ASTypeKind.Int29 || sourceKind == ASTypeKind.Number || sourceKind == ASTypeKind.String)); }
/// <inheritdoc /> public override IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor) { foreach (PrimitiveMapper mapper in mappers) { if (mapper.SupportsSourceMapping(descriptor)) { return(mapper); } } return(null); }
/// <inheritdoc /> public override IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor) { if ((descriptor.SourceKind == ASTypeKind.Array || descriptor.SourceKind == ASTypeKind.ByteArray) && (descriptor.SourceContentFlags & ASValueContentFlags.HasDynamicProperties) == 0 && descriptor.TargetNativeType.IsArray) { Type[] genericTypes = new Type[] { descriptor.TargetNativeType.GetElementType() }; return((IASSourceMapper)MappingUtils.InvokeGenericMethod(genericTypes, getMapperInstance, EmptyArray <object> .Instance)); } return(null); }
/// <inheritdoc /> public override IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor) { if (descriptor.SourceKind == ASTypeKind.Object) { ActionScriptClassMapping classMapping = mappingTable.GetClassMappingByAlias(descriptor.SourceClassAlias); if (classMapping != null && descriptor.TargetNativeType.IsAssignableFrom(classMapping.NativeType)) { return(new ObjectMapper(classMapping)); } } return(null); }
/// <inheritdoc /> public override IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor) { if ((descriptor.SourceKind == ASTypeKind.Array || descriptor.SourceKind == ASTypeKind.Object) && (descriptor.SourceContentFlags & ASValueContentFlags.HasIndexedValues) == 0) { Type[] genericTypeArgs = MappingUtils.GetGenericDictionaryTypeArgs(descriptor.TargetNativeType); if (genericTypeArgs != null) { return((IASSourceMapper)MappingUtils.InvokeGenericMethod(genericTypeArgs, getMapperInstance, new object[] { descriptor.TargetNativeType })); } } return(null); }
public virtual bool SupportsSourceMapping(ASSourceMappingDescriptor descriptor) { // Note: Use strict equality here because we don't want to use // most primitive mappings if the result type is underspecified. // How would we know whether to map to "int" or "long"? The mapping // would be ambiguous! Instead we handle this case with default native type // mappings elsewhere. if (descriptor.TargetNativeType == type) { foreach (ASTypeKind kind in kinds) { if (descriptor.SourceKind == kind) { return(true); } } } return(false); }
/// <summary> /// Gets an ActionScript source mapper that satisfies the specified descriptor. /// </summary> /// <param name="descriptor">The source mapping descriptor</param> /// <returns>The ActionScript target mapper, or null if no compatible mapper can be obtained by any registered factory</returns> public IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor) { lock (syncRoot) { IASSourceMapper mapper; if (!sourceMapperCache.TryGetValue(descriptor, out mapper)) { foreach (IASMapperFactory factory in mapperFactories) { mapper = factory.GetASSourceMapper(descriptor); if (mapper != null) { break; } } sourceMapperCache.Add(descriptor, mapper); } return(mapper); } }
/// <summary> /// Gets an ActionScript source mapper that satisfies the specified descriptor. /// </summary> /// <param name="descriptor">The source mapping descriptor</param> /// <returns>The ActionScript target mapper, or null if no compatible mapper can be obtained by this factory</returns> public virtual IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor) { return(null); }