Ejemplo n.º 1
0
 private void RegisterBindings(ConfigFile file)
 {
     foreach (var bindingRule in file.Bindings)
     {
         typeRegistry.BindType(bindingRule.From, typeRegistry.ImportType(bindingRule.To),
                               string.IsNullOrEmpty(bindingRule.Marshal) ?
                               null
                  : typeRegistry.ImportType(bindingRule.Marshal));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Prepares C++ struct for mapping. This method is creating the associated C# struct.
        /// </summary>
        /// <param name="cppStruct">The c++ struct.</param>
        /// <returns></returns>
        public override CsStruct Prepare(CppStruct cppStruct)
        {
            // Create a new C# struct
            var nameSpace = namespaceRegistry.ResolveNamespace(cppStruct);
            var csStruct  = new CsStruct(cppStruct)
            {
                Name = NamingRules.Rename(cppStruct),
                // IsFullyMapped to false => The structure is being mapped
                IsFullyMapped = false
            };

            // Add the C# struct to its namespace
            nameSpace.Add(csStruct);

            // Map the C++ name to the C# struct
            typeRegistry.BindType(cppStruct.Name, csStruct);
            return(csStruct);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Prepares the specified C++ element to a C# element.
        /// </summary>
        /// <param name="cppEnum">The C++ element.</param>
        /// <returns>The C# element created and registered to the <see cref="TransformManager"/></returns>
        public override CsEnum Prepare(CppEnum cppEnum)
        {
            // Create C# enum
            var newEnum = new CsEnum
            {
                Name           = NamingRules.Rename(cppEnum),
                CppElement     = cppEnum,
                UnderlyingType = typeRegistry.ImportType(typeof(int))
            };

            // Get the namespace for this particular include and enum
            var nameSpace = namespaceRegistry.ResolveNamespace(cppEnum);

            nameSpace.Add(newEnum);

            // Bind C++ enum to C# enum
            typeRegistry.BindType(cppEnum.Name, newEnum);

            return(newEnum);
        }