/// <summary> /// See <see cref="System.Attribute.Equals"/>. /// </summary> public override bool Equals(object obj) { InterfaceTypeAttribute other = obj as InterfaceTypeAttribute; if (other == null) { return(false); } return(m_idlType == other.m_idlType); }
/** handles the declaration for the value definition / fwd declaration * @return the TypeBuilder for this interface */ private TypeBuilder CreateOrGetValueDcl(Symbol forSymbol, System.Type parent, System.Type[] interfaces, bool isAbstract, bool isForwardDecl) { TypeBuilder valueToBuild; if (!m_typeManager.IsFwdDeclared(forSymbol)) { Trace.WriteLine("generating code for value type: " + forSymbol.getSymbolName()); TypeAttributes attrs = TypeAttributes.Public | TypeAttributes.Abstract; if (isAbstract) { attrs |= TypeAttributes.Interface; if (parent != null) { // classes are considered as concrete value types throw new InvalidIdlException("not possible for an abstract value type " + forSymbol.getDeclaredIn().GetFullyQualifiedNameForSymbol(forSymbol.getSymbolName()) + " to inherit from a concrete one " + parent.FullName); } } else { attrs |= TypeAttributes.Class; } valueToBuild = m_typeManager.StartTypeDefinition(forSymbol, attrs, parent, interfaces, isForwardDecl); if (isAbstract) { // add InterfaceTypeAttribute IdlTypeInterface ifType = IdlTypeInterface.AbstractValueType; CustomAttributeBuilder interfaceTypeAttrBuilder = new InterfaceTypeAttribute(ifType).CreateAttributeBuilder(); valueToBuild.SetCustomAttribute(interfaceTypeAttrBuilder); } valueToBuild.AddInterfaceImplementation(typeof(IIdlEntity)); // implement IDLEntity } else { // get incomplete type Trace.WriteLine("complete valuetype: " + forSymbol.getSymbolName()); valueToBuild = m_typeManager.GetIncompleteForwardDeclaration(forSymbol); // add inheritance relationship: for (int i = 0; i < interfaces.Length; i++) { valueToBuild.AddInterfaceImplementation(interfaces[i]); } if (parent != null) { valueToBuild.SetParent(parent); } } // add abstract methods for all interface methods, a class inherit from (only if valueToBuild is a class an not an interface) // add property to abstract class for all properties defined in an interface (only if valueToBuild is a class an not an interface) AddInheritedMembersAbstractDeclToClassForIf(valueToBuild, interfaces); return valueToBuild; }
/** handles the declaration for the interface definition / fwd declaration * @return the TypeBuilder for this interface */ private TypeBuilder CreateOrGetInterfaceDcl(Symbol forSymbol, System.Type[] interfaces, bool isAbstract, bool isLocal, bool isForward) { TypeBuilder interfaceToBuild = null; if (!m_typeManager.IsFwdDeclared(forSymbol)) { Trace.WriteLine("generating code for interface: " + forSymbol.getSymbolName()); interfaceToBuild = m_typeManager.StartTypeDefinition(forSymbol, TypeAttributes.Interface | TypeAttributes.Public | TypeAttributes.Abstract, null, interfaces, isForward); // add InterfaceTypeAttribute IdlTypeInterface ifType = IdlTypeInterface.ConcreteInterface; if (isAbstract) { ifType = IdlTypeInterface.AbstractInterface; } if (isLocal) { ifType = IdlTypeInterface.LocalInterface; } if ((isLocal) && (isAbstract)) { throw new InternalCompilerException("internal error: iftype precondition"); } // add interface type CustomAttributeBuilder interfaceTypeAttrBuilder = new InterfaceTypeAttribute(ifType).CreateAttributeBuilder(); interfaceToBuild.SetCustomAttribute(interfaceTypeAttrBuilder); interfaceToBuild.AddInterfaceImplementation(typeof(IIdlEntity)); } else { // get incomplete type Trace.WriteLine("complete interface: " + forSymbol.getSymbolName()); interfaceToBuild = m_typeManager.GetIncompleteForwardDeclaration(forSymbol); // add inheritance relationship: for (int i = 0; i < interfaces.Length; i++) { interfaceToBuild.AddInterfaceImplementation(interfaces[i]); } } return interfaceToBuild; }