Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OODebugStandards.m
Go to the documentation of this file.
1/*
2
3OODebugStandards.m
4
5OXP strictness warnings for errors and deprecated content
6
7
8Copyright (C) 2014
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27
28*/
29
30#import "OODebugStandards.h"
31#import "OOLogging.h"
33#import "GameController.h"
34
35#ifdef NDEBUG
36// in release mode, stubs
37void OOStandardsDeprecated(NSString *message) {}
38void OOStandardsError(NSString *message) {}
39BOOL OOEnforceStandards() { return NO; }
41
42#else
43
44void OOStandardsSetup(void);
45void OOStandardsInternal(NSString *type, NSString *message);
46
47static BOOL sSetup = NO;
48
49typedef enum {
50// do nothing (equivalent to release build)
52// warn in log but otherwise do nothing
54// warn in log, block use of deprecated or error items
56// note in log, then exit if deprecated or error condition occurs
59
61
62
64{
65 if (sSetup)
66 {
67 return;
68 }
69 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
70 int s = [prefs oo_intForKey:@"enforce-oxp-standards"
71 defaultValue:STANDARDS_ENFORCEMENT_WARN];
73 {
75 }
76 else if (s > STANDARDS_ENFORCEMENT_QUIT)
77 {
79 }
80 sEnforcement = s;
81}
82
83
84void OOStandardsInternal(NSString *type, NSString *message)
85{
88 {
89 return;
90 }
91
92 OOLog(type, @"%@", message);
93
95 {
97 // exit
98 }
99}
100
101
102void OOStandardsDeprecated(NSString *message)
103{
104 OOStandardsInternal(@"oxp-standards.deprecated",message);
105}
106
107
108void OOStandardsError(NSString *message)
109{
110 OOStandardsInternal(@"oxp-standards.error",message);
111}
112
113
119
120
126
127
128
129#endif
BOOL OOEnforceStandards()
static OOStandardsEnforcement sEnforcement
void OOStandardsSetup(void)
void OOStandardsDeprecated(NSString *message)
static BOOL sSetup
void OOStandardsInternal(NSString *type, NSString *message)
void OOSetStandardsForOXPVerifierMode()
OOStandardsEnforcement
@ STANDARDS_ENFORCEMENT_OFF
@ STANDARDS_ENFORCEMENT_QUIT
@ STANDARDS_ENFORCEMENT_WARN
@ STANDARDS_ENFORCEMENT_ENFORCE
void OOStandardsError(NSString *message)
#define OOLog(class, format,...)
Definition OOLogging.h:88
GameController * sharedController()
void exitAppWithContext:(NSString *context)