[glibmm/gmmproc-refactor] Another bunch of changes.



commit e04454b8a38c50916bda5a6d7a25444f2807cbb4
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Tue Feb 15 17:38:58 2011 +0100

    Another bunch of changes.
    
    Cleaned up whitespace. Began using exceptions. Added base class for
    api backends. Almost finished Defs::Backend. Made changes
    in gmmproc.in to show what I want to attain. Added more meaningful
    TODO.
    
    Next stage - probably Outputter and outputter backend for Defs.

 tools/TODO                          |   12 -
 tools/enum.pl                       |    2 +-
 tools/generate_wrap_init.pl.in      |   11 +-
 tools/gmmproc.in                    |  128 ++++++------
 tools/pm/Base/Backend.pm            |  219 ++++++++++++++++++++
 tools/pm/Base/Exceptions.pm         |   55 +++++
 tools/pm/Base/Function.pm           |    3 +-
 tools/pm/Common/Api.pm              |   15 +-
 tools/pm/{ => Common}/DocsParser.pm |   16 +-
 tools/pm/{ => Common}/Function.pm   |   11 +-
 tools/pm/{ => Common}/Output.pm     |   32 ++--
 tools/pm/{ => Common}/Util.pm       |   17 +-
 tools/pm/{ => Common}/WrapParser.pm |   80 +++-----
 tools/pm/Defs/Backend.pm            |  376 ++++++++++++++++++++++-------------
 tools/pm/Defs/Function.pm           |    6 -
 tools/pm/FunctionBase.pm            |    3 +-
 tools/pm/GtkDefs.pm                 |    4 +-
 tools/pm/Property.pm                |    6 +-
 tools/pm/TODO                       |   20 ++
 tools/pm/test.pl                    |    1 +
 20 files changed, 682 insertions(+), 335 deletions(-)
---
diff --git a/tools/enum.pl b/tools/enum.pl
index 11026bf..844b924 100755
--- a/tools/enum.pl
+++ b/tools/enum.pl
@@ -466,4 +466,4 @@ sub form_names($$)
     push(@names, $_);
   }
   return \ names;
-}  
+}
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 53c16d5..8b94d23 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -199,7 +199,7 @@ foreach $i (sort keys %objects)
   {
     print "#ifndef G_OS_WIN32\n"
   }
-  
+
   print "GType $basenames{$i}_get_type(void);\n";
 
   if( $win32_nowrap{$i} eq 1 )
@@ -240,7 +240,7 @@ foreach $i (sort keys %objects)
   {
     print "#ifndef G_OS_WIN32\n"
   }
-  
+
   my $namespace_declarations = "";
   my $namespace_close = "";
   foreach ( @{$namespaces{$i}} )
@@ -250,7 +250,7 @@ foreach $i (sort keys %objects)
   }
 
   print "${namespace_declarations} class ${i}_Class { public: static Glib::ObjectBase* wrap_new(GObject*); }; ${namespace_close}\n";
