]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/mdns_object.m
mDNSResponder-1096.100.3.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / mdns_object.m
1 /*
2 * Copyright (c) 2019 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 #import "mdns_object.h"
18
19 #import <CoreUtils/CoreUtils.h>
20 #import <Foundation/Foundation.h>
21 #import <os/object_private.h>
22
23 //======================================================================================================================
24 // MARK: - Class Declarations
25
26 #define MDNS_OBJECT_CLASS_DECLARE(NAME) \
27 _OS_OBJECT_DECL_SUBCLASS_INTERFACE(mdns_ ## NAME, mdns_object) \
28 extern int _mdns_dummy_variable
29
30 _OS_OBJECT_DECL_SUBCLASS_INTERFACE(mdns_object, object)
31
32 MDNS_OBJECT_CLASS_DECLARE(interface_monitor);
33
34 //======================================================================================================================
35 // MARK: - Class Definitions
36
37 @implementation OS_OBJECT_CLASS(mdns_object)
38 - (void)dealloc
39 {
40 mdns_object_finalize(self);
41 arc_safe_super_dealloc();
42 }
43
44 - (NSString *)description
45 {
46 return arc_safe_autorelease((NSString *)mdns_object_copy_description_as_cfstring(self, false, false));
47 }
48
49 - (NSString *)debugDescription
50 {
51 return arc_safe_autorelease((NSString *)mdns_object_copy_description_as_cfstring(self, true, false));
52 }
53
54 - (NSString *)redactedDescription
55 {
56 return arc_safe_autorelease((NSString *)mdns_object_copy_description_as_cfstring(self, false, true));
57 }
58 @end
59
60 #define MDNS_CLASS(NAME) OS_OBJECT_CLASS(mdns_ ## NAME)
61 #define MDNS_OBJECT_CLASS_DEFINE(NAME) \
62 @implementation MDNS_CLASS(NAME) \
63 @end \
64 \
65 mdns_ ## NAME ## _t \
66 mdns_object_ ## NAME ## _alloc(const size_t size) \
67 { \
68 return (mdns_## NAME ##_t)_os_object_alloc([MDNS_CLASS(NAME) class], size); \
69 } \
70 extern int _mdns_dummy_variable
71
72 MDNS_OBJECT_CLASS_DEFINE(interface_monitor);