Пример #1
0
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template))
                return false;

            template.Specializations.RemoveAll(
                s => s.Fields.Any(f => f.Type.IsPrimitiveType(PrimitiveType.Void)));

            if (template.Specializations.Count == 0)
                return false;

            var groups = (from specialization in template.Specializations
                          group specialization by specialization.Arguments.All(
                              a => a.Type.Type != null && a.Type.Type.IsAddress()) into @group
                          select @group).ToList();

            var lastGroup = groups.Last();
            if (lastGroup.Key)
            {
                foreach (var specialization in lastGroup.Skip(1))
                    template.Specializations.Remove(specialization);
            }

            return true;
        }
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template) || template.IsIncomplete)
                return false;

            template.Specializations.RemoveAll(
                s => s.Fields.Any(f => f.Type.IsPrimitiveType(PrimitiveType.Void)));

            if (template.Specializations.Count == 0)
                return false;

            var groups = (from specialization in template.Specializations
                          group specialization by specialization.Arguments.All(
                              a => a.Type.Type != null && a.Type.Type.IsAddress()) into @group
                          select @group).ToList();

            foreach (var group in groups.Where(g => g.Key))
                foreach (var specialization in group.Skip(1))
                    template.Specializations.Remove(specialization);

            for (int i = template.Specializations.Count - 1; i >= 0; i--)
                if (template.Specializations[i] is ClassTemplatePartialSpecialization)
                    template.Specializations.RemoveAt(i);

            return true;
        }
Пример #3
0
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template))
                return false;

            // templates are not supported yet
            foreach (var specialization in template.Specializations)
                specialization.ExplicitlyIgnore();

            return true;
        }
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template))
                return false;

            EnsureCompleteDeclaration(template.TemplatedDecl);

            template.TemplatedDecl = template.TemplatedDecl.CompleteDeclaration ?? template.TemplatedDecl;

            return true;
        }
Пример #5
0
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template))
                return false;

            if (!Driver.Options.IsCLIGenerator && template.IsSupportedStdType())
                return false;

            // templates are not supported yet
            foreach (var specialization in template.Specializations)
                specialization.ExplicitlyIgnore();

            return true;
        }
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template))
                return false;

            EnsureCompleteDeclaration(template.TemplatedDecl);

            template.TemplatedDecl = template.TemplatedDecl.CompleteDeclaration ?? template.TemplatedDecl;
            // store all spesializations in the real template class because ClassTemplateDecl only forwards
            foreach (var specialization in template.Specializations.Where(
                s => !s.IsIncomplete && !template.TemplatedClass.Specializations.Contains(s)))
                template.TemplatedClass.Specializations.Add(specialization);

            return true;
        }
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template) ||
                template.Specializations.Count == 0 ||
                template.Specializations.All(s => s is ClassTemplatePartialSpecialization))
                return false;

            var @class = template.TemplatedDecl.Namespace as Class;
            if (@class == null || @class is ClassTemplateSpecialization ||
                @class.Namespace is Class)
                return false;

            if (movedClassTemplates.ContainsKey(@class.Namespace))
                movedClassTemplates[@class.Namespace].Add(template);
            else
                movedClassTemplates.Add(@class.Namespace, new List<ClassTemplate> { template });

            return true;
        }
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            if (!base.VisitClassTemplateDecl(template))
                return false;

            if (template.IsIncomplete)
            {
                var completeDeclaration = (ClassTemplate) template.CompleteDeclaration;
                foreach (var specialization in template.Specializations.Where(
                    spec => completeDeclaration.Specializations.All(s => s.USR != spec.USR)))
                {
                    specialization.TemplatedDecl = completeDeclaration;
                    completeDeclaration.Specializations.Add(specialization);
                }
            }

            EnsureCompleteDeclaration(template.TemplatedDecl);

            template.TemplatedDecl = template.TemplatedDecl.CompleteDeclaration ?? template.TemplatedDecl;

            return true;
        }
Пример #9
0
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            var expansions = template.PreprocessedEntities.OfType<MacroExpansion>();

            var expansion = expansions.FirstOrDefault(e => e.Text.StartsWith(Prefix + "_CONSTRAINT"));
            if (expansion != null)
            {
                var args = GetArguments(expansion.Text);
                for (var i = 0; i < template.Parameters.Count && i < args.Length; ++i)
                {
                    var param = template.Parameters[i];
                    param.Constraint = args[i];
                    template.Parameters[i] = param;
                }
            }

            return base.VisitClassTemplateDecl(template);
        }
