rt_public long ei_offset_of_type(long i, EIF_ENCODED_TYPE enc_ftype) /* Returns the memory address of the i-th field of objects of type `enc_ftype'. */ { EIF_TYPE_INDEX dtype = To_dtype(eif_decoded_type(enc_ftype).id); uint32 offset; offset = wattr(System(dtype).cn_attr[i - 1], dtype); return offset; }
rt_public void * ei_oref(long i, EIF_REFERENCE object) /* Returns the memory address of the i-th field of `object'. */ { EIF_TYPE_INDEX dtype = Dtype(object); uint32 offset; offset = wattr(System(dtype).cn_attr[i], dtype); return object + offset; }
void CursesAction::drawImpl() { if(isDisabled()) { wbkgd(hnd(), COLOR_PAIR(2)); wattrset(hnd(), 0); } else { bool menuOpen = _menu && _menu->isOpen(); bool standout = menuOpen || wattr().testFlag(Focused); if(_blink) standout = !standout; int attr = standout ? A_STANDOUT : A_NORMAL; if(_activateWait || menuOpen) attr |= A_BOLD; else if(isDisabled()) attr |= A_DIM; wbkgd(hnd(), COLOR_PAIR(1)); wattrset(hnd(), attr); } char space = isDisabled() || has_colors() ? ' ' : ACS_CKBOARD; wmove(hnd(), 0, 0); waddch(hnd(), space); foreach(char c, text().toLocal8Bit()) { if(c == '_') { if(!isDisabled()) wattron(hnd(), A_UNDERLINE); continue; } else if(c == ' ') c = space; waddch(hnd(), c); wattroff(hnd(), A_UNDERLINE); } waddch(hnd(), space); int left = width() - 2 - text().length(); while(left > 0) { waddch(hnd(), ' '); left--; } }
rt_public char *ei_field (long i, EIF_REFERENCE object) { /* Returns the object referenced by the i_th field of `object'. * Take care of normal and expanded types. */ const struct cnode *obj_desc; EIF_TYPE_INDEX dtype = Dtype(object); uint32 field_type; long offset; obj_desc = &System(dtype); field_type = obj_desc->cn_types[i]; #ifndef WORKBENCH offset = obj_desc->cn_offsets[i]; #else offset = wattr(obj_desc->cn_attr[i], dtype); #endif return ei_field_at (offset, field_type, object); }
rt_private void eif_std_field_copy (EIF_REFERENCE source, EIF_REFERENCE target) { EIF_TYPE_INDEX dtype = Dtype(target); /* Doesn't matter to take target or source since they are supposed to be the same type.*/ const struct cnode *skeleton = &System(dtype); long index; /* Target attribute index */ long offset; EIF_REFERENCE t_ref, s_ref; #ifndef WORKBENCH const long *offsets = skeleton->cn_offsets; /* Target attribute offsets. */ #else const int32 *cn_attr = skeleton->cn_attr; /* Array of attribute keys for target object */ int32 attr_key; /* Attribute key */ #endif for (index = skeleton->cn_nbattr - 1; index >= 0; index--) { #ifndef WORKBENCH offset = offsets[index]; t_ref = target + offset; s_ref = source + offset; #else /* Evaluation of the attribute key */ attr_key = cn_attr[index]; /* Evaluation of the target attribute offset */ offset = wattr(attr_key, dtype); t_ref = target + offset; /* Evaluation of the source attribute offset */ /* It is the same as the target, since they have the same dynamic type */ s_ref = source + offset; #endif switch (skeleton->cn_types[index] & SK_HEAD) { case SK_BOOL: case SK_CHAR8: *t_ref = *s_ref; break; case SK_CHAR32: *(EIF_CHARACTER_32 *) t_ref = *(EIF_CHARACTER_32 *) s_ref; break; case SK_UINT8: *(EIF_NATURAL_8 *) t_ref = *(EIF_NATURAL_8 *) s_ref; break; case SK_UINT16: *(EIF_NATURAL_16 *) t_ref = *(EIF_NATURAL_16 *) s_ref; break; case SK_UINT32: *(EIF_NATURAL_32 *) t_ref = *(EIF_NATURAL_32 *) s_ref; break; case SK_UINT64: *(EIF_NATURAL_64 *) t_ref = *(EIF_NATURAL_64 *) s_ref; break; case SK_INT8: *(EIF_INTEGER_8 *) t_ref = *(EIF_INTEGER_8 *) s_ref; break; case SK_INT16: *(EIF_INTEGER_16 *) t_ref = *(EIF_INTEGER_16 *) s_ref; break; case SK_INT32: *(EIF_INTEGER_32 *) t_ref = *(EIF_INTEGER_32 *) s_ref; break; case SK_INT64: *(EIF_INTEGER_64 *) t_ref = *(EIF_INTEGER_64 *) s_ref; break; case SK_REAL32: *(EIF_REAL_32 *) t_ref = *(EIF_REAL_32 *) s_ref; break; case SK_REAL64: *(EIF_REAL_64 *) t_ref = *(EIF_REAL_64 *) s_ref; break; case SK_POINTER: *(EIF_POINTER *) t_ref = *(EIF_POINTER *) s_ref; break; case SK_EXP: eif_std_ref_copy (s_ref, t_ref); break; default: *(EIF_REFERENCE *)t_ref = *(EIF_REFERENCE *)s_ref; break; } } }