Changeset 105 for trunk/orca/ovalue.c

Show
Ignore:
Timestamp:
03/30/06 14:50:55 (3 years ago)
Author:
krobillard
Message:

Can now make binary! from string!.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/ovalue.c

    r99 r105  
    641641 
    642642 
     643/* 
     644   Returns non-zero of successful. 
     645*/ 
    643646static int orMake( int type, OValue* from, OValue* res ) 
    644647{ 
     
    651654        case OT_GETWORD: 
    652655        case OT_LITWORD: 
    653             if( from->type == OT_STRING ) 
     656            if( orIs(from, OT_STRING) ) 
    654657            { 
    655658                OContext ctx; 
     
    662665                return 1; 
    663666            } 
    664             else if( from->type == OT_WORD ) 
     667            else if( orIs(from, OT_WORD) ) 
    665668            { 
    666669                res->word = from->word; 
     
    683686 
    684687        case OT_INTEGER: 
    685             if( from->type == OT_LOGIC ) 
     688            if( orIs(from, OT_LOGIC) ) 
    686689            { 
    687690                orInt(res) = orInt(from); 
    688691                return 1; 
    689692            } 
    690             else if( from->type == OT_DECIMAL ) 
     693            else if( orIs(from, OT_DECIMAL) ) 
    691694            { 
    692695                orInt(res) = (int) orDecimal(from); 
    693696                return 1; 
    694697            } 
    695             else if( from->type == OT_STRING ) 
     698            else if( orIs(from, OT_STRING) ) 
    696699            { 
    697700                OString* str = orSTRING(from); 
     
    706709 
    707710        case OT_DECIMAL: 
    708             if( (from->type == OT_INTEGER) || 
    709                 (from->type == OT_LOGIC) ) 
     711            if( orIs(from, OT_INTEGER) || 
     712                orIs(from, OT_LOGIC) ) 
    710713            { 
    711714                orDecimal(res) = (double) orInt(from); 
     
    725728 
    726729        case OT_PAIR: 
    727             if( from->type == OT_BLOCK ) 
     730            if( orIs(from, OT_BLOCK) ) 
    728731            { 
    729732                OBlock* blk = orBLOCK( from ); 
     
    744747 
    745748        case OT_TUPLE: 
    746             if( from->type == OT_BLOCK ) 
     749            if( orIs(from, OT_BLOCK) ) 
    747750            { 
    748751                OBlock* blk = orBLOCK( from ); 
     
    768771            } 
    769772            break; 
     773 
     774        case OT_BINARY: 
     775            if( orIs(from, OT_STRING) ) 
     776            { 
     777                OString* str; 
     778                OBinary* bin; 
     779                int len; 
     780 
     781                str = orSTRING( from ); 
     782                len = str->used - from->series.it; 
     783 
     784                bin = orMakeBinary( len ); 
     785                bin->used = len; 
     786                memCpy(bin->byteArray, str->charArray + from->series.it, len);  
     787 
     788                orSetTF( res, OT_BINARY ); 
     789                orSetSeries( res, orBinaryN(bin), 0 ); 
     790                return 1; 
     791            } 
     792            break; 
    770793    } 
    771794 
     
    777800static OBinary* _makeBitset( OBlock* blk, int index ); 
    778801 
    779 void orMakeNative( OValue* a1 ) 
     802OR_NATIVE( orMakeNative ) 
    780803{ 
    781804    OValue* a2 = a1 + 1;