-  
+
   if( $win32_nowrap{$i} eq 1 )
   {
     print "#endif //G_OS_WIN32\n"
@@ -324,7 +324,7 @@ foreach $i (sort keys %objects)
   {
     print "#ifndef G_OS_WIN32\n"
   }
-  
+
   my $namespace_prefix = "";
   foreach( @{$namespaces{$i}} )
   {
@@ -360,7 +360,7 @@ foreach $i (sort keys %objects)
   {
     print "#ifndef G_OS_WIN32\n"
   }
-  
+
   my $namespace_prefix = "";
   foreach( @{$namespaces{$i}} )
   {
@@ -389,4 +389,3 @@ $namespace_whole_close
 EOF
 
 exit 0;
-
diff --git a/tools/gmmproc.in b/tools/gmmproc.in
index f024e17..8540d4f 100644
--- a/tools/gmmproc.in
+++ b/tools/gmmproc.in
@@ -46,9 +46,9 @@ use warnings;
 use IO::File;
 use Getopt::Long qw(:config permute);
 
-require Output;
-require WrapParser;
-require Base::Api;
+require Common::Output;
+require Common::WrapParser;
+require Common::Api;
 
 
 # prototypes
@@ -144,85 +144,87 @@ sub main ()
   }
   push (@{$includes_a_r}, $g_procdir . '/m4');
 
-  my $objOutputter = &Output::new($g_m4path, $includes_a_r);
-  my $objWrapParser = &WrapParser::new($objOutputter);
-
-  my $api = Base::Api->new ($file, $defs_a_r);
+  eval
+  {
+    my $api = Base::Api->new ($file, $defs_a_r);
+    my $outputter = $api->get_outputter ();
 
-  $objOutputter->set_backend ($api->get_outputter_backend ());
+    $outputter->set_paths ($g_m4path, $includes_a_r);
+    $outputter->set_destination_dir ($destination_dir);
 
-  $$objWrapParser{srcdir} = $source_dir;
-  $$objWrapParser{defsdir} = $defs_a_r->[0];
-  $$objOutputter{destdir} = $destination_dir;
+    my $wrap_parser = Common::WrapParser->new ($api);
 
-  for my $template (@{$templates_a_r})
-  {
-    print join ('', 'Processing ', $template, "...\n");
-    $$objWrapParser{source} = $template;
-    $$objOutputter{source} = $template;
+    $wrap_parser->set_source_dir ($source_dir);
 
-    # Merge the C docs, e.g. gtk_docs.xml
+    for my $template (@{$templates_a_r})
+    {
+      print join ('', 'Processing ', $template, "...\n");
+      $wrap_parser->set_source_base ($template);
+      $outputter->set_destination_base ($template);
 
-    # Suck the whole file into one big string, breaking it into tokens:
-    $objWrapParser->read_file($source_dir, $template);
+      # Suck the whole file into one big string, breaking it into tokens:
+      $wrap_parser->read_file($template);
 
-    # Parse output
-    $objWrapParser->parse_and_build_output();
+      # Parse output
+      $objWrapParser->parse_and_build_output();
 
-    # Write out *.g1 temporary file:
-    $objOutputter->output_temp_g1($$objWrapParser{module}); # e.g. "gtk"
+#      # Write out *.g1 temporary file:
+#      $objOutputter->output_temp_g1($$objWrapParser{module}); # e.g. "gtk"
 
-    # Execute m4 to get *.g2 file:
-    {
-      my $exitcode = $objOutputter->make_g2_from_g1();
+#      # Execute m4 to get *.g2 file:
+#      {
+#        my $exitcode = $objOutputter->make_g2_from_g1();
 
-      if ($exitcode)
-      {
-        $objOutputter->remove_temp_files() unless ($debug);
+#        if ($exitcode)
+#        {
+#          $objOutputter->remove_temp_files() unless ($debug);
 
-        print STDERR "m4 failed with exit code $exitcode.  Aborting...\n";
-        exit($exitcode);
-      }
-    }
+#          print STDERR "m4 failed with exit code $exitcode.  Aborting...\n";
+#          exit($exitcode);
+#        }
+#      }
 
-    # Section out the resulting output
-    $objOutputter->write_sections_to_files();
-    $objOutputter->remove_temp_files() unless ($debug);
+#      # Section out the resulting output
+#      $objOutputter->write_sections_to_files();
+      $outputter->remove_temp_files() unless ($debug);
 
-    #Warn about any unwrapped function/signals:
-    if ($unwrapped)
-    {
-      my @unwrapped = GtkDefs::get_unwrapped();
-      @unwrapped = grep { exists $$_{entity_type} } @unwrapped;
-
-      if (@unwrapped)
+      #Warn about any unwrapped function/signals:
+      #TODO: info about unwrapped information should be written to a logfile.
+      if ($unwrapped)
       {
-        my @methods = grep { $$_{entity_type} eq 'method' and $$_{c_name} !~ m/^_/s } @unwrapped;
-        my @signals = grep { $$_{entity_type} eq 'signal' } @unwrapped;
-        # Don't take non-readable construct-only properties into account.
-        my @properties = grep { $$_{entity_type} eq 'property' and ( $$_{readable} or not $$_{construct_only} ) } @unwrapped;
+        my @unwrapped = GtkDefs::get_unwrapped();
+        @unwrapped = grep { exists $$_{entity_type} } @unwrapped;
 
-        local $, = "\ngmmproc:   ";
-        local $\ = "\n";
-
-        if (@methods)
-        {
-          print STDERR ('gmmproc: Unwrapped functions:',
-                        map($$_{c_name}, @methods));
-        }
-        if (@properties)
-        {
-          print STDERR ('gmmproc: Unwrapped properties:',
-                        map($$_{class} . '::' . $$_{name}, @properties));
-        }
-        if (@signals)
+        if (@unwrapped)
         {
-          print STDERR ('gmmproc: Unwrapped signals:',
-                        map($$_{class} . '::' . $$_{name}, @signals));
+          my @methods = grep { $$_{entity_type} eq 'method' and $$_{c_name} !~ m/^_/s } @unwrapped;
+          my @signals = grep { $$_{entity_type} eq 'signal' } @unwrapped;
+          # Don't take non-readable construct-only properties into account.
+          my @properties = grep { $$_{entity_type} eq 'property' and ( $$_{readable} or not $$_{construct_only} ) } @unwrapped;
+
+          local $, = "\ngmmproc:   ";
+          local $\ = "\n";
+
+          if (@methods)
+          {
+            print STDERR ('gmmproc: Unwrapped functions:',
+                          map($$_{c_name}, @methods));
+          }
+          if (@properties)
+          {
+            print STDERR ('gmmproc: Unwrapped properties:',
+                          map($$_{class} . '::' . $$_{name}, @properties));
+          }
+          if (@signals)
+          {
+            print STDERR ('gmmproc: Unwrapped signals:',
+                          map($$_{class} . '::' . $$_{name}, @signals));
+          }
         }
       }
     }
   }
+  #TODO: catch the exception.
 
   exit 0;
 }
diff --git a/tools/pm/Base/Backend.pm b/tools/pm/Base/Backend.pm
new file mode 100644
index 0000000..c4ff260
--- /dev/null
+++ b/tools/pm/Base/Backend.pm
@@ -0,0 +1,219 @@
+# gmmproc - Base::Backend module
+#
+# Copyright 2011 glibmm development team
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+#
+
+package Base::Backend;
+
+use strict;
+use warnings;
+use Base::Exceptions;
+
+# class Base::Backend
+# {
+#   function array get_methods ();
+#   property array get_properties ();
+#   function array get_signals ();
+#
+#   enum lookup_enum(c_type)
+#   object lookup_object(c_name)
+#   function lookup_method(c_name)
+#   function lookup_function(c_name)
+#   property lookup_property(object, c_name)
+#   function lookup_signal(object, c_name)
+# }
+
+# public
+sub new ($$)
+{
+  my $type = shift;
+  my $class = (ref ($type) or $type or "Base::Backend");
+  my $self = {};
+
+  bless ($self, $class);
+  return $self;
+}
+
+sub read_file ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'read_file ($$) is not implemented.'));
+}
+
+sub get_enums ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_enums ($$) is not implemented.'));
+}
+
+sub get_methods ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_methods ($$) is not implemented.'));
+}
+
+sub get_signals ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_signals ($$) is not implemented.'));
+}
+
+sub get_properties ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_properties ($$) is not implemented.'));
+}
+
+sub get_objects ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_objects ($$) is not implemented.'));
+}
+
+sub get_functions ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_functions ($$) is not implemented.'));
+}
+
+sub get_unwrapped_methods ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_methods ($$) is not implemented.'));
+}
+
+sub get_unwrapped_signals ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_signals ($$) is not implemented.'));
+}
+
+sub get_unwrapped_properties ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_properties ($$) is not implemented.'));
+}
+
+sub get_unwrapped_objects ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_objects ($$) is not implemented.'));
+}
+
+sub get_unwrapped_enums ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_enums ($$) is not implemented.'));
+}
+
+sub get_unwrapped_functions ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_functions ($$) is not implemented.'));
+}
+
+sub get_unwrapped_vfuncs ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'get_unwrapped_vfuncs ($$) is not implemented.'));
+}
+
+sub lookup_enum ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'lookup_enum ($$) is not implemented.'));
+}
+
+sub lookup_object ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'lookup_object ($$) is not implemented.'));
+}
+
+sub lookup_property ($$$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'lookup_property ($$) is not implemented.'));
+}
+
+sub lookup_method ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'lookup_method ($$) is not implemented.'));
+}
+
+sub lookup_function ($$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'lookup_function ($$) is not implemented.'));
+}
+
+sub lookup_signal ($$$)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'lookup_signal ($$) is not implemented.'));
+}
+
+sub create_outputter_backend ($)
+{
+  my $self = shift;
+  my $class = ref ($self);
+
+  $Base::Exceptions::not_implemented->throw (error => join ('::', $class, 'create_outputter_backend ($$) is not implemented.'));
+}
+
+1; #indicate proper module load.
diff --git a/tools/pm/Base/Exceptions.pm b/tools/pm/Base/Exceptions.pm
new file mode 100644
index 0000000..959af0c
--- /dev/null
+++ b/tools/pm/Base/Exceptions.pm
@@ -0,0 +1,55 @@
+# gmmproc - Base::Exceptions module
+#
+# Copyright 2011 glibmm development team
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+#
+
+package Base::Exceptions;
+
+use strict;
+use warnings;
+
+our $base = 'BaseException';
+our $not_implemented = 'NotImplementedException';
+our $i_o = 'IOException';
+our $parse = 'ParseException';
+
+my $g_i = 'isa';
+my $g_d = 'description';
+
+my $g_s = 'These exceptions are related to ';
+
+use Exception::Class
+(
+  $base,
+  $not_implemented =>
+  {
+    $g_i => $base,
+    $g_d => join ('', $g_s, 'NIH.')
+  },
+  $i_o =>
+  {
+    $g_i => $base,
+    $g_d => join ('', $g_s, 'IO.')
+  }
+  $parse =>
+  {
+    $g_i => $base,
+    $g_d => join ('', $g_s, 'parsing.')
+  }
+);
+
+1; #indicate proper module load.
diff --git a/tools/pm/Base/Function.pm b/tools/pm/Base/Function.pm
index 1671649..d1c2777 100644
--- a/tools/pm/Base/Function.pm
+++ b/tools/pm/Base/Function.pm
@@ -22,7 +22,6 @@ package Base::Function;
 use strict;
 use warnings;
 use parent qw (Base::Entity);
