// // ObjCTypeAssociate() // public ObjCTypeAssociation ObjCTypeAssociate(string managedType) { ObjCTypeAssociation typeAssoc = null; // look for literal association if (managedType != null && ObjCTypeAssociations.ContainsKey(managedType)) { typeAssoc = ObjCTypeAssociations[managedType]; } return(typeAssoc); }
// // AssociateTypes() // void AssociateTypes(ManagedTypeAssociation managedTA, ObjCTypeAssociation objcTA) { objcTA.ManagedTypeAssociate = managedTA; // 1:1 association from managed type to objc type // the managed type name key is undecorated ObjCTypeAssociations.Add(managedTA.ManagedType, objcTA); // 1:N association from objc declaration to managed type. // hence we qualify the objc declaration with the managed type name. string objCKey = objcTA.UniqueTypeNameForManagedType(managedTA.ManagedType); ManagedTypeAssociations.Add(objCKey, managedTA); }
// // ObjCTypeDeclFromManagedFacet() // public string ObjCTypeDeclFromManagedFacet(CodeFacet managedFacet, bool allowObjCTypeAssociation = true) { string decl = ""; // if the facet represents a generic parameter (or ref) then we // won't know the actual type until runtime, so we default to the System_Object; if (managedFacet.IsGenericParameterOrRef()) { decl = "System_Object *"; return(decl); } string managedType = ManagedTypeForAssociation(managedFacet); if (managedType == null) { return("????"); } if (allowObjCTypeAssociation && ObjCTypeAssociations.ContainsKey(managedType)) { decl = ObjCTypeAssociations[managedType].ObjCTypeDecl; if (managedFacet.IsPointer) { decl += " *"; } } else { // canonical type name. decl = ObjCIdentifierFromManagedIdentifier(managedType); if (managedFacet.IsEnum) { decl = "enum" + decl; } else { decl += " *"; } } return(decl); }
// // ObjCNonAssociatedTypeIsNSObject // //public static bool ObjCNonAssociatedTypeIsNSObject(CodeFacet facet) //{ // This assessment is only valid for non associated types. // ie: System.String will fail this test even though its ObjC rep is NSString. // Only call this method if associated type info cannot be found. // TODO: determine if association can be tested for in this method. // Logic : // Managed structs are value types, ObjC rep is an NSObject // return (!facet.IsValueType || facet.IsStruct); //} // // ObjCTypeNameFromManagedTypeName // string ObjCTypeNameFromManagedTypeName(string managedType) { string value = managedType; if (managedType == null) { return("DBManagedObject"); } // there are situations where we can encounter an excluded type // (such as the base class for a whitelisted type) if (!Config.GenerateTypeBinding(managedType)) { return("System_Object"); } if (ObjCTypeAssociations.ContainsKey(managedType) && ObjCTypeAssociations[managedType].ObjCType != null) { value = ObjCTypeAssociations[managedType].ObjCType; } return(ObjCIdentifierFromManagedIdentifier(value)); }