Work around enums not being blittable (#1857)

This commit is contained in:
Matthew Leibowitz 2021-11-10 00:16:05 +02:00 коммит произвёл GitHub
Родитель e83c08b06f
Коммит 948bc94267
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 165 добавлений и 24 удалений

Просмотреть файл

@ -24,17 +24,17 @@ namespace HarfBuzzSharp
public static readonly UnicodeDecomposeProxyDelegate DecomposeProxy = DecomposeProxyImplementation;
[MonoPInvokeCallback (typeof (UnicodeCombiningClassProxyDelegate))]
private static UnicodeCombiningClass CombiningClassProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
private static int CombiningClassProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
{
GetMultiUserData<CombiningClassDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, unicode);
return (int)del.Invoke (functions, unicode);
}
[MonoPInvokeCallback (typeof (UnicodeGeneralCategoryProxyDelegate))]
private static UnicodeGeneralCategory GeneralCategoryProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
private static int GeneralCategoryProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
{
GetMultiUserData<GeneralCategoryDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
return del.Invoke (functions, unicode);
return (int)del.Invoke (functions, unicode);
}
[MonoPInvokeCallback (typeof (UnicodeMirroringProxyDelegate))]

Просмотреть файл

@ -64,6 +64,34 @@ namespace HarfBuzzSharp
(hb_blob_create_from_file_delegate ??= GetSymbol<Delegates.hb_blob_create_from_file> ("hb_blob_create_from_file")).Invoke (file_name);
#endif
// extern hb_blob_t* hb_blob_create_from_file_or_fail(const char* file_name)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern hb_blob_t hb_blob_create_from_file_or_fail (/* char */ void* file_name);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate hb_blob_t hb_blob_create_from_file_or_fail (/* char */ void* file_name);
}
private static Delegates.hb_blob_create_from_file_or_fail hb_blob_create_from_file_or_fail_delegate;
internal static hb_blob_t hb_blob_create_from_file_or_fail (/* char */ void* file_name) =>
(hb_blob_create_from_file_or_fail_delegate ??= GetSymbol<Delegates.hb_blob_create_from_file_or_fail> ("hb_blob_create_from_file_or_fail")).Invoke (file_name);
#endif
// extern hb_blob_t* hb_blob_create_or_fail(const char* data, unsigned int length, hb_memory_mode_t mode, void* user_data, hb_destroy_func_t destroy)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern hb_blob_t hb_blob_create_or_fail (/* char */ void* data, UInt32 length, MemoryMode mode, void* user_data, DestroyProxyDelegate destroy);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate hb_blob_t hb_blob_create_or_fail (/* char */ void* data, UInt32 length, MemoryMode mode, void* user_data, DestroyProxyDelegate destroy);
}
private static Delegates.hb_blob_create_or_fail hb_blob_create_or_fail_delegate;
internal static hb_blob_t hb_blob_create_or_fail (/* char */ void* data, UInt32 length, MemoryMode mode, void* user_data, DestroyProxyDelegate destroy) =>
(hb_blob_create_or_fail_delegate ??= GetSymbol<Delegates.hb_blob_create_or_fail> ("hb_blob_create_or_fail")).Invoke (data, length, mode, user_data, destroy);
#endif
// extern hb_blob_t* hb_blob_create_sub_blob(hb_blob_t* parent, unsigned int offset, unsigned int length)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -354,6 +382,22 @@ namespace HarfBuzzSharp
(hb_buffer_deserialize_glyphs_delegate ??= GetSymbol<Delegates.hb_buffer_deserialize_glyphs> ("hb_buffer_deserialize_glyphs")).Invoke (buffer, buf, buf_len, end_ptr, font, format);
#endif
// extern hb_bool_t hb_buffer_deserialize_unicode(hb_buffer_t* buffer, const char* buf, int buf_len, const char** end_ptr, hb_buffer_serialize_format_t format)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal static extern bool hb_buffer_deserialize_unicode (hb_buffer_t buffer, /* char */ void* buf, Int32 buf_len, /* char */ void** end_ptr, SerializeFormat format);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool hb_buffer_deserialize_unicode (hb_buffer_t buffer, /* char */ void* buf, Int32 buf_len, /* char */ void** end_ptr, SerializeFormat format);
}
private static Delegates.hb_buffer_deserialize_unicode hb_buffer_deserialize_unicode_delegate;
internal static bool hb_buffer_deserialize_unicode (hb_buffer_t buffer, /* char */ void* buf, Int32 buf_len, /* char */ void** end_ptr, SerializeFormat format) =>
(hb_buffer_deserialize_unicode_delegate ??= GetSymbol<Delegates.hb_buffer_deserialize_unicode> ("hb_buffer_deserialize_unicode")).Invoke (buffer, buf, buf_len, end_ptr, format);
#endif
// extern void hb_buffer_destroy(hb_buffer_t* buffer)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -578,6 +622,22 @@ namespace HarfBuzzSharp
(hb_buffer_guess_segment_properties_delegate ??= GetSymbol<Delegates.hb_buffer_guess_segment_properties> ("hb_buffer_guess_segment_properties")).Invoke (buffer);
#endif
// extern hb_bool_t hb_buffer_has_positions(hb_buffer_t* buffer)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal static extern bool hb_buffer_has_positions (hb_buffer_t buffer);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool hb_buffer_has_positions (hb_buffer_t buffer);
}
private static Delegates.hb_buffer_has_positions hb_buffer_has_positions_delegate;
internal static bool hb_buffer_has_positions (hb_buffer_t buffer) =>
(hb_buffer_has_positions_delegate ??= GetSymbol<Delegates.hb_buffer_has_positions> ("hb_buffer_has_positions")).Invoke (buffer);
#endif
// extern void hb_buffer_normalize_glyphs(hb_buffer_t* buffer)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -678,6 +738,20 @@ namespace HarfBuzzSharp
(hb_buffer_reverse_range_delegate ??= GetSymbol<Delegates.hb_buffer_reverse_range> ("hb_buffer_reverse_range")).Invoke (buffer, start, end);
#endif
// extern unsigned int hb_buffer_serialize(hb_buffer_t* buffer, unsigned int start, unsigned int end, char* buf, unsigned int buf_size, unsigned int* buf_consumed, hb_font_t* font, hb_buffer_serialize_format_t format, hb_buffer_serialize_flags_t flags)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt32 hb_buffer_serialize (hb_buffer_t buffer, UInt32 start, UInt32 end, /* char */ void* buf, UInt32 buf_size, UInt32* buf_consumed, hb_font_t font, SerializeFormat format, SerializeFlag flags);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate UInt32 hb_buffer_serialize (hb_buffer_t buffer, UInt32 start, UInt32 end, /* char */ void* buf, UInt32 buf_size, UInt32* buf_consumed, hb_font_t font, SerializeFormat format, SerializeFlag flags);
}
private static Delegates.hb_buffer_serialize hb_buffer_serialize_delegate;
internal static UInt32 hb_buffer_serialize (hb_buffer_t buffer, UInt32 start, UInt32 end, /* char */ void* buf, UInt32 buf_size, UInt32* buf_consumed, hb_font_t font, SerializeFormat format, SerializeFlag flags) =>
(hb_buffer_serialize_delegate ??= GetSymbol<Delegates.hb_buffer_serialize> ("hb_buffer_serialize")).Invoke (buffer, start, end, buf, buf_size, buf_consumed, font, format, flags);
#endif
// extern hb_buffer_serialize_format_t hb_buffer_serialize_format_from_string(const char* str, int len)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -734,6 +808,20 @@ namespace HarfBuzzSharp
(hb_buffer_serialize_list_formats_delegate ??= GetSymbol<Delegates.hb_buffer_serialize_list_formats> ("hb_buffer_serialize_list_formats")).Invoke ();
#endif
// extern unsigned int hb_buffer_serialize_unicode(hb_buffer_t* buffer, unsigned int start, unsigned int end, char* buf, unsigned int buf_size, unsigned int* buf_consumed, hb_buffer_serialize_format_t format, hb_buffer_serialize_flags_t flags)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt32 hb_buffer_serialize_unicode (hb_buffer_t buffer, UInt32 start, UInt32 end, /* char */ void* buf, UInt32 buf_size, UInt32* buf_consumed, SerializeFormat format, SerializeFlag flags);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate UInt32 hb_buffer_serialize_unicode (hb_buffer_t buffer, UInt32 start, UInt32 end, /* char */ void* buf, UInt32 buf_size, UInt32* buf_consumed, SerializeFormat format, SerializeFlag flags);
}
private static Delegates.hb_buffer_serialize_unicode hb_buffer_serialize_unicode_delegate;
internal static UInt32 hb_buffer_serialize_unicode (hb_buffer_t buffer, UInt32 start, UInt32 end, /* char */ void* buf, UInt32 buf_size, UInt32* buf_consumed, SerializeFormat format, SerializeFlag flags) =>
(hb_buffer_serialize_unicode_delegate ??= GetSymbol<Delegates.hb_buffer_serialize_unicode> ("hb_buffer_serialize_unicode")).Invoke (buffer, start, end, buf, buf_size, buf_consumed, format, flags);
#endif
// extern void hb_buffer_set_cluster_level(hb_buffer_t* buffer, hb_buffer_cluster_level_t cluster_level)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -2208,6 +2296,20 @@ namespace HarfBuzzSharp
(hb_font_get_nominal_glyph_delegate ??= GetSymbol<Delegates.hb_font_get_nominal_glyph> ("hb_font_get_nominal_glyph")).Invoke (font, unicode, glyph);
#endif
// extern unsigned int hb_font_get_nominal_glyphs(hb_font_t* font, unsigned int count, const hb_codepoint_t* first_unicode, unsigned int unicode_stride, hb_codepoint_t* first_glyph, unsigned int glyph_stride)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt32 hb_font_get_nominal_glyphs (hb_font_t font, UInt32 count, UInt32* first_unicode, UInt32 unicode_stride, UInt32* first_glyph, UInt32 glyph_stride);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate UInt32 hb_font_get_nominal_glyphs (hb_font_t font, UInt32 count, UInt32* first_unicode, UInt32 unicode_stride, UInt32* first_glyph, UInt32 glyph_stride);
}
private static Delegates.hb_font_get_nominal_glyphs hb_font_get_nominal_glyphs_delegate;
internal static UInt32 hb_font_get_nominal_glyphs (hb_font_t font, UInt32 count, UInt32* first_unicode, UInt32 unicode_stride, UInt32* first_glyph, UInt32 glyph_stride) =>
(hb_font_get_nominal_glyphs_delegate ??= GetSymbol<Delegates.hb_font_get_nominal_glyphs> ("hb_font_get_nominal_glyphs")).Invoke (font, count, first_unicode, unicode_stride, first_glyph, glyph_stride);
#endif
// extern hb_font_t* hb_font_get_parent(hb_font_t* font)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -3244,6 +3346,20 @@ namespace HarfBuzzSharp
(hb_ot_layout_lookup_collect_glyphs_delegate ??= GetSymbol<Delegates.hb_ot_layout_lookup_collect_glyphs> ("hb_ot_layout_lookup_collect_glyphs")).Invoke (face, table_tag, lookup_index, glyphs_before, glyphs_input, glyphs_after, glyphs_output);
#endif
// extern unsigned int hb_ot_layout_lookup_get_glyph_alternates(hb_face_t* face, unsigned int lookup_index, hb_codepoint_t glyph, unsigned int start_offset, unsigned int* alternate_count, hb_codepoint_t* alternate_glyphs)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt32 hb_ot_layout_lookup_get_glyph_alternates (hb_face_t face, UInt32 lookup_index, UInt32 glyph, UInt32 start_offset, UInt32* alternate_count, UInt32* alternate_glyphs);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate UInt32 hb_ot_layout_lookup_get_glyph_alternates (hb_face_t face, UInt32 lookup_index, UInt32 glyph, UInt32 start_offset, UInt32* alternate_count, UInt32* alternate_glyphs);
}
private static Delegates.hb_ot_layout_lookup_get_glyph_alternates hb_ot_layout_lookup_get_glyph_alternates_delegate;
internal static UInt32 hb_ot_layout_lookup_get_glyph_alternates (hb_face_t face, UInt32 lookup_index, UInt32 glyph, UInt32 start_offset, UInt32* alternate_count, UInt32* alternate_glyphs) =>
(hb_ot_layout_lookup_get_glyph_alternates_delegate ??= GetSymbol<Delegates.hb_ot_layout_lookup_get_glyph_alternates> ("hb_ot_layout_lookup_get_glyph_alternates")).Invoke (face, lookup_index, glyph, start_offset, alternate_count, alternate_glyphs);
#endif
// extern void hb_ot_layout_lookup_substitute_closure(hb_face_t* face, unsigned int lookup_index, hb_set_t* glyphs)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -3846,6 +3962,20 @@ namespace HarfBuzzSharp
(hb_set_clear_delegate ??= GetSymbol<Delegates.hb_set_clear> ("hb_set_clear")).Invoke (set);
#endif
// extern hb_set_t* hb_set_copy(const hb_set_t* set)
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
internal static extern hb_set_t hb_set_copy (hb_set_t set);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate hb_set_t hb_set_copy (hb_set_t set);
}
private static Delegates.hb_set_copy hb_set_copy_delegate;
internal static hb_set_t hb_set_copy (hb_set_t set) =>
(hb_set_copy_delegate ??= GetSymbol<Delegates.hb_set_copy> ("hb_set_copy")).Invoke (set);
#endif
// extern hb_set_t* hb_set_create()
#if !USE_DELEGATES
[DllImport (HARFBUZZ, CallingConvention = CallingConvention.Cdecl)]
@ -4639,7 +4769,7 @@ namespace HarfBuzzSharp
// typedef hb_unicode_combining_class_t (*)(hb_unicode_funcs_t* ufuncs, hb_codepoint_t unicode, void* user_data)* hb_unicode_combining_class_func_t
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal unsafe delegate UnicodeCombiningClass UnicodeCombiningClassProxyDelegate(hb_unicode_funcs_t ufuncs, UInt32 unicode, void* user_data);
internal unsafe delegate int UnicodeCombiningClassProxyDelegate(hb_unicode_funcs_t ufuncs, UInt32 unicode, void* user_data);
// typedef hb_bool_t (*)(hb_unicode_funcs_t* ufuncs, hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t* ab, void* user_data)* hb_unicode_compose_func_t
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
@ -4661,7 +4791,7 @@ namespace HarfBuzzSharp
// typedef hb_unicode_general_category_t (*)(hb_unicode_funcs_t* ufuncs, hb_codepoint_t unicode, void* user_data)* hb_unicode_general_category_func_t
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal unsafe delegate UnicodeGeneralCategory UnicodeGeneralCategoryProxyDelegate(hb_unicode_funcs_t ufuncs, UInt32 unicode, void* user_data);
internal unsafe delegate int UnicodeGeneralCategoryProxyDelegate(hb_unicode_funcs_t ufuncs, UInt32 unicode, void* user_data);
// typedef hb_codepoint_t (*)(hb_unicode_funcs_t* ufuncs, hb_codepoint_t unicode, void* user_data)* hb_unicode_mirroring_func_t
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]

