Expose the ProfileNode sorting functions on JavaScriptProfileNode.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2008 13:58:27 +0000 (13:58 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2008 13:58:27 +0000 (13:58 +0000)
Reviewed by Kevin McCullough.

* page/JavaScriptProfileNode.cpp:
(WebCore::sortTotalTimeDescending): Call ProfileNode.
(WebCore::sortTotalTimeAscending): Ditto.
(WebCore::sortSelfTimeDescending): Ditto.
(WebCore::sortSelfTimeAscending): Ditto.
(WebCore::sortCallsDescending): Ditto.
(WebCore::sortCallsAscending): Ditto.
(WebCore::ProfileNodeClass): Add static static functions.

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

WebCore/ChangeLog
WebCore/page/JavaScriptProfileNode.cpp

index 3e66cc1..2de782f 100644 (file)
@@ -1,5 +1,20 @@
 2008-05-19  Timothy Hatcher  <timothy@apple.com>
 
+        Expose the ProfileNode sorting functions on JavaScriptProfileNode.
+
+        Reviewed by Kevin McCullough.
+
+        * page/JavaScriptProfileNode.cpp:
+        (WebCore::sortTotalTimeDescending): Call ProfileNode.
+        (WebCore::sortTotalTimeAscending): Ditto.
+        (WebCore::sortSelfTimeDescending): Ditto.
+        (WebCore::sortSelfTimeAscending): Ditto.
+        (WebCore::sortCallsDescending): Ditto.
+        (WebCore::sortCallsAscending): Ditto.
+        (WebCore::ProfileNodeClass): Add static static functions.
+
+2008-05-19  Timothy Hatcher  <timothy@apple.com>
+
         * page/InspectorController.cpp: Change the include for
         JavaScriptProfile.h to sue double quotes instead of backets.
 
index 0c3fc3e..4a1be73 100644 (file)
@@ -163,6 +163,72 @@ static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSString
     return result;
 }
 
+static JSValueRef sortTotalTimeDescending(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    profileNode->sortTotalTimeDescending();
+
+    return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef sortTotalTimeAscending(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    profileNode->sortTotalTimeAscending();
+
+    return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef sortSelfTimeDescending(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    profileNode->sortSelfTimeDescending();
+
+    return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef sortSelfTimeAscending(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    profileNode->sortSelfTimeAscending();
+
+    return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef sortCallsDescending(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    profileNode->sortCallsDescending();
+
+    return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef sortCallsAscending(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    profileNode->sortCallsAscending();
+
+    return JSValueMakeUndefined(ctx);
+}
+
 static void finalize(JSObjectRef object)
 {
     ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(object));
@@ -183,8 +249,18 @@ JSClassRef ProfileNodeClass()
         { 0, 0, 0, 0 }
     };
 
+    static JSStaticFunction staticFunctions[] = {
+        { "sortTotalTimeDescending", sortTotalTimeDescending, kJSPropertyAttributeNone },
+        { "sortTotalTimeAscending", sortTotalTimeAscending, kJSPropertyAttributeNone },
+        { "sortSelfTimeDescending", sortSelfTimeDescending, kJSPropertyAttributeNone },
+        { "sortSelfTimeAscending", sortSelfTimeAscending, kJSPropertyAttributeNone },
+        { "sortCallsDescending", sortCallsDescending, kJSPropertyAttributeNone },
+        { "sortCallsAscending", sortCallsAscending, kJSPropertyAttributeNone },
+        { 0, 0, 0 }
+    };
+
     static JSClassDefinition classDefinition = {
-        0, kJSClassAttributeNone, "ProfileNode", 0, staticValues, 0,
+        0, kJSClassAttributeNone, "ProfileNode", 0, staticValues, staticFunctions,
         0, finalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
     };