[Libreoffice-commits] core.git: 3 commits - idlc/CustomTarget_parser_test.mk solenv/bin unoidl/source

Stephan Bergmann sbergman at redhat.com
Fri Sep 20 06:38:28 PDT 2013


 idlc/CustomTarget_parser_test.mk                 |   44 +++++-----
 solenv/bin/exectest.pl                           |   97 +++++++++--------------
 unoidl/source/sourceprovider-parser-requires.hxx |    2 
 unoidl/source/sourceprovider-parser.y            |   95 ++++++++++++++++++----
 unoidl/source/sourceprovider-scanner.hxx         |   33 +++++++
 5 files changed, 177 insertions(+), 94 deletions(-)

New commits:
commit 60f8d808c2451fd37f02c1f86ed7fe60f4f58fa6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 20 13:11:59 2013 +0200

    Reject "too similar" service constructors
    
    Change-Id: Ie81e9994084b5a2f44a436c764318ea6e5049faf

diff --git a/unoidl/source/sourceprovider-parser-requires.hxx b/unoidl/source/sourceprovider-parser-requires.hxx
index fc84c5d..9865720 100644
--- a/unoidl/source/sourceprovider-parser-requires.hxx
+++ b/unoidl/source/sourceprovider-parser-requires.hxx
@@ -118,6 +118,8 @@ struct SourceProviderType {
 
     OUString getName() const;
 
+    bool equals(SourceProviderType const & other) const;
+
     Type type;
     OUString name; // TYPE_ENUM ... TYPE_PARAMETER
     SourceProviderEntity const * entity;
diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y
index e410f35..6512e4a 100644
--- a/unoidl/source/sourceprovider-parser.y
+++ b/unoidl/source/sourceprovider-parser.y
@@ -2205,13 +2205,32 @@ singleInterfaceBasedServiceDefn:
           dynamic_cast<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad *>(
               ent->pad.get());
       assert(pad != 0);
-      if (!$7) {
+      std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor> ctors;
+      if ($7) {
+          for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor>::iterator
+                   i(pad->constructors.begin());
+               i != pad->constructors.end(); ++i)
+          {
+              std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter> parms;
+              for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter>::iterator
+                       j(i->parameters.begin());
+                   j != i->parameters.end(); ++j)
+              {
+                  parms.push_back(
+                      unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter(
+                          j->name, j->type.getName(), j->rest));
+              }
+              ctors.push_back(
+                  unoidl::SingleInterfaceBasedServiceEntity::Constructor(
+                      i->name, parms, i->exceptions, i->annotations));
+          }
+      } else {
           assert(pad->constructors.empty());
-          pad->constructors.push_back(
+          ctors.push_back(
               unoidl::SingleInterfaceBasedServiceEntity::Constructor());
       }
       ent->entity = new unoidl::SingleInterfaceBasedServiceEntity(
-          pad->isPublished(), pad->base, pad->constructors, annotations($1));
+          pad->isPublished(), pad->base, ctors, annotations($1));
       ent->pad.clear();
       clearCurrentName(data);
   }
@@ -2235,7 +2254,7 @@ ctor:
       rtl::Reference<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>
           pad(getCurrentPad<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>(
                   data));
