Skip to content

Commit

Permalink
pkg: merge Keyword.from_ptr() and Keyword.__init__()
Browse files Browse the repository at this point in the history
  • Loading branch information
radhermit committed Jun 18, 2024
1 parent 84e22d2 commit 7a0c881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pkgcraft/pkg/ebuild.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cdef class Keyword:
cdef int _hash

@staticmethod
cdef Keyword from_ptr(C.Keyword *)
cdef Keyword from_ptr(C.Keyword *, Keyword inst=*)


cdef class Maintainer(Indirect):
Expand Down
9 changes: 4 additions & 5 deletions src/pkgcraft/pkg/ebuild.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,13 @@ cdef class Keyword:
if ptr is NULL:
raise PkgcraftError

self.status = KeywordStatus(ptr.status)
self.arch = ptr.arch.decode()
self.ptr = ptr
Keyword.from_ptr(ptr, self)

@staticmethod
cdef Keyword from_ptr(C.Keyword *ptr):
cdef Keyword from_ptr(C.Keyword *ptr, Keyword inst = None):
"""Create a Keyword from a pointer."""
inst = <Keyword>Keyword.__new__(Keyword)
if inst is None:
inst = <Keyword>Keyword.__new__(Keyword)
inst.status = KeywordStatus(ptr.status)
inst.arch = ptr.arch.decode()
inst.ptr = ptr
Expand Down

0 comments on commit 7a0c881

Please sign in to comment.