[wasm-api] Match interface and implementation signatures

This commit is contained in:
Behdad Esfahbod 2023-02-24 12:42:22 -07:00
parent fea3ffe031
commit 39f8703df1
6 changed files with 64 additions and 83 deletions

View File

@ -31,8 +31,7 @@ namespace hb {
namespace wasm { namespace wasm {
void HB_WASM_API (void, blob_free) (HB_WASM_EXEC_ENV
blob_free (HB_WASM_EXEC_ENV
ptr_d(blob_t, blob)) ptr_d(blob_t, blob))
{ {
HB_OUT_PARAM (blob_t, blob); HB_OUT_PARAM (blob_t, blob);

View File

@ -35,24 +35,7 @@ namespace wasm {
static_assert (sizeof (glyph_info_t) == sizeof (hb_glyph_info_t), ""); static_assert (sizeof (glyph_info_t) == sizeof (hb_glyph_info_t), "");
static_assert (sizeof (glyph_position_t) == sizeof (hb_glyph_position_t), ""); static_assert (sizeof (glyph_position_t) == sizeof (hb_glyph_position_t), "");
void HB_WASM_API (void, buffer_contents_realloc) (HB_WASM_EXEC_ENV
buffer_contents_free (HB_WASM_EXEC_ENV
ptr_d(buffer_contents_t, contents))
{
HB_OUT_PARAM (buffer_contents_t, contents);
if (unlikely (!contents))
return;
module_free (contents->info);
module_free (contents->pos);
contents->info = nullref;
contents->pos = nullref;
contents->length = 0;
}
void
buffer_contents_realloc (HB_WASM_EXEC_ENV
ptr_d(buffer_contents_t, contents), ptr_d(buffer_contents_t, contents),
uint32_t size) uint32_t size)
{ {
@ -83,8 +66,22 @@ void
contents->length = size; contents->length = size;
} }
void HB_WASM_API (void, buffer_contents_free) (HB_WASM_EXEC_ENV
buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND ptr_d(buffer_contents_t, contents))
{
HB_OUT_PARAM (buffer_contents_t, contents);
if (unlikely (!contents))
return;
module_free (contents->info);
module_free (contents->pos);
contents->info = nullref;
contents->pos = nullref;
contents->length = 0;
}
HB_WASM_API_COMPOUND (buffer_contents_t, buffer_copy_contents) (HB_WASM_EXEC_ENV_COMPOUND
ptr_d(buffer_t, buffer)) ptr_d(buffer_t, buffer))
{ {
HB_RETURN_STRUCT (buffer_contents_t, ret); HB_RETURN_STRUCT (buffer_contents_t, ret);
@ -99,8 +96,7 @@ buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
ret.pos = wasm_runtime_module_dup_data (module_inst, (const char *) buffer->pos, length * sizeof (buffer->pos[0])); ret.pos = wasm_runtime_module_dup_data (module_inst, (const char *) buffer->pos, length * sizeof (buffer->pos[0]));
} }
bool_t HB_WASM_API (bool_t, buffer_set_contents) (HB_WASM_EXEC_ENV
buffer_set_contents (HB_WASM_EXEC_ENV
ptr_d(buffer_t, buffer), ptr_d(buffer_t, buffer),
ptr_d(const buffer_contents_t, contents)) ptr_d(const buffer_contents_t, contents))
{ {
@ -128,8 +124,7 @@ buffer_set_contents (HB_WASM_EXEC_ENV
return true; return true;
} }
direction_t HB_WASM_API (direction_t, buffer_get_direction) (HB_WASM_EXEC_ENV
buffer_get_direction (HB_WASM_EXEC_ENV
ptr_d(buffer_t, buffer)) ptr_d(buffer_t, buffer))
{ {
HB_REF2OBJ (buffer); HB_REF2OBJ (buffer);
@ -137,8 +132,7 @@ buffer_get_direction (HB_WASM_EXEC_ENV
return (direction_t) hb_buffer_get_direction (buffer); return (direction_t) hb_buffer_get_direction (buffer);
} }
void HB_WASM_API (void, buffer_reverse) (HB_WASM_EXEC_ENV
buffer_reverse (HB_WASM_EXEC_ENV
ptr_d(buffer_t, buffer)) ptr_d(buffer_t, buffer))
{ {
HB_REF2OBJ (buffer); HB_REF2OBJ (buffer);
@ -146,8 +140,7 @@ buffer_reverse (HB_WASM_EXEC_ENV
hb_buffer_reverse (buffer); hb_buffer_reverse (buffer);
} }
void HB_WASM_API (void, buffer_reverse_clusters) (HB_WASM_EXEC_ENV
buffer_reverse_clusters (HB_WASM_EXEC_ENV
ptr_d(buffer_t, buffer)) ptr_d(buffer_t, buffer))
{ {
HB_REF2OBJ (buffer); HB_REF2OBJ (buffer);

View File

@ -31,8 +31,7 @@ namespace hb {
namespace wasm { namespace wasm {
void HB_WASM_API_COMPOUND (blob_t, face_reference_table) (HB_WASM_EXEC_ENV_COMPOUND
face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
ptr_d(face_t, face), ptr_d(face_t, face),
tag_t table_tag) tag_t table_tag)
{ {
@ -50,8 +49,7 @@ face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
hb_blob_destroy (blob); hb_blob_destroy (blob);
} }
unsigned HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
face_get_upem (HB_WASM_EXEC_ENV
ptr_d(face_t, face)) ptr_d(face_t, face))
{ {
HB_REF2OBJ (face); HB_REF2OBJ (face);

View File

@ -31,8 +31,7 @@ namespace hb {
namespace wasm { namespace wasm {
ptr_t(face_t) HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV
font_get_face (HB_WASM_EXEC_ENV
ptr_d(font_t, font)) ptr_d(font_t, font))
{ {
HB_REF2OBJ (font); HB_REF2OBJ (font);
@ -43,8 +42,7 @@ font_get_face (HB_WASM_EXEC_ENV
return faceref; return faceref;
} }
void HB_WASM_API (void, font_get_scale) (HB_WASM_EXEC_ENV
font_get_scale (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
ptr_d(int32_t, x_scale), ptr_d(int32_t, x_scale),
ptr_d(int32_t, y_scale)) ptr_d(int32_t, y_scale))
@ -57,8 +55,7 @@ font_get_scale (HB_WASM_EXEC_ENV
hb_font_get_scale (font, x_scale, y_scale); hb_font_get_scale (font, x_scale, y_scale);
} }
codepoint_t HB_WASM_API (codepoint_t, font_get_glyph) (HB_WASM_EXEC_ENV
font_get_glyph (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
codepoint_t unicode, codepoint_t unicode,
codepoint_t variation_selector) codepoint_t variation_selector)
@ -70,8 +67,7 @@ font_get_glyph (HB_WASM_EXEC_ENV
return glyph; return glyph;
} }
hb_position_t HB_WASM_API (position_t, font_get_glyph_h_advance) (HB_WASM_EXEC_ENV
font_get_glyph_h_advance (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
codepoint_t glyph) codepoint_t glyph)
{ {
@ -79,8 +75,7 @@ font_get_glyph_h_advance (HB_WASM_EXEC_ENV
return hb_font_get_glyph_h_advance (font, glyph); return hb_font_get_glyph_h_advance (font, glyph);
} }
hb_position_t HB_WASM_API (position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV
font_get_glyph_v_advance (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
codepoint_t glyph) codepoint_t glyph)
{ {
@ -90,8 +85,7 @@ font_get_glyph_v_advance (HB_WASM_EXEC_ENV
static_assert (sizeof (glyph_extents_t) == sizeof (hb_glyph_extents_t), ""); static_assert (sizeof (glyph_extents_t) == sizeof (hb_glyph_extents_t), "");
bool_t HB_WASM_API (bool_t, font_get_glyph_extents) (HB_WASM_EXEC_ENV
font_get_glyph_extents (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
codepoint_t glyph, codepoint_t glyph,
ptr_d(glyph_extents_t, extents)) ptr_d(glyph_extents_t, extents))
@ -105,8 +99,7 @@ font_get_glyph_extents (HB_WASM_EXEC_ENV
(hb_glyph_extents_t *) extents); (hb_glyph_extents_t *) extents);
} }
void HB_WASM_API (void, font_glyph_to_string) (HB_WASM_EXEC_ENV
font_glyph_to_string (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
codepoint_t glyph, codepoint_t glyph,
char *s, uint32_t size) char *s, uint32_t size)

View File

@ -31,8 +31,7 @@ namespace hb {
namespace wasm { namespace wasm {
bool_t HB_WASM_INTERFACE (bool_t, shape_with) (HB_WASM_EXEC_ENV
shape_with (HB_WASM_EXEC_ENV
ptr_d(font_t, font), ptr_d(font_t, font),
ptr_d(buffer_t, buffer), ptr_d(buffer_t, buffer),
const char *shaper) const char *shaper)

View File

@ -43,7 +43,6 @@
#include "hb-wasm-api.h" #include "hb-wasm-api.h"
#undef HB_WASM_API
#undef HB_WASM_BEGIN_DECLS #undef HB_WASM_BEGIN_DECLS
#undef HB_WASM_END_DECLS #undef HB_WASM_END_DECLS