Пример #1
0
        private void DetermineContentDependenciesFromMethods()
        {
            BindingFlags flags = BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public;

            MethodInfo[] methods = m_forType.GetMethods(flags);
            foreach (MethodInfo info in methods)
            {
                // return type
                Type returnType = info.ReturnType;
                if (!m_manager.IsDefaultMapped(returnType) && !returnType.Equals(m_forType))
                {
                    AddToDepList(m_dependenciesContent, CreateMapTypeInfo(returnType,
                                                                          ReflectionHelper.CollectReturnParameterAttributes(info)),
                                 false);
                }

                ParameterInfo[] methodParams = info.GetParameters();
                foreach (ParameterInfo paramInfo in methodParams)
                {
                    if (!m_manager.IsDefaultMapped(paramInfo.ParameterType) && !paramInfo.ParameterType.Equals(m_forType))
                    {
                        // only add to dependencies, if not default mapped and not the same as type which is checked
                        AddToDepList(m_dependenciesContent, CreateMapTypeInfo(paramInfo.ParameterType,
                                                                              ReflectionHelper.CollectParameterAttributes(paramInfo, info)),
                                     false);
                    }
                }

                if ((ClsToIdlMapper.IsMappedToAbstractInterface(m_forType) ||
                     ClsToIdlMapper.IsMappedToConcreteInterface(m_forType)))
                {
                    DetermineContentDependenciesFromExceptions(info);
                }
            }
        }
Пример #2
0
        public override void Serialize(Corba.DataOutputStream arg)
        {
            // rmi data
            arg.write_octet(1);
            arg.write_octet(1);
            // size: is equal to size of m_elements
            int size = m_elements.Length;

            arg.write_long(size);
            if (m_backArraySize < size)
            {
                m_backArraySize = size;
            }
            arg.write_long(m_backArraySize);

            for (int i = 0; i < size; i++)
            {
                bool isByRef = false;
                if (m_elements[i] != null)
                {
                    isByRef = ClsToIdlMapper.IsMappedToConcreteInterface(m_elements[i].GetType());
                }
                arg.write_boolean(isByRef);
                if (!isByRef)
                {
                    arg.write_ValueOfActualType(m_elements[i]);
                }
                else
                {
                    arg.write_Object((MarshalByRefObject)m_elements[i]);
                }
            }
        }
Пример #3
0
        private void DetermineContentDependencies(AttributeExtCollection attributesAfterMap)
        {
            m_dependenciesContent = new ArrayList();

            // for the following types methods and properties must be considered
            if (ClsToIdlMapper.IsMappedToConcreteValueType(m_forType) ||
                ClsToIdlMapper.IsMappedToAbstractValueType(m_forType) ||
                ClsToIdlMapper.IsMappedToConcreteInterface(m_forType) ||
                ClsToIdlMapper.IsMappedToAbstractInterface(m_forType) ||
                ClsToIdlMapper.IsMappedToLocalInterface(m_forType))
            {
                // check the methods
                DetermineContentDependenciesFromMethods();
                // check the properties
                DetermineContentDependenciesFromProperties();
            }

            // fields must be considered only for value-types
            if (ClsToIdlMapper.IsMappedToConcreteValueType(m_forType) ||
                ClsToIdlMapper.IsException(m_forType) ||
                ClsToIdlMapper.IsMarshalledAsStruct(m_forType) ||
                ClsToIdlMapper.IsMappedToBoxedValueType(m_forType))
            {
                DetermineContentDependenciesFromFields();
            }
            if (ClsToIdlMapper.IsArray(m_forType))
            {
                DetermineContentDependenciesFromElementType(attributesAfterMap);
            }
        }
