Permalink
Browse files

Merge pull request #132 from thefiddler/fixbool2

 Fix bool return types
  • Loading branch information...
thefiddler committed Jun 8, 2014
2 parents d81fc0e + 829185a commit b9e948580a5e7b6ff5f72a7a44783768221fbf45
@@ -384,7 +384,7 @@ void WriteDocumentation(BindStreamWriter sw, Function f)
else
{
Console.Error.WriteLine(
- "[Warning] Parameter '{0}' in function '{1}' not found in documentation '{{{3}}}'",
+ "[Warning] Parameter '{0}' in function '{1}' not found in documentation '{{{2}}}'",
param.Name, f.Name,
String.Join(",", docs.Parameters.Select(p => p.Name).ToArray()));
sw.WriteLine("/// <param name=\"{0}\">{1}</param>",
@@ -588,6 +588,12 @@ static void ApplyReturnTypeReplacement(Delegate d, XPathNavigator function_overr
d.ReturnType.QualifiedType = "int";
}
+ if (d.ReturnType.CurrentType.ToLower().Contains("bool"))
+ {
+ d.ReturnType.QualifiedType = "byte";
+ d.ReturnType.WrapperType |= WrapperTypes.BoolParameter;
+ }
+
d.ReturnType.CurrentType = GetCLSCompliantType(d.ReturnType);
}
@@ -1212,6 +1218,11 @@ static void WrapReturnType(Function func)
// Nothing else we can do, using generics will break the runtime
func.ReturnType.QualifiedType = "IntPtr";
}
+
+ if ((func.ReturnType.WrapperType & WrapperTypes.BoolParameter) != 0)
+ {
+ func.ReturnType.QualifiedType = "bool";
+ }
}
#endregion
@@ -497,6 +497,14 @@ private static void EmitReturnTypeWrapper(MethodDefinition wrapper, MethodDefini
{
// 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);
@@ -14372,7 +14372,7 @@ public static void ExtGetTexSubImage<T10>(OpenTK.Graphics.ES11.All target, Int32
static extern unsafe void glGetSyncivAPPLE(IntPtr sync, System.Int32 pname, Int32 bufSize, [OutAttribute] Int32* length, [OutAttribute] Int32* values);
[Slot(189)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsSyncAPPLE(IntPtr sync);
+ static extern byte glIsSyncAPPLE(IntPtr sync);
[Slot(294)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glRenderbufferStorageMultisampleAPPLE(System.Int32 target, Int32 samples, System.Int32 internalformat, Int32 width, Int32 height);
@@ -14600,13 +14600,13 @@ public static void ExtGetTexSubImage<T10>(OpenTK.Graphics.ES11.All target, Int32
static extern void glHint(System.Int32 target, System.Int32 mode);
[Slot(184)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsBuffer(UInt32 buffer);
+ static extern byte glIsBuffer(UInt32 buffer);
[Slot(185)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsEnabled(System.Int32 cap);
+ static extern byte glIsEnabled(System.Int32 cap);
[Slot(190)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsTexture(UInt32 texture);
+ static extern byte glIsTexture(UInt32 texture);
[Slot(192)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glLightf(System.Int32 light, System.Int32 pname, Single param);
@@ -14903,13 +14903,13 @@ public static void ExtGetTexSubImage<T10>(OpenTK.Graphics.ES11.All target, Int32
static extern unsafe void glGetFenceivNV(UInt32 fence, System.Int32 pname, [OutAttribute] Int32* @params);
[Slot(186)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsFenceNV(UInt32 fence);
+ static extern byte glIsFenceNV(UInt32 fence);
[Slot(310)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glSetFenceNV(UInt32 fence, System.Int32 condition);
[Slot(316)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glTestFenceNV(UInt32 fence);
+ static extern byte glTestFenceNV(UInt32 fence);
[Slot(0)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glAccumxOES(System.Int32 op, int value);
@@ -15134,13 +15134,13 @@ public static void ExtGetTexSubImage<T10>(OpenTK.Graphics.ES11.All target, Int32
static extern unsafe void glIndexxvOES(int* component);
[Slot(187)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsFramebufferOES(UInt32 framebuffer);
+ static extern byte glIsFramebufferOES(UInt32 framebuffer);
[Slot(188)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsRenderbufferOES(UInt32 renderbuffer);
+ static extern byte glIsRenderbufferOES(UInt32 renderbuffer);
[Slot(191)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glIsVertexArrayOES(UInt32 array);
+ static extern byte glIsVertexArrayOES(UInt32 array);
[Slot(197)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glLightModelxOES(System.Int32 pname, int param);
@@ -15407,7 +15407,7 @@ public static void ExtGetTexSubImage<T10>(OpenTK.Graphics.ES11.All target, Int32
static extern void glTranslatexOES(int x, int y, int z);
[Slot(367)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glUnmapBufferOES(System.Int32 target);
+ static extern byte glUnmapBufferOES(System.Int32 target);
[Slot(368)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glVertex2bOES(SByte x);
@@ -15488,7 +15488,7 @@ public static void ExtGetTexSubImage<T10>(OpenTK.Graphics.ES11.All target, Int32
static extern unsafe void glExtGetTexturesQCOM([OutAttribute] UInt32* textures, Int32 maxTextures, [OutAttribute] Int32* numTextures);
[Slot(103)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
- static extern bool glExtIsProgramBinaryQCOM(UInt32 program);
+ static extern byte glExtIsProgramBinaryQCOM(UInt32 program);
[Slot(104)]
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
static extern void glExtTexObjectStateOverrideiQCOM(System.Int32 target, System.Int32 pname, Int32 param);
Oops, something went wrong.

0 comments on commit b9e9485

Please sign in to comment.