format code

This commit is contained in:
2023-05-31 16:31:52 +07:00
parent e3453ae127
commit 841a50f8e1
12 changed files with 201 additions and 196 deletions

View File

@ -1,8 +1,8 @@
/// Contains the declaration of FatHeader and FatArch
/// These structs are always written using Big-Endian,
/// as documented in the mach-o/fat.h
/// This file also has a CreateFat function to generate
/// Fat file from a list of MachoContext
// / Contains the declaration of FatHeader and FatArch
// / These structs are always written using Big-Endian,
// / as documented in the mach-o/fat.h
// / This file also has a CreateFat function to generate
// / Fat file from a list of MachoContext
package fat
import (
@ -16,8 +16,8 @@ import (
macho "ios-wrapper/pkg/ios/macho"
)
/// Get the alignment for the Mach-O in Fat binary
/// The returned value is the multiplier of 2
// / Get the alignment for the Mach-O in Fat binary
// / The returned value is the multiplier of 2
func GetAlignment(h *macho.Header) uint32 {
switch h.Cputype() {
case CPU_TYPE_ARM, CPU_TYPE_ARM64:
@ -46,17 +46,17 @@ func MachosToFatArchs(machos []*macho.MachoContext) []*FatArch {
return fa
}
/// Create a Fat binary from MachoContext
/// Convert MachoContext to FatArch
/// Calculate the alignment, now using basic calculation
/// because iOS always has valid archs ARM
///
/// Sort the Fat arch as per the cctools/lipo
/// Calculate the offset with each Mach-O
///
/// Write the FatHeader
/// Write the FatArchs
/// Write the Mach-Os
// / Create a Fat binary from MachoContext
// / Convert MachoContext to FatArch
// / Calculate the alignment, now using basic calculation
// / because iOS always has valid archs ARM
// /
// / Sort the Fat arch as per the cctools/lipo
// / Calculate the offset with each Mach-O
// /
// / Write the FatHeader
// / Write the FatArchs
// / Write the Mach-Os
func CreateFat(machos []*macho.MachoContext, outfilename string) error {
archs := MachosToFatArchs(machos)
sort.SliceStable(archs, func(i, j int) bool {
@ -139,9 +139,9 @@ func (fw *fatWriter) WriteFatArchs(w io.Writer, archs []*FatArch) {
}
}
/// for each fat arch sorted, we locate the MachoContext and
/// use it to Write to the buffer
/// locating the macho by its cputype and cpusubtype
// / for each fat arch sorted, we locate the MachoContext and
// / use it to Write to the buffer
// / locating the macho by its cputype and cpusubtype
func (fw *fatWriter) WriteMachos(
w io.WriteSeeker,
archs []*FatArch,