-      for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>::iterator
+      for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor>::iterator
                i(pad->constructors.begin());
            i != pad->constructors.end(); ++i)
       {
@@ -2249,22 +2268,49 @@ ctor:
           }
       }
       pad->constructors.push_back(
-          unoidl::SingleInterfaceBasedServiceEntity::Constructor(
-              id, std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter>(),
-              std::vector<OUString>(), annotations($1)));
+          unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor(
+              id, annotations($1)));
   }
   '(' ctorParams_opt ')' exceptionSpec_opt ';'
   {
+      unoidl::detail::SourceProviderScannerData * data = yyget_extra(yyscanner);
+      rtl::Reference<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>
+          pad(getCurrentPad<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>(
+                  data));
+      assert(!pad->constructors.empty());
       if ($7 != 0) {
-          unoidl::detail::SourceProviderScannerData * data
-              = yyget_extra(yyscanner);
-          rtl::Reference<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>
-              pad(getCurrentPad<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>(
-                      data));
-          assert(!pad->constructors.empty());
           pad->constructors.back().exceptions = *$7;
           delete $7;
       }
+      for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor>::iterator
+               i(pad->constructors.begin());
+           i != pad->constructors.end() - 1; ++i)
+      {
+          if (i->parameters.size()
+              == pad->constructors.back().parameters.size())
+          {
+              bool same = true;
+              for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter>::iterator
+                       j(i->parameters.begin()),
+                       k(pad->constructors.back().parameters.begin());
+                   j != i->parameters.end(); ++j, ++k)
+              {
+                  if (!j->type.equals(k->type) || j->rest != k->rest) {
+                      same = false;
+                      break;
+                  }
+              }
+              if (same) {
+                  error(
+                      @2, yyscanner,
+                      ("single-interface--based service " + data->currentName
+                       + " constructor " + pad->constructors.back().name
+                       + " has similar paramete list to constructor "
+                       + i->name));
+                  YYERROR;
+              }
+          }
+      }
   }
 ;
 
@@ -2338,7 +2384,7 @@ ctorParam:
                + " rest parameter must be last parameter"));
           YYERROR;
       }
-      for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter>::iterator
+      for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter>::iterator
                i(pad->constructors.back().parameters.begin());
            i != pad->constructors.back().parameters.end(); ++i)
       {
@@ -2353,8 +2399,8 @@ ctorParam:
           }
       }
       pad->constructors.back().parameters.push_back(
-          unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter(
-              id, t.getName(), $5));
+          unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter(
+              id, t, $5));
   }
 ;
 
@@ -3682,6 +3728,23 @@ OUString SourceProviderType::getName() const {
     }
 }
 
+bool SourceProviderType::equals(SourceProviderType const & other) const {
+    if (type != other.type || name != other.name
+        || subtypes.size() != other.subtypes.size())
+    {
+        return false;
+    }
+    for (std::vector<SourceProviderType>::const_iterator
+             i(subtypes.begin()), j(other.subtypes.begin());
+         i != subtypes.end(); ++i, ++j)
+    {
+        if (!i->equals(*j)) {
+            return false;
+        }
+    }
+    return true;
+}
+
 bool parse(OUString const & uri, SourceProviderScannerData * data) {
     assert(data != 0);
     oslFileHandle handle;
diff --git a/unoidl/source/sourceprovider-scanner.hxx b/unoidl/source/sourceprovider-scanner.hxx
index 8a79d31..0c08a13 100644
--- a/unoidl/source/sourceprovider-scanner.hxx
+++ b/unoidl/source/sourceprovider-scanner.hxx
@@ -156,14 +156,43 @@ class SourceProviderSingleInterfaceBasedServiceEntityPad:
     public SourceProviderEntityPad
 {
 public:
+    struct Constructor {
+        struct Parameter {
+            Parameter(
+                rtl::OUString const & theName,
+                SourceProviderType const & theType, bool theRest):
+                name(theName), type(theType), rest(theRest)
+            {}
+
+            rtl::OUString name;
+
+            SourceProviderType type;
+
+            bool rest;
+        };
+
+        Constructor(
+            rtl::OUString const & theName,
+            std::vector< rtl::OUString > const & theAnnotations):
+            name(theName), annotations(theAnnotations)
+        {}
+
+        rtl::OUString const name;
+
+        std::vector< Parameter > parameters;
+
+        std::vector< rtl::OUString > exceptions;
+
+        std::vector< rtl::OUString > const annotations;
+    };
+
     explicit SourceProviderSingleInterfaceBasedServiceEntityPad(
         bool published, OUString const & theBase):
         SourceProviderEntityPad(published), base(theBase)
     {}
 
     OUString const base;
-    std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>
-        constructors;
+    std::vector<Constructor> constructors;
 
 private:
     virtual ~SourceProviderSingleInterfaceBasedServiceEntityPad() throw () {}
commit aeee571501df4d3b1d91e10d61b434f0ecac4d6a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 20 11:01:44 2013 +0200

    Use tempfile instead of stdin in exectest.pl
    
    ...so it can easily be reused to test unoidl-write, too.
    
    Change-Id: I4992850b44faaa152bcf1d281f2787824d6ad036

diff --git a/idlc/CustomTarget_parser_test.mk b/idlc/CustomTarget_parser_test.mk
index 6be490a..d8defd6 100644
--- a/idlc/CustomTarget_parser_test.mk
+++ b/idlc/CustomTarget_parser_test.mk
@@ -23,57 +23,59 @@ $(call gb_CustomTarget_get_target,idlc/parser_test) : \
             $(SRCDIR)/idlc/test/parser/polystruct.tests \
             $(SRCDIR)/idlc/test/parser/published.tests \
             $(SRCDIR)/idlc/test/parser/struct.tests \
-            $(SRCDIR)/idlc/test/parser/typedef.tests
+            $(SRCDIR)/idlc/test/parser/typedef.tests \
+            | $(call gb_CustomTarget_get_workdir,idlc/parser_test)/.dir
 	$(call gb_Helper_abbreviate_dirs,( \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/attribute.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/constant.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/constructor.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/interfaceinheritance.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/methodoverload.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/oldstyle.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/polystruct.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/published.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/struct.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin && \
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {} && \
             $(PERL) $(SRCDIR)/solenv/bin/exectest.pl \
                 $(SRCDIR)/idlc/test/parser/typedef.tests \
+                $(call gb_CustomTarget_get_workdir,idlc/parser_test)/in.idl \
                 $(call gb_Executable_get_command,idlc) \
-                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) \
-                -stdin) > $@.log 2>&1 || (cat $@.log && false))
+                -O $(call gb_CustomTarget_get_workdir,idlc/parser_test) {}) \
+            > ${}.log 2>&1 || (cat ${}.log && false))
 
 # vim: set noet sw=4 ts=4:
