Changeset 54 for trunk/orca

Show
Ignore:
Timestamp:
02/17/06 15:30:01 (3 years ago)
Author:
krobillard
Message:

Now using orDecimal() & orInt() where appropriate.

Location:
trunk/orca
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/ChangeLog

    r2 r54  
    22 
    33 
    4 V0.0.23 - ?? January 2005 
     4V0.0.23 - ?? February 2005 
    55 
    66    * Foreach no longer creates a new context. Use 'rebol in config.r to 
     
    88    * Script header is now required. 
    99    * Implemented do/args. 
     10    * Most math operators now work on tuples. 
    1011    * Bugfixes. 
    1112 
  • trunk/orca/bytecode.c

    r42 r54  
    7575        case OT_INTEGER: 
    7676        { 
    77             int i = val->integer; 
     77            int i = orInt(val); 
    7878            if( i > 255 ) 
    7979            { 
     
    103103 
    104104            end = cp + 8; 
    105             li = *((uint64_t*) &val->num.decimal); 
     105            li = *((uint64_t*) &orDecimal(val)); 
    106106            while( cp != end ) 
    107107            { 
     
    117117            RESERVE( 2 ); 
    118118            *cp++ = val->type; 
    119             *cp   = val->integer & 0xff; 
     119            *cp   = orInt(val) & 0xff; 
    120120            break; 
    121121 
  • trunk/orca/context.c

    r45 r54  
    158158    while( it != end ) 
    159159    { 
    160         if( it->word.atom == atom ) 
     160        if( orAtom(it) == atom ) 
    161161            return it - wordBlk->values; 
    162162        ++it; 
     
    232232    while( it != end ) 
    233233    { 
    234         if( it->word.atom == atom ) 
     234        if( orAtom(it) == atom ) 
    235235            return it - wblk->values; 
    236236        ++it; 
     
    264264            // Word might be redefined mulitple times so we have to 
    265265            // orLookup() first. 
    266             wrdN = orLookup( ctx, it->word.atom ); 
     266            wrdN = orLookup( ctx, orAtom(it) ); 
    267267            if( wrdN < 0 ) 
    268                 wrdN = orInternA( wordBlk, it->word.atom ); 
     268                wrdN = orInternA( wordBlk, orAtom(it) ); 
    269269        } 
    270270        ++it; 
     
    444444        if( it->type == OT_SETWORD ) 
    445445        { 
    446             if( orLookup( orig, it->word.atom ) < 0 ) 
     446            if( orLookup( orig, orAtom(it) ) < 0 ) 
    447447                ++wcount; 
    448448        } 
     
    506506{ 
    507507    int wrdN; 
    508     wrdN = orLookup( ctx, val->word.atom ); 
     508    wrdN = orLookup( ctx, orAtom(val) ); 
    509509    if( wrdN > -1 ) 
    510510    { 
     
    571571            (it->type == OT_GETWORD) ) 
    572572        { 
    573             if( (it->word.atom == orEnv->atom_func) || 
    574                 (it->word.atom == orEnv->atom_does) ) 
     573            if( (orAtom(it) == orEnv->atom_func) || 
     574                (orAtom(it) == orEnv->atom_does) ) 
    575575                return 1; 
    576576        } 
     
    681681    vblk = orBlockPtr( ctx.wblkN ); 
    682682 
    683     if( a1->type == OT_WORD ) 
    684     { 
    685         wrdN = orLookup( &ctx, a1->word.atom ); 
     683    if( orIs(a1, OT_WORD) ) 
     684    { 
     685        wrdN = orLookup( &ctx, orAtom(a1) ); 
    686686        if( wrdN > -1 ) 
    687687        { 
     
    689689        } 
    690690    } 
    691     else if( a1->type == OT_BLOCK ) 
     691    else if( orIs(a1, OT_BLOCK) ) 
    692692    { 
    693693        OBlock* blk = orBLOCK( a1 ); 
     
    696696        while( it != end ) 
    697697        { 
    698             if( it->type == OT_WORD ) 
    699             { 
    700                 wrdN = orLookup( &ctx, a1->word.atom ); 
     698            if( orIs(it, OT_WORD) ) 
     699            { 
     700                wrdN = orLookup( &ctx, orAtom(a1) ); 
    701701                if( wrdN > -1 ) 
    702702                { 
     
    720720    OIndex wrdN; 
    721721 
    722     wrdN = orLookup( &a1->ctx, a2->word.atom ); 
     722    wrdN = orLookup( &a1->ctx, orAtom(a2) ); 
    723723    if( wrdN < 0 ) 
    724724    { 
     
    730730        // a1->context remains unchanged. 
    731731        a1->word.index = wrdN; 
    732         a1->word.atom  = a2->word.atom; 
     732        orAtom(a1)     = orAtom(a2); 
    733733    } 
    734734} 
     
    754754    { 
    755755        orMakeContext( &ctx, 1 ); 
    756         orInternA( orBlockPtr( ctx.wblkN ), a1->word.atom ); 
     756        orInternA( orBlockPtr( ctx.wblkN ), orAtom(a1) ); 
    757757    } 
    758758    else 
     
    770770        { 
    771771            if( it->type == OT_WORD ) 
    772                 orInternA( blk, it->word.atom ); 
     772                orInternA( blk, orAtom(it) ); 
    773773            ++it; 
    774774        } 
     
    846846            if( it->type == OT_WORD ) 
    847847            { 
    848                 orInternA( blk, it->word.atom ); 
     848                orInternA( blk, orAtom(it) ); 
    849849            } 
    850850            else 
     
    861861    { 
    862862        orMakeContext( &ctx, 1 ); 
    863         orInternA( orBlockPtr( ctx.wblkN ), a1->word.atom ); 
     863        orInternA( orBlockPtr( ctx.wblkN ), orAtom(a1) ); 
    864864    } 
    865865 
     
    942942            { 
    943943                for( rlen = 0; rlen < vlen; ++rlen ) 
    944                     (wval + rlen)->integer = str->charArray[ si++ ]; 
     944                    orInt(wval + rlen) = str->charArray[ si++ ]; 
    945945 
    946946                orEvalBlock( orBlockPtr( body ), bi ); 
     
    956956                while( si < str->used ) 
    957957                { 
    958                     wval->integer = str->charArray[ si++ ]; 
     958                    orInt(wval) = str->charArray[ si++ ]; 
    959959                    ++wval; 
    960960                } 
     
    11271127                        { 
    11281128                            orSetTF( val, OT_CHAR ); 
    1129                             val->integer = str->charArray[ si ]; 
     1129                            orInt(val) = str->charArray[ si ]; 
    11301130                        } 
    11311131                        else 
  • trunk/orca/error.c

    r42 r54  
    6868                OBlock* vblk = orBlockPtr( ctx.vblkN ); 
    6969                val = vblk->values + wrd; 
    70                 if( val->type == OT_OBJECT ) 
     70                if( orIs(val, OT_OBJECT) ) 
    7171                { 
    7272                    ctx = val->ctx; 
    7373                    blk = 0; 
    7474                } 
    75                 else if( val->type == OT_BLOCK ) 
     75                else if( orIs(val, OT_BLOCK) ) 
    7676                { 
    7777                    orGlobalCtx( ctx ); 
     
    111111void orDisarmNative( OValue* a1 ) 
    112112{ 
    113     if( a1->type == OT_ERROR ) 
     113    if( orIs(a1, OT_ERROR) ) 
    114114    { 
    115115        OValue* val; 
     
    119119                            OT_WORD, orEnv->atom_error, 
    120120                            OR_LPATH_END ); 
    121         if( val && (val->type == OT_OBJECT) ) 
     121        if( val && orIs(val, OT_OBJECT) ) 
    122122        { 
    123123            int errType; 
     
    155155                                 OR_LPATH_END ); 
    156156            ++val; 
    157             if( tval && tval->type == OT_BLOCK ) 
     157            if( tval && orIs(tval, OT_BLOCK) ) 
    158158            { 
    159159                OBlock* blk = orBLOCK(tval); 
     
    165165            } 
    166166            orSetTF( val, OT_INTEGER ); 
    167             val->integer = errType; 
     167            orInt(val) = errType; 
    168168end_type: 
    169169 
     
    171171            ++val; 
    172172            orSetTF( val, OT_INTEGER ); 
    173             val->integer = a1->error.msg; 
     173            orInt(val) = a1->error.msg; 
    174174            */ 
    175175 
  • trunk/orca/gl/dlist.c

    r43 r54  
    113113{ 
    114114    if( val->type == OT_DECIMAL ) 
    115         return (GLfloat) val->num.decimal; 
     115        return (GLfloat) orDecimal(val); 
    116116    else if( val->type == OT_INTEGER ) 
    117         return (GLfloat) val->integer; 
     117        return (GLfloat) orInt(val); 
    118118    return 0.0f; 
    119119} 
     
    132132    else if( val->type == OT_DECIMAL ) 
    133133    { 
    134         GLfloat f = (GLfloat) val->num.decimal; 
     134        GLfloat f = (GLfloat) orDecimal(val); 
    135135        pc[0].f = pc[1].f = pc[2].f = f; 
    136136    } 
    137137    else if( val->type == OT_INTEGER ) 
    138138    { 
    139         GLfloat f = (GLfloat) val->integer; 
     139        GLfloat f = (GLfloat) orInt(val); 
    140140        pc[0].f = pc[1].f = pc[2].f = f; 
    141141    } 
     
    238238        pc = ((RenderWord*) prog->buf) + prog->used; 
    239239 
    240         switch( match->integer ) 
     240        switch( orInt(match) ) 
    241241        { 
    242242            case DLP_CALL_INT: 
     
    508508            return; 
    509509        } 
    510         key = a1->integer; 
     510        key = orInt(a1); 
    511511    } 
    512512    else 
     
    573573            { 
    574574                case PRIM_KEY_VERTEX: 
    575                     vindex = idx->integer * 3; 
     575                    vindex = orInt(idx) * 3; 
    576576                    getVector( 3, gEnv.state.vertVals + vindex, vec ); 
    577577                    glVertex3dv( vec ); 
     
    580580 
    581581                case PRIM_KEY_NORMAL: 
    582                     vindex = idx->integer * 3; 
     582                    vindex = orInt(idx) * 3; 
    583583                    getVector( 3, gEnv.state.normVals + vindex, vec ); 
    584584                    glNormal3dv( vec ); 
     
    588588                case PRIM_KEY_COLOR: 
    589589                { 
    590                     OValue* cval = gEnv.state.colorVals + idx->integer; 
     590                    OValue* cval = gEnv.state.colorVals + orInt(idx); 
    591591                    if( orIs(cval, OT_TUPLE) ) 
    592592                    { 
     
    600600 
    601601                case PRIM_KEY_UV0: 
    602                     vindex = idx->integer * 2; 
     602                    vindex = orInt(idx) * 2; 
    603603                    getVector( 2, gEnv.state.uvVals + vindex, vec ); 
    604604                    //printf( "KR UV0 %g %g\n", vec[0], vec[1] ); 
  • trunk/orca/gl/gx.c

    r42 r54  
    325325    { 
    326326        if( val->type == OT_DECIMAL ) 
    327             *vec++ = val->num.decimal; 
     327            *vec++ = orDecimal(val); 
    328328        else if( val->type == OT_INTEGER ) 
    329             *vec++ = (GLdouble) val->integer; 
     329            *vec++ = (GLdouble) orInt(val); 
    330330        else 
    331331            *vec++ = 0.0; 
     
    704704    if( a1->type == OT_INTEGER ) 
    705705    { 
    706         glCallList( a1->integer ); 
     706        glCallList( orInt(a1) ); 
    707707    } 
    708708    else 
    709709    { 
    710         DrawListResource* res = gxDList( a1->integer ); 
     710        DrawListResource* res = gxDList( orInt(a1) ); 
    711711        if( res && res->prog ) 
    712712            gxRunRenderProgram( res->prog ); 
     
    736736        else 
    737737        { 
    738             mode.id     = a1->integer; 
     738            mode.id     = orInt(a1); 
    739739            mode.width  = 0; 
    740740            mode.height = 0; 
     
    832832        if( it->type == OT_WORD ) 
    833833        { 
    834             cp = orAtomCString( it->word.atom ); 
     834            cp = orAtomCString( orAtom(it) ); 
    835835            strLen = 0; 
    836836            while( cp[ strLen ] ) 
     
    840840        else if( it->type == OT_CHAR ) 
    841841        { 
    842             ch = it->integer; 
     842            ch = orInt(it); 
    843843            if( ! ch ) 
    844844                ch = -1; 
     
    11151115    { 
    11161116        if( val->type == OT_INTEGER ) 
    1117             *dim = (double) val->integer; 
     1117            *dim = (double) orInt(val); 
    11181118        else if( val->type == OT_DECIMAL ) 
    1119             *dim = val->num.decimal; 
     1119            *dim = orDecimal(val); 
    11201120        else 
    11211121        { 
     
    11341134#define toDecimal(idx,dim) \ 
    11351135    if( val->type == OT_DECIMAL ) \ 
    1136         num[idx] = val->num.decimal * dim; \ 
     1136        num[idx] = orDecimal(val) * dim; \ 
    11371137    else if( val->type == OT_INTEGER ) \ 
    1138         num[idx] = (double) val->integer; \ 
     1138        num[idx] = (double) orInt(val); \ 
    11391139    else return 0; 
    11401140 
     
    12681268    if( a1->type == OT_WORD ) 
    12691269    { 
    1270         if( a1->word.atom == gEnv.atom_model ) 
     1270        if( orAtom(a1) == gEnv.atom_model ) 
    12711271        { 
    12721272            gxStateModel(); 
    12731273        } 
    1274         else if( a1->word.atom == gEnv.atom_solid ) 
     1274        else if( orAtom(a1) == gEnv.atom_solid ) 
    12751275        { 
    12761276            gxStateSolid(); 
     
    13891389        { 
    13901390            if( it->type == OT_DECIMAL ) 
    1391                 *pf += (float) it->num.decimal; 
     1391                *pf += (float) orDecimal(it); 
    13921392            else if( it->type == OT_INTEGER ) 
    1393                 *pf += (float) it->integer; 
     1393                *pf += (float) orInt(it); 
    13941394 
    13951395            ++pf; 
     
    14121412 
    14131413        if( a3->type == OT_DECIMAL ) 
    1414             angle = a3->num.decimal; 
     1414            angle = orDecimal(a3); 
    14151415        else if( a3->type == OT_INTEGER ) 
    1416             angle = (double) a3->integer; 
     1416            angle = (double) orInt(a3); 
    14171417        else 
    14181418            angle = 0.0; 
     
    14291429void keyRepeatNative( OValue* a1 ) 
    14301430{ 
    1431     glv_filterRepeatKeys( gView, a1->integer ); 
     1431    glv_filterRepeatKeys( gView, orInt(a1) ); 
    14321432} 
    14331433 
     
    15541554 
    15551555    if( a1->type == OT_INTEGER ) 
    1556         key = a1->integer; 
     1556        key = orInt(a1); 
    15571557    else 
    15581558        key = gxHashString(a1); 
     
    15791579 
    15801580    if( a1->type == OT_INTEGER ) 
    1581         id = a1->integer; 
     1581        id = orInt(a1); 
    15821582    else if( a1->type == OT_WORD ) 
    1583         id = a1->word.atom; 
     1583        id = orAtom(a1); 
    15841584 
    15851585    if( orRefineSet(REF_RG_FREE) ) 
  • trunk/orca/gl/joystick.c

    r1 r54  
    7070        val = cblk->values + JV_FD; 
    7171        orSetTF( val, OT_INTEGER ); 
    72         val->integer = fd; 
     72        orInt(val) = fd; 
    7373 
    7474        i = orMakeCString( name, -1 ); 
     
    7979        val = cblk->values + JV_AXIS_COUNT; 
    8080        orSetTF( val, OT_INTEGER ); 
    81         val->integer = axes; 
     81        orInt(val) = axes; 
    8282 
    8383        val = cblk->values + JV_BTN_COUNT; 
    8484        orSetTF( val, OT_INTEGER ); 
    85         val->integer = buttons; 
     85        orInt(val) = buttons; 
    8686 
    8787        blk = orMakeBlock( axes + buttons ); 
     
    9292        { 
    9393            orSetTF( val, OT_INTEGER ); 
    94             val->integer = 0; 
     94            orInt(val) = 0; 
    9595            ++val; 
    9696        } 
     
    119119    if( orIs( val, OT_INTEGER ) ) 
    120120    { 
    121         fd = val->integer; 
     121        fd = orInt(val); 
    122122        if( fd > -1 ) 
    123123        { 
     
    141141    val = vblk->values + JV_FD; 
    142142 
    143     if( orIs( val, OT_INTEGER ) && (val->integer > -1) ) 
     143    if( orIs( val, OT_INTEGER ) && (orInt(val) > -1) ) 
    144144    { 
    145145        int axes; 
     
    148148        OBlock* blk; 
    149149 
    150         fd = val->integer; 
     150        fd = orInt(val); 
    151151 
    152152        val = vblk->values + JV_AXIS_COUNT; 
    153         axes = val->integer; 
     153        axes = orInt(val); 
    154154 
    155155        val = vblk->values + JV_INPUT; 
  • trunk/orca/gl/ttf_load.c

    r37 r54  
    636636    tf  = &res->tfont; 
    637637 
    638     psize = (a1 + 2)->integer; 
     638    psize = orInt(a1 + 2); 
    639639    if( psize < 1 ) 
    640640        psize = 20; 
     
    657657        if( arg->type == OT_INTEGER ) 
    658658        { 
    659             tf->tex_width  = arg->integer; 
    660             tf->tex_height = arg->integer; 
     659            tf->tex_width  = orInt(arg); 
     660            tf->tex_height = orInt(arg); 
    661661        } 
    662662        else 
  • trunk/orca/math.c

    r42 r54  
    4242    double n; \ 
    4343    if( a1->type == OT_DECIMAL ) { \ 
    44         n = a1->num.decimal; \ 
     44        n = orDecimal(a1); \ 
    4545    } else { \ 
    46         n = (double) a1->integer; \ 
     46        n = (double) orInt(a1); \ 
    4747        orSetTF( a1, OT_DECIMAL ); \ 
    4848    } \ 
    4949    if( orRefineSet(REF_RADIANS) ) \ 
    50         a1->num.decimal = func( n ); \ 
     50        orDecimal(a1) = func( n ); \ 
    5151    else \ 
    52         a1->num.decimal = func( DEG_TO_RAD * n ); 
     52        orDecimal(a1) = func( DEG_TO_RAD * n ); 
    5353 
    5454 
     
    9494    if( a1->type == OT_DECIMAL ) 
    9595    { 
    96         n = a1->num.decimal; 
     96        n = orDecimal(a1); 
    9797    } 
    9898    else 
    9999    { 
    100         n = (double) a1->integer; 
     100        n = (double) orInt(a1); 
    101101        orSetTF( a1, OT_DECIMAL ); 
    102102    } 
    103     a1->num.decimal = mathSqrt( n ); 
     103    orDecimal(a1) = mathSqrt( n ); 
    104104} 
    105105 
     
    114114    { 
    115115        unsigned long seed;