-use Util;
 
 ##################################################
 ### Function
@@ -281,7 +280,7 @@ sub args_types_and_names_with_default_values($)
   my $param_types = $$self{param_types};
   my $param_default_values = $$self{param_default_values};
   my @out;
-  
+
   for ($i = 0; $i < $#$param_types + 1; $i++)
   {
     my $str = sprintf("%s %s", $$param_types[$i], $$param_names[$i]);
diff --git a/tools/pm/Common/Api.pm b/tools/pm/Common/Api.pm
index 6114b0e..d872679 100644
--- a/tools/pm/Common/Api.pm
+++ b/tools/pm/Common/Api.pm
@@ -52,7 +52,7 @@ sub deduce_backend_from_file ($)
   return undef;
 }
 
-#my $g_o = 'outputter';
+my $g_o = 'outputter';
 my $g_b = 'backend';
 
 sub new ($$$)
@@ -60,7 +60,6 @@ sub new ($$$)
   my $type = shift;
   my $file = shift;
   my $defs_a_r = shift;
-#  my $outputter = shift;
   my $class = (ref ($type) or $type or "Common::Api");
   my $backend = undef;
   my $main_backend_module = deduce_backend_from_file ($file);
@@ -70,12 +69,11 @@ sub new ($$$)
     #TODO: implement Gir backend and remove the condition below.
     if ($main_backend_module eq 'Gir')
     {
-      print STDERR join ('', 'Gir backend for file ', $file, "is not yet implemented\n");
+      print STDERR join ('', 'Gir backend for file ', $file, " is not yet implemented\n");
     }
     #TODO: error!
     exit 1;
   }
-#  $outputter->set_backend ($backend->get_outputter_backend ());
 
   unless ($backend->read_file ($file))
   {
@@ -83,19 +81,22 @@ sub new ($$$)
     exit 1;
   }
 
+  my $outputter = Common::Outputter->new ($backend->get_outputter_backend ());
   my $self =
   {
-    $g_b => $backend
-#    $g_o => $outputter
+    $g_b => $backend,
+    $g_o => $outputter
   };
 
   bless ($self, $class);
   return $self;
 }
 
-sub read_file ($$)
+sub get_outputter ($)
 {
   my $self = shift;
+
+  return $self->{$g_o};
 }
 
 sub get_enums ($)
diff --git a/tools/pm/DocsParser.pm b/tools/pm/Common/DocsParser.pm
similarity index 99%
rename from tools/pm/DocsParser.pm
rename to tools/pm/Common/DocsParser.pm
index 02caa44..db2f03a 100644
--- a/tools/pm/DocsParser.pm
+++ b/tools/pm/Common/DocsParser.pm
@@ -70,10 +70,10 @@ $DocsParser::commentEnd = "   */";
 sub read_defs($$$)
 {
   my ($path, $filename, $filename_override) = @_;
-  
+
   my $objParser = new XML::Parser(ErrorContext => 0);
   $objParser->setHandlers(Start => \&parse_on_start, End => \&parse_on_end, Char => \&parse_on_cdata);
-  
+
   # C documentation:
   $DocsParser::CurrentFile = "$path/$filename";
   if ( ! -r $DocsParser::CurrentFile)
@@ -118,7 +118,7 @@ sub parse_on_start($$%)
     {
       $objParser->xpcroak("\nClose a function tag before you open another one.");
     }
-    
+
     my $functionName = $attr{name};
 
     #Reuse existing Function, if it exists:
@@ -293,7 +293,7 @@ sub append_parameter_docs($$)
     if ($param ne "error" ) #We wrap GErrors as exceptions, so ignore these.
     {
       my $desc = $$param_descriptions->{$param};
-    
+
       $param =~ s/([a-zA-Z0-9]*(_[a-zA-Z0-9]+)*)_?/$1/g;
       DocsParser::convert_docs_to_cpp($obj_function, \$desc);
       if(length($desc) > 0)
@@ -436,7 +436,7 @@ sub substitute_function($$)
     }
     else
     {
-      print "Documentation: Transformed C name $name into ";  
+      print "Documentation: Transformed C name $name into ";
       non_object_method_name($doc_func, \$name);
       print "C++ name $name\n";
     }
@@ -477,9 +477,9 @@ sub non_object_method_name($$)
       }
     }
   }
