From 714fb7ecc4f55421bc8f5318f23df8dde0bd8a9f Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Tue, 17 Nov 2020 23:24:50 +0000 Subject: [PATCH] Add per-declaration support for decl maps. --- src/AST/Declaration.cs | 4 ++++ src/Generator/Types/DeclMapDatabase.cs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/AST/Declaration.cs b/src/AST/Declaration.cs index 9e399e46..1b97e997 100644 --- a/src/AST/Declaration.cs +++ b/src/AST/Declaration.cs @@ -334,6 +334,9 @@ namespace CppSharp.AST public List Redeclarations { get; } = new List(); + // Custom declaration map for custom code generation. + public object DeclMap { get; set; } + protected Declaration() { Access = AccessSpecifier.Public; @@ -372,6 +375,7 @@ namespace CppSharp.AST LineNumberEnd = declaration.LineNumberEnd; IsImplicit = declaration.IsImplicit; AssociatedDeclaration = declaration.AssociatedDeclaration; + DeclMap = declaration.DeclMap; } public override string ToString() diff --git a/src/Generator/Types/DeclMapDatabase.cs b/src/Generator/Types/DeclMapDatabase.cs index 9ac72884..26a98464 100644 --- a/src/Generator/Types/DeclMapDatabase.cs +++ b/src/Generator/Types/DeclMapDatabase.cs @@ -60,6 +60,12 @@ namespace CppSharp.Types public bool FindDeclMap(Declaration decl, out DeclMap declMap) { + if (decl.DeclMap != null) + { + declMap = decl.DeclMap as DeclMap; + return true; + } + // Looks up the decl in the cache map. if (declMaps.ContainsKey(decl)) {