#include <LocalStorage/LocalStorageMgr.h>
#include <Commons/WrtAccess/WrtAccess.h>
+// temporary
+extern "C" JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx);
+
#define CATCH_EXCEPTION_NO_MODIFABLE \
Catch(Commons::LocalStorageValueNoModifableException) { \
LogError("The item is read only"); \
JSClassRef JSWidget::m_jsClassRef = JSClassCreate(JSWidget::getClassInfo());
-JSContextRef JSWidget::m_globalContext = NULL;
-
void JSWidget::initialize(JSContextRef context,
JSObjectRef object)
{
- LogDebug("entered. Context : " << context << ", Object: " << object);
+ JSGlobalContextRef g_context = JSContextGetGlobalContext(context);
+
+ LogDebug("entered. Context : " << context << "(global:" << g_context << "), Object: " << object);
+
+ if (context != g_context)
+ {
+ context = g_context;
+ }
JSWidgetPrivateObject* priv =
static_cast<JSWidgetPrivateObject*>(JSObjectGetPrivate(object));
}
}
-void JSWidget::acquireGlobalContext(java_script_context_t global_context,
- js_object_instance_t /*iframe*/,
- js_object_instance_t /*object*/)
-{
- if (!m_globalContext) {
- m_globalContext = static_cast<JSContextRef>(global_context);
- LogInfo("Global context acquired.");
- } else {
- LogInfo("Global context already set.");
- }
-}
-
JSValueRef JSWidget::getAuthor(JSContextRef context,
JSObjectRef object,
JSStringRef /*propertyName*/,
JSValueRef* /*exception*/)
{
LogDebug("widget constructor");
- if (!m_globalContext) {
- LogError("Global context not set. Creating 'widget' object with "
- "local context!");
- return JSObjectMake(context, JSWidget::getClassRef(), NULL);
- }
- return JSObjectMake(m_globalContext, JSWidget::getClassRef(), NULL);
+ return JSObjectMake(context, JSWidget::getClassRef(), NULL);
}
#undef CATCH_EXCEPTION_NO_MODIFABLE