Please help me with RI.watchSize

Filip Konvička filip.konvicka.removethisantispamtoken at logis.cz
Tue Apr 25 15:16:06 CEST 2006


Dear hackers,

I'm trying to add a domain watcher for the RI (XRI, actually :-)) 
module, one much like FD.watch.size. I have added the following code:

OZ_BI_define(ri_watchSize, 2, 1)
{
   OZ_EXPECTED_TYPE(EM_RI ", FLOAT");
   RIExpect pe;
   OZ_expect_t r = pe.expectRIVarMinMax(OZ_in(0));

   if (pe.isFailing(r)) {
     return OZ_typeErrorCPI(expectedType, 0, "");
   } else if (pe.isSuspending(r)) {
     return pe.suspend();
   }

   RIVar ri;
   ri.ask(OZ_in(0));
   double w = ri->getWidth();

   // get the value to compare with
   OZ_declareFloat(1,f);

   // compute return value
   if (w < f) { OZ_RETURN_BOOL(true); }
   if (f < 0.) { OZ_RETURN_BOOL(false); }

   if (w > 0.){
     //  must return SUSPEND;
     return pe.suspend();
   }
   OZ_RETURN_BOOL(false);
} OZ_BI_end

I'm able to run this fine, but the code does not seem to wake up 
properly. It does the right job when the real variable domain width is 
already smaller than the limit (it correctly returns true immediately). 
I added some printf/fflush to see what really gets called and it seems 
that for an unconstrained variable, the code correctly ends with the 
"return pe.suspend()", but after the variable domain changes, the 
function does not get called again.

The code was inspired by fdcore.cc and the docs, and from what I've read 
in the docs, it should be correct ;-) Do you have any clues, please?

Thanks for any info!

Cheers,
Filip




More information about the mozart-hackers mailing list