Ignore:
Timestamp:
Dec 29, 2011, 11:17:03 AM (8 years ago)
Author:
cameron
Message:

Eliminate u8 struct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/u8u16/u8u16_pablo_straight.py

    r1814 r1821  
    11# -*- coding: utf-8 -*-
    22
    3 class u8 ():
    4   unibyte = 0
    5   prefix = 0
    6   prefix2 = 0
    7   prefix3 = 0
    8   prefix4 = 0
    9   suffix = 0
    10   badprefix = 0
    11   xE0 = 0
    12   xED = 0
    13   xF0 = 0
    14   xF4 = 0
    15   xA0_xBF = 0
    16   x80_x9F = 0
    17   x90_xBF = 0
    18   x80_x8F = 0
    19   xEF = 0
    20   xBF = 0
    21   xBE = 0
    22   scope22 = 0
    23   scope32 = 0
    24   scope33 = 0
    25   scope42 = 0
    26   scope43 = 0
    27   scope44 = 0
    28   xE0_scope = 0
    29   xED_scope = 0
    30   xF0_scope = 0
    31   xF4_scope = 0
    32   xEF_scope = 0
    33   error = 0
    34 
    35 
    36 def main(u8, mask):
    37         u8.unibyte = (~bit[0]);
    38         u8.prefix = (bit[0] & bit[1]);
    39         u8.prefix2 = (u8.prefix &~ bit[2]);
     3def main():
     4        u8_unibyte = (~bit[0]);
     5        u8_prefix = (bit[0] & bit[1]);
     6        u8_prefix2 = (u8_prefix &~ bit[2]);
    407        temp1 = (bit[2] &~ bit[3]);
    41         u8.prefix3 = (u8.prefix & temp1);
     8        u8_prefix3 = (u8_prefix & temp1);
    429        temp2 = (bit[2] & bit[3]);
    43         u8.prefix4 = (u8.prefix & temp2);
    44         u8.suffix = (bit[0] &~ bit[1]);
     10        u8_prefix4 = (u8_prefix & temp2);
     11        u8_suffix = (bit[0] &~ bit[1]);
    4512        temp3 = (bit[2] | bit[3]);
    46         temp4 = (u8.prefix &~ temp3);
     13        temp4 = (u8_prefix &~ temp3);
    4714        temp5 = (bit[4] | bit[5]);
    4815        temp6 = (temp5 | bit[6]);
     
    5118        temp9 = (bit[5] & temp8);
    5219        temp10 = (bit[4] | temp9);
    53         temp11 = (u8.prefix4 & temp10);
    54         u8.badprefix = (temp7 | temp11);
     20        temp11 = (u8_prefix4 & temp10);
     21        u8_badprefix = (temp7 | temp11);
    5522        temp12 = (temp5 | temp8);
    56         xE0 = (u8.prefix3 &~ temp12);
     23        xE0 = (u8_prefix3 &~ temp12);
    5724        temp13 = (bit[4] & bit[5]);
    5825        temp14 = (bit[7] &~ bit[6]);
    5926        temp15 = (temp13 & temp14);
    60         xED = (u8.prefix3 & temp15);
    61         xF0 = (u8.prefix4 &~ temp12);
     27        xED = (u8_prefix3 & temp15);
     28        xF0 = (u8_prefix4 &~ temp12);
    6229        temp16 = (bit[5] &~ bit[4]);
    6330        temp17 = (temp16 &~ temp8);
    64         xF4 = (u8.prefix4 & temp17);
    65         xA0_xBF = (u8.suffix & bit[2]);
    66         x80_x9F = (u8.suffix &~ bit[2]);
    67         x90_xBF = (u8.suffix & temp3);
    68         x80_x8F = (u8.suffix &~ temp3);
     31        xF4 = (u8_prefix4 & temp17);
     32        xA0_xBF = (u8_suffix & bit[2]);
     33        x80_x9F = (u8_suffix &~ bit[2]);
     34        x90_xBF = (u8_suffix & temp3);
     35        x80_x8F = (u8_suffix &~ temp3);
    6936
    7037      #
    71         u8.scope22 = pablo.Advance(u8.prefix2)
    72         u8.scope32 = pablo.Advance(u8.prefix3)
    73         u8.scope33 = pablo.Advance(u8.scope32)
    74         u8.scope42 = pablo.Advance(u8.prefix4)
    75         u8.scope43 = pablo.Advance(u8.scope42)
    76         u8.scope44 = pablo.Advance(u8.scope43)
    77         u8lastscope = u8.scope22 | u8.scope33 | u8.scope44
    78         u8anyscope = u8lastscope | u8.scope32 | u8.scope42 | u8.scope43
     38        u8_scope22 = pablo.Advance(u8_prefix2)
     39        u8_scope32 = pablo.Advance(u8_prefix3)
     40        u8_scope33 = pablo.Advance(u8_scope32)
     41        u8_scope42 = pablo.Advance(u8_prefix4)
     42        u8_scope43 = pablo.Advance(u8_scope42)
     43        u8_scope44 = pablo.Advance(u8_scope43)
     44        u8lastscope = u8_scope22 | u8_scope33 | u8_scope44
     45        u8anyscope = u8lastscope | u8_scope32 | u8_scope42 | u8_scope43
    7946
    8047        adv_bit2 = pablo.Advance(bit[2])
     
    8653             
    8754        # C0-C1 and F5-FF are illegal
    88         error_mask = u8.badprefix
     55        error_mask = u8_badprefix
    8956             
    9057        error_mask |= pablo.Advance(xE0) & x80_x9F
     
    9360        error_mask |= pablo.Advance(xF4) & x90_xBF
    9461             
    95         error_mask |= u8anyscope ^ u8.suffix
    96         u8.error = error_mask
    97         u8lastbyte = u8.unibyte | u8lastscope
     62        error_mask |= u8anyscope ^ u8_suffix
     63        u8_error = error_mask
     64        u8lastbyte = u8_unibyte | u8lastscope
    9865        u16lo[2] = u8lastbyte & bit[2]
    9966        u16lo[3] = u8lastbyte & bit[3]
     
    10269        u16lo[6] = u8lastbyte & bit[6]
    10370        u16lo[7] = u8lastbyte & bit[7]
    104         u16lo[1] = (u8.unibyte & bit[1]) | (u8lastscope & adv_bit7)
     71        u16lo[1] = (u8_unibyte & bit[1]) | (u8lastscope & adv_bit7)
    10572        u16lo[0] = u8lastscope & adv_bit6
    10673       
     
    11077        advadv_bit6 = pablo.Advance(adv_bit6)
    11178        advadv_bit7 = pablo.Advance(adv_bit7)
    112         u16hi[0] = u8.scope33 & pablo.Advance(adv_bit4)
    113         u16hi[1] = u8.scope33 & pablo.Advance(adv_bit5)
    114         u16hi[2] = u8.scope33 & pablo.Advance(adv_bit6)
    115         u16hi[3] = u8.scope33 & pablo.Advance(adv_bit7)
    116         u16hi[4] = u8.scope33 & adv_bit2
     79        u16hi[0] = u8_scope33 & pablo.Advance(adv_bit4)
     80        u16hi[1] = u8_scope33 & pablo.Advance(adv_bit5)
     81        u16hi[2] = u8_scope33 & pablo.Advance(adv_bit6)
     82        u16hi[3] = u8_scope33 & pablo.Advance(adv_bit7)
     83        u16hi[4] = u8_scope33 & adv_bit2
    11784
    118         u8surrogate = u8.scope43 | u8.scope44
     85        u8surrogate = u8_scope43 | u8_scope44
    11986        u16hi[0] = u16hi[0] | u8surrogate       
    12087        u16hi[1] = u16hi[1] | u8surrogate       
    12188        u16hi[3] = u16hi[3] | u8surrogate       
    12289        u16hi[4] = u16hi[4] | u8surrogate       
    123         u16hi[5] = u16hi[5] | u8.scope44
     90        u16hi[5] = u16hi[5] | u8_scope44
    12491
    12592
    12693        s43lo1 = ~adv_bit3 # subtract 1
    127         u16lo[1] = u16lo[1] | u8.scope43 & s43lo1
     94        u16lo[1] = u16lo[1] | u8_scope43 & s43lo1
    12895        s43lo0 = adv_bit2 ^ s43lo1 # borrow *
    129         u16lo[0] = u16lo[0] | u8.scope43 & s43lo0
     96        u16lo[0] = u16lo[0] | u8_scope43 & s43lo0
    13097        s43borrow1 = s43lo1 & ~adv_bit2
    13198        s43hi7 = advadv_bit7 ^ s43borrow1
     
    136103
    137104
    138         u16hi[7]= u16hi[7] | (u8.scope43 & s43hi7)
    139         u16hi[6] = u16hi[6] | (u8.scope43 & s43hi6)
     105        u16hi[7]= u16hi[7] | (u8_scope43 & s43hi7)
     106        u16hi[6] = u16hi[6] | (u8_scope43 & s43hi6)
    140107
    141         u16lo[2] = u16lo[2] | (u8.scope43 & adv_bit4)
    142         u16lo[3] = u16lo[3] | (u8.scope43 & adv_bit5)
    143         u16lo[4] = u16lo[4] | (u8.scope43 & adv_bit6)
    144         u16lo[5] = u16lo[5] | (u8.scope43 & adv_bit7)
    145         u16lo[6] = u16lo[6] | (u8.scope43 & bit[2])
    146         u16lo[7] = u16lo[7] | (u8.scope43 & bit[3])
     108        u16lo[2] = u16lo[2] | (u8_scope43 & adv_bit4)
     109        u16lo[3] = u16lo[3] | (u8_scope43 & adv_bit5)
     110        u16lo[4] = u16lo[4] | (u8_scope43 & adv_bit6)
     111        u16lo[5] = u16lo[5] | (u8_scope43 & adv_bit7)
     112        u16lo[6] = u16lo[6] | (u8_scope43 & bit[2])
     113        u16lo[7] = u16lo[7] | (u8_scope43 & bit[3])
    147114
    148         delmask = u8.prefix | u8.scope32 | u8.scope42
     115        delmask = u8_prefix | u8_scope32 | u8_scope42
    149116
Note: See TracChangeset for help on using the changeset viewer.