Ignore:
Timestamp:
Feb 27, 2006, 7:51:43 PM (19 years ago)
Author:
eseidel
Message:

2006-02-27 Eric Seidel <[email protected]>

Reviewed by mjs.

Made Assertions.cpp platform independent.
Moved mac-specific logging logic up into WebCore.
http://bugzilla.opendarwin.org/show_bug.cgi?id=7503

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kxmlcore/Assertions.cpp: Added.
  • kxmlcore/Assertions.h:
  • kxmlcore/Assertions.mm: Removed.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kxmlcore/Assertions.cpp

    r13027 r13034  
    11// -*- mode: c++; c-basic-offset: 4 -*-
    22/*
    3  * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
     3 * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    2828#include "Assertions.h"
    2929
    30 #define SUPPORT_OBJC_LOGGING 1
    31 
    32 #if SUPPORT_OBJC_LOGGING
     30#if __APPLE__
    3331#include <CoreFoundation/CFString.h>
    3432#endif
    3533
    36 #include <Foundation/NSString.h>
    37 #include <Foundation/NSUserDefaults.h>
    38 #include <Foundation/NSScanner.h>
    39 
    4034extern "C" {
    4135
     36// This is to work around the "you should use a printf format attribute" warning on GCC
     37// We can't use _attribute__ ((format (printf, 2, 3))) since we allow %@
    4238static int (* vfprintf_no_warning)(FILE *, const char *, va_list) = vfprintf;
    4339
    44 static void vprintf_stderr_objc(const char *format, va_list args)
     40static void vprintf_stderr_common(const char *format, va_list args)
    4541{
    46 #if SUPPORT_OBJC_LOGGING
     42#if __APPLE__
    4743    if (!strstr(format, "%@")) {
    4844        CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8);
     
    7773    va_list args;
    7874    va_start(args, format);
    79     vprintf_stderr_objc(format, args);
     75    vprintf_stderr_common(format, args);
    8076    va_end(args);
    8177    fprintf(stderr, "\n%s (%s:%d %s)\n=================\n", assertion, file, line, function);
     
    9288    va_list args;
    9389    va_start(args, format);
    94     vprintf_stderr_objc(format, args);
     90    vprintf_stderr_common(format, args);
    9591    va_end(args);
    9692    fprintf(stderr, "\n(%s:%d %s)\n=================\n", file, line, function);
     
    10298    va_list args;
    10399    va_start(args, format);
    104     vprintf_stderr_objc(format, args);
     100    vprintf_stderr_common(format, args);
    105101    va_end(args);
    106102    fprintf(stderr, "\n(%s:%d %s)\n=================\n", file, line, function);
    107103}
    108104
    109 static void fprintf_objc(const char *format, ...)
    110 {
    111     va_list args;
    112     va_start(args, format);
    113     vprintf_stderr_objc(format, args);
    114     va_end(args);
    115 }
    116 
    117 
    118105void KXCLog(const char*, int, const char*, KXCLogChannel *channel, const char *format, ...)
    119 {
    120     if (channel->state == KXCLogChannelUninitialized) {
    121         channel->state = KXCLogChannelOff;
    122         NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:channel->defaultName]];
    123         if (logLevelString) {
    124             unsigned logLevel;
    125             if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel]) {
    126                 fprintf_objc("unable to parse hex value for %s (%@), logging is off", channel->defaultName, logLevelString);
    127             }
    128             if ((logLevel & channel->mask) == channel->mask) {
    129                 channel->state = KXCLogChannelOn;
    130             }
    131         }
    132     }
    133    
     106{   
    134107    if (channel->state != KXCLogChannelOn)
    135108        return;
     
    137110    va_list args;
    138111    va_start(args, format);
    139     vprintf_stderr_objc(format, args);
     112    vprintf_stderr_common(format, args);
    140113    va_end(args);
    141114    if (format[strlen(format) - 1] != '\n')
Note: See TracChangeset for help on using the changeset viewer.