pkg/fontconfig: const pointers

This commit is contained in:
Mitchell Hashimoto
2022-09-17 09:19:00 -07:00
parent 9750ac87fd
commit 57a82a26e7
2 changed files with 18 additions and 4 deletions

View File

@ -11,8 +11,8 @@ pub const CharSet = opaque {
c.FcCharSetDestroy(self.cval()); c.FcCharSetDestroy(self.cval());
} }
pub fn hasChar(self: *CharSet, cp: u32) bool { pub fn hasChar(self: *const CharSet, cp: u32) bool {
return c.FcCharSetHasChar(self.cval(), cp) == c.FcTrue; return c.FcCharSetHasChar(self.cvalConst(), cp) == c.FcTrue;
} }
pub inline fn cval(self: *CharSet) *c.struct__FcCharSet { pub inline fn cval(self: *CharSet) *c.struct__FcCharSet {
@ -21,6 +21,13 @@ pub const CharSet = opaque {
self, self,
); );
} }
pub inline fn cvalConst(self: *const CharSet) *const c.struct__FcCharSet {
return @ptrCast(
*const c.struct__FcCharSet,
self,
);
}
}; };
test "create" { test "create" {

View File

@ -11,8 +11,8 @@ pub const LangSet = opaque {
c.FcLangSetDestroy(self.cval()); c.FcLangSetDestroy(self.cval());
} }
pub fn hasLang(self: *LangSet, lang: [:0]const u8) bool { pub fn hasLang(self: *const LangSet, lang: [:0]const u8) bool {
return c.FcLangSetHasLang(self.cval(), lang.ptr) == c.FcTrue; return c.FcLangSetHasLang(self.cvalConst(), lang.ptr) == c.FcTrue;
} }
pub inline fn cval(self: *LangSet) *c.struct__FcLangSet { pub inline fn cval(self: *LangSet) *c.struct__FcLangSet {
@ -21,6 +21,13 @@ pub const LangSet = opaque {
self, self,
); );
} }
pub inline fn cvalConst(self: *const LangSet) *const c.struct__FcLangSet {
return @ptrCast(
*const c.struct__FcLangSet,
self,
);
}
}; };
test "create" { test "create" {