Exemple #1
0
 internal UnityTypeReference(string builtInType, EnumDefinitionRaw enumDefinition,
                             UnityTypeDefinition typeDefinition)
 {
     this.builtInType    = builtInType;
     this.enumDefinition = enumDefinition;
     this.typeDefinition = typeDefinition;
 }
Exemple #2
0
 public string Generate(UnityTypeDefinition typeDefinition, string package, HashSet <string> enumSet)
 {
     qualifiedNamespace  = UnityTypeMappings.PackagePrefix + package;
     this.typeDefinition = typeDefinition;
     this.enumSet        = enumSet;
     return(TransformText());
 }
Exemple #3
0
 public string Generate(UnityTypeDefinition typeDefinition, HashSet <string> enumSet)
 {
     this.typeDefinition = typeDefinition;
     this.enumSet        = enumSet;
     this.nestedTypes    = typeDefinition.TypeDefinitions;
     this.nestedEnums    = typeDefinition.EnumDefinitions.ToList();
     return(TransformText());
 }
Exemple #4
0
 public UnityTypeDetails(UnityTypeDefinition typeDefinition)
 {
     CapitalisedName = Formatting.SnakeCaseToCapitalisedCamelCase(typeDefinition.Name);
     CamelCaseName   = Formatting.SnakeCaseToCamelCase(typeDefinition.Name);
     FullyQualifiedSpatialTypeName =
         "global::" + Formatting.CapitaliseQualifiedNameParts(typeDefinition.QualifiedName);
     FullyQualifiedTypeName = "global::" + Formatting.CapitaliseQualifiedNameParts(typeDefinition.QualifiedName);
 }
Exemple #5
0
        private void ExtractEnums(UnityTypeDefinition typeDefinition, HashSet <string> enumSet)
        {
            foreach (var enumDefinition in typeDefinition.EnumDefinitions)
            {
                enumSet.Add(enumDefinition.qualifiedName);
            }

            foreach (var nestedTypeDefinition in typeDefinition.TypeDefinitions)
            {
                ExtractEnums(nestedTypeDefinition, enumSet);
            }
        }
Exemple #6
0
        private static bool ApplyBlittableMarkerToTypeRecursively(UnityTypeDefinition typeDefinition,
                                                                  Dictionary <string, bool> blittableTypeMap, Dictionary <string, UnityTypeDefinition> unvisited)
        {
            var isBlittable = typeDefinition.FieldDefinitions.All(fieldDefinition =>
                                                                  CanBlitFieldOfTypeRecursively(fieldDefinition, blittableTypeMap, unvisited));

            typeDefinition.IsBlittable = isBlittable;
            blittableTypeMap[typeDefinition.QualifiedName] = isBlittable;
            unvisited.Remove(typeDefinition.QualifiedName);

            return(isBlittable);
        }
Exemple #7
0
        private static void PopulateTypeDefinitionsRecursively(Dictionary <string, UnityTypeDefinition> typeMap,
                                                               HashSet <string> enumSet, UnityTypeDefinition typeDefinition)
        {
            foreach (var nestedTypeDefinition in typeDefinition.TypeDefinitions)
            {
                typeMap.Add(nestedTypeDefinition.QualifiedName, nestedTypeDefinition);
                PopulateTypeDefinitionsRecursively(typeMap, enumSet, nestedTypeDefinition);
            }

            foreach (var nestedEnumDefinition in typeDefinition.EnumDefinitions)
            {
                enumSet.Add(nestedEnumDefinition.qualifiedName);
            }
        }