From 0486ab5b0ccd5f0970ff85fd4a791c737dd637aa Mon Sep 17 00:00:00 2001 From: portix Date: Tue, 4 Dec 2012 13:12:08 +0100 Subject: Create constructor for objects derived from gobject, allows to use 'instanceof' for gobjects --- src/scripts.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/scripts.c') diff --git a/src/scripts.c b/src/scripts.c index e379ad92..5a6242b2 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -2545,12 +2545,14 @@ create_global_object() /* Default gobject class */ cd = kJSClassDefinitionEmpty; + cd.className = "GObject"; cd.staticFunctions = default_functions; cd.getProperty = get_property; cd.setProperty = set_property; - m_default_class = JSClassCreate(&cd); + create_constructor(m_global_context, "GObject", m_webview_class, NULL, NULL); + /* Webview */ cd.className = "WebKitWebView"; cd.staticFunctions = wv_functions; @@ -2558,19 +2560,26 @@ create_global_object() cd.parentClass = m_default_class; m_webview_class = JSClassCreate(&cd); + create_constructor(m_global_context, "WebKitWebView", m_webview_class, NULL, NULL); + /* Frame */ - cd.className = NULL; + cd.className = "WebKitWebFrame"; cd.staticFunctions = frame_functions; cd.staticValues = frame_values; cd.parentClass = m_default_class; m_frame_class = JSClassCreate(&cd); + create_constructor(m_global_context, "WebKitWebFrame", m_frame_class, NULL, NULL); + /* SoupMessage */ + cd.className = "SoupMessage"; cd.staticFunctions = default_functions; cd.staticValues = message_values; cd.parentClass = m_default_class; m_message_class = JSClassCreate(&cd); + create_constructor(m_global_context, "SoupMessage", m_frame_class, NULL, NULL); + static JSStaticValue gui_values[] = { { "window", gui_get_window, NULL, kJSDefaultAttributes }, { "mainBox", gui_get_main_box, NULL, kJSDefaultAttributes }, @@ -2599,6 +2608,8 @@ create_global_object() cd.parentClass = m_default_class; m_download_class = JSClassCreate(&cd); + create_constructor(m_global_context, "Download", m_download_class, download_constructor_cb, NULL); + JSStaticFunction scratchpad_functions[] = { { "show", sp_show, kJSDefaultAttributes }, { "hide", sp_hide, kJSDefaultAttributes }, @@ -2615,8 +2626,6 @@ create_global_object() JSObjectRef o = make_object_for_class(m_global_context, class, G_OBJECT(scratchpad_get()), true); js_set_property(m_global_context, global_object, "scratchpad", o, kJSDefaultAttributes, NULL); - create_constructor(m_global_context, "Download", m_download_class, download_constructor_cb, NULL); - create_constructor(m_global_context, "WebKitWebView", m_webview_class, NULL, NULL); }/*}}}*/ /*}}}*/ -- cgit v1.2.3