mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 00:41:09 +01:00
[cplusplus] Enable hb_unique_ptr_t for subsystem types
The vtable specializations for hb_{raster,vector,gpu,subset}_*_t in
hb-cplusplus.hh were gated behind #ifdef HB_<SUBSYSTEM>_H, which
only fires when a subsystem public header was included BEFORE
hb-cplusplus.hh. Internal code includes hb-cplusplus.hh via hb.hh
long before any subsystem header, so those specializations never
activated — hb_unique_ptr_t<hb_raster_image_t> failed to compile.
Fix: keep the HB_DEFINE_VTABLE macro available (stop #undef'ing it at
the bottom of hb-cplusplus.hh) and add a paired tail block to each
subsystem public header that fires when HB_CPLUSPLUS_HH is already
defined. Either include order now works.
Also fix the pre-existing const-correctness drift: the subsystem
_get_user_data functions took non-const T* while the vtable_t
template (matching the core types) expects const T*. Add const to:
hb_raster_image_get_user_data
hb_raster_draw_get_user_data
hb_raster_paint_get_user_data
hb_vector_draw_get_user_data
hb_vector_paint_get_user_data
hb_gpu_draw_get_user_data
Signature-only change; all existing call sites keep compiling
because non-const arguments pass through const-pointer parameters
fine. Source-compatible for consumers too.
All 240 tests pass.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4650398a07
commit
80bed0cc9f
11 files changed
+46
-13
No files matched your search
+2
-1
@@ -192,7 +192,8 @@ HB_DEFINE_VTABLE (gpu_draw, nullptr);
|
||||
|
||||
#endif
|
||||
|
||||
#undef HB_DEFINE_VTABLE
|
||||
/* HB_DEFINE_VTABLE stays available for subsystem headers' paired tail
|
||||
* blocks (see hb-raster.h, hb-vector.h, hb-gpu.h, hb-subset.h). */
|
||||
|
||||
|
||||
} // namespace hb
|
||||
|
||||
+1
-1
@@ -969,7 +969,7 @@ hb_gpu_draw_set_user_data (hb_gpu_draw_t *draw,
|
||||
* Since: 14.0.0
|
||||
**/
|
||||
void *
|
||||
hb_gpu_draw_get_user_data (hb_gpu_draw_t *draw,
|
||||
hb_gpu_draw_get_user_data (const hb_gpu_draw_t *draw,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (draw, key);
|
||||
|
||||
+8
-1
@@ -85,7 +85,7 @@ hb_gpu_draw_set_user_data (hb_gpu_draw_t *draw,
|
||||
hb_bool_t replace);
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_gpu_draw_get_user_data (hb_gpu_draw_t *draw,
|
||||
hb_gpu_draw_get_user_data (const hb_gpu_draw_t *draw,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
|
||||
@@ -126,4 +126,11 @@ hb_gpu_draw_recycle_blob (hb_gpu_draw_t *draw,
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
||||
#if defined(__cplusplus) && defined(HB_CPLUSPLUS_HH)
|
||||
namespace hb {
|
||||
HB_DEFINE_VTABLE (gpu_draw, nullptr);
|
||||
} // namespace hb
|
||||
#endif
|
||||
|
||||
#endif /* HB_GPU_H */
|
||||
@@ -196,7 +196,7 @@ hb_raster_draw_set_user_data (hb_raster_draw_t *draw,
|
||||
* Since: 13.0.0
|
||||
**/
|
||||
void *
|
||||
hb_raster_draw_get_user_data (hb_raster_draw_t *draw,
|
||||
hb_raster_draw_get_user_data (const hb_raster_draw_t *draw,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (draw, key);
|
||||
|
||||
@@ -918,7 +918,7 @@ hb_raster_image_set_user_data (hb_raster_image_t *image,
|
||||
* Since: 13.0.0
|
||||
**/
|
||||
void *
|
||||
hb_raster_image_get_user_data (hb_raster_image_t *image,
|
||||
hb_raster_image_get_user_data (const hb_raster_image_t *image,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (image, key);
|
||||
|
||||
@@ -1814,7 +1814,7 @@ hb_raster_paint_set_user_data (hb_raster_paint_t *paint,
|
||||
* Since: 13.0.0
|
||||
**/
|
||||
void *
|
||||
hb_raster_paint_get_user_data (hb_raster_paint_t *paint,
|
||||
hb_raster_paint_get_user_data (const hb_raster_paint_t *paint,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (paint, key);
|
||||
|
||||
+12
-3
@@ -96,7 +96,7 @@ hb_raster_image_set_user_data (hb_raster_image_t *image,
|
||||
hb_bool_t replace);
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_raster_image_get_user_data (hb_raster_image_t *image,
|
||||
hb_raster_image_get_user_data (const hb_raster_image_t *image,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
@@ -155,7 +155,7 @@ hb_raster_draw_set_user_data (hb_raster_draw_t *draw,
|
||||
hb_bool_t replace);
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_raster_draw_get_user_data (hb_raster_draw_t *draw,
|
||||
hb_raster_draw_get_user_data (const hb_raster_draw_t *draw,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -247,7 +247,7 @@ hb_raster_paint_set_user_data (hb_raster_paint_t *paint,
|
||||
hb_bool_t replace);
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_raster_paint_get_user_data (hb_raster_paint_t *paint,
|
||||
hb_raster_paint_get_user_data (const hb_raster_paint_t *paint,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -324,4 +324,13 @@ hb_raster_paint_recycle_image (hb_raster_paint_t *paint,
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
||||
#if defined(__cplusplus) && defined(HB_CPLUSPLUS_HH)
|
||||
namespace hb {
|
||||
HB_DEFINE_VTABLE (raster_image, nullptr);
|
||||
HB_DEFINE_VTABLE (raster_draw, nullptr);
|
||||
HB_DEFINE_VTABLE (raster_paint, nullptr);
|
||||
} // namespace hb
|
||||
#endif
|
||||
|
||||
#endif /* HB_RASTER_H */
|
||||
@@ -298,4 +298,12 @@ hb_subset_plan_get_user_data (const hb_subset_plan_t *plan,
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
||||
#if defined(__cplusplus) && defined(HB_CPLUSPLUS_HH)
|
||||
namespace hb {
|
||||
HB_DEFINE_VTABLE (subset_input, nullptr);
|
||||
HB_DEFINE_VTABLE (subset_plan, nullptr);
|
||||
} // namespace hb
|
||||
#endif
|
||||
|
||||
#endif /* HB_SUBSET_H */
|
||||
@@ -317,7 +317,7 @@ hb_vector_draw_set_user_data (hb_vector_draw_t *draw,
|
||||
* Since: 13.0.0
|
||||
*/
|
||||
void *
|
||||
hb_vector_draw_get_user_data (hb_vector_draw_t *draw,
|
||||
hb_vector_draw_get_user_data (const hb_vector_draw_t *draw,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (draw, key);
|
||||
|
||||
@@ -928,7 +928,7 @@ hb_vector_paint_set_user_data (hb_vector_paint_t *paint,
|
||||
* Since: 13.0.0
|
||||
*/
|
||||
void *
|
||||
hb_vector_paint_get_user_data (hb_vector_paint_t *paint,
|
||||
hb_vector_paint_get_user_data (const hb_vector_paint_t *paint,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (paint, key);
|
||||
|
||||
+10
-2
@@ -114,7 +114,7 @@ hb_vector_draw_set_user_data (hb_vector_draw_t *draw,
|
||||
hb_bool_t replace);
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_vector_draw_get_user_data (hb_vector_draw_t *draw,
|
||||
hb_vector_draw_get_user_data (const hb_vector_draw_t *draw,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -203,7 +203,7 @@ hb_vector_paint_set_user_data (hb_vector_paint_t *paint,
|
||||
hb_bool_t replace);
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_vector_paint_get_user_data (hb_vector_paint_t *paint,
|
||||
hb_vector_paint_get_user_data (const hb_vector_paint_t *paint,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -290,4 +290,12 @@ hb_vector_paint_recycle_blob (hb_vector_paint_t *paint,
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
||||
#if defined(__cplusplus) && defined(HB_CPLUSPLUS_HH)
|
||||
namespace hb {
|
||||
HB_DEFINE_VTABLE (vector_draw, nullptr);
|
||||
HB_DEFINE_VTABLE (vector_paint, nullptr);
|
||||
} // namespace hb
|
||||
#endif
|
||||
|
||||
#endif /* HB_VECTOR_H */
|
||||
Reference in new issue
Block a user