2006-02-27 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Feb 2006 03:51:43 +0000 (03:51 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Feb 2006 03:51:43 +0000 (03:51 +0000)
        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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13034 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/kxmlcore/Assertions.cpp [moved from JavaScriptCore/kxmlcore/Assertions.mm with 75% similarity]
JavaScriptCore/kxmlcore/Assertions.h

index e2d503786c30a1dc9ef673cf91f5989b853c24de..f685f1ce80ee5c413d0227401e1372623f6a116a 100644 (file)
@@ -1,3 +1,16 @@
+2006-02-27  Eric Seidel  <eseidel@apple.com>
+
+        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.
+
 2006-02-27  Darin Adler  <darin@apple.com>
 
         - fixed Mac Debug build, there was an unused parameter
index 3d8e5687bbe01992f7a82a5a6c1f51632d530849..4d7636039036384e6282afb038762e1984aea3b8 100644 (file)
@@ -51,7 +51,7 @@
                65DFC93408EA173A00F7300B /* HashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92E08EA173A00F7300B /* HashTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65DFC93508EA173A00F7300B /* HashTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92F08EA173A00F7300B /* HashTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65E217BD08E7EECC0023E5F6 /* Assertions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E217B708E7EECC0023E5F6 /* Assertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               65E217BE08E7EECC0023E5F6 /* Assertions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B808E7EECC0023E5F6 /* Assertions.mm */; };
+               65E217BE08E7EECC0023E5F6 /* Assertions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B808E7EECC0023E5F6 /* Assertions.cpp */; };
                65E217BF08E7EECC0023E5F6 /* FastMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */; };
                65E217C008E7EECC0023E5F6 /* FastMalloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E217BA08E7EECC0023E5F6 /* FastMalloc.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65EA4C9B092AF9E20093D800 /* JSLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65EA4C99092AF9E20093D800 /* JSLock.cpp */; };
                65DFC92E08EA173A00F7300B /* HashTable.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashTable.h; sourceTree = "<group>"; tabWidth = 8; };
                65DFC92F08EA173A00F7300B /* HashTraits.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashTraits.h; sourceTree = "<group>"; tabWidth = 8; };
                65E217B708E7EECC0023E5F6 /* Assertions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Assertions.h; sourceTree = "<group>"; tabWidth = 8; };
-               65E217B808E7EECC0023E5F6 /* Assertions.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Assertions.mm; sourceTree = "<group>"; tabWidth = 8; };
+               65E217B808E7EECC0023E5F6 /* Assertions.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Assertions.cpp; sourceTree = "<group>"; tabWidth = 8; };
                65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FastMalloc.cpp; sourceTree = "<group>"; tabWidth = 8; };
                65E217BA08E7EECC0023E5F6 /* FastMalloc.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = FastMalloc.h; sourceTree = "<group>"; tabWidth = 8; };
                65EA4C99092AF9E20093D800 /* JSLock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLock.cpp; sourceTree = "<group>"; tabWidth = 8; };
                        children = (
                                93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
                                65E217B708E7EECC0023E5F6 /* Assertions.h */,
-                               65E217B808E7EECC0023E5F6 /* Assertions.mm */,
+                               65E217B808E7EECC0023E5F6 /* Assertions.cpp */,
                                65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */,
                                65E217BA08E7EECC0023E5F6 /* FastMalloc.h */,
                                65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */,
                                93E26BD408B1514100F85226 /* pcre_xclass.c in Sources */,
                                93E26CF708B29A1C00F85226 /* pcre_get.c in Sources */,
                                93E26DDC08B2A4F400F85226 /* pcre_printint.c in Sources */,
-                               65E217BE08E7EECC0023E5F6 /* Assertions.mm in Sources */,
+                               65E217BE08E7EECC0023E5F6 /* Assertions.cpp in Sources */,
                                65E217BF08E7EECC0023E5F6 /* FastMalloc.cpp in Sources */,
                                6541BD7408E80A17002CBEE7 /* TCSystemAlloc.cpp in Sources */,
                                65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */,
