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

List:       kde-commits
Subject:    branches/KDE/4.0/kdelibs/khtml/ecma
From:       Harri Porten <porten () kde ! org>
Date:       2008-01-18 5:59:51
Message-ID: 1200635991.528513.21799.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 762890 by porten:

Make DOMException an object type of its own. Still todo:
harmonize exception objects and properties.


 M  +7 -0      kjs_binding.cpp  
 M  +12 -53    kjs_dom.cpp  
 M  +4 -6      kjs_dom.h  


--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_binding.cpp #762889:762890
@@ -319,6 +319,9 @@
   const char* const* nameTable;
   int nameTableSize;
 
+  // ### clean up after harmonizing exception objects. maybe use a
+  // ### single class? Some human readable message would be nice, too.
+
   if (code >= DOM::RangeException::_EXCEPTION_OFFSET && code <= \
DOM::RangeException::_EXCEPTION_MAX) {  type = "DOM Range";
     code -= DOM::RangeException::_EXCEPTION_OFFSET;
@@ -341,6 +344,10 @@
   } else {
     nameTable = exceptionNames;
     nameTableSize = sizeof(exceptionNames) / sizeof(exceptionNames[0]);
+    errorObject = new JSDOMException(exec);
+    exec->setException(errorObject);
+    errorObject->put(exec, exec->propertyNames().name, jsString(UString(type) + " \
Exception")); +    errorObject->put(exec, exec->propertyNames().message, \
jsString(nameTable[code]));  }
 
   const char* name = (code >= 0 && code < nameTableSize) ? nameTable[code] : 0;
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_dom.cpp #762889:762890
@@ -1702,10 +1702,8 @@
 IMPLEMENT_PSEUDO_CONSTRUCTOR_WITH_PARENT(NodeConstructor, "NodeConstructor", \
DOMNodeProto, DOMNodeConstants)  // \
-------------------------------------------------------------------------  
-const ClassInfo DOMExceptionConstructor::info = { "DOMExceptionConstructor", 0, 0, 0 \
                };
-
-/* Source for DOMExceptionConstructorTable.
-@begin DOMExceptionConstructorTable 15
+/* Source for DOMExceptionProtoTable.
+@begin DOMExceptionProtoTable 15
   INDEX_SIZE_ERR		DOM::DOMException::INDEX_SIZE_ERR		DontDelete|ReadOnly
   DOMSTRING_SIZE_ERR		DOM::DOMException::DOMSTRING_SIZE_ERR	DontDelete|ReadOnly
   HIERARCHY_REQUEST_ERR		DOM::DOMException::HIERARCHY_REQUEST_ERR	DontDelete|ReadOnly
 @@ -1726,62 +1724,23 @@
 @end
 */
 
-DOMExceptionConstructor::DOMExceptionConstructor(ExecState* exec)
-  : DOMObject(exec->lexicalInterpreter()->builtinObjectPrototype())
-{
-}
+DEFINE_CONSTANT_TABLE(DOMExceptionProto)
+IMPLEMENT_CONSTANT_TABLE(DOMExceptionProto, "DOMException")
 
-bool DOMExceptionConstructor::getOwnPropertySlot(ExecState *exec, const Identifier& \
                propertyName, PropertySlot& slot)
-{
-  return getStaticValueSlot<DOMExceptionConstructor, DOMObject>(exec, \
                &DOMExceptionConstructorTable, this, propertyName, slot);
-}
+IMPLEMENT_PSEUDO_CONSTRUCTOR_WITH_PARENT(DOMExceptionPseudoCtor,
+                             "DOMException",
+                             DOMExceptionProto, DOMExceptionProto)
 
-JSValue* DOMExceptionConstructor::getValueProperty(ExecState *, int token) const
+JSDOMException::JSDOMException(ExecState* exec)
+  : DOMObject(DOMExceptionProto::self(exec))
 {
-  // We use the token as the value to return directly
-  return jsNumber((unsigned int)token);
-#if 0
-  switch (token) {
-  case INDEX_SIZE_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::INDEX_SIZE_ERR);
-  case DOMSTRING_SIZE_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::DOMSTRING_SIZE_ERR);
-  case HIERARCHY_REQUEST_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::HIERARCHY_REQUEST_ERR);
-  case WRONG_DOCUMENT_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::WRONG_DOCUMENT_ERR);
-  case INVALID_CHARACTER_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::INVALID_CHARACTER_ERR);
-  case NO_DATA_ALLOWED_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::NO_DATA_ALLOWED_ERR);
-  case NO_MODIFICATION_ALLOWED_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR);
-  case NOT_FOUND_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::NOT_FOUND_ERR);
-  case NOT_SUPPORTED_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::NOT_SUPPORTED_ERR);
-  case INUSE_ATTRIBUTE_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::INUSE_ATTRIBUTE_ERR);
-  case INVALID_STATE_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::INVALID_STATE_ERR);
-  case SYNTAX_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::SYNTAX_ERR);
-  case INVALID_MODIFICATION_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::INVALID_MODIFICATION_ERR);
-  case NAMESPACE_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::NAMESPACE_ERR);
-  case INVALID_ACCESS_ERR:
-    return jsNumber((unsigned int)DOM::DOMException::INVALID_ACCESS_ERR);
-  default:
-    kDebug(6070) << "WARNING: DOMExceptionConstructor::getValueProperty unhandled \
                token " << token;
-    return jsNull();
-  }
-#endif
 }
 
+const ClassInfo JSDOMException::info = { "DOMException", 0, 0, 0 };
+
 JSObject *KJS::getDOMExceptionConstructor(ExecState *exec)
 {
-  return cacheGlobalObject<DOMExceptionConstructor>(exec, \
"[[DOMException.constructor]]"); +  return DOMExceptionPseudoCtor::self(exec);
 }
 
 // -------------------------------------------------------------------------
--- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_dom.h #762889:762890
@@ -261,13 +261,11 @@
     enum { PublicId, SystemId, NotationName };
   };
 
-  // Constructor for DOMException - constructor stuff not implemented yet
-  class DOMExceptionConstructor : public DOMObject {
+  DEFINE_PSEUDO_CONSTRUCTOR(DOMExceptionPseudoCtor);
+
+  class JSDOMException : public DOMObject {
   public:
-    DOMExceptionConstructor(ExecState *);
-    virtual bool getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, \
                PropertySlot& slot);
-    JSValue* getValueProperty(ExecState *exec, int token) const;
-    // no put - all read-only
+    JSDOMException(ExecState* exec);
     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