/* writeValue - write a value */
bool write_ctx::writeValue(value v)
{
    if (v == UNDEFINED_VALUE)
        return s->put(CsFaslTagUndefined);
    else if (v == NULL_VALUE)
        return s->put(CsFaslTagNull);
    else if (v == TRUE_VALUE)
        return s->put(CsFaslTagTrue);
    else if (v == FALSE_VALUE)
        return s->put(CsFaslTagFalse);
    else if (CsCompiledCodeP(v))
        return writeCodeValue(v);
    else if (CsVectorP(v))
    {
        uint n = 0;
        if(object2id.find(v,n))
          return writeProxyValue(n);
        else
        {
          n = object2id.size();
          object2id[v] = n;
          return writeVectorValue(v);
        }
    }
    else if (CsObjectP(v))
    {
        uint n = 0;
        if(object2id.find(v,n))
          return writeProxyValue(n);
        else
        {
          n = object2id.size();
          object2id[v] = n;
          return writeObjectValue(v);
        }
    }
    else if (CsSymbolP(v))
        return writeSymbolValue(v);
    else if (CsStringP(v))
        return writeStringValue(v);
    else if (CsIntegerP(v))
        return writeIntegerValue(v);
    else if (CsFloatP(v))
        return writeFloatValue(v);
    else if (CsTupleP(v))
        return writeTupleValue(v);
    else if (CsByteVectorP(v))
        return writeByteVectorValue(v);
    else if (CsDateP(c,v))
        return writeDateValue(v);
    else if (CsColorP(v))
        return writeColorValue(v);
    else if (CsLengthP(v))
        return writeLengthValue(v);
    else if (CsAngleP(v))
        return writeAngleValue(v);
    else if (CsDurationP(v))
        return writeDurationValue(v);
    else {
#ifdef _DEBUG
        dispatch* pd = CsGetDispatch(v);
#endif
        assert(false);
        return false;
    }
}
Exemplo n.º 2
0
/* FloatValue - convert a value to float */
static float_t FloatValue(value val)
{
    if (CsFloatP(val))
        return CsFloatValue(val);
    return (float_t)CsIntegerValue(val);
}