forked from nygard/class-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDLCSourceVersion.m
57 lines (43 loc) · 1.47 KB
/
CDLCSourceVersion.m
1
2
3
4
5
6
7
8
9
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
// -*- mode: ObjC -*-
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2015 Steve Nygard.
#import "CDLCSourceVersion.h"
#import "CDMachOFile.h"
@implementation CDLCSourceVersion
{
struct source_version_command _sourceVersionCommand;
}
- (id)initWithDataCursor:(CDMachOFileDataCursor *)cursor;
{
if ((self = [super initWithDataCursor:cursor])) {
_sourceVersionCommand.cmd = [cursor readInt32];
_sourceVersionCommand.cmdsize = [cursor readInt32];
_sourceVersionCommand.version = [cursor readInt64];
}
return self;
}
#pragma mark -
- (uint32_t)cmd;
{
return _sourceVersionCommand.cmd;
}
- (uint32_t)cmdsize;
{
return _sourceVersionCommand.cmdsize;
}
- (NSString *)sourceVersionString;
{
// A.B.C.D.E packed as a24.b10.c10.d10.e10
uint32_t a = (_sourceVersionCommand.version >> 40);
uint32_t b = (_sourceVersionCommand.version >> 30) & 0x3f;
uint32_t c = (_sourceVersionCommand.version >> 20) & 0x3f;
uint32_t d = (_sourceVersionCommand.version >> 10) & 0x3f;
uint32_t e = _sourceVersionCommand.version & 0x3f;
return [NSString stringWithFormat:@"%u.%u.%u.%u.%u", a, b, c, d, e];
}
- (void)appendToString:(NSMutableString *)resultString verbose:(BOOL)isVerbose;
{
[super appendToString:resultString verbose:isVerbose];
[resultString appendFormat:@" Source version: %@\n", self.sourceVersionString];
}
@end