diff --git a/solenv/bin/exectest.pl b/solenv/bin/exectest.pl
index 2cd9fb6..bd9b5f3 100644
--- a/solenv/bin/exectest.pl
+++ b/solenv/bin/exectest.pl
@@ -23,8 +23,11 @@ sub encode($)
     return $arg
 }
 
-$#ARGV >= 1 or die "Usage: $0 <input file> <command> <arguments...>";
-open INPUT, $ARGV[0] or die "cannot open $ARGV[0]: $!";
+$#ARGV >= 2
+    or die "Usage: $0 <input file> <temp file> <command> <arguments...>";
+open INPUT, '<', $ARGV[0] or die "cannot open $ARGV[0]: $!";
+shift @ARGV;
+$temp = $ARGV[0];
 shift @ARGV;
 $failed = 0;
 $open = 0;
@@ -35,7 +38,31 @@ while (1) {
     {
         if ($open)
         {
-            close PIPE;
+            close OUTPUT;
+            my $prog = '';
+            my $assigns = 1;
+            for ($i = 0; $i != scalar(@ARGV); ++$i)
+            {
+                $prog .= ' ' unless $i == 0;
+                if ($assigns && $ARGV[$i] =~ /^([A-Za-z_][A-Za-z0-9_]+)=(.*)$/)
+                {
+                    $prog .= $1 . "='" . encode($2) . "'";
+                }
+                else
+                {
+                    if ($ARGV[$i] =~ /^{}$/)
+                    {
+                        $prog .= "'" . encode($temp) . "'";
+                    }
+                    else
+                    {
+                        $prog .= "'" . encode($ARGV[$i]) . "'";
+                    }
+                    $assigns = 0;
+                }
+            }
+            system("$prog");
+            unlink $temp;
             if ($? % 256 == 0)
             {
                 $exit = $? / 256;
@@ -60,27 +87,12 @@ while (1) {
         last if $eof;
         $expect = $1;
         $title = $2;
-        my $prog = '';
-        my $assigns = 1;
-        for ($i = 0; $i != scalar(@ARGV); ++$i)
-        {
-            $prog .= ' ' unless $i == 0;
-            if ($assigns && $ARGV[$i] =~ /^([A-Za-z_][A-Za-z0-9_]+)=(.*)$/)
-            {
-                $prog .= $1 . "='" . encode($2) . "'";
-            }
-            else
-            {
-                $prog .= "'" . encode($ARGV[$i]) . "'";
-                $assigns = 0;
-            }
-        }
-        open PIPE, "| $prog" or die "cannot start process: $!";
+        open OUTPUT, '>', $temp or die "cannot open $temp: $!";
         $open = 1;
     }
     elsif ($open)
     {
-        print PIPE $in or die "cannot write to pipe: $!";
+        print OUTPUT $in or die "cannot write to $temp: $!";
     }
 }
 exit(0);
commit 89d911a2775118dbf5e4cd337e4ede4284b6f717
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 20 10:35:57 2013 +0200

    Strip exectest.pl down to what is needed by its only client
    
    Change-Id: I9355f8618757f657fb8f8408a10b02f113fc0966

diff --git a/solenv/bin/exectest.pl b/solenv/bin/exectest.pl
index 06c9072..2cd9fb6 100644
--- a/solenv/bin/exectest.pl
+++ b/solenv/bin/exectest.pl
@@ -23,31 +23,15 @@ sub encode($)
     return $arg
 }
 
-$#ARGV >= 1
-    or die "Usage: $0 <input file>|-SUCCESS|-FAILURE <command> <arguments...>";
-if ($ARGV[0] eq "-SUCCESS")
-{
-    $expect = "SUCCESS";
-    $input = 0;
-}
-elsif ($ARGV[0] eq "-FAILURE")
-{
-    $expect = "FAILURE";
-    $input = 0;
-}
-else
-{
-    open INPUT, $ARGV[0] or die "cannot open $ARGV[0]: $!";
-    $input = 1;
-}
+$#ARGV >= 1 or die "Usage: $0 <input file> <command> <arguments...>";
+open INPUT, $ARGV[0] or die "cannot open $ARGV[0]: $!";
 shift @ARGV;
 $failed = 0;
 $open = 0;
 while (1) {
-    $eof = $input ? eof INPUT : $open;
-    $in = <INPUT> if $input && !$eof;
-    if (!$input || $eof
-        || $in =~ /^EXPECT (SUCCESS|FAILURE|\d+)( "([^"]*)")?:\n$/)
+    $eof = eof INPUT;
+    $in = <INPUT> unless $eof;
+    if ($eof || $in =~ /^EXPECT (SUCCESS|FAILURE) "([^"]*)"?:\n$/)
     {
         if ($open)
         {
@@ -55,16 +39,14 @@ while (1) {
             if ($? % 256 == 0)
             {
                 $exit = $? / 256;
-                $ok = $expect eq "SUCCESS" ? $exit == 0
-                    : $expect eq "FAILURE" ? $exit != 0 : $exit == $expect;
+                $ok = ($? == 0) == ($expect eq "SUCCESS");
             }
             else
             {
                 $exit = "signal";
                 $ok = 0;
             }
-            print "\"$title\", " if defined $title;
-            print "expected $expect, got $exit ($?): ";
+            print "\"$title\" expected $expect, got $exit ($?): ";
             if ($ok)
             {
                 print "ok\n";
@@ -72,19 +54,12 @@ while (1) {
             else
             {
                 print "FAILED!\n";
-                $failed = 1;
+                exit(1);
             }
         }
         last if $eof;
-        $expect = $1 if $input;
-        if (defined $3)
-        {
-            $title = $3;
-        }
-        else
-        {
-            undef $title;
-        }
+        $expect = $1;
+        $title = $2;
         my $prog = '';
         my $assigns = 1;
         for ($i = 0; $i != scalar(@ARGV); ++$i)
@@ -103,9 +78,9 @@ while (1) {
         open PIPE, "| $prog" or die "cannot start process: $!";
         $open = 1;
     }
-    elsif ($open && $input)
+    elsif ($open)
     {
         print PIPE $in or die "cannot write to pipe: $!";
     }
 }
-exit $failed;
+exit(0);


More information about the Libreoffice-commits mailing list