branches/work/kdelibs-js/khtml/ecma

Maksim Orlovich mo85 at cornell.edu
Fri Dec 16 21:06:27 CET 2005


>
> I'd love to add it. I only see KHTML changes in that bug, not KJS.


maksim at maksim4139up:~$ svn diff -r259630:259631
svn://anonsvn.kde.org/home/kde

Index: trunk/kdelibs/kjs/function.h
===================================================================
--- trunk/kdelibs/kjs/function.h        (revision 259630)
+++ trunk/kdelibs/kjs/function.h        (revision 259631)
@@ -32,8 +32,36 @@
   class Parameter;

   /**
-   * @short Implementation class for internal Functions.
+   * Base class for all function objects.
+   * It implements the hasInstance method (for instanceof, which only
applies to function objects)
+   * and allows to give the function a name, used in toString().
+   *
+   * Constructors and prototypes of internal objects (implemented in C++)
directly inherit from this.
+   * FunctionImp also does, for functions implemented in JS.
    */
+  class InternalFunctionImp : public ObjectImp {
+  public:
+    /**
+     * Constructor. For C++-implemented functions, @p funcProto is usually
+     *
static_cast<FunctionPrototypeImp*>(exec->interpreter()->builtinFunctionPrototype().imp())
+     */
+    InternalFunctionImp(FunctionPrototypeImp *funcProto);
+    bool implementsHasInstance() const;
+    Boolean hasInstance(ExecState *exec, const Value &value);
+
+    virtual const ClassInfo *classInfo() const { return &info; }
+    static const ClassInfo info;
+    Identifier name() const { return ident; }
+    /// You might want to use the helper function
ObjectImp::setFunctionName for this
+    void setName(Identifier _ident) { ident = _ident; }
+
+  protected:
+    Identifier ident;
+  };
+
+  /**
+   * @short Implementation class for functions implemented in JS.
+   */
   class FunctionImp : public InternalFunctionImp {
     friend class Function;
     friend class ActivationImp;
@@ -121,7 +149,7 @@

     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
-
+
     virtual void mark();

   private:
Index: trunk/kdelibs/kjs/function_object.h
===================================================================
--- trunk/kdelibs/kjs/function_object.h (revision 259630)
+++ trunk/kdelibs/kjs/function_object.h (revision 259631)
@@ -29,10 +29,8 @@
 namespace KJS {

   /**
-   * @internal
-   *
    * The initial value of Function.prototype (and thus all objects created
-   * with the Function constructor
+   * with the Function constructor)
    */
   class FunctionPrototypeImp : public InternalFunctionImp {
   public:
Index: trunk/kdelibs/kjs/internal.h
===================================================================
--- trunk/kdelibs/kjs/internal.h        (revision 259630)
+++ trunk/kdelibs/kjs/internal.h        (revision 259631)
@@ -130,7 +130,7 @@
     static ValueImp *zero() { return SimpleNumber::make(0); }
     static ValueImp *one() { return SimpleNumber::make(1); }
     static ValueImp *two() { return SimpleNumber::make(2); }
-
+
     double value() const { return val; }

     Type type() const { return NumberType; }
@@ -305,7 +305,7 @@

     void addSourceCode(SourceCode *code);
     void removeSourceCode(SourceCode *code);
-
+
     void setContext(ContextImp *c) { _context = c; }

   private:
@@ -358,7 +358,7 @@
     // Chained list of interpreters (ring) - for collector
     static InterpreterImp* s_hook;
     InterpreterImp *next, *prev;
-
+
     ContextImp *_context;

     int recursion;
@@ -381,23 +381,6 @@
     bool isAborted;
   };

-
-
-  class InternalFunctionImp : public ObjectImp {
-  public:
-    InternalFunctionImp(FunctionPrototypeImp *funcProto);
-    bool implementsHasInstance() const;
-    Boolean hasInstance(ExecState *exec, const Value &value);
-
-    virtual const ClassInfo *classInfo() const { return &info; }
-    static const ClassInfo info;
-    Identifier name() const { return ident; }
-    void setName(Identifier _ident) { ident = _ident; }
-
-  protected:
-    Identifier ident;
-  };
-
   // helper function for toInteger, toInt32, toUInt32 and toUInt16
   double roundValue(ExecState *exec, const Value &v);

Index: trunk/kdelibs/kjs/object_object.h
===================================================================
--- trunk/kdelibs/kjs/object_object.h   (revision 259630)
+++ trunk/kdelibs/kjs/object_object.h   (revision 259631)
@@ -23,6 +23,7 @@
 #define _OBJECT_OBJECT_H_

 #include "internal.h"
+#include "function.h"

 namespace KJS {

Index: trunk/kdelibs/kjs/object.h
===================================================================
--- trunk/kdelibs/kjs/object.h  (revision 259630)
+++ trunk/kdelibs/kjs/object.h  (revision 259631)
@@ -590,7 +590,10 @@
     void putDirect(const Identifier &propertyName, ValueImp *value, int
attr = 0);
     void putDirect(const Identifier &propertyName, int value, int attr = 0);

-    // Used internally
+    /**
+     * Sets the name of the function, if this is an InternalFunctionImp
object.
+     * (calling InternalFunctionImp::setName)
+     */
     void setFunctionName(const Identifier &propertyName);

   protected:




More information about the Khtml-devel mailing list