Просмотреть файл

@ -154,6 +154,11 @@
"_HB_OT_META_TAG_MAX_VALUE": ""
}
},
"hb_ot_layout_baseline_tag_t": {
"members": {
"_HB_OT_LAYOUT_BASELINE_TAG_MAX_VALUE": ""
}
},
"hb_ot_var_axis_flags_t": {
"members": {
"_HB_OT_VAR_AXIS_FLAG_MAX_VALUE": ""
@ -208,6 +213,16 @@
}
},
"functions": {
"hb_unicode_combining_class_func_t": {
"parameters": {
"-1": "int"
}
},
"hb_unicode_general_category_func_t": {
"parameters": {
"-1": "int"
}
},
"hb_font_get_glyph_from_name": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String"

Просмотреть файл

@ -25,7 +25,7 @@ variables:
XCODE_VERSION: 12.4
DOTNET_VERSION_PREVIOUS: 3.1.413
DOTNET_VERSION: 5.0.401
DOTNET_VERSION_PREVIEW: 6.0.100-rtm.21525.3
DOTNET_VERSION_PREVIEW: 6.0.100
DOTNET_WORKLOAD_SOURCE: 'https://aka.ms/dotnet/maui/6.0.101/preview.10.json'
VS_VERSION_PREVIEW: 17/pre
CONFIGURATION: 'Release'

Просмотреть файл

@ -17,7 +17,7 @@ parameters:
condition: succeeded() # whether or not to run this template
shouldPublish: true # whether or not to publish the artifacts
configuration: $(CONFIGURATION) # the build configuration
buildExternals: '' # the build number to download externals from
buildExternals: '5425298' # the build number to download externals from
verbosity: $(VERBOSITY) # the level of verbosity to use when building
docker: '' # the Docker image to build and use
dockerArgs: '' # any additional arguments to pass to docker build
@ -31,18 +31,18 @@ parameters:
artifactName: '' # the name of the artifact to merge this run into
jobs:
# - ${{ if startsWith(parameters.name, 'native_') }}:
# - template: azure-templates-download.yml
# parameters:
# name: ${{ parameters.name }}
# displayName: ${{ parameters.displayName }}
# vmImage: ${{ parameters.vmImage }}
# condition: ${{ parameters.condition }}
# postBuildSteps: ${{ parameters.postBuildSteps }}
# buildExternals: ${{ parameters.buildExternals }}
# artifactName: ${{ parameters.artifactName }}
- ${{ if startsWith(parameters.name, 'native_') }}:
- template: azure-templates-download.yml
parameters:
name: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
vmImage: ${{ parameters.vmImage }}
condition: ${{ parameters.condition }}
postBuildSteps: ${{ parameters.postBuildSteps }}
buildExternals: ${{ parameters.buildExternals }}
artifactName: ${{ parameters.artifactName }}
# - ${{ if not(startsWith(parameters.name, 'native_')) }}:
- ${{ if not(startsWith(parameters.name, 'native_')) }}:
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
timeoutInMinutes: 120

Просмотреть файл

@ -11,10 +11,6 @@ Write-Host "Installing workloads..."
& dotnet workload install `
android ios tvos macos maccatalyst wasm-tools maui `
--from-rollback-file $SourceUrl `
--source https://aka.ms/dotnet6/nuget/index.json `
--source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-aspnetcore-7c57ecbd-3/nuget/v3/index.json `
--source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-4822e3c3-5/nuget/v3/index.json `
--source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-windowsdesktop-59fea7da-4/nuget/v3/index.json `
--source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-1ec2e17f-4/nuget/v3/index.json
--source https://api.nuget.org/v3/index.json
exit $LASTEXITCODE