You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2002/03/28 08:47:17 UTC

cvs commit: xml-xerces/perl/Handler PerlNodeFilterCallbackHandler.hpp PerlNodeFilterCallbackHandler.i PerlNodeFilterCallbackHandler.swig.hpp

jasons      02/03/27 23:47:17

  Added:       perl/Handler PerlNodeFilterCallbackHandler.hpp
                        PerlNodeFilterCallbackHandler.i
                        PerlNodeFilterCallbackHandler.swig.hpp
  Log:
  	* Handler/PerlNodeFilterCallbackHandler.swig.hpp (Repository):
  	new node filter class for tree walkers and node iterators
  
  Revision  Changes    Path
  1.1                  xml-xerces/perl/Handler/PerlNodeFilterCallbackHandler.hpp
  
  Index: PerlNodeFilterCallbackHandler.hpp
  ===================================================================
  #ifndef __PERLNODEFILTERCALLBACKHANDLER
  #define __PERLNODEFILTERCALLBACKHANDLER
  
  #include "PerlCallbackHandler.hpp"
  #include "xercesc/idom/IDOM_NodeFilter.hpp"
  class PerlNodeFilterCallbackHandler : public IDOM_NodeFilter
  				    , public  PerlCallbackHandler
  {
  
  protected:
  //    SV *callbackObj;
  
  public:
  
      PerlNodeFilterCallbackHandler() {};
      PerlNodeFilterCallbackHandler(SV *obj) : PerlCallbackHandler(obj){};
      ~PerlNodeFilterCallbackHandler() {};
  
      SV* set_callback_obj(SV*);
  
  	// The NodeFilter interface
      short acceptNode (const IDOM_Node* node) const;
  };
  
  #endif __PERLNODEFILTERCALLBACKHANDLER
  
  
  
  1.1                  xml-xerces/perl/Handler/PerlNodeFilterCallbackHandler.i
  
  Index: PerlNodeFilterCallbackHandler.i
  ===================================================================
  #include "PerlNodeFilterCallbackHandler.hpp"
  
  SV*
  PerlNodeFilterCallbackHandler::set_callback_obj(SV* object) {
      SV *oldRef = &PL_sv_undef;	// default to 'undef'
      if (callbackObj != NULL) {
  	oldRef = callbackObj;
  	SvREFCNT_dec(oldRef);
      }
      SvREFCNT_inc(object);
      callbackObj = object;
      return oldRef;
  }
  
  short
  PerlNodeFilterCallbackHandler::acceptNode (const IDOM_Node* node) const
  {
      if (!callbackObj) {
          croak("\nacceptNode: no NodeFilter set\n");
  	return 0;
      }
  
      dSP;
  
      ENTER;
      SAVETMPS;
  
      PUSHMARK(SP);
  	// first put the callback object on the stack
      XPUSHs(callbackObj);
  
          // the only argument is the node
      swig_type_info *ty = SWIG_TypeDynamicCast(SWIGTYPE_p_IDOM_Node, (void **) &node);
      SV* node_sv = sv_newmortal();
      SWIG_MakePtr(node_sv, (void *) node, ty);
      XPUSHs(node_sv);
  
      PUTBACK;
  
      int count = perl_call_method("acceptNode", G_SCALAR);
  
      SPAGAIN ;
  
      if (count != 1)
  	croak("NodeFilter did not return an answer\n") ;
  
      short accept = POPi;
  
      PUTBACK ;
      FREETMPS;
      LEAVE;
      return accept;
  }
  
  
  
  1.1                  xml-xerces/perl/Handler/PerlNodeFilterCallbackHandler.swig.hpp
  
  Index: PerlNodeFilterCallbackHandler.swig.hpp
  ===================================================================
  class PerlNodeFilterCallbackHandler : public IDOM_NodeFilter {
  
  public:
  
      PerlNodeFilterCallbackHandler();
  
      void set_callback_obj(SV*);
  
  };
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org