LCOV - code coverage report
Current view: top level - Core/Debug - OODebugStandards.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 10 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

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

Generated by: LCOV version 1.14