Synced const-correctness in ui_attrstr.h to attrstr.c, propagated that to the necessary private functions, and added some references to testing.h.

This commit is contained in:
Pietro Gagliardi 2018-03-04 11:15:18 -05:00
parent 77c07075e3
commit 9c8f6849c3
4 changed files with 17 additions and 13 deletions

View File

@ -43,6 +43,10 @@ extern "C" {
static inline void testingprivScaffold ## name(testingT *t) { name(t); }
#endif
// references:
// - https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gconstructor.h
// - https://gitlab.gnome.org/GNOME/glib/blob/master/gio/glib-compile-resources.c
// - https://msdn.microsoft.com/en-us/library/bb918180.aspx
#if defined(__cplusplus)
#define testingprivMkCtor(name, reg) \
static reg ## Class testingprivCtor ## name(#name, testingprivScaffold ## name);

View File

@ -598,7 +598,7 @@ void uiprivAttrListRemoveCharacters(uiprivAttrList *alist, size_t start, size_t
a = attrDeleteRange(alist, a, start, end);
}
void uiprivAttrListForEach(uiprivAttrList *alist, uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data)
void uiprivAttrListForEach(const uiprivAttrList *alist, const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data)
{
struct attr *a;
uiForEach ret;

View File

@ -279,6 +279,17 @@ void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end)
resize(s, start + count, start16 + count16);
}
void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t start, size_t end)
{
uiprivAttrListInsertAttribute(s->attrs, spec, start, end);
}
// LONGTERM introduce an iterator object instead?
void uiAttributedStringForEachAttribute(const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data)
{
uiprivAttrListForEach(s->attrs, s, f, data);
}
// TODO figure out if we should count the grapheme past the end
size_t uiAttributedStringNumGraphemes(uiAttributedString *s)
{
@ -303,17 +314,6 @@ size_t uiAttributedStringGraphemeToByteIndex(uiAttributedString *s, size_t pos)
return pos;
}
void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t start, size_t end)
{
uiprivAttrListInsertAttribute(s->attrs, spec, start, end);
}
// LONGTERM introduce an iterator object instead?
void uiAttributedStringForEachAttribute(uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data)
{
uiprivAttrListForEach(s->attrs, s, f, data);
}
// helpers for platform-specific code
const uint16_t *uiprivAttributedStringUTF16String(uiAttributedString *s)

View File

@ -18,7 +18,7 @@ extern void uiprivAttrListInsertCharactersExtendingAttributes(uiprivAttrList *al
extern void uiprivAttrListRemoveAttribute(uiprivAttrList *alist, uiAttribute type, size_t start, size_t end);
extern void uiprivAttrListRemoveAttributes(uiprivAttrList *alist, size_t start, size_t end);
extern void uiprivAttrListRemoveCharacters(uiprivAttrList *alist, size_t start, size_t end);
extern void uiprivAttrListForEach(uiprivAttrList *alist, uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data);
extern void uiprivAttrListForEach(const uiprivAttrList *alist, const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data);
// attrstr.c
extern const uint16_t *uiprivAttributedStringUTF16String(uiAttributedString *s);