Sha256: 296a32e67d27819a42eaee41a6101ffe8c188174b9e6c4dcf2555776bc77f1fd

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require 'ffi'

require 'uia/library/struct_attributes'

module Uia
  module Library
    module ElementLayout
      def self.included(base)
        base.class_eval do
          extend StructAttributes

          layout :handle, :int,
                 :runtime_id, :pointer,
                 :number_of_ids, :int,
                 :name, :string,
                 :class_name, :string,
                 :control_type_id, :int,
                 :patterns, :pointer,
                 :patterns_length, :int,
                 :id, :string,
                 :is_enabled, :bool,
                 :is_visible, :bool

          struct_attr :id, :name, :handle, :control_type_id, :class_name,
                      [:enabled?, :is_enabled], [:visible?, :is_visible]

          def runtime_id
            self[:runtime_id].read_array_of_int(number_of_ids)
          end

          def pattern_ids
            self[:patterns].read_array_of_int(self[:patterns_length])
          end

          def children
            Library.children(self)
          end

          def descendants
            Library.descendants(self)
          end

          def empty?
            to_ptr.address == 0
          end

          private
          def number_of_ids
            self[:number_of_ids]
          end
        end
      end
    end

    class ManagedElementStruct < FFI::ManagedStruct
      include ElementLayout

      def self.release(pointer)
        Library.release_element(pointer)
      end
    end

    class ElementStruct < FFI::Struct
      include ElementLayout
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uia-0.0.8 lib/uia/library/element_structs.rb