Commit 2e29b13d by Jamie Madill Committed by Commit Bot

Fix some default return values in auto-gen.

We don't generally test for the default return values of function calls that have validation errors, but the auto-gen script might not have been returning things correctly. For GLint values, default to returning -1 instead of zero. BUG=angleproject:1309 Change-Id: I736b5a7ef9b50ca1509087fe933c4a4e526531d8 Reviewed-on: https://chromium-review.googlesource.com/636522Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b79b3f96
...@@ -156,17 +156,10 @@ def param_format_string(param): ...@@ -156,17 +156,10 @@ def param_format_string(param):
return param + " = " + format_dict[type_only] return param + " = " + format_dict[type_only]
def default_return_value(return_type): def default_return_value(cmd_name, return_type):
if return_type == "void": if return_type == "void":
return "" return ""
elif return_type == "GLenum" or return_type == "GLint" or return_type == "GLuint": return "GetDefaultReturnValue<EntryPoint::" + cmd_name[2:] + ", " + return_type + ">()"
return "0"
elif return_type == "GLboolean":
return "GL_FALSE"
elif "*" in return_type or return_type == "GLsync":
return "nullptr"
else:
raise Exception("Don't know default return type for " + return_type)
def get_context_getter_function(cmd_name): def get_context_getter_function(cmd_name):
if cmd_name == "glGetError": if cmd_name == "glGetError":
...@@ -178,7 +171,7 @@ def format_entry_point_def(cmd_name, proto, params): ...@@ -178,7 +171,7 @@ def format_entry_point_def(cmd_name, proto, params):
pass_params = [just_the_name(param) for param in params] pass_params = [just_the_name(param) for param in params]
format_params = [param_format_string(param) for param in params] format_params = [param_format_string(param) for param in params]
return_type = proto[:-len(cmd_name)] return_type = proto[:-len(cmd_name)]
default_return = default_return_value(return_type.strip()) default_return = default_return_value(cmd_name, return_type.strip())
return template_entry_point_def.format( return template_entry_point_def.format(
name = cmd_name[2:], name = cmd_name[2:],
name_lower = cmd_name[2:3].lower() + cmd_name[3:], name_lower = cmd_name[2:3].lower() + cmd_name[3:],
......
...@@ -167,6 +167,43 @@ struct EntryPointParam ...@@ -167,6 +167,43 @@ struct EntryPointParam
using Type = ParamsBase; using Type = ParamsBase;
}; };
// A template struct for determining the default value to return for each entry point.
template <EntryPoint EP, typename ReturnType>
struct DefaultReturnValue;
// Default return values for each basic return type.
template <EntryPoint EP>
struct DefaultReturnValue<EP, GLint>
{
static constexpr GLint kValue = -1;
};
// This doubles as the GLenum return value.
template <EntryPoint EP>
struct DefaultReturnValue<EP, GLuint>
{
static constexpr GLuint kValue = 0;
};
template <EntryPoint EP>
struct DefaultReturnValue<EP, GLboolean>
{
static constexpr GLboolean kValue = GL_FALSE;
};
// Catch-all rule for pointer types.
template <EntryPoint EP, typename PointerType>
struct DefaultReturnValue<EP, const PointerType *>
{
static constexpr const PointerType *kValue = nullptr;
};
template <EntryPoint EP, typename ReturnType>
constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
{
return DefaultReturnValue<EP, ReturnType>::kValue;
}
} // namespace gl } // namespace gl
#endif // LIBANGLE_PARAMS_H_ #endif // LIBANGLE_PARAMS_H_
...@@ -269,7 +269,7 @@ GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target) ...@@ -269,7 +269,7 @@ GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target)
} }
} }
return 0; return GetDefaultReturnValue<EntryPoint::CheckFramebufferStatus, GLenum>();
} }
void GL_APIENTRY Clear(GLbitfield mask) void GL_APIENTRY Clear(GLbitfield mask)
...@@ -505,7 +505,7 @@ GLuint GL_APIENTRY CreateProgram() ...@@ -505,7 +505,7 @@ GLuint GL_APIENTRY CreateProgram()
} }
} }
return 0; return GetDefaultReturnValue<EntryPoint::CreateProgram, GLuint>();
} }
GLuint GL_APIENTRY CreateShader(GLenum type) GLuint GL_APIENTRY CreateShader(GLenum type)
...@@ -523,7 +523,7 @@ GLuint GL_APIENTRY CreateShader(GLenum type) ...@@ -523,7 +523,7 @@ GLuint GL_APIENTRY CreateShader(GLenum type)
} }
} }
return 0; return GetDefaultReturnValue<EntryPoint::CreateShader, GLuint>();
} }
void GL_APIENTRY CullFace(GLenum mode) void GL_APIENTRY CullFace(GLenum mode)
...@@ -1071,7 +1071,7 @@ GLint GL_APIENTRY GetAttribLocation(GLuint program, const GLchar *name) ...@@ -1071,7 +1071,7 @@ GLint GL_APIENTRY GetAttribLocation(GLuint program, const GLchar *name)
} }
} }
return 0; return GetDefaultReturnValue<EntryPoint::GetAttribLocation, GLint>();
} }
void GL_APIENTRY GetBooleanv(GLenum pname, GLboolean *data) void GL_APIENTRY GetBooleanv(GLenum pname, GLboolean *data)
...@@ -1123,7 +1123,7 @@ GLenum GL_APIENTRY GetError() ...@@ -1123,7 +1123,7 @@ GLenum GL_APIENTRY GetError()
} }
} }
return 0; return GetDefaultReturnValue<EntryPoint::GetError, GLenum>();
} }
void GL_APIENTRY GetFloatv(GLenum pname, GLfloat *data) void GL_APIENTRY GetFloatv(GLenum pname, GLfloat *data)
...@@ -1336,7 +1336,7 @@ const GLubyte *GL_APIENTRY GetString(GLenum name) ...@@ -1336,7 +1336,7 @@ const GLubyte *GL_APIENTRY GetString(GLenum name)
} }
} }
return nullptr; return GetDefaultReturnValue<EntryPoint::GetString, const GLubyte *>();
} }
void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
...@@ -1422,7 +1422,7 @@ GLint GL_APIENTRY GetUniformLocation(GLuint program, const GLchar *name) ...@@ -1422,7 +1422,7 @@ GLint GL_APIENTRY GetUniformLocation(GLuint program, const GLchar *name)
} }
} }
return 0; return GetDefaultReturnValue<EntryPoint::GetUniformLocation, GLint>();
} }
void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
...@@ -1508,7 +1508,7 @@ GLboolean GL_APIENTRY IsBuffer(GLuint buffer) ...@@ -1508,7 +1508,7 @@ GLboolean GL_APIENTRY IsBuffer(GLuint buffer)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsBuffer, GLboolean>();
} }
GLboolean GL_APIENTRY IsEnabled(GLenum cap) GLboolean GL_APIENTRY IsEnabled(GLenum cap)
...@@ -1526,7 +1526,7 @@ GLboolean GL_APIENTRY IsEnabled(GLenum cap) ...@@ -1526,7 +1526,7 @@ GLboolean GL_APIENTRY IsEnabled(GLenum cap)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsEnabled, GLboolean>();
} }
GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer) GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer)
...@@ -1544,7 +1544,7 @@ GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer) ...@@ -1544,7 +1544,7 @@ GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsFramebuffer, GLboolean>();
} }
GLboolean GL_APIENTRY IsProgram(GLuint program) GLboolean GL_APIENTRY IsProgram(GLuint program)
...@@ -1562,7 +1562,7 @@ GLboolean GL_APIENTRY IsProgram(GLuint program) ...@@ -1562,7 +1562,7 @@ GLboolean GL_APIENTRY IsProgram(GLuint program)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsProgram, GLboolean>();
} }
GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer) GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer)
...@@ -1580,7 +1580,7 @@ GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer) ...@@ -1580,7 +1580,7 @@ GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsRenderbuffer, GLboolean>();
} }
GLboolean GL_APIENTRY IsShader(GLuint shader) GLboolean GL_APIENTRY IsShader(GLuint shader)
...@@ -1598,7 +1598,7 @@ GLboolean GL_APIENTRY IsShader(GLuint shader) ...@@ -1598,7 +1598,7 @@ GLboolean GL_APIENTRY IsShader(GLuint shader)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsShader, GLboolean>();
} }
GLboolean GL_APIENTRY IsTexture(GLuint texture) GLboolean GL_APIENTRY IsTexture(GLuint texture)
...@@ -1616,7 +1616,7 @@ GLboolean GL_APIENTRY IsTexture(GLuint texture) ...@@ -1616,7 +1616,7 @@ GLboolean GL_APIENTRY IsTexture(GLuint texture)
} }
} }
return GL_FALSE; return GetDefaultReturnValue<EntryPoint::IsTexture, GLboolean>();
} }
void GL_APIENTRY LineWidth(GLfloat width) void GL_APIENTRY LineWidth(GLfloat width)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment