]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - API/JSCallbackConstructor.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / API / JSCallbackConstructor.h
index fc45cb5e3be905f42acceeafba93cd5eba60a617..f178936e00cb0f2522a2f8d0208836a816f654cd 100644 (file)
@@ -1,6 +1,5 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
 /*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 #define JSCallbackConstructor_h
 
 #include "JSObjectRef.h"
-#include <kjs/object.h>
+#include "runtime/JSDestructibleObject.h"
 
-namespace KJS {
+namespace JSC {
 
-class JSCallbackConstructor : public JSObject
-{
+class JSCallbackConstructor : public JSDestructibleObject {
 public:
-    JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback);
-    virtual ~JSCallbackConstructor();
-    
-    virtual bool implementsHasInstance() const;
-    
-    virtual bool implementsConstruct() const;
-    virtual JSObject* construct(ExecState*, const List &args);
-    
-    virtual const ClassInfo *classInfo() const { return &info; }
-    static const ClassInfo info;
+    typedef JSDestructibleObject Base;
+    static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance;
+
+    static JSCallbackConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSClassRef classRef, JSObjectCallAsConstructorCallback callback) 
+    {
+        JSCallbackConstructor* constructor = new (NotNull, allocateCell<JSCallbackConstructor>(*exec->heap())) JSCallbackConstructor(globalObject, structure, classRef, callback);
+        constructor->finishCreation(globalObject, classRef);
+        return constructor;
+    }
     
+    ~JSCallbackConstructor();
+    static void destroy(JSCell*);
+    JSClassRef classRef() const { return m_class; }
+    JSObjectCallAsConstructorCallback callback() const { return m_callback; }
+    DECLARE_INFO;
+
+    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto) 
+    {
+        return Structure::create(vm, globalObject, proto, TypeInfo(ObjectType, StructureFlags), info());
+    }
+
+protected:
+    JSCallbackConstructor(JSGlobalObject*, Structure*, JSClassRef, JSObjectCallAsConstructorCallback);
+    void finishCreation(JSGlobalObject*, JSClassRef);
+
 private:
-    JSCallbackConstructor(); // prevent default construction
-    JSCallbackConstructor(const JSCallbackConstructor&);
+    friend struct APICallbackFunction;
+
+    static ConstructType getConstructData(JSCell*, ConstructData&);
+
+    JSObjectCallAsConstructorCallback constructCallback() { return m_callback; }
 
     JSClassRef m_class;
     JSObjectCallAsConstructorCallback m_callback;
 };
 
-} // namespace KJS
+} // namespace JSC
 
 #endif // JSCallbackConstructor_h