Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / standards / W3C / Widget / JSWidget.h
index 0ae68f5..3be203a 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/PrivateObject.h>
+#include <wrt_plugin_export.h>
 
 namespace WrtPlugins {
 namespace W3C {
@@ -44,6 +45,24 @@ class JSWidget
      */
     static const JSClassDefinition* getClassInfo();
 
+    static JSObjectRef callAsConstructor(JSContextRef context,
+                                         JSObjectRef constructor,
+                                         size_t argumentCount,
+                                         const JSValueRef arguments[],
+                                         JSValueRef* exception);
+
+    /**
+     * This function will acquire global context which is used later to
+     * keep JSValueProtect/Unprotect functionality working.
+     * This is workaround for JSCore semantic: when an object is created with
+     * JSObjectMakeConstructor a context passed to createCallback function
+     * is different (shorter lifecycle) than global context, so JSValueUnprotect
+     * called in finalize may fail because of invalid context.
+     */
+    static void acquireGlobalContext(java_script_context_t global_context,
+            js_object_instance_t iframe,
+            js_object_instance_t object);
+
   private:
     /**
      * The callback invoked when an object is first created.
@@ -68,6 +87,11 @@ class JSWidget
 
     static JSClassRef m_jsClassRef;
 
+    /**
+     * Global context acquired by acquireGlobalContext() function.
+     */
+    static JSContextRef m_globalContext;
+
     // getters for properties
     static JSValueRef getAuthor(JSContextRef context,
                                 JSObjectRef object,
@@ -124,6 +148,7 @@ class JSWidget
                             JSStringRef propertyName,
                             JSValueRef value,
                             JSValueRef* exception);
+
 };
 }
 }