Differences From Artifact [3b65b7b5aa]:
- File
src/OFNull.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 2432) [annotate] [blame] [check-ins using]
To Artifact [8d2ffd1fab]:
- File
src/OFNull.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 2442) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFString.h" #import "OFXMLElement.h" #import "OFDataArray.h" #import "OFInvalidArgumentException.h" @interface OFNull () | | | | | | | | | | | | 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | #import "OFString.h" #import "OFXMLElement.h" #import "OFDataArray.h" #import "OFInvalidArgumentException.h" @interface OFNull () - (OFString *)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end static OFNull *null = nil; @implementation OFNull + (void)initialize { null = [[self alloc] init]; } + (OFNull *)null { return null; } - initWithSerialization: (OFXMLElement *)element { void *pool; [self release]; pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); return [OFNull null]; } - (OFString *)description { return @"<null>"; } - copy { return self; } - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS]; [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } - (OFString *)JSONRepresentation { return [self OF_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { return [self OF_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { return @"null"; } - (OFDataArray *)messagePackRepresentation { OFDataArray *data = [OFDataArray dataArrayWithItemSize: 1 capacity: 1]; uint8_t type = 0xC0; [data addItem: &type]; |
︙ | ︙ |