API cleanup, removed inconsistency in the prototypes and implementation of LogEvent...
authorJan Pospíšil <honik@ntc.zcu.cz>
Sat, 9 Jun 2007 17:14:14 +0000 (17:14 +0000)
committerJan Pospíšil <honik@ntc.zcu.cz>
Sat, 9 Jun 2007 17:14:14 +0000 (17:14 +0000)
- the .T code now identical (rewritten a lot), differs only in setting two variables $PRINTPROTOTYPESONLY and $PRINTDOC, but still duplicit in both files - would be nice to have it only once (but I don't know how to handle properly the include in perl)
- cleaned the doxygen documentation - probably still requires an overall revision (groups, etc.)

org.glite.lb.client/interface/producer.h.T
org.glite.lb.client/src/uiwrap.c.T

index 468fada..402f0ba 100644 (file)
@@ -38,88 +38,160 @@ extern "C" {
 
 /* edg_wll_LogEvent shortcuts */
 @@@{
+my $PRINTPROTOTYPESONLY = 1;
+my $PRINTDOC = 1;
+
 for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} }
                $event->getTypes) {
        my $tu = uc $t;
-       my $a = "(edg_wll_Context context";
-       my $b = "(context,EDG_WLL_EVENT_$tu,EDG_WLL_FORMAT_$tu";
-       my $doc = qq{
- * \\param[in,out] context\tcontext to work with,
-};
+       my $func = "edg_wll_Log$t";             # name of generated function
+       my $funcproxy = $func . "Proxy";
+       my $funcc = $func . "CODETOREPLACE";    # name of generated CODE function
+       my $funccproxy = $funcc . "Proxy";
+       my $p = "edg_wll_Context context";      # parameters of generated function
+       my $pc = $p;                            # parameters of generated CODE function
+       my $q = "context,EDG_WLL_EVENT_$tu,EDG_WLL_FORMAT_$tu"; # parameters for LogEvent called in generated function
+       my $qc = $q;                            # parameters for LogEvent called in generated CODE function
+       my $text = "";                          # whole text for generated function
+       my $textproxy = "";                     # whole text for generated CODE function
+       my $doc = " * \\param[in,out] context\tcontext to work with, \n"; # parameters description for generated function
+       my $docc = $doc;                        # parameters description for generated CODE function
+
+       my $decl = "\tint ret;\n";              
+       my $free = "";
+
        selectType $event $t;
        for ($event->getFieldsOrdered) {
                my $f = selectField $event $_;
                my $fn = $f->getName;
-               my $ft;
+               my $sfn = $fn;
+               my $ft = "const ";
+               my $fc = $f->getComment;
+               if ($ULMasString{$f->{type}}) {
+                       $decl .= "\tchar *s_$fn = ".$f->getType()."ToString($fn);\n";
+                       $free .= "\tif (s_$fn) free(s_$fn);\n";
+                       $sfn = "s_$fn";
+               }
                 if ($f->{codes}) {
-#                        $ft = "enum edg_wll\_$t" . ucfirst $fn;
-                        $ft = "char *";
+# XXX: obsolete         $ft = "enum edg_wll\_$t" . ucfirst $fn;
+                        $ft = $ft . "char *";
+                       $qc = $qc . ", CODETOREPLACE";
                 } else {
-                        $ft = $f->getType;
+                        $ft = $ft . $f->getType;
+                       $pc = $pc . ", $ft $fn";
+                       $qc = $qc . ", $sfn";
+                       $docc = $docc . " * \\param[in] $fn\t$fc\n";
                 }
-               $ft = "const ".$ft;
-               my $fc = $f->getComment;
-               $a = $a . ", $ft $fn";
-               $b = $b . ", $fn";
+               $p = $p . ", $ft $fn";
+               $q = $q . ", $sfn";
                $doc = $doc . " * \\param[in] $fn\t$fc\n";
        }
-       $a = $a . ")";
-       $b = $b . ")";
-       gen qq{
+       $text = qq{
 /**
- * \\fn int edg_wll_Log$t$a; 
- * \\brief simple wrapper around edg_wll_LogEvent for event $t} . $doc . qq{ * \\see edg_wll_LogEvent\(\)
- */
+ * \\brief $func
+ *
+ * $func - simple wrapper around edg_wll_LogEvent for event $t
+ *
 };
-       gen "\nextern int edg_wll_Log${t}$a;\n";
-       gen "\nextern int edg_wll_Log${t}Proxy$a;\n";
-#      gen qq{
-#int edg_wll_Log$t$a
-#\{
-#      return edg_wll_LogEvent$b;
-#\}\n
-#};
+       $textproxy = qq{
+/**
+ * \\brief $funcproxy
+ *
+ * $funcproxy - simple wrapper around edg_wll_LogEventProxy for event $t
+ *
+};
+       if ($PRINTDOC) {
+               $text = $text . $doc . " * \\see edg_wll_LogEvent()\n";
+               $textproxy = $textproxy . $doc . "* \\see edg_wll_LogEventProxy()\n"
+       }
+       $text = $text . " */\n";
+       $textproxy = $textproxy . " */\n";
+       if ($PRINTPROTOTYPESONLY) {
+               $text = $text . "\nextern int $func($p);\n";
+               $textproxy = $textproxy . "\nextern int $funcproxy($p);\n";
+       } else {
+               $text = $text . qq{
+int $func($p)
+\{
+$decl
+       ret = edg_wll_LogEvent($q);
+$free
+       return ret;
+\}
+};
+               $textproxy = $textproxy . qq{
+int $funcproxy($p)
+\{
+$decl
+       ret = edg_wll_LogEventProxy($q);
+$free
+       return ret;
+\}
+};
+       }
+       gen "$text";
+       gen "$textproxy";
+
+       #
+       # generate also CODE functions:
+       #
        for ($event->getFieldsOrdered) {
-               my $f = selectField $event $_;
-               my $fn = $f->getName;
-               my $ft;
-                if ($f->{codes}) {
-#                        $ft = "enum edg_wll\_$t" . ucfirst $fn;
-                        $ft = "char *";
-                } else {
-                        $ft = $f->getType;
-                }
-               my $ftreg = $ft;
-               $ftreg =~ s/\*/\\\*/g;
-               $ftreg = "const ".$ftreg;
-               my $fc = $f->getComment;
-               if ($f->{codes}) {
-                       for (@{$f->{codes}}) {
-                               my $code = uc $_->{name};
-                               my $c = $a;
-                               my $d = $b;
-                               my $e = $doc;
-                               $c =~ s/, $ftreg $fn//g;
-                               $d =~ s/$fn/"$code"/g;
-# FIXME: this documentation line in $e doesn't delete!!
-                               $e =~ s/ \* \\param\[in\] $fn\t$fc\n//g;
-                               gen qq{
+       my $f = selectField $event $_;
+       my $fn = $f->getName;
+       if ($f->{codes}) {
+       for (@{$f->{codes}}) {
+               my $code = uc $_->{name};
+               my $funccc = $funcc; $funccc =~ s/CODETOREPLACE/$code/g;
+               my $funcccproxy = $funccproxy; $funcccproxy =~ s/CODETOREPLACE/$code/g;
+               my $qcc = $qc; $qcc =~ s/CODETOREPLACE/"$code"/g;
+               my $textc = qq{
 /**
- * \\fn int edg_wll_Log$t$code$c; 
- * \\brief simple wrapper around edg_wll_LogEvent for event $t, $fn $code} . $e . qq{ * \\see edg_wll_LogEvent\(\)
- */
+ * \\brief $funccc
+ *
+ * $funccc - simple wrapper around edg_wll_LogEvent for event $t, $fn $code
+ *
 };
-                               gen "\nextern int edg_wll_Log$t${code}$c;\n";
-                               gen "\nextern int edg_wll_Log$t${code}Proxy$c;\n";
-#                              gen qq{
-#int edg_wll_Log$t$code$c
-#\{
-#      return edg_wll_LogEvent$d;
-#\}\n
-#};
-                       }
+               my $textcproxy = qq{
+/**
+ * \\brief $funcccproxy
+ *
+ * $funcccproxy - simple wrapper around edg_wll_LogEventProxy for event $t, $fn $code
+ *
+};
+               if ($PRINTDOC) {
+                       $textc = $textc . $docc . " * \\see edg_wll_LogEvent()\n";
+                       $textcproxy = $textcproxy . $docc . " * \\see edg_wll_LogEventProxy()\n";
                }
-       }
+               $textc = $textc . " */\n";
+               $textcproxy = $textcproxy . " */\n";
+               if ($PRINTPROTOTYPESONLY) {
+                       $textc = $textc . "\nextern int $funccc($pc);\n";
+                       $textcproxy = $textcproxy . "\nextern int $funcccproxy($pc);\n";
+               } else {
+                       $textc = $textc . qq{
+int $funccc($pc)
+\{
+$decl
+       ret = edg_wll_LogEvent($qcc);
+$free
+       return ret;
+\}
+};
+                       $textcproxy = $textcproxy . qq{
+int $funcccproxy($pc)
+\{
+$decl
+       ret = edg_wll_LogEventProxy($qcc);
+$free
+       return ret;
+\}
+};
+               }
+               gen "$textc";
+               gen "$textcproxy";
+       } # for codes
+       } # if
+       } # for getFields
 }
 @@@}
 
@@ -302,8 +374,9 @@ extern int edg_wll_RegisterJobSync(
  * Partitionable jobs should set num_subjobs=0 initially,
  * and re-register when number of subjobs becomes known.
  *
+ * \param[in,out] context      context to work with
+ * \param[in] job              jobId
  * \param[in] type             EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE
- * \param[in] user             user credentials
  * \param[in] jdl              user-specified JDL
  * \param[in] ns               network server contact
  * \param[in] num_subjobs      number of subjobs to create
@@ -357,7 +430,10 @@ extern int edg_wll_RegisterJobProxyOnly(
  * Register subjobs in a batch.
  * Mainly used to provide JDL's of individual subjobs in a more efficient
  * way than logging them one by one.
+ * \param[in,out] context      context to work with
+ * \param[in] parent           parent's jobId
  * \param[in] jdls             array of JDL's
+ * \param[in] ns               network server contact
  * \param[in] subjobs          array of jobid's in the same order
  */
 
@@ -374,7 +450,10 @@ extern int edg_wll_RegisterSubjobs(
  * Register subjobs to LB Proxyin a batch.
  * Mainly used to provide JDL's of individual subjobs in a more efficient
  * way than logging them one by one.
+ * \param[in,out] context      context to work with
+ * \param[in] parent           parent's jobId
  * \param[in] jdls             array of JDL's
+ * \param[in] ns               network server contact
  * \param[in] subjobs          array of jobid's in the same order
  */
 
index a64316d..4c71b39 100644 (file)
 */
 @@@LANG: C
 
+#include <stdlib.h>
 #include "glite/wmsutils/jobid/cjobid.h"
 #include "producer.h"
 
 @@@{
+my $PRINTPROTOTYPESONLY = 0;
+my $PRINTDOC = 0;
+
 for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} }
                $event->getTypes) {
        my $tu = uc $t;
-       my $a = "(edg_wll_Context context";
-       my $b = "(context,EDG_WLL_EVENT_$tu,EDG_WLL_FORMAT_$tu";
-       my $decl = "";
+       my $func = "edg_wll_Log$t";             # name of generated function
+       my $funcproxy = $func . "Proxy";
+       my $funcc = $func . "CODETOREPLACE";    # name of generated CODE function
+       my $funccproxy = $funcc . "Proxy";
+       my $p = "edg_wll_Context context";      # parameters of generated function
+       my $pc = $p;                            # parameters of generated CODE function
+       my $q = "context,EDG_WLL_EVENT_$tu,EDG_WLL_FORMAT_$tu"; # parameters for LogEvent called in generated function
+       my $qc = $q;                            # parameters for LogEvent called in generated CODE function
+       my $text = "";                          # whole text for generated function
+       my $textproxy = "";                     # whole text for generated CODE function
+       my $doc = " * \\param[in,out] context\tcontext to work with, \n"; # parameters description for generated function
+       my $docc = $doc;                        # parameters description for generated CODE function
+
+       my $decl = "\tint ret;\n";              
        my $free = "";
-       my $doc = qq{
- * \\param context\tcontext to work with,
-};
+
        selectType $event $t;
        for ($event->getFieldsOrdered) {
                my $f = selectField $event $_;
                my $fn = $f->getName;
-               my $ft;
-               my $bfn = $fn;
-                if ($f->{codes}) {
-#                        $ft = "enum edg_wll\_$t" . ucfirst $fn;
-                        $ft = "char *";
-                } else {
-                        $ft = $f->getType;
-                }
+               my $sfn = $fn;
+               my $ft = "const ";
+               my $fc = $f->getComment;
                if ($ULMasString{$f->{type}}) {
                        $decl .= "\tchar *s_$fn = ".$f->getType()."ToString($fn);\n";
-                       $free .= "\tfree(s_$fn);\n";
-                       $bfn = "s_$fn";
+                       $free .= "\tif (s_$fn) free(s_$fn);\n";
+                       $sfn = "s_$fn";
                }
-               $ft = "const ".$ft;
-               my $fc = $f->getComment;
-               $a = $a . ", $ft $fn";
-               $b = $b . ", $bfn";
-               $doc = $doc . " * \\param $fn\t$fc\n";
+                if ($f->{codes}) {
+# XXX: obsolete         $ft = "enum edg_wll\_$t" . ucfirst $fn;
+                        $ft = $ft . "char *";
+                       $qc = $qc . ", CODETOREPLACE";
+                } else {
+                        $ft = $ft . $f->getType;
+                       $pc = $pc . ", $ft $fn";
+                       $qc = $qc . ", $sfn";
+                       $docc = $docc . " * \\param[in] $fn\t$fc\n";
+                }
+               $p = $p . ", $ft $fn";
+               $q = $q . ", $sfn";
+               $doc = $doc . " * \\param[in] $fn\t$fc\n";
        }
-       $a = $a . ")";
-       $b = $b . ")";
-
-       gen qq{
-/*!
- * \\fn int edg_wll_Log$t$a; 
- * \\brief simple wrapper around edg_wll_LogEvent for event $t} . $doc . qq{ * \\see edg_wll_LogEvent\(\)
- */
+       $text = qq{
+/**
+ * \\brief $func
+ *
+ * $func - simple wrapper around edg_wll_LogEvent for event $t
+ *
 };
-#      gen "\nextern int edg_wll_Log$t$a;\n\n";
-       gen qq{
-int edg_wll_Log$t$a
+       $textproxy = qq{
+/**
+ * \\brief $funcproxy
+ *
+ * $funcproxy - simple wrapper around edg_wll_LogEventProxy for event $t
+ *
+};
+       if ($PRINTDOC) {
+               $text = $text . $doc . " * \\see edg_wll_LogEvent()\n";
+               $textproxy = $textproxy . $doc . "* \\see edg_wll_LogEventProxy()\n"
+       }
+       $text = $text . " */\n";
+       $textproxy = $textproxy . " */\n";
+       if ($PRINTPROTOTYPESONLY) {
+               $text = $text . "\nextern int $func($p);\n";
+               $textproxy = $textproxy . "\nextern int $funcproxy($p);\n";
+       } else {
+               $text = $text . qq{
+int $func($p)
 \{
 $decl
-       return edg_wll_LogEvent$b;
-\}\n
+       ret = edg_wll_LogEvent($q);
+$free
+       return ret;
+\}
 };
-       gen qq{
-int edg_wll_Log${t}Proxy$a
+               $textproxy = $textproxy . qq{
+int $funcproxy($p)
 \{
 $decl
-       return edg_wll_LogEventProxy$b;
-\}\n
+       ret = edg_wll_LogEventProxy($q);
+$free
+       return ret;
+\}
 };
+       }
+       gen "$text";
+       gen "$textproxy";
+
+       #
+       # generate also CODE functions:
+       #
        for ($event->getFieldsOrdered) {
-               my $f = selectField $event $_;
-               my $fn = $f->getName;
-               my $ft;
-                if ($f->{codes}) {
-#                        $ft = "enum edg_wll\_$t" . ucfirst $fn;
-                        $ft = "char *";
-                } else {
-                        $ft = $f->getType;
-                }
-               my $ftreg = $ft;
-               $ftreg =~ s/\*/\\\*/g;
-               $ftreg = "const ".$ftreg;
-               my $fc = $f->getComment;
-               if ($f->{codes}) {
-                       for (@{$f->{codes}}) {
-                               my $code = uc $_->{name};
-                               my $c = $a;
-                               my $d = $b;
-                               my $e = $doc;
-                               $c =~ s/, $ftreg $fn//g;
-                               $d =~ s/$fn/"$code"/g;
-                               $e =~ s/ \* \\param $fn\t$fc\n//g;
-                               gen qq{
-/*!
- * \\fn int edg_wll_Log$t$code$c; 
- * \\brief simple wrapper around edg_wll_LogEvent for event $t, $fn $code} . $e . qq{ * \\see edg_wll_LogEvent\(\)
- */
+       my $f = selectField $event $_;
+       my $fn = $f->getName;
+       if ($f->{codes}) {
+       for (@{$f->{codes}}) {
+               my $code = uc $_->{name};
+               my $funccc = $funcc; $funccc =~ s/CODETOREPLACE/$code/g;
+               my $funcccproxy = $funccproxy; $funcccproxy =~ s/CODETOREPLACE/$code/g;
+               my $qcc = $qc; $qcc =~ s/CODETOREPLACE/"$code"/g;
+               my $textc = qq{
+/**
+ * \\brief $funccc
+ *
+ * $funccc - simple wrapper around edg_wll_LogEvent for event $t, $fn $code
+ *
 };
-#                              gen "\nextern int edg_wll_Log$t$code$c;\n\n";
-                               gen qq{
-int edg_wll_Log$t$code$c
+               my $textcproxy = qq{
+/**
+ * \\brief $funcccproxy
+ *
+ * $funcccproxy - simple wrapper around edg_wll_LogEventProxy for event $t, $fn $code
+ *
+};
+               if ($PRINTDOC) {
+                       $textc = $textc . $docc . " * \\see edg_wll_LogEvent()\n";
+                       $textcproxy = $textcproxy . $docc . " * \\see edg_wll_LogEventProxy()\n";
+               }
+               $textc = $textc . " */\n";
+               $textcproxy = $textcproxy . " */\n";
+               if ($PRINTPROTOTYPESONLY) {
+                       $textc = $textc . "\nextern int $funccc($pc);\n";
+                       $textcproxy = $textcproxy . "\nextern int $funcccproxy($pc);\n";
+               } else {
+                       $textc = $textc . qq{
+int $funccc($pc)
 \{
 $decl
-       return edg_wll_LogEvent$d;
-\}\n
+       ret = edg_wll_LogEvent($qcc);
+$free
+       return ret;
+\}
 };
-                               gen qq{
-int edg_wll_Log$t${code}Proxy$c
+                       $textcproxy = $textcproxy . qq{
+int $funcccproxy($pc)
 \{
 $decl
-       return edg_wll_LogEventProxy$d;
-\}\n
+       ret = edg_wll_LogEventProxy($qcc);
+$free
+       return ret;
+\}
 };
-                       }
                }
-       }
+               gen "$textc";
+               gen "$textcproxy";
+       } # for codes
+       } # if
+       } # for getFields
 }
 @@@}