Exemple #1
0
*/ RL_API u32 *RL_Words_Of_Object(REBSER *obj)
/*
**	Returns information about the object.
**
**	Returns:
**		Returns an array of words used as fields of the object.
**	Arguments:
**		obj  - object pointer (e.g. from RXA_OBJECT)
**	Notes:
**		Returns a word array similar to MAP_WORDS().
**		The array is allocated with OS_ALLOC. You can OS_FREE it any time.
**
***********************************************************************/
{
	REBCNT index;
	u32 *syms;
	REBVAL *keys;

	keys = FRM_KEY(obj, 1);
	// One less, because SELF not included.
	syms = OS_ALLOC_ARRAY(u32, obj->tail);
	for (index = 0; index < (obj->tail - 1); keys++, index++) {
		syms[index] = VAL_TYPESET_CANON(keys);
	}
	syms[index] = 0;
	return syms;
}
Exemple #2
0
//
//  RL_Words_Of_Object: C
// 
// Returns information about the object.
// 
// Returns:
//     Returns an array of words used as fields of the object.
// Arguments:
//     obj  - object pointer (e.g. from RXA_OBJECT)
// Notes:
//     Returns a word array similar to MAP_WORDS().
//     The array is allocated with OS_ALLOC. You can OS_FREE it any time.
//
RL_API u32 *RL_Words_Of_Object(REBSER *obj)
{
    REBCNT index;
    u32 *syms;
    REBVAL *key;
    REBCTX *context = AS_CONTEXT(obj);

    key = CTX_KEYS_HEAD(context);

    // We don't include hidden keys (e.g. SELF), but terminate by 0.
    // Conservative estimate that there are no hidden keys, add one.
    //
    syms = OS_ALLOC_N(u32, CTX_LEN(context) + 1);

    index = 0;
    for (; NOT_END(key); key++) {
        if (GET_VAL_FLAG(key, TYPESET_FLAG_HIDDEN))
            continue;

        syms[index] = VAL_TYPESET_CANON(key);
        index++;
    }

    syms[index] = SYM_0; // Null terminate

    return syms;
}