OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2012 Google, Inc. | 2 * Copyright © 2012 Google, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##
object##_data_destroy | 72 #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##
object##_data_destroy |
73 | 73 |
74 #define HB_SHAPER_DATA_PROTOTYPE(shaper, object) \ | 74 #define HB_SHAPER_DATA_PROTOTYPE(shaper, object) \ |
75 HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \ | 75 HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \ |
76 extern "C" HB_INTERNAL HB_SHAPER_DATA_TYPE (shaper, object) * \ | 76 extern "C" HB_INTERNAL HB_SHAPER_DATA_TYPE (shaper, object) * \ |
77 HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object HB_
SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS); \ | 77 HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object HB_
SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS); \ |
78 extern "C" HB_INTERNAL void \ | 78 extern "C" HB_INTERNAL void \ |
79 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shape
r, object) *data) | 79 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shape
r, object) *data) |
80 | 80 |
81 #define HB_SHAPER_DATA_DESTROY(shaper, object) \ | 81 #define HB_SHAPER_DATA_DESTROY(shaper, object) \ |
82 » if (object->shaper_data.shaper && \ | 82 if (HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, obj
ect)) \ |
83 » object->shaper_data.shaper != HB_SHAPER_DATA_INVALID && \ | 83 if (data != HB_SHAPER_DATA_INVALID && data != HB_SHAPER_DATA_SUCCEEDED) \ |
84 » object->shaper_data.shaper != HB_SHAPER_DATA_SUCCEEDED) \ | 84 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); |
85 » HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA (shaper,
object)); | |
86 | 85 |
87 #define HB_SHAPER_DATA_ENSURE_DECLARE(shaper, object) \ | 86 #define HB_SHAPER_DATA_ENSURE_DECLARE(shaper, object) \ |
88 static inline bool \ | 87 static inline bool \ |
89 hb_##shaper##_shaper_##object##_data_ensure (hb_##object##_t *object) \ | 88 hb_##shaper##_shaper_##object##_data_ensure (hb_##object##_t *object) \ |
90 {\ | 89 {\ |
91 retry: \ | 90 retry: \ |
92 HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, obj
ect) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \ | 91 HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, obj
ect) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \ |
93 if (unlikely (!data)) { \ | 92 if (unlikely (!data)) { \ |
94 data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \ | 93 data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \ |
95 if (unlikely (!data)) \ | 94 if (unlikely (!data)) \ |
96 data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \ | 95 data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \ |
97 if (!hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), NULL, data)) {
\ | 96 if (!hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), NULL, data)) {
\ |
98 if (data && \ | 97 if (data && \ |
99 data != HB_SHAPER_DATA_INVALID && \ | 98 data != HB_SHAPER_DATA_INVALID && \ |
100 data != HB_SHAPER_DATA_SUCCEEDED) \ | 99 data != HB_SHAPER_DATA_SUCCEEDED) \ |
101 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \ | 100 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \ |
102 goto retry; \ | 101 goto retry; \ |
103 } \ | 102 } \ |
104 } \ | 103 } \ |
105 return data != NULL && !HB_SHAPER_DATA_IS_INVALID (data); \ | 104 return data != NULL && !HB_SHAPER_DATA_IS_INVALID (data); \ |
106 } | 105 } |
107 | 106 |
108 | 107 |
109 #endif /* HB_SHAPER_PRIVATE_HH */ | 108 #endif /* HB_SHAPER_PRIVATE_HH */ |
OLD | NEW |