diff --git a/Source/Bind/CppSpecWriter.cs b/Source/Bind/CppSpecWriter.cs index f7a20a9a..81966911 100644 --- a/Source/Bind/CppSpecWriter.cs +++ b/Source/Bind/CppSpecWriter.cs @@ -122,19 +122,25 @@ namespace Bind sw.Indent(); } + // Avoid multiple definitions of the same function Delegate last_delegate = null; - foreach (Function f in wrappers[extension]) + + // Write forward-compatible functions + foreach (Function f in wrappers[extension].Where(f => !f.Deprecated).Select(f => f)) { - var d = f.WrappedDelegate; - // Avoid multiple definitions of the same function - if (d != last_delegate) - { - last_delegate = d; - sw.WriteLine("static {0} (*p{1})({2});", d.ReturnType, f.TrimmedName, d.Parameters); - sw.WriteLine("extern p{0} {0};", f.TrimmedName); - } + WriteDelegate(sw, f, ref last_delegate); } + // Write deprecated functions + sw.WriteLine("#ifdef ALLOW_DEPRECATED_GL"); + sw.Indent(); + foreach (Function f in wrappers[extension].Where(f => !f.Deprecated).Select(f => f)) + { + WriteDelegate(sw, f, ref last_delegate); + } + sw.Unindent(); + sw.WriteLine("#endif"); + if (extension != "Core") { sw.Unindent(); @@ -146,6 +152,18 @@ namespace Bind sw.WriteLine("};"); } + private static void WriteDelegate(BindStreamWriter sw, Function f, ref Delegate last_delegate) + { + var d = f.WrappedDelegate; + // Avoid multiple definitions of the same function + if (d != last_delegate) + { + last_delegate = d; + sw.WriteLine("static {0} (*p{1})({2});", d.ReturnType, f.TrimmedName, d.Parameters); + sw.WriteLine("extern p{0} {0};", f.TrimmedName); + } + } + static DocProcessor processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile)); static Dictionary docfiles; void WriteDocumentation(BindStreamWriter sw, Function f)