From 4149cdfa8897be34b4b8356db9d0d62360125f89 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Tue, 26 Nov 2013 01:31:29 +0100 Subject: [PATCH] Do not emit method bodies. --- Source/Bind/CSharpSpecWriter.cs | 24 +++++--------- Source/OpenTK/SlotAttribute.cs | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 Source/OpenTK/SlotAttribute.cs diff --git a/Source/Bind/CSharpSpecWriter.cs b/Source/Bind/CSharpSpecWriter.cs index 65128543..cfb02b86 100644 --- a/Source/Bind/CSharpSpecWriter.cs +++ b/Source/Bind/CSharpSpecWriter.cs @@ -301,10 +301,11 @@ namespace Bind { Trace.WriteLine(String.Format("Writing wrappers to:\t{0}.{1}", Settings.OutputNamespace, Settings.OutputClass)); - sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute - sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments - sw.WriteLine("#pragma warning disable 1572"); // Wrong param comments - sw.WriteLine("#pragma warning disable 1573"); // Missing param comments + sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute + sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments + sw.WriteLine("#pragma warning disable 1572"); // Wrong param comments + sw.WriteLine("#pragma warning disable 1573"); // Missing param comments + sw.WriteLine("#pragma warning disable 626"); // extern method without DllImport sw.WriteLine(); sw.WriteLine("partial class {0}", Settings.OutputClass); @@ -396,7 +397,8 @@ namespace Bind sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]", f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.EntryPoint); - sw.WriteLine("public static "); + sw.WriteLine("[Slot({0})]", f.WrappedDelegate.Slot); + sw.WriteLine("public static extern "); sw.Write(GetDeclarationString(f)); sw.WriteLine(); } @@ -669,11 +671,6 @@ namespace Bind p.WrapperType == WrapperTypes.ArrayParameter || p.WrapperType == WrapperTypes.ReferenceParameter) { - if (f.Name.Contains("EdgeFlagPointerList")) - { - System.Diagnostics.Debugger.Break(); - } - // Pin the parameter to obtain a pointer we can safely pass to unmanaged code if (p.Pointer > 0) { @@ -1002,12 +999,7 @@ namespace Bind } } - sb.AppendLine("{"); - foreach (var line in f.Body) - { - sb.AppendLine(line); - } - sb.Append("}"); + sb.AppendLine(";"); return sb.ToString(); } diff --git a/Source/OpenTK/SlotAttribute.cs b/Source/OpenTK/SlotAttribute.cs new file mode 100644 index 00000000..9092b3c8 --- /dev/null +++ b/Source/OpenTK/SlotAttribute.cs @@ -0,0 +1,55 @@ +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2010 the Open Toolkit library, except where noted. +// +// 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. +// +#endregion + +using System; + +namespace OpenTK +{ + /// + /// Defines the slot index for a wrapper function. + /// This type supports OpenTK and should not be + /// used in user code. + /// + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public class SlotAttribute : Attribute + { + /// + /// Defines the slot index for a wrapper function. + /// + internal int Slot { get; set; } + + /// + /// Constructs a new instance. + /// + /// The slot index for a wrapper function. + public SlotAttribute(int index) + { + Slot = index; + } + } +} +