Reviewed by Eric.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2005 23:32:34 +0000 (23:32 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2005 23:32:34 +0000 (23:32 +0000)
        - converted tabs to spaces, NULL to 0, added some (void), got rid of __ prefixes
          in headers (reserved for compiler/library)

        * Info.plist:
        * JSBase.cpp:
        * JSBase.h:
        * JSObject.cpp:
        * JSObject.h:
        * JSRun.cpp:
        * JSRun.h:
        * JSUtils.cpp:
        * JSUtils.h:
        * JSValueWrapper.cpp:
        * JSValueWrapper.h:
        * JavaScriptGlue.cpp:
        * JavaScriptGlue.h:
        * UserObjectImp.cpp:
        * UserObjectImp.h:

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

16 files changed:
JavaScriptGlue/ChangeLog
JavaScriptGlue/Info.plist
JavaScriptGlue/JSBase.cpp
JavaScriptGlue/JSBase.h
JavaScriptGlue/JSObject.cpp
JavaScriptGlue/JSObject.h
JavaScriptGlue/JSRun.cpp
JavaScriptGlue/JSRun.h
JavaScriptGlue/JSUtils.cpp
JavaScriptGlue/JSUtils.h
JavaScriptGlue/JSValueWrapper.cpp
JavaScriptGlue/JSValueWrapper.h
JavaScriptGlue/JavaScriptGlue.cpp
JavaScriptGlue/JavaScriptGlue.h
JavaScriptGlue/UserObjectImp.cpp
JavaScriptGlue/UserObjectImp.h

index 5c8fa56..d37c062 100644 (file)
@@ -1,5 +1,28 @@
 2005-10-10  Darin Adler  <darin@apple.com>
 
+        Reviewed by Eric.
+
+        - converted tabs to spaces, NULL to 0, added some (void), got rid of __ prefixes
+          in headers (reserved for compiler/library)
+
+        * Info.plist:
+        * JSBase.cpp:
+        * JSBase.h:
+        * JSObject.cpp:
+        * JSObject.h:
+        * JSRun.cpp:
+        * JSRun.h:
+        * JSUtils.cpp:
+        * JSUtils.h:
+        * JSValueWrapper.cpp:
+        * JSValueWrapper.h:
+        * JavaScriptGlue.cpp:
+        * JavaScriptGlue.h:
+        * UserObjectImp.cpp:
+        * UserObjectImp.h:
+
+2005-10-10  Darin Adler  <darin@apple.com>
+
         * .cvsignore: Added. Ignore Makefile.in and Makefile.
 
 2005-10-07  Timothy Hatcher  <timothy@apple.com>
index 647ca92..3c59b1f 100644 (file)
@@ -2,27 +2,27 @@
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>JavaScriptGlue</string>
-       <key>CFBundleGetInfoString</key>
-       <string>420+, Copyright 2005, Apple Computer Inc.</string>
-       <key>CFBundleIconFile</key>
-       <string></string>
-       <key>CFBundleIdentifier</key>
-       <string>com.apple.JavaScriptGlue</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundlePackageType</key>
-       <string>FMWK</string>
-       <key>CFBundleShortVersionString</key>
-       <string>420+</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>420+</string>
-       <key>NSPrincipalClass</key>
-       <string></string>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleExecutable</key>
+    <string>JavaScriptGlue</string>
+    <key>CFBundleGetInfoString</key>
+    <string>420+, Copyright 2005, Apple Computer Inc.</string>
+    <key>CFBundleIconFile</key>
+    <string></string>
+    <key>CFBundleIdentifier</key>
+    <string>com.apple.JavaScriptGlue</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundlePackageType</key>
+    <string>FMWK</string>
+    <key>CFBundleShortVersionString</key>
+    <string>420+</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleVersion</key>
+    <string>420+</string>
+    <key>NSPrincipalClass</key>
+    <string></string>
 </dict>
 </plist>
index 8007c8f..252ef18 100644 (file)
@@ -4,49 +4,49 @@
 
 #include "JSBase.h"
 
-JSBase::JSBase(JSTypeID type) : fTypeID(type), fRetainCount(1) 
-{ 
+JSBase::JSBase(JSTypeID type) : fTypeID(type), fRetainCount(1)
+{
 }
 
-JSBase::~JSBase() 
+JSBase::~JSBase()
 {
 }
-       
-JSBase* JSBase::Retain() 
+
+JSBase* JSBase::Retain()
 {
-       fRetainCount++; return this; 
+    fRetainCount++; return this;
 }
 
-void JSBase::Release() 
-{ 
-       if (--fRetainCount == 0) 
-       {
-               delete this;
-       } 
+void JSBase::Release()
+{
+    if (--fRetainCount == 0)
+    {
+        delete this;
+    }
 }
 
 CFIndex JSBase::RetainCount() const
 {
-       return fRetainCount; 
+    return fRetainCount;
 }
 
-JSTypeID JSBase::GetTypeID() const 
-{ 
-       return fTypeID; 
+JSTypeID JSBase::GetTypeID() const
+{
+    return fTypeID;
 }
-               
-CFStringRef JSBase::CopyDescription() 
-{ 
-       return CFStringCreateWithFormat(
-                               NULL,
-                               NULL,
-                               CFSTR("<JSTypeRef- ptr:0x%lx type: %d, retaincount: %ld>"), 
-                               (long)this,
-                               (int)fTypeID,
-                               (long)fRetainCount); 
+
+CFStringRef JSBase::CopyDescription()
+{
+    return CFStringCreateWithFormat(
+                0,
+                0,
+                CFSTR("<JSTypeRef- ptr:0x%lx type: %d, retaincount: %ld>"),
+                (long)this,
+                (int)fTypeID,
+                (long)fRetainCount);
 }
 
-UInt8 JSBase::Equal(JSBase* other) 
-{ 
-       return this == other; 
+UInt8 JSBase::Equal(JSBase* other)
+{
+    return this == other;
 }
index de59869..c822c27 100644 (file)
@@ -2,27 +2,27 @@
 // JSBase.h
 //
 
-#ifndef __JSBase_h
-#define __JSBase_h
+#ifndef JSBase_h
+#define JSBase_h
 
 #include "JSUtils.h"
 
 class JSBase {
-       public:
-               JSBase(JSTypeID type);
-               virtual ~JSBase();
-       
-               JSBase* Retain();
-               void Release();
-               CFIndex RetainCount() const;
-               JSTypeID GetTypeID() const;
-               
-               virtual CFStringRef CopyDescription();
-               virtual UInt8 Equal(JSBase* other);
-               
-       private:
-               JSTypeID fTypeID;
-               CFIndex fRetainCount;
+    public:
+        JSBase(JSTypeID type);
+        virtual ~JSBase();
+
+        JSBase* Retain();
+        void Release();
+        CFIndex RetainCount() const;
+        JSTypeID GetTypeID() const;
+
+        virtual CFStringRef CopyDescription();
+        virtual UInt8 Equal(JSBase* other);
+
+    private:
+        JSTypeID fTypeID;
+        CFIndex fRetainCount;
 };
 
-#endif
\ No newline at end of file
+#endif
index 1c0a078..06781c2 100644 (file)
 //
-//     JSObject.cpp
+// JSObject.cpp
 //
 
 #include "JSObject.h"
 
-JSUserObject::JSUserObject(JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, void* data, int dataType) 
-       : JSBase(kJSObjectTypeID), fCallBacks(*callBacks), fMarkProc(markProc), fData(data), fDataType(dataType)
-{ 
+JSUserObject::JSUserObject(JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, void *data, int dataType)
+    : JSBase(kJSObjectTypeID), fCallBacks(*callBacks), fMarkProc(markProc), fData(data), fDataType(dataType)
+{
 }
 
 JSUserObject::~JSUserObject()
 {
-       if (fCallBacks.dispose)
-       {
-               fCallBacks.dispose(fData);
-       }
+    if (fCallBacks.dispose)
+    {
+        fCallBacks.dispose(fData);
+    }
 }
 
 CFArrayRef JSUserObject::CopyPropertyNames(void)
 {
-       CFArrayRef result = NULL;
-       if (fCallBacks.copyPropertyNames)
-       {
-               result = fCallBacks.copyPropertyNames(fData);
-       }
-       return result;
+    CFArrayRef result = 0;
+    if (fCallBacks.copyPropertyNames)
+    {
+        result = fCallBacks.copyPropertyNames(fData);
+    }
+    return result;
 }
-               
+
 JSUserObject* JSUserObject::CopyProperty(CFStringRef propertyName)
 {
-       JSUserObject* result = NULL;
-       if (fCallBacks.copyProperty)
-       {
-               result = (JSUserObject*)fCallBacks.copyProperty(fData, propertyName);
-       }
-       return result;
+    JSUserObject* result = 0;
+    if (fCallBacks.copyProperty)
+    {
+        result = (JSUserObject*)fCallBacks.copyProperty(fData, propertyName);
+    }
+    return result;
 }
 
 void JSUserObject::SetProperty(CFStringRef propertyName, JSUserObject* value)
 {
-       if (fCallBacks.setProperty)
-       {
-               fCallBacks.setProperty(fData, propertyName, (JSObjectRef)value);
-       }
+    if (fCallBacks.setProperty)
+    {
+        fCallBacks.setProperty(fData, propertyName, (JSObjectRef)value);
+    }
 
 }
 
 bool JSUserObject::ImplementsCall()
 {
-       return fCallBacks.callFunction ? true : false;
+    return fCallBacks.callFunction ? true : false;
 }
 
 JSUserObject* JSUserObject::CallFunction(JSUserObject* thisObj, CFArrayRef args)
 {
-       JSUserObject* result = NULL;
-       if (fCallBacks.callFunction)
-       {
-               result = (JSUserObject*)fCallBacks.callFunction(fData, (JSObjectRef)thisObj, args);
-       }
-       return result;
+    JSUserObject* result = 0;
+    if (fCallBacks.callFunction)
+    {
+        result = (JSUserObject*)fCallBacks.callFunction(fData, (JSObjectRef)thisObj, args);
+    }
+    return result;
 
 }
 
 CFTypeRef JSUserObject::CopyCFValue() const
 {
-       CFTypeRef result = NULL;
-       if (fCallBacks.copyCFValue)
-       {
-               result = (JSUserObject*)fCallBacks.copyCFValue(fData);
-       }
-       return result;
+    CFTypeRef result = 0;
+    if (fCallBacks.copyCFValue)
+    {
+        result = (JSUserObject*)fCallBacks.copyCFValue(fData);
+    }
+    return result;
 }
 
 UInt8 JSUserObject::Equal(JSBase* other)
 {
-       UInt8 result = false;
-       JSUserObject* obj = (JSUserObject*)other;
-       if (obj->GetTypeID() == kJSObjectTypeID)
-       {
-               if (fCallBacks.equal)
-               {
-                       result = fCallBacks.equal(GetData(), obj->GetData());
-               }
-               else
-               {
-                       CFTypeRef cf1 = CopyCFValue();
-                       CFTypeRef cf2 = obj->CopyCFValue();
-                       if (cf1 && cf2)
-                       {
-                               result = CFEqual(cf1, cf2);
-                       }
-                       ReleaseCFType(cf2);
-                       ReleaseCFType(cf1);
-               }
-       }
-       return result;
+    UInt8 result = false;
+    JSUserObject* obj = (JSUserObject*)other;
+    if (obj->GetTypeID() == kJSObjectTypeID)
+    {
+        if (fCallBacks.equal)
+        {
+            result = fCallBacks.equal(GetData(), obj->GetData());
+        }
+        else
+        {
+            CFTypeRef cf1 = CopyCFValue();
+            CFTypeRef cf2 = obj->CopyCFValue();
+            if (cf1 && cf2)
+            {
+                result = CFEqual(cf1, cf2);
+            }
+            ReleaseCFType(cf2);
+            ReleaseCFType(cf1);
+        }
+    }
+    return result;
 }
 
 void JSUserObject::Mark()
 {
-       if (fMarkProc)
-       {
-               fMarkProc(fData);
-       }
+    if (fMarkProc)
+    {
+        fMarkProc(fData);
+    }
 }
 
-void* JSUserObject::GetData() 
+void *JSUserObject::GetData()
 {
-       return fData; 
+    return fData;
 }
 
 
index eb8548a..6952f00 100644 (file)
@@ -2,37 +2,36 @@
 // JSObject.h
 //
 
-#ifndef __JSObject_h
-#define __JSObject_h
+#ifndef JSObject_h
+#define JSObject_h
 
 #include "JSBase.h"
 #include "JSUtils.h"
 
-typedef void (*JSObjectMarkProcPtr)(voiddata);
-JSObjectRef JSObjectCreateInternal(voiddata, JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, int dataType);
+typedef void (*JSObjectMarkProcPtr)(void *data);
+JSObjectRef JSObjectCreateInternal(void *data, JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, int dataType);
 
 class JSUserObject : public JSBase {
-       public:
-//             JSUserObject(JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, void* data, int dataType = kJSUserObjectDataTypeUnknown);
-               JSUserObject(JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, void* data, int dataType);
-               virtual ~JSUserObject();
-               
-               CFArrayRef CopyPropertyNames(void);
-               JSUserObject* CopyProperty(CFStringRef propertyName);
-               void SetProperty(CFStringRef propertyName, JSUserObject* value);
-               bool ImplementsCall();
-               JSUserObject* CallFunction(JSUserObject* thisObj, CFArrayRef args);
-               CFTypeRef CopyCFValue() const;
-               virtual UInt8 Equal(JSBase* other);
-               void* GetData();
-               void Mark();
-               
+    public:
+        JSUserObject(JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, void *data, int dataType);
+        virtual ~JSUserObject();
+
+        CFArrayRef CopyPropertyNames(void);
+        JSUserObject* CopyProperty(CFStringRef propertyName);
+        void SetProperty(CFStringRef propertyName, JSUserObject* value);
+        bool ImplementsCall();
+        JSUserObject* CallFunction(JSUserObject* thisObj, CFArrayRef args);
+        CFTypeRef CopyCFValue() const;
+        virtual UInt8 Equal(JSBase* other);
+        void *GetData();
+        void Mark();
+
                 int DataType() const { return fDataType; }
-       private:
-               JSObjectCallBacks fCallBacks;
-               JSObjectMarkProcPtr fMarkProc;
-               void* fData;
+    private:
+        JSObjectCallBacks fCallBacks;
+        JSObjectMarkProcPtr fMarkProc;
+        void *fData;
                 int fDataType;
 };
 
-#endif
\ No newline at end of file
+#endif
index da807a4..2f13e43 100644 (file)
@@ -4,46 +4,46 @@
 
 #include "JSRun.h"
 
-JSRun::JSRun(CFStringRef source, JSFlags inFlags) 
-       :       JSBase(kJSRunTypeID), 
-               fSource(CFStringToUString(source)), 
-               fGlobalObject(new ObjectImp()),
-               fInterpreter(fGlobalObject, inFlags),
-               fFlags(inFlags)
+JSRun::JSRun(CFStringRef source, JSFlags inFlags)
+    :   JSBase(kJSRunTypeID),
+        fSource(CFStringToUString(source)),
+        fGlobalObject(new ObjectImp()),
+        fInterpreter(fGlobalObject, inFlags),
+        fFlags(inFlags)
 {
 }
-                               
-JSRun::~JSRun() 
-{ 
+
+JSRun::~JSRun()
+{
 }
 
 JSFlags JSRun::Flags() const
 {
-       return fFlags;
+    return fFlags;
 }
 
 UString JSRun::GetSource() const
 {
-       return fSource;
+    return fSource;
 }
 
 ObjectImp *JSRun::GlobalObject() const
 {
-       return fGlobalObject;
+    return fGlobalObject;
 }
 
-JSInterpreter* JSRun::GetInterpreter() 
+JSInterpreter* JSRun::GetInterpreter()
 {
-       return &fInterpreter; 
+    return &fInterpreter;
 }
 
-Completion JSRun::Evaluate() 
-{ 
-       return fInterpreter.evaluate(fSource); 
+Completion JSRun::Evaluate()
+{
+    return fInterpreter.evaluate(fSource);
 }
 
 
-bool JSRun::CheckSyntax() 
-{ 
-       return fInterpreter.checkSyntax(fSource); 
+bool JSRun::CheckSyntax()
+{
+    return fInterpreter.checkSyntax(fSource);
 }
index cc2c4e7..b51dc5c 100644 (file)
@@ -1,40 +1,40 @@
-#ifndef __JSRun_h
-#define __JSRun_h
+#ifndef JSRun_h
+#define JSRun_h
 
 /*
-       JSRun.h
+    JSRun.h
 */
 
 #include "JSBase.h"
 #include "JSUtils.h"
 
 class JSInterpreter : public Interpreter {
-       public:
-               JSInterpreter(ObjectImp *global, JSFlags flags) : Interpreter(global), fJSFlags(flags) { }
-               JSInterpreter(ObjectImp *global) : Interpreter(global), fJSFlags(kJSFlagNone) { }
-               JSInterpreter() : Interpreter(), fJSFlags(kJSFlagNone) { }
-               JSInterpreter::~JSInterpreter() { }
-               JSFlags Flags() const { return fJSFlags; }
-       private:
-               JSFlags fJSFlags;
+    public:
+        JSInterpreter(ObjectImp *global, JSFlags flags) : Interpreter(global), fJSFlags(flags) { }
+        JSInterpreter(ObjectImp *global) : Interpreter(global), fJSFlags(kJSFlagNone) { }
+        JSInterpreter() : Interpreter(), fJSFlags(kJSFlagNone) { }
+        JSInterpreter::~JSInterpreter() { }
+        JSFlags Flags() const { return fJSFlags; }
+    private:
+        JSFlags fJSFlags;
 };
 
 class JSRun : public JSBase {
-       public:
-               JSRun(CFStringRef source, JSFlags inFlags);
-               virtual ~JSRun();
+    public:
+        JSRun(CFStringRef source, JSFlags inFlags);
+        virtual ~JSRun();
 
-               UString GetSource() const;
-               ObjectImp *GlobalObject() const;
-               JSInterpreter* GetInterpreter();
-               Completion Evaluate();
-               bool CheckSyntax();
-               JSFlags Flags() const;
-       private:
-               UString fSource;                
-               ProtectedPtr<ObjectImp> fGlobalObject;
-               JSInterpreter fInterpreter;
-               JSFlags fFlags;
+        UString GetSource() const;
+        ObjectImp *GlobalObject() const;
+        JSInterpreter* GetInterpreter();
+        Completion Evaluate();
+        bool CheckSyntax();
+        JSFlags Flags() const;
+    private:
+        UString fSource;
+        ProtectedPtr<ObjectImp> fGlobalObject;
+        JSInterpreter fInterpreter;
+        JSFlags fFlags;
 };
 
 #endif
index 5bec5be..df18285 100644 (file)
 #include "JavaScriptCore/IdentifierSequencedSet.h"
 
 struct ObjectImpList {
-       ObjectImp* imp;
-       ObjectImpList* next;
-       CFTypeRef data;
+    ObjectImp* imp;
+    ObjectImpList* next;
+    CFTypeRef data;
 };
 
 static CFTypeRef KJSValueToCFTypeInternal(ValueImp *inValue, ExecState *exec, ObjectImpList* inImps);
 
 
 //--------------------------------------------------------------------------
-//     CFStringToUString
+// CFStringToUString
 //--------------------------------------------------------------------------
 
 UString CFStringToUString(CFStringRef inCFString)
@@ -44,48 +44,46 @@ UString CFStringToUString(CFStringRef inCFString)
 
 
 //--------------------------------------------------------------------------
-//     UStringToCFString
+// UStringToCFString
 //--------------------------------------------------------------------------
 // Caller is responsible for releasing the returned CFStringRef
 CFStringRef UStringToCFString(const UString& inUString)
 {
-       return CFStringCreateWithCharacters(NULL, (const UniChar*)inUString.data(), inUString.size());
+    return CFStringCreateWithCharacters(0, (const UniChar*)inUString.data(), inUString.size());
 }
 
 
-#if JAG_PINK_OR_LATER
 //--------------------------------------------------------------------------
-//     CFStringToIdentifier
+// CFStringToIdentifier
 //--------------------------------------------------------------------------
 
 Identifier CFStringToIdentifier(CFStringRef inCFString)
 {
-       return Identifier(CFStringToUString(inCFString));
+    return Identifier(CFStringToUString(inCFString));
 }
 
 
 //--------------------------------------------------------------------------
-//     IdentifierToCFString
+// IdentifierToCFString
 //--------------------------------------------------------------------------
 // Caller is responsible for releasing the returned CFStringRef
 CFStringRef IdentifierToCFString(const Identifier& inIdentifier)
 {
-       return UStringToCFString(inIdentifier.ustring());
+    return UStringToCFString(inIdentifier.ustring());
 }
-#endif
 
 
 //--------------------------------------------------------------------------
-//     KJSValueToJSObject
+// KJSValueToJSObject
 //--------------------------------------------------------------------------
 JSUserObject* KJSValueToJSObject(ValueImp *inValue, ExecState *exec)
 {
-    JSUserObject* result = NULL;
-    
+    JSUserObject* result = 0;
+
     if (inValue->isObject(&UserObjectImp::info)) {
         UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(inValue);
         result = userObjectImp->GetJSUserObject();
-        if (result) 
+        if (result)
             result->Retain();
     } else {
         JSValueWrapper* wrapperValue = new JSValueWrapper(inValue, exec);
@@ -102,7 +100,7 @@ JSUserObject* KJSValueToJSObject(ValueImp *inValue, ExecState *exec)
 }
 
 //--------------------------------------------------------------------------
-//     JSObjectKJSValue
+// JSObjectKJSValue
 //--------------------------------------------------------------------------
 ValueImp *JSObjectKJSValue(JSUserObject* ptr)
 {
@@ -112,7 +110,7 @@ ValueImp *JSObjectKJSValue(JSUserObject* ptr)
     if (ptr)
     {
         bool handled = false;
-        
+
         switch (ptr->DataType())
         {
             case kJSUserObjectDataTypeJSValueWrapper:
@@ -125,7 +123,7 @@ ValueImp *JSObjectKJSValue(JSUserObject* ptr)
                 }
                 break;
             }
-                
+
             case kJSUserObjectDataTypeCFType:
             {
                 CFTypeRef cfType = (CFTypeRef*)ptr->GetData();
@@ -187,279 +185,190 @@ ValueImp *JSObjectKJSValue(JSUserObject* ptr)
 
 
 //--------------------------------------------------------------------------
-//     KJSValueToCFTypeInternal
+// KJSValueToCFTypeInternal
 //--------------------------------------------------------------------------
 // Caller is responsible for releasing the returned CFTypeRef
 CFTypeRef KJSValueToCFTypeInternal(ValueImp *inValue, ExecState *exec, ObjectImpList* inImps)
 {
-       if (inValue)
-               return NULL;
-               
-       CFTypeRef result = NULL;
-       
+    if (inValue)
+        return 0;
+
+    CFTypeRef result = 0;
+
         InterpreterLock lock;
 
-       switch (inValue->type())
-       {
-               case BooleanType:
-                       {
-                               result = inValue->toBoolean(exec) ? kCFBooleanTrue : kCFBooleanFalse;
-                               RetainCFType(result);
-                       }
-                       break;
-                       
-               case StringType:
-                       {
-                               UString uString = inValue->toString(exec);
-                               result = UStringToCFString(uString);
-                       }
-                       break;
-                       
-               case NumberType:
-                       {
-                               double number1 = inValue->toNumber(exec);
-                               double number2 = (double)inValue->toInteger(exec);
-                               if (number1 ==  number2)
-                               {
-                                       int intValue = (int)number2;
-                                       result = CFNumberCreate(NULL, kCFNumberIntType, &intValue);
-                               }
-                               else
-                               {
-                                       result = CFNumberCreate(NULL, kCFNumberDoubleType, &number1);
-                               }
-                       }
-                       break;
-                       
-               case ObjectType:
-                       {
+    switch (inValue->type())
+    {
+        case BooleanType:
+            {
+                result = inValue->toBoolean(exec) ? kCFBooleanTrue : kCFBooleanFalse;
+                RetainCFType(result);
+            }
+            break;
+
+        case StringType:
+            {
+                UString uString = inValue->toString(exec);
+                result = UStringToCFString(uString);
+            }
+            break;
+
+        case NumberType:
+            {
+                double number1 = inValue->toNumber(exec);
+                double number2 = (double)inValue->toInteger(exec);
+                if (number1 ==  number2)
+                {
+                    int intValue = (int)number2;
+                    result = CFNumberCreate(0, kCFNumberIntType, &intValue);
+                }
+                else
+                {
+                    result = CFNumberCreate(0, kCFNumberDoubleType, &number1);
+                }
+            }
+            break;
+
+        case ObjectType:
+            {
                             if (inValue->isObject(&UserObjectImp::info)) {
                                 UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(inValue);
-                                       JSUserObject* ptr = userObjectImp->GetJSUserObject();
-                                       if (ptr)
-                                       {
-                                               result = ptr->CopyCFValue();
-                                       }
-                               }
-                               else
-                               {
-                                       ObjectImp *object = inValue->toObject(exec);
-                                       UInt8 isArray = false;
-
-                                       // if two objects reference each
-                                       ObjectImp* imp = object;
-                                       ObjectImpList* temp = inImps;
-                                       while (temp) {
-                                               if (imp == temp->imp) {
-                                                       return CFRetain(GetCFNull());
-                                               }
-                                               temp = temp->next;
-                                       }
-
-                                       ObjectImpList imps;
-                                       imps.next = inImps;
-                                       imps.imp = imp;
-
-                                       
+                    JSUserObject* ptr = userObjectImp->GetJSUserObject();
+                    if (ptr)
+                    {
+                        result = ptr->CopyCFValue();
+                    }
+                }
+                else
+                {
+                    ObjectImp *object = inValue->toObject(exec);
+                    UInt8 isArray = false;
+
+                    // if two objects reference each
+                    ObjectImp* imp = object;
+                    ObjectImpList* temp = inImps;
+                    while (temp) {
+                        if (imp == temp->imp) {
+                            return CFRetain(GetCFNull());
+                        }
+                        temp = temp->next;
+                    }
+
+                    ObjectImpList imps;
+                    imps.next = inImps;
+                    imps.imp = imp;
+
+
 //[...] HACK since we do not have access to the class info we use class name instead
 #if 0
-                                       if (object->inherits(&ArrayInstanceImp::info))
+                    if (object->inherits(&ArrayInstanceImp::info))
 #else
-                                       if (object->className() == "Array")
+                    if (object->className() == "Array")
 #endif
-                                       {
-                                               isArray = true;                                 
-#if JAG_PINK_OR_LATER
-                                               JSInterpreter* intrepreter = (JSInterpreter*)exec->dynamicInterpreter();
-                                               if (intrepreter && (intrepreter->Flags() & kJSFlagConvertAssociativeArray)) {
-                                                       IdentifierSequencedSet propList;
+                    {
+                        isArray = true;
+                        JSInterpreter* intrepreter = (JSInterpreter*)exec->dynamicInterpreter();
+                        if (intrepreter && (intrepreter->Flags() & kJSFlagConvertAssociativeArray)) {
+                            IdentifierSequencedSet propList;
                                                         object->getPropertyNames(exec, propList);
-                                                       IdentifierSequencedSetIterator iter = propList.begin();
-                                                       IdentifierSequencedSetIterator end = propList.end();
-                                                       while(iter != end && isArray)
-                                                       {
-                                                               Identifier propName = *iter;
-                                                               UString ustr = propName.ustring();
-                                                               const UniChar* uniChars = (const UniChar*)ustr.data();
-                                                               int size = ustr.size();
-                                                               while (size--) {
-                                                                       if (uniChars[size] < '0' || uniChars[size] > '9') {
-                                                                               isArray = false;
-                                                                               break;
-                                                                       }
-                                                               }
-                                                               ++iter;
-                                                       }
-                                               }
-#endif
-                                       }
-                                       
-                                       if (isArray)
-                                       {                               
-                                               // This is an KJS array
-                                               unsigned int length = object->get(exec, "length")->toUInt32(exec);
-                                               result = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-                                               if (result)
-                                               {
-#if JAG_PINK_OR_LATER
-                                                       for (unsigned i = 0; i < length; i++)
-                                                       {
-                                                               CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, i), exec, &imps);
-                                                               CFArrayAppendValue((CFMutableArrayRef)result, cfValue);
-                                                               ReleaseCFType(cfValue);
-                                                       }
-#else
-                                                       for (unsigned int i = 0; i < length; i++)
-                                                       {
-                                                               UString propertyName = UString::from(i);
-                                                               CFTypeRef cfValue = KJSValueToCFTypeInternal(object.get(exec, propertyName), exec, &imps);
-                                                               CFArrayAppendValue((CFMutableArrayRef)result, cfValue);
-                                                               ReleaseCFType(cfValue);
-                                                       }
-#endif
-                                               }
-                                       }
-                                       else
-                                       {
-#if JAG_PINK_OR_LATER
-                                               // Not an arry, just treat it like a dictionary which contains (property name, property value) paiars
-                                               IdentifierSequencedSet propList;
+                            IdentifierSequencedSetIterator iter = propList.begin();
+                            IdentifierSequencedSetIterator end = propList.end();
+                            while(iter != end && isArray)
+                            {
+                                Identifier propName = *iter;
+                                UString ustr = propName.ustring();
+                                const UniChar* uniChars = (const UniChar*)ustr.data();
+                                int size = ustr.size();
+                                while (size--) {
+                                    if (uniChars[size] < '0' || uniChars[size] > '9') {
+                                        isArray = false;
+                                        break;
+                                    }
+                                }
+                                ++iter;
+                            }
+                        }
+                    }
+
+                    if (isArray)
+                    {
+                        // This is an KJS array
+                        unsigned int length = object->get(exec, "length")->toUInt32(exec);
+                        result = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks);
+                        if (result)
+                        {
+                            for (unsigned i = 0; i < length; i++)
+                            {
+                                CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, i), exec, &imps);
+                                CFArrayAppendValue((CFMutableArrayRef)result, cfValue);
+                                ReleaseCFType(cfValue);
+                            }
+                        }
+                    }
+                    else
+                    {
+                        // Not an array, just treat it like a dictionary which contains (property name, property value) pairs
+                        IdentifierSequencedSet propList;
                                                 object->getPropertyNames(exec, propList);
-                                               {
-                                                       result = CFDictionaryCreateMutable(NULL, 
-                                                                                                                          0, 
-                                                                                                                          &kCFTypeDictionaryKeyCallBacks, 
-                                                                                                                          &kCFTypeDictionaryValueCallBacks);
-                                                       if (result)
-                                                       {
-                                                               IdentifierSequencedSetIterator iter = propList.begin();
-                                                               IdentifierSequencedSetIterator end = propList.end();
-                                                               while(iter != end)
-                                                               {
-                                                                       Identifier propName = *iter;
-                                                                       if (object->hasProperty(exec, propName))
-                                                                       {
-                                                                               CFStringRef cfKey = IdentifierToCFString(propName);
-                                                                               CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, propName), exec, &imps);
-                                                                               if (cfKey && cfValue)
-                                                                               {
-                                                                                       CFDictionaryAddValue((CFMutableDictionaryRef)result, cfKey, cfValue);
-                                                                               }
-                                                                               ReleaseCFType(cfKey);
-                                                                               ReleaseCFType(cfValue);
-                                                                       }
-                                                                       ++iter;
-                                                               }
-                                                       }
-                                               }
-#else
-                                               List propList = object.propList(exec);
-                                               if (propList.size() > 0)
-                                               {
-                                                       result = CFDictionaryCreateMutable(NULL, 
-                                                                                                                          0, 
-                                                                                                                          &kCFTypeDictionaryKeyCallBacks, 
-                                                                                                                          &kCFTypeDictionaryValueCallBacks);
-                                                       if (result)
-                                                       {
-                                                               ListIterator iter = propList.begin();
-                                                               ListIterator end = propList.end();
-                                                               while(iter != end)
-                                                               {
-                                                                       UString propName = iter->getPropertyName(exec);
-                                                                       if (object.hasProperty(exec, propName))
-                                                                       {
-                                                                               CFStringRef cfKey = UStringToCFString(propName);
-                                                                               CFTypeRef cfValue = KJSValueToCFTypeInternal(iter->getValue(exec), exec, &imps);
-                                                                               if (cfKey && cfValue)
-                                                                               {
-                                                                                       CFDictionaryAddValue((CFMutableDictionaryRef)result, cfKey, cfValue);
-                                                                               }
-                                                                               ReleaseCFType(cfKey);
-                                                                               ReleaseCFType(cfValue);
-                                                                       }
-                                                                       ++iter;
-                                                               }
-                                                       }
-                                               }
-#endif
-                                       }
-                               }
-                       }
-                       break;
-
-#if !JAG_PINK_OR_LATER
-               case ReferenceType:
-                       {
-                               ValueImp *value = inValue->getValue(exec);
-                               result = KJSValueToCFTypeInternal(value, exec, NULL);
-                       }
-                       break;
-
-               case ListType:
-                       {
-                               List list = List::dynamicCast(inValue);
-                               if (!list.isNull())
-                               {
-                                       result = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-                                       if (result)
-                                       {
-                                               ListIterator iter = list.begin();
-                                               ListIterator end = list.end();
-                                               while (iter != end)
-                                               {
-                                                       CFTypeRef cfTypeRef = KJSValueToCFTypeInternal(*iter, exec, NULL);
-                                                       if (cfTypeRef)
-                                                               CFArrayAppendValue((CFMutableArrayRef)result, cfTypeRef);
-                                                       ++iter;
-                                               }
-                                       }
-                               }
-                       }
-                       break;
-#endif
-               
-               case NullType:
-               case UndefinedType:
-               case UnspecifiedType:
-                       result = RetainCFType(GetCFNull());
-                       break;
-                       
-#if !JAG_PINK_OR_LATER
-               case CompletionType:
-                       {
-                               Completion completion = Completion::dynamicCast(inValue);
-                               if (completion.isValueCompletion())
-                               {
-                                       result = KJSValueToCFTypeInternal(completion.value(), exec, NULL);
-                               }
-                       }
-                       break;
-#endif
+                        {
+                            result = CFDictionaryCreateMutable(0,
+                                                               0,
+                                                               &kCFTypeDictionaryKeyCallBacks,
+                                                               &kCFTypeDictionaryValueCallBacks);
+                            if (result)
+                            {
+                                IdentifierSequencedSetIterator iter = propList.begin();
+                                IdentifierSequencedSetIterator end = propList.end();
+                                while(iter != end)
+                                {
+                                    Identifier propName = *iter;
+                                    if (object->hasProperty(exec, propName))
+                                    {
+                                        CFStringRef cfKey = IdentifierToCFString(propName);
+                                        CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, propName), exec, &imps);
+                                        if (cfKey && cfValue)
+                                        {
+                                            CFDictionaryAddValue((CFMutableDictionaryRef)result, cfKey, cfValue);
+                                        }
+                                        ReleaseCFType(cfKey);
+                                        ReleaseCFType(cfValue);
+                                    }
+                                    ++iter;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            break;
 
-#if JAG_PINK_OR_LATER
-               default:
-                       fprintf(stderr, "KJSValueToCFType: wrong value type %d\n", inValue->type());
-                       break;
-#endif
-       }
-       
-       return result;
+        case NullType:
+        case UndefinedType:
+        case UnspecifiedType:
+            result = RetainCFType(GetCFNull());
+            break;
+
+        default:
+            fprintf(stderr, "KJSValueToCFType: wrong value type %d\n", inValue->type());
+            break;
+    }
+
+    return result;
 }
 
 CFTypeRef KJSValueToCFType(ValueImp *inValue, ExecState *exec)
 {
-       return KJSValueToCFTypeInternal(inValue, exec, NULL);
+    return KJSValueToCFTypeInternal(inValue, exec, 0);
 }
 
 CFTypeRef GetCFNull(void)
 {
-       static CFArrayRef sCFNull = CFArrayCreate(NULL, NULL, 0, NULL);
-       CFTypeRef result = JSGetCFNull();
-       if (!result)
-       {
-               result = sCFNull;
-       }
-       return result;
+    static CFArrayRef sCFNull = CFArrayCreate(0, 0, 0, 0);
+    CFTypeRef result = JSGetCFNull();
+    if (!result)
+    {
+        result = sCFNull;
+    }
+    return result;
 }
 
index 5c1e3b8..64be2e7 100644 (file)
@@ -1,23 +1,12 @@
-#ifndef __JSUtils_h
-#define __JSUtils_h
+#ifndef JSUtils_h
+#define JSUtils_h
 
 /*
-       JSUtils.h
+    JSUtils.h
 */
 
-#ifndef __CORESERVICES__
-#include <CoreServices/CoreServices.h>
-#endif
-
 #include <JavaScriptGlue/JavaScriptGlue.h>
 
-#ifdef USE_JSHACK
-#include <JSHack/value.h>
-#include <JSHack/object.h>
-#include <JSHack/types.h>
-#include <JSHack/interpreter.h>
-#include <JSHack/ustring.h>
-#else
 #include <JavaScriptCore/value.h>
 #include <JavaScriptCore/object.h>
 #include <JavaScriptCore/types.h>
@@ -25,9 +14,6 @@
 #include <JavaScriptCore/protect.h>
 #include <JavaScriptCore/collector.h>
 #include <JavaScriptCore/ustring.h>
-#endif
-
-#define JAG_PINK_OR_LATER      1 /* %%% turn on for new JavaScriptCore */
 
 using namespace KJS;
 
@@ -39,11 +25,9 @@ class JSUserObjectImp;
 
 UString CFStringToUString(CFStringRef inCFString);
 CFStringRef UStringToCFString(const UString& inUString);
-#if JAG_PINK_OR_LATER
 Identifier CFStringToIdentifier(CFStringRef inCFString);
 CFStringRef IdentifierToCFString(const Identifier& inIdentifier);
-#endif
-JSUserObject* KJSValueToJSObject(ValueImp *inValue, ExecState *exec);
+JSUserObject *KJSValueToJSObject(ValueImp *inValue, ExecState *exec);
 CFTypeRef KJSValueToCFType(ValueImp *inValue, ExecState *exec);
 ValueImp *JSObjectKJSValue(JSUserObject* ptr);
 CFTypeRef GetCFNull(void);
@@ -52,9 +36,9 @@ inline CFTypeRef RetainCFType(CFTypeRef x) { if (x) x = CFRetain(x); return x; }
 inline void ReleaseCFType(CFTypeRef x) { if (x) CFRelease(x);  }
 
 enum {
-       kJSInvalidTypeID = 0,
-       kJSObjectTypeID,
-       kJSRunTypeID
+    kJSInvalidTypeID = 0,
+    kJSObjectTypeID,
+    kJSRunTypeID
 };
 
 enum {
index 54ced96..910f48b 100644 (file)
 #include "JSValueWrapper.h"
 #include "JavaScriptCore/IdentifierSequencedSet.h"
 
-JSValueWrapper::JSValueWrapper(ValueImp *inValue, ExecState *inExec) 
-       : fValue(inValue), fExec(inExec) 
-{ 
+JSValueWrapper::JSValueWrapper(ValueImp *inValue, ExecState *inExec)
+    : fValue(inValue), fExec(inExec)
+{
 }
 
 JSValueWrapper::~JSValueWrapper()
-{ 
+{
 }
 
-ValueImp *JSValueWrapper::GetValue() 
-{ 
-       return fValue; 
+ValueImp *JSValueWrapper::GetValue()
+{
+    return fValue;
 }
-ExecState* JSValueWrapper::GetExecState() const 
+ExecState* JSValueWrapper::GetExecState() const
 {
-       return fExec; 
+    return fExec;
 }
-       
+
 
 void JSValueWrapper::GetJSObectCallBacks(JSObjectCallBacks& callBacks)
 {
-       callBacks.dispose = (JSObjectDisposeProcPtr)JSValueWrapper::JSObjectDispose;
-       callBacks.equal = (JSObjectEqualProcPtr)NULL;
-       callBacks.copyPropertyNames = (JSObjectCopyPropertyNamesProcPtr)JSValueWrapper::JSObjectCopyPropertyNames;
-       callBacks.copyCFValue = (JSObjectCopyCFValueProcPtr)JSValueWrapper::JSObjectCopyCFValue;
-       callBacks.copyProperty = (JSObjectCopyPropertyProcPtr)JSValueWrapper::JSObjectCopyProperty;
-       callBacks.setProperty = (JSObjectSetPropertyProcPtr)JSValueWrapper::JSObjectSetProperty;
-       callBacks.callFunction = (JSObjectCallFunctionProcPtr)JSValueWrapper::JSObjectCallFunction;
+    callBacks.dispose = (JSObjectDisposeProcPtr)JSValueWrapper::JSObjectDispose;
+    callBacks.equal = (JSObjectEqualProcPtr)0;
+    callBacks.copyPropertyNames = (JSObjectCopyPropertyNamesProcPtr)JSValueWrapper::JSObjectCopyPropertyNames;
+    callBacks.copyCFValue = (JSObjectCopyCFValueProcPtr)JSValueWrapper::JSObjectCopyCFValue;
+    callBacks.copyProperty = (JSObjectCopyPropertyProcPtr)JSValueWrapper::JSObjectCopyProperty;
+    callBacks.setProperty = (JSObjectSetPropertyProcPtr)JSValueWrapper::JSObjectSetProperty;
+    callBacks.callFunction = (JSObjectCallFunctionProcPtr)JSValueWrapper::JSObjectCallFunction;
 }
-                       
-void JSValueWrapper::JSObjectDispose(voiddata)
+
+void JSValueWrapper::JSObjectDispose(void *data)
 {
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       delete ptr;
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    delete ptr;
 }
-       
 
-CFArrayRef JSValueWrapper::JSObjectCopyPropertyNames(void* data)
+
+CFArrayRef JSValueWrapper::JSObjectCopyPropertyNames(void *data)
 {
     InterpreterLock lock;
 
-       CFMutableArrayRef result = NULL;
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       if (ptr)
-       {
-               ExecState* exec = ptr->GetExecState();
-               ObjectImp *object = ptr->GetValue()->toObject(exec);
-               IdentifierSequencedSet list;
+    CFMutableArrayRef result = 0;
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    if (ptr)
+    {
+        ExecState* exec = ptr->GetExecState();
+        ObjectImp *object = ptr->GetValue()->toObject(exec);
+        IdentifierSequencedSet list;
                 object->getPropertyNames(exec, list);
-               IdentifierSequencedSetIterator iterator = list.begin();
-
-               while (iterator != list.end()) {
-                       Identifier name = *iterator;
-                       CFStringRef nameStr = IdentifierToCFString(name);
-
-                       if (!result)
-                       {
-                               result = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-                       }
-                       if (result && nameStr)
-                       {
-                               CFArrayAppendValue(result, nameStr);
-                       }
-                       ReleaseCFType(nameStr);
-                       ++iterator;
-               }
-
-       }
-       return result;
+        IdentifierSequencedSetIterator iterator = list.begin();
+
+        while (iterator != list.end()) {
+            Identifier name = *iterator;
+            CFStringRef nameStr = IdentifierToCFString(name);
+
+            if (!result)
+            {
+                result = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks);
+            }
+            if (result && nameStr)
+            {
+                CFArrayAppendValue(result, nameStr);
+            }
+            ReleaseCFType(nameStr);
+            ++iterator;
+        }
+
+    }
+    return result;
 }
 
 
-JSObjectRef JSValueWrapper::JSObjectCopyProperty(voiddata, CFStringRef propertyName)
+JSObjectRef JSValueWrapper::JSObjectCopyProperty(void *data, CFStringRef propertyName)
 {
     InterpreterLock lock;
 
-       JSObjectRef result = NULL;
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       if (ptr)
-       {
-               ExecState* exec = ptr->GetExecState();
-               ValueImp *propValue = ptr->GetValue()->toObject(exec)->get(exec, CFStringToIdentifier(propertyName));
-               JSValueWrapper* wrapperValue = new JSValueWrapper(propValue, exec);
-
-               JSObjectCallBacks callBacks;
-               GetJSObectCallBacks(callBacks);
-               result = JSObjectCreateInternal(wrapperValue, &callBacks, JSValueWrapper::JSObjectMark, kJSUserObjectDataTypeJSValueWrapper);
-
-               if (!result)
-               {
-                       delete wrapperValue;
-               }
-       }
-       return result;
+    JSObjectRef result = 0;
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    if (ptr)
+    {
+        ExecState* exec = ptr->GetExecState();
+        ValueImp *propValue = ptr->GetValue()->toObject(exec)->get(exec, CFStringToIdentifier(propertyName));
+        JSValueWrapper* wrapperValue = new JSValueWrapper(propValue, exec);
+
+        JSObjectCallBacks callBacks;
+        GetJSObectCallBacks(callBacks);
+        result = JSObjectCreateInternal(wrapperValue, &callBacks, JSValueWrapper::JSObjectMark, kJSUserObjectDataTypeJSValueWrapper);
+
+        if (!result)
+        {
+            delete wrapperValue;
+        }
+    }
+    return result;
 }
 
-void JSValueWrapper::JSObjectSetProperty(voiddata, CFStringRef propertyName, JSObjectRef jsValue)
+void JSValueWrapper::JSObjectSetProperty(void *data, CFStringRef propertyName, JSObjectRef jsValue)
 {
     InterpreterLock lock;
 
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       if (ptr)
-       {
-               ExecState* exec = ptr->GetExecState();  
-               ValueImp *value = JSObjectKJSValue((JSUserObject*)jsValue);
-               ObjectImp *objValue = ptr->GetValue()->toObject(exec);
-               objValue->put(exec, CFStringToIdentifier(propertyName), value);
-       }
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    if (ptr)
+    {
+        ExecState* exec = ptr->GetExecState();
+        ValueImp *value = JSObjectKJSValue((JSUserObject*)jsValue);
+        ObjectImp *objValue = ptr->GetValue()->toObject(exec);
+        objValue->put(exec, CFStringToIdentifier(propertyName), value);
+    }
 }
 
-JSObjectRef JSValueWrapper::JSObjectCallFunction(voiddata, JSObjectRef thisObj, CFArrayRef args)
+JSObjectRef JSValueWrapper::JSObjectCallFunction(void *data, JSObjectRef thisObj, CFArrayRef args)
 {
     InterpreterLock lock;
 
-       JSObjectRef result = NULL;
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       if (ptr)
-       {
-               ExecState* exec = ptr->GetExecState();  
-       
-               ValueImp *value = JSObjectKJSValue((JSUserObject*)thisObj);
-               ObjectImp *ksjThisObj = value->toObject(exec);
-               ObjectImp *objValue = ptr->GetValue()->toObject(exec);
-
-               List listArgs;
-               CFIndex argCount = args ? CFArrayGetCount(args) : 0;
-               for (CFIndex i = 0; i < argCount; i++)
-               {
-                       JSObjectRef jsArg = (JSObjectRef)CFArrayGetValueAtIndex(args, i);
-                       ValueImp *kgsArg = JSObjectKJSValue((JSUserObject*)jsArg);
-                       listArgs.append(kgsArg);
-               }
-
-               ValueImp *resultValue = objValue->call(exec, ksjThisObj, listArgs);
-               JSValueWrapper* wrapperValue = new JSValueWrapper(resultValue, ptr->GetExecState());
-               JSObjectCallBacks callBacks;
-               GetJSObectCallBacks(callBacks);
-               result = JSObjectCreate(wrapperValue, &callBacks);
-               if (!result)
-               {
-                       delete wrapperValue;
-               }
-       }
-       return result;
+    JSObjectRef result = 0;
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    if (ptr)
+    {
+        ExecState* exec = ptr->GetExecState();
+
+        ValueImp *value = JSObjectKJSValue((JSUserObject*)thisObj);
+        ObjectImp *ksjThisObj = value->toObject(exec);
+        ObjectImp *objValue = ptr->GetValue()->toObject(exec);
+
+        List listArgs;
+        CFIndex argCount = args ? CFArrayGetCount(args) : 0;
+        for (CFIndex i = 0; i < argCount; i++)
+        {
+            JSObjectRef jsArg = (JSObjectRef)CFArrayGetValueAtIndex(args, i);
+            ValueImp *kgsArg = JSObjectKJSValue((JSUserObject*)jsArg);
+            listArgs.append(kgsArg);
+        }
+
+        ValueImp *resultValue = objValue->call(exec, ksjThisObj, listArgs);
+        JSValueWrapper* wrapperValue = new JSValueWrapper(resultValue, ptr->GetExecState());
+        JSObjectCallBacks callBacks;
+        GetJSObectCallBacks(callBacks);
+        result = JSObjectCreate(wrapperValue, &callBacks);
+        if (!result)
+        {
+            delete wrapperValue;
+        }
+    }
+    return result;
 }
 
-CFTypeRef JSValueWrapper::JSObjectCopyCFValue(voiddata)
+CFTypeRef JSValueWrapper::JSObjectCopyCFValue(void *data)
 {
     InterpreterLock lock;
 
-       CFTypeRef result = NULL;
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       if (ptr)
-       {
-               result = KJSValueToCFType(ptr->fValue, ptr->fExec);
-       }
-       return result;
+    CFTypeRef result = 0;
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    if (ptr)
+    {
+        result = KJSValueToCFType(ptr->fValue, ptr->fExec);
+    }
+    return result;
 }
 
-void JSValueWrapper::JSObjectMark(voiddata)
+void JSValueWrapper::JSObjectMark(void *data)
 {
-       JSValueWrapper* ptr = (JSValueWrapper*)data;
-       if (ptr)
-       {
-               ptr->fValue->mark();
-       }
+    JSValueWrapper* ptr = (JSValueWrapper*)data;
+    if (ptr)
+    {
+        ptr->fValue->mark();
+    }
 }
index 4851acc..eb48b56 100644 (file)
@@ -1,10 +1,8 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
-
-#ifndef __JSValueWrapper_h
-#define __JSValueWrapper_h
+#ifndef JSValueWrapper_h
+#define JSValueWrapper_h
 
 /*
-       JSValueWrapper.h
+    JSValueWrapper.h
 */
 
 #include "JSUtils.h"
@@ -15,24 +13,23 @@ class JSValueWrapper {
 public:
     JSValueWrapper(ValueImp *inValue, ExecState *inExec);
     virtual ~JSValueWrapper();
-    
+
     ValueImp *GetValue();
-    ExecStateGetExecState() const;
-    
+    ExecState *GetExecState() const;
+
     ProtectedPtr<ValueImp> fValue;
-    ExecStatefExec;
-    
+    ExecState *fExec;
+
     static void GetJSObectCallBacks(JSObjectCallBacks& callBacks);
-    
+
 private:
-    static void JSObjectDispose(voiddata);
-    static CFArrayRef JSObjectCopyPropertyNames(voiddata);
-    static JSObjectRef JSObjectCopyProperty(voiddata, CFStringRef propertyName);
-    static void JSObjectSetProperty(voiddata, CFStringRef propertyName, JSObjectRef jsValue);
-    static JSObjectRef JSObjectCallFunction(voiddata, JSObjectRef thisObj, CFArrayRef args);
-    static CFTypeRef JSObjectCopyCFValue(voiddata);
-    static void JSObjectMark(voiddata);
+    static void JSObjectDispose(void *data);
+    static CFArrayRef JSObjectCopyPropertyNames(void *data);
+    static JSObjectRef JSObjectCopyProperty(void *data, CFStringRef propertyName);
+    static void JSObjectSetProperty(void *data, CFStringRef propertyName, JSObjectRef jsValue);
+    static JSObjectRef JSObjectCallFunction(void *data, JSObjectRef thisObj, CFArrayRef args);
+    static CFTypeRef JSObjectCopyCFValue(void *data);
+    static void JSObjectMark(void *data);
 };
 
-
 #endif
index 1bbdf1e..2c92a61 100644 (file)
@@ -1,5 +1,5 @@
 /*
-       JSGlue.cpp
+    JSGlue.cpp
 */
 
 #include "JavaScriptGlue.h"
 #include "JSObject.h"
 #include "JSRun.h"
 
-static CFTypeRef sJSCFNullRef = NULL;
+static CFTypeRef sJSCFNullRef = 0;
 
-static void CFJSObjectDispose(voiddata);
-static JSObjectRef CFJSObjectCopyProperty(voiddata, CFStringRef propertyName);
-static void CFJSObjectSetProperty(voiddata, CFStringRef propertyName, JSObjectRef jsValue);
-static CFTypeRef CFJSObjectCopyCFValue(voiddata);
-static UInt8 CFJSObjectEqual(void* data1, void* data2);
-static CFArrayRef CFJSObjectCopyPropertyNames(voiddata);
+static void CFJSObjectDispose(void *data);
+static JSObjectRef CFJSObjectCopyProperty(void *data, CFStringRef propertyName);
+static void CFJSObjectSetProperty(void *data, CFStringRef propertyName, JSObjectRef jsValue);
+static CFTypeRef CFJSObjectCopyCFValue(void *data);
+static UInt8 CFJSObjectEqual(void *data1, void *data2);
+static CFArrayRef CFJSObjectCopyPropertyNames(void *data);
 
-voidJSCFRetain(CFAllocatorRef allocator, const void *value);
+void *JSCFRetain(CFAllocatorRef allocator, const void *value);
 void JSCFRelease(CFAllocatorRef allocator, const void *value);
 
 
 void JSSetCFNull(CFTypeRef nullRef)
 {
-       ReleaseCFType(sJSCFNullRef);
-       sJSCFNullRef = RetainCFType(nullRef);
+    ReleaseCFType(sJSCFNullRef);
+    sJSCFNullRef = RetainCFType(nullRef);
 }
 
 CFTypeRef JSGetCFNull(void)
 {
-       return sJSCFNullRef;
+    return sJSCFNullRef;
 }
 
 /*
-       JSRetain
+    JSRetain
 */
 JSTypeRef JSRetain(JSTypeRef ref)
 {
-       if (ref)
-       {
-               JSBase* ptr = (JSBase*)ref;
-               ptr->Retain();
-       }
-       return ref;
+    if (ref)
+    {
+        JSBase* ptr = (JSBase*)ref;
+        ptr->Retain();
+    }
+    return ref;
 }
 
 /*
-       JSRelease
+    JSRelease
 */
 void JSRelease(JSTypeRef ref)
 {
-       if (ref)
-       {
-               JSBase* ptr = (JSBase*)ref;
-               ptr->Release();
-       }
+    if (ref)
+    {
+        JSBase* ptr = (JSBase*)ref;
+        ptr->Release();
+    }
 }
 
 /*
-       JSCopyDescription
+    JSCopyDescription
 */
-CFStringRef    JSCopyDescription(JSTypeRef ref)
+CFStringRef JSCopyDescription(JSTypeRef ref)
 {
-       CFStringRef result = NULL;
-       if (ref)
-       {
-               JSBase* ptr = (JSBase*)ref;
-               ptr->CopyDescription();
-       }
-       return result;
+    CFStringRef result = 0;
+    if (ref)
+    {
+        JSBase* ptr = (JSBase*)ref;
+        ptr->CopyDescription();
+    }
+    return result;
 }
 
 /*
-       JSEqual
+    JSEqual
 */
-UInt8  JSEqual(JSTypeRef ref1, JSTypeRef ref2)
+UInt8 JSEqual(JSTypeRef ref1, JSTypeRef ref2)
 {
-       UInt8 result = false;
-       if (ref1 && ref2)
-       {
-               JSBase* ptr = (JSBase*)ref1;
-               result = ptr->Equal((JSBase*)ref2);
-       }
-       return result;
+    UInt8 result = false;
+    if (ref1 && ref2)
+    {
+        JSBase* ptr = (JSBase*)ref1;
+        result = ptr->Equal((JSBase*)ref2);
+    }
+    return result;
 }
 
 
 /*
-       JSGetTypeID
+    JSGetTypeID
 */
 JSTypeID JSGetTypeID(JSTypeRef ref)
 {
-       JSTypeID result = kJSInvalidTypeID;
-       if (ref)
-       {
-               JSBase* ptr = (JSBase*)ref;
-               result = ptr->GetTypeID();
-       }
-       return result;
+    JSTypeID result = kJSInvalidTypeID;
+    if (ref)
+    {
+        JSBase* ptr = (JSBase*)ref;
+        result = ptr->GetTypeID();
+    }
+    return result;
 }
 
 
 /*
-       JSGetRetainCount
+    JSGetRetainCount
 */
 CFIndex JSGetRetainCount(JSTypeRef ref)
 {
-       CFIndex result = -1;
-       if (ref)
-       {
-               JSBase* ptr = (JSBase*)ref;
-               result = ptr->RetainCount();
-       }
-       return result;
+    CFIndex result = -1;
+    if (ref)
+    {
+        JSBase* ptr = (JSBase*)ref;
+        result = ptr->RetainCount();
+    }
+    return result;
 }
 
 
 
 /*
-       JSObjectCreate
+    JSObjectCreate
 */
-JSObjectRef JSObjectCreate(voiddata, JSObjectCallBacksPtr callBacks)
+JSObjectRef JSObjectCreate(void *data, JSObjectCallBacksPtr callBacks)
 {
-       JSObjectRef result = JSObjectCreateInternal(data, callBacks, NULL, kJSUserObjectDataTypeUnknown);
-       return result;
+    JSObjectRef result = JSObjectCreateInternal(data, callBacks, 0, kJSUserObjectDataTypeUnknown);
+    return result;
 }
 
 /*
-       JSObjectCreateInternal
+    JSObjectCreateInternal
 */
-JSObjectRef JSObjectCreateInternal(voiddata, JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, int type)
+JSObjectRef JSObjectCreateInternal(void *data, JSObjectCallBacksPtr callBacks, JSObjectMarkProcPtr markProc, int type)
 {
-       JSObjectRef result = NULL;
-       JSUserObject* ptr = new JSUserObject(callBacks, markProc, data, type);
-       result = (JSObjectRef)ptr;
-       return result;
+    JSObjectRef result = 0;
+    JSUserObject* ptr = new JSUserObject(callBacks, markProc, data, type);
+    result = (JSObjectRef)ptr;
+    return result;
 }
 
 /*
-       JSObjectCopyCFValue
+    JSObjectCopyCFValue
 */
 CFTypeRef JSObjectCopyCFValue(JSObjectRef ref)
 {
-       CFTypeRef result = NULL;
-       JSUserObject* ptr = (JSUserObject*)ref;
-       if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
-       {
-               result = ptr->CopyCFValue();
-       }
-       return result;
+    CFTypeRef result = 0;
+    JSUserObject* ptr = (JSUserObject*)ref;
+    if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
+    {
+        result = ptr->CopyCFValue();
+    }
+    return result;
 }
 
 /*
-       JSObjectGetData
+    JSObjectGetData
 */
-voidJSObjectGetData(JSObjectRef ref)
+void *JSObjectGetData(JSObjectRef ref)
 {
-       void* result = NULL;
-       JSUserObject* ptr = (JSUserObject*)ref;
-       if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
-       {
-               result = ptr->GetData();
-       }
-       return result;
+    void *result = 0;
+    JSUserObject* ptr = (JSUserObject*)ref;
+    if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
+    {
+        result = ptr->GetData();
+    }
+    return result;
 }
 
 
 /*
-       JSObjectCopyProperty
+    JSObjectCopyProperty
 */
 JSObjectRef JSObjectCopyProperty(JSObjectRef ref, CFStringRef propertyName)
 {
-       JSObjectRef result = NULL;
-       JSUserObject* ptr = (JSUserObject*)ref;
-       if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
-       {
-               result = (JSObjectRef)ptr->CopyProperty(propertyName);
-       }
-       return result;
+    JSObjectRef result = 0;
+    JSUserObject* ptr = (JSUserObject*)ref;
+    if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
+    {
+        result = (JSObjectRef)ptr->CopyProperty(propertyName);
+    }
+    return result;
 }
 
 
 /*
-       JSObjectSetProperty
+    JSObjectSetProperty
 */
 void JSObjectSetProperty(JSObjectRef ref, CFStringRef propertyName, JSObjectRef value)
 {
-       JSUserObject* ptr = (JSUserObject*)ref;
-       if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
-       {
-               ptr->SetProperty(propertyName, (JSUserObject*)value);
-       }
+    JSUserObject* ptr = (JSUserObject*)ref;
+    if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
+    {
+        ptr->SetProperty(propertyName, (JSUserObject*)value);
+    }
 }
 
 
 /*
-       JSObjectCallFunction
+    JSObjectCallFunction
 */
 JSObjectRef JSObjectCallFunction(JSObjectRef ref, JSObjectRef thisObj, CFArrayRef args)
 {
-       JSObjectRef result = NULL;
-       JSUserObject* ptr = (JSUserObject*)ref;
-       if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
-       {
-               result = (JSObjectRef)ptr->CallFunction((JSUserObject*)thisObj, args);
-       }
-       return result;
+    JSObjectRef result = 0;
+    JSUserObject* ptr = (JSUserObject*)ref;
+    if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
+    {
+        result = (JSObjectRef)ptr->CallFunction((JSUserObject*)thisObj, args);
+    }
+    return result;
 }
 
 
 /*
-       JSRunCreate
+    JSRunCreate
 */
 JSRunRef JSRunCreate(CFStringRef jsSource, JSFlags inFlags)
 {
-       JSRunRef result = NULL;
-       if (jsSource)
-       {
-               result = (JSRunRef) new JSRun(jsSource, inFlags);
-       }
-       return result;
+    JSRunRef result = 0;
+    if (jsSource)
+    {
+        result = (JSRunRef) new JSRun(jsSource, inFlags);
+    }
+    return result;
 }
 
 /*
-       JSRunCopySource
+    JSRunCopySource
 */
 CFStringRef JSRunCopySource(JSRunRef ref)
 {
-       CFStringRef result = NULL;
-       JSRun* ptr = (JSRun*)ref;
-       if (ptr)
-       {
-               result = UStringToCFString(ptr->GetSource());
-       }
-       return result;
+    CFStringRef result = 0;
+    JSRun* ptr = (JSRun*)ref;
+    if (ptr)
+    {
+        result = UStringToCFString(ptr->GetSource());
+    }
+    return result;
 }
 
 
 /*
-       JSRunCopyGlobalObject
+    JSRunCopyGlobalObject
 */
 JSObjectRef JSRunCopyGlobalObject(JSRunRef ref)
 {
-       JSObjectRef result = NULL;
-       JSRun* ptr = (JSRun*)ref;
-       if (ptr)
-       {
-               ObjectImp *globalObject = ptr->GlobalObject();
-               result = (JSObjectRef)KJSValueToJSObject(globalObject, ptr->GetInterpreter()->globalExec());
-       }
-       return result;
+    JSObjectRef result = 0;
+    JSRun* ptr = (JSRun*)ref;
+    if (ptr)
+    {
+        ObjectImp *globalObject = ptr->GlobalObject();
+        result = (JSObjectRef)KJSValueToJSObject(globalObject, ptr->GetInterpreter()->globalExec());
+    }
+    return result;
 }
 
 /*
-       JSRunEvaluate
+    JSRunEvaluate
 */
 JSObjectRef JSRunEvaluate(JSRunRef ref)
 {
-       JSObjectRef result = NULL;
-       JSRun* ptr = (JSRun*)ref;
-       if (ptr)
-       {
-               Completion completion = ptr->Evaluate();
-#if JAG_PINK_OR_LATER
-
-               if (completion.isValueCompletion())
-               {
-                       result = (JSObjectRef)KJSValueToJSObject(completion.value(), ptr->GetInterpreter()->globalExec());
-               }
-
-               if (completion.complType() == Throw)    
-               {
-                       JSFlags flags = ptr->Flags();
-                       if (flags & kJSFlagDebug)
-                       {
-                               CFTypeRef error = JSObjectCopyCFValue(result);
-                               if (error)
-                               {
-                                       CFShow(error);
-                                       CFRelease(error);
-                               }
-                       }
-               }
-
-#else
-               result = (JSObjectRef)KJSValueToJSObject(completion, ptr->GetInterpreter()->globalExec());              
-#endif
-       }
-       return result;
+    JSObjectRef result = 0;
+    JSRun* ptr = (JSRun*)ref;
+    if (ptr)
+    {
+        Completion completion = ptr->Evaluate();
+        if (completion.isValueCompletion())
+        {
+            result = (JSObjectRef)KJSValueToJSObject(completion.value(), ptr->GetInterpreter()->globalExec());
+        }
+
+        if (completion.complType() == Throw)
+        {
+            JSFlags flags = ptr->Flags();
+            if (flags & kJSFlagDebug)
+            {
+                CFTypeRef error = JSObjectCopyCFValue(result);
+                if (error)
+                {
+                    CFShow(error);
+                    CFRelease(error);
+                }
+            }
+        }
+    }
+    return result;
 }
 
 /*
-       JSRunCheckSyntax
-       Return true if no syntax error
+    JSRunCheckSyntax
+    Return true if no syntax error
 */
 bool JSRunCheckSyntax(JSRunRef ref)
 {
-#if JAG_PINK_OR_LATER
-       bool result = false;
-       JSRun* ptr = (JSRun*)ref;
-       if (ptr)
-       {
+    bool result = false;
+    JSRun* ptr = (JSRun*)ref;
+    if (ptr)
+    {
             JSLockInterpreter();
             result = ptr->CheckSyntax();
             JSUnlockInterpreter();
-       }
-       return result;
-#else
-       return true;
-#endif
+    }
+    return result;
 }
 
 /*
-       JSCollect - trigger garbage collection
+    JSCollect - trigger garbage collection
 */
 void JSCollect(void)
 {
-#if JAG_PINK_OR_LATER
     InterpreterLock lock;
-       Collector::collect();
-#endif
+    Collector::collect();
 }
 
 /*
-       JSTypeGetCFArrayCallBacks
+    JSTypeGetCFArrayCallBacks
 */
 void JSTypeGetCFArrayCallBacks(CFArrayCallBacks* outCallBacks)
 {
-       if (outCallBacks)
-       {
-               outCallBacks->version = 1;
-               outCallBacks->retain = (CFArrayRetainCallBack)JSCFRetain;
-               outCallBacks->release = (CFArrayReleaseCallBack)JSCFRelease;
-               outCallBacks->copyDescription = (CFArrayCopyDescriptionCallBack)JSCopyDescription;
-               outCallBacks->equal = (CFArrayEqualCallBack)JSEqual;
-       }
+    if (outCallBacks)
+    {
+        outCallBacks->version = 1;
+        outCallBacks->retain = (CFArrayRetainCallBack)JSCFRetain;
+        outCallBacks->release = (CFArrayReleaseCallBack)JSCFRelease;
+        outCallBacks->copyDescription = (CFArrayCopyDescriptionCallBack)JSCopyDescription;
+        outCallBacks->equal = (CFArrayEqualCallBack)JSEqual;
+    }
 }
 
 
 /*
-       JSCFRetain
+    JSCFRetain
 */
-voidJSCFRetain(CFAllocatorRef allocator, const void *value)
+void *JSCFRetain(CFAllocatorRef allocator, const void *value)
 {
-       JSRetain((JSTypeRef)value);
-       return (void*)value;
+    JSRetain((JSTypeRef)value);
+    return (void*)value;
 }
 
 /*
-       JSCFRelease
+    JSCFRelease
 */
 void JSCFRelease(CFAllocatorRef allocator, const void *value)
 {
-       JSRelease((JSTypeRef)value);
+    JSRelease((JSTypeRef)value);
 }
 
 
 /*
-       JSObjectCreateWithCFType
+    JSObjectCreateWithCFType
 */
 JSObjectRef JSObjectCreateWithCFType(CFTypeRef inRef)
 {
-       JSObjectCallBacks callBacks;
-       JSObjectRef cfJSObject = nil;
-       if (inRef)
-       {
-               callBacks.dispose = CFJSObjectDispose;
-               callBacks.equal = CFJSObjectEqual;
-               callBacks.copyCFValue = CFJSObjectCopyCFValue;
-               callBacks.copyProperty = CFJSObjectCopyProperty;
-               callBacks.setProperty = CFJSObjectSetProperty;
-               callBacks.callFunction = NULL;
-               callBacks.copyPropertyNames = CFJSObjectCopyPropertyNames;
-               cfJSObject = JSObjectCreateInternal((void*)CFRetain(inRef), &callBacks, NULL, kJSUserObjectDataTypeCFType );
-       }
-       return cfJSObject;
+    JSObjectCallBacks callBacks;
+    JSObjectRef cfJSObject = nil;
+    if (inRef)
+    {
+        callBacks.dispose = CFJSObjectDispose;
+        callBacks.equal = CFJSObjectEqual;
+        callBacks.copyCFValue = CFJSObjectCopyCFValue;
+        callBacks.copyProperty = CFJSObjectCopyProperty;
+        callBacks.setProperty = CFJSObjectSetProperty;
+        callBacks.callFunction = 0;
+        callBacks.copyPropertyNames = CFJSObjectCopyPropertyNames;
+        cfJSObject = JSObjectCreateInternal((void*)CFRetain(inRef), &callBacks, 0, kJSUserObjectDataTypeCFType );
+    }
+    return cfJSObject;
 }
 
 /*
-       CFJSObjectDispose
+    CFJSObjectDispose
 */
-void CFJSObjectDispose(voiddata)
+void CFJSObjectDispose(void *data)
 {
-       if (data)
-       {
-               CFRelease((JSTypeRef)data);
-       }
+    if (data)
+    {
+        CFRelease((JSTypeRef)data);
+    }
 }
 
 CFArrayRef JSObjectCopyPropertyNames(JSObjectRef ref)
 {
-       CFArrayRef result = NULL;
-       JSUserObject* ptr = (JSUserObject*)ref;
-       if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
-       {
-               result = ptr->CopyPropertyNames();
-       }
-       return result;
+    CFArrayRef result = 0;
+    JSUserObject* ptr = (JSUserObject*)ref;
+    if (ptr && (ptr->GetTypeID() == kJSObjectTypeID))
+    {
+        result = ptr->CopyPropertyNames();
+    }
+    return result;
 }
 /*
-       CFJSObjectCopyProperty
+    CFJSObjectCopyProperty
 */
-JSObjectRef CFJSObjectCopyProperty(voiddata, CFStringRef propertyName)
-{
-       JSObjectRef result = NULL;
-       if (data && propertyName)
-       {
-               CFTypeRef cfResult = NULL;
-               if (CFGetTypeID(data) == CFDictionaryGetTypeID())
-               {
-                       if (CFStringCompare(propertyName, CFSTR("length"), 0) == kCFCompareEqualTo)
-                       {
-                               int len = CFDictionaryGetCount((CFDictionaryRef)data);
-                               cfResult = CFNumberCreate(NULL, kCFNumberIntType, &len);
-                       }
-                       else
-                       {
-                               cfResult = RetainCFType(CFDictionaryGetValue((CFDictionaryRef)data, propertyName));
-                       }
-               }
-               else if (CFGetTypeID(data) == CFArrayGetTypeID())
-               {
-                       if (CFStringCompare(propertyName, CFSTR("length"), 0) == kCFCompareEqualTo)
-                       {
-                               int len = CFArrayGetCount((CFArrayRef)data);
-                               cfResult = CFNumberCreate(NULL, kCFNumberIntType, &len);
-                       }
-                       else
-                       {
-                               SInt32 index = CFStringGetIntValue(propertyName);       
-                               CFIndex arrayCount = CFArrayGetCount((CFArrayRef)data);
-                               if (index >= 0 && index < arrayCount)
-                               {
-                                       cfResult = RetainCFType(CFArrayGetValueAtIndex((CFArrayRef)data, index));
-                               }
-                       }
-               }
-               else if (CFGetTypeID(data) == CFStringGetTypeID())
-               {
-                       if (CFStringCompare(propertyName, CFSTR("length"), 0) == kCFCompareEqualTo)
-                       {
-                               int len = CFStringGetLength((CFStringRef)data);
-                               cfResult = CFNumberCreate(NULL, kCFNumberIntType, &len);
-                       }
-               }
-               if (cfResult)
-               {
-                       result = JSObjectCreateWithCFType(cfResult);
-                       CFRelease(cfResult);
-               }
-       }
-       return result;
+JSObjectRef CFJSObjectCopyProperty(void *data, CFStringRef propertyName)
+{
+    JSObjectRef result = 0;
+    if (data && propertyName)
+    {
+        CFTypeRef cfResult = 0;
+        if (CFGetTypeID(data) == CFDictionaryGetTypeID())
+        {
+            if (CFStringCompare(propertyName, CFSTR("length"), 0) == kCFCompareEqualTo)
+            {
+                int len = CFDictionaryGetCount((CFDictionaryRef)data);
+                cfResult = CFNumberCreate(0, kCFNumberIntType, &len);
+            }
+            else
+            {
+                cfResult = RetainCFType(CFDictionaryGetValue((CFDictionaryRef)data, propertyName));
+            }
+        }
+        else if (CFGetTypeID(data) == CFArrayGetTypeID())
+        {
+            if (CFStringCompare(propertyName, CFSTR("length"), 0) == kCFCompareEqualTo)
+            {
+                int len = CFArrayGetCount((CFArrayRef)data);
+                cfResult = CFNumberCreate(0, kCFNumberIntType, &len);
+            }
+            else
+            {
+                SInt32 index = CFStringGetIntValue(propertyName);
+                CFIndex arrayCount = CFArrayGetCount((CFArrayRef)data);
+                if (index >= 0 && index < arrayCount)
+                {
+                    cfResult = RetainCFType(CFArrayGetValueAtIndex((CFArrayRef)data, index));
+                }
+            }
+        }
+        else if (CFGetTypeID(data) == CFStringGetTypeID())
+        {
+            if (CFStringCompare(propertyName, CFSTR("length"), 0) == kCFCompareEqualTo)
+            {
+                int len = CFStringGetLength((CFStringRef)data);
+                cfResult = CFNumberCreate(0, kCFNumberIntType, &len);
+            }
+        }
+        if (cfResult)
+        {
+            result = JSObjectCreateWithCFType(cfResult);
+            CFRelease(cfResult);
+        }
+    }
+    return result;
 }
 
 
 /*
-       CFJSObjectSetProperty
+    CFJSObjectSetProperty
 */
-void CFJSObjectSetProperty(voiddata, CFStringRef propertyName, JSObjectRef jsValue)
-{
-       if (data && propertyName)
-       {
-               CFTypeRef cfValue = JSObjectCopyCFValue(jsValue);
-
-               if (cfValue)
-               {
-                       if (CFGetTypeID(data) == CFDictionaryGetTypeID())
-                       {
-                               CFDictionarySetValue((CFMutableDictionaryRef)data, propertyName, cfValue);
-                       }
-                       else if (CFGetTypeID(data) == CFArrayGetTypeID())
-                       {
-                               SInt32 index = CFStringGetIntValue(propertyName);       
-                               CFIndex arrayCount = CFArrayGetCount((CFArrayRef)data);
-                               if (index >= 0)
-                               {
-                                       for (; arrayCount < index; arrayCount++)
-                                       {
-                                               CFArrayAppendValue((CFMutableArrayRef)data, GetCFNull());
-                                       }
-                                       CFArraySetValueAtIndex((CFMutableArrayRef)data, index, cfValue);                                        
-                               }
-                       }               
-                       CFRelease(cfValue);
-               }
-               else
-               {
-                       if (CFGetTypeID(data) == CFDictionaryGetTypeID())
-                       {
-                               CFDictionaryRemoveValue((CFMutableDictionaryRef)data, propertyName);
-                       }
-                       else if (CFGetTypeID(data) == CFArrayGetTypeID())
-                       {
-                               SInt32 index = CFStringGetIntValue(propertyName);                               
-                               CFIndex arrayCount = CFArrayGetCount((CFArrayRef)data);
-                               if (index >= 0)
-                               {
-                                       for (; arrayCount < index; arrayCount++)
-                                       {
-                                               CFArrayAppendValue((CFMutableArrayRef)data, GetCFNull());
-                                       }
-                                       CFArraySetValueAtIndex((CFMutableArrayRef)data, index, GetCFNull());                                    
-                               }                               
-                       }
-               }
-       }
+void CFJSObjectSetProperty(void *data, CFStringRef propertyName, JSObjectRef jsValue)
+{
+    if (data && propertyName)
+    {
+        CFTypeRef cfValue = JSObjectCopyCFValue(jsValue);
+
+        if (cfValue)
+        {
+            if (CFGetTypeID(data) == CFDictionaryGetTypeID())
+            {
+                CFDictionarySetValue((CFMutableDictionaryRef)data, propertyName, cfValue);
+            }
+            else if (CFGetTypeID(data) == CFArrayGetTypeID())
+            {
+                SInt32 index = CFStringGetIntValue(propertyName);
+                CFIndex arrayCount = CFArrayGetCount((CFArrayRef)data);
+                if (index >= 0)
+                {
+                    for (; arrayCount < index; arrayCount++)
+                    {
+                        CFArrayAppendValue((CFMutableArrayRef)data, GetCFNull());
+                    }
+                    CFArraySetValueAtIndex((CFMutableArrayRef)data, index, cfValue);
+                }
+            }
+            CFRelease(cfValue);
+        }
+        else
+        {
+            if (CFGetTypeID(data) == CFDictionaryGetTypeID())
+            {
+                CFDictionaryRemoveValue((CFMutableDictionaryRef)data, propertyName);
+            }
+            else if (CFGetTypeID(data) == CFArrayGetTypeID())
+            {
+                SInt32 index = CFStringGetIntValue(propertyName);
+                CFIndex arrayCount = CFArrayGetCount((CFArrayRef)data);
+                if (index >= 0)
+                {
+                    for (; arrayCount < index; arrayCount++)
+                    {
+                        CFArrayAppendValue((CFMutableArrayRef)data, GetCFNull());
+                    }
+                    CFArraySetValueAtIndex((CFMutableArrayRef)data, index, GetCFNull());
+                }
+            }
+        }
+    }
 }
 
 
 /*
-       CFJSObjectCopyCFValue
+    CFJSObjectCopyCFValue
 */
-CFTypeRef CFJSObjectCopyCFValue(voiddata)
+CFTypeRef CFJSObjectCopyCFValue(void *data)
 {
-       CFTypeRef result = NULL;
-       if (data)
-       {
-               result = (CFTypeRef)CFRetain(data);
-       }
-       return result;
+    CFTypeRef result = 0;
+    if (data)
+    {
+        result = (CFTypeRef)CFRetain(data);
+    }
+    return result;
 }
 
 /*
-       CFJSObjectCopyCFValue
+    CFJSObjectCopyCFValue
 */
-UInt8 CFJSObjectEqual(void* data1, void* data2)
+UInt8 CFJSObjectEqual(void *data1, void *data2)
 {
-       UInt8 result = false;
-       if (data1 && data2)
-       {
-               CFEqual((CFTypeRef)data1, (CFTypeRef)data2);
-       }
-       return result;
+    UInt8 result = false;
+    if (data1 && data2)
+    {
+        CFEqual((CFTypeRef)data1, (CFTypeRef)data2);
+    }
+    return result;
 }
 
 
 /*
-       CFJSObjectCopyPropertyNames
+    CFJSObjectCopyPropertyNames
 */
-CFArrayRef CFJSObjectCopyPropertyNames(voiddata)
-{
-       CFMutableArrayRef result = NULL;
-       if (data)
-       {
-               CFTypeID cfType = CFGetTypeID(data);
-               if (cfType == CFDictionaryGetTypeID())
-               {
-                       CFIndex count = CFDictionaryGetCount((CFDictionaryRef)data);
-                       if (count)
-                       {
-                               CFTypeRef* keys = (CFTypeRef*)malloc(sizeof(CFTypeRef)*count);
-                               if (keys)
-                               {
-                                       int i;
-                                       CFDictionaryGetKeysAndValues((CFDictionaryRef)data, (const void **)keys, NULL);
-                                       for (i = 0; i < count; i++)
-                                       {
-                                               CFStringRef key = (CFStringRef)keys[i];
-                                               if (CFGetTypeID(key) != CFStringGetTypeID()) continue;
-
-                                               if (!result) result = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-                                               if (!result) continue;
-                                               
-                                               CFArrayAppendValue(result, key);
-                                       }
-                                       free(keys);
-                               }
-                       }
-               }
-       }
-       return result;
+CFArrayRef CFJSObjectCopyPropertyNames(void *data)
+{
+    CFMutableArrayRef result = 0;
+    if (data)
+    {
+        CFTypeID cfType = CFGetTypeID(data);
+        if (cfType == CFDictionaryGetTypeID())
+        {
+            CFIndex count = CFDictionaryGetCount((CFDictionaryRef)data);
+            if (count)
+            {
+                CFTypeRef* keys = (CFTypeRef*)malloc(sizeof(CFTypeRef)*count);
+                if (keys)
+                {
+                    int i;
+                    CFDictionaryGetKeysAndValues((CFDictionaryRef)data, (const void **)keys, 0);
+                    for (i = 0; i < count; i++)
+                    {
+                        CFStringRef key = (CFStringRef)keys[i];
+                        if (CFGetTypeID(key) != CFStringGetTypeID()) continue;
+
+                        if (!result) result = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks);
+                        if (!result) continue;
+
+                        CFArrayAppendValue(result, key);
+                    }
+                    free(keys);
+                }
+            }
+        }
+    }
+    return result;
 }
 
 
@@ -577,65 +565,60 @@ CFArrayRef CFJSObjectCopyPropertyNames(void* data)
 
 CFMutableArrayRef JSCreateCFArrayFromJSArray(CFArrayRef array)
 {
-       CFIndex count = array ? CFArrayGetCount(array) : 0;
-       CFMutableArrayRef cfArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-       CFIndex i;
-
-       for (i = 0; cfArray && i <  count; i++)
-       {
-               JSObjectRef jsValue = (JSObjectRef)CFArrayGetValueAtIndex(array, i);
-               CFTypeRef cfvalue = JSObjectCopyCFValue(jsValue);
-               if (cfvalue)
-               {
-                       CFArrayAppendValue(cfArray, cfvalue);
-                       CFRelease(cfvalue);
-               }
-               else
-               {
-                       CFArrayAppendValue(cfArray, GetCFNull());
-               }
-       }
-       return cfArray;
+    CFIndex count = array ? CFArrayGetCount(array) : 0;
+    CFMutableArrayRef cfArray = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks);
+    CFIndex i;
+
+    for (i = 0; cfArray && i <  count; i++)
+    {
+        JSObjectRef jsValue = (JSObjectRef)CFArrayGetValueAtIndex(array, i);
+        CFTypeRef cfvalue = JSObjectCopyCFValue(jsValue);
+        if (cfvalue)
+        {
+            CFArrayAppendValue(cfArray, cfvalue);
+            CFRelease(cfvalue);
+        }
+        else
+        {
+            CFArrayAppendValue(cfArray, GetCFNull());
+        }
+    }
+    return cfArray;
 }
 
 CFMutableArrayRef JSCreateJSArrayFromCFArray(CFArrayRef array)
 {
-       CFIndex count = array ? CFArrayGetCount(array) : 0;
-       CFArrayCallBacks arrayCallbacks;
-       CFMutableArrayRef jsArray;
-       CFIndex i;
+    CFIndex count = array ? CFArrayGetCount(array) : 0;
+    CFArrayCallBacks arrayCallbacks;
+    CFMutableArrayRef jsArray;
+    CFIndex i;
 
-       JSTypeGetCFArrayCallBacks(&arrayCallbacks);
-       jsArray = CFArrayCreateMutable(NULL, 0, &arrayCallbacks);
+    JSTypeGetCFArrayCallBacks(&arrayCallbacks);
+    jsArray = CFArrayCreateMutable(0, 0, &arrayCallbacks);
 
-       for (i = 0; array && i <  count; i++)
-       {
-               CFTypeRef cfValue = (CFTypeRef)CFArrayGetValueAtIndex(array, i);
-               JSObjectRef jsValue = JSObjectCreateWithCFType(cfValue);
-               
-               if (!jsValue) jsValue = JSObjectCreateWithCFType(GetCFNull());
-               if (jsValue)
-               {
-                       CFArrayAppendValue(jsArray, jsValue);
-                       JSRelease(jsValue);
-               }
-       }
-       return jsArray;
+    for (i = 0; array && i <  count; i++)
+    {
+        CFTypeRef cfValue = (CFTypeRef)CFArrayGetValueAtIndex(array, i);
+        JSObjectRef jsValue = JSObjectCreateWithCFType(cfValue);
+
+        if (!jsValue) jsValue = JSObjectCreateWithCFType(GetCFNull());
+        if (jsValue)
+        {
+            CFArrayAppendValue(jsArray, jsValue);
+            JSRelease(jsValue);
+        }
+    }
+    return jsArray;
 }
 
 
 void JSLockInterpreter()
 {
-#if JAG_PINK_OR_LATER
-       Interpreter::lock();
-#endif
+    Interpreter::lock();
 }
 
 
 void JSUnlockInterpreter()
 {
-#if JAG_PINK_OR_LATER
-       Interpreter::unlock();
-#endif
+    Interpreter::unlock();
 }
-
index 8a8f8a4..dfa3d26 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __JAVASCRIPTGLUE__
-#define __JAVASCRIPTGLUE__
+#ifndef JAVASCRIPTGLUE_H
+#define JAVASCRIPTGLUE_H
 
 /*
-       JavaScriptGlue.h
+    JavaScriptGlue.h
 */
 
 #ifndef __CORESERVICES__
@@ -15,32 +15,32 @@ extern "C" {
 
 /* typedefs/structs */
 typedef enum {
-       kJSFlagNone = 0,
-       kJSFlagDebug = 1 << 0,
-       kJSFlagConvertAssociativeArray = 1 << 1 /* associative arrays will be converted to dictionaries */
+    kJSFlagNone = 0,
+    kJSFlagDebug = 1 << 0,
+    kJSFlagConvertAssociativeArray = 1 << 1 /* associative arrays will be converted to dictionaries */
 } JSFlags;
 
-typedef struct OpaqueJSTypeRefJSTypeRef;
+typedef struct OpaqueJSTypeRef *JSTypeRef;
 typedef JSTypeRef JSObjectRef;
 typedef JSTypeRef JSRunRef;
 typedef CFTypeID JSTypeID;
 
-typedef void (*JSObjectDisposeProcPtr)(voiddata);
-typedef CFArrayRef (*JSObjectCopyPropertyNamesProcPtr)(voiddata);
-typedef JSObjectRef (*JSObjectCopyPropertyProcPtr)(voiddata, CFStringRef propertyName);
-typedef void (*JSObjectSetPropertyProcPtr)(voiddata, CFStringRef propertyName, JSObjectRef jsValue);
-typedef JSObjectRef (*JSObjectCallFunctionProcPtr)(voiddata, JSObjectRef thisObj, CFArrayRef args);
-typedef CFTypeRef (*JSObjectCopyCFValueProcPtr)(voiddata);
-typedef UInt8 (*JSObjectEqualProcPtr)(void* data1, void* data2);
+typedef void (*JSObjectDisposeProcPtr)(void *data);
+typedef CFArrayRef (*JSObjectCopyPropertyNamesProcPtr)(void *data);
+typedef JSObjectRef (*JSObjectCopyPropertyProcPtr)(void *data, CFStringRef propertyName);
+typedef void (*JSObjectSetPropertyProcPtr)(void *data, CFStringRef propertyName, JSObjectRef jsValue);
+typedef JSObjectRef (*JSObjectCallFunctionProcPtr)(void *data, JSObjectRef thisObj, CFArrayRef args);
+typedef CFTypeRef (*JSObjectCopyCFValueProcPtr)(void *data);
+typedef UInt8 (*JSObjectEqualProcPtr)(void *data1, void *data2);
 
 struct JSObjectCallBacks {
-       JSObjectDisposeProcPtr dispose;
-       JSObjectEqualProcPtr equal;
-       JSObjectCopyCFValueProcPtr copyCFValue;
-       JSObjectCopyPropertyProcPtr copyProperty;
-       JSObjectSetPropertyProcPtr setProperty;
-       JSObjectCallFunctionProcPtr callFunction;
-       JSObjectCopyPropertyNamesProcPtr copyPropertyNames;
+    JSObjectDisposeProcPtr dispose;
+    JSObjectEqualProcPtr equal;
+    JSObjectCopyCFValueProcPtr copyCFValue;
+    JSObjectCopyPropertyProcPtr copyProperty;
+    JSObjectSetPropertyProcPtr setProperty;
+    JSObjectCallFunctionProcPtr callFunction;
+    JSObjectCopyPropertyNamesProcPtr copyPropertyNames;
 };
 typedef struct JSObjectCallBacks JSObjectCallBacks, *JSObjectCallBacksPtr;
 
@@ -51,13 +51,13 @@ JSTypeRef JSRetain(JSTypeRef ref);
 void JSRelease(JSTypeRef ref);
 JSTypeID JSGetTypeID(JSTypeRef ref);
 CFIndex JSGetRetainCount(JSTypeRef ref);
-CFStringRef    JSCopyDescription(JSTypeRef ref);
+CFStringRef JSCopyDescription(JSTypeRef ref);
 UInt8 JSEqual(JSTypeRef ref1, JSTypeRef ref2);
 
-JSObjectRef JSObjectCreate(voiddata, JSObjectCallBacksPtr callBacks);
+JSObjectRef JSObjectCreate(void *data, JSObjectCallBacksPtr callBacks);
 JSObjectRef JSObjectCreateWithCFType(CFTypeRef inRef);
 CFTypeRef JSObjectCopyCFValue(JSObjectRef ref);
-voidJSObjectGetData(JSObjectRef ref);
+void *JSObjectGetData(JSObjectRef ref);
 
 CFArrayRef JSObjectCopyPropertyNames(JSObjectRef ref);
 JSObjectRef JSObjectCopyProperty(JSObjectRef ref, CFStringRef propertyName);
@@ -72,13 +72,13 @@ bool JSRunCheckSyntax(JSRunRef ref);
 
 void JSCollect(void);
 
-void JSTypeGetCFArrayCallBacks(CFArrayCallBacksoutCallBacks);
+void JSTypeGetCFArrayCallBacks(CFArrayCallBacks *outCallBacks);
 
-CFMutableArrayRef JSCreateCFArrayFromJSArray(CFArrayRef array); 
+CFMutableArrayRef JSCreateCFArrayFromJSArray(CFArrayRef array);
 CFMutableArrayRef JSCreateJSArrayFromCFArray(CFArrayRef array);
 
-void JSLockInterpreter();
-void JSUnlockInterpreter();
+void JSLockInterpreter(void);
+void JSUnlockInterpreter(void);
 
 #ifdef __cplusplus
 }
index beee2fc..0731495 100644 (file)
@@ -6,12 +6,12 @@ const ClassInfo UserObjectImp::info = {"UserObject", 0, 0, 0};
 class UserObjectPrototypeImp : public UserObjectImp {
   public:
     UserObjectPrototypeImp();
-       static UserObjectPrototypeImp* GlobalUserObjectPrototypeImp();
+    static UserObjectPrototypeImp* GlobalUserObjectPrototypeImp();
   private:
-       static UserObjectPrototypeImp* sUserObjectPrototypeImp;
+    static UserObjectPrototypeImp* sUserObjectPrototypeImp;
 };
 
-UserObjectPrototypeImp* UserObjectPrototypeImp::sUserObjectPrototypeImp = NULL;
+UserObjectPrototypeImp* UserObjectPrototypeImp::sUserObjectPrototypeImp = 0;
 
 UserObjectPrototypeImp::UserObjectPrototypeImp()
   : UserObjectImp()
@@ -20,41 +20,41 @@ UserObjectPrototypeImp::UserObjectPrototypeImp()
 
 UserObjectPrototypeImp* UserObjectPrototypeImp::GlobalUserObjectPrototypeImp()
 {
-       if (!sUserObjectPrototypeImp)
-       {
+    if (!sUserObjectPrototypeImp)
+    {
             sUserObjectPrototypeImp  = new UserObjectPrototypeImp();
             static ProtectedPtr<UserObjectPrototypeImp> protectPrototype;
-       }
-       return sUserObjectPrototypeImp;
+    }
+    return sUserObjectPrototypeImp;
 }
 
 
-UserObjectImp::UserObjectImp(): ObjectImp(), fJSUserObject(NULL)
+UserObjectImp::UserObjectImp(): ObjectImp(), fJSUserObject(0)
 {
 }
 
-UserObjectImp::UserObjectImp(JSUserObject* userObject) : 
-       ObjectImp(UserObjectPrototypeImp::GlobalUserObjectPrototypeImp()), 
-       fJSUserObject((JSUserObject*)userObject->Retain()) 
-{ 
+UserObjectImp::UserObjectImp(JSUserObject* userObject) :
+    ObjectImp(UserObjectPrototypeImp::GlobalUserObjectPrototypeImp()),
+    fJSUserObject((JSUserObject*)userObject->Retain())
+{
 }
 
-UserObjectImp::~UserObjectImp() 
+UserObjectImp::~UserObjectImp()
 {
-       if (fJSUserObject)
-       {
-               fJSUserObject->Release(); 
-       }
+    if (fJSUserObject)
+    {
+        fJSUserObject->Release();
+    }
 }
-    
-const ClassInfo        * UserObjectImp::classInfo() const 
+
+const ClassInfo * UserObjectImp::classInfo() const
 {
-       return &info; 
+    return &info;
 }
-        
-bool   UserObjectImp::implementsCall() const 
+
+bool UserObjectImp::implementsCall() const
 {
-       return fJSUserObject ? fJSUserObject->ImplementsCall() : false; 
+    return fJSUserObject ? fJSUserObject->ImplementsCall() : false;
 }
 
 ValueImp *UserObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
@@ -65,7 +65,7 @@ ValueImp *UserObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, con
         CFIndex argCount = args.size();
         CFArrayCallBacks arrayCallBacks;
         JSTypeGetCFArrayCallBacks(&arrayCallBacks);
-        CFMutableArrayRef jsArgs = CFArrayCreateMutable(NULL, 0, &arrayCallBacks);
+        CFMutableArrayRef jsArgs = CFArrayCreateMutable(0, 0, &arrayCallBacks);
         if (jsArgs) {
             for (CFIndex i = 0; i < argCount; i++) {
                 JSUserObject* jsArg = KJSValueToJSObject(args[i], exec);
@@ -79,9 +79,9 @@ ValueImp *UserObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, con
         for (i = 0; i < lockCount; i++) {
             Interpreter::unlock();
         }
-        
+
         JSUserObject* jsResult = fJSUserObject->CallFunction(jsThisObj, jsArgs);
-        
+
         for (i = 0; i < lockCount; i++) {
             Interpreter::lock();
         }
@@ -118,7 +118,7 @@ void UserObjectImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet& pr
 ValueImp *UserObjectImp::userObjectGetter(ExecState *, const Identifier& propertyName, const PropertySlot& slot)
 {
     UserObjectImp *thisObj = static_cast<UserObjectImp *>(slot.slotBase());
-    CFStringRef        cfPropName = IdentifierToCFString(propertyName);
+    CFStringRef cfPropName = IdentifierToCFString(propertyName);
     JSUserObject *jsResult = thisObj->fJSUserObject->CopyProperty(cfPropName);
     ReleaseCFType(cfPropName);
     ValueImp *result = JSObjectKJSValue(jsResult);
@@ -129,7 +129,7 @@ ValueImp *UserObjectImp::userObjectGetter(ExecState *, const Identifier& propert
 
 bool UserObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 {
-    CFStringRef        cfPropName = IdentifierToCFString(propertyName);
+    CFStringRef cfPropName = IdentifierToCFString(propertyName);
     JSUserObject *jsResult = fJSUserObject->CopyProperty(cfPropName);
     ReleaseCFType(cfPropName);
     if (jsResult) {
@@ -149,25 +149,25 @@ bool UserObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& proper
 
 void UserObjectImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
 {
-    CFStringRef        cfPropName = IdentifierToCFString(propertyName);
+    CFStringRef cfPropName = IdentifierToCFString(propertyName);
     JSUserObject *jsValueObj = KJSValueToJSObject(value, exec);
-    
+
     fJSUserObject->SetProperty(cfPropName, jsValueObj);
-    
-    if (jsValueObj) jsValueObj->Release();     
+
+    if (jsValueObj) jsValueObj->Release();
     ReleaseCFType(cfPropName);
 }
-        
-JSUserObject* UserObjectImp::GetJSUserObject() const 
-{ 
-       return fJSUserObject; 
+
+JSUserObject* UserObjectImp::GetJSUserObject() const
+{
+    return fJSUserObject;
 }
 
 ValueImp *UserObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
 {
     ValueImp *result = Undefined();
     JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
-    CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : NULL;
+    CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
     if (cfValue) {
         CFTypeID cfType = CFGetTypeID(cfValue);  // toPrimitive
         if (cfValue == GetCFNull()) {
@@ -191,10 +191,10 @@ ValueImp *UserObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
                 result = KJS::String(CFStringToUString(CFURLGetString(absURL)));
                 ReleaseCFType(absURL);
             }
-        }              
+        }
         ReleaseCFType(cfValue);
     }
-    if (jsObjPtr) 
+    if (jsObjPtr)
         jsObjPtr->Release();
     return result;
 }
@@ -202,211 +202,211 @@ ValueImp *UserObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
 
 bool UserObjectImp::toBoolean(ExecState *exec) const
 {
-       bool result = false;
-       JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
-       CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : NULL;
-       if (cfValue)
-       {
-               CFTypeID cfType = CFGetTypeID(cfValue);  // toPrimitive
-               if (cfValue == GetCFNull())
-               {
-                       //
-               }
-               else if (cfType == CFBooleanGetTypeID())
-               {
-                       if (cfValue == kCFBooleanTrue)
-                       {
-                               result = true;
-                       }
-               }
-               else if (cfType == CFStringGetTypeID())
-               {
-                       if (CFStringGetLength((CFStringRef)cfValue))
-                       {
-                               result = true;
-                       }
-               }
-               else if (cfType == CFNumberGetTypeID())
-               {
-                       if (cfValue != kCFNumberNaN)
-                       {
-                               double d;
-                               if (CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d))
-                               {
-                                       if (d != 0)
-                                       {
-                                               result = true;
-                                       }
-                               }
-                       }
-               }
-               else if (cfType == CFArrayGetTypeID())
-               {
-                       if (CFArrayGetCount((CFArrayRef)cfValue))
-                       {
-                               result = true;
-                       }
-               }
-               else if (cfType == CFDictionaryGetTypeID())
-               {
-                       if (CFDictionaryGetCount((CFDictionaryRef)cfValue))
-                       {
-                               result = true;
-                       }
-               }
-               else if (cfType == CFSetGetTypeID())
-               {
-                       if (CFSetGetCount((CFSetRef)cfValue))
-                       {
-                               result = true;
-                       }
-               }
-               else if (cfType == CFURLGetTypeID())
-               {
-                       CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue);
-                       if (absURL)
-                       {
-                               CFStringRef cfStr = CFURLGetString(absURL);
-                               if (cfStr && CFStringGetLength(cfStr))
-                               {
-                                       result = true;
-                               }
-                               ReleaseCFType(absURL);
-                       }
-               }
-       }
-       if (jsObjPtr) jsObjPtr->Release();
-       ReleaseCFType(cfValue);
-       return result;
+    bool result = false;
+    JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
+    CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
+    if (cfValue)
+    {
+        CFTypeID cfType = CFGetTypeID(cfValue);  // toPrimitive
+        if (cfValue == GetCFNull())
+        {
+            //
+        }
+        else if (cfType == CFBooleanGetTypeID())
+        {
+            if (cfValue == kCFBooleanTrue)
+            {
+                result = true;
+            }
+        }
+        else if (cfType == CFStringGetTypeID())
+        {
+            if (CFStringGetLength((CFStringRef)cfValue))
+            {
+                result = true;
+            }
+        }
+        else if (cfType == CFNumberGetTypeID())
+        {
+            if (cfValue != kCFNumberNaN)
+            {
+                double d;
+                if (CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d))
+                {
+                    if (d != 0)
+                    {
+                        result = true;
+                    }
+                }
+            }
+        }
+        else if (cfType == CFArrayGetTypeID())
+        {
+            if (CFArrayGetCount((CFArrayRef)cfValue))
+            {
+                result = true;
+            }
+        }
+        else if (cfType == CFDictionaryGetTypeID())
+        {
+            if (CFDictionaryGetCount((CFDictionaryRef)cfValue))
+            {
+                result = true;
+            }
+        }
+        else if (cfType == CFSetGetTypeID())
+        {
+            if (CFSetGetCount((CFSetRef)cfValue))
+            {
+                result = true;
+            }
+        }
+        else if (cfType == CFURLGetTypeID())
+        {
+            CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue);
+            if (absURL)
+            {
+                CFStringRef cfStr = CFURLGetString(absURL);
+                if (cfStr && CFStringGetLength(cfStr))
+                {
+                    result = true;
+                }
+                ReleaseCFType(absURL);
+            }
+        }
+    }
+    if (jsObjPtr) jsObjPtr->Release();
+    ReleaseCFType(cfValue);
+    return result;
 }
 
 double UserObjectImp::toNumber(ExecState *exec) const
 {
-       double result = 0;
-       JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
-       CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : NULL;
-       if (cfValue)
-       {
-               CFTypeID cfType = CFGetTypeID(cfValue);
-               
-               if (cfValue == GetCFNull())
-               {
-                       //
-               }
-               else if (cfType == CFBooleanGetTypeID())
-               {
-                       if (cfValue == kCFBooleanTrue)
-                       {
-                               result = 1;
-                       }
-               }
-               else if (cfType == CFStringGetTypeID())
-               {
-                       result = CFStringGetDoubleValue((CFStringRef)cfValue);
-               }
-               else if (cfType == CFNumberGetTypeID())
-               {
-                       CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &result);           
-               }
-       }
-       ReleaseCFType(cfValue);
-       if (jsObjPtr) jsObjPtr->Release();
-       return result;
+    double result = 0;
+    JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
+    CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
+    if (cfValue)
+    {
+        CFTypeID cfType = CFGetTypeID(cfValue);
+
+        if (cfValue == GetCFNull())
+        {
+            //
+        }
+        else if (cfType == CFBooleanGetTypeID())
+        {
+            if (cfValue == kCFBooleanTrue)
+            {
+                result = 1;
+            }
+        }
+        else if (cfType == CFStringGetTypeID())
+        {
+            result = CFStringGetDoubleValue((CFStringRef)cfValue);
+        }
+        else if (cfType == CFNumberGetTypeID())
+        {
+            CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &result);
+        }
+    }
+    ReleaseCFType(cfValue);
+    if (jsObjPtr) jsObjPtr->Release();
+    return result;
 }
 
 UString UserObjectImp::toString(ExecState *exec) const
 {
-       UString result;
-       JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
-       CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : NULL;
-       if (cfValue)
-       {
-               CFTypeID cfType = CFGetTypeID(cfValue);
-               if (cfValue == GetCFNull())
-               {
-                       //
-               }
-               else if (cfType == CFBooleanGetTypeID())
-               {
-                       if (cfValue == kCFBooleanTrue)
-                       {
-                               result = "true";
-                       }
-                       else
-                       {
-                               result = "false";
-                       }
-               }
-               else if (cfType == CFStringGetTypeID())
-               {
-                       result = CFStringToUString((CFStringRef)cfValue);
-               }
-               else if (cfType == CFNumberGetTypeID())
-               {
-                       if (cfValue == kCFNumberNaN)
-                       {
-                               result = "Nan";
-                       }
-                       else if (CFNumberCompare(kCFNumberPositiveInfinity, (CFNumberRef)cfValue, NULL) == 0)
-                       {
-                               result = "Infinity";
-                       }
-                       else if (CFNumberCompare(kCFNumberNegativeInfinity, (CFNumberRef)cfValue, NULL) == 0)
-                       {
-                               result = "-Infinity";
-                       }
-                       else
-                       {
-                               CFStringRef cfNumStr = NULL;
-                               if (CFNumberIsFloatType((CFNumberRef)cfValue))
-                               {
-                                       double d = 0;
-                                       CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d);
-                                       cfNumStr = CFStringCreateWithFormat(NULL, NULL, CFSTR("%f"), (float)d);
-                               }
-                               else
-                               {
-                                       int i = 0;
-                                       CFNumberGetValue((CFNumberRef)cfValue, kCFNumberIntType, &i);
-                                       cfNumStr = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d"), (int)i);
-                               }
-                               
-                               if (cfNumStr)
-                               {
-                                       result = CFStringToUString(cfNumStr);
-                                       ReleaseCFType(cfNumStr);
-                               }                               
-                       }
-               }
-               else if (cfType == CFArrayGetTypeID())
-               {
-                       //
-               }
-               else if (cfType == CFDictionaryGetTypeID())
-               {
-                       //
-               }
-               else if (cfType == CFSetGetTypeID())
-               {
-                       //
-               }
-               else if (cfType == CFURLGetTypeID())
-               {
-                       CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue);
-                       if (absURL)
-                       {
-                               CFStringRef cfStr = CFURLGetString(absURL);
-                               if (cfStr)
-                               {
-                                       result = CFStringToUString(cfStr);
-                               }
-                               ReleaseCFType(absURL);
-                       }
-               }               
-       }
-       ReleaseCFType(cfValue);
-       if (jsObjPtr) jsObjPtr->Release();
-       return result;
+    UString result;
+    JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
+    CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
+    if (cfValue)
+    {
+        CFTypeID cfType = CFGetTypeID(cfValue);
+        if (cfValue == GetCFNull())
+        {
+            //
+        }
+        else if (cfType == CFBooleanGetTypeID())
+        {
+            if (cfValue == kCFBooleanTrue)
+            {
+                result = "true";
+            }
+            else
+            {
+                result = "false";
+            }
+        }
+        else if (cfType == CFStringGetTypeID())
+        {
+            result = CFStringToUString((CFStringRef)cfValue);
+        }
+        else if (cfType == CFNumberGetTypeID())
+        {
+            if (cfValue == kCFNumberNaN)
+            {
+                result = "Nan";
+            }
+            else if (CFNumberCompare(kCFNumberPositiveInfinity, (CFNumberRef)cfValue, 0) == 0)
+            {
+                result = "Infinity";
+            }
+            else if (CFNumberCompare(kCFNumberNegativeInfinity, (CFNumberRef)cfValue, 0) == 0)
+            {
+                result = "-Infinity";
+            }
+            else
+            {
+                CFStringRef cfNumStr = 0;
+                if (CFNumberIsFloatType((CFNumberRef)cfValue))
+                {
+                    double d = 0;
+                    CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d);
+                    cfNumStr = CFStringCreateWithFormat(0, 0, CFSTR("%f"), (float)d);
+                }
+                else
+                {
+                    int i = 0;
+                    CFNumberGetValue((CFNumberRef)cfValue, kCFNumberIntType, &i);
+                    cfNumStr = CFStringCreateWithFormat(0, 0, CFSTR("%d"), (int)i);
+                }
+
+                if (cfNumStr)
+                {
+                    result = CFStringToUString(cfNumStr);
+                    ReleaseCFType(cfNumStr);
+                }
+            }
+        }
+        else if (cfType == CFArrayGetTypeID())
+        {
+            //
+        }
+        else if (cfType == CFDictionaryGetTypeID())
+        {
+            //
+        }
+        else if (cfType == CFSetGetTypeID())
+        {
+            //
+        }
+        else if (cfType == CFURLGetTypeID())
+        {
+            CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue);
+            if (absURL)
+            {
+                CFStringRef cfStr = CFURLGetString(absURL);
+                if (cfStr)
+                {
+                    result = CFStringToUString(cfStr);
+                }
+                ReleaseCFType(absURL);
+            }
+        }
+    }
+    ReleaseCFType(cfValue);
+    if (jsObjPtr) jsObjPtr->Release();
+    return result;
 }
 
 void UserObjectImp::mark()
index 377cfcc..06220e7 100644 (file)
@@ -1,10 +1,8 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
-
-#ifndef __UserObjectImp_h
-#define __UserObjectImp_h
+#ifndef UserObjectImp_h
+#define UserObjectImp_h
 
 /*
-       UserObjectImp.h
+    UserObjectImp.h
 */
 
 #include "JSUtils.h"
@@ -16,26 +14,26 @@ class UserObjectImp : public ObjectImp
 public:
     UserObjectImp(JSUserObject* userObject);
     virtual ~UserObjectImp();
-    
+
     virtual const ClassInfo *classInfo() const;
     static const ClassInfo info;
-    
+
     virtual bool implementsCall() const;
-    
+
     virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);
-    
+
     virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
-    
+
     ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
     virtual bool toBoolean(ExecState *exec) const;
     virtual double toNumber(ExecState *exec) const;
     virtual UString toString(ExecState *exec) const;
-    
+
     virtual void mark();
-    
-    JSUserObjectGetJSUserObject() const;
+
+    JSUserObject *GetJSUserObject() const;
 protected:
     UserObjectImp();
 private:
@@ -44,5 +42,4 @@ private:
     JSUserObject* fJSUserObject;
 };
 
-
 #endif