similarity index 75%
rename from JavaScriptCore/kxmlcore/Assertions.mm
rename to JavaScriptCore/kxmlcore/Assertions.cpp
index 4e86ce1d76042933d15f5b116300b74a3028a5e0..19b9a16e1109bfe1c8ea30e6c19f1175b9b1609f 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: c++; c-basic-offset: 4 -*-
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "Assertions.h"
 
-#define SUPPORT_OBJC_LOGGING 1
-
-#if SUPPORT_OBJC_LOGGING
+#if __APPLE__
 #include <CoreFoundation/CFString.h>
 #endif
 
-#include <Foundation/NSString.h>
-#include <Foundation/NSUserDefaults.h>
-#include <Foundation/NSScanner.h>
-
 extern "C" {
 
+// This is to work around the "you should use a printf format attribute" warning on GCC
+// We can't use _attribute__ ((format (printf, 2, 3))) since we allow %@
 static int (* vfprintf_no_warning)(FILE *, const char *, va_list) = vfprintf;
 
-static void vprintf_stderr_objc(const char *format, va_list args)
+static void vprintf_stderr_common(const char *format, va_list args)
 {
-#if SUPPORT_OBJC_LOGGING
+#if __APPLE__
     if (!strstr(format, "%@")) {
         CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8);
         CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args);
@@ -76,7 +72,7 @@ void KXCReportAssertionFailureWithMessage(const char *file, int line, const char
     fprintf(stderr, "=================\nASSERTION FAILED: ");
     va_list args;
     va_start(args, format);
-    vprintf_stderr_objc(format, args);
+    vprintf_stderr_common(format, args);
     va_end(args);
     fprintf(stderr, "\n%s (%s:%d %s)\n=================\n", assertion, file, line, function);
 }
@@ -91,7 +87,7 @@ void KXCReportFatalError(const char *file, int line, const char *function, const
     fprintf(stderr, "=================\nFATAL ERROR: ");
     va_list args;
     va_start(args, format);
-    vprintf_stderr_objc(format, args);
+    vprintf_stderr_common(format, args);
     va_end(args);
     fprintf(stderr, "\n(%s:%d %s)\n=================\n", file, line, function);
 }
@@ -101,42 +97,19 @@ void KXCReportError(const char *file, int line, const char *function, const char
     fprintf(stderr, "=================\nERROR: ");
     va_list args;
     va_start(args, format);
-    vprintf_stderr_objc(format, args);
+    vprintf_stderr_common(format, args);
     va_end(args);
     fprintf(stderr, "\n(%s:%d %s)\n=================\n", file, line, function);
 }
 
-static void fprintf_objc(const char *format, ...)
-{
-    va_list args;
-    va_start(args, format);
-    vprintf_stderr_objc(format, args);
-    va_end(args);
-}
-
-
 void KXCLog(const char*, int, const char*, KXCLogChannel *channel, const char *format, ...)
-{
-    if (channel->state == KXCLogChannelUninitialized) {
-        channel->state = KXCLogChannelOff;
-        NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithCString:channel->defaultName]];
-        if (logLevelString) {
-            unsigned logLevel;
-            if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel]) {
-                fprintf_objc("unable to parse hex value for %s (%@), logging is off", channel->defaultName, logLevelString);
-            }
-            if ((logLevel & channel->mask) == channel->mask) {
-                channel->state = KXCLogChannelOn;
-            }
-        }
-    }
-    
+{    
     if (channel->state != KXCLogChannelOn)
         return;
     
     va_list args;
     va_start(args, format);
-    vprintf_stderr_objc(format, args);
+    vprintf_stderr_common(format, args);
     va_end(args);
     if (format[strlen(format) - 1] != '\n')
         putc('\n', stderr);
index 28caa1ca041f722798987f5f7530f24c4c41caba..7c74d1d88d80576d6cfcfffb45b9e823023f4414 100644 (file)
@@ -77,7 +77,7 @@
 extern "C" {
 #endif
 
-typedef enum { KXCLogChannelUninitialized, KXCLogChannelOff, KXCLogChannelOn } KXCLogChannelState;
+typedef enum { KXCLogChannelOff, KXCLogChannelOn } KXCLogChannelState;
 
 typedef struct {
     unsigned mask;