File: HFByteSlice.m

package info (click to toggle)
sameboy 1.0.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 10,528 kB
  • sloc: ansic: 29,948; objc: 22,249; asm: 1,424; pascal: 1,373; makefile: 1,065; xml: 111
file content (85 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
//  HFByteSlice.m
//  HexFiend_2
//
//  Copyright 2007 ridiculous_fish. All rights reserved.
//

#import <HexFiend/HFByteSlice.h>


@implementation HFByteSlice

- (instancetype)init {
    if ([self class] == [HFByteSlice class]) {
        [NSException raise:NSInvalidArgumentException format:@"init sent to HFByteArray, but HFByteArray is an abstract class.  Instantiate one of its subclasses instead."];
    }
    return [super init];
}

- (unsigned long long)length { UNIMPLEMENTED(); }

- (void)copyBytes:(unsigned char*)dst range:(HFRange)range { USE(dst); USE(range); UNIMPLEMENTED_VOID(); }

- (HFByteSlice *)subsliceWithRange:(HFRange)range { USE(range); UNIMPLEMENTED(); }

- (void)constructNewByteSlicesAboutRange:(HFRange)range first:(HFByteSlice **)first second:(HFByteSlice **)second {
    const unsigned long long length = [self length];
    
    //clip the range to our extent
    range.location = llmin(range.location, length);
    range.length = llmin(range.length, length - range.location);
    
    HFRange firstRange = {0, range.location};
    HFRange secondRange = {range.location + range.length, [self length] - (range.location + range.length)};
    
    if (first) {
        if (firstRange.length > 0)
            *first = [self subsliceWithRange:firstRange];
        else
            *first = nil;
    }
    
    if (second) {
        if (secondRange.length > 0)
            *second = [self subsliceWithRange:secondRange];
        else
            *second = nil;
    }
}

- (HFByteSlice *)byteSliceByAppendingSlice:(HFByteSlice *)slice {
    USE(slice);
    return nil;
}

- (HFByteRangeAttributeArray *)attributesForBytesInRange:(HFRange)range {
    USE(range);
    return nil;
}

- (BOOL)isSourcedFromFile {
    return NO;
}

- (HFRange)sourceRangeForFile:(HFFileReference *)reference {
    USE(reference);
    return HFRangeMake(ULLONG_MAX, ULLONG_MAX);
}

- (id)retain {
    HFAtomicIncrement(&retainCount, NO);
    return self;
}

- (oneway void)release {
    if (HFAtomicDecrement(&retainCount, NO) == (NSUInteger)(-1)) {
        [self dealloc];
    }
}

- (NSUInteger)retainCount {
    return 1 + retainCount;
}

@end