Skip to content

Commit

Permalink
Make possible to use Pango::AttrList and Pango::Attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopl committed Jul 25, 2022
1 parent ab41fb8 commit a26d921
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/bindings/pango/attribute.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Pango
class Attribute
def initialize(pointer : Pointer(Void), transfer : GICrystal::Transfer)
raise ArgumentError.new("Tried to generate struct with a NULL pointer") if pointer.null?

@pointer = if transfer.none?
LibPango.pango_attribute_copy(pointer)
else
pointer
end
end

def finalize
{% if flag?(:debugmemory) %}
LibC.printf("~%s at %p\n", self.class.name.to_unsafe, self)
{% end %}
LibPango.pango_attribute_destroy(to_unsafe)
end
end
end
12 changes: 12 additions & 0 deletions src/bindings/pango/binding.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
namespace: Pango
version: "1.0"
require_after:
- attribute.cr
- font_metrics.cr
- layout.cr

types:
Attribute:
binding_strategy: heap_wrapper_struct
ignore_fields:
- klass
ignore_methods:
- init
- destroy
AttrList:
ignore_methods:
- ref
- unref
FontMetrics:
binding_strategy: heap_wrapper_struct
ignore_methods:
Expand Down
3 changes: 3 additions & 0 deletions src/bindings/pango/font_metrics.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module Pango
end

def finalize
{% if flag?(:debugmemory) %}
LibC.printf("~%s at %p - ref count: %d\n", self.class.name.to_unsafe, self, ref_count)
{% end %}
LibPango.pango_font_metrics_unref(to_unsafe)
end
end
Expand Down

0 comments on commit a26d921

Please sign in to comment.