Sha256: c1429c82e2b398f263fdf2d8872ca7c0b365b98291029e81e6381932559e40a3

Contents?: true

Size: 924 Bytes

Versions: 25

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require 'headdesk/apk/field'
require 'headdesk/apk/method'

module Headdesk
  class Apk
    #
    # A Smali bytecode class
    #
    class Class
      # Formats:
      #   android/content/Context
      #   android.content.Context
      def self.path_for(decl)
        File.join(*decl.split(%r{[\/,\.]}))
      end

      def initialize(smali_file)
        @smali = File.read(smali_file)
      end

      def method?(name)
        method(name) != false
      end

      def method(name)
        matchdata = /(^\.method .* #{name}.*$[\s\S]*?\.end method)/.match(@smali)
        return nil unless matchdata

        Method.new(matchdata)
      end

      def field?(name)
        field(name) != false
      end

      def field(name)
        matchdata = /^\.field .* #{name}.* = "(.*)"$/.match(@smali)
        return nil unless matchdata

        Field.new(matchdata)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
headdesk-0.5.0 lib/headdesk/apk/class.rb
headdesk-0.4.0 lib/headdesk/apk/class.rb
headdesk-0.3.0 lib/headdesk/apk/class.rb
headdesk-0.2.0 lib/headdesk/apk/class.rb
headdesk-0.1.0 lib/headdesk/apk/class.rb