-  
+
   print STDERR "Documentation: Class/Namespace for $$name not found\n";
-}   
+}
 
 sub lookup_object_of_method($$)
 {
@@ -517,7 +517,7 @@ sub lookup_object_of_method($$)
 
     pop(@parts);
   }
-  
+
   return undef;
 }
 
diff --git a/tools/pm/Function.pm b/tools/pm/Common/Function.pm
similarity index 99%
rename from tools/pm/Function.pm
rename to tools/pm/Common/Function.pm
index 98d4cdb..fec174c 100644
--- a/tools/pm/Function.pm
+++ b/tools/pm/Common/Function.pm
@@ -1,9 +1,9 @@
-package Function;
+package Common::Function;
 
 use strict;
 use warnings;
-use Util;
-use base qw (FunctionBase);
+use Common::Util;
+use parent qw (Base::Function);
 
 my $gi_p_t = 'internal_param_types';
 my $gi_p_n = 'internal_param_names';
@@ -40,7 +40,7 @@ sub parse_params($$)
   for my $part (split(/(const )|([,=&*()])|(<[^,]*>)|(\s+)/, $line)) #special characters OR <something> OR whitespace.
   {
     next if (not defined ($part) or not $part);
-      
+
     if ($part eq '(') #Detect the opening bracket.
     {
        push (@str, $part);
@@ -87,7 +87,7 @@ sub parse_params($$)
       push (@{$param_types}, $type);
       push (@{$param_names}, $name);
       push (@{$param_default_values}, $value);
-      
+
       #Clear variables, ready for the next parameter.
       @str = ();
       $type= '';
@@ -383,4 +383,3 @@ sub get_is_const($)
 }
 
 1; # indicate proper module load.
-
diff --git a/tools/pm/Output.pm b/tools/pm/Common/Output.pm
similarity index 99%
rename from tools/pm/Output.pm
rename to tools/pm/Common/Output.pm
index 389f885..0fe04e6 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Common/Output.pm
@@ -80,23 +80,23 @@ sub error
 
 sub ifdef($$)
 {
-	my ($self, $ifdef) = @_;
-	if ($ifdef)
-	{
-		$self->append("\n#ifdef $ifdef\n");
-	}
+  my ($self, $ifdef) = @_;
+  if ($ifdef)
+  {
+    $self->append("\n#ifdef $ifdef\n");
+  }
 }
 
 sub endif($$)
 {
-	my ($self, $ifdef) = @_;
-	if ($ifdef)
-	{
-		$self->append("\n#endif // $ifdef\n");
-	}
+  my ($self, $ifdef) = @_;
+  if ($ifdef)
+  {
+    $self->append("\n#endif // $ifdef\n");
+  }
 }
 
-### Convert _WRAP to a virtual 
+### Convert _WRAP to a virtual
 # _VFUNC_H(signame,rettype,`<cppargs>')
 # _VFUNC_PH(gtkname,crettype,cargs and names)
 # void output_wrap_vfunc_h($filename, $line_num, $objCppfunc, $objCDefsFunc)
@@ -223,7 +223,7 @@ sub output_wrap_default_signal_handler_cc($$$$$$$$$)
   {
     my $refreturn = "";
     $refreturn = "refreturn" if($bRefreturn eq 1);
-  
+
     my $str = sprintf("_SIGNAL_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n",
       $$objCppfunc{name},
       $cname,
@@ -292,10 +292,10 @@ sub output_wrap_meth($$$$$$$)
   $self->ifdef($ifdef);
 
   $self->append("  ${cppMethodDecl};");
-  
+
   $self->endif($ifdef);
 
-  
+
   if($deprecated ne "")
   {
     $self->append("\n_DEPRECATE_IFDEF_END\n");
@@ -930,8 +930,8 @@ sub output_implements_interface($$)
   my ($self, $interface, $ifdef) = @_;
 
   my $str = sprintf("_IMPLEMENTS_INTERFACE_CC(%s, %s)dnl\n",
-  	$interface,
-  	$ifdef);
+    $interface,
+    $ifdef);
 
   $self->append($str);
 }
diff --git a/tools/pm/Util.pm b/tools/pm/Common/Util.pm
similarity index 90%
rename from tools/pm/Util.pm
rename to tools/pm/Common/Util.pm
index aa74e4e..bb03e40 100644
--- a/tools/pm/Util.pm
+++ b/tools/pm/Common/Util.pm
@@ -4,13 +4,13 @@
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or 
+# the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
-# GNU General Public License for more details. 
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
@@ -18,7 +18,7 @@
 #
 #
 # This file holds basic functions used throughout gtkmmproc modules.
-# Functions in this module are exported so there is no need to 
+# Functions in this module are exported so there is no need to
 # request them by module name.
 #
 package Util;
@@ -32,13 +32,13 @@ use warnings;
 sub string_unquote($)
 {
     my ($str) = @_;
-    
+
     $str =~ s/^['`"]// ;
     $str =~ s/['`"]$// ;
- 
+
     return $str;
 }
-         
+
 # $ string_trim($string)
 # Removes leading and trailing white space.
 sub string_trim ($)
@@ -74,7 +74,7 @@ sub string_canonical($)
 
 # TODO: is this function used anywhere?
 #
-#  Back tracing utility.  
+#  Back tracing utility.
 #    Prints the call stack.
 #
 #  void trace()
@@ -108,4 +108,3 @@ sub unique(@)
 }
 
 1; # indicate proper module load.
-
diff --git a/tools/pm/WrapParser.pm b/tools/pm/Common/WrapParser.pm
similarity index 95%
rename from tools/pm/WrapParser.pm
rename to tools/pm/Common/WrapParser.pm
index f7b4226..4f7c010 100644
--- a/tools/pm/WrapParser.pm
+++ b/tools/pm/Common/WrapParser.pm
@@ -1,6 +1,6 @@
-# gtkmm - WrapParser module
+# gmmproc - Common::WrapParser module
 #
-# Copyright 2001 Free Software Foundation
+# Copyright 2011 glibmm development team
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,50 +16,31 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 #
-package WrapParser;
+
+package Common::WrapParser;
+
 use strict;
 use warnings;
-use Util;
-use GtkDefs;
-use Function;
-use DocsParser;
-
-BEGIN {
-     use Exporter   ();
-     our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
-
-     # set the version for version checking
-     $VERSION     = 1.00;
-     @ISA         = qw(Exporter);
-     @EXPORT      = ( );
-     %EXPORT_TAGS = ( );
-     # your exported package globals go here,
-     # as well as any optionally exported functions
-     @EXPORT_OK   = ( );
-     }
-our @EXPORT_OK;
+use Common::Util;
+use Common::Function;
+use Common::DocsParser;
 
 ############################################################################
 
-#TODO: write a function in main guessing backend main module based on given definitions filename - gtk.defs will give Defs, gtk.gir will give Gir
-#TODO: on construction of Base::Api a module name should be passed. it will be used to create a backend for it.
-#TODO: require $guessed_main_module::Backend;
-#TODO: on construction take Base::Api as parameter.
-#TODO: Base::Api will give an outputter to use.
-#TODO: Outputter should be split into two classes - common part and backend part.
-#TODO: When setting backend for Base::Api it should also get backend for outputter.
-#TODO: Backend should have methods like used in Base::API and a method returning an outputter backend.
-
-
 my @tokens = ();
 
-# $objWrapParser new($objOutputter)
-sub new($)
-{
-  my ($objOutputter) = @_;
+my $g_a = 'api';
+my $g_
 
-  my $self = {};
-  bless $self;
+sub new($$)
+{
+  my $type = shift;
+  my $api = shift;
+  my $class = (ref ($type) or $type or 'Common::WrapParser');
+  my $self =
+  {
+    $g_m => $api
+  }
 
    #Initialize member data:
   $$self{objOutputter} = $objOutputter;
@@ -82,6 +63,7 @@ sub new($)
 
   $$self{already_read} = {};
 
+  bless ($self, $class);
   return $self;
 }
 
@@ -352,18 +334,18 @@ sub on_comment_doxygen($)
       while ($next_token !~ /\S/)
       {
         push(@whitespace, $self->extract_token());
-	$next_token = $self->peek_token();
+        $next_token = $self->peek_token();
       }
 
       # If the next token is a signal, do not close this comment, to merge
       # this doxygen comment with the one from the signal.
       if($next_token eq '_WRAP_SIGNAL')
       {
-	# Extract token and process
-	$self->extract_token();
-	# Tell wrap_signal to merge automatically generated comment with
-	# already existing comment. This is why we do not close the comment
-	# here.
+        # Extract token and process
+        $self->extract_token();
+        # Tell wrap_signal to merge automatically generated comment with
+        # already existing comment. This is why we do not close the comment
+        # here.
         $self->on_wrap_signal(1);
       }
       else
@@ -942,7 +924,7 @@ sub on_wrap_method($)
     }
     elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
     {
-    	$ifdef = $1;
+      $ifdef = $1;
     }
   }
 
@@ -1103,7 +1085,7 @@ sub on_implements_interface($$)
     }
   }
   my $objOutputter = $$self{objOutputter};
