//============================================================ // 初期化 //============================================================ public AttributeCollection(LanguageWriter writer, ICustomAttributeProvider provider, IType type) { this.writer = writer; this.provider = provider; this.type = type; // 属性の対象 if (provider is IAssembly) { attr_class = "assembly"; isAsmOrModule = true; } else if (provider is IModule) { attr_class = "module"; isAsmOrModule = true; } else if (provider is IMethodReturnType) { attr_class = "returnvalue"; } // 個々の属性に対して走査 foreach (ICustomAttribute attr in provider.Attributes) { if (attr == null) { continue; } string attrname = GetCustomAttributeName(attr); switch (attrname) { case "ParamArray": case "System::ParamArray": containsParams = true; continue; case "MarshalAs": case "System::Runtime::InteropServices::MarshalAs": IExpressionCollection arguments = attr.Arguments; if (arguments == null) { break; } IFieldReferenceExpression exp_fld = arguments[0] as IFieldReferenceExpression; if (exp_fld == null) { break; } ITypeReferenceExpression target = exp_fld.Target as ITypeReferenceExpression; if (target == null || target.Type.Name != "UnmanagedType") { break; } IFieldReference field = exp_fld.Field; if (field.Name == "U1") { if (LanguageWriter.Type(type, "System", "Boolean")) { continue; } } else if (field.Name == "U2" && LanguageWriter.Type(type, "System", "Char")) { continue; } break; } attrs.Add(new AttrPair(attrname, attr)); } // 名前空間順に並び替え attrs.Sort(delegate(AttrPair l, AttrPair r){ string l_name = ((ITypeReference)l.Value.Constructor.DeclaringType).Namespace; string r_name = ((ITypeReference)r.Value.Constructor.DeclaringType).Namespace; return(l_name.CompareTo(r_name)); }); }