From c7c3e3b69b16462e7bbc58af8e8a57a63b8064d7 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Sun, 8 Jun 2014 09:42:27 +0200 Subject: [PATCH] [Rewrite] Implement byte -> bool marshalling Since GL_TRUE and GL_FALSE match .Net true and false (1 and 0, respectively), we can simply reinterpret the byte value as a bool. In the future, we could issue a `(if value == 0 then false else true)` statement for added safety, but this does not appear to be necessary right now. --- Source/Generator.Rewrite/Program.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Generator.Rewrite/Program.cs b/Source/Generator.Rewrite/Program.cs index c5c3b5cb..cd5baf47 100644 --- a/Source/Generator.Rewrite/Program.cs +++ b/Source/Generator.Rewrite/Program.cs @@ -497,6 +497,14 @@ namespace OpenTK.Rewrite { // Nothing to do } + else if (wrapper.ReturnType.Name == "Boolean" && native.ReturnType.Name == "Byte") + { + // Nothing to do + // It appears that a byte with 1 = true (GL_TRUE) and 0 = false (GL_FALSE) + // can be reinterpreted as a bool without a problem. + // Todo: maybe we should return (value == 0 ? false : true) just to be + // on the safe side? + } else { Console.Error.WriteLine("Return wrapper for '{1}' not implemented yet ({0})", native.Name, wrapper.ReturnType.Name);