From 379cf32f1de8a8b9ea698e0c8a8cdae6ebc0bb75 Mon Sep 17 00:00:00 2001 From: marcos henrich Date: Tue, 30 Jul 2013 10:12:19 +0100 Subject: [PATCH] Added FieldToPropertyPass, all non ignored fields can now be transformed into properties before generation. --- src/Generator/Passes/FieldToPropertyPass.cs | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Generator/Passes/FieldToPropertyPass.cs diff --git a/src/Generator/Passes/FieldToPropertyPass.cs b/src/Generator/Passes/FieldToPropertyPass.cs new file mode 100644 index 00000000..f2151256 --- /dev/null +++ b/src/Generator/Passes/FieldToPropertyPass.cs @@ -0,0 +1,33 @@ +using CppSharp.AST; + +namespace CppSharp.Passes +{ + public class FieldToPropertyPass : TranslationUnitPass + { + public override bool VisitFieldDecl(Field field) + { + var @class = field.Namespace as Class; + if (@class == null) + return false; + + if (@class.IsValueType) + return false; + + if (ASTUtils.CheckIgnoreField(@class,field)) + return false; + + var prop = new Property() + { + Name = field.Name, + Namespace = field.Namespace, + QualifiedType = field.QualifiedType, + Field = field + }; + @class.Properties.Add(prop); + + field.ExplicityIgnored = true; + + return false; + } + } +}