[gimp-perl] Use gimp_procedural_db_proc_exists. Bug #726213



commit b2cd0178a261fd37f5cc1ace42db0ab215aa7589
Author: Ed J <m8r-35s8eo mailinator com>
Date:   Thu Mar 13 01:29:38 2014 +0000

    Use gimp_procedural_db_proc_exists. Bug #726213

 Gimp.pm     |    4 +-
 Gimp/Lib.pm |    2 +-
 Gimp/Lib.xs |  116 ++++++++++++++++++++++------------------------------------
 Net/Net.pm  |    2 +-
 Perl-Server |    2 +-
 5 files changed, 49 insertions(+), 77 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index c4a274d..523d5ce 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -531,7 +531,7 @@ eval "require $interface_pkg" or croak "$@";
 $interface_pkg->import;
 
 # create some common aliases
-for(qw(_gimp_procedure_available gimp_call_procedure set_trace initialized)) {
+for(qw(gimp_procedural_db_proc_exists gimp_call_procedure set_trace initialized)) {
    *$_ = \&{"$interface_pkg\::$_"};
 }
 
@@ -586,7 +586,7 @@ sub AUTOLOAD {
             recroak $@ if $@; wantarray ? @r : $r[0];
          };
          goto &$AUTOLOAD;
-      } elsif (_gimp_procedure_available ($sub)) {
+      } elsif (gimp_procedural_db_proc_exists($sub)) {
          *{$AUTOLOAD} = sub {
             shift unless ref $_[0];
             unshift @_, $sub;
diff --git a/Gimp/Lib.pm b/Gimp/Lib.pm
index 3e5861a..9c28e4c 100644
--- a/Gimp/Lib.pm
+++ b/Gimp/Lib.pm
@@ -11,7 +11,7 @@ BEGIN {
 
 use subs qw(
        gimp_call_procedure             gimp_main       gimp_init
-       _gimp_procedure_available       set_trace       gimp_end
+       gimp_procedural_db_proc_exists  set_trace       gimp_end
         initialized
 );
 
diff --git a/Gimp/Lib.xs b/Gimp/Lib.xs
index 9c00f2d..5ebd50e 100644
--- a/Gimp/Lib.xs
+++ b/Gimp/Lib.xs
@@ -1385,82 +1385,54 @@ gimp_micro_version()
 
 # checks whether a gimp procedure exists
 int
-_gimp_procedure_available (utf8_str proc_name)
-       CODE:
-       {
-               char *proc_blurb;
-               char *proc_help;
-               char *proc_author;
-               char *proc_copyright;
-               char *proc_date;
-               GimpPDBProcType proc_type;
-               int nparams;
-               int nreturn_vals;
-               GimpParamDef *params;
-               GimpParamDef *return_vals;
-
-                if (!gimp_is_initialized)
-                  croak (__("_gimp_procedure_available(%s) called without an active connection"), proc_name);
-
-               if (gimp_procedural_db_proc_info (proc_name, &proc_blurb, &proc_help, &proc_author,
-                   &proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
-                   &params, &return_vals) == TRUE)
-                 {
-                   g_free (proc_blurb);
-                   g_free (proc_help);
-                   g_free (proc_author);
-                   g_free (proc_copyright);
-                   g_free (proc_date);
-                   gimp_destroy_paramdefs (params, nparams);
-                   gimp_destroy_paramdefs (return_vals, nreturn_vals);
-                   RETVAL = TRUE;
-                 }
-               else
-                 RETVAL = FALSE;
-
-       }
-       OUTPUT:
-       RETVAL
-
-#if 0
+gimp_procedural_db_proc_exists(char *proc_name)
+CODE:
+  if (!gimp_is_initialized)
+    croak (__("gimp_procedural_db_proc_exists(%s) called without an active connection"), proc_name);
+  RETVAL = gimp_procedural_db_proc_exists(proc_name);
+OUTPUT:
+RETVAL
 
-# checks whether a gimp procedure exists
+# get gimp procedure info
 void
 gimp_procedural_db_proc_info(proc_name)
-       char * proc_name
-       PPCODE:
-       {
-               char *proc_blurb;
-               char *proc_help;
-               char *proc_author;
-               char *proc_copyright;
-               char *proc_date;
-               GimpPDBProcType proc_type;
-               int nparams;
-               int nreturn_vals;
-               GimpParamDef *params;
-               GimpParamDef *return_vals;
-
-                if (!gimp_is_initialized)
-                  croak ("gimp_procedural_db_proc_info called without an active connection");
+char * proc_name
+PPCODE:
+{
+  char *proc_blurb;
+  char *proc_help;
+  char *proc_author;
+  char *proc_copyright;
+  char *proc_date;
+  GimpPDBProcType proc_type;
+  int nparams;
+  int nreturn_vals;
+  GimpParamDef *params;
+  GimpParamDef *return_vals;
 
-               if (gimp_procedural_db_proc_info (proc_name, &proc_blurb, &proc_help, &proc_author,
-                   &proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
-                   &params, &return_vals) == TRUE)
-                 {
-                    EXTEND (SP,8);
-                    PUSHs (newSVpv (proc_blurb,0));    g_free (proc_blurb);
-                   PUSHs (newSVpv (proc_help,0));      g_free (proc_help);
-                   PUSHs (newSVpv (proc_author,0));    g_free (proc_author);
-                   PUSHs (newSVpv (proc_copyright,0)); g_free (proc_copyright);
-                   PUSHs (newSVpv (proc_date,0));      g_free (proc_date);
-                   PUSHs (newSViv (proc_type));
-                    PUSHs (newSV_paramdefs (params, nparams));         gimp_destroy_paramdefs (params, 
nparams);
-                   PUSHs (newSV_paramdefs (return_vals, nreturn_vals));gimp_destroy_paramdefs (return_vals, 
nreturn_vals);
-                 }
-       }
+  if (!gimp_is_initialized)
+    croak("gimp_procedural_db_proc_info called without an active connection");
 
-#endif
+  if (
+    gimp_procedural_db_proc_info(
+      proc_name, &proc_blurb, &proc_help, &proc_author,
+      &proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
+      &params, &return_vals
+    ) != TRUE
+  )
+    XSRETURN_EMPTY;
+  EXTEND(SP,8);
+  PUSHs(newSVpv(proc_blurb,0));                g_free(proc_blurb);
+  PUSHs(newSVpv(proc_help,0));         g_free(proc_help);
+  PUSHs(newSVpv(proc_author,0));       g_free(proc_author);
+  PUSHs(newSVpv(proc_copyright,0));    g_free(proc_copyright);
+  PUSHs(newSVpv(proc_date,0));         g_free(proc_date);
+  PUSHs(newSViv(proc_type));
+  PUSHs(newSV_paramdefs(params, nparams));
+    gimp_destroy_paramdefs(params, nparams);
+  PUSHs(newSV_paramdefs(return_vals, nreturn_vals));
+    gimp_destroy_paramdefs(return_vals, nreturn_vals);
+}
 
 void
 gimp_call_procedure (proc_name, ...)
diff --git a/Net/Net.pm b/Net/Net.pm
index b163cf9..fc9c76c 100644
--- a/Net/Net.pm
+++ b/Net/Net.pm
@@ -54,7 +54,7 @@ sub import {
    };
 }
 
-sub _gimp_procedure_available {
+sub gimp_procedural_db_proc_exists {
    my $req="TEST".$_[0];
    print $server_fh pack("N",length($req)).$req;
    read($server_fh,$req,1);
diff --git a/Perl-Server b/Perl-Server
index d7fbabb..4589c1a 100755
--- a/Perl-Server
+++ b/Perl-Server
@@ -93,7 +93,7 @@ sub handle_request($) {
          print $fh pack("N",length($data)).$data;
       } elsif ($req eq "TEST") {
          no strict 'refs';
-         print $fh (defined(*{"Gimp::Lib::$data"}{CODE}) || Gimp::_gimp_procedure_available($data)) ? "1" : 
"0";
+         print $fh (defined(*{"Gimp::Lib::$data"}{CODE}) || Gimp::gimp_procedural_db_proc_exists($data)) ? 
"1" : "0";
       } elsif ($req eq "DTRY") {
          Gimp::Net::destroy_objects Gimp::Net::net2args 0,$data;
          print $fh pack("N",0); # fix to work around using non-sysread/write functions


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]