Class: Android::Dex::ClassInfo
- Inherits:
-
Object
- Object
- Android::Dex::ClassInfo
- Defined in:
- lib/android/dex/info.rb
Overview
class information in dex
Constant Summary collapse
- NO_INDEX =
no index flag
0xffffffff
Instance Attribute Summary collapse
- #access_flags ⇒ ClassAccessFlag readonly
- #class_data ⇒ DexObject::ClassDataItem readonly
- #class_def ⇒ DexObject::ClassDefItem readonly
-
#direct_methods ⇒ Array<MethodInfo>
readonly
Direct methods.
-
#instance_fields ⇒ Array<FieldInfo>
readonly
Instance fields.
-
#name ⇒ String
readonly
Class name.
-
#static_fields ⇒ Array<FieldInfo>
readonly
Static fields.
-
#super_class ⇒ String
readonly
Super class name.
-
#virtual_methods ⇒ Array<MethodInfo>
readonly
Virtual methods.
Instance Method Summary collapse
-
#definition ⇒ String
Class difinition.
-
#initialize(class_def, dex) ⇒ ClassInfo
constructor
A new instance of ClassInfo.
Constructor Details
#initialize(class_def, dex) ⇒ ClassInfo
Returns a new instance of ClassInfo.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/android/dex/info.rb', line 42 def initialize(class_def, dex) @class_def = class_def @dex = dex @access_flags = ClassAccessFlag.new(@class_def[:access_flags]) @class_data = @class_def.class_data_item @static_fields = @instance_fields = @direct_methods = @virtual_methods = [] unless @class_data.nil? @static_fields = cls2info(@class_data[:static_fields], FieldInfo, :field_idx_diff) @instance_fields = cls2info(@class_data[:instance_fields], FieldInfo, :field_idx_diff) @direct_methods = cls2info(@class_data[:direct_methods], MethodInfo, :method_idx_diff) @virtual_methods = cls2info(@class_data[:virtual_methods], MethodInfo, :method_idx_diff) end end |
Instance Attribute Details
#access_flags ⇒ ClassAccessFlag (readonly)
15 16 17 |
# File 'lib/android/dex/info.rb', line 15 def access_flags @access_flags end |
#class_data ⇒ DexObject::ClassDataItem (readonly)
26 27 28 |
# File 'lib/android/dex/info.rb', line 26 def class_data @class_data end |
#class_def ⇒ DexObject::ClassDefItem (readonly)
28 29 30 |
# File 'lib/android/dex/info.rb', line 28 def class_def @class_def end |
#direct_methods ⇒ Array<MethodInfo> (readonly)
Returns direct methods.
21 22 23 |
# File 'lib/android/dex/info.rb', line 21 def direct_methods @direct_methods end |
#instance_fields ⇒ Array<FieldInfo> (readonly)
Returns instance fields.
19 20 21 |
# File 'lib/android/dex/info.rb', line 19 def instance_fields @instance_fields end |
#name ⇒ String (readonly)
Returns class name.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/android/dex/info.rb', line 10 class ClassInfo # no index flag NO_INDEX = 0xffffffff # @return [ClassAccessFlag] attr_reader :access_flags # @return [Array<FieldInfo>] static fields attr_reader :static_fields # @return [Array<FieldInfo>] instance fields attr_reader :instance_fields # @return [Array<MethodInfo>] direct methods attr_reader :direct_methods # @return [Array<MethodInfo>] virtual methods attr_reader :virtual_methods # @return [DexObject::ClassDataItem] attr_reader :class_data # @return [DexObject::ClassDefItem] attr_reader :class_def def name @dex.type_resolve(@class_def[:class_idx]) end def super_class if @class_def[:superclass_idx] != NO_INDEX @super_class = @dex.type_resolve(@class_def[:superclass_idx]) else nil end end # @param [Dex::ClassDefItem] class_def # @param [Dex] dex dex class instance def initialize(class_def, dex) @class_def = class_def @dex = dex @access_flags = ClassAccessFlag.new(@class_def[:access_flags]) @class_data = @class_def.class_data_item @static_fields = @instance_fields = @direct_methods = @virtual_methods = [] unless @class_data.nil? @static_fields = cls2info(@class_data[:static_fields], FieldInfo, :field_idx_diff) @instance_fields = cls2info(@class_data[:instance_fields], FieldInfo, :field_idx_diff) @direct_methods = cls2info(@class_data[:direct_methods], MethodInfo, :method_idx_diff) @virtual_methods = cls2info(@class_data[:virtual_methods], MethodInfo, :method_idx_diff) end end # @return [String] class difinition def definition ret = "#{access_flags} class #{name}" super_class.nil? ? ret : ret + " extends #{super_class}" end private def cls2info(arr, cls, idx_key) idx = 0 ret = [] arr.each do |item| idx += item[idx_key] ret << cls.new(item, idx, @dex) end ret end end |
#static_fields ⇒ Array<FieldInfo> (readonly)
Returns static fields.
17 18 19 |
# File 'lib/android/dex/info.rb', line 17 def static_fields @static_fields end |
#super_class ⇒ String (readonly)
Returns super class name.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/android/dex/info.rb', line 10 class ClassInfo # no index flag NO_INDEX = 0xffffffff # @return [ClassAccessFlag] attr_reader :access_flags # @return [Array<FieldInfo>] static fields attr_reader :static_fields # @return [Array<FieldInfo>] instance fields attr_reader :instance_fields # @return [Array<MethodInfo>] direct methods attr_reader :direct_methods # @return [Array<MethodInfo>] virtual methods attr_reader :virtual_methods # @return [DexObject::ClassDataItem] attr_reader :class_data # @return [DexObject::ClassDefItem] attr_reader :class_def def name @dex.type_resolve(@class_def[:class_idx]) end def super_class if @class_def[:superclass_idx] != NO_INDEX @super_class = @dex.type_resolve(@class_def[:superclass_idx]) else nil end end # @param [Dex::ClassDefItem] class_def # @param [Dex] dex dex class instance def initialize(class_def, dex) @class_def = class_def @dex = dex @access_flags = ClassAccessFlag.new(@class_def[:access_flags]) @class_data = @class_def.class_data_item @static_fields = @instance_fields = @direct_methods = @virtual_methods = [] unless @class_data.nil? @static_fields = cls2info(@class_data[:static_fields], FieldInfo, :field_idx_diff) @instance_fields = cls2info(@class_data[:instance_fields], FieldInfo, :field_idx_diff) @direct_methods = cls2info(@class_data[:direct_methods], MethodInfo, :method_idx_diff) @virtual_methods = cls2info(@class_data[:virtual_methods], MethodInfo, :method_idx_diff) end end # @return [String] class difinition def definition ret = "#{access_flags} class #{name}" super_class.nil? ? ret : ret + " extends #{super_class}" end private def cls2info(arr, cls, idx_key) idx = 0 ret = [] arr.each do |item| idx += item[idx_key] ret << cls.new(item, idx, @dex) end ret end end |
#virtual_methods ⇒ Array<MethodInfo> (readonly)
Returns virtual methods.
23 24 25 |
# File 'lib/android/dex/info.rb', line 23 def virtual_methods @virtual_methods end |
Instance Method Details
#definition ⇒ String
Returns class difinition.
57 58 59 60 |
# File 'lib/android/dex/info.rb', line 57 def definition ret = "#{access_flags} class #{name}" super_class.nil? ? ret : ret + " extends #{super_class}" end |