Skip to content

Commit 5b21faf

Browse files
committed
dep: move all cdef object creation support directly after __init__()
1 parent 9a15769 commit 5b21faf

1 file changed

Lines changed: 40 additions & 40 deletions

File tree

src/pkgcraft/dep/base.pyx

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ cdef class Dependency:
6666

6767
Dependency.from_ptr(ptr, self)
6868

69+
@staticmethod
70+
cdef Dependency from_ptr(C.Dependency *ptr, Dependency inst = None):
71+
"""Create a Dependency from a pointer and type."""
72+
if inst is None:
73+
inst = <Dependency>Dependency.__new__(Dependency)
74+
inst.set = DependencySetKind(ptr.set)
75+
inst.kind = DependencyKind(ptr.kind)
76+
inst.ptr = ptr
77+
return inst
78+
6979
@classmethod
7080
def package(cls, s: str = None, eapi: Eapi | str = None):
7181
"""Parse a string into a package dependency."""
@@ -96,16 +106,6 @@ cdef class Dependency:
96106
"""Parse a string into a SRC_URI dependency."""
97107
return cls(s, set=DependencySetKind.SrcUri)
98108

99-
@staticmethod
100-
cdef Dependency from_ptr(C.Dependency *ptr, Dependency inst = None):
101-
"""Create a Dependency from a pointer and type."""
102-
if inst is None:
103-
inst = <Dependency>Dependency.__new__(Dependency)
104-
inst.set = DependencySetKind(ptr.set)
105-
inst.kind = DependencyKind(ptr.kind)
106-
inst.ptr = ptr
107-
return inst
108-
109109
@property
110110
def conditional(self):
111111
"""Return the conditional UseDep for a Dependency if it exists."""
@@ -230,36 +230,6 @@ cdef class DependencySet:
230230

231231
DependencySet.from_ptr(ptr, self)
232232

233-
@classmethod
234-
def package(cls, s: str = None, eapi: Eapi | str = None):
235-
"""Parse a string into a package dependency set."""
236-
return cls(s, eapi, set=DependencySetKind.Package)
237-
238-
@classmethod
239-
def license(cls, s: str = None):
240-
"""Parse a string into a LICENSE dependency set."""
241-
return cls(s, set=DependencySetKind.License)
242-
243-
@classmethod
244-
def properties(cls, s: str = None):
245-
"""Parse a string into a PROPERTIES dependency set."""
246-
return cls(s, set=DependencySetKind.Properties)
247-
248-
@classmethod
249-
def required_use(cls, s: str = None):
250-
"""Parse a string into a REQUIRED_USE dependency set."""
251-
return cls(s, set=DependencySetKind.RequiredUse)
252-
253-
@classmethod
254-
def restrict(cls, s: str = None):
255-
"""Parse a string into a RESTRICT dependency set."""
256-
return cls(s, set=DependencySetKind.Restrict)
257-
258-
@classmethod
259-
def src_uri(cls, s: str = None):
260-
"""Parse a string into a SRC_URI dependency set."""
261-
return cls(s, set=DependencySetKind.SrcUri)
262-
263233
@staticmethod
264234
cdef DependencySet from_ptr(C.DependencySet *ptr, DependencySet inst = None):
265235
"""Create a DependencySet from a pointer."""
@@ -299,6 +269,36 @@ cdef class DependencySet:
299269
PyMem_Free(array)
300270
return ptr
301271

272+
@classmethod
273+
def package(cls, s: str = None, eapi: Eapi | str = None):
274+
"""Parse a string into a package dependency set."""
275+
return cls(s, eapi, set=DependencySetKind.Package)
276+
277+
@classmethod
278+
def license(cls, s: str = None):
279+
"""Parse a string into a LICENSE dependency set."""
280+
return cls(s, set=DependencySetKind.License)
281+
282+
@classmethod
283+
def properties(cls, s: str = None):
284+
"""Parse a string into a PROPERTIES dependency set."""
285+
return cls(s, set=DependencySetKind.Properties)
286+
287+
@classmethod
288+
def required_use(cls, s: str = None):
289+
"""Parse a string into a REQUIRED_USE dependency set."""
290+
return cls(s, set=DependencySetKind.RequiredUse)
291+
292+
@classmethod
293+
def restrict(cls, s: str = None):
294+
"""Parse a string into a RESTRICT dependency set."""
295+
return cls(s, set=DependencySetKind.Restrict)
296+
297+
@classmethod
298+
def src_uri(cls, s: str = None):
299+
"""Parse a string into a SRC_URI dependency set."""
300+
return cls(s, set=DependencySetKind.SrcUri)
301+
302302
def evaluate(self, enabled=()):
303303
"""Evaluate a DependencySet using a given set of enabled options or by force."""
304304
if isinstance(enabled, bool):

0 commit comments

Comments
 (0)