From b3075b2ff8a860c70215c0555e0c7b246eff2ae3 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 24 Oct 2005 16:42:16 +0000 Subject: [PATCH] Horrible, horrible support for set_callback(). I can hear them coming to get me. The rats ... the rats are in the walls! IN THE WALLS! (Also, the first few lines of ZOOM::Query support.) --- lib/ZOOM.pm | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/ZOOM.pm b/lib/ZOOM.pm index a75c407..45369f5 100644 --- a/lib/ZOOM.pm +++ b/lib/ZOOM.pm @@ -1,4 +1,4 @@ -# $Id: ZOOM.pm,v 1.8 2005-10-19 13:53:35 mike Exp $ +# $Id: ZOOM.pm,v 1.9 2005-10-24 16:42:16 mike Exp $ use strict; use warnings; @@ -179,6 +179,30 @@ sub set_int { Net::Z3950::ZOOM::options_set_int($this->_opts(), $key, $value); } +# ### Feel guilty. Feel very, very guilty. I've not been able to +# get the callback memory-management right in "ZOOM.xs", with +# the result that the values of $function and $udata passed into +# this function, which are on the stack, have sometimes been +# freed by the time they're used by __ZOOM_option_callback(), +# with hilarious results. To avoid this, I copy the values into +# module-scoped globals, and pass _those_ into the extension +# function. To avoid overwriting those globals by subsequent +# calls, I keep all the old ones, pushed onto the @_function and +# @_udata arrays, which means that THIS FUNCTION LEAKS MEMORY +# LIKE IT'S GOING OUT OF FASHION. Not nice. One day, I should +# fix this, but for now there's more important fish to fry. +# +my(@_function, @_udata); +sub set_callback { + my $o1 = shift(); + my($function, $udata) = @_; + + push @_function, $function; + push @_udata, $udata; + Net::Z3950::ZOOM::options_set_callback($o1->_opts(), + $_function[-1], $_udata[-1]); +} + sub destroy { my $this = shift(); @@ -315,6 +339,26 @@ sub destroy { # ---------------------------------------------------------------------------- +package ZOOM::Query; + +sub new { + my $class = shift(); + die "You can't create $class objects: it's a virtual base class"; + +} + + +package ZOOM::Query::RPN; + +sub new { + my $class = shift(); + + ### Er ... +} + + +# ---------------------------------------------------------------------------- + package ZOOM::ResultSet; sub new { -- 1.7.10.4