Fix previous commit
Priority should be given to specific over dispatch. Broke sanitize before. This fixes it, by moving prioritization to the context implementation, since the correct priority cannot be done in the dispatch implementation. Done for subset and sanitize only, which need it.
This commit is contained in:
parent
b10f65933a
commit
c14efb8e68
|
@ -807,7 +807,7 @@ struct hb_aat_apply_context_t :
|
||||||
{
|
{
|
||||||
const char *get_name () { return "APPLY"; }
|
const char *get_name () { return "APPLY"; }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { return obj.apply (this); }
|
return_t dispatch (const T &obj) { return obj.apply (this); }
|
||||||
static return_t default_return_value () { return false; }
|
static return_t default_return_value () { return false; }
|
||||||
bool stop_sublookup_iteration (return_t r) const { return r; }
|
bool stop_sublookup_iteration (return_t r) const { return r; }
|
||||||
|
|
||||||
|
|
|
@ -49,17 +49,9 @@ struct hb_dispatch_context_t
|
||||||
bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; }
|
bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; }
|
||||||
template <typename T, typename ...Ts>
|
template <typename T, typename ...Ts>
|
||||||
return_t dispatch (const T &obj, Ts &&...ds)
|
return_t dispatch (const T &obj, Ts &&...ds)
|
||||||
{ return _dispatch_impl (obj, hb_prioritize, hb_forward<Ts> (ds)...); }
|
{ return obj.dispatch (thiz (), hb_forward<Ts> (ds)...); }
|
||||||
static return_t no_dispatch_return_value () { return Context::default_return_value (); }
|
static return_t no_dispatch_return_value () { return Context::default_return_value (); }
|
||||||
static bool stop_sublookup_iteration (const return_t r HB_UNUSED) { return false; }
|
static bool stop_sublookup_iteration (const return_t r HB_UNUSED) { return false; }
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename T, typename ...Ts>
|
|
||||||
auto _dispatch_impl (const T &obj, hb_priority<1>, Ts &&...ds) HB_AUTO_RETURN
|
|
||||||
(obj.dispatch (thiz (), hb_forward<Ts> (ds)...))
|
|
||||||
template <typename T, typename ...Ts>
|
|
||||||
Return _dispatch_impl (const T &obj, hb_priority<0>, Ts &&...ds)
|
|
||||||
{ return thiz()->_dispatch (obj, hb_forward<Ts> (ds)...); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct hb_intersects_context_t :
|
||||||
{
|
{
|
||||||
const char *get_name () { return "INTERSECTS"; }
|
const char *get_name () { return "INTERSECTS"; }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { return obj.intersects (this->glyphs); }
|
return_t dispatch (const T &obj) { return obj.intersects (this->glyphs); }
|
||||||
static return_t default_return_value () { return false; }
|
static return_t default_return_value () { return false; }
|
||||||
bool stop_sublookup_iteration (return_t r) const { return r; }
|
bool stop_sublookup_iteration (return_t r) const { return r; }
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ struct hb_closure_context_t :
|
||||||
const char *get_name () { return "CLOSURE"; }
|
const char *get_name () { return "CLOSURE"; }
|
||||||
typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index);
|
typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { obj.closure (this); return hb_void_t (); }
|
return_t dispatch (const T &obj) { obj.closure (this); return hb_void_t (); }
|
||||||
static return_t default_return_value () { return hb_void_t (); }
|
static return_t default_return_value () { return hb_void_t (); }
|
||||||
void recurse (unsigned int lookup_index)
|
void recurse (unsigned int lookup_index)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ struct hb_would_apply_context_t :
|
||||||
{
|
{
|
||||||
const char *get_name () { return "WOULD_APPLY"; }
|
const char *get_name () { return "WOULD_APPLY"; }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { return obj.would_apply (this); }
|
return_t dispatch (const T &obj) { return obj.would_apply (this); }
|
||||||
static return_t default_return_value () { return false; }
|
static return_t default_return_value () { return false; }
|
||||||
bool stop_sublookup_iteration (return_t r) const { return r; }
|
bool stop_sublookup_iteration (return_t r) const { return r; }
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ struct hb_collect_glyphs_context_t :
|
||||||
const char *get_name () { return "COLLECT_GLYPHS"; }
|
const char *get_name () { return "COLLECT_GLYPHS"; }
|
||||||
typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index);
|
typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { obj.collect_glyphs (this); return hb_void_t (); }
|
return_t dispatch (const T &obj) { obj.collect_glyphs (this); return hb_void_t (); }
|
||||||
static return_t default_return_value () { return hb_void_t (); }
|
static return_t default_return_value () { return hb_void_t (); }
|
||||||
void recurse (unsigned int lookup_index)
|
void recurse (unsigned int lookup_index)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +235,7 @@ struct hb_add_coverage_context_t :
|
||||||
const char *get_name () { return "GET_COVERAGE"; }
|
const char *get_name () { return "GET_COVERAGE"; }
|
||||||
typedef const Coverage &return_t;
|
typedef const Coverage &return_t;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { return obj.get_coverage (); }
|
return_t dispatch (const T &obj) { return obj.get_coverage (); }
|
||||||
static return_t default_return_value () { return Null(Coverage); }
|
static return_t default_return_value () { return Null(Coverage); }
|
||||||
bool stop_sublookup_iteration (return_t r) const
|
bool stop_sublookup_iteration (return_t r) const
|
||||||
{
|
{
|
||||||
|
@ -438,7 +438,7 @@ struct hb_ot_apply_context_t :
|
||||||
const char *get_name () { return "APPLY"; }
|
const char *get_name () { return "APPLY"; }
|
||||||
typedef return_t (*recurse_func_t) (hb_ot_apply_context_t *c, unsigned int lookup_index);
|
typedef return_t (*recurse_func_t) (hb_ot_apply_context_t *c, unsigned int lookup_index);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj) { return obj.apply (this); }
|
return_t dispatch (const T &obj) { return obj.apply (this); }
|
||||||
static return_t default_return_value () { return false; }
|
static return_t default_return_value () { return false; }
|
||||||
bool stop_sublookup_iteration (return_t r) const { return r; }
|
bool stop_sublookup_iteration (return_t r) const { return r; }
|
||||||
return_t recurse (unsigned int sub_lookup_index)
|
return_t recurse (unsigned int sub_lookup_index)
|
||||||
|
@ -648,7 +648,7 @@ struct hb_get_subtables_context_t :
|
||||||
/* Dispatch interface. */
|
/* Dispatch interface. */
|
||||||
const char *get_name () { return "GET_SUBTABLES"; }
|
const char *get_name () { return "GET_SUBTABLES"; }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
return_t _dispatch (const T &obj)
|
return_t dispatch (const T &obj)
|
||||||
{
|
{
|
||||||
hb_applicable_t *entry = array.push();
|
hb_applicable_t *entry = array.push();
|
||||||
entry->init (obj, apply_to<T>);
|
entry->init (obj, apply_to<T>);
|
||||||
|
|
|
@ -130,13 +130,23 @@ struct hb_sanitize_context_t :
|
||||||
template <typename T, typename F>
|
template <typename T, typename F>
|
||||||
bool may_dispatch (const T *obj HB_UNUSED, const F *format)
|
bool may_dispatch (const T *obj HB_UNUSED, const F *format)
|
||||||
{ return format->sanitize (this); }
|
{ return format->sanitize (this); }
|
||||||
template <typename T, typename ...Ts>
|
|
||||||
return_t _dispatch (const T &obj, Ts &&...ds)
|
|
||||||
{ return obj.sanitize (this, hb_forward<Ts> (ds)...); }
|
|
||||||
static return_t default_return_value () { return true; }
|
static return_t default_return_value () { return true; }
|
||||||
static return_t no_dispatch_return_value () { return false; }
|
static return_t no_dispatch_return_value () { return false; }
|
||||||
bool stop_sublookup_iteration (const return_t r) const { return !r; }
|
bool stop_sublookup_iteration (const return_t r) const { return !r; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T, typename ...Ts> auto
|
||||||
|
_dispatch (const T &obj, hb_priority<1>, Ts &&...ds) HB_AUTO_RETURN
|
||||||
|
( obj.sanitize (this, hb_forward<Ts> (ds)...) )
|
||||||
|
template <typename T, typename ...Ts> auto
|
||||||
|
_dispatch (const T &obj, hb_priority<0>, Ts &&...ds) HB_AUTO_RETURN
|
||||||
|
( obj.dispatch (this, hb_forward<Ts> (ds)...) )
|
||||||
|
public:
|
||||||
|
template <typename T, typename ...Ts> auto
|
||||||
|
dispatch (const T &obj, Ts &&...ds) HB_AUTO_RETURN
|
||||||
|
( _dispatch (obj, hb_prioritize, hb_forward<Ts> (ds)...) )
|
||||||
|
|
||||||
|
|
||||||
void init (hb_blob_t *b)
|
void init (hb_blob_t *b)
|
||||||
{
|
{
|
||||||
this->blob = hb_blob_reference (b);
|
this->blob = hb_blob_reference (b);
|
||||||
|
|
|
@ -40,11 +40,20 @@ struct hb_subset_context_t :
|
||||||
hb_dispatch_context_t<hb_subset_context_t, bool, HB_DEBUG_SUBSET>
|
hb_dispatch_context_t<hb_subset_context_t, bool, HB_DEBUG_SUBSET>
|
||||||
{
|
{
|
||||||
const char *get_name () { return "SUBSET"; }
|
const char *get_name () { return "SUBSET"; }
|
||||||
template <typename T, typename ...Ts>
|
|
||||||
return_t _dispatch (const T &obj, Ts &&...ds)
|
|
||||||
{ return obj.subset (this, hb_forward<Ts> (ds)...); }
|
|
||||||
static return_t default_return_value () { return true; }
|
static return_t default_return_value () { return true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T, typename ...Ts> auto
|
||||||
|
_dispatch (const T &obj, hb_priority<1>, Ts &&...ds) HB_AUTO_RETURN
|
||||||
|
( obj.subset (this, hb_forward<Ts> (ds)...) )
|
||||||
|
template <typename T, typename ...Ts> auto
|
||||||
|
_dispatch (const T &obj, hb_priority<0>, Ts &&...ds) HB_AUTO_RETURN
|
||||||
|
( obj.dispatch (this, hb_forward<Ts> (ds)...) )
|
||||||
|
public:
|
||||||
|
template <typename T, typename ...Ts> auto
|
||||||
|
dispatch (const T &obj, Ts &&...ds) HB_AUTO_RETURN
|
||||||
|
( _dispatch (obj, hb_prioritize, hb_forward<Ts> (ds)...) )
|
||||||
|
|
||||||
hb_subset_plan_t *plan;
|
hb_subset_plan_t *plan;
|
||||||
hb_serialize_context_t *serializer;
|
hb_serialize_context_t *serializer;
|
||||||
unsigned int debug_depth;
|
unsigned int debug_depth;
|
||||||
|
|
Loading…
Reference in New Issue