-  $objOutputter->output_implements_interface($interface, $ifdef);	
+  $objOutputter->output_implements_interface($interface, $ifdef);
 }
 
 sub on_wrap_create($)
@@ -1168,9 +1150,9 @@ sub on_wrap_signal($$)
       $bRefreturn = 1;
     }
 
-  	elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
+    elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
     {
-    	$ifdef = $1;
+      $ifdef = $1;
     }
   }
 
@@ -1212,7 +1194,7 @@ sub on_wrap_vfunc($)
       { $refreturn_ctype = 1; }
   elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start.
     {
-    	$ifdef = $1;
+      $ifdef = $1;
     }
   }
 
diff --git a/tools/pm/Defs/Backend.pm b/tools/pm/Defs/Backend.pm
index da9b147..da8998d 100644
--- a/tools/pm/Defs/Backend.pm
+++ b/tools/pm/Defs/Backend.pm
@@ -22,7 +22,10 @@ package Defs::Backend;
 use strict;
 use warnings;
 
-# class Defs::Backend
+use parent qw(Base::Backend);
+use Base::Exceptions;
+
+# class Defs::Backend : public Base::Backend
 # {
 #   function array get_methods ();
 #   property array get_properties ();
@@ -66,11 +69,12 @@ sub split_tokens ($)
   for (my $index = 0; $index < $len; ++$index)
   {
     my $char = substr ($token_string, $index, 1);
-    # if we are inside double quotes.
+
     if ($char eq "\n")
     {
       ++$line_number;
     }
+    # if we are inside double quotes.
     elsif ($inside_dquotes)
     {
       # if prevous char was backslash, then current char is not important -
@@ -129,24 +133,31 @@ sub split_tokens ($)
         $begin_token = $index;
         $token_line_number = $line_number;
       }
-      $parens++;
+      ++$parens;
     }
     # closing paren - if paren count is 1 then this is an end of a token, so we
     # extract it from token string and push into token list.
     elsif ($char eq ')')
     {
-      $parens--;
+      --$parens;
       unless ($parens)
       {
         my $token_len = $index + 1 - $begin_token;
         my $token = substr ($token_string, $begin_token, $token_len);
 
-        $token =~ s/\s+/ /g;
-        push (@{$tokens_a_r}, { $gi_l_n => $token_line_number, $gi_t => $token });
+        push (@{$tokens_a_r}, {$gi_l_n => $token_line_number, $gi_t => Common::Util::string_simplify ($token)});
+      }
+      elsif ($parens < 0)
+      {
+        $Base::Exceptions::g_p->throw (error => join ('', 'Unmatched closing paren at line ', $line_number, '.'));
       }
     }
     # do nothing on other chars.
   }
