From 7a8d0d8bc2572707c9d35006f30ea835c86954b0 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Tue, 9 Apr 2024 03:14:17 -0400 Subject: first draft to generate waves --- glew/auto/bin/filter_gl_ext.sh | 614 +++++++++++++++++++++++++++++++++++++ glew/auto/bin/filter_gles_ext.sh | 20 ++ glew/auto/bin/filter_spec.py | 38 +++ glew/auto/bin/make.pl | 224 ++++++++++++++ glew/auto/bin/make_def_fun.pl | 37 +++ glew/auto/bin/make_def_var.pl | 33 ++ glew/auto/bin/make_enable_index.pl | 48 +++ glew/auto/bin/make_header.pl | 73 +++++ glew/auto/bin/make_html.pl | 57 ++++ glew/auto/bin/make_index.pl | 41 +++ glew/auto/bin/make_info.pl | 71 +++++ glew/auto/bin/make_info_list.pl | 49 +++ glew/auto/bin/make_init.pl | 61 ++++ glew/auto/bin/make_initd.pl | 45 +++ glew/auto/bin/make_list.pl | 75 +++++ glew/auto/bin/make_list2.pl | 46 +++ glew/auto/bin/make_str.pl | 55 ++++ glew/auto/bin/make_struct_fun.pl | 38 +++ glew/auto/bin/make_struct_var.pl | 33 ++ glew/auto/bin/parse_spec.pl | 410 +++++++++++++++++++++++++ glew/auto/bin/parse_xml.py | 145 +++++++++ glew/auto/bin/update_ext.sh | 26 ++ 22 files changed, 2239 insertions(+) create mode 100644 glew/auto/bin/filter_gl_ext.sh create mode 100644 glew/auto/bin/filter_gles_ext.sh create mode 100644 glew/auto/bin/filter_spec.py create mode 100644 glew/auto/bin/make.pl create mode 100644 glew/auto/bin/make_def_fun.pl create mode 100644 glew/auto/bin/make_def_var.pl create mode 100644 glew/auto/bin/make_enable_index.pl create mode 100644 glew/auto/bin/make_header.pl create mode 100644 glew/auto/bin/make_html.pl create mode 100644 glew/auto/bin/make_index.pl create mode 100644 glew/auto/bin/make_info.pl create mode 100644 glew/auto/bin/make_info_list.pl create mode 100644 glew/auto/bin/make_init.pl create mode 100644 glew/auto/bin/make_initd.pl create mode 100644 glew/auto/bin/make_list.pl create mode 100644 glew/auto/bin/make_list2.pl create mode 100644 glew/auto/bin/make_str.pl create mode 100644 glew/auto/bin/make_struct_fun.pl create mode 100644 glew/auto/bin/make_struct_var.pl create mode 100644 glew/auto/bin/parse_spec.pl create mode 100644 glew/auto/bin/parse_xml.py create mode 100644 glew/auto/bin/update_ext.sh (limited to 'glew/auto/bin') diff --git a/glew/auto/bin/filter_gl_ext.sh b/glew/auto/bin/filter_gl_ext.sh new file mode 100644 index 0000000..e295f65 --- /dev/null +++ b/glew/auto/bin/filter_gl_ext.sh @@ -0,0 +1,614 @@ +#!/usr/bin/env bash +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. +## +## Parameters: +## +## $1: Extensions directory + +set -e + +# fix GL_NV_texture_compression_vtc + grep -v EXT $1/GL_NV_texture_compression_vtc > tmp + mv tmp $1/GL_NV_texture_compression_vtc + +# remove duplicates from GL_ARB_vertex_program and GL_ARB_fragment_program + tail -n +5 $1/GL_ARB_vertex_program > patterns + grep -v -F -f patterns $1/GL_ARB_fragment_program > tmp + mv tmp $1/GL_ARB_fragment_program + +# remove duplicates from GLX_EXT_visual_rating and GLX_EXT_visual_info + tail -n +5 $1/GLX_EXT_visual_info > patterns + grep -v -F -f patterns $1/GLX_EXT_visual_rating > tmp + mv tmp $1/GLX_EXT_visual_rating + +# GL_EXT_draw_buffers2 and GL_EXT_transform_feedback both define glGetBooleanIndexedvEXT but with different parameter names + grep -v glGetBooleanIndexedvEXT $1/GL_EXT_transform_feedback > tmp + mv tmp $1/GL_EXT_transform_feedback + +# GL_EXT_draw_buffers2 and GL_EXT_transform_feedback both define glGetIntegerIndexedvEXT but with different parameter names + grep -v glGetIntegerIndexedvEXT $1/GL_EXT_transform_feedback > tmp + mv tmp $1/GL_EXT_transform_feedback + +# remove duplicates from GL_NV_video_capture and GLX_NV_video_capture + grep -v glX $1/GL_NV_video_capture > tmp + mv tmp $1/GL_NV_video_capture + +# add missing functions to GL_NV_video_capture + cat >> $1/GL_NV_video_capture <> $1/WGL_NV_video_capture <> $1/GLX_NV_video_capture < patterns + grep -v -F -f patterns $1/GL_NV_present_video > tmp + mv tmp $1/GL_NV_present_video + +# fix WGL_NV_present_video + cat >> $1/WGL_NV_present_video <> $1/WGL_NV_video_output < tmp + mv tmp $1/GL_NV_occlusion_query + +# add deprecated constants to GL_ATI_fragment_shader + cat >> $1/GL_ATI_fragment_shader <> $1/GL_NV_texture_shader <> $1/WGL_ATI_pixel_format_float <> $1/WGL_ARB_make_current_read <> $1/WGL_EXT_make_current_read <> $1/GL_ARB_vertex_buffer_object <> $1/GLX_EXT_import_context <> $1/GLX_OML_swap_method <> $1/GLX_SGIX_fbconfig <> $1/GLX_SGIX_pbuffer <> $1/GL_NV_half_float <> $1/WGL_ARB_pbuffer <> $1/WGL_EXT_pbuffer < patterns + grep -v -F -f patterns $1/GL_ARB_fragment_shader > tmp + mv tmp $1/GL_ARB_fragment_shader + grep -v -F -f patterns $1/GL_ARB_vertex_shader > tmp + mv tmp $1/GL_ARB_vertex_shader + +# remove duplicates in GL_ARB_vertex_program and GL_ARB_vertex_shader + tail -n +5 $1/GL_ARB_vertex_program > patterns + grep -v -F -f patterns $1/GL_ARB_vertex_shader > tmp + mv tmp $1/GL_ARB_vertex_shader + +# remove triplicates in GL_ARB_fragment_program, GL_ARB_fragment_shader, +# and GL_ARB_vertex_shader + tail -n +5 $1/GL_ARB_fragment_program > patterns + grep -v -F -f patterns $1/GL_ARB_fragment_shader > tmp + mv tmp $1/GL_ARB_fragment_shader + grep -v -F -f patterns $1/GL_ARB_vertex_shader > tmp + mv tmp $1/GL_ARB_vertex_shader + +# remove duplicates in GL_EXT_direct_state_access + grep -v "glGetBooleanIndexedvEXT" $1/GL_EXT_direct_state_access > tmp + mv tmp $1/GL_EXT_direct_state_access + grep -v "glGetIntegerIndexedvEXT" $1/GL_EXT_direct_state_access > tmp + mv tmp $1/GL_EXT_direct_state_access + grep -v "glDisableIndexedEXT" $1/GL_EXT_direct_state_access > tmp + mv tmp $1/GL_EXT_direct_state_access + grep -v "glEnableIndexedEXT" $1/GL_EXT_direct_state_access > tmp + mv tmp $1/GL_EXT_direct_state_access + grep -v "glIsEnabledIndexedEXT" $1/GL_EXT_direct_state_access > tmp + mv tmp $1/GL_EXT_direct_state_access + +# remove duplicates in GL_NV_explicit_multisample + grep -v "glGetBooleanIndexedvEXT" $1/GL_NV_explicit_multisample > tmp + mv tmp $1/GL_NV_explicit_multisample + grep -v "glGetIntegerIndexedvEXT" $1/GL_NV_explicit_multisample > tmp + mv tmp $1/GL_NV_explicit_multisample + +# fix bugs in GL_ARB_vertex_shader + grep -v "GL_FLOAT" $1/GL_ARB_vertex_shader > tmp + mv tmp $1/GL_ARB_vertex_shader + perl -e 's/handle /GLhandleARB /g' -pi $1/GL_ARB_vertex_shader + +# fix bugs in GL_ARB_shader_objects + grep -v "GL_FLOAT " $1/GL_ARB_shader_objects > tmp + mv tmp $1/GL_ARB_shader_objects + grep -v "GL_INT " $1/GL_ARB_shader_objects > tmp + mv tmp $1/GL_ARB_shader_objects + +# add typedefs to GL_ARB_shader_objects + cat >> $1/GL_ARB_shader_objects <> $1/GL_ARB_transpose_matrix <> $1/GL_EXT_framebuffer_multisample < tmp + mv tmp $1/GL_NV_gpu_program_fp64 + +# Filter glGetUniformui64vNV from GL_NV_shader_buffer_load + grep -v "glGetUniformui64vNV" $1/GL_NV_shader_buffer_load > tmp + mv tmp $1/GL_NV_shader_buffer_load + +# Filter out profile enumerations from GLX_ARB_create_context + grep -v "_PROFILE_" $1/GLX_ARB_create_context > tmp + mv tmp $1/GLX_ARB_create_context + +# Filter only profile related enumerations for GLX_ARB_create_context_profile + head -n4 $1/GLX_ARB_create_context_profile > tmp + grep "_PROFILE_" $1/GLX_ARB_create_context_profile >> tmp + mv tmp $1/GLX_ARB_create_context_profile + +# Filter out profile enumerations from WGL_ARB_create_context + grep -v "_PROFILE_" $1/WGL_ARB_create_context > tmp + mv tmp $1/WGL_ARB_create_context + +# Filter only profile related enumerations for WGL_ARB_create_context_profile + head -n4 $1/WGL_ARB_create_context_profile > tmp + grep "_PROFILE_" $1/WGL_ARB_create_context_profile >> tmp + mv tmp $1/WGL_ARB_create_context_profile + +# add missing function to GLX_NV_copy_image + cat >> $1/GLX_NV_copy_image <> $1/WGL_NV_copy_image < tmp + mv tmp $1/GL_EXT_separate_shader_objects + +# Filter out EXT functions from GL_ARB_viewport_array + grep -v "EXT" $1/GL_ARB_viewport_array > tmp + mv tmp $1/GL_ARB_viewport_array + +# Additional enumerations for GL_NV_vertex_buffer_unified_memory +# These are mentioned in GL_ARB_draw_indirect.txt + + cat >> $1/GL_NV_vertex_buffer_unified_memory < tmp + mv tmp $1/GL_ARB_debug_output + +# Filter glGetPointerv from GL_EXT_vertex_array +# It's part of OpenGL 1.1, after all + + grep -v "glGetPointerv" $1/GL_EXT_vertex_array > tmp + mv tmp $1/GL_EXT_vertex_array + +# add typedef to GL_AMD_debug_output +# parse_spec.pl can't parse typedefs from New Types section, but ought to + cat >> $1/GL_AMD_debug_output <> $1/GL_ARB_debug_output <> $1/GL_KHR_debug < tmp + mv tmp $1/GL_KHR_debug + +# add typedefs to GL_ARB_cl_event +# parse_spec.pl can't parse typedefs from New Types section, but ought to + cat >> $1/GL_ARB_cl_event < tmp + mv tmp $1/GL_ARB_gpu_shader_fp64 + +# add missing functions to GL_EXT_direct_state_access (GL_ARB_gpu_shader_fp64 related) + cat >> $1/GL_EXT_direct_state_access <> $1/GL_EXT_direct_state_access < tmp + mv tmp $1/GL_AMD_performance_monitor + grep -v 'GL_FLOAT ' $1/GL_AMD_performance_monitor > tmp + mv tmp $1/GL_AMD_performance_monitor + +# Filter out GL_STORAGE_CACHED_APPLE and GL_STORAGE_SHARED_APPLE from GL_APPLE_texture_range + grep -v 'GL_STORAGE_CACHED_APPLE ' $1/GL_APPLE_texture_range > tmp + mv tmp $1/GL_APPLE_texture_range + grep -v 'GL_STORAGE_SHARED_APPLE ' $1/GL_APPLE_texture_range > tmp + mv tmp $1/GL_APPLE_texture_range + +# Filter out GL_RED from GL_ARB_texture_rg + grep -v 'GL_RED ' $1/GL_ARB_texture_rg > tmp + mv tmp $1/GL_ARB_texture_rg + +# Filter out _EXT enums from GL_ARB_texture_storage + grep -v '_EXT ' $1/GL_ARB_texture_storage > tmp + mv tmp $1/GL_ARB_texture_storage + +# Filter out TEXTURE_3D enums from GL_EXT_paletted_texture + grep -v 'TEXTURE_3D' $1/GL_EXT_paletted_texture > tmp + mv tmp $1/GL_EXT_paletted_texture + +# Filter out GL_VERSION_1_1 enums from GL_AMD_stencil_operation_extended + grep -v '0x150' $1/GL_AMD_stencil_operation_extended > tmp + mv tmp $1/GL_AMD_stencil_operation_extended + +# Filter out from GL_APPLE_ycbcr_422 + grep -v 'GL_UNSIGNED_SHORT_8_8_APPLE' $1/GL_APPLE_ycbcr_422 > tmp + mv tmp $1/GL_APPLE_ycbcr_422 + grep -v 'GL_UNSIGNED_SHORT_8_8_REV_APPLE' $1/GL_APPLE_ycbcr_422 > tmp + mv tmp $1/GL_APPLE_ycbcr_422 + +# Filter out GL_FRAGMENT_DEPTH_EXT from GL_EXT_light_texture + grep -v 'GL_FRAGMENT_DEPTH_EXT' $1/GL_EXT_light_texture > tmp + mv tmp $1/GL_EXT_light_texture + +# Filter out GL_MULTISAMPLE_BIT_EXT from GL_SGIS_multisample + grep -v 'GL_MULTISAMPLE_BIT_EXT' $1/GL_SGIS_multisample > tmp + mv tmp $1/GL_SGIS_multisample + +# Filter out GL_COMPRESSED_RGB_S3TC_DXT1_EXT from GL_EXT_texture_compression_dxt1 + grep -v 'GL_COMPRESSED_RGB_S3TC_DXT1_EXT' $1/GL_EXT_texture_compression_dxt1 > tmp + mv tmp $1/GL_EXT_texture_compression_dxt1 + +# Filter out GL_COMPRESSED_RGBA_S3TC_DXT1_EXT from GL_EXT_texture_compression_dxt1 + grep -v 'GL_COMPRESSED_RGBA_S3TC_DXT1_EXT' $1/GL_EXT_texture_compression_dxt1 > tmp + mv tmp $1/GL_EXT_texture_compression_dxt1 + +# Append GLfixed to GL_ARB_ES2_compatibility +# Probably ought to be explicitly mentioned in the spec language + + cat >> $1/GL_ARB_ES2_compatibility <> $1/GL_REGAL_ES1_0_compatibility <> $1/GL_REGAL_log < GLLOGPROCREGAL + perl -e 's/LOGPROCREGAL/GLLOGPROCREGAL/g' -pi $1/GL_REGAL_log + +# Filter out GL_BYTE from GL_OES_byte_coordinates + grep -v 'GL_BYTE' $1/GL_OES_byte_coordinates > tmp + mv tmp $1/GL_OES_byte_coordinates + +# Filter out fp64 (not widely supported) from GL_EXT_direct_state_access + egrep -v 'glProgramUniform.*[1234]d[v]?EXT' $1/GL_EXT_direct_state_access > tmp + mv tmp $1/GL_EXT_direct_state_access + +# Filter out all enums from GL_ANGLE_depth_texture + grep -v '0x' $1/GL_ANGLE_depth_texture > tmp + mv tmp $1/GL_ANGLE_depth_texture + +# Filter out GL_NONE enum from GL_ANGLE_depth_texture + grep -v 'GL_NONE' $1/GL_ANGLE_texture_usage > tmp + mv tmp $1/GL_ANGLE_texture_usage + +# Fixup REGAL and ANGLE urls + + for i in $1/GL_REGAL_*; do perl -e 's#http://www.opengl.org/registry/specs/REGAL/.*#https://github.com/p3/regal/tree/master/doc/extensions#g' -pi $i; done + for i in $1/GL_ANGLE_*; do perl -e 's#http://www.opengl.org/registry/specs/ANGLE/.*#https://code.google.com/p/angleproject/source/browse/\#git%2Fextensions#g' -pi $i; done + +# Filter out GL_NV_blend_equation_advanced_coherent enums and functions + head -n4 $1/GL_NV_blend_equation_advanced_coherent > tmp + mv tmp $1/GL_NV_blend_equation_advanced_coherent + +# Filter out GL_AMD_gpu_shader_int64 enums and functions + head -n4 $1/GL_AMD_gpu_shader_int64 > tmp + mv tmp $1/GL_AMD_gpu_shader_int64 + +# Filter out GL_NO_ERROR enum and glGetGraphicsResetStatus from GL_KHR_robustness + grep -v 'GL_NO_ERROR' $1/GL_KHR_robustness | + grep -v 'glGetGraphicsResetStatus' > tmp + mv tmp $1/GL_KHR_robustness + +# Filter out all enums from GL_KHR_blend_equation_advanced_coherent + grep -v '0x' $1/GL_KHR_blend_equation_advanced_coherent > tmp + mv tmp $1/GL_KHR_blend_equation_advanced_coherent + +# Filter out glBlendBarrierKHR enum from GL_KHR_blend_equation_advanced_coherent + grep -v 'glBlendBarrierKHR' $1/GL_KHR_blend_equation_advanced_coherent > tmp + mv tmp $1/GL_KHR_blend_equation_advanced_coherent + +# Filter out GL_NONE enum from GL_KHR_context_flush_control + grep -v 'GL_NONE' $1/GL_KHR_context_flush_control > tmp + mv tmp $1/GL_KHR_context_flush_control + +# Filter out CoverageModulation from NV_framebuffer_mixed_samples +# Superset of EXT_raster_multisample + + grep -v "CoverageModulation" $1/GL_NV_framebuffer_mixed_samples > tmp + mv tmp $1/GL_NV_framebuffer_mixed_samples + +# Filter out glRasterSamplesEXT from NV_framebuffer_mixed_samples +# Superset of EXT_raster_multisample + + grep -v "RasterSamplesEXT" $1/GL_NV_framebuffer_mixed_samples > tmp + mv tmp $1/GL_NV_framebuffer_mixed_samples + +# Filter out glNamedBufferStorageEXT from GL_ARB_buffer_storage + + grep -v "glNamedBufferStorageEXT" $1/GL_ARB_buffer_storage > tmp + mv tmp $1/GL_ARB_buffer_storage + +# Filter out glFramebufferTextureEXT from GL_EXT_geometry_point_size +# and GL_EXT_geometry_shader + + grep -v "glFramebufferTextureEXT" $1/GL_EXT_geometry_point_size > tmp + mv tmp $1/GL_EXT_geometry_point_size + + grep -v "glFramebufferTextureEXT" $1/GL_EXT_geometry_shader > tmp + mv tmp $1/GL_EXT_geometry_shader + +# Filter out glBindFragDataLocationEXT from GL_EXT_blend_func_extended + + grep -v "glBindFragDataLocationEXT" $1/GL_EXT_blend_func_extended > tmp + mv tmp $1/GL_EXT_blend_func_extended + +# Filter out glDrawArraysInstancedEXT and glDrawElementsInstancedEXT from GL_EXT_blend_func_extended + + grep -v "glDrawArraysInstancedEXT" $1/GL_EXT_instanced_arrays > tmp + mv tmp $1/GL_EXT_instanced_arrays + + grep -v "glDrawElementsInstancedEXT" $1/GL_EXT_instanced_arrays > tmp + mv tmp $1/GL_EXT_instanced_arrays + +# Filter out glRenderbufferStorageMultisampleEXT from GL_EXT_multisampled_render_to_texture + + grep -v "glRenderbufferStorageMultisampleEXT" $1/GL_EXT_multisampled_render_to_texture > tmp + mv tmp $1/GL_EXT_multisampled_render_to_texture + +# Filter out glTexturePageCommitmentEXT from GL_ARB_sparse_texture + + grep -v "glTexturePageCommitmentEXT" $1/GL_ARB_sparse_texture > tmp + mv tmp $1/GL_ARB_sparse_texture + +# Filter out TextureStorage* from GL_ARB_texture_storage + + grep -v "TextureStorage" $1/GL_ARB_texture_storage > tmp + mv tmp $1/GL_ARB_texture_storage + +# Filter out functions from GL_EXT_occlusion_query_boolean + + grep -v "(" $1/GL_EXT_occlusion_query_boolean > tmp + mv tmp $1/GL_EXT_occlusion_query_boolean + +# Filter out duplicate enums from GL_EXT_protected_textures + + cat $1/GL_EXT_protected_textures | grep -v GL_TRUE | grep -v GL_FALSE > tmp + mv tmp $1/GL_EXT_protected_textures + +# Filter out duplicate enums from GL_EXT_robustness + + cat $1/GL_EXT_robustness | grep -v GL_NO_ERROR > tmp + mv tmp $1/GL_EXT_robustness + +# Filter GL_EXT_shader_framebuffer_fetch_non_coherent + + grep -v "FramebufferFetchBarrierEXT" $1/GL_EXT_shader_framebuffer_fetch_non_coherent > tmp + mv tmp $1/GL_EXT_shader_framebuffer_fetch_non_coherent + +# Filter GL_EXT_tessellation_shader + + grep -v "PatchParameteriEXT" $1/GL_EXT_tessellation_shader > tmp + mv tmp $1/GL_EXT_tessellation_shader + +# Filter GL_EXT_texture_buffer + + grep -v "TexBuffer" $1/GL_EXT_texture_buffer > tmp + mv tmp $1/GL_EXT_texture_buffer + +# Filter GL_EXT_texture_border_clamp + + grep -v "TexParameter" $1/GL_EXT_texture_border_clamp > tmp + mv tmp $1/GL_EXT_texture_border_clamp + +# Filter GL_EXT_disjoint_timer_query + + cat $1/GL_EXT_disjoint_timer_query | grep -v GetQueryObjecti64v | grep -v GetQueryObjectui64v > tmp + mv tmp $1/GL_EXT_disjoint_timer_query + +# Filter GL_NV_read_buffer_front + + grep -v "ReadBufferNV" $1/GL_NV_read_buffer_front > tmp + mv tmp $1/GL_NV_read_buffer_front + +# Append GLVULKANPROCNV to GL_NV_draw_vulkan_image +# Probably ought to be explicitly mentioned in the spec language + + cat >> $1/GL_NV_draw_vulkan_image < +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. +## +## Parameters: +## +## $1: Extensions directory +## $2: Registry directory +## $3: The black list + +set -e + +# clean up + rm -f $1/*.bak diff --git a/glew/auto/bin/filter_spec.py b/glew/auto/bin/filter_spec.py new file mode 100644 index 0000000..16c2fa9 --- /dev/null +++ b/glew/auto/bin/filter_spec.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +import re + +section = re.compile('^(Name|Name Strings?|Contact|Notice|Number|Dependencies|Overview|Issues|IP Status|Status|Version|New Procedures and Functions|New Tokens|Additions to .*|Changes to .*|Modifications to .*|Add new Section .*)\s*$') +token = re.compile('^\s+(([A-Z0-9][A-Z0-9_x]*):?\s+((?:0x)?[0-9A-F]+)([^\?]*))?\s*$') +match = [ 'Name', 'Name String', 'Contact', 'Notice', 'Name Strings', 'Version', 'Number', 'Dependencies', 'New Procedures and Functions', 'New Tokens'] + +if __name__ == '__main__': + + from optparse import OptionParser + import os + + parser = OptionParser('usage: %prog [options] [SOURCES...]') + (options, args) = parser.parse_args() + + for i in args: + lines = open(i).readlines() + f = open(i,'w') + + # Keep track of the current section as we iterate over the input + current = '' + for j in lines: + + # Detect the start of a new section + m = section.match(j) + if m: + current = m.group(1).strip() + if current in match: + print >>f, j, + continue + + if current=='New Tokens': + if token.match(j): + print >>f, j, + elif current in match: + print >>f, j, + diff --git a/glew/auto/bin/make.pl b/glew/auto/bin/make.pl new file mode 100644 index 0000000..e0b32ef --- /dev/null +++ b/glew/auto/bin/make.pl @@ -0,0 +1,224 @@ +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +my %regex = ( + extname => qr/^[A-Z][A-Za-z0-9_]+$/, + exturl => qr/^http.+$/, + function => qr/^(.+) ([a-z][a-z0-9_]*) \((.*)\)$/i, + token => qr/^([A-Z][A-Z0-9_x]*)\s+((?:0x)?[0-9A-Fa-f]+(u(ll)?)?|[A-Z][A-Z0-9_]*)$/, + type => qr/^typedef\s+(.+)$/, + exact => qr/.*;$/, +); + +# prefix function name with glew +sub prefixname($) +{ + my $name = $_[0]; + $name =~ s/^(.*?)gl/__$1glew/; + return $name; +} + +# prefix function name with glew +sub prefix_varname($) +{ + my $name = $_[0]; + $name =~ s/^(.*?)GL(X*?)EW/__$1GL$2EW/; + return $name; +} + +#--------------------------------------------------------------------------------------- + +sub make_exact($) +{ + my $exact = $_[0]; + $exact =~ s/(; |{)/$1\n/g; + return $exact; +} + +sub make_separator($) +{ + my $extname = $_[0]; + my $l = length $extname; + my $s = (71 - $l)/2; + print "/* "; + my $j = 3; + for (my $i = 0; $i < $s; $i++) + { + print "-"; + $j++; + } + print " $_[0] "; + $j += $l + 2; + while ($j < 76) + { + print "-"; + $j++; + } + print " */\n\n"; +} + +#--------------------------------------------------------------------------------------- + +sub parse_ext($) +{ + my $filename = shift; + my %functions = (); + my %tokens = (); + my @reuse = (); # Extensions to reuse + my @types = (); + my @exacts = (); + my $extname = ""; # Full extension name GL_FOO_extension + my $exturl = ""; # Info URL + my $extstring = ""; # Relevant extension string + + open EXT, "<$filename" or return; + + # As of GLEW 1.14.0 the first four lines _must_ be + # the extension name, the URL and the GL extension + # string (which might be different to the name), + # and the reused extensions + # + # For example GL_NV_geometry_program4 is available + # iff GL_NV_gpu_program4 appears in the extension + # string. + # + # For core OpenGL versions, the third line should + # be blank. + # + # If the URL is unknown, the second line should be + # blank. + + $extname = readline(*EXT); + $exturl = readline(*EXT); + $extstring = readline(*EXT); + @reuse = split(" ", readline(*EXT)); + + chomp($extname); + chomp($exturl); + chomp($extstring); + + while() + { + chomp; + if (s/^\s+//) + { + if (/$regex{exact}/) + { + push @exacts, $_; + } + elsif (/$regex{type}/) + { + push @types, $_; + } + elsif (/$regex{token}/) + { + my ($name, $value) = ($1, $2); + $tokens{$name} = $value; + } + elsif (/$regex{function}/) + { + my ($return, $name, $parms) = ($1, $2, $3); + $functions{$name} = { + rtype => $return, + parms => $parms, + }; + } else { + print STDERR "'$_' matched no regex.\n"; + } + } + } + + close EXT; + + return ($extname, $exturl, $extstring, \@reuse, \@types, \%tokens, \%functions, \@exacts); +} + +sub output_tokens($$) +{ + my ($tbl, $fnc) = @_; + if (keys %{$tbl}) + { + local $, = "\n"; + print "\n"; + print map { &{$fnc}($_, $tbl->{$_}) } sort { + if (${$tbl}{$a} eq ${$tbl}{$b}) { + $a cmp $b + } else { + if (${$tbl}{$a} =~ /_/) { + if (${$tbl}{$b} =~ /_/) { + $a cmp $b + } else { + -1 + } + } else { + if (${$tbl}{$b} =~ /_/) { + 1 + } else { + if (hex ${$tbl}{$a} eq hex ${$tbl}{$b}) { + $a cmp $b + } else { + hex ${$tbl}{$a} <=> hex ${$tbl}{$b} + } + } + } + } + } keys %{$tbl}; + print "\n"; + } else { + print STDERR "no keys in table!\n"; + } +} + +sub output_types($$) +{ + my ($tbl, $fnc) = @_; + if (scalar @{$tbl}) + { + local $, = "\n"; + print "\n"; + print map { &{$fnc}($_) } sort @{$tbl}; + print "\n"; + } +} + +sub output_decls($$) +{ + my ($tbl, $fnc) = @_; + if (keys %{$tbl}) + { + local $, = "\n"; + print "\n"; + print map { &{$fnc}($_, $tbl->{$_}) } sort keys %{$tbl}; + print "\n"; + } +} + +sub output_exacts($$) +{ + my ($tbl, $fnc) = @_; + if (scalar @{$tbl}) + { + local $, = "\n"; + print "\n"; + print map { &{$fnc}($_) } sort @{$tbl}; + print "\n"; + } +} + +sub output_reuse($$) +{ + my ($tbl, $fnc) = @_; + if (scalar @{$tbl}) + { + local $, = "\n"; + print "\n"; + print map { &{$fnc}($_) } sort @{$tbl}; + print "\n"; + } +} diff --git a/glew/auto/bin/make_def_fun.pl b/glew/auto/bin/make_def_fun.pl new file mode 100644 index 0000000..af74706 --- /dev/null +++ b/glew/auto/bin/make_def_fun.pl @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +# function pointer declaration +sub make_pfn_decl($%) +{ + return "PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . " = NULL;"; +} + +my @extlist = (); +my %extensions = (); + +our $type = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + output_decls($functions, \&make_pfn_decl); + } +} diff --git a/glew/auto/bin/make_def_var.pl b/glew/auto/bin/make_def_var.pl new file mode 100644 index 0000000..993a68c --- /dev/null +++ b/glew/auto/bin/make_def_var.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +my @extlist = (); +my %extensions = (); + +our $type = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + print "GLboolean " . prefix_varname($extvar) . " = GL_FALSE;\n"; + } +} diff --git a/glew/auto/bin/make_enable_index.pl b/glew/auto/bin/make_enable_index.pl new file mode 100644 index 0000000..bdbe7d1 --- /dev/null +++ b/glew/auto/bin/make_enable_index.pl @@ -0,0 +1,48 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; +use File::Basename; + +use lib '.'; +do 'bin/make.pl'; + +## +## Make Extension-enabled Index +## + +my @extlist = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + print "/* Detected in the extension string or strings */\n"; + print "static GLboolean _glewExtensionString[" . scalar @extlist . "];\n"; + + print "/* Detected via extension string or experimental mode */\n"; + print "static GLboolean* _glewExtensionEnabled[] = {\n";; + + foreach my $ext (sort { basename($a) cmp basename($b) } @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = + parse_ext($ext); + + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + + print "#ifdef $extname\n"; + print " &__$extvar,\n"; + print "#endif\n"; + } + + print " NULL\n};\n\n"; +} diff --git a/glew/auto/bin/make_header.pl b/glew/auto/bin/make_header.pl new file mode 100644 index 0000000..9917db1 --- /dev/null +++ b/glew/auto/bin/make_header.pl @@ -0,0 +1,73 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +# token +sub make_define($$) +{ + return "#define $_[0] $_[1]" +} + +# type declaration +sub make_type($$) +{ + return "@_;" +} + +# function pointer type declaration +sub make_pfn_type($%) +{ + our $api; + return join(' ', "typedef", $_[1]->{rtype}, + "($api * PFN" . (uc $_[0]) . "PROC)", + "(" . $_[1]->{parms} . ")") . ";"; +} + +# function name alias +sub make_pfn_alias($%) +{ + our $type; + return join(" ", "#define", $_[0], $type . "EW_GET_FUN(" . prefixname($_[0]) . ")") +} + +my @extlist = (); +my %extensions = (); + +our $api = shift; +our $type = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + + make_separator($extname); + print "#ifndef $extname\n#define $extname 1\n"; + output_tokens($tokens, \&make_define); + output_types($types, \&make_type); + output_exacts($exacts, \&make_exact); + output_decls($functions, \&make_pfn_type); + output_decls($functions, \&make_pfn_alias); + + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + + print "\n#define $extvar " . $type . "EW_GET_VAR(" . prefix_varname($extvar) . ")\n"; + print "\n#endif /* $extname */\n\n"; + } +} diff --git a/glew/auto/bin/make_html.pl b/glew/auto/bin/make_html.pl new file mode 100644 index 0000000..be97003 --- /dev/null +++ b/glew/auto/bin/make_html.pl @@ -0,0 +1,57 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +#--------------------------------------------------------------------------------------- + +my @extlist = (); +my %extensions = (); +my $group = ""; +my $cur_group = ""; + +if (@ARGV) +{ + @extlist = @ARGV; + my $n = 1; + print "\n"; + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + $cur_group = $extname; + $cur_group =~ s/^(?:W?)GL(?:X?)_([A-Z0-9]+?)_.*$/$1/; + $extname =~ s/^(?:W?)GL(?:X?)_(.*)$/$1/; + if ($cur_group ne $group) + { + if ($group ne "") + { + print "\n"; + } + $group = $cur_group; + } + + { + if ($exturl) + { + print "\n"; + } + else + { + print "\n"; + } + $n++; + } + } + print "