Пример #10
0
 internal ClassTemplate(ClassTemplate.Internal native)
     : this(&native)
 {
 }
Пример #11
0
 internal ClassTemplate(ClassTemplate.Internal* native)
     : this(new global::System.IntPtr(native))
 {
 }
Пример #12
0
 private ClassTemplate(ClassTemplate.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
 }
Пример #13
0
        public override bool VisitClassTemplateDecl(ClassTemplate template)
        {
            CheckForTemplateConstraints(template);

            return base.VisitClassTemplateDecl(template);
        }
Пример #14
0
 private ClassTemplate(ClassTemplate.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
Пример #15
0
 public static ClassTemplate __CreateInstance(ClassTemplate.Internal native)
 {
     return new ClassTemplate(native);
 }
Пример #16
0
 private ClassTemplate(ClassTemplate.Internal native, bool skipVTables = false)
     : this(__CopyValue(native), skipVTables)
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
Пример #17
0
 private static void* __CopyValue(ClassTemplate.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(156);
     global::CppSharp.Parser.AST.ClassTemplate.__Internal.cctor_1(ret, new global::System.IntPtr(&native));
     return ret.ToPointer();
 }
Пример #18
0
 public override bool VisitClassTemplateDecl(ClassTemplate template)
 {
     return template.TemplatedClass.Visit(this);
 }
Пример #19
0
 public static ClassTemplate __CreateInstance(ClassTemplate.Internal native, bool skipVTables = false)
 {
     return new ClassTemplate(native, skipVTables);
 }
Пример #20
0
 public override bool VisitClassTemplateDecl(ClassTemplate template)
 {
     return false;
 }
Пример #21
0
 protected ClassTemplate(ClassTemplate.Internal* native, bool skipVTables = false)
     : base((CppSharp.Parser.AST.Template.Internal*) null)
 {
     __PointerAdjustment = 0;
     if (native == null)
         return;
     __Instance = new global::System.IntPtr(native);
 }
Пример #22
0
 public override bool VisitClassTemplateDecl(ClassTemplate template)
 {
     return VisitClassDecl(template.TemplatedClass);
 }
Пример #23
0
 private static ClassTemplate.Internal* __CopyValue(ClassTemplate.Internal native)
 {
     var ret = Marshal.AllocHGlobal(224);
     CppSharp.Parser.AST.ClassTemplate.Internal.cctor_2(ret, new global::System.IntPtr(&native));
     return (ClassTemplate.Internal*) ret;
 }
Пример #24
0
 internal ClassTemplate(ClassTemplate.Internal native)
     : this(__CopyValue(native))
 {
 }
Пример #25
0
 protected ClassTemplate(ClassTemplate.Internal* native, bool isInternalImpl = false)
     : base((CppSharp.Parser.AST.Template.Internal*) native)
 {
 }
Пример #26
0
        private ClassTemplate GeneratePocoClass(IEdmSchemaType ent)
        {

            if (ent == null) return null;
            //for debuging
           // var debugString = Helper.Dump(ent);
            //v1.0.0-rc3 , enum support
            var enumType = ent as IEdmEnumType;
            ClassTemplate classTemplate = new ClassTemplate
               {
                   Name = ent.Name,
                 //  ToDebugString = debugString,
                   IsEnum = (enumType != null)

               };

            //for enum type , stop here , no more information needed
            if (classTemplate.IsEnum) return classTemplate;

            //fill setname
            //v1.4
            classTemplate.EntitySetName = GetEntitySetName(ent.Name);

            //fill keys 
            var list = GetKeys(ent);
            if (list != null) classTemplate.Keys.AddRange(list);

            //fill navigation properties
            var list2 = GetNavigation(ent);
            if (list2 != null) classTemplate.Navigation.AddRange(list2);

            var entityProperties = GetClassProperties(ent);

            //set the key ,comment
            foreach (var property in entityProperties)
            {
                //@@@ v1.0.0-rc3  
                if (classTemplate.Navigation.Exists(x => x == property.PropName)) property.IsNavigate = true;

                if (classTemplate.Keys.Exists(x => x == property.PropName)) property.IsKey = true;
                var comment = (property.IsKey ? "PrimaryKey" : String.Empty)
                                + (property.IsNullable ? String.Empty : " not null");
                if (!string.IsNullOrEmpty(comment)) property.PropComment = "//" + comment;

            }
            classTemplate.Properties.AddRange(entityProperties);
            return classTemplate;
        }