Пример #4
0
        /// <summary>
        /// Maps the method name for the CLS method to IDL
        /// </summary>
        public static string MapClsMethodNameToIdlName(MethodInfo method, bool isOverloaded)
        {
            string methodName = MapClsNameToIdlName(method.Name);

            if (isOverloaded)
            {
                // do the mangling
                ParameterInfo[] parameters = method.GetParameters();
                if (parameters.Length == 0)
                {
                    methodName += "__";
                }
                ClsToIdlMapper mapper = ClsToIdlMapper.GetSingleton();
                foreach (ParameterInfo parameter in parameters)
                {
                    string mappedTypeName = (string)mapper.MapClsType(parameter.ParameterType,
                                                                      ReflectionHelper.CollectParameterAttributes(parameter, method),
                                                                      s_genIdlNameforClsTypeNoAnonSeq);
                    mappedTypeName = mappedTypeName.Replace(" ", "_");
                    mappedTypeName = mappedTypeName.Replace("::", "__");
                    methodName     = methodName + "__" + mappedTypeName;
                }
            }
            return(methodName);
        }
Пример #5
0
 /// <summary>
 /// returns true, if a forward declaration for the given type info is possible;
 /// it's not possible e.g. for Boxed value types.
 /// </summary>
 public bool IsForwardDeclPossible(Type forType, AttributeExtCollection attributes)
 {
     // boxed value types can't have forward declaration --> be sure to not include boxed value types here
     // CORBA 2.3: only concrete/abstract value types and concrete/abstract/local interface can be fwd declared.
     return((ClsToIdlMapper.IsMappedToConcreteValueType(forType) ||
             ClsToIdlMapper.IsMappedToAbstractValueType(forType, attributes) ||
             ClsToIdlMapper.IsMappedToConcreteInterface(forType) ||
             ClsToIdlMapper.IsMappedToAbstractInterface(forType) ||
             ClsToIdlMapper.IsMappedToLocalInterface(forType)) &&
            (!IsMappedBeforeGeneration(forType)));
     // don't create fwd references for entities, which are mapped before generation run
 }
Пример #6
0
        /// <summary>
        /// return the short type name of typedef for the idl sequence
        /// </summary>
        public static string GetTypeDefAliasForSequenceType(Type seqType, int bound, AttributeExtCollection elemTypeAttributes, out string namespaceName, out string elemTypeFullQualName)
        {
            elemTypeFullQualName = (string)ClsToIdlMapper.GetSingleton().MapClsType(seqType.GetElementType(), elemTypeAttributes,
                                                                                    s_genIdlNameforClsTypeNoAnonSeq);

            string elemTypeNameId = elemTypeFullQualName.Replace(":", "_");

            elemTypeNameId = elemTypeNameId.Replace(" ", "_");
            string typedefName = "seqTd" + bound + "_" + elemTypeNameId;

            namespaceName = "org.omg.seqTypeDef";
            return(typedefName);
        }
Пример #7
0
 /// <summary>used by type code creating methods</summary>
 internal static TypeCodeImpl CreateTypeCodeForTypeInternal(Type forType, AttributeExtCollection attributes,
                                                            TypeCodeCreater typeCodeCreator)
 {
     if (forType != null)
     {
         ClsToIdlMapper mapper = ClsToIdlMapper.GetSingleton();
         return((TypeCodeImpl)mapper.MapClsType(forType, attributes, typeCodeCreator));
     }
     else
     {
         // if no type info present, map to null typecode; the case can't be handled by cls to idl mapper
         return(new NullTC());
     }
 }
Пример #8
0
        public static void Main(string[] args)
        {
            try {
                Type typeToMap = ParseArgs(args);

                Console.WriteLine("emitting Predef.idl");
                EmitPredefIdl();
                Console.WriteLine("generating IDL for type: " + typeToMap.FullName);
                Console.WriteLine("destination: " + s_destination);
                ClsToIdlMapper mapper = ClsToIdlMapper.GetSingleton();
                mapper.MapClsType(typeToMap,
                                  AttributeExtCollection.EmptyCollection, new GenerationActionDefineTypes(s_destination));
            } catch (Exception e) {
                Console.WriteLine("error while running generator: " + e);
            }
        }
Пример #9
0
        private void WriteObject(object val, Corba.DataOutputStream target)
        {
            bool isByRef = false;

            if (val != null)
            {
                isByRef = ClsToIdlMapper.IsMappedToConcreteInterface(val.GetType());
            }
            target.write_boolean(isByRef);
            if (!isByRef)
            {
                target.write_ValueOfActualType(val);
            }
            else
            {
                target.write_Object((MarshalByRefObject)val);
            }
        }
