[wasm-api] Beautify internal API
This commit is contained in:
parent
fe557e2f21
commit
fea3ffe031
|
@ -33,7 +33,7 @@ namespace wasm {
|
||||||
|
|
||||||
void
|
void
|
||||||
blob_free (HB_WASM_EXEC_ENV
|
blob_free (HB_WASM_EXEC_ENV
|
||||||
ptr_t(blob_t) blobptr)
|
ptr_d(blob_t, blob))
|
||||||
{
|
{
|
||||||
HB_OUT_PARAM (blob_t, blob);
|
HB_OUT_PARAM (blob_t, blob);
|
||||||
if (unlikely (!blob))
|
if (unlikely (!blob))
|
||||||
|
|
|
@ -37,7 +37,7 @@ static_assert (sizeof (glyph_position_t) == sizeof (hb_glyph_position_t), "");
|
||||||
|
|
||||||
void
|
void
|
||||||
buffer_contents_free (HB_WASM_EXEC_ENV
|
buffer_contents_free (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_contents_t) contentsptr)
|
ptr_d(buffer_contents_t, contents))
|
||||||
{
|
{
|
||||||
HB_OUT_PARAM (buffer_contents_t, contents);
|
HB_OUT_PARAM (buffer_contents_t, contents);
|
||||||
if (unlikely (!contents))
|
if (unlikely (!contents))
|
||||||
|
@ -53,7 +53,7 @@ buffer_contents_free (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
void
|
void
|
||||||
buffer_contents_realloc (HB_WASM_EXEC_ENV
|
buffer_contents_realloc (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_contents_t) contentsptr,
|
ptr_d(buffer_contents_t, contents),
|
||||||
uint32_t size)
|
uint32_t size)
|
||||||
{
|
{
|
||||||
HB_OUT_PARAM (buffer_contents_t, contents);
|
HB_OUT_PARAM (buffer_contents_t, contents);
|
||||||
|
@ -85,7 +85,7 @@ void
|
||||||
|
|
||||||
void
|
void
|
||||||
buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
|
buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
ptr_t(buffer_t) bufferref)
|
ptr_d(buffer_t, buffer))
|
||||||
{
|
{
|
||||||
HB_RETURN_STRUCT (buffer_contents_t, ret);
|
HB_RETURN_STRUCT (buffer_contents_t, ret);
|
||||||
HB_REF2OBJ (buffer);
|
HB_REF2OBJ (buffer);
|
||||||
|
@ -101,8 +101,8 @@ buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
|
|
||||||
bool_t
|
bool_t
|
||||||
buffer_set_contents (HB_WASM_EXEC_ENV
|
buffer_set_contents (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t) bufferref,
|
ptr_d(buffer_t, buffer),
|
||||||
ptr_t(const buffer_contents_t) contentsptr)
|
ptr_d(const buffer_contents_t, contents))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (buffer);
|
HB_REF2OBJ (buffer);
|
||||||
HB_OUT_PARAM (buffer_contents_t, contents);
|
HB_OUT_PARAM (buffer_contents_t, contents);
|
||||||
|
@ -130,7 +130,7 @@ buffer_set_contents (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
direction_t
|
direction_t
|
||||||
buffer_get_direction (HB_WASM_EXEC_ENV
|
buffer_get_direction (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t) bufferref)
|
ptr_d(buffer_t, buffer))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (buffer);
|
HB_REF2OBJ (buffer);
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ buffer_get_direction (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
void
|
void
|
||||||
buffer_reverse (HB_WASM_EXEC_ENV
|
buffer_reverse (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t) bufferref)
|
ptr_d(buffer_t, buffer))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (buffer);
|
HB_REF2OBJ (buffer);
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ buffer_reverse (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
void
|
void
|
||||||
buffer_reverse_clusters (HB_WASM_EXEC_ENV
|
buffer_reverse_clusters (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t) bufferref)
|
ptr_d(buffer_t, buffer))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (buffer);
|
HB_REF2OBJ (buffer);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace wasm {
|
||||||
|
|
||||||
void
|
void
|
||||||
face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
|
face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
ptr_t(face_t) faceref,
|
ptr_d(face_t, face),
|
||||||
tag_t table_tag)
|
tag_t table_tag)
|
||||||
{
|
{
|
||||||
HB_RETURN_STRUCT (blob_t, ret);
|
HB_RETURN_STRUCT (blob_t, ret);
|
||||||
|
@ -52,7 +52,7 @@ face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
face_get_upem (HB_WASM_EXEC_ENV
|
face_get_upem (HB_WASM_EXEC_ENV
|
||||||
ptr_t(face_t) faceref)
|
ptr_d(face_t, face))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (face);
|
HB_REF2OBJ (face);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace wasm {
|
||||||
|
|
||||||
ptr_t(face_t)
|
ptr_t(face_t)
|
||||||
font_get_face (HB_WASM_EXEC_ENV
|
font_get_face (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref)
|
ptr_d(font_t, font))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (font);
|
HB_REF2OBJ (font);
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ font_get_face (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
void
|
void
|
||||||
font_get_scale (HB_WASM_EXEC_ENV
|
font_get_scale (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
ptr_t(int32_t) x_scaleptr,
|
ptr_d(int32_t, x_scale),
|
||||||
ptr_t(int32_t) y_scaleptr)
|
ptr_d(int32_t, y_scale))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (font);
|
HB_REF2OBJ (font);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ font_get_scale (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
codepoint_t
|
codepoint_t
|
||||||
font_get_glyph (HB_WASM_EXEC_ENV
|
font_get_glyph (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
codepoint_t unicode,
|
codepoint_t unicode,
|
||||||
codepoint_t variation_selector)
|
codepoint_t variation_selector)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ font_get_glyph (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
hb_position_t
|
hb_position_t
|
||||||
font_get_glyph_h_advance (HB_WASM_EXEC_ENV
|
font_get_glyph_h_advance (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph)
|
codepoint_t glyph)
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (font);
|
HB_REF2OBJ (font);
|
||||||
|
@ -81,7 +81,7 @@ font_get_glyph_h_advance (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
hb_position_t
|
hb_position_t
|
||||||
font_get_glyph_v_advance (HB_WASM_EXEC_ENV
|
font_get_glyph_v_advance (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph)
|
codepoint_t glyph)
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (font);
|
HB_REF2OBJ (font);
|
||||||
|
@ -92,9 +92,9 @@ static_assert (sizeof (glyph_extents_t) == sizeof (hb_glyph_extents_t), "");
|
||||||
|
|
||||||
bool_t
|
bool_t
|
||||||
font_get_glyph_extents (HB_WASM_EXEC_ENV
|
font_get_glyph_extents (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph,
|
codepoint_t glyph,
|
||||||
ptr_t(glyph_extents_t) extentsptr)
|
ptr_d(glyph_extents_t, extents))
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (font);
|
HB_REF2OBJ (font);
|
||||||
HB_OUT_PARAM (glyph_extents_t, extents);
|
HB_OUT_PARAM (glyph_extents_t, extents);
|
||||||
|
@ -107,7 +107,7 @@ font_get_glyph_extents (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
void
|
void
|
||||||
font_glyph_to_string (HB_WASM_EXEC_ENV
|
font_glyph_to_string (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph,
|
codepoint_t glyph,
|
||||||
char *s, uint32_t size)
|
char *s, uint32_t size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace wasm {
|
||||||
|
|
||||||
bool_t
|
bool_t
|
||||||
shape_with (HB_WASM_EXEC_ENV
|
shape_with (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_d(font_t, font),
|
||||||
ptr_t(buffer_t) bufferref,
|
ptr_d(buffer_t, buffer),
|
||||||
const char *shaper)
|
const char *shaper)
|
||||||
{
|
{
|
||||||
HB_REF2OBJ (font);
|
HB_REF2OBJ (font);
|
||||||
|
|
|
@ -68,6 +68,9 @@ HB_WASM_BEGIN_DECLS
|
||||||
#ifndef ptr_t
|
#ifndef ptr_t
|
||||||
#define ptr_t(type_t) type_t *
|
#define ptr_t(type_t) type_t *
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ptr_d
|
||||||
|
#define ptr_d(type_t, name) type_t *name
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef uint32_t codepoint_t;
|
typedef uint32_t codepoint_t;
|
||||||
typedef int32_t position_t;
|
typedef int32_t position_t;
|
||||||
|
@ -99,7 +102,7 @@ typedef struct
|
||||||
} blob_t;
|
} blob_t;
|
||||||
|
|
||||||
HB_WASM_API (void, blob_free) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, blob_free) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(blob_t));
|
ptr_d(blob_t, blob));
|
||||||
|
|
||||||
|
|
||||||
/* buffer */
|
/* buffer */
|
||||||
|
@ -130,40 +133,40 @@ typedef struct
|
||||||
} buffer_contents_t;
|
} buffer_contents_t;
|
||||||
|
|
||||||
HB_WASM_API (void, buffer_contents_realloc) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, buffer_contents_realloc) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_contents_t),
|
ptr_d(buffer_contents_t, contents),
|
||||||
uint32_t size);
|
uint32_t size);
|
||||||
|
|
||||||
HB_WASM_API (void, buffer_contents_free) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, buffer_contents_free) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_contents_t));
|
ptr_d(buffer_contents_t, contents));
|
||||||
|
|
||||||
typedef struct buffer_t buffer_t;
|
typedef struct buffer_t buffer_t;
|
||||||
|
|
||||||
HB_WASM_API_COMPOUND (buffer_contents_t, buffer_copy_contents) (HB_WASM_EXEC_ENV_COMPOUND
|
HB_WASM_API_COMPOUND (buffer_contents_t, buffer_copy_contents) (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
ptr_t(buffer_t));
|
ptr_d(buffer_t, buffer));
|
||||||
|
|
||||||
HB_WASM_API (bool_t, buffer_set_contents) (HB_WASM_EXEC_ENV
|
HB_WASM_API (bool_t, buffer_set_contents) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t),
|
ptr_d(buffer_t, buffer),
|
||||||
ptr_t(const buffer_contents_t));
|
ptr_d(const buffer_contents_t, contents));
|
||||||
|
|
||||||
HB_WASM_API (direction_t, buffer_get_direction) (HB_WASM_EXEC_ENV
|
HB_WASM_API (direction_t, buffer_get_direction) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t));
|
ptr_d(buffer_t, buffer));
|
||||||
|
|
||||||
HB_WASM_API (void, buffer_reverse) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, buffer_reverse) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t));
|
ptr_d(buffer_t, buffer));
|
||||||
|
|
||||||
HB_WASM_API (void, buffer_reverse_clusters) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, buffer_reverse_clusters) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(buffer_t));
|
ptr_d(buffer_t, buffer));
|
||||||
|
|
||||||
/* face */
|
/* face */
|
||||||
|
|
||||||
typedef struct face_t face_t;
|
typedef struct face_t face_t;
|
||||||
|
|
||||||
HB_WASM_API_COMPOUND (blob_t, face_reference_table) (HB_WASM_EXEC_ENV_COMPOUND
|
HB_WASM_API_COMPOUND (blob_t, face_reference_table) (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
ptr_t(face_t),
|
ptr_d(face_t, face),
|
||||||
tag_t table_tag);
|
tag_t table_tag);
|
||||||
|
|
||||||
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(face_t));
|
ptr_d(face_t, face));
|
||||||
|
|
||||||
|
|
||||||
/* font */
|
/* font */
|
||||||
|
@ -171,24 +174,24 @@ HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
||||||
typedef struct font_t font_t;
|
typedef struct font_t font_t;
|
||||||
|
|
||||||
HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV
|
HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t));
|
ptr_d(font_t, font));
|
||||||
|
|
||||||
HB_WASM_API (void, font_get_scale) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, font_get_scale) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
ptr_t(int32_t) x_scale,
|
ptr_d(int32_t, x_scale),
|
||||||
ptr_t(int32_t) y_scale);
|
ptr_d(int32_t, y_scale));
|
||||||
|
|
||||||
HB_WASM_API (codepoint_t, font_get_glyph) (HB_WASM_EXEC_ENV
|
HB_WASM_API (codepoint_t, font_get_glyph) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
codepoint_t unicode,
|
codepoint_t unicode,
|
||||||
codepoint_t variation_selector);
|
codepoint_t variation_selector);
|
||||||
|
|
||||||
HB_WASM_API (position_t, font_get_glyph_h_advance) (HB_WASM_EXEC_ENV
|
HB_WASM_API (position_t, font_get_glyph_h_advance) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph);
|
codepoint_t glyph);
|
||||||
|
|
||||||
HB_WASM_API (position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV
|
HB_WASM_API (position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph);
|
codepoint_t glyph);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -199,12 +202,12 @@ typedef struct {
|
||||||
} glyph_extents_t;
|
} glyph_extents_t;
|
||||||
|
|
||||||
HB_WASM_API (bool_t, font_get_glyph_extents) (HB_WASM_EXEC_ENV
|
HB_WASM_API (bool_t, font_get_glyph_extents) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph,
|
codepoint_t glyph,
|
||||||
ptr_t(glyph_extents_t) extents);
|
ptr_d(glyph_extents_t, extents));
|
||||||
|
|
||||||
HB_WASM_API (void, font_glyph_to_string) (HB_WASM_EXEC_ENV
|
HB_WASM_API (void, font_glyph_to_string) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
codepoint_t glyph,
|
codepoint_t glyph,
|
||||||
char *s, uint32_t size);
|
char *s, uint32_t size);
|
||||||
|
|
||||||
|
@ -212,16 +215,16 @@ HB_WASM_API (void, font_glyph_to_string) (HB_WASM_EXEC_ENV
|
||||||
/* shape */
|
/* shape */
|
||||||
|
|
||||||
HB_WASM_INTERFACE (bool_t, shape_with) (HB_WASM_EXEC_ENV
|
HB_WASM_INTERFACE (bool_t, shape_with) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
ptr_t(buffer_t),
|
ptr_d(buffer_t, buffer),
|
||||||
const char *shaper);
|
const char *shaper);
|
||||||
|
|
||||||
|
|
||||||
/* shape interface */
|
/* shape interface */
|
||||||
|
|
||||||
HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV
|
HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_d(font_t, font),
|
||||||
ptr_t(buffer_t));
|
ptr_d(buffer_t, buffer));
|
||||||
|
|
||||||
|
|
||||||
HB_WASM_END_DECLS
|
HB_WASM_END_DECLS
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#define HB_WASM_EXEC_ENV_COMPOUND wasm_exec_env_t exec_env, ptr_t() retptr,
|
#define HB_WASM_EXEC_ENV_COMPOUND wasm_exec_env_t exec_env, ptr_t() retptr,
|
||||||
|
|
||||||
#define ptr_t(type_t) uint32_t
|
#define ptr_t(type_t) uint32_t
|
||||||
|
#define ptr_d(type_t, name) uint32_t name##ptr
|
||||||
|
|
||||||
#include "hb-wasm-api.h"
|
#include "hb-wasm-api.h"
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ HB_INTERNAL extern hb_user_data_key_t _hb_wasm_ref_type_key;
|
||||||
#define HB_REF2OBJ(obj) \
|
#define HB_REF2OBJ(obj) \
|
||||||
hb_##obj##_t *obj = nullptr; \
|
hb_##obj##_t *obj = nullptr; \
|
||||||
HB_STMT_START { \
|
HB_STMT_START { \
|
||||||
(void) wasm_externref_ref2obj (obj##ref, (void **) &obj); \
|
(void) wasm_externref_ref2obj (obj##ptr, (void **) &obj); \
|
||||||
/* Check object type. */ \
|
/* Check object type. */ \
|
||||||
/* This works because all our objects have the same hb_object_t layout. */ \
|
/* This works because all our objects have the same hb_object_t layout. */ \
|
||||||
if (unlikely (hb_##obj##_get_user_data (obj, &_hb_wasm_ref_type_key) != \
|
if (unlikely (hb_##obj##_get_user_data (obj, &_hb_wasm_ref_type_key) != \
|
||||||
|
|
Loading…
Reference in New Issue