1/* 2 * This file is part of the WebKit open source project. 3 * This file has been generated by generate-bindings.pl. DO NOT MODIFY! 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21#include "config.h" 22#include "WebKitDOMattribute.h" 23 24#include "CSSImportRule.h" 25#include "DOMObjectCache.h" 26#include "Document.h" 27#include "ExceptionCode.h" 28#include "JSMainThreadExecState.h" 29#include "WebKitDOMPrivate.h" 30#include "WebKitDOMattributePrivate.h" 31#include "gobject/ConvertToUTF8String.h" 32#include <wtf/GetPtr.h> 33#include <wtf/RefPtr.h> 34 35#define WEBKIT_DOM_ATTRIBUTE_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_DOM_TYPE_ATTRIBUTE, WebKitDOMattributePrivate) 36 37typedef struct _WebKitDOMattributePrivate { 38 RefPtr<WebCore::attribute> coreObject; 39} WebKitDOMattributePrivate; 40 41namespace WebKit { 42 43WebKitDOMattribute* kit(WebCore::attribute* obj) 44{ 45 if (!obj) 46 return 0; 47 48 if (gpointer ret = DOMObjectCache::get(obj)) 49 return WEBKIT_DOM_ATTRIBUTE(ret); 50 51 return wrapattribute(obj); 52} 53 54WebCore::attribute* core(WebKitDOMattribute* request) 55{ 56 return request ? static_cast<WebCore::attribute*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0; 57} 58 59WebKitDOMattribute* wrapattribute(WebCore::attribute* coreObject) 60{ 61 ASSERT(coreObject); 62 return WEBKIT_DOM_ATTRIBUTE(g_object_new(WEBKIT_DOM_TYPE_ATTRIBUTE, "core-object", coreObject, nullptr)); 63} 64 65} // namespace WebKit 66 67G_DEFINE_TYPE(WebKitDOMattribute, webkit_dom_attribute, WEBKIT_DOM_TYPE_OBJECT) 68 69enum { 70 PROP_0, 71 PROP_READONLY, 72}; 73 74static void webkit_dom_attribute_finalize(GObject* object) 75{ 76 WebKitDOMattributePrivate* priv = WEBKIT_DOM_ATTRIBUTE_GET_PRIVATE(object); 77 78 WebKit::DOMObjectCache::forget(priv->coreObject.get()); 79 80 priv->~WebKitDOMattributePrivate(); 81 G_OBJECT_CLASS(webkit_dom_attribute_parent_class)->finalize(object); 82} 83 84static void webkit_dom_test_exception_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) 85{ 86 WebKitDOMTestException* self = WEBKIT_DOM_TEST_EXCEPTION(object); 87 88 switch (propertyId) { 89 case PROP_NAME: 90 g_value_take_string(value, webkit_dom_test_exception_get_name(self)); 91 break; 92 default: 93 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); 94 break; 95 } 96} 97static void webkit_dom_attribute_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) 98{ 99 WebKitDOMattribute* self = WEBKIT_DOM_ATTRIBUTE(object); 100 101 switch (propertyId) { 102 case PROP_READONLY: 103 g_value_take_string(value, webkit_dom_attribute_get_readonly(self)); 104 break; 105 default: 106 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); 107 break; 108 } 109} 110 111static GObject* webkit_dom_attribute_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties) 112{ 113 GObject* object = G_OBJECT_CLASS(webkit_dom_attribute_parent_class)->constructor(type, constructPropertiesCount, constructProperties); 114 115 WebKitDOMattributePrivate* priv = WEBKIT_DOM_ATTRIBUTE_GET_PRIVATE(object); 116 priv->coreObject = static_cast<WebCore::attribute*>(WEBKIT_DOM_OBJECT(object)->coreObject); 117 WebKit::DOMObjectCache::put(priv->coreObject.get(), object); 118 119 return object; 120} 121 122static void webkit_dom_attribute_class_init(WebKitDOMattributeClass* requestClass) 123{ 124 GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); 125 g_type_class_add_private(gobjectClass, sizeof(WebKitDOMattributePrivate)); 126 gobjectClass->constructor = webkit_dom_attribute_constructor; 127 gobjectClass->finalize = webkit_dom_attribute_finalize; 128 gobjectClass->get_property = webkit_dom_attribute_get_property; 129 130 g_object_class_install_property( 131 gobjectClass, 132 PROP_NAME, 133 g_param_spec_string( 134 "name", 135 "TestException:name", 136 "read-only gchar* TestException:name", 137 "", 138 WEBKIT_PARAM_READABLE)); 139 140 g_object_class_install_property( 141 gobjectClass, 142 PROP_READONLY, 143 g_param_spec_string( 144 "readonly", 145 "attribute:readonly", 146 "read-only gchar* attribute:readonly", 147 "", 148 WEBKIT_PARAM_READABLE)); 149 150} 151 152static void webkit_dom_attribute_init(WebKitDOMattribute* request) 153{ 154 WebKitDOMattributePrivate* priv = WEBKIT_DOM_ATTRIBUTE_GET_PRIVATE(request); 155 new (priv) WebKitDOMattributePrivate(); 156} 157 158gchar* webkit_dom_attribute_get_readonly(WebKitDOMattribute* self) 159{ 160 WebCore::JSMainThreadNullState state; 161 g_return_val_if_fail(WEBKIT_DOM_IS_ATTRIBUTE(self), 0); 162 WebCore::attribute* item = WebKit::core(self); 163 gchar* result = convertToUTF8String(item->readonly()); 164 return result; 165} 166 167