+  if ($parens)
+  {
+    $Base::Exceptions::g_p->throw (error => join ('', 'Unmatched opening paren.'));
+  }
   return $tokens_a_r;
 }
 
@@ -178,23 +189,155 @@ my $g_o = 'objects';
 my $g_m = 'methods';
 my $g_s = 'signals';
 my $g_p = 'properties';
+my $g_f = 'functions';
 my $g_a_r_f = 'already_read_files';
+my $g_h = 'handlers';
+my $g_v = 'vfuncs';
+
+#callbacks
+sub on_include ($$)
+{
+  my $self = shift;
+  my $token = shift;
+
+  if ($token =~ /\(include (\S+)\)/)
+  {
+    unless ($self->read_file ($1))
+    {
+      #TODO: die?
+      return 0;
+    }
+  }
+}
+
+sub on_nothing ($$)
+{
+  #does nothing of course.
+}
+
+sub on_enum ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Enum->new ();
+
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_e}{$thing->get_c_name ()} = $thing;
+}
+
+sub on_object ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Object->new ();
+
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_o}{$thing->get_c_name ()} = $thing;
+}
+
+sub on_function ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Function->new ();
+
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_f}{$thing->get_c_name ()} = $thing;
+}
+
+sub on_method ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Function->new ();
+
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_m}{$thing->get_c_name ()} = $thing if ($thing);
+}
+
+sub on_property ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Property->new ();
 
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_p}{join ('::', $thing->get_class (), $thing->get_name ())} = $thing;
+}
+
+sub on_signal ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Signal->new ();
+
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_s}{join ('::', $thing->get_class (), $thing->get_name ())} = $thing;
+}
+
+sub on_vfunc ($$)
+{
+  my $self = shift;
+  my $token = shift;
+  my $thing = Defs::Signal->new ();
+
+  unless (defined ($thing) and $thing->parse ($token))
+  {
+    #TODO: die?
+  }
+  $self->{$g_v}{join ('::', $thing->get_class (), $thing->get_name ())} = $thing;
+}
+
+# public
 sub new ($$)
 {
   my $type = shift;
   my $include_paths_a_r = shift;
   my $class = (ref ($type) or $type or "Defs::Backend");
-  my $self =
+  my $handlers =
   {
-    $g_i_p => $include_paths_a_r,
-    $g_e => {},
-    $g_o => {},
-    $g_m => {},
-    $g_s => {},
-    $g_p => {},
-    $g_a_r_f => {}
+    'include' => \&on_include,
+    'define-flags-extended' => \&on_enum,
+    'define-enum-extended' => \&on_enum,
+    'define-flags' => \&on_nothing,
+    'define-enum' => \&on_nothing,
+    'define-object' => \&on_object,
+    'define-function' => \&on_function,
+    'define-method' => \&on_method,
+    'define-property' => \&on_property,
+    'define-signal' => \&on_signal,
+    'define-vfunc' => \&on_vfunc
   };
+  my $self = $class->SUPER->new ();
+
+  $self->{$g_i_p} = $include_paths_a_r;
+  $self->{$g_e} = {};
+  $self->{$g_o} = {};
+  $self->{$g_m} = {};
+  $self->{$g_s} = {};
+  $self->{$g_p} = {};
+  $self->{$g_f} = {};
+  $self->{$g_a_r_f} = {};
+  $self->{$g_h} = $handlers;
+  $self->{$g_v} = {};
 
   bless ($self, $class);
   return $self;
@@ -218,13 +361,12 @@ sub read_file ($$)
   }
   unless ($real_path)
   {
-    print STDERR join (' ', 'Could not find file', $file, 'in paths:', join (':', @{$self->{$g_i_p}}), "\n");
-    return 0;
+    $Base::Exceptions::$i_o->throw (join (' ', 'Could not find file', $file, 'in paths:', join (':', @{$self->{$g_i_p}})));
   }
 
   if (exists ($self->{$g_a_r_f}{$real_path}))
   {
-    return 1;
+    return;
   }
   ${self}->{$g_a_r_f}{$real_path} = 1;
 
@@ -237,48 +379,35 @@ sub read_file ($$)
 
     next if ($token =~ /^\s*$/);
 
