* Mono.WebBrowser/tools/xpidl2cs/xpidl2cs.pl: add option parsing. add
authorAndreia Gaita <avidigal@novell.com>
Mon, 13 Oct 2008 23:34:46 +0000 (23:34 -0000)
committerAndreia Gaita <avidigal@novell.com>
Mon, 13 Oct 2008 23:34:46 +0000 (23:34 -0000)
  support for choosing a specific interface to process inside an idl
  which defines several interfaces

2008-10-14  Andreia Gaita  <avidigal@novell.com>

svn path=/trunk/mcs/; revision=115715

mcs/class/Mono.WebBrowser/tools/xpidl2cs/ChangeLog
mcs/class/Mono.WebBrowser/tools/xpidl2cs/xpidl2cs.pl

index 1c7539992878b7b9626868201f46573c5bb7a474..259d17039d7cf8863d1587b922d1ed7250a9d18a 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-14  Andreia Gaita  <avidigal@novell.com>
+
+       * xpidl2cs.pl: add option parsing. add support for choosing a specific
+       interface to process inside an idl which defines several interfaces
+
 2008-09-23  Andreia Gaita <avidigal@novell.com> 
 
        * xpidl2cs.pl: whitespace clean up
index afb0f1f6a2aba3908799fdf24d88076fdc5b1b7b..8aabd350f40cef794cef17ee3bcfe2c8b01fd9a1 100755 (executable)
 # Boston, MA 02111-1307, USA.
 ##############################################################
 
-die "Usage: xpidl2cs.pl file.idl [/path/to/idl/]" if scalar(@ARGV) < 1;
 
-my $file = shift;
-my $path = shift if scalar(@ARGV) > 0;
-my $nosig = shift if scalar(@ARGV) > 0;
-$nosig = "" if !$nosig;
 
-open FILE, '<', $path.$file or die "Can't open file $path$file";
+
+my $file;
+my $path;
+my $nosig;
+my $_class;
+my %opt=();
+
+#open FILE, '<', $path.$file or die "Can't open file $path$file";
 
 my %interface = (
                 properties => (), 
@@ -128,6 +130,39 @@ my %dependents;
    
 my $class_implementation;
 
+
+
+sub usage ()
+{
+       print STDERR << "EOF";
+    Usage: xpidl2cs.pl -f file -p path/to/idl [-nh -c class]
+    -h         : this help
+    -f         : idl file to parse, with extension
+    -p         : path to the idl file directory
+    -n         : generate files with no PreserveSig attribute (optional, defaults to adding the attribute)
+    -c         : specific class to use inside the idl file (optional)
+EOF
+       exit;
+}
+
+sub init ()
+{
+       use Getopt::Std;
+       my $opts = 'f:p:c:n';
+       getopts( "$opts", \%opt ) or usage();
+       usage if $opt{h};
+
+       usage() if !$opt{f} or !$opt{p};
+
+       $file = $opt{f};
+       $path = $opt{p};
+       open FILE, '<', $path.$file or die "Can't open file $path$file";
+       
+       $nosig = 1 if $opt{n};
+       $_class = $opt{c};
+}
+
+
 sub trim{
 #print "trim\n";
     $_[0]=~s/^\s+//;
@@ -442,6 +477,19 @@ sub parse_file {
                                my $class = $line;
                                $class =~ s/interface ([^\:|\s]+)\s*:\s*(.*)/\1/;
 #              print "\t\tclass:$class\n";
+#              print "\t\t_class:$_class\n";
+                               if ($_class && $_class !~ $class) {
+                                       $uuid = '';
+                                       $class = '';
+                                       $method = 0;
+                                       $mname = '';
+                                       $mtype = '';
+                                       $mparams = '';
+                                       $start = 0;
+                                       $comment = 0;
+                                       next;
+                               }
+
                                my $parent = $line;
                                $parent =~ s/([^\:]+):\s*(.*)[\s|\{]/\2/;
 #              print "\t\tparent:$parent\n";
@@ -681,7 +729,9 @@ sub generate_dependents {
     for my $dependent (keys %dependents) {
                if (! (-e "$dependent.cs") && -e "$path$dependent.idl" && $file != $dependent) {
                        print "generating $path$dependent.idl\n";
-                       my $ret = `perl xpidl2cs.pl $dependent.idl $path $nosig`;
+                       my $cmd = "perl xpidl2cs.pl -f $dependent.idl -p $path";
+                       $cmd .= "-n" if $nosig;
+                       my $ret = `$cmd`;
                        print "\n$ret";
                }
     }
@@ -803,7 +853,7 @@ sub generate_class_implementation_example {
        
 }
 
-
+&init();
 &parse_file ();
 &output ();
 &generate_dependents ();