Пример #10
0
        /// <summary>determines the non-default types, this type depends on</summary>
        private void DetermineInheritanceDependencies()
        {
            m_dependenciesInheritance = new ArrayList();

            // for the following types the base classes must be mapped
            if (m_forType.IsClass &&
                (ClsToIdlMapper.IsMappedToConcreteValueType(m_forType) ||
                 ClsToIdlMapper.IsMappedToAbstractValueType(m_forType) ||
                 ClsToIdlMapper.IsMappedToConcreteInterface(m_forType) ||
                 ClsToIdlMapper.IsMappedToAbstractInterface(m_forType) ||
                 ClsToIdlMapper.IsMappedToLocalInterface(m_forType)))
            {
                // boxed value types are excluded here, because they do not have inheritance dependencies
                Type baseType = m_forType.BaseType;
                if (!((baseType.Equals(typeof(System.Object))) || (baseType.Equals(typeof(System.ValueType))) ||
                      (baseType.Equals(typeof(System.ComponentModel.MarshalByValueComponent))) ||
                      (baseType.Equals(typeof(System.MarshalByRefObject)))))
                {
                    AddToDepList(m_dependenciesInheritance,
                                 CreateMapTypeInfo(baseType, AttributeExtCollection.EmptyCollection),
                                 true);
                }
            }

            // for the following types, implemented interfaces must be considered
            if (ClsToIdlMapper.IsMappedToAbstractValueType(m_forType) ||
                ClsToIdlMapper.IsMappedToConcreteValueType(m_forType) ||
                ClsToIdlMapper.IsMappedToConcreteInterface(m_forType) ||
                ClsToIdlMapper.IsMappedToAbstractInterface(m_forType) ||
                ClsToIdlMapper.IsMappedToLocalInterface(m_forType))
            {
                Type[] implementedIF = m_forType.GetInterfaces();
                for (int i = 0; i < implementedIF.Length; i++)
                {
                    // don't map to IDL, if not legal to inherit from
                    if (ClsToIdlMapper.MapInheritanceFromInterfaceToIdl(implementedIF[i], m_forType))
                    {
                        AddToDepList(m_dependenciesInheritance,
                                     CreateMapTypeInfo(implementedIF[i], AttributeExtCollection.EmptyCollection),
                                     true);
                    }
                }
            }
        }
Пример #11
0
 public object MapToIdlEnum(System.Type clsType)
 {
     lock (m_enumSers.SyncRoot) {
         Serializer result = (Serializer)m_enumSers[clsType];
         if (result == null)
         {
             if (ClsToIdlMapper.IsIdlEnum(clsType))
             {
                 result = new IdlEnumSerializer(clsType);
             }
             else
             {
                 result = new EnumMapClsToIdlRangeSerializer(clsType);
             }
             m_enumSers[clsType] = result;
         }
         return(result);
     }
 }
Пример #12
0
        /// <summary>
        /// return the short type name of typedef for the idl array
        /// </summary>
        public static string GetTypeDefAliasForArrayType(Type arrayType, int[] dimensions, AttributeExtCollection elemTypeAttributes, out string namespaceName, out string elemTypeFullQualName)
        {
            elemTypeFullQualName = (string)ClsToIdlMapper.GetSingleton().MapClsType(arrayType.GetElementType(), elemTypeAttributes,
                                                                                    s_genIdlNameforClsTypeNoAnonSeq);

            string elemTypeNameId = elemTypeFullQualName.Replace(":", "_");

            elemTypeNameId = elemTypeNameId.Replace(" ", "_");
            string dimensionRep = "";

            for (int i = 0; i < dimensions.Length; i++)
            {
                dimensionRep = dimensionRep + "_" + dimensions[i];
            }
            string typedefName = "arrayTd" + dimensionRep + "_" + elemTypeNameId;

            namespaceName = "org.omg.arrayTypeDef";
            return(typedefName);
        }