Changeset 22270 for v6

Show
Ignore:
Timestamp:
09/17/08 13:27:13 (3 months ago)
Author:
pmurias
Message:

[smop] IO RI converted to the RI DSL

Location:
v6/smop
Files:
1 removed
2 modified
1 moved

Legend:

Unmodified
Added
Removed
  • v6/smop/CMakeLists.txt

    r22268 r22270  
    101101 
    102102foreach (ri_file 
    103 #    src/smop_s1p_itemcontext.ri 
    104 #    src/smop_s1p_itemrwcontext.ri 
     103    src/smop_s1p_io.ri 
    105104) 
    106105compile_ri (${ri_file}) 
  • v6/smop/src/smop_s1p_io.ri

    r22261 r22270  
    33%prefix smop_s1p_io 
    44%include <stdlib.h>,<stdio.h> 
     5 
     6%{ 
     7typedef struct smop_s1p_io_struct { 
     8  SMOP__Object__BASE 
     9} smop_s1p_io_struct; 
     10 
     11SMOP__Object* SMOP__S1P__IO_create(SMOP__Object* interpreter) { 
     12    SMOP_REFERENCE(interpreter,RI); 
     13    SMOP__Object* ret = smop_lowlevel_alloc(sizeof(smop_s1p_io_struct)); 
     14    ret->RI = (SMOP__ResponderInterface*)RI; 
     15    return ret; 
     16} 
     17%} 
     18 
    519%method print 
    620    int pc = SMOP__NATIVE__capture_positional_count(interpreter,capture); 
     
    2337    } 
    2438%method DESTROYALL 
     39    SMOP_RELEASE(interpreter,RI); 
     40%method new 
     41    ret = SMOP__S1P__IO_create(interpreter); 
  • v6/smop/tools/ri

    r22263 r22270  
    55sub mangle { 
    66    my $id = shift; 
    7     return 'SMOP__ID__'.$id; 
     7    return 'ID__'.$id; 
    88} 
    99 
    10 my @properties = qw(RI RI.id prefix include); 
     10my @properties = qw(RI RI.id prefix include prototype); 
    1111my %properties; 
    1212 
     
    1414my $method; 
    1515 
    16 # FIX convoluted 
    17 LINE: while (my $line = <>) { 
    18     if ($method) { 
     16my $raw = ''; 
     17 
     18sub debug { 
     19} 
     20while (my $line = <>) { 
     21    if ($line =~ /^\%\{\s*/) { 
     22         debug "raw start\n"; 
     23         until((my $raw_line = <>) =~ /^\%}\s*$/) { 
     24             debug "raw $raw_line"; 
     25             $raw .= $raw_line; 
     26         } 
     27         debug "raw stop\n"; 
     28    } elsif ($method) { 
    1929        if ($line =~ /^%/) { 
    2030            undef $method; 
     31            redo; 
    2132        } else { 
     33            debug "in method $line"; 
    2234            $methods{$method} .= $line; 
    2335            next; 
    2436        } 
    25     } 
    26     if ($line =~ /^%method\s*(.*)$/) { 
     37    } elsif ($line =~ /^%method\s*(.*)$/) { 
    2738        $method = $1; 
    28         next; 
    29     } 
    30     for my $property (@properties) { 
    31         if ($line =~ /^% \s* \Q$property\E \s+ (.*)$/x) { 
    32             $properties{$property} = $1; 
    33             next LINE; 
     39        debug "method start:$method\n"; 
     40    } elsif ($line =~ / ^\s*$ | ^\# | ^\/\/ /x) { 
     41        debug "ws/comment:$line"; 
     42    } else { 
     43        for my $property (@properties) { 
     44            if ($line =~ /^% \s* \Q$property\E \s+ (.*)$/x) { 
     45                $properties{$property} = $1; 
     46                debug "prop $property = $1\n"; 
     47                goto FOUND; 
     48            } 
    3449        } 
    35     } 
     50        die "unrecognised line: $line"; 
     51        FOUND: ; 
     52    }  
    3653} 
    3754 
     
    5774    print 'static SMOP__Object* ',mangle($_),";\n"; 
    5875} 
     76 
     77print $raw; 
     78 
    5979print q[ 
    6080static SMOP__Object* message(SMOP__Object* interpreter,