#include "cvector.h"
#include "cvectorvector.h"

#if HB_CHECK_VERSION(1, 7, 7)
hb_blob_t*
mlton_hb_blob_create_from_file (SML_CVECTOR_VAL(const char, file_name))
{
  return hb_blob_create_from_file (GET_SML_CVECTOR_VAL(const char, file_name));
}
#endif

#if HB_CHECK_VERSION(0, 9, 31)
void
mlton_hb_buffer_add_codepoints (hb_buffer_t* buffer,
                                SML_CVECTOR_VAL(const hb_codepoint_t, text),
                                int text_length,
                                unsigned int item_offset,
                                int item_length)
{
  hb_buffer_add_codepoints (buffer,
                            GET_SML_CVECTOR_VAL(const hb_codepoint_t, text),
                            text_length,
                            item_offset,
                            item_length);
}
#endif

#if HB_CHECK_VERSION(0, 9, 39)
void
mlton_hb_buffer_add_latin1 (hb_buffer_t* buffer,
                            SML_CVECTOR_VAL(const uint8_t, text),
                            int text_length,
                            unsigned int item_offset,
                            int item_length)
{
  hb_buffer_add_latin1 (buffer,
                        GET_SML_CVECTOR_VAL(const uint8_t, text),
                        text_length,
                        item_offset,
                        item_length);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
void
mlton_hb_buffer_add_utf16 (hb_buffer_t* buffer,
                           SML_CVECTOR_VAL(const uint16_t, text),
                           int text_length,
                           unsigned int item_offset,
                           int item_length)
{
  hb_buffer_add_utf16 (buffer,
                       GET_SML_CVECTOR_VAL(const uint16_t, text),
                       text_length,
                       item_offset,
                       item_length);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
void
mlton_hb_buffer_add_utf32 (hb_buffer_t* buffer,
                           SML_CVECTOR_VAL(const uint32_t, text),
                           int text_length,
                           unsigned int item_offset,
                           int item_length)
{
  hb_buffer_add_utf32 (buffer,
                       GET_SML_CVECTOR_VAL(const uint32_t, text),
                       text_length,
                       item_offset,
                       item_length);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
void
mlton_hb_buffer_add_utf8 (hb_buffer_t* buffer,
                          SML_CVECTOR_VAL(const char, text),
                          int text_length,
                          unsigned int item_offset,
                          int item_length)
{
  hb_buffer_add_utf8 (buffer,
                      GET_SML_CVECTOR_VAL(const char, text),
                      text_length,
                      item_offset,
                      item_length);
}
#endif

#if HB_CHECK_VERSION(0, 9, 7)
hb_buffer_serialize_format_t
mlton_hb_buffer_serialize_format_from_string (SML_CVECTOR_VAL(const char, str),
                                              int len)
{
  return hb_buffer_serialize_format_from_string (GET_SML_CVECTOR_VAL(const char, str),
                                                 len);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
hb_direction_t
mlton_hb_direction_from_string (SML_CVECTOR_VAL(const char, str),
                                int len)
{
  return hb_direction_from_string (GET_SML_CVECTOR_VAL(const char, str),
                                   len);
}
#endif

#if HB_CHECK_VERSION(0, 9, 5)
hb_bool_t
mlton_hb_feature_from_string (SML_CVECTOR_VAL(const char, str),
                              int len,
                              hb_feature_t* feature)
{
  return hb_feature_from_string (GET_SML_CVECTOR_VAL(const char, str),
                                 len,
                                 feature);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
hb_bool_t
mlton_hb_font_glyph_from_string (hb_font_t* font,
                                 SML_CVECTOR_VAL(const char, s),
                                 int len,
                                 hb_codepoint_t* glyph)
{
  return hb_font_glyph_from_string (font,
                                    GET_SML_CVECTOR_VAL(const char, s),
                                    len,
                                    glyph);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
hb_language_t
mlton_hb_language_from_string (SML_CVECTOR_VAL(const char, str),
                               int len)
{
  return hb_language_from_string (GET_SML_CVECTOR_VAL(const char, str),
                                  len);
}
#endif

#if HB_CHECK_VERSION(2, 1, 0)
unsigned int
mlton_hb_ot_name_get_utf16 (hb_face_t* face,
                            hb_ot_name_id_t name_id,
                            hb_language_t language,
                            unsigned int* text_size,
                            SML_CVECTOR_VAL(uint16_t, text))
{
  return hb_ot_name_get_utf16 (face,
                               name_id,
                               language,
                               text_size,
                               GET_SML_CVECTOR_VAL(uint16_t, text));
}
#endif

#if HB_CHECK_VERSION(2, 1, 0)
unsigned int
mlton_hb_ot_name_get_utf32 (hb_face_t* face,
                            hb_ot_name_id_t name_id,
                            hb_language_t language,
                            unsigned int* text_size,
                            SML_CVECTOR_VAL(uint32_t, text))
{
  return hb_ot_name_get_utf32 (face,
                               name_id,
                               language,
                               text_size,
                               GET_SML_CVECTOR_VAL(uint32_t, text));
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
hb_script_t
mlton_hb_script_from_string (SML_CVECTOR_VAL(const char, str),
                             int len)
{
  return hb_script_from_string (GET_SML_CVECTOR_VAL(const char, str),
                                len);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
void
mlton_hb_shape (hb_font_t* font,
                hb_buffer_t* buffer,
                SML_CVECTOR_VAL(const hb_feature_t, features),
                unsigned int num_features)
{
  hb_shape (font,
            buffer,
            GET_SML_CVECTOR_VAL(const hb_feature_t, features),
            num_features);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
hb_bool_t
mlton_hb_shape_full (hb_font_t* font,
                     hb_buffer_t* buffer,
                     SML_CVECTOR_VAL(const hb_feature_t, features),
                     unsigned int num_features,
                     SML_CVECTORVECTOR_VAL(const char, shaper_list))
{
  return hb_shape_full (font,
                        buffer,
                        GET_SML_CVECTOR_VAL(const hb_feature_t, features),
                        num_features,
                        GET_SML_CVECTORVECTOR_VAL(const char, shaper_list));
}
#endif

#if HB_CHECK_VERSION(0, 9, 7)
hb_shape_plan_t*
mlton_hb_shape_plan_create (hb_face_t* face,
                            const hb_segment_properties_t* props,
                            SML_CVECTOR_VAL(const hb_feature_t, user_features),
                            unsigned int num_user_features,
                            SML_CVECTORVECTOR_VAL(const char, shaper_list))
{
  return hb_shape_plan_create (face,
                               props,
                               GET_SML_CVECTOR_VAL(const hb_feature_t, user_features),
                               num_user_features,
                               GET_SML_CVECTORVECTOR_VAL(const char, shaper_list));
}
#endif

hb_shape_plan_t*
mlton_hb_shape_plan_create2 (hb_face_t* face,
                             const hb_segment_properties_t* props,
                             const hb_feature_t* user_features,
                             unsigned int num_user_features,
                             const int* coords,
                             unsigned int num_coords,
                             SML_CVECTOR_VAL(const char* const, shaper_list))
{
  return hb_shape_plan_create2 (face,
                                props,
                                user_features,
                                num_user_features,
                                coords,
                                num_coords,
                                GET_SML_CVECTOR_VAL(const char* const, shaper_list));
}

#if HB_CHECK_VERSION(0, 9, 7)
hb_shape_plan_t*
mlton_hb_shape_plan_create_cached (hb_face_t* face,
                                   const hb_segment_properties_t* props,
                                   SML_CVECTOR_VAL(const hb_feature_t, user_features),
                                   unsigned int num_user_features,
                                   SML_CVECTORVECTOR_VAL(const char, shaper_list))
{
  return hb_shape_plan_create_cached (face,
                                      props,
                                      GET_SML_CVECTOR_VAL(const hb_feature_t, user_features),
                                      num_user_features,
                                      GET_SML_CVECTORVECTOR_VAL(const char, shaper_list));
}
#endif

hb_shape_plan_t*
mlton_hb_shape_plan_create_cached2 (hb_face_t* face,
                                    const hb_segment_properties_t* props,
                                    const hb_feature_t* user_features,
                                    unsigned int num_user_features,
                                    const int* coords,
                                    unsigned int num_coords,
                                    SML_CVECTOR_VAL(const char* const, shaper_list))
{
  return hb_shape_plan_create_cached2 (face,
                                       props,
                                       user_features,
                                       num_user_features,
                                       coords,
                                       num_coords,
                                       GET_SML_CVECTOR_VAL(const char* const, shaper_list));
}

#if HB_CHECK_VERSION(0, 9, 7)
hb_bool_t
mlton_hb_shape_plan_execute (hb_shape_plan_t* shape_plan,
                             hb_font_t* font,
                             hb_buffer_t* buffer,
                             SML_CVECTOR_VAL(const hb_feature_t, features),
                             unsigned int num_features)
{
  return hb_shape_plan_execute (shape_plan,
                                font,
                                buffer,
                                GET_SML_CVECTOR_VAL(const hb_feature_t, features),
                                num_features);
}
#endif

#if HB_CHECK_VERSION(0, 9, 2)
hb_tag_t
mlton_hb_tag_from_string (SML_CVECTOR_VAL(const char, str),
                          int len)
{
  return hb_tag_from_string (GET_SML_CVECTOR_VAL(const char, str),
                             len);
}
#endif

#if HB_CHECK_VERSION(0, 9, 5)
void
mlton_hb_tag_to_string (hb_tag_t tag,
                        SML_CVECTOR_VAL(char, buf))
{
  hb_tag_to_string (tag,
                    GET_SML_CVECTOR_VAL(char, buf));
}
#endif

#if HB_CHECK_VERSION(1, 4, 2)
hb_bool_t
mlton_hb_variation_from_string (SML_CVECTOR_VAL(const char, str),
                                int len,
                                hb_variation_t* variation)
{
  return hb_variation_from_string (GET_SML_CVECTOR_VAL(const char, str),
                                   len,
                                   variation);
}
#endif

#if HB_CHECK_VERSION(1, 4, 2)
void
mlton_hb_variation_to_string (hb_variation_t* variation,
                              SML_CVECTOR_VAL(char, buf),
                              unsigned int size)
{
  hb_variation_to_string (variation,
                          GET_SML_CVECTOR_VAL(char, buf),
                          size);
}
#endif
