[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kjs
From:       Maks Orlovich <maksim () kde ! org>
Date:       2010-09-11 19:12:10
Message-ID: 20100911191210.E2009AC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1174274 by orlovich:

Merged revision:r1174273 | orlovich | 2010-09-11 15:09:21 -0400 (Sat, 11 Sep 2010) | 4 lines

Add a way of cloning value-like types, so I can implement HTML5 cloning algorithm
w/o KDE_EXPORTING all the wrapper types.

 M  +7 -0      bool_object.cpp  
 M  +2 -0      bool_object.h  
 M  +7 -0      date_object.cpp  
 M  +2 -0      date_object.h  
 M  +8 -0      number_object.cpp  
 M  +2 -0      number_object.h  
 M  +5 -0      object.cpp  
 M  +7 -0      regexp_object.cpp  
 M  +1 -0      regexp_object.h  
 M  +5 -0      string_object.cpp  
 M  +1 -0      string_object.h  


--- trunk/KDE/kdelibs/kjs/bool_object.cpp #1174273:1174274
@@ -37,6 +37,13 @@
 {
 }
 
+JSObject* BooleanInstance::valueClone(Interpreter* targetCtx) const
+{
+    BooleanInstance* copy = new BooleanInstance(targetCtx->builtinBooleanPrototype());
+    copy->setInternalValue(internalValue());
+    return copy;
+}
+
 // ------------------------------ BooleanPrototype --------------------------
 
 // ECMA 15.6.4
--- trunk/KDE/kdelibs/kjs/bool_object.h #1174273:1174274
@@ -32,6 +32,8 @@
   public:
     BooleanInstance(JSObject *proto);
 
+    virtual JSObject* valueClone(Interpreter* targetCtx) const;
+
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
   };
--- trunk/KDE/kdelibs/kjs/date_object.cpp #1174273:1174274
@@ -398,6 +398,13 @@
 {
 }
 
+JSObject* DateInstance::valueClone(Interpreter* targetCtx) const
+{
+    DateInstance* copy = new DateInstance(targetCtx->builtinDatePrototype());
+    copy->setInternalValue(internalValue());
+    return copy;
+}
+
 bool DateInstance::getTime(tm &t, int &offset) const
 {
     double milli = internalValue()->getNumber();
--- trunk/KDE/kdelibs/kjs/date_object.h #1174273:1174274
@@ -42,6 +42,8 @@
 
         virtual const ClassInfo *classInfo() const { return &info; }
         static const ClassInfo info;
+
+        virtual JSObject* valueClone(Interpreter* targetCtx) const;
     };
 
     /**
--- trunk/KDE/kdelibs/kjs/number_object.cpp #1174273:1174274
@@ -50,6 +50,14 @@
     : JSWrapperObject(proto)
 {
 }
+
+JSObject* NumberInstance::valueClone(Interpreter* targetCtx) const
+{
+    NumberInstance* copy = new NumberInstance(targetCtx->builtinNumberPrototype());
+    copy->setInternalValue(internalValue());
+    return copy;
+}
+
 // ------------------------------ NumberPrototype ---------------------------
 
 // ECMA 15.7.4
--- trunk/KDE/kdelibs/kjs/number_object.h #1174273:1174274
@@ -33,6 +33,8 @@
 
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
+
+    virtual JSObject* valueClone(Interpreter* targetCtx) const;
   };
 
   /**
--- trunk/KDE/kdelibs/kjs/object.cpp #1174273:1174274
@@ -412,6 +412,11 @@
   return construct(exec, args);
 }
 
+JSObject* JSObject::valueClone(Interpreter* /*targetCtx*/) const
+{
+    return 0;
+}
+
 bool JSObject::isFunctionType() const
 {
   return implementsCall();
--- trunk/KDE/kdelibs/kjs/regexp_object.cpp #1174273:1174274
@@ -186,6 +186,13 @@
   putDirect(exec->propertyNames().lastIndex, jsNumber(0), DontDelete | DontEnum);
 }
 
+JSObject* RegExpImp::valueClone(Interpreter* targetCtx) const
+{
+    RegExpImp* copy = new RegExpImp(static_cast<RegExpPrototype*>(targetCtx->builtinRegExpPrototype()));
+    copy->setRegExp(targetCtx->globalExec(), new RegExp(reg->pattern(), reg->flags()));
+    return copy;
+}
+
 // ------------------------------ RegExpObjectImp ------------------------------
 
 const ClassInfo RegExpObjectImp::info = {"Function", &InternalFunctionImp::info, &RegExpTable, 0};
--- trunk/KDE/kdelibs/kjs/regexp_object.h #1174273:1174274
@@ -59,6 +59,7 @@
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
 
+    virtual JSObject* valueClone(Interpreter* targetCtx) const;
   private:
     RegExp *reg;
   };
--- trunk/KDE/kdelibs/kjs/string_object.cpp #1174273:1174274
@@ -136,6 +136,11 @@
     return JSObject::toString(exec);
 }
 
+JSObject* StringInstance::valueClone(Interpreter* targetCtx) const
+{
+    return new StringInstance(targetCtx->builtinStringPrototype(), internalValue());
+}
+
 // ------------------------------ StringPrototype ---------------------------
 const ClassInfo StringPrototype::info = {"String", &StringInstance::info, &stringTable, 0};
 /* Source for string_object.lut.h
--- trunk/KDE/kdelibs/kjs/string_object.h #1174273:1174274
@@ -44,6 +44,7 @@
     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
 
     virtual UString toString(ExecState *exec) const;
+    virtual JSObject* valueClone(Interpreter* targetCtx) const;    
 
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic