Exemplo n.º 1
0
static void blitrow_d16_si8(SK_RESTRICT uint16_t* dst,
                            SK_RESTRICT const uint8_t* src, int count,
                            SK_RESTRICT const uint16_t* ctable) {
    if (count <= 8) {
        do {
            *dst++ = ctable[*src++];
        } while (--count);
        return;
    }

    // eat src until we're on a 4byte boundary
    while (asint(src) & 3) {
        *dst++ = ctable[*src++];
        count -= 1;
    }

    int qcount = count >> 2;
    SkASSERT(qcount > 0);
    const uint32_t* qsrc = reinterpret_cast<const uint32_t*>(src);
    if (asint(dst) & 2) {
        do {
            uint32_t s4 = *qsrc++;
#ifdef SK_CPU_LENDIAN
            *dst++ = ctable[s4 & 0xFF];
            *dst++ = ctable[(s4 >> 8) & 0xFF];
            *dst++ = ctable[(s4 >> 16) & 0xFF];
            *dst++ = ctable[s4 >> 24];
#else   // BENDIAN
            *dst++ = ctable[s4 >> 24];
            *dst++ = ctable[(s4 >> 16) & 0xFF];
            *dst++ = ctable[(s4 >> 8) & 0xFF];
            *dst++ = ctable[s4 & 0xFF];
#endif
        } while (--qcount);
    } else {    // dst is on a 4byte boundary
Exemplo n.º 2
0
void tojson(BYTE* buffer, int level, int isarray)
{  
    int i = 0;    
    printf ((isarray) ? "[" : "{");
    if (*buffer)
    {
        do 
        {
            if (i>0)
                printf(",");
            printf ("\n");            
            addtabs(level); 
            if (!isarray)
            {                                
                printf("\"%s\": ", getkey(buffer));
            }                    
            switch (gettype(buffer))
            {
                case BT_INT32BIT:
                    printf("%d", asint(getvalue(buffer)));
                    break;
                case BT_FLOP64BIT:
                    printf("%lf", asdouble(getvalue(buffer)));
                    break;
                case BT_BOOLFALSETRUE:
                    printf("%s", (asboolean(getvalue(buffer)) ? "true" : "false"));
                    break;
                case BT_UTF8STRING:
                    printf("\"%s\"", asstring(getvalue(buffer)));
                    break;
                case BT_EMBEDEDDOC:
                    tojson(opendoc(getvalue(buffer), 0), level + 1, 0);                                
                    break;
                case BT_ARRAY:                 
                    tojson(opendoc(getvalue(buffer), 0), level + 1, 1);                
                    break;
                default:
                    printf(" \"(0x%X) __NOTIMPLEMENTED__\"", gettype(buffer));
            }
            
            i++;
            //getchar();
        } while (*(buffer = nextitem(buffer)));           
        printf ("\n"); 
        addtabs(level - 1);
    }
       
    printf ((isarray) ? "]" : "}");
    if (errorno)
        printf ("ERROR #%d\n", errorno);    
}