#include <JavaScriptCore/JavaScript.h>
#include <CommonsJavaScript/PrivateObject.h>
+#include <wrt_plugin_export.h>
namespace WrtPlugins {
namespace W3C {
*/
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.
static JSClassRef m_jsClassRef;
+ /**
+ * Global context acquired by acquireGlobalContext() function.
+ */
+ static JSContextRef m_globalContext;
+
// getters for properties
static JSValueRef getAuthor(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
+
};
}
}