Skip to content

Commit

Permalink
dep: fix Revision creation for Version objects from raw pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
radhermit committed Jun 18, 2024
1 parent 831e5aa commit 3588a3a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/pkgcraft/dep/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class Revision < C::Revision
include InspectPointerRender
include Comparable

# Create a Revision from a pointer.
def self.from_ptr(ptr)
obj = allocate
obj.instance_variable_set(:@ptr, ptr)
obj
end

private_class_method :from_ptr

def initialize(str)
@ptr = C.pkgcraft_revision_new(str.to_s)
raise Error::InvalidVersion if @ptr.null?
Expand Down Expand Up @@ -105,7 +114,7 @@ def op
def revision
if @revision.equal?(SENTINEL)
ptr = C.pkgcraft_version_revision(self)
@revision = ptr.null? ? nil : ptr
@revision = ptr.null? ? nil : Revision.send(:from_ptr, ptr)
end
@revision
end
Expand Down

0 comments on commit 3588a3a

Please sign in to comment.