/
dgrigorev
/
SkiaSharp
Обзор
Документация
Войти
/
dgrigorev
/
SkiaSharp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
binding/HarfBuzzSharp/Feature.cs
71 строка
1 KB
Matthew Leibowitz
Enable Nullability on the binding projects
17 авг 2023, 18:24
17 авг 2023, 18:24
ed94547
Код
Авторство
О чём код?
#nullable disable using System; using System.Runtime.InteropServices; namespace HarfBuzzSharp { public unsafe partial struct Feature { private const int MaxFeatureStringSize = 128; public Feature (Tag tag) : this (tag, 1u, 0, uint.MaxValue) { } public Feature (Tag tag, uint value) : this (tag, value, 0, uint.MaxValue) { } public Feature (Tag tag, uint value, uint start, uint end) { this.tag = tag; this.value = value; this.start = start; this.end = end; } public Tag Tag { readonly get => tag; set => tag = value; } public uint Value { readonly get => value; set => this.value = value; } public uint Start { readonly get => start; set => start = value; } public uint End { readonly get => end; set => end = value; } public override string ToString () { fixed (Feature* f = &this) { var buffer = Marshal.AllocHGlobal (MaxFeatureStringSize); HarfBuzzApi.hb_feature_to_string (f, (void*)buffer, MaxFeatureStringSize); var str = Marshal.PtrToStringAnsi (buffer); Marshal.FreeHGlobal (buffer); return str; } } public static bool TryParse (string s, out Feature feature) { fixed (Feature* f = &feature) { return HarfBuzzApi.hb_feature_from_string (s, -1, f); } } public static Feature Parse (string s) => TryParse (s, out var feature) ? feature : throw new FormatException ("Unrecognized feature string format."); } }