From b91cd8e41ce00343bc3ec20f52c73f1daa135f33 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 17 Nov 2022 15:15:09 -0800 Subject: [PATCH] pkg/macos: character set in range --- pkg/macos/foundation/character_set.zig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/macos/foundation/character_set.zig b/pkg/macos/foundation/character_set.zig index 60d1843a9..ace4b1953 100644 --- a/pkg/macos/foundation/character_set.zig +++ b/pkg/macos/foundation/character_set.zig @@ -14,6 +14,15 @@ pub const CharacterSet = opaque { ))) orelse Allocator.Error.OutOfMemory; } + pub fn createWithCharactersInRange( + range: foundation.Range, + ) Allocator.Error!*CharacterSet { + return @intToPtr(?*CharacterSet, @ptrToInt(c.CFCharacterSetCreateWithCharactersInRange( + null, + range.cval(), + ))) orelse Allocator.Error.OutOfMemory; + } + pub fn release(self: *CharacterSet) void { c.CFRelease(self); } @@ -28,3 +37,13 @@ test "character set" { const cs = try CharacterSet.createWithCharactersInString(str); defer cs.release(); } + +test "character set range" { + //const testing = std.testing; + + const cs = try CharacterSet.createWithCharactersInRange(.{ + .location = 'A', + .length = 1, + }); + defer cs.release(); +}