Sha256: 9325e267f8fe0db3db17044b9d9cc3e2e0231c55eb19bfc5424da12c5494bb44

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

#
# bitclust/functionentry.rb
#
# Copyright (c) 2006-2008 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the Ruby License.
#

require 'bitclust/entry'
require 'bitclust/exception'

module BitClust

  class FunctionEntry < Entry

    def FunctionEntry.type_id
      :function
    end

    def initialize(db, id)
      super db
      @id = id
      init_properties
    end

    def inspect
      "\#<function #{@id}>"
    end

    def name_match?(re)
      re =~ name()
    end

    def <=>(other)
      @id.casecmp(other.id)
    end

    persistent_properties {
      property :filename,   'String'
      property :macro,      'bool'
      property :private,    'bool'
      property :type,       'String'
      property :name,       'String'
      property :params,     'String'
      property :source,     'String'
    }

    attr_reader :id
    remove_method :name
    alias name id
    alias label id

    alias macro? macro
    alias private? private

    def public?
      not private?
    end

    def callable?
      not params().empty?
    end

    def type_label
      macro? ? 'macro' : 'function'
    end
    alias kind type_label

    def header
      if callable?
        base = "#{type()} #{name()}#{params()}"
      else
        base = "#{type()} #{name()}"
      end
      "#{private? ? 'static ' : ''}#{base}"
    end

    def description
      source.split(/\n\n+/, 2)[0].strip
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bitclust-core-1.2.5 lib/bitclust/functionentry.rb
bitclust-core-1.2.4 lib/bitclust/functionentry.rb
bitclust-core-1.2.3 lib/bitclust/functionentry.rb
bitclust-core-1.2.2 lib/bitclust/functionentry.rb
bitclust-core-1.2.1 lib/bitclust/functionentry.rb
bitclust-core-1.2.0 lib/bitclust/functionentry.rb
bitclust-core-1.1.1 lib/bitclust/functionentry.rb
bitclust-core-1.1.0 lib/bitclust/functionentry.rb