Changeset 22230 for v6

Show
Ignore:
Timestamp:
09/12/08 20:17:52 (3 months ago)
Author:
pmurias
Message:

[smop] meta RI, it's only used by the IO RI `

Location:
v6/smop
Files:
1 added
11 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/CMakeLists.txt

    r22187 r22230  
    111111    src/smop_slime_frame.c 
    112112    src/smop_slime_node.c 
     113    src/smop_ri.c 
    113114) 
    114115 
  • v6/smop/include/smop_lowlevel.h

    r22017 r22230  
    55#include <smop.h> 
    66#include <smop_slime.h> 
     7#include <pthread.h> 
    78 
    89/* The lowlevel SMOP API is an additional API that is not included by 
     
    2122extern void smop_lowlevel_destr(); 
    2223 
     24typedef struct SMOP_LOWLEVEL_INTERNAL { 
     25  int ref_cnt; 
     26  pthread_rwlock_t* rwlock; 
     27} SMOP_LOWLEVEL_INTERNAL; 
     28 
    2329/* This function is the place from where every allocation should 
    2430 * happen. 
     
    3642 */ 
    3743extern SMOP__Object* smop_lowlevel_refcnt_inc(SMOP__Object* interpreter, SMOP__ResponderInterface* ri, SMOP__Object* value); 
     44 
     45SMOP__Object* SMOP__RI__create( 
     46  SMOP__Object* (*MESSAGE)  (SMOP__Object* interpreter,            
     47                             SMOP__ResponderInterface* self,       
     48                             SMOP__Object* identifier,             
     49                             SMOP__Object* capture),               
     50  SMOP__Object* (*REFERENCE)(SMOP__Object* interpreter,            
     51                             SMOP__ResponderInterface* self,       
     52                             SMOP__Object* object),                
     53  SMOP__Object* (*RELEASE)  (SMOP__Object* interpreter,            
     54                             SMOP__ResponderInterface* self,       
     55                             SMOP__Object* object), 
     56  char *id 
     57);  
    3858 
    3959/* This functions decrements the reference count of a value, it should 
  • v6/smop/include/smop_s1p.h

    r22183 r22230  
    66extern SMOP__Object* SMOP__S1P__Array; 
    77extern SMOP__Object* SMOP__S1P__Array_Iterator; 
    8 extern SMOP__Object* SMOP__S1P__IO; 
    98extern SMOP__Object* SMOP__S1P__Str; 
    109extern SMOP__Object* SMOP__S1P__Hash; 
     
    4241SMOP__Object* SMOP__S1P__Scalar_FETCH(SMOP__Object* object); 
    4342SMOP__Object* SMOP__S1P__Scalar_STORE(SMOP__Object* object, SMOP__Object* new_value); 
    44 SMOP__Object* SMOP__S1P__IO_create(void); 
     43SMOP__Object* SMOP__S1P__IO_create(SMOP__Object* interpreter); 
    4544SMOP__Object* SMOP__S1P__Hash_create(void); 
    4645SMOP__Object* SMOP__S1P__Array_create(void); 
  • v6/smop/src/smop.c

    r22017 r22230  
    3737                                             NULL, NULL)); 
    3838 
     39  SMOP_INTERNAL_DESTROY_SEQUENCE; 
    3940  SMOP_RELEASE(SMOP__INTPTR__InterpreterInstance,SMOP__GlobalInterpreter); 
    40   SMOP_INTERNAL_DESTROY_SEQUENCE; 
    4141  SMOP_INTERNAL_SHUTDOWN_SEQUENCE; 
    4242} 
  • v6/smop/src/smop_internal.h

    r22183 r22230  
    2121     smop_native_int_init();          \ 
    2222     smop_native_bool_init();         \ 
     23     smop_ri_init();                  \ 
    2324     smop_slime_frame_init();         \ 
    2425     smop_slime_currentframe_init();  \ 
    2526     smop_slime_node_init();          \ 
    26      smop_slime_capturize_init(); 
     27     smop_slime_capturize_init();      
    2728#define SMOP_INTERNAL_SHUTDOWN_SEQUENCE  \ 
    2829     smop_slime_capturize_destr();       \ 
     
    3536     smop_interpreter_destr();           \ 
    3637     smop_lowlevel_destr();              \ 
     38     smop_ri_destr();                    \ 
    3739     smop_idconst_destr(); 
    3840 
  • v6/smop/src/smop_lowlevel.sm0p

    r22017 r22230  
    7979#endif 
    8080 
    81 typedef struct SMOP_LOWLEVEL_INTERNAL { 
    82   int ref_cnt; 
    83   pthread_rwlock_t* rwlock; 
    84 } SMOP_LOWLEVEL_INTERNAL; 
    8581 
    8682 
  • v6/smop/src/smop_s1p_io.c

    r22017 r22230  
    55#include <smop_s1p.h> 
    66 
    7 SMOP__Object* SMOP__S1P__IO; 
     7static SMOP__Object* SMOP__S1P__IO; 
    88 
    99typedef struct smop_s1p_io_struct { 
     
    1111} smop_s1p_io_struct; 
    1212 
    13 SMOP__Object* SMOP__S1P__IO_create(void) { 
     13SMOP__Object* SMOP__S1P__IO_create(SMOP__Object* interpreter) { 
     14    SMOP_REFERENCE(interpreter,SMOP__S1P__IO); 
    1415    SMOP__Object* ret = smop_lowlevel_alloc(sizeof(smop_s1p_io_struct)); 
    1516    ret->RI = (SMOP__ResponderInterface*)SMOP__S1P__IO; 
     
    4647        } 
    4748 
    48         SMOP_RELEASE(interpreter,obj); 
    49     } 
     49        SMOP_RELEASE(interpreter,obj); } 
    5050  } else if (identifier == SMOP__ID__new) { 
    51     SMOP__S1P__IO_create(); 
     51    SMOP__S1P__IO_create(interpreter); 
    5252  } else if (identifier == SMOP__ID__DESTROYALL) { 
     53    SMOP_RELEASE(interpreter,SMOP__S1P__IO); 
    5354  } else { 
    5455    fprintf(stderr,"unkown method at S1P::IO\n"); 
     
    6263 
    6364void smop_s1p_io_init() { 
    64   SMOP__S1P__IO = calloc(1,sizeof(SMOP__ResponderInterface)); 
    65   ((SMOP__ResponderInterface*)SMOP__S1P__IO)->MESSAGE = smop_s1p_io_message; 
    66   ((SMOP__ResponderInterface*)SMOP__S1P__IO)->REFERENCE = smop_lowlevel_generic_reference; 
    67   ((SMOP__ResponderInterface*)SMOP__S1P__IO)->RELEASE = smop_lowlevel_generic_release; 
    68   ((SMOP__ResponderInterface*)SMOP__S1P__IO)->id = "Lowlevel io"; 
     65  SMOP__S1P__IO = SMOP__RI__create( 
     66      smop_s1p_io_message, 
     67      smop_lowlevel_generic_reference, 
     68      smop_lowlevel_generic_release, 
     69      "Lowlevel io"); 
    6970} 
    7071 
    7172void smop_s1p_io_destr() { 
    72   free(SMOP__S1P__IO); 
     73  SMOP__ResponderInterface* ri = (SMOP__ResponderInterface*) SMOP__S1P__IO; 
     74  SMOP_RELEASE(SMOP__GlobalInterpreter,SMOP__S1P__IO); 
    7375} 
    7476 
  • v6/smop/src/smop_s1p_root_namespace.c

    r22017 r22230  
    2626  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Hash",SMOP__S1P__Hash_create()); 
    2727  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Array",SMOP__S1P__Array_create()); 
    28   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"$*OUT",SMOP__S1P__IO_create()); 
     28  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"$*OUT",SMOP__S1P__IO_create(SMOP__GlobalInterpreter)); 
    2929  //smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Code",SMOP__S1P__Code_create(SMOP__NATIVE__bool_false)); 
    3030  SMOP__Object* mold = SMOP__Mold_create(0,(SMOP__Object*[]) { NULL },1,(int[]) { 0 }); 
  • v6/smop/test/16_labels.sm0p

    r21324 r22230  
    1919  SMOP__Object* node = NULL; 
    2020 
    21   SMOP__Object* io = SMOP__S1P__IO_create(); 
     21  SMOP__Object* io = SMOP__S1P__IO_create(interpreter); 
    2222  node = q:sm0p { 
    2323    ; 
  • v6/smop/test/17_sm0p.sm0p

    r21915 r22230  
    1919  SMOP__Object* node = NULL; 
    2020 
    21   SMOP__Object* io   = SMOP__S1P__IO_create(); 
     21  SMOP__Object* io   = SMOP__S1P__IO_create(interpreter); 
    2222  node = q:sm0p { 
    2323    ; 
  • v6/smop/test/23_mold.sm0p

    r21892 r22230  
    2020  SMOP__Object* mold = SMOP__Mold_create(1, 
    2121    (SMOP__Object*[]) { /* constants */ 
    22       SMOP__S1P__IO_create(),  
     22      SMOP__S1P__IO_create(interpreter),  
    2323      SMOP__NATIVE__idconst_create("print"),  
    2424      SMOP__S1P__Str_create("ok 2 - simple method call works\n"),