-    if ($token =~ /\(include (\S+)\)/)
+    if ($token =~ /^\((\S+).*\)$/)
     {
-      unless ($self->read_file ($1))
+      my $type = $1;
+
+      if (exists ($self->{$g_h}{$type}))
+      {
+        my $method = $self->{$g_h}{$type};
+
+        $self->$method ($token);
+      }
+      else
       {
-        return 0;
+        my $line_number = $token_description->{$gi_l_n};
+
+        if ($token =~ /^\(define-(\S+) (\S+)/)
+        {
+          $Base::Exceptions::$parse->throw (join (' ', 'Unknown lisp definition for', $1, $2, 'at line:', $line_number));
+        }
+        else
+        {
+          $Base::Exceptions::$parse->throw (join (' ', 'Unknown token at line: ', $line_number, '-', $token));
+        }
       }
-      next;
     }
-    elsif ($token =~ /^\(define-flags-extended.*\)$/)
-    { $self->on_enum ($token); }
-    elsif ($token =~ /^\(define-enum-extended.*\)$/)
-    { $self->on_enum ($token); }
-    elsif ($token =~ /^\(define-flags.*\)$/)
-    { }
-    elsif ($token =~ /^\(define-enum.*\)$/)
-    { }
-    elsif ($token =~ /^\(define-object.*\)$/)
-    { $self->on_object ($token); }
-    elsif ($token =~ /^\(define-function.*\)$/)
-    { $self->on_function ($token); }
-    elsif ($token =~ /^\(define-method.*\)$/)
-    { $self->on_method ($token); }
-    elsif ($token =~ /^\(define-property.*\)$/)
-    { $self->on_property ($token); }
-    elsif ($token =~ /^\(define-signal.*\)$/)
-    { $self->on_signal ($token);  }
-    elsif ($token =~ /^\(define-vfunc.*\)$/)
-    { $self->on_vfunc ($token); }
     else
     {
       my $line_number = $token_description->{$gi_l_n};
 
-      if ($token =~ /^\(define-(\S+) (\S+)/)
-      {
-        print STDERR join (' ', 'Unknown lisp definition for', $1, $2, 'at line:', $line_number, "\n");
-        return 0;
-      }
-      else
-      {
-        print STDERR join ('', 'Unknown token at line: ', $line_number, "\n", $token, "\n");
-        return 0;
-      }
+      $Base::Exceptions::$parse->throw (join (' ', 'Badly formed token at line: ', $line_number, '-', $token));
     }
   }
 
@@ -289,91 +418,95 @@ sub get_enums ($)
 {
   my $self = shift;
 
-  return [];
+  return sort {$a->get_c_name () cmp $b->get_c_name ()} values %{$self->{$g_e}};
 }
 
 sub get_methods ($)
 {
   my $self = shift;
 
-  return [];
+  return sort {$a->get_c_name () cmp $b->get_c_name ()} values %{$self->{$g_m}};
 }
 
 sub get_signals ($)
 {
   my $self = shift;
 
-  return [];
+  return sort {$a->get_name () cmp $b->get_name ()} values %{$self->{$g_s}};
 }
 
 sub get_properties ($)
 {
   my $self = shift;
 
-  return [];
+  return sort {$a->get_name () cmp $b->get_name ()} values %{$self->{$g_p}};
 }
 
 sub get_objects ($)
 {
   my $self = shift;
 
-  return [];
+  return sort {$a->get_c_name () cmp $b->get_c_name ()} values %{$self->{$g_o}};
 }
 
 sub get_functions ($)
 {
   my $self = shift;
 
-  return [];
+  return sort {$a->get_c_name () cmp $b->get_c_name ()} values %{$self->{$g_f}};
 }
 
-sub get_marked ($)
+sub get_unwrapped_methods ($$)
 {
   my $self = shift;
+  my $object = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0 and $$_->get_class () == $object->get_c_name ()} values (%{$self->{$g_m}});
 }
 
-sub get_unwrapped_methods ($)
+sub get_unwrapped_signals ($$)
 {
   my $self = shift;
+  my $object = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0 and $$_->get_class () == $object->get_c_name ()} values (%{$self->{$g_s}});
 }
 
-sub get_unwrapped_signals ($)
+sub get_unwrapped_properties ($$)
 {
   my $self = shift;
+  my $object = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0 and $$_->get_class () == $object->get_c_name ()} values (%{$self->{$g_p}});
 }
 
-sub get_unwrapped_properties ($)
+sub get_unwrapped_objects ($)
 {
   my $self = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0} values (%{$self->{$g_o}});
 }
 
-sub get_unwrapped_objects ($)
+sub get_unwrapped_enums ($)
 {
   my $self = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0} values (%{$self->{$g_e}});
 }
 
-sub get_unwrapped_enums ($)
+sub get_unwrapped_functions ($)
 {
   my $self = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0} values (%{$self->{$g_f}});
 }
 
-sub get_unwrapped_functions ($)
+sub get_unwrapped_vfuncs ($$)
 {
   my $self = shift;
+  my $object = shift;
 
-  return [];
+  return grep {$$_->is_marked () == 0 and $$_->get_class () == $object->get_c_name ()} values (%{$self->{$g_v}});
 }
 
 sub lookup_enum ($$)
@@ -381,6 +514,10 @@ sub lookup_enum ($$)
   my $self = shift;
   my $c_name = shift;
 
+  if (exists ($self->{$g_e}{$c_name}))
+  {
+    return $self->{$g_e}{$c_name};
+  }
   return undef;
 }
 
@@ -389,6 +526,10 @@ sub lookup_object ($$)
   my $self = shift;
   my $c_name = shift;
 
+  if (exists ($self->{$g_o}{$c_name}))
+  {
+    return $self->{$g_o}{$c_name};
+  }
   return undef;
 }
 
@@ -397,7 +538,12 @@ sub lookup_property ($$$)
   my $self = shift;
   my $object = shift;
   my $name = shift;
+  my $prop_name = join ('::', $object, $name);
 
+  if (exists ($self->{$g_p}{$prop_name}))
+  {
+    return $self->{$g_p}{$prop_name};
+  }
   return undef;
 }
 
@@ -406,6 +552,10 @@ sub lookup_method ($$)
   my $self = shift;
   my $c_name = shift;
 
+  if (exists ($self->{$g_m}{$c_name}))
+  {
+    return $self->{$g_m}{$c_name};
+  }
   return undef;
 }
 
@@ -414,7 +564,7 @@ sub lookup_function ($$)
   my $self = shift;
   my $c_name = shift;
 
-  return undef;
+  return $self->lookup_method ($c_name);
 }
 
 sub lookup_signal ($$$)
@@ -422,81 +572,21 @@ sub lookup_signal ($$$)
   my $self = shift;
   my $object = shift;
   my $name = shift;
+  my $signal_name = join ('::', $object, $name);
 
