CopyTypeFrom() public method

public CopyTypeFrom ( CppType type ) : CppType
type CppType
return CppType
Beispiel #1
0
 CppType GetType(Node n, CppType modifiers)
 {
     switch (n.Type) {
     case "ArrayType":
         return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Array));
     case "PointerType":
         return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Pointer));
     case "ReferenceType":
         return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Reference));
     case "FundamentalType":
         return modifiers.CopyTypeFrom (new CppType (n.Name));
     case "CvQualifiedType":
         if (n.IsTrue ("const"))
             return GetType (GetTypeNode (n), modifiers.Modify (CppModifiers.Const));
         else
             throw new NotImplementedException ();
     case "Class":
     case "Struct":
         if (!NodeToClass.ContainsKey (n)) {
             if (modifiers.Modifiers.Count () == 1 && modifiers.Modifiers [0] == CppModifiers.Pointer)
                 // Map these to void*
                 return modifiers.CopyTypeFrom (CppTypes.Void);
             else
                 return CppTypes.Unknown;
         }
         return modifiers.CopyTypeFrom (new CppType (CppTypes.Class, NodeToClass [n].Name));
     default:
         return CppTypes.Unknown;
     }
 }
Beispiel #2
0
        public virtual CppType GetMangleType(ICustomAttributeProvider icap, Type managedType)
        {
            CppType mangleType = new CppType ();
            MangleAsAttribute maa = (MangleAsAttribute)icap.GetCustomAttributes (typeof (MangleAsAttribute), false).FirstOrDefault ();
            if (maa != null)
                mangleType = maa.MangleType;

            // this means that either no MangleAsAttribute was defined, or
            //  only CppModifiers were applied .. apply CppType from managed parameter type
            if (mangleType.ElementType == CppTypes.Unknown && mangleType.ElementTypeName == null)
                mangleType.CopyTypeFrom (CppType.ForManagedType (managedType));
            else if (mangleType.ElementType == CppTypes.Unknown)
                // FIXME: otherwise, we just assume it's CppTypes.Class for now.
                mangleType.ElementType = CppTypes.Class;

            return mangleType;
        }