Add FcPatternGetWithBinding() to obtain the binding type of the value in FcPattern.

https://bugs.freedesktop.org/show_bug.cgi?id=19375
This commit is contained in:
Akira TAGOH 2015-07-28 12:48:40 +09:00
parent 01085e0785
commit ee2000494c
4 changed files with 47 additions and 9 deletions

View File

@ -198,6 +198,23 @@ any existing list of values.
<function>FcPatternAddRange</function> are available since 2.11.91.
@@
@RET@ FcResult
@FUNC@ FcPatternGetWithBinding
@TYPE1@ FcPattern * @ARG1@ p
@TYPE2@ const char * @ARG2@ object
@TYPE3@ int% @ARG3@ id
@TYPE4@ FcValue * @ARG4@ v
@TYPE5@ FcValueBinding * @ARG5@ b
@PURPOSE@ Return a value with binding from a pattern
@DESC@
Returns in <parameter>v</parameter> the <parameter>id</parameter>'th value
and <parameter>b</parameter> binding for that associated with the property
<parameter>object</parameter>.
The Value returned is not a copy, but rather refers to the data stored
within the pattern directly. Applications must not free this value.
@SINCE@ 2.13.0
@@
@RET@ FcResult
@FUNC@ FcPatternGet
@TYPE1@ FcPattern * @ARG1@ p

View File

@ -28,6 +28,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <limits.h>
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define FC_ATTRIBUTE_SENTINEL(x) __attribute__((__sentinel__(0)))
@ -236,6 +237,12 @@ typedef enum _FcResult {
FcResultOutOfMemory
} FcResult;
typedef enum _FcValueBinding {
FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame,
/* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */
FcValueBindingEnd = INT_MAX
} FcValueBinding;
typedef struct _FcPattern FcPattern;
typedef struct _FcLangSet FcLangSet;
@ -837,7 +844,10 @@ FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append
FcPublic FcResult
FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v);
FcPublic FcResult
FcPatternGetWithBinding (const FcPattern *p, const char *object, int id, FcValue *v, FcValueBinding *b);
FcPublic FcBool
FcPatternDel (FcPattern *p, const char *object);

View File

@ -116,12 +116,6 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
typedef enum _FcValueBinding {
FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame,
/* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */
FcValueBindingEnd = INT_MAX
} FcValueBinding;
#define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s)))
#define FcFree(s) (free ((FcChar8 *) (s)))
@ -999,6 +993,9 @@ FcPatternObjectAdd (FcPattern *p, FcObject object, FcValue value, FcBool append)
FcPrivate FcBool
FcPatternObjectAddWeak (FcPattern *p, FcObject object, FcValue value, FcBool append);
FcPrivate FcResult
FcPatternObjectGetWithBinding (const FcPattern *p, FcObject object, int id, FcValue *v, FcValueBinding *b);
FcPrivate FcResult
FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v);

View File

@ -883,7 +883,7 @@ FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r)
}
FcResult
FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
FcPatternObjectGetWithBinding (const FcPattern *p, FcObject object, int id, FcValue *v, FcValueBinding *b)
{
FcPatternElt *e;
FcValueListPtr l;
@ -898,6 +898,8 @@ FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
if (!id)
{
*v = FcValueCanonicalize(&l->value);
if (b)
*b = l->binding;
return FcResultMatch;
}
id--;
@ -905,10 +907,22 @@ FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
return FcResultNoId;
}
FcResult
FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v)
{
return FcPatternObjectGetWithBinding (p, object, id, v, NULL);
}
FcResult
FcPatternGetWithBinding (const FcPattern *p, const char *object, int id, FcValue *v, FcValueBinding *b)
{
return FcPatternObjectGetWithBinding (p, FcObjectFromName (object), id, v, b);
}
FcResult
FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v)
{
return FcPatternObjectGet (p, FcObjectFromName (object), id, v);
return FcPatternObjectGetWithBinding (p, FcObjectFromName (object), id, v, NULL);
}
FcResult