+  if (exists ($self->{$g_s}{$signal_name}))
+  {
+    return $self->{$g_s}{$signal_name};
+  }
   return undef;
 }
 
-sub get_outputter_backend ($)
-{
-  my $self = shift;
-
-  return undef;
-}
-
-
-
-
-sub on_enum ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Enum->new ($token);
-
-  $self->{$g_e}{$thing->get_c_name ()} = $thing;
-}
-
-sub on_object ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Object->new ($token);
-
-  $self->{$g_o}{$thing->get_c_name ()} = $thing;
-}
-
-sub on_function ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Function->new ($token);
-
-  $self->{$g_m}{$thing->get_c_name ()} = $thing;
-}
-
-sub on_method ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Function->new ($token);
-
-  $self->{$g_m}{$thing->get_c_name ()} = $thing if ($thing);
-}
+#TODO: implement it when Defs::OutputterBacked is done. For now the base class method will be called.
+#sub create_outputter_backend ($)
+#{
+#  my $self = shift;
 
-sub on_property ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Property->new ($token);
-
-  $self->{$g_p}{join ('::', $thing->get_class (), $thing->get_name ())} = $thing;
-}
-
-sub on_signal ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Signal->new ($token);
-
-  $self->{$g_s}{join ('::', $thing->get_class (), $thing->get_name ())} = $thing;
-}
-
-sub on_vfunc ($$)
-{
-  my $self = shift;
-  my $token = shift;
-  my $thing = Defs::Signal->new ($token);
-
-  $self->{$g_s}{join ('::', $thing->get_class (), $thing->get_name ())} = $thing;
-}
+#  return undef;
+#}
 
 1; #indicate proper module load.
diff --git a/tools/pm/Defs/Function.pm b/tools/pm/Defs/Function.pm
index c2a2f8a..a3836c7 100644
--- a/tools/pm/Defs/Function.pm
+++ b/tools/pm/Defs/Function.pm
@@ -130,12 +130,6 @@ sub parse ($$)
     #Ignore them.
   }
 
-  # of-object
-  if ($def =~ s/\(of-object "(\S+)"\)//)
-  {
-    #Ignore them.
-  }
-
   if ($def !~ /^\s*$/)
   {
     #GtkDefs::error("Unhandled function parameter ($def) in $$self{c_name}\n");
diff --git a/tools/pm/FunctionBase.pm b/tools/pm/FunctionBase.pm
index bd7c353..bca5473 100644
--- a/tools/pm/FunctionBase.pm
+++ b/tools/pm/FunctionBase.pm
@@ -274,7 +274,7 @@ sub args_types_and_names_with_default_values($)
   my $param_types = $$self{param_types};
   my $param_default_values = $$self{param_default_values};
   my @out;
-  
+
   for ($i = 0; $i < $#$param_types + 1; $i++)
   {
     my $str = sprintf("%s %s", $$param_types[$i], $$param_names[$i]);
@@ -294,4 +294,3 @@ sub args_types_and_names_with_default_values($)
 }
 
 1; # indicate proper module load.
-
diff --git a/tools/pm/GtkDefs.pm b/tools/pm/GtkDefs.pm
index 9fbcf27..17f9629 100644
--- a/tools/pm/GtkDefs.pm
+++ b/tools/pm/GtkDefs.pm
@@ -216,7 +216,7 @@ sub read_defs ($$)
 {
   my ($self, $file) = @_;
   my $real_path = '';
-  
+
   for my $path (@{$self->{$g_i_p}})
   {
     my $temp_path = join ('/', $path, $file);
@@ -751,7 +751,7 @@ sub new
 
   if ($def!~/^\s*$/)
   {
-	  GtkDefs::error("Unhandled signal/vfunc def ($def) in $$self{class}::$$self{name}");
+    GtkDefs::error("Unhandled signal/vfunc def ($def) in $$self{class}::$$self{name}");
   }
 
   return $self;
diff --git a/tools/pm/Property.pm b/tools/pm/Property.pm
index 80f21bb..a0e9759 100644
--- a/tools/pm/Property.pm
+++ b/tools/pm/Property.pm
@@ -47,7 +47,7 @@ sub new
   $$self{writable} = ($1 eq "#t")       if ($def =~ s/\(writable (\S+)\)//);
   $$self{construct_only} = ($1 eq "#t") if ($def =~ s/\(construct-only (\S+)\)//);
   $$self{entity_type} = 'property';
-  
+
   # Property documentation:
   my $propertydocs = $1                     if ($def =~ s/\(docs "([^"]*)"\)//);
   # Add a full-stop if there is not one already:
@@ -62,9 +62,9 @@ sub new
       }
     }
   }
-  
+
   $$self{docs} = $propertydocs;
-  
+
 
   $$self{name} =~ s/-/_/g; # change - to _
 
diff --git a/tools/pm/TODO b/tools/pm/TODO
new file mode 100644
index 0000000..903893f
--- /dev/null
+++ b/tools/pm/TODO
@@ -0,0 +1,20 @@
+- On construction of WrapParser take Common::Api as parameter.
+
+- Common::Api will give an outputter to use.
+
+- Outputter should be split into two classes - common part and backend part.
+
+- Backend should have methods like used in Common::Api and a method returning an outputter backend.
+
+- Add exceptions, so instead of using print STDERR "message\n"; exit 1; everywhere die() could be used.
+  See Exception::Class module.
+
+- Design an outputter backend interface.
+
+- Implement outputter backend for Defs.
+
+Some more details should come here.
+
+LATER:
+
+- Get rid of m4 stuff by implementing a "core" set of sort of plugins or something - have to think about it.
diff --git a/tools/pm/test.pl b/tools/pm/test.pl
index dee7e9f..3bb4fa2 100755
--- a/tools/pm/test.pl
+++ b/tools/pm/test.pl
@@ -10,6 +10,7 @@ require Base::Enum;
 require Base::Function;
 require Base::Object;
 require Base::Property;
+require Base::Backend;
 
 require Defs::Common;
 require Defs::Enum;



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