Permalink
Browse files

Changed an event to a context with a read-only list of parameters.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Aug 25, 2017
1 parent 8a2e813 commit 16aa74a20b95a32521052608db65b6ac588694f8
@@ -2,13 +2,8 @@
namespace CppSharp.AST
{
public class Event : Declaration, ITypedDecl
public class Event : DeclarationContext, ITypedDecl
{
public Event()
{
Parameters = new List<Parameter>();
}
public override T Visit<T>(IDeclVisitor<T> visitor)
{
return visitor.VisitEvent(this);
@@ -17,7 +12,7 @@ public override T Visit<T>(IDeclVisitor<T> visitor)
public Type Type { get { return QualifiedType.Type; } }
public QualifiedType QualifiedType { get; set; }
public List<Parameter> Parameters;
public List<Parameter> Parameters { get; } = new List<Parameter>();
public Declaration OriginalDeclaration { get; set; }
}
@@ -258,7 +258,7 @@ public FunctionType(FunctionType type)
: base(type)
{
ReturnType = new QualifiedType((Type) type.ReturnType.Type.Clone(), type.ReturnType.Qualifiers);
Parameters.AddRange(type.Parameters.Select(p => new Parameter(p)).ToList());
Parameters.AddRange(type.Parameters.Select(p => new Parameter(p)));
CallingConvention = type.CallingConvention;
IsDependent = type.IsDependent;
}
@@ -151,11 +151,8 @@ private void CreateIndexer(Class @class, Method @operator)
ReturnType = op.ReturnType
};
foreach (var parameter in op.Parameters)
{
var newParameter = new Parameter(parameter) { Namespace = method };
method.Parameters.Add(newParameter);
}
method.Parameters.AddRange(op.Parameters.Select(
p => new Parameter(p) { Namespace = method }));
@class.Methods.Insert(index, method);
}
@@ -59,11 +59,9 @@ public override bool VisitFunctionDecl(Function function)
FunctionType = function.FunctionType
};
foreach (var parameter in function.Parameters)
{
var newParameter = new Parameter(parameter) { Namespace = method };
method.Parameters.Add(newParameter);
}
method.Parameters.AddRange(function.Parameters.Select(
p => new Parameter(p) { Namespace = method }));
if (Options.GeneratorKind == GeneratorKind.CSharp)
method.Parameters.RemoveAt(0);
@@ -1,4 +1,5 @@
using CppSharp.AST;
using System.Linq;
using CppSharp.AST;
namespace CppSharp.Passes
{
@@ -53,11 +54,8 @@ public override bool VisitFunctionDecl(Function function)
Conversion = MethodConversionKind.FunctionToStaticMethod
};
foreach (var parameter in function.Parameters)
{
var newParameter = new Parameter(parameter) { Namespace = method };
method.Parameters.Add(newParameter);
}
method.Parameters.AddRange(function.Parameters.Select(
p => new Parameter(p) { Namespace = method }));
@class.Methods.Add(method);

0 comments on commit 16aa74a

Please sign in to comment.