SharpGen/Model/CsMethod.cs (45 lines of code) (raw):

// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System.Collections.Generic; using System.Linq; using SharpGen.CppModel; using SharpGen.Transform; namespace SharpGen.Model { public sealed class CsMethod : CsCallable { protected override int MaxSizeReturnParameter => 4; public CsMethod(Ioc ioc, CppMethod cppMethod, string name) : base(ioc, cppMethod, name) { if (cppMethod == null) return; var tag = cppMethod.Rule; AllowProperty = tag.Property ?? AllowProperty; IsPersistent = tag.Persist ?? IsPersistent; Hidden = tag.Hidden ?? Hidden; CustomVtbl = tag.CustomVtbl ?? CustomVtbl; IsKeepImplementPublic = tag.IsKeepImplementPublic ?? IsKeepImplementPublic; // Apply any offset to the method's vtable var offset = tag.LayoutOffsetTranslate; Offset = cppMethod.Offset + offset; WindowsOffset = cppMethod.WindowsOffset + offset; } public bool Hidden { get; set; } private bool IsKeepImplementPublic { get; } public bool? AllowProperty { get; } public bool CustomVtbl { get; } public bool IsPersistent { get; } public int Offset { get; } public int WindowsOffset { get; } public bool IsPublicVisibilityForced(CsInterface parentInterface) { if (parentInterface == null) return false; return IsKeepImplementPublic || parentInterface.IsCallback && !Hidden; } public bool IsPublicVisibilityForced(params CsInterface[] parentInterfaces) => parentInterfaces.Any(IsPublicVisibilityForced); public void SuffixName(string suffix) { Name += suffix; } } }