$n $extname
$n $extname
\n" +} diff --git a/glew/auto/bin/make_index.pl b/glew/auto/bin/make_index.pl new file mode 100644 index 0000000..cf247f8 --- /dev/null +++ b/glew/auto/bin/make_index.pl @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; +use File::Basename; + +use lib '.'; +do 'bin/make.pl'; + +## +## Make Index +## +## Output sorted array of extension strings for indexing into extension +## enable/disable flags. This provides a way to convert an extension string +## into an integer index. +## + +my @extlist = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort { basename($a) cmp basename($b) } @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = + parse_ext($ext); + + print "#ifdef $extname\n"; + print " \"$extname\",\n"; + print "#endif\n"; + } +} diff --git a/glew/auto/bin/make_info.pl b/glew/auto/bin/make_info.pl new file mode 100644 index 0000000..3dcece9 --- /dev/null +++ b/glew/auto/bin/make_info.pl @@ -0,0 +1,71 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +#--------------------------------------------------------------------------------------- + +# function pointer definition +sub make_pfn_info($%) +{ + my $name = $_[0]; + return " glewInfoFunc(fi, \"$_[0]\", $name == NULL);"; +} + +#--------------------------------------------------------------------------------------- + +my @extlist = (); +my %extensions = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + my $extpre = $extname; + $extpre =~ s/(GLX|GLW|GL).*/$1/; + $extpre = lc $extpre; + + #make_separator($extname); + print "#ifdef $extname\n\n"; + print "static void _glewInfo_$extname (void)\n{\n"; + + if (! %$functions) + { + print " "; + } + else + { + print " GLboolean fi = "; + } + + if ($extvar =~ /VERSION/) + { + print "glewPrintExt(\"$extname\", $extvar, $extvar, $extvar);\n"; + } + else + { + print "glewPrintExt(\"$extname\", $extvar, $extpre" . + "ewIsSupported(\"$extname\"), $extpre" . + "ewGetExtension(\"$extstring\"));\n"; + } + output_decls($functions, \&make_pfn_info); + print "}\n\n"; + print "#endif /* $extname */\n\n"; + } +} diff --git a/glew/auto/bin/make_info_list.pl b/glew/auto/bin/make_info_list.pl new file mode 100644 index 0000000..74dbb77 --- /dev/null +++ b/glew/auto/bin/make_info_list.pl @@ -0,0 +1,49 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +#--------------------------------------------------------------------------------------- + +# function pointer definition +sub make_pfn_def($%) +{ + return "PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . " = NULL;"; +} + +# function pointer definition +sub make_init_call($%) +{ + my $name = prefixname($_[0]); + return " r = r || (" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $name . "\")) == NULL;"; +} + +#--------------------------------------------------------------------------------------- + +my @extlist = (); +my %extensions = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + + print "#ifdef $extname\n"; + print " _glewInfo_$extname();\n"; + print "#endif /* $extname */\n"; + } +} diff --git a/glew/auto/bin/make_init.pl b/glew/auto/bin/make_init.pl new file mode 100644 index 0000000..37922ee --- /dev/null +++ b/glew/auto/bin/make_init.pl @@ -0,0 +1,61 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +#------------------------------------------------------------------------------- + +# function pointer definition +sub make_pfn_def_init($%) +{ + #my $name = prefixname($_[0]); + return " r = ((" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; +} + +sub make_reuse_call($%) +{ + return " r = _glewInit_" . $_[0] . "() || r;"; +} + +#------------------------------------------------------------------------------- + +my @extlist = (); +my %extensions = (); + +our $type = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = + parse_ext($ext); + + #make_separator($extname); + my $extvar = $extname; + my $extvardef = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + if (keys %$functions or keys @$reuse) + { + print "#ifdef $extname\n\n"; + print "static GLboolean _glewInit_$extname ()\n{\n GLboolean r = GL_FALSE;\n"; + output_reuse($reuse, \&make_reuse_call); + output_decls($functions, \&make_pfn_def_init); + print "\n return r;\n}\n\n"; + print "#endif /* $extname */\n\n"; + } + } +} diff --git a/glew/auto/bin/make_initd.pl b/glew/auto/bin/make_initd.pl new file mode 100644 index 0000000..2f7e2e6 --- /dev/null +++ b/glew/auto/bin/make_initd.pl @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +## Output declarations for the _glewInit_[extension] functions defined +## by make_init.pl script. These are necessary for for initializers to +## call each other, such as a core GL 3 context that depends on certain +## extensions. + +#------------------------------------------------------------------------------- + +my @extlist = (); +my %extensions = (); + +our $type = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = + parse_ext($ext); + + #print "#ifdef $extname\n\n"; + if (keys %$functions) + { + print "static GLboolean _glewInit_$extname ();\n"; + } + #print "#endif /* $extname */\n\n"; + } +} diff --git a/glew/auto/bin/make_list.pl b/glew/auto/bin/make_list.pl new file mode 100644 index 0000000..38aebcd --- /dev/null +++ b/glew/auto/bin/make_list.pl @@ -0,0 +1,75 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +#--------------------------------------------------------------------------------------- + +# function pointer definition +sub make_init_call($%) +{ + my $name = prefixname($_[0]); + return " r = r || (" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;"; +} + +#--------------------------------------------------------------------------------------- + +my @extlist = (); +my %extensions = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + + my $extpre = $extname; + $extpre =~ s/^(W?E?)GL(X?).*$/\l$1gl\l$2ew/; + + #my $pextvar = prefix_varname($extvar); + + if (length($extstring) && $extstring !~ /^GL_/ || keys %$functions) + { + print "#ifdef $extname\n"; + } + + if (length($extstring) && $extstring !~ /^GL_/) + { + print " " . $extvar . " = _glewSearchExtension(\"$extstring\", extStart, extEnd);\n"; + } + + if (keys %$functions) + { + if ($extname =~ /WGL_.*/) + { + print " if (glewExperimental || " . $extvar . "|| crippled) " . $extvar . "= !_glewInit_$extname();\n"; + } + else + { + print " if (glewExperimental || " . $extvar . ") " . $extvar . " = !_glewInit_$extname();\n"; + } + } + + if (length($extstring) && $extstring !~ /^GL_/ || keys %$functions) + { + print "#endif /* $extname */\n"; + } + } + +} diff --git a/glew/auto/bin/make_list2.pl b/glew/auto/bin/make_list2.pl new file mode 100644 index 0000000..3ded727 --- /dev/null +++ b/glew/auto/bin/make_list2.pl @@ -0,0 +1,46 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +#--------------------------------------------------------------------------------------- +# Extensions that depend on others can be enabled once we know +# if the one it depends on, is enabled. + +my @extlist = (); +my %extensions = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + + if ($extname ne $extstring && length($extstring)) + { + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + + my $parent = $extstring; + $parent =~ s/GL(X*)_/GL$1EW_/; + + print "#ifdef $extname\n"; + print " $extvar = $parent;\n"; + print "#endif /* $extname */\n"; + } + } + +} diff --git a/glew/auto/bin/make_str.pl b/glew/auto/bin/make_str.pl new file mode 100644 index 0000000..a6d7709 --- /dev/null +++ b/glew/auto/bin/make_str.pl @@ -0,0 +1,55 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +my @extlist = (); +my %extensions = (); + +if (@ARGV) +{ + @extlist = @ARGV; + + my $curexttype = ""; + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + my $exttype = $extname; + $exttype =~ s/(W?E?)GL(X?)_(.*?_)(.*)/$3/; + my $extrem = $extname; + $extrem =~ s/(W?E?)GL(X?)_(.*?_)(.*)/$4/; + my $extvar = $extname; + $extvar =~ s/(W?E?)GL(X?)_/$1GL$2EW_/; + if(!($exttype =~ $curexttype)) + { + if(length($curexttype) > 0) + { + print " }\n"; + } + print " if (_glewStrSame2(&pos, &len, (const GLubyte*)\"$exttype\", " . length($exttype) . "))\n"; + print " {\n"; + $curexttype = $exttype; + } + print "#ifdef $extname\n"; + print " if (_glewStrSame3(&pos, &len, (const GLubyte*)\"$extrem\", ". length($extrem) . "))\n"; + #print " return $extvar;\n"; + print " {\n"; + print " ret = $extvar;\n"; + print " continue;\n"; + print " }\n"; + print "#endif\n"; + } + + print " }\n"; +} diff --git a/glew/auto/bin/make_struct_fun.pl b/glew/auto/bin/make_struct_fun.pl new file mode 100644 index 0000000..cc9eef5 --- /dev/null +++ b/glew/auto/bin/make_struct_fun.pl @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +# function pointer declaration +sub make_pfn_decl($%) +{ + our $export; + return $export . " PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . ";"; +} + +my @extlist = (); +my %extensions = (); + +our $export = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + output_decls($functions, \&make_pfn_decl); + } +} diff --git a/glew/auto/bin/make_struct_var.pl b/glew/auto/bin/make_struct_var.pl new file mode 100644 index 0000000..ab8b8b5 --- /dev/null +++ b/glew/auto/bin/make_struct_var.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +use lib '.'; +do 'bin/make.pl'; + +my @extlist = (); +my %extensions = (); + +our $export = shift; + +if (@ARGV) +{ + @extlist = @ARGV; + + foreach my $ext (sort @extlist) + { + my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext); + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + print $export . " GLboolean " . prefix_varname($extvar) . ";\n"; + } +} diff --git a/glew/auto/bin/parse_spec.pl b/glew/auto/bin/parse_spec.pl new file mode 100644 index 0000000..5e12f60 --- /dev/null +++ b/glew/auto/bin/parse_spec.pl @@ -0,0 +1,410 @@ +#!/usr/bin/env perl +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. + +use strict; +use warnings; + +sub compile_regex +{ + my $regex = join('', @_); + return qr/$regex/ +} + +my @sections = ( + "Name", + "Name Strings?", + "New Procedures and Functions", + "New Tokens.*", # Optional (GL/WGL/GLX/...) suffix + "Additions to Chapter.*", +); + +my %typemap = ( + bitfield => "GLbitfield", + boolean => "GLboolean", + # fsck up in EXT_vertex_array + Boolean => "GLboolean", + byte => "GLbyte", + clampd => "GLclampd", + clampf => "GLclampf", + double => "GLdouble", + enum => "GLenum", + # Intel fsck up + Glenum => "GLenum", + float => "GLfloat", + half => "GLhalf", + int => "GLint", + short => "GLshort", + sizei => "GLsizei", + ubyte => "GLubyte", + uint => "GLuint", + ushort => "GLushort", + DMbuffer => "void *", + # Nvidia video output fsck up + int64EXT => "GLint64EXT", + uint64EXT=> "GLuint64EXT", + + # ARB VBO introduces these. + + sizeiptr => "GLsizeiptr", + intptr => "GLintptr", + sizeiptrARB => "GLsizeiptrARB", + intptrARB => "GLintptrARB", + + # ARB shader objects introduces these, charARB is at least 8 bits, + # handleARB is at least 32 bits + charARB => "GLcharARB", + handleARB => "GLhandleARB", + + char => "GLchar", + + # OpenGL 3.2 and GL_ARB_sync + + int64 => "GLint64", + uint64 => "GLuint64", + sync => "GLsync", + + # GL_EXT_EGL_image_storage + + eglImageOES => "GLeglImageOES", + + # AMD_debug_output + + DEBUGPROCAMD => "GLDEBUGPROCAMD", + + # ARB_debug_output + + DEBUGPROCARB => "GLDEBUGPROCARB", + + # KHR_debug + + DEBUGPROC => "GLDEBUGPROC", + + VULKANPROCNV => "GLVULKANPROCNV", + + vdpauSurfaceNV => "GLvdpauSurfaceNV", + + # GLX 1.3 defines new types which might not be available at compile time + + #GLXFBConfig => "void*", + #GLXFBConfigID => "XID", + #GLXContextID => "XID", + #GLXWindow => "XID", + #GLXPbuffer => "XID", + + # Weird stuff to some SGIX extension + + #GLXFBConfigSGIX => "void*", + #GLXFBConfigIDSGIX => "XID", + +); + +my %voidtypemap = ( + void => "GLvoid", +); + +my %taboo_tokens = ( + GL_ZERO => 1, +); + +# list of function definitions to be ignored, unless they are being defined in +# the given spec. This is an ugly hack around the fact that people writing +# spec files seem to shut down all brain activity while they are at this task. +# +# This will be moved to its own file eventually. +# +# (mem, 2003-03-19) + +my %fnc_ignore_list = ( + "BindProgramARB" => "ARB_vertex_program", + "ColorSubTableEXT" => "EXT_color_subtable", + "DeleteProgramsARB" => "ARB_vertex_program", + "GenProgramsARB" => "ARB_vertex_program", + "GetProgramEnvParameterdvARB" => "ARB_vertex_program", + "GetProgramEnvParameterfvARB" => "ARB_vertex_program", + "GetProgramLocalParameterdvARB" => "ARB_vertex_program", + "GetProgramLocalParameterfvARB" => "ARB_vertex_program", + "GetProgramStringARB" => "ARB_vertex_program", + "GetProgramivARB" => "ARB_vertex_program", + "IsProgramARB" => "ARB_vertex_program", + "ProgramEnvParameter4dARB" => "ARB_vertex_program", + "ProgramEnvParameter4dvARB" => "ARB_vertex_program", + "ProgramEnvParameter4fARB" => "ARB_vertex_program", + "ProgramEnvParameter4fvARB" => "ARB_vertex_program", + "ProgramLocalParameter4dARB" => "ARB_vertex_program", + "ProgramLocalParameter4dvARB" => "ARB_vertex_program", + "ProgramLocalParameter4fARB" => "ARB_vertex_program", + "ProgramLocalParameter4fvARB" => "ARB_vertex_program", + "ProgramStringARB" => "ARB_vertex_program", + "EGLImageTargetTexture2DOES" => "OES_EGL_image", + "FramebufferTextureOES" => "GL_OES_geometry_shader", + "PatchParameteriOES" => "GL_OES_tessellation_shader", + "PointSizePointerOES" => "GL_OES_point_size_array", + "LockArraysEXT" => "EXT_compiled_vertex_array", + "UnlockArraysEXT" => "EXT_compiled_vertex_array", + "CoverageMaskNV" => "NV_coverage_sample", + "CoverageOperationNV" => "NV_coverage_sample", + "glXCreateContextAttribsARB" => "ARB_create_context_profile", + "wglCreateContextAttribsARB" => "WGL_ARB_create_context_profile", +); + +my %regex = ( + eofnc => qr/(?:\);?$|^$)/, # )$ | );$ | ^$ + extname => qr/^[A-Z][A-Za-z0-9_]+$/, + none => qr/^\(none\)$/, + function => qr/^(.+) ([a-z][a-z0-9_]*) \((.*)\)$/i, + prefix => qr/^(?:[aw]?gl|glX|egl)/, # gl | agl | wgl | glX + tprefix => qr/^(?:[AW]?GL|GLX|EGL)_/, # GL_ | AGL_ | WGL_ | GLX_ + section => compile_regex('^(', join('|', @sections), ')$'), # sections in spec + token => qr/^([A-Z0-9][A-Z0-9_x]*):?\s+((?:0x)?[0-9A-Fa-f]+(u(ll)?)?)(|\s[^\?]*)$/, # define tokens + types => compile_regex('\b(', join('|', keys %typemap), ')\b'), # var types + voidtype => compile_regex('\b(', keys %voidtypemap, ')\b '), # void type +); + +# reshapes the the function declaration from multiline to single line form +sub normalize_prototype +{ + local $_ = join(" ", @_); + s/\s+/ /g; # multiple whitespace -> single space + s/\<.*\>//g; # remove from direct state access extension + s/\<.*$//g; # remove incomplete from direct state access extension + s#/\*.*\*/##g; # remove /* ... */ comments + s/\s*\(\s*/ \(/; # exactly one space before ( and none after + s/\s*\)\s*/\)/; # no space before or after ) + s/\s*\*([a-zA-Z])/\* $1/; # "* identifier" + s/\*wgl/\* wgl/; # "* wgl" + s/\*glX/\* glX/; # "* glX" + s/\.\.\./void/; # ... -> void + s/;$//; # remove ; at the end of the line + return $_; +} + +# Ugly hack to work around the fact that functions are declared in more +# than one spec file. +sub ignore_function($$) +{ + return exists($fnc_ignore_list{$_[0]}) && $fnc_ignore_list{$_[0]} ne $_[1] +} + +sub parse_spec($) +{ + my $filename = shift; + my $extname = ""; + my $vendortag = ""; + my @extnames = (); + my %functions = (); + my %tokens = (); + + my $section = ""; + my @fnc = (); + + my %proc = ( + "Name" => sub { + if (/^([a-z0-9]+)_([a-z0-9_]+)/i) + { + $extname = "$1_$2"; + $vendortag = $1; + } + }, + + "Name Strings" => sub { + # Add extension name to extension list + + # Initially use $extname if (none) specified + if (/$regex{none}/) + { + $_ = $extname; + } + + if (/$regex{extname}/) + { + # prefix with "GL_" if prefix not present + s/^/GL_/ unless /$regex{tprefix}/o; + # Add extension name to extension list + push @extnames, $_; + } + }, + + "New Procedures and Functions" => sub { + # if line matches end of function + if (/$regex{eofnc}/) + { + # add line to function declaration + push @fnc, $_; + + # if normalized version of function looks like a function + if (normalize_prototype(@fnc) =~ /$regex{function}/) + { + # get return type, name, and arguments from regex + my ($return, $name, $parms) = ($1, $2, $3); + if (!ignore_function($name, $extname)) + { + # prefix with "gl" if prefix not present + $name =~ s/^/gl/ unless $name =~ /$regex{prefix}/; + # is this a pure GL function? + if ($name =~ /^gl/ && $name !~ /^glX/) + { + # apply typemaps + $return =~ s/$regex{types}/$typemap{$1}/og; + $return =~ s/GLvoid/void/og; + $return =~ s/void\*/void */og; + $parms =~ s/$regex{types}/$typemap{$1}/og; + $parms =~ s/$regex{voidtype}/$voidtypemap{$1}/og; + $parms =~ s/GLvoid/void/og; + $parms =~ s/ void\* / void */og; + if ($parms eq "") + { + $parms = "void"; # NVX_progress_fence and others + } + } + # add to functions hash + $functions{$name} = { + rtype => $return, + parms => $parms, + }; + } + } + # reset function declaration + @fnc = (); + } elsif ($_ ne "" and $_ ne "None") { + # if not eof, add line to function declaration + push @fnc, $_ + } + }, + + "New Tokens" => sub { + if (/$regex{token}/) + { + my ($name, $value) = ($1, $2); + # prefix with "GL_" if prefix not present + $name =~ s/^/GL_/ unless $name =~ /$regex{tprefix}/; + # Add (name, value) pair to tokens hash, unless it's taboo + $tokens{$name} = $value unless exists $taboo_tokens{$name}; + } + }, + ); + + # Some people can't read, the template clearly says "Name String_s_" + $proc{"Name String"} = $proc{"Name Strings"}; + + # Open spec file + open SPEC, "<$filename" or return; + + # For each line of SPEC + while() + { + # Delete trailing newline character + chomp; + # Remove trailing white spaces + s/\s+$//; + # If starts with a capital letter, it must be a new section + if (/^[A-Z]/) + { + # Match section name with one of the predefined names + $section = /$regex{section}/o ? $1 : "default"; + } else { + # Line is internal to a section + # Remove leading whitespace + s/^\s+//; + # Call appropriate section processing function if it exists + &{$proc{$section}} if exists $proc{$section}; + } + } + + close SPEC; + + return ($extname, \@extnames, \%tokens, \%functions); +} + +#---------------------------------------------------------------------------------------- + +my @speclist = (); +my %extensions = (); + +my $ext_dir = shift; +my $reg_http = "https://www.khronos.org/registry/OpenGL/extensions/"; + +# Take command line arguments or read list from file +if (@ARGV) +{ + @speclist = @ARGV; +} else { + local $/; #??? + @speclist = split "\n", (<>); +} + +foreach my $spec (sort @speclist) +{ + my ($extname, $extnames, $tokens, $functions) = parse_spec($spec); + + foreach my $ext (@{$extnames}) + { + my $info = "$ext_dir/" . $ext; + open EXT, ">$info"; + print EXT $ext . "\n"; # Extension name + my $specname = $spec; + $specname =~ s/OpenGL-Registry\/extensions\///; + print EXT $reg_http . $specname . "\n"; # Extension info URL + print EXT $ext . "\n"; # Extension string + print EXT "\n"; # Resuses nothing by default + + my $prefix = $ext; + $prefix =~ s/^(.+?)(_.+)$/$1/; + foreach my $token (sort { + if (${$tokens}{$a} eq ${$tokens}{$b}) { + $a cmp $b + } else { + if (${$tokens}{$a} =~ /_/) { + if (${$tokens}{$b} =~ /_/) { + $a cmp $b + } else { + -1 + } + } else { + if (${$tokens}{$b} =~ /_/) { + 1 + } else { + if (${$tokens}{$a} =~ /u(ll)?$/) { + if (${$tokens}{$b} =~ /u(ll)?$/) { + $a cmp $b + } else { + -1 + } + } else { + if (${$tokens}{$b} =~ /u(ll)?$/) { + 1 + } else { + if (hex ${$tokens}{$a} eq hex ${$tokens}{$b}) + { + $a cmp $b + } else { + hex ${$tokens}{$a} <=> hex ${$tokens}{$b} + } + } + } + } + } + } + } keys %{$tokens}) + { + if ($token =~ /^$prefix\_.*/i) + { + print EXT "\t" . $token . " " . ${\%{$tokens}}{$token} . "\n"; + } + } + foreach my $function (sort keys %{$functions}) + { + if ($function =~ /^$prefix.*/i) + { + print EXT "\t" . ${$functions}{$function}{rtype} . " " . $function . " (" . ${$functions}{$function}{parms} . ")" . "\n"; + } + } + close EXT; + } +} diff --git a/glew/auto/bin/parse_xml.py b/glew/auto/bin/parse_xml.py new file mode 100644 index 0000000..28ecb9f --- /dev/null +++ b/glew/auto/bin/parse_xml.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python + +import re +import sys +from xml.dom.minidom import parse, Node + +# +# DOM traversal utility functions +# + +def findChildren(node, path): + result = [] + if len(path)==1: + for i in node.childNodes: + if i.nodeType==Node.ELEMENT_NODE: + if i.tagName==path[0]: + result.append(i) + else: + for i in node.childNodes: + if i.nodeType==Node.ELEMENT_NODE: + if i.tagName==path[0]: + result.extend(findChildren(i, path[1:])) + return result + +def findData(node, path): + return [ i.firstChild.data for i in findChildren(node, path) ] + +isPointer = re.compile('(.*)([ ]+)([*]+)') + +def findParams(node): + n = findData(node, ['name'])[0] + t = '' + for i in node.childNodes: + if i.nodeType==Node.TEXT_NODE: + t += i.data + if i.nodeType==Node.ELEMENT_NODE and i.tagName=='ptype': + t += i.firstChild.data + + t.strip() + m = isPointer.match(t) + if m: + t = ('%s%s'%(m.group(1), m.group(3))).strip() + return ( t, n.strip()) + +def findEnums(dom): + return {i.getAttribute('name'): i.getAttribute('value') for i in findChildren(dom, [ 'registry', 'enums', 'enum' ])} + +def findCommands(dom): + ret = {} + for i in findChildren(dom, [ 'registry', 'commands', 'command' ]): + r,n = findParams(findChildren(i, ['proto'])[0]) + p = [ findParams(j) for j in findChildren(i, ['param'])] + ret[n] = (r, p) + return ret + +def findFeatures(dom): + ret = {} + for i in findChildren(dom, [ 'registry', 'feature' ]): + n = i.getAttribute('name') + e = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'enum' ])] + c = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'command' ])] + ret[n] = (e,c) + return ret + +def findExtensions(dom): + ret = {} + for i in findChildren(dom, [ 'registry', 'extensions', 'extension' ]): + n = i.getAttribute('name') + e = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'enum' ])] + c = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'command' ])] + ret[n] = (e,c) + return ret + +def findApi(dom, name): + enums = findEnums(dom) + commands = findCommands(dom) + features = findFeatures(dom) + extensions = findExtensions(dom) + return (enums, commands, features, extensions) + +# +# +# + +isWGL = re.compile('WGL_([A-Z0-9]+)_.*') + +def writeExtension(f, name, extension, enums, commands): + f.write(('%s\n'%name).encode()) + + url = 'https://www.khronos.org/registry/egl/specs/eglspec.1.5.pdf' + + m = isWGL.match(name) + if m: + url = 'https://www.khronos.org/registry/OpenGL/extensions/%s/%s.txt'%(m.group(1), name) + + f.write(('%s\n'%(url)).encode()) + + if name.find('_VERSION_')==-1: + f.write(('%s\n'%name).encode()) + else: + f.write('\n'.encode()) + f.write('\n'.encode()) + + enums = [ (j, enums[j]) for j in extension[0] ] + for e in sorted(enums, key=lambda i: i[1]): + f.write(('\t%s %s\n'%(e[0], e[1])).encode()) + + commands = [ (j, commands[j]) for j in extension[1] ] + for c in sorted(commands): + params = ', '.join( [ '%s %s'%(j[0].strip(), j[1].strip()) for j in c[1][1] ] ) + if len(params)==0: + params = 'void' + f.write(('\t%s %s (%s)\n'%(c[1][0].strip(), c[0].strip(), params)).encode()) + +if __name__ == '__main__': + + from argparse import ArgumentParser + import os + + parser = ArgumentParser(description='usage: %prog [options] [XML specs...]') + parser.add_argument("--core", dest="core", help="location for core outputs", default='') + parser.add_argument("--api", dest="name", help="API name: egl, wgl, glx, etc", default='') + parser.add_argument("--extensions", dest="extensions", help="location for extensions outputs", default='') + + (options, args) = parser.parse_known_args() + options = vars(options) + + for i in args: + + dom = parse(i) + api = findApi(dom, options['name']) + + print('Found {} enums, {} commands, {} features and {} extensions.'.format( + len(api[0]), len(api[1]), len(api[2]), len(api[3]))) + + if len(options['core']): + for i in api[2].keys(): + with open(os.path.join(options['core'], i), 'wb') as f: + writeExtension(f, i, api[2][i], api[0], api[1]) + + if len(options['extensions']): + for i in api[3].keys(): + with open(os.path.join(options['extensions'], i), 'wb') as f: + writeExtension(f, i, api[3][i], api[0], api[1]) + diff --git a/glew/auto/bin/update_ext.sh b/glew/auto/bin/update_ext.sh new file mode 100644 index 0000000..0ee3af1 --- /dev/null +++ b/glew/auto/bin/update_ext.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +## +## Copyright (C) 2008-2019, Nigel Stewart +## Copyright (C) 2002-2008, Marcelo E. Magallon +## Copyright (C) 2002-2008, Milan Ikits +## +## This program is distributed under the terms and conditions of the GNU +## General Public License Version 2 as published by the Free Software +## Foundation or, at your option, any later version. +## +## Parameters: +## +## $1: Extensions directory +## $2: Registry directory +## $3: The black list + +set -e + +if [ ! -d $1 ] ; then + mkdir -p $1 + +# Parse each of the extensions in the registry + find $2 -name doc -type d -prune -o -name "*.txt" -print | \ + grep -v -f $3 | sort | bin/parse_spec.pl $1 + +fi -- cgit v1.2.3-70-g09d2