Example #1
0
        public void GenerateClassProperties(Class @class)
        {
            // Handle the case of struct (value-type) inheritance by adding the base
            // properties to the managed value subtypes.
            if (@class.IsValueType)
            {
                foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
                {
                    GenerateClassProperties(@base.Class);
                }
            }

            Indent();
            foreach (var prop in @class.Properties.Where(
                         prop => !ASTUtils.CheckIgnoreProperty(prop) && !TypeIgnored(prop.Type)))
            {
                if (prop.IsInRefTypeAndBackedByValueClassField())
                {
                    prop.Field.Visit(this);
                    continue;
                }

                prop.Visit(this);
            }
            Unindent();
        }
Example #2
0
        public void GenerateClassProperties(Class @class)
        {
            // Handle the case of struct (value-type) inheritance by adding the base
            // properties to the managed value subtypes.
            if (@class.IsValueType)
            {
                foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
                {
                    GenerateClassProperties(@base.Class);
                }
            }

            PushIndent();
            foreach (var prop in @class.Properties.Where(prop => !ASTUtils.CheckIgnoreProperty(prop)))
            {
                if (prop.IsInRefTypeAndBackedByValueClassField())
                {
                    GenerateField(@class, prop.Field);
                    continue;
                }

                GenerateDeclarationCommon(prop);
                GenerateProperty(prop);
            }
            PopIndent();
        }
Example #3
0
        private void GenerateStructMarshaling(Class @class, string nativeVar)
        {
            foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
            {
                GenerateStructMarshaling(@base.Class, nativeVar);
            }

            foreach (var property in @class.Properties.Where(p => !ASTUtils.CheckIgnoreProperty(p)))
            {
                if (property.Field == null)
                {
                    continue;
                }

                var nativeField = string.Format("{0}{1}",
                                                nativeVar, property.Field.OriginalName);

                var ctx = new MarshalContext(Driver)
                {
                    ArgName       = property.Name,
                    ReturnVarName = nativeField,
                    ReturnType    = property.QualifiedType
                };

                var marshal = new CLIMarshalNativeToManagedPrinter(ctx);
                property.Visit(marshal);

                if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore))
                {
                    Write(marshal.Context.SupportBefore);
                }

                WriteLine("{0} = {1};", property.Field.Name, marshal.Context.Return);
            }
        }
Example #4
0
        public virtual void GenerateClassProperties(Class @class)
        {
            foreach (var property in @class.Properties)
            {
                if (ASTUtils.CheckIgnoreProperty(property) || CppHeaders.TypeIgnored(property.Type))
                {
                    continue;
                }

                property.Visit(this);
            }
        }
Example #5
0
        private void GenerateClassProperties(Class @class, Class realOwner)
        {
            if (@class.IsValueType)
            {
                foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
                {
                    GenerateClassProperties(@base.Class, realOwner);
                }
            }

            foreach (var property in @class.Properties.Where(
                         p => !ASTUtils.CheckIgnoreProperty(p) && !p.IsInRefTypeAndBackedByValueClassField()))
            {
                GenerateProperty(property, realOwner);
            }
        }
Example #6
0
        public virtual bool VisitClassDeclContext(Class @class)
        {
            if (!VisitDeclContext(@class))
            {
                return(false);
            }

            foreach (var field in @class.Fields.Where(f => !ASTUtils.CheckIgnoreField(f)))
            {
                field.Visit(this);
            }

            foreach (var property in @class.Properties.Where(p => !ASTUtils.CheckIgnoreProperty(p)))
            {
                property.Visit(this);
            }

            VisitClassConstructors(@class);
            VisitClassMethods(@class);

            foreach (var @event in @class.Events)
            {
                if ([email protected])
                {
                    continue;
                }

                @event.Visit(this);
            }

            foreach (var variable in @class.Variables)
            {
                if (!variable.IsGenerated)
                {
                    continue;
                }

                if (variable.Access != AccessSpecifier.Public)
                {
                    continue;
                }

                variable.Visit(this);
            }

            return(true);
        }
Example #7
0
        public void MarshalValueClassProperties(Class @class, string marshalVar)
        {
            foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
            {
                MarshalValueClassProperties(@base.Class, marshalVar);
            }

            foreach (var property in @class.Properties.Where(p => !ASTUtils.CheckIgnoreProperty(p)))
            {
                if (property.Field == null)
                {
                    continue;
                }

                MarshalValueClassProperty(property, marshalVar);
            }
        }
Example #8
0
        private void GenerateStructMarshaling(Class @class, string nativeVar)
        {
            foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
            {
                GenerateStructMarshaling(@base.Class, nativeVar);
            }

            int paramIndex = 0;

            foreach (var property in @class.Properties.Where(
                         p => !ASTUtils.CheckIgnoreProperty(p) && !CLIHeaders.TypeIgnored(p.Type)))
            {
                if (property.Field == null)
                {
                    continue;
                }

                var nativeField = string.Format("{0}{1}",
                                                nativeVar, property.Field.OriginalName);

                var ctx = new MarshalContext(Context, CurrentIndentation)
                {
                    ArgName        = property.Name,
                    ReturnVarName  = nativeField,
                    ReturnType     = property.QualifiedType,
                    ParameterIndex = paramIndex++
                };
                ctx.PushMarshalKind(MarshalKind.NativeField);
                var marshal = new CLIMarshalNativeToManagedPrinter(ctx);
                property.Visit(marshal);

                if (!string.IsNullOrWhiteSpace(marshal.Context.Before))
                {
                    Write(marshal.Context.Before);
                }

                WriteLine("{0} = {1};", property.Field.Name, marshal.Context.Return);
            }
        }
Example #9
0
        public virtual bool VisitClassDeclContext(Class @class)
        {
            if (!VisitDeclContext(@class))
            {
                return(false);
            }

            foreach (var field in @class.Fields.Where(f => !ASTUtils.CheckIgnoreField(f)))
            {
                field.Visit(this);
            }

            foreach (var property in @class.Properties.Where(p => !ASTUtils.CheckIgnoreProperty(p)))
            {
                property.Visit(this);
            }

            VisitClassConstructors(@class);
            VisitClassMethods(@class);

            return(true);
        }