A few more API methods implemented
authorLars Knoll <lars.knoll@digia.com>
Wed, 6 Mar 2013 21:21:26 +0000 (22:21 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Wed, 6 Mar 2013 21:37:56 +0000 (22:37 +0100)
Change-Id: I4168ad5bb934a74e6957969417fdcf491a7374a1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/v4/qv4v8.cpp
src/v4/qv4v8.h

index 7fc6d89..4dd32c2 100644 (file)
@@ -1139,7 +1139,10 @@ Local<Object> AccessorInfo::Holder() const
 
 Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback, Handle<Value> data)
 {
-    Q_UNIMPLEMENTED();
+    FunctionTemplate *ft = new FunctionTemplate;
+    ft->m_callback = callback;
+    ft->m_data = Persistent<Value>::New(data);
+    return Local<FunctionTemplate>::New(Handle<FunctionTemplate>(ft));
 }
 
 Local<Function> FunctionTemplate::GetFunction()
@@ -1149,18 +1152,23 @@ Local<Function> FunctionTemplate::GetFunction()
 
 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate()
 {
-    Q_UNIMPLEMENTED();
+    if (!*m_instanceTemplate)
+        m_instanceTemplate = ObjectTemplate::New();
+    return m_instanceTemplate;
 }
 
 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate()
 {
-    Q_UNIMPLEMENTED();
+    if (!*m_prototypeTemplate)
+        m_prototypeTemplate = ObjectTemplate::New();
+    return m_prototypeTemplate;
 }
 
 
 Local<ObjectTemplate> ObjectTemplate::New()
 {
-    Q_UNIMPLEMENTED();
+    ObjectTemplate *ot = new ObjectTemplate;
+    return Local<ObjectTemplate>::New(Handle<ObjectTemplate>(ot));
 }
 
 Local<Object> ObjectTemplate::NewInstance()
index 7c3d6b1..b9356d6 100644 (file)
@@ -574,9 +574,10 @@ class V8EXPORT HandleScope {
 /**
  * The superclass of values and API object templates.
  */
-class V8EXPORT Data {
+class V8EXPORT Data  : public QSharedData {
 };
 
+DEFINE_REFCOUNTED_HANDLE_OPERATIONS(Data)
 
 /**
  * The origin, within a file, of a script.
@@ -1884,6 +1885,11 @@ class V8EXPORT FunctionTemplate : public Template {
    */
   Local<ObjectTemplate> PrototypeTemplate();
 
+private:
+  InvocationCallback m_callback;
+  Persistent<Value> m_data;
+  Local<ObjectTemplate> m_instanceTemplate;
+  Local<ObjectTemplate> m_prototypeTemplate;
 };