@@ -4,25 +4,25 @@ module MachO
44 # Represents a "Fat" file, which contains a header, a listing of available
55 # architectures, and one or more Mach-O binaries.
66 # @see https://en.wikipedia.org/wiki/Mach-O#Multi-architecture_binaries
7- # @see MachO:: MachOFile
7+ # @see MachOFile
88 class FatFile
99 extend Forwardable
1010
1111 # @return [String] the filename loaded from, or nil if loaded from a binary string
1212 attr_accessor :filename
1313
14- # @return [MachO:: Headers::FatHeader] the file's header
14+ # @return [Headers::FatHeader] the file's header
1515 attr_reader :header
1616
17- # @return [Array<MachO:: Headers::FatArch>] an array of fat architectures
17+ # @return [Array<Headers::FatArch>] an array of fat architectures
1818 attr_reader :fat_archs
1919
20- # @return [Array<MachO:: MachOFile>] an array of Mach-O binaries
20+ # @return [Array<MachOFile>] an array of Mach-O binaries
2121 attr_reader :machos
2222
2323 # Creates a new FatFile from the given (single-arch) Mach-Os
24- # @param machos [Array<MachO:: MachOFile>] the machos to combine
25- # @return [MachO:: FatFile] a new FatFile containing the give machos
24+ # @param machos [Array<MachOFile>] the machos to combine
25+ # @return [FatFile] a new FatFile containing the give machos
2626 def self . new_from_machos ( *machos )
2727 header = Headers ::FatHeader . new ( Headers ::FAT_MAGIC , machos . size )
2828 offset = Headers ::FatHeader . bytesize + ( machos . size * Headers ::FatArch . bytesize )
@@ -44,7 +44,7 @@ def self.new_from_machos(*machos)
4444
4545 # Creates a new FatFile instance from a binary string.
4646 # @param bin [String] a binary string containing raw Mach-O data
47- # @return [MachO:: FatFile] a new FatFile
47+ # @return [FatFile] a new FatFile
4848 def self . new_from_bin ( bin )
4949 instance = allocate
5050 instance . initialize_from_bin ( bin )
@@ -64,7 +64,7 @@ def initialize(filename)
6464 end
6565
6666 # Initializes a new FatFile instance from a binary string.
67- # @see MachO::FatFile. new_from_bin
67+ # @see new_from_bin
6868 # @api private
6969 def initialize_from_bin ( bin )
7070 @filename = nil
@@ -125,12 +125,13 @@ def populate_fields
125125 end
126126
127127 # All load commands responsible for loading dylibs in the file's Mach-O's.
128- # @return [Array<MachO:: LoadCommands::DylibCommand>] an array of DylibCommands
128+ # @return [Array<LoadCommands::DylibCommand>] an array of DylibCommands
129129 def dylib_load_commands
130130 machos . map ( &:dylib_load_commands ) . flatten
131131 end
132132
133- # Changes the file's dylib ID to `new_id`. If the file is not a dylib, does nothing.
133+ # Changes the file's dylib ID to `new_id`. If the file is not a dylib,
134+ # does nothing.
134135 # @example
135136 # file.change_dylib_id('libFoo.dylib')
136137 # @param new_id [String] the new dylib ID
@@ -139,7 +140,7 @@ def dylib_load_commands
139140 # if false, fail only if all slices fail.
140141 # @return [void]
141142 # @raise [ArgumentError] if `new_id` is not a String
142- # @see MachO:: MachOFile#linked_dylibs
143+ # @see MachOFile#linked_dylibs
143144 def change_dylib_id ( new_id , options = { } )
144145 raise ArgumentError , "argument must be a String" unless new_id . is_a? ( String )
145146 return unless machos . all? ( &:dylib? )
@@ -155,16 +156,17 @@ def change_dylib_id(new_id, options = {})
155156
156157 # All shared libraries linked to the file's Mach-Os.
157158 # @return [Array<String>] an array of all shared libraries
158- # @see MachO:: MachOFile#linked_dylibs
159+ # @see MachOFile#linked_dylibs
159160 def linked_dylibs
160161 # Individual architectures in a fat binary can link to different subsets
161162 # of libraries, but at this point we want to have the full picture, i.e.
162163 # the union of all libraries used by all architectures.
163164 machos . map ( &:linked_dylibs ) . flatten . uniq
164165 end
165166
166- # Changes all dependent shared library install names from `old_name` to `new_name`.
167- # In a fat file, this changes install names in all internal Mach-Os.
167+ # Changes all dependent shared library install names from `old_name` to
168+ # `new_name`. In a fat file, this changes install names in all internal
169+ # Mach-Os.
168170 # @example
169171 # file.change_install_name('/usr/lib/libFoo.dylib', '/usr/lib/libBar.dylib')
170172 # @param old_name [String] the shared library name being changed
@@ -173,7 +175,7 @@ def linked_dylibs
173175 # @option options [Boolean] :strict (true) if true, fail if one slice fails.
174176 # if false, fail only if all slices fail.
175177 # @return [void]
176- # @see MachO:: MachOFile#change_install_name
178+ # @see MachOFile#change_install_name
177179 def change_install_name ( old_name , new_name , options = { } )
178180 each_macho ( options ) do |macho |
179181 macho . change_install_name ( old_name , new_name , options )
@@ -186,7 +188,7 @@ def change_install_name(old_name, new_name, options = {})
186188
187189 # All runtime paths associated with the file's Mach-Os.
188190 # @return [Array<String>] an array of all runtime paths
189- # @see MachO:: MachOFile#rpaths
191+ # @see MachOFile#rpaths
190192 def rpaths
191193 # Can individual architectures have different runtime paths?
192194 machos . map ( &:rpaths ) . flatten . uniq
@@ -199,7 +201,7 @@ def rpaths
199201 # @option options [Boolean] :strict (true) if true, fail if one slice fails.
200202 # if false, fail only if all slices fail.
201203 # @return [void]
202- # @see MachO:: MachOFile#change_rpath
204+ # @see MachOFile#change_rpath
203205 def change_rpath ( old_path , new_path , options = { } )
204206 each_macho ( options ) do |macho |
205207 macho . change_rpath ( old_path , new_path , options )
@@ -214,7 +216,7 @@ def change_rpath(old_path, new_path, options = {})
214216 # @option options [Boolean] :strict (true) if true, fail if one slice fails.
215217 # if false, fail only if all slices fail.
216218 # @return [void]
217- # @see MachO:: MachOFile#add_rpath
219+ # @see MachOFile#add_rpath
218220 def add_rpath ( path , options = { } )
219221 each_macho ( options ) do |macho |
220222 macho . add_rpath ( path , options )
@@ -229,7 +231,7 @@ def add_rpath(path, options = {})
229231 # @option options [Boolean] :strict (true) if true, fail if one slice fails.
230232 # if false, fail only if all slices fail.
231233 # @return void
232- # @see MachO:: MachOFile#delete_rpath
234+ # @see MachOFile#delete_rpath
233235 def delete_rpath ( path , options = { } )
234236 each_macho ( options ) do |macho |
235237 macho . delete_rpath ( path , options )
@@ -242,20 +244,21 @@ def delete_rpath(path, options = {})
242244 # @example
243245 # file.extract(:i386) # => MachO::MachOFile
244246 # @param cputype [Symbol] the CPU type of the Mach-O being extracted
245- # @return [MachO:: MachOFile, nil] the extracted Mach-O or nil if no Mach-O has the given CPU type
247+ # @return [MachOFile, nil] the extracted Mach-O or nil if no Mach-O has the given CPU type
246248 def extract ( cputype )
247249 machos . select { |macho | macho . cputype == cputype } . first
248250 end
249251
250252 # Write all (fat) data to the given filename.
251253 # @param filename [String] the file to write to
254+ # @return [void]
252255 def write ( filename )
253256 File . open ( filename , "wb" ) { |f | f . write ( @raw_data ) }
254257 end
255258
256259 # Write all (fat) data to the file used to initialize the instance.
257260 # @return [void]
258- # @raise [MachO:: MachOError] if the instance was initialized without a file
261+ # @raise [MachOError] if the instance was initialized without a file
259262 # @note Overwrites all data in the file!
260263 def write!
261264 if filename . nil?
@@ -268,11 +271,12 @@ def write!
268271 private
269272
270273 # Obtain the fat header from raw file data.
271- # @return [MachO::Headers::FatHeader] the fat header
272- # @raise [MachO::TruncatedFileError] if the file is too small to have a valid header
273- # @raise [MachO::MagicError] if the magic is not valid Mach-O magic
274- # @raise [MachO::MachOBinaryError] if the magic is for a non-fat Mach-O file
275- # @raise [MachO::JavaClassFileError] if the file is a Java classfile
274+ # @return [Headers::FatHeader] the fat header
275+ # @raise [TruncatedFileError] if the file is too small to have a
276+ # valid header
277+ # @raise [MagicError] if the magic is not valid Mach-O magic
278+ # @raise [MachOBinaryError] if the magic is for a non-fat Mach-O file
279+ # @raise [JavaClassFileError] if the file is a Java classfile
276280 # @api private
277281 def populate_fat_header
278282 # the smallest fat Mach-O header is 8 bytes
@@ -296,7 +300,7 @@ def populate_fat_header
296300 end
297301
298302 # Obtain an array of fat architectures from raw file data.
299- # @return [Array<MachO:: Headers::FatArch>] an array of fat architectures
303+ # @return [Array<Headers::FatArch>] an array of fat architectures
300304 # @api private
301305 def populate_fat_archs
302306 archs = [ ]
@@ -311,7 +315,7 @@ def populate_fat_archs
311315 end
312316
313317 # Obtain an array of Mach-O blobs from raw file data.
314- # @return [Array<MachO:: MachOFile>] an array of Mach-Os
318+ # @return [Array<MachOFile>] an array of Mach-Os
315319 # @api private
316320 def populate_machos
317321 machos = [ ]
@@ -339,7 +343,7 @@ def repopulate_raw_machos
339343 # @option options [Boolean] :strict (true) whether or not to fail loudly
340344 # with an exception if at least one Mach-O raises an exception. If false,
341345 # only raises an exception if *all* Mach-Os raise exceptions.
342- # @raise [MachO:: RecoverableModificationError] under the conditions of
346+ # @raise [RecoverableModificationError] under the conditions of
343347 # the `:strict` option above.
344348 # @api private
345349 def each_macho ( options = { } )
@@ -364,7 +368,7 @@ def each_macho(options = {})
364368
365369 # Return a single-arch Mach-O that represents this fat Mach-O for purposes
366370 # of delegation.
367- # @return [MachO:: MachOFile] the Mach-O file
371+ # @return [MachOFile] the Mach-O file
368372 # @api private
369373 def canonical_macho
370374 machos . first
0 commit comments