2010-04-26 Adam Barth <abarth@webkit.org>
[WebKit-https.git] / WebCore / bindings / scripts / test / GObject / WebKitDOMTestObj.cpp
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 <glib-object.h>
22 #include "config.h"
23
24 #include <wtf/GetPtr.h>
25 #include <wtf/RefPtr.h>
26 #include "ExceptionCode.h"
27 #include "TestObj.h"
28 #include "WebKitDOMBinding.h"
29 #include "gobject/ConvertToUTF8String.h"
30 #include "webkit/WebKitDOMTestObj.h"
31 #include "webkit/WebKitDOMTestObjPrivate.h"
32 #include "webkitmarshal.h"
33 #include "webkitprivate.h"
34
35 namespace WebKit {
36     
37 gpointer kit(WebCore::TestObj* obj)
38 {
39     g_return_val_if_fail(obj != 0, 0);
40
41     if (gpointer ret = DOMObjectCache::get(obj))
42         return ret;
43
44     return DOMObjectCache::put(obj, WebKit::wrapTestObj(obj));
45 }
46     
47 } // namespace WebKit //
48
49 void
50 webkit_dom_test_obj_void_method (WebKitDOMTestObj *self)
51 {
52     g_return_if_fail (self);
53     WebCore::TestObj * item = WebKit::core(self);
54     item->voidMethod();
55
56 }
57
58 void
59 webkit_dom_test_obj_void_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar*  str_arg, WebKitDOMTestObj*  obj_arg)
60 {
61     g_return_if_fail (self);
62     WebCore::TestObj * item = WebKit::core(self);
63     g_return_if_fail (str_arg);
64     g_return_if_fail (obj_arg);
65     WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg);
66     WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg);
67     g_return_if_fail (_g_obj_arg);
68     item->voidMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg);
69
70 }
71
72 glong
73 webkit_dom_test_obj_int_method (WebKitDOMTestObj *self)
74 {
75     g_return_val_if_fail (self, 0);
76     WebCore::TestObj * item = WebKit::core(self);
77     glong res = item->intMethod();
78     return res;
79
80 }
81
82 glong
83 webkit_dom_test_obj_int_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar*  str_arg, WebKitDOMTestObj*  obj_arg)
84 {
85     g_return_val_if_fail (self, 0);
86     WebCore::TestObj * item = WebKit::core(self);
87     g_return_val_if_fail (str_arg, 0);
88     g_return_val_if_fail (obj_arg, 0);
89     WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg);
90     WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg);
91     g_return_val_if_fail (_g_obj_arg, 0);
92     glong res = item->intMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg);
93     return res;
94
95 }
96
97 WebKitDOMTestObj* 
98 webkit_dom_test_obj_obj_method (WebKitDOMTestObj *self)
99 {
100     g_return_val_if_fail (self, 0);
101     WebCore::TestObj * item = WebKit::core(self);
102     PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethod());
103     WebKitDOMTestObj*  res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
104     return res;
105
106 }
107
108 WebKitDOMTestObj* 
109 webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar*  str_arg, WebKitDOMTestObj*  obj_arg)
110 {
111     g_return_val_if_fail (self, 0);
112     WebCore::TestObj * item = WebKit::core(self);
113     g_return_val_if_fail (str_arg, 0);
114     g_return_val_if_fail (obj_arg, 0);
115     WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg);
116     WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg);
117     g_return_val_if_fail (_g_obj_arg, 0);
118     PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg));
119     WebKitDOMTestObj*  res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
120     return res;
121
122 }
123
124 void
125 webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error)
126 {
127     g_return_if_fail (self);
128     WebCore::TestObj * item = WebKit::core(self);
129     WebCore::ExceptionCode ec = 0;
130     item->methodWithException(ec);
131     if (ec) {
132         WebCore::ExceptionCodeDescription ecdesc;
133         WebCore::getExceptionCodeDescription(ec, ecdesc);
134         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
135     }
136
137 }
138
139 void
140 webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt)
141 {
142     g_return_if_fail (self);
143     WebCore::TestObj * item = WebKit::core(self);
144     item->methodWithOptionalArg(opt);
145
146 }
147
148 void
149 webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg (WebKitDOMTestObj *self, glong non_opt, glong opt)
150 {
151     g_return_if_fail (self);
152     WebCore::TestObj * item = WebKit::core(self);
153     item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt);
154
155 }
156
157 void
158 webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args (WebKitDOMTestObj *self, glong non_opt, glong opt1, glong opt2)
159 {
160     g_return_if_fail (self);
161     WebCore::TestObj * item = WebKit::core(self);
162     item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2);
163
164 }
165
166 glong
167 webkit_dom_test_obj_get_read_only_int_attr (WebKitDOMTestObj *self)
168 {
169     g_return_val_if_fail (self, 0);
170     WebCore::TestObj * item = WebKit::core(self);
171     glong res = item->readOnlyIntAttr();
172     return res;
173
174 }
175
176 gchar* 
177 webkit_dom_test_obj_get_read_only_string_attr (WebKitDOMTestObj *self)
178 {
179     g_return_val_if_fail (self, 0);
180     WebCore::TestObj * item = WebKit::core(self);
181     gchar*  res = convertToUTF8String(item->readOnlyStringAttr());
182     return res;
183
184 }
185
186 WebKitDOMTestObj* 
187 webkit_dom_test_obj_get_read_only_test_obj_attr (WebKitDOMTestObj *self)
188 {
189     g_return_val_if_fail (self, 0);
190     WebCore::TestObj * item = WebKit::core(self);
191     PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->readOnlyTestObjAttr());
192     WebKitDOMTestObj*  res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
193     return res;
194
195 }
196
197 glong
198 webkit_dom_test_obj_get_int_attr (WebKitDOMTestObj *self)
199 {
200     g_return_val_if_fail (self, 0);
201     WebCore::TestObj * item = WebKit::core(self);
202     glong res = item->intAttr();
203     return res;
204
205 }
206
207 void
208 webkit_dom_test_obj_set_int_attr (WebKitDOMTestObj *self, glong value)
209 {
210     g_return_if_fail (self);
211     WebCore::TestObj * item = WebKit::core(self);
212     item->setIntAttr(value);
213
214 }
215
216 gchar* 
217 webkit_dom_test_obj_get_string_attr (WebKitDOMTestObj *self)
218 {
219     g_return_val_if_fail (self, 0);
220     WebCore::TestObj * item = WebKit::core(self);
221     gchar*  res = convertToUTF8String(item->stringAttr());
222     return res;
223
224 }
225
226 void
227 webkit_dom_test_obj_set_string_attr (WebKitDOMTestObj *self, gchar*  value)
228 {
229     g_return_if_fail (self);
230     WebCore::TestObj * item = WebKit::core(self);
231     g_return_if_fail (value);
232     WebCore::String _g_value = WebCore::String::fromUTF8(value);
233     item->setStringAttr(_g_value);
234
235 }
236
237 WebKitDOMTestObj* 
238 webkit_dom_test_obj_get_test_obj_attr (WebKitDOMTestObj *self)
239 {
240     g_return_val_if_fail (self, 0);
241     WebCore::TestObj * item = WebKit::core(self);
242     PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr());
243     WebKitDOMTestObj*  res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
244     return res;
245
246 }
247
248 void
249 webkit_dom_test_obj_set_test_obj_attr (WebKitDOMTestObj *self, WebKitDOMTestObj*  value)
250 {
251     g_return_if_fail (self);
252     WebCore::TestObj * item = WebKit::core(self);
253     g_return_if_fail (value);
254     WebCore::TestObj * _g_value = WebKit::core(value);
255     g_return_if_fail (_g_value);
256     item->setTestObjAttr(_g_value);
257
258 }
259
260 glong
261 webkit_dom_test_obj_get_attr_with_exception (WebKitDOMTestObj *self)
262 {
263     g_return_val_if_fail (self, 0);
264     WebCore::TestObj * item = WebKit::core(self);
265     glong res = item->attrWithException();
266     return res;
267
268 }
269
270 void
271 webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value)
272 {
273     g_return_if_fail (self);
274     WebCore::TestObj * item = WebKit::core(self);
275     item->setAttrWithException(value);
276
277 }
278
279 glong
280 webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self)
281 {
282     g_return_val_if_fail (self, 0);
283     WebCore::TestObj * item = WebKit::core(self);
284     glong res = item->attrWithSetterException();
285     return res;
286
287 }
288
289 void
290 webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value)
291 {
292     g_return_if_fail (self);
293     WebCore::TestObj * item = WebKit::core(self);
294     item->setAttrWithSetterException(value);
295
296 }
297
298 glong
299 webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self)
300 {
301     g_return_val_if_fail (self, 0);
302     WebCore::TestObj * item = WebKit::core(self);
303     glong res = item->attrWithGetterException();
304     return res;
305
306 }
307
308 void
309 webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value)
310 {
311     g_return_if_fail (self);
312     WebCore::TestObj * item = WebKit::core(self);
313     item->setAttrWithGetterException(value);
314
315 }
316
317
318 G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT)
319
320 namespace WebKit {
321
322 WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject)
323 {
324     g_return_val_if_fail(coreObject != 0, 0);
325     
326     WebKitDOMTestObj* wrapper = WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, NULL));
327     g_return_val_if_fail(wrapper != 0, 0);
328
329     /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object
330      * in a C-allocated GObject structure.  See the finalize() code for the
331      * matching deref().
332      */
333
334     coreObject->ref();
335     WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject;
336
337     return wrapper;
338 }
339
340 WebCore::TestObj* core(WebKitDOMTestObj* request)
341 {
342     g_return_val_if_fail(request != 0, 0);
343     
344     WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(WEBKIT_DOM_OBJECT(request)->coreObject);
345     g_return_val_if_fail(coreObject != 0, 0);
346     
347     return coreObject;
348 }
349
350 } // namespace WebKit
351 enum {
352     PROP_0,
353     PROP_READ_ONLY_INT_ATTR,
354     PROP_READ_ONLY_STRING_ATTR,
355     PROP_READ_ONLY_TEST_OBJ_ATTR,
356     PROP_INT_ATTR,
357     PROP_STRING_ATTR,
358     PROP_TEST_OBJ_ATTR,
359     PROP_ATTR_WITH_EXCEPTION,
360     PROP_ATTR_WITH_SETTER_EXCEPTION,
361     PROP_ATTR_WITH_GETTER_EXCEPTION,
362     PROP_CUSTOM_ATTR,
363 };
364
365
366 static void webkit_dom_test_obj_finalize(GObject* object)
367 {
368     WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object);
369     
370     if (dom_object->coreObject != NULL) {
371         WebCore::TestObj* coreObject = static_cast<WebCore::TestObj *>(dom_object->coreObject);
372
373         WebKit::DOMObjectCache::forget(coreObject);
374         coreObject->deref();
375
376         dom_object->coreObject = NULL;
377     }
378
379     G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->finalize(object);
380 }
381
382 static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
383 {
384     WebKitDOMTestObj *self = WEBKIT_DOM_TEST_OBJ(object);
385     WebCore::TestObj* coreSelf = WebKit::core(self);
386
387     switch (prop_id) {
388     case PROP_INT_ATTR:
389     {
390          coreSelf->setIntAttr((g_value_get_long(value)) );
391          break;
392     }
393     case PROP_STRING_ATTR:
394     {
395          coreSelf->setStringAttr(WebCore::String::fromUTF8(g_value_get_string(value)) );
396          break;
397     }
398     case PROP_ATTR_WITH_EXCEPTION:
399     {
400          coreSelf->setAttrWithException((g_value_get_long(value)) );
401          break;
402     }
403     case PROP_ATTR_WITH_SETTER_EXCEPTION:
404     {
405          coreSelf->setAttrWithSetterException((g_value_get_long(value)) );
406          break;
407     }
408     case PROP_ATTR_WITH_GETTER_EXCEPTION:
409     {
410          coreSelf->setAttrWithGetterException((g_value_get_long(value)) );
411          break;
412     }
413     case PROP_CUSTOM_ATTR:
414     {
415          coreSelf->setCustomAttr((g_value_get_long(value)) );
416          break;
417     }
418      default:
419         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
420         break;
421     }
422 }
423
424
425 static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
426 {
427     WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object);
428     WebCore::TestObj* coreSelf = WebKit::core(self);
429
430     switch (prop_id) {
431     case PROP_READ_ONLY_INT_ATTR:
432     {
433          g_value_set_long(value, coreSelf->readOnlyIntAttr());
434          break;
435     }
436     case PROP_READ_ONLY_STRING_ATTR:
437     {
438          g_value_take_string(value, convertToUTF8String(coreSelf->readOnlyStringAttr()));
439          break;
440     }
441     case PROP_READ_ONLY_TEST_OBJ_ATTR:
442     {
443          RefPtr<WebCore::TestObj> ptr = coreSelf->readOnlyTestObjAttr();
444         g_value_set_object(value, WebKit::kit(ptr.get()));
445          break;
446     }
447     case PROP_INT_ATTR:
448     {
449          g_value_set_long(value, coreSelf->intAttr());
450          break;
451     }
452     case PROP_STRING_ATTR:
453     {
454          g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr()));
455          break;
456     }
457     case PROP_TEST_OBJ_ATTR:
458     {
459          RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr();
460         g_value_set_object(value, WebKit::kit(ptr.get()));
461          break;
462     }
463     case PROP_ATTR_WITH_EXCEPTION:
464     {
465          g_value_set_long(value, coreSelf->attrWithException());
466          break;
467     }
468     case PROP_ATTR_WITH_SETTER_EXCEPTION:
469     {
470          g_value_set_long(value, coreSelf->attrWithSetterException());
471          break;
472     }
473     case PROP_ATTR_WITH_GETTER_EXCEPTION:
474     {
475          g_value_set_long(value, coreSelf->attrWithGetterException());
476          break;
477     }
478     case PROP_CUSTOM_ATTR:
479     {
480          g_value_set_long(value, coreSelf->customAttr());
481          break;
482     }
483      default:
484         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
485         break;
486     }
487 }
488
489
490 static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass)
491 {
492     GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass);
493     gobjectClass->finalize = webkit_dom_test_obj_finalize;
494     gobjectClass->set_property = webkit_dom_test_obj_set_property;
495     gobjectClass->get_property = webkit_dom_test_obj_get_property;
496
497     g_object_class_install_property(gobjectClass,
498                                     PROP_READ_ONLY_INT_ATTR,
499                                     g_param_spec_long("read-only-int-attr", /* name */
500                                                            "test_obj_read-only-int-attr", /* short description */
501                                                            "read-only  glong TestObj.read-only-int-attr", /* longer - could do with some extra doc stuff here */
502                                                            G_MINLONG, /* min */
503 G_MAXLONG, /* max */
504 0, /* default */
505                                                            WEBKIT_PARAM_READABLE));
506      g_object_class_install_property(gobjectClass,
507                                     PROP_READ_ONLY_STRING_ATTR,
508                                     g_param_spec_string("read-only-string-attr", /* name */
509                                                            "test_obj_read-only-string-attr", /* short description */
510                                                            "read-only  gchar*  TestObj.read-only-string-attr", /* longer - could do with some extra doc stuff here */
511                                                            "", /* default */
512                                                            WEBKIT_PARAM_READABLE));
513      g_object_class_install_property(gobjectClass,
514                                     PROP_READ_ONLY_TEST_OBJ_ATTR,
515                                     g_param_spec_object("read-only-test-obj-attr", /* name */
516                                                            "test_obj_read-only-test-obj-attr", /* short description */
517                                                            "read-only  WebKitDOMTestObj*  TestObj.read-only-test-obj-attr", /* longer - could do with some extra doc stuff here */
518                                                            WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */
519                                                            WEBKIT_PARAM_READABLE));
520      g_object_class_install_property(gobjectClass,
521                                     PROP_INT_ATTR,
522                                     g_param_spec_long("int-attr", /* name */
523                                                            "test_obj_int-attr", /* short description */
524                                                            "read-write  glong TestObj.int-attr", /* longer - could do with some extra doc stuff here */
525                                                            G_MINLONG, /* min */
526 G_MAXLONG, /* max */
527 0, /* default */
528                                                            WEBKIT_PARAM_READWRITE));
529      g_object_class_install_property(gobjectClass,
530                                     PROP_STRING_ATTR,
531                                     g_param_spec_string("string-attr", /* name */
532                                                            "test_obj_string-attr", /* short description */
533                                                            "read-write  gchar*  TestObj.string-attr", /* longer - could do with some extra doc stuff here */
534                                                            "", /* default */
535                                                            WEBKIT_PARAM_READWRITE));
536      g_object_class_install_property(gobjectClass,
537                                     PROP_TEST_OBJ_ATTR,
538                                     g_param_spec_object("test-obj-attr", /* name */
539                                                            "test_obj_test-obj-attr", /* short description */
540                                                            "read-write  WebKitDOMTestObj*  TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */
541                                                            WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */
542                                                            WEBKIT_PARAM_READWRITE));
543      g_object_class_install_property(gobjectClass,
544                                     PROP_ATTR_WITH_EXCEPTION,
545                                     g_param_spec_long("attr-with-exception", /* name */
546                                                            "test_obj_attr-with-exception", /* short description */
547                                                            "read-write  glong TestObj.attr-with-exception", /* longer - could do with some extra doc stuff here */
548                                                            G_MINLONG, /* min */
549 G_MAXLONG, /* max */
550 0, /* default */
551                                                            WEBKIT_PARAM_READWRITE));
552      g_object_class_install_property(gobjectClass,
553                                     PROP_ATTR_WITH_SETTER_EXCEPTION,
554                                     g_param_spec_long("attr-with-setter-exception", /* name */
555                                                            "test_obj_attr-with-setter-exception", /* short description */
556                                                            "read-write  glong TestObj.attr-with-setter-exception", /* longer - could do with some extra doc stuff here */
557                                                            G_MINLONG, /* min */
558 G_MAXLONG, /* max */
559 0, /* default */
560                                                            WEBKIT_PARAM_READWRITE));
561      g_object_class_install_property(gobjectClass,
562                                     PROP_ATTR_WITH_GETTER_EXCEPTION,
563                                     g_param_spec_long("attr-with-getter-exception", /* name */
564                                                            "test_obj_attr-with-getter-exception", /* short description */
565                                                            "read-write  glong TestObj.attr-with-getter-exception", /* longer - could do with some extra doc stuff here */
566                                                            G_MINLONG, /* min */
567 G_MAXLONG, /* max */
568 0, /* default */
569                                                            WEBKIT_PARAM_READWRITE));
570      g_object_class_install_property(gobjectClass,
571                                     PROP_CUSTOM_ATTR,
572                                     g_param_spec_long("custom-attr", /* name */
573                                                            "test_obj_custom-attr", /* short description */
574                                                            "read-write  glong TestObj.custom-attr", /* longer - could do with some extra doc stuff here */
575                                                            G_MINLONG, /* min */
576 G_MAXLONG, /* max */
577 0, /* default */
578                                                            WEBKIT_PARAM_READWRITE));
579
580
581
582 }
583
584 static void webkit_dom_test_obj_init(WebKitDOMTestObj* request)
585 {
586 }
587