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 */,
// -*- 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);
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);
}
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);
}
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);