From dab1fe8e98f80fc1169bb30493dd3b9dadd3d9de Mon Sep 17 00:00:00 2001 From: rconde Date: Sat, 15 Mar 2014 17:40:26 -0400 Subject: [PATCH 1/3] - implemented feature request in sourceforge feature request #30 -- https://sourceforge.net/p/glew/feature-requests/30/ -- alter macro definitions so that full signature is captured -- doubled number of macros to maintain support for function pointer assign/test ---- there are some alternate implementations if not desired -- seems many signatures don't have parameter names...will look into that --- auto/Makefile | 6 +-- auto/bin/make_header.pl | 81 +++++++++++++++++++++++++++++++++++++++- auto/bin/make_info.pl | 2 +- auto/bin/make_init.pl | 2 +- auto/src/glew_init_glx.c | 4 +- 5 files changed, 87 insertions(+), 8 deletions(-) diff --git a/auto/Makefile b/auto/Makefile index e05ceef..7b0a1ce 100644 --- a/auto/Makefile +++ b/auto/Makefile @@ -238,7 +238,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy perl -e "s/GLEW_VERSION_MINOR_STRING/$(GLEW_MINOR)/g" -pi $@ perl -e "s/GLEW_VERSION_MICRO_STRING/$(GLEW_MICRO)/g" -pi $@ perl -e "s/GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader\(GLEW_CONTEXT_ARG_VAR_INIT\);/{ GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); _glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); }/g" -pi $@ - perl -e "s/\(\(glColorSubTable = /((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glColorSubTable = /g" -pi $@ + perl -e "s/\(\(glColorSubTable = /((glBlendEquationFP = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glColorSubTable = /g" -pi $@ rm -f $@.bak $(S.DEST)/glew_def.c: $(EXT)/.dummy @@ -293,7 +293,7 @@ $(S.DEST)/glew_init.c: $(EXT)/.dummy perl -e "s/GLEW_VERSION_MINOR_STRING/$(GLEW_MINOR)/g" -pi $@ perl -e "s/GLEW_VERSION_MICRO_STRING/$(GLEW_MICRO)/g" -pi $@ perl -e "s/GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader\(GLEW_CONTEXT_ARG_VAR_INIT\);/{ GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); _glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); }/g" -pi $@ - perl -e "s/\(\(glBlendColor = /((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glBlendColor = /g" -pi $@ + perl -e "s/\(\(glBlendColorFP = /((glBlendEquationFP = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glBlendColor = /g" -pi $@ rm -f $@.bak $(S.DEST)/glew_str.c: $(EXT)/.dummy @@ -334,7 +334,7 @@ $(S.DEST)/glewinfo.c: $(EXT)/.dummy $(BIN)/make_info_list.pl $(GLX_CORE_SPEC) >> $@ $(BIN)/make_info_list.pl $(GLX_EXT_SPEC) >> $@ cat $(SRC)/glewinfo_tail.c >> $@ - perl -e 's/"glColorSubTable"/"glBlendEquation", glBlendEquation == NULL);\n glewInfoFunc("glColorSubTable"/g' -pi $@ + perl -e 's/"glColorSubTable"/"glBlendEquation", glBlendEquationFP == NULL);\n glewInfoFunc("glColorSubTable"/g' -pi $@ rm -f $@.bak # Update documentation diff --git a/auto/bin/make_header.pl b/auto/bin/make_header.pl index 934ef77..410984b 100755 --- a/auto/bin/make_header.pl +++ b/auto/bin/make_header.pl @@ -37,7 +37,86 @@ sub make_pfn_type($%) sub make_pfn_alias($%) { our $type; - return join(" ", "#define", $_[0], $type . "EW_GET_FUN(" . prefixname($_[0]) . ")") + my $parms = $_[1]->{parms}; + + #trim off any whitespace + $parms =~ s/^\s+|\s+$//g; + + #fix up parm identifiers for macro + my $fixed_up_parms = ""; + my $fixed_up_calllist = ""; + + #if the parm list is void, nothing to substitute + if($parms ne "void") + { + #split parms + my @split_parms = split(/,/,$parms); + + my $num_parms = @split_parms; + + my $i = 0; + + foreach(@split_parms) + { + my $temp = $_; + + #trim off any whitespace + $temp =~ s/^\s+|\s+$//g; + + #get the parm name, store it, and strip it off + my $parm_name = ""; + + if($temp =~ /([a-zA-Z_]+[0-9a-zA-Z_]*)$/) + { + $parm_name = $1; + $temp = substr($temp,0,length($temp) - length($parm_name)); + } + + #remove any remaining whitespace + $temp =~ s/\s+//g; + + #replace pointer * with P + $temp =~ s/\s*\*\s*/P/g; + + #remove brackets + $temp =~ s/\[|\]//g; + + #add to parmlist...handling cases where no parm name is specified + if($parm_name eq "") + { + $fixed_up_calllist .= "(" . $temp . "__parm" . $i . ")"; + $fixed_up_parms .= $temp . "__parm" . $i; + } + elsif($temp eq "") + { + $fixed_up_calllist .= "(" . $parm_name . "__parm" . $i . ")"; + $fixed_up_parms .= $parm_name . "__parm" . $i; + } + else + { + $fixed_up_calllist .= "(" . $temp . "__" . $parm_name . ")"; + $fixed_up_parms .= $temp . "__" . $parm_name; + } + + if($i != $num_parms - 1) + { + $fixed_up_parms .= ", "; + $fixed_up_calllist .= ", "; + } + + $i += 1; + } + } + + return join(" ", + #to get the function pointer for assignment/testing + "#define", + $_[0] . "FP", + $type . "EW_GET_FUN(" . prefixname($_[0]) . ")", + #to call the function naturally + "\n#define", + $_[0] . "(" . $fixed_up_parms . ")", + $type . "EW_GET_FUN(" . prefixname($_[0]) . ")(" . $fixed_up_calllist . ")"); } my @extlist = (); diff --git a/auto/bin/make_info.pl b/auto/bin/make_info.pl index 5d0c7f6..5ef1bdc 100755 --- a/auto/bin/make_info.pl +++ b/auto/bin/make_info.pl @@ -18,7 +18,7 @@ do 'bin/make.pl'; sub make_pfn_info($%) { my $name = $_[0]; - return " glewInfoFunc(\"$_[0]\", $name == NULL);"; + return " glewInfoFunc(\"$_[0]\", $name" . "FP == NULL);"; } #--------------------------------------------------------------------------------------- diff --git a/auto/bin/make_init.pl b/auto/bin/make_init.pl index 70abc98..043f074 100755 --- a/auto/bin/make_init.pl +++ b/auto/bin/make_init.pl @@ -18,7 +18,7 @@ do 'bin/make.pl'; sub make_pfn_def_init($%) { #my $name = prefixname($_[0]); - return " r = ((" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; + return " r = ((" . $_[0] . "FP = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; } #------------------------------------------------------------------------------- diff --git a/auto/src/glew_init_glx.c b/auto/src/glew_init_glx.c index f5b393b..a663579 100644 --- a/auto/src/glew_init_glx.c +++ b/auto/src/glew_init_glx.c @@ -5,7 +5,7 @@ GLboolean glxewGetExtension (const char* name) const GLubyte* start; const GLubyte* end; - if (glXGetCurrentDisplay == NULL) return GL_FALSE; + if (glXGetCurrentDisplayFP == NULL) return GL_FALSE; start = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (0 == start) return GL_FALSE; end = start + _glewStrLen(start); @@ -45,7 +45,7 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) } /* query GLX extension string */ extStart = 0; - if (glXGetCurrentDisplay != NULL) + if (glXGetCurrentDisplayFP != NULL) extStart = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (extStart == 0) extStart = (const GLubyte *)""; From f7aca0a76273a0dd86bb23b07072408cd9b05adc Mon Sep 17 00:00:00 2001 From: rconde Date: Sat, 15 Mar 2014 18:12:50 -0400 Subject: [PATCH 2/3] - fixed handling of arrays --- auto/bin/make_header.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auto/bin/make_header.pl b/auto/bin/make_header.pl index 410984b..4d63541 100755 --- a/auto/bin/make_header.pl +++ b/auto/bin/make_header.pl @@ -59,6 +59,9 @@ sub make_pfn_alias($%) foreach(@split_parms) { my $temp = $_; + + #remove brackets + $temp =~ s/\[|\]//g; #trim off any whitespace $temp =~ s/^\s+|\s+$//g; @@ -77,9 +80,6 @@ sub make_pfn_alias($%) #replace pointer * with P $temp =~ s/\s*\*\s*/P/g; - - #remove brackets - $temp =~ s/\[|\]//g; #add to parmlist...handling cases where no parm name is specified if($parm_name eq "") From 3091aad3b3d1624a9873e4e635898288036e7160 Mon Sep 17 00:00:00 2001 From: rconde Date: Sat, 15 Mar 2014 19:01:27 -0400 Subject: [PATCH 3/3] - fixed handling of "void" despite the case --- auto/bin/make_header.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto/bin/make_header.pl b/auto/bin/make_header.pl index 4d63541..b3d0e11 100755 --- a/auto/bin/make_header.pl +++ b/auto/bin/make_header.pl @@ -47,7 +47,7 @@ sub make_pfn_alias($%) my $fixed_up_calllist = ""; #if the parm list is void, nothing to substitute - if($parms ne "void") + if(lc($parms) ne "void") { #split parms my @split_parms = split(/,/,$parms);