@@ -25,6 +25,15 @@ cdef extern from "pkgcraft.h":
2525 LOG_LEVEL_WARN,
2626 LOG_LEVEL_ERROR,
2727
28+ cdef enum Operator:
29+ OPERATOR_LESS # = 1,
30+ OPERATOR_LESS_OR_EQUAL,
31+ OPERATOR_EQUAL,
32+ OPERATOR_EQUAL_GLOB,
33+ OPERATOR_APPROXIMATE,
34+ OPERATOR_GREATER_OR_EQUAL,
35+ OPERATOR_GREATER,
36+
2837 cdef enum PkgFormat:
2938 PKG_FORMAT_EBUILD,
3039 PKG_FORMAT_FAKE,
@@ -54,10 +63,6 @@ cdef extern from "pkgcraft.h":
5463 cdef struct Atom:
5564 pass
5665
57- # Opaque wrapper for AtomVersion objects.
58- cdef struct AtomVersion:
59- pass
60-
6166 # System config
6267 cdef struct Config:
6368 pass
@@ -110,6 +115,9 @@ cdef extern from "pkgcraft.h":
110115 cdef struct Uri:
111116 pass
112117
118+ cdef struct Version:
119+ pass
120+
113121 cdef struct PkgcraftError:
114122 char * message
115123 ErrorKind kind
@@ -295,7 +303,7 @@ cdef extern from "pkgcraft.h":
295303 #
296304 # # Safety
297305 # The argument must be a non-null Atom pointer.
298- AtomVersion * pkgcraft_atom_version(Atom * atom)
306+ Version * pkgcraft_atom_version(Atom * atom)
299307
300308 # Add an external Repo to the config.
301309 #
@@ -850,7 +858,7 @@ cdef extern from "pkgcraft.h":
850858 #
851859 # # Safety
852860 # The argument must be a non-null Pkg pointer.
853- AtomVersion * pkgcraft_pkg_version(Pkg * p)
861+ Version * pkgcraft_pkg_version(Pkg * p)
854862
855863 # Return a repo's categories.
856864 #
@@ -1237,57 +1245,76 @@ cdef extern from "pkgcraft.h":
12371245 #
12381246 # # Safety
12391247 # The version arguments should be non-null Version pointers.
1240- int pkgcraft_version_cmp(AtomVersion * v1,
1241- AtomVersion * v2)
1248+ int pkgcraft_version_cmp(Version * v1,
1249+ Version * v2)
12421250
12431251 # Free a version.
12441252 #
12451253 # # Safety
12461254 # The version argument should be a non-null Version pointer.
1247- void pkgcraft_version_free(AtomVersion * v)
1255+ void pkgcraft_version_free(Version * v)
12481256
12491257 # Return the hash value for a version.
12501258 #
12511259 # # Safety
12521260 # The version argument should be a non-null Version pointer.
1253- uint64_t pkgcraft_version_hash(AtomVersion * v)
1261+ uint64_t pkgcraft_version_hash(Version * v)
12541262
12551263 # Determine if two versions intersect.
12561264 #
12571265 # # Safety
12581266 # The version arguments should be non-null Version pointers.
1259- bool pkgcraft_version_intersects(AtomVersion * v1, AtomVersion * v2)
1267+ bool pkgcraft_version_intersects(Version * v1, Version * v2)
12601268
12611269 # Parse a string into a version.
12621270 #
12631271 # Returns NULL on error.
12641272 #
12651273 # # Safety
12661274 # The version argument should point to a valid string.
1267- AtomVersion * pkgcraft_version_new(const char * s)
1275+ Version * pkgcraft_version_new(const char * s)
1276+
1277+ # Return a version's operator.
1278+ #
1279+ # Returns 0 on nonexistence.
1280+ #
1281+ # # Safety
1282+ # The argument must be a non-null Version pointer.
1283+ int pkgcraft_version_op(Version * v)
1284+
1285+ # Parse a string into an Operator.
1286+ #
1287+ # Returns 0 on error.
1288+ #
1289+ # # Safety
1290+ # The argument should be a UTF-8 string.
1291+ int pkgcraft_version_op_from_str(const char * s)
1292+
1293+ # Return the string for an Operator.
1294+ char * pkgcraft_version_op_str(Operator op)
12681295
12691296 # Return a version's revision, e.g. the version "1-r2" has a revision of "2".
12701297 #
12711298 # # Safety
12721299 # The version argument should be a non-null Version pointer.
1273- char * pkgcraft_version_revision(AtomVersion * v)
1300+ char * pkgcraft_version_revision(Version * v)
12741301
12751302 # Return a version's string value without operator.
12761303 #
12771304 # # Safety
12781305 # The version argument should be a non-null Version pointer.
1279- char * pkgcraft_version_str(AtomVersion * v)
1306+ char * pkgcraft_version_str(Version * v)
12801307
12811308 # Return a version's string value including the operator if it exists.
12821309 #
12831310 # # Safety
12841311 # The version argument should be a non-null Version pointer.
1285- char * pkgcraft_version_str_with_op(AtomVersion * v)
1312+ char * pkgcraft_version_str_with_op(Version * v)
12861313
12871314 # Parse a string into a version with an operator.
12881315 #
12891316 # Returns NULL on error.
12901317 #
12911318 # # Safety
12921319 # The version argument should point to a valid string.
1293- AtomVersion * pkgcraft_version_with_op(const char * s)
1320+ Version * pkgcraft_version_with_op(const char * s)
0 commit comments