Tassilo von Parseval said:
> For demonstration purpose, I uploaded the little and cursory XS wrapper around
> <vector> to
> http://www-users.rwth-aachen.de/Tassilo.Parseval/Vector-0.01.tar.gz
> and everybody is free to have a look at it. It mainly demonstrates how
> to use '::' in method names to avoid some typing. Also, it does some
> overloading in XS, although this is not C++ specific.

I have some ugly and non-open code at work that illustrates binding a C++
abstract class to perl and allowing perl code to override virtual methods. 
It's not pretty, and involves creating a special subclass of the C++ object
that adds wrapper information, but it does work quite well.

  package MyDataSource;
  use base 'DataSourceBase';  # DataSourceBase is actually implemented in C++

  # override the get_data virtual method.  this will get called not
  # only when perl code triggers the method, but when *any* code calls
  # it.  very important for plugin-style things.
  sub GETDATA {
     my ($this, @params) = @_;
     # custom code to implement the virtual method goes here
     return $this->SUPER::GETDATA (@params);  # chain up
  }


If that would be interesting or helpful, i'll try to carve a useful example
out of that code this weekend.


-- 
muppet <scott at asofyet dot org>

Reply via email to