Show
Ignore:
Timestamp:
07/04/08 02:15:06 (5 months ago)
Author:
ruoso
Message:

[smop] yet more work on the p6opaque implementation... Some nasty bug is causing a deadlock (yes... I know the reasons for locks to exist is to cause dead-locks, but that is what I got so far)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/test/12_p6opaque.sm0p

    r21201 r21202  
    44#include <smop_slime.h> 
    55#include <smop_oo.h> 
     6#include <smop_lowlevel.h> 
     7 
     8static SMOP__Object* test_message(SMOP__Object* interpreter, 
     9                                  SMOP__ResponderInterface* responder, 
     10                                  SMOP__Object* identifier, 
     11                                  SMOP__Object* capture) { 
     12  if (identifier == SMOP__ID__dispatch) { 
     13    printf("ok 3 - called dispatch\n"); 
     14    SMOP_RELEASE(interpreter, capture); 
     15  } else if (identifier == SMOP__ID__DESTROYALL) { 
     16    printf("ok 4 - called DESTROYALL\n"); 
     17  } else { 
     18    printf("not ok - unkown method\n"); 
     19    SMOP_RELEASE(interpreter, capture); 
     20  } 
     21  return SMOP__NATIVE__bool_true; 
     22} 
     23 
     24extern SMOP__Object* test_release(SMOP__Object* interpreter,  
     25                                  SMOP__ResponderInterface* responder, 
     26                                  SMOP__Object* obj) { 
     27  printf("-"); 
     28  smop_lowlevel_refcnt_dec(interpreter, responder, obj); 
     29  return obj; 
     30} 
     31 
     32extern SMOP__Object* test_reference(SMOP__Object* interpreter,  
     33                                    SMOP__ResponderInterface* responder, 
     34                                    SMOP__Object* obj) { 
     35  printf("+"); 
     36  smop_lowlevel_refcnt_inc(interpreter, responder, obj); 
     37  return obj; 
     38} 
    639 
    740int main() { 
    841  smop_init(); 
    942 
    10   printf("1..4\n"); 
     43  printf("1..6\n"); 
    1144 
    1245 
     
    1649                                                                         SMOP__INTPTR__InterpreterInstance,NULL,NULL)); 
    1750  SMOP__Object* frame; 
    18   SMOP__Object* how = SMOP__NATIVE__bool_true; 
     51  SMOP__Object* how = smop_lowlevel_alloc(sizeof(SMOP__ResponderInterface)); 
     52  ((SMOP__ResponderInterface*)how)->MESSAGE = &test_message; 
     53  ((SMOP__ResponderInterface*)how)->REFERENCE = &test_reference; 
     54  ((SMOP__ResponderInterface*)how)->RELEASE = &test_release; 
     55  ((SMOP__ResponderInterface*)how)->id = "test metaclass"; 
     56 
    1957  SMOP__Object* p6opaque =  
    2058    SMOP_DISPATCH(SMOP__INTPTR__InterpreterInstance, SMOP__p6opaque__RI, 
     
    2462  $frame = q:sm0p { 
    2563    ; 
    26     $p6opaque.SMOP__ID__new(); 
     64    $p6opaque.SMOP__ID__REPR_how($how); 
     65    $p6opaque.SMOP__ID__STORE(); 
    2766  }; 
    28   //  SMOP__SLIME__CurrentFrame.move_responder(7,2); 
    29   //  SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(9,(),(),1)); 
    30   //  SMOP__p6opaque__RI.SMOP__ID__new(); 
    31   //}; 
    3267 
    3368  if (!frame) printf("not "); 
    3469  printf("ok 1 - frame created.\n"); 
    3570 
    36   SMOP_RELEASE(interpreter,p6opaque); 
    3771  SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
    3872                SMOP__ID__goto, 
     
    4175  printf("ok 2 - goto frame.\n"); 
    4276 
     77  SMOP_RELEASE(interpreter,p6opaque); 
    4378  SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
    4479                SMOP__ID__loop, SMOP__NATIVE__capture_create(interpreter, 
    4580                                                             SMOP_REFERENCE(interpreter,interpreter), 
    4681                                                             NULL, NULL)); 
    47   printf("ok 3 - interpreter loop.\n"); 
     82  printf("ok 5 - interpreter loop.\n"); 
    4883 
    4984 
    5085  SMOP_RELEASE(SMOP__INTPTR__InterpreterInstance,interpreter); 
    5186 
    52   printf("ok 4 - Scalar destroyed should free the p6opaque object also.\n"); 
     87  printf("ok 6 - Scalar destroyed should free the p6opaque object also.\n"); 
    5388 
    5489  smop_destr();