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 "WebKitDOMTestException.h"
23
24#include "CSSImportRule.h"
25#include "DOMObjectCache.h"
26#include "ExceptionCode.h"
27#include "JSMainThreadExecState.h"
28#include "WebKitDOMPrivate.h"
29#include "WebKitDOMTestExceptionPrivate.h"
30#include "gobject/ConvertToUTF8String.h"
31#include <wtf/GetPtr.h>
32#include <wtf/RefPtr.h>
33
34#define WEBKIT_DOM_TEST_EXCEPTION_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_TYPE_DOM_TEST_EXCEPTION, WebKitDOMTestExceptionPrivate)
35
36typedef struct _WebKitDOMTestExceptionPrivate {
37    RefPtr<WebCore::TestException> coreObject;
38} WebKitDOMTestExceptionPrivate;
39
40namespace WebKit {
41
42WebKitDOMTestException* kit(WebCore::TestException* obj)
43{
44    if (!obj)
45        return 0;
46
47    if (gpointer ret = DOMObjectCache::get(obj))
48        return WEBKIT_DOM_TEST_EXCEPTION(ret);
49
50    return wrapTestException(obj);
51}
52
53WebCore::TestException* core(WebKitDOMTestException* request)
54{
55    return request ? static_cast<WebCore::TestException*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
56}
57
58WebKitDOMTestException* wrapTestException(WebCore::TestException* coreObject)
59{
60    ASSERT(coreObject);
61    return WEBKIT_DOM_TEST_EXCEPTION(g_object_new(WEBKIT_TYPE_DOM_TEST_EXCEPTION, "core-object", coreObject, NULL));
62}
63
64} // namespace WebKit
65
66G_DEFINE_TYPE(WebKitDOMTestException, webkit_dom_test_exception, WEBKIT_TYPE_DOM_OBJECT)
67
68enum {
69    PROP_0,
70    PROP_NAME,
71};
72
73static void webkit_dom_test_exception_finalize(GObject* object)
74{
75    WebKitDOMTestExceptionPrivate* priv = WEBKIT_DOM_TEST_EXCEPTION_GET_PRIVATE(object);
76
77    WebKit::DOMObjectCache::forget(priv->coreObject.get());
78
79    priv->~WebKitDOMTestExceptionPrivate();
80    G_OBJECT_CLASS(webkit_dom_test_exception_parent_class)->finalize(object);
81}
82
83static void webkit_dom_test_exception_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
84{
85    WebCore::JSMainThreadNullState state;
86
87    WebKitDOMTestException* self = WEBKIT_DOM_TEST_EXCEPTION(object);
88    WebCore::TestException* coreSelf = WebKit::core(self);
89
90    switch (propertyId) {
91    case PROP_NAME: {
92        g_value_take_string(value, convertToUTF8String(coreSelf->name()));
93        break;
94    }
95    default:
96        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
97        break;
98    }
99}
100
101static GObject* webkit_dom_test_exception_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties)
102{
103    GObject* object = G_OBJECT_CLASS(webkit_dom_test_exception_parent_class)->constructor(type, constructPropertiesCount, constructProperties);
104
105    WebKitDOMTestExceptionPrivate* priv = WEBKIT_DOM_TEST_EXCEPTION_GET_PRIVATE(object);
106    priv->coreObject = static_cast<WebCore::TestException*>(WEBKIT_DOM_OBJECT(object)->coreObject);
107    WebKit::DOMObjectCache::put(priv->coreObject.get(), object);
108
109    return object;
110}
111
112static void webkit_dom_test_exception_class_init(WebKitDOMTestExceptionClass* requestClass)
113{
114    GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
115    g_type_class_add_private(gobjectClass, sizeof(WebKitDOMTestExceptionPrivate));
116    gobjectClass->constructor = webkit_dom_test_exception_constructor;
117    gobjectClass->finalize = webkit_dom_test_exception_finalize;
118    gobjectClass->get_property = webkit_dom_test_exception_get_property;
119
120    g_object_class_install_property(gobjectClass,
121                                    PROP_NAME,
122                                    g_param_spec_string("name", /* name */
123                                                           "test_exception_name", /* short description */
124                                                           "read-only  gchar* TestException.name", /* longer - could do with some extra doc stuff here */
125                                                           "", /* default */
126                                                           WEBKIT_PARAM_READABLE));
127}
128
129static void webkit_dom_test_exception_init(WebKitDOMTestException* request)
130{
131    WebKitDOMTestExceptionPrivate* priv = WEBKIT_DOM_TEST_EXCEPTION_GET_PRIVATE(request);
132    new (priv) WebKitDOMTestExceptionPrivate();
133}
134
135gchar*
136webkit_dom_test_exception_get_name(WebKitDOMTestException* self)
137{
138    WebCore::JSMainThreadNullState state;
139    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_EXCEPTION(self), 0);
140    WebCore::TestException* item = WebKit::core(self);
141    gchar* result = convertToUTF8String(item->name());
142    return result;
143}
144
145