Example #1
0
static EJSPropertyDesc*
_ejs_dataview_specop_get_own_property (ejsval obj, ejsval propertyName)
{
    if (EJSVAL_IS_NUMBER(propertyName)) {
        double needle = EJSVAL_TO_NUMBER(propertyName);
        int needle_int;
        if (EJSDOUBLE_IS_INT32(needle, &needle_int)) {
            if (needle_int >= 0 && needle_int < EJS_DATA_VIEW_BYTE_LEN(obj))
                return NULL; // XXX
        }
    }

    return _ejs_Object_specops.get_own_property (obj, propertyName);
}
Example #2
0
ejsval NumberToString(double d)
{
    int32_t i;
    if (EJSDOUBLE_IS_INT32(d, &i)) {
        if (i >=0 && i <= 200)
            return *builtin_numbers_atoms[i];
        jschar int_buf[UINT32_CHAR_BUFFER_LENGTH+1];
        jschar *cp = IntToUCS2(int_buf, i, 10);
        return _ejs_string_new_ucs2 (cp);
    }

    char num_buf[256];
    snprintf (num_buf, sizeof(num_buf), EJS_NUMBER_FORMAT, d);
    return _ejs_string_new_utf8 (num_buf);
}
Example #3
0
static EJSPropertyDesc*
_ejs_arraybuffer_specop_get_own_property (ejsval obj, ejsval propertyName)
{
    if (EJSVAL_IS_NUMBER(propertyName)) {
        double needle = EJSVAL_TO_NUMBER(propertyName);
        int needle_int;
        if (EJSDOUBLE_IS_INT32(needle, &needle_int)) {
            if (needle_int >= 0 && needle_int < EJS_ARRAY_LEN(obj))
                return NULL; // XXX
        }
    }

    // XXX we need to handle the length property here (see EJSArray's get_own_property)

    return _ejs_Object_specops.get_own_property (obj, propertyName);
}