]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/mdns_objects/mdns_objects.m
mDNSResponder-1310.40.42.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / mdns_objects / mdns_objects.m
1 /*
2 * Copyright (c) 2019-2020 Apple Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #undef MDNS_OBJECT_FORCE_NO_OBJC
18 #define MDNS_OBJECT_FORCE_NO_OBJC 0
19 #import "mdns_objects.h"
20
21 #import <CoreUtils/CoreUtils.h>
22 #import <Foundation/Foundation.h>
23 #import <os/object_private.h>
24
25 //======================================================================================================================
26 // MARK: - Class Definitions
27
28 #define MDNS_CLASS(NAME) OS_OBJECT_CLASS(mdns_ ## NAME)
29
30 @implementation OS_OBJECT_CLASS(mdns_object)
31 - (void)dealloc
32 {
33 mdns_object_finalize(self);
34 arc_safe_super_dealloc();
35 }
36
37 - (NSString *)description
38 {
39 NSString * const nsstr = (NSString *)CFBridgingTransfer(mdns_object_copy_description_as_cfstring(self));
40 return arc_safe_autorelease(nsstr);
41 }
42
43 - (NSString *)debugDescription
44 {
45 NSString * const nsstr = (NSString *)CFBridgingTransfer(mdns_object_copy_debug_description_as_cfstring(self));
46 return arc_safe_autorelease(nsstr);
47 }
48
49 - (NSString *)redactedDescription
50 {
51 NSString * const nsstr = (NSString *)CFBridgingTransfer(mdns_object_copy_redacted_description_as_cfstring(self));
52 return arc_safe_autorelease(nsstr);
53 }
54
55 - (BOOL)isEqual:(id)other
56 {
57 if (self == other) {
58 return YES;
59 }
60 if (![other isKindOfClass:[MDNS_CLASS(object) class]]) {
61 return NO;
62 }
63 return (mdns_equal(self, (mdns_object_t)other) ? YES : NO);
64 }
65 @end
66
67 #define MDNS_OBJECT_CLASS_DEFINE(NAME) \
68 _OS_OBJECT_DECL_SUBCLASS_INTERFACE(mdns_ ## NAME, mdns_object) \
69 \
70 @implementation MDNS_CLASS(NAME) \
71 @end \
72 \
73 mdns_ ## NAME ## _t \
74 mdns_ ## NAME ## _object_alloc(const size_t size) \
75 { \
76 return (mdns_ ## NAME ## _t)_os_object_alloc([MDNS_CLASS(NAME) class], size); \
77 } \
78 extern int _mdns_dummy_variable
79
80 MDNS_OBJECT_CLASS_DEFINE(address);
81 MDNS_OBJECT_CLASS_DEFINE(dns_service);
82 MDNS_OBJECT_CLASS_DEFINE(dns_service_manager);
83 MDNS_OBJECT_CLASS_DEFINE(interface_monitor);
84 MDNS_OBJECT_CLASS_DEFINE(message);
85 MDNS_OBJECT_CLASS_DEFINE(query_message);
86 MDNS_OBJECT_CLASS_DEFINE(querier);
87 MDNS_OBJECT_CLASS_DEFINE(resolver);
88 MDNS_OBJECT_CLASS_DEFINE(server);
89 MDNS_OBJECT_CLASS_DEFINE(session);
90 MDNS_OBJECT_CLASS_DEFINE(set);
91 MDNS_OBJECT_CLASS_DEFINE(trust);