1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /*
3 * Copyright © 2020 Endless Mobile Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include "test/gjs-test-no-introspection-object.h"
25
26 struct _GjsTestNoIntrospectionObject {
27 GObject parent_instance;
28
29 int a_int;
30 };
31
32 G_DEFINE_TYPE(GjsTestNoIntrospectionObject, gjstest_no_introspection_object,
33 G_TYPE_OBJECT)
34
35 static GjsTestNoIntrospectionObject* last_object = NULL;
36
gjstest_no_introspection_object_init(GjsTestNoIntrospectionObject * self)37 static void gjstest_no_introspection_object_init(
38 GjsTestNoIntrospectionObject* self) {
39 self->a_int = 0;
40 last_object = self;
41 }
42
gjstest_no_introspection_object_set_property(GObject * object,unsigned prop_id,const GValue * value,GParamSpec * pspec)43 static void gjstest_no_introspection_object_set_property(GObject* object,
44 unsigned prop_id,
45 const GValue* value,
46 GParamSpec* pspec) {
47 GjsTestNoIntrospectionObject* self =
48 GJSTEST_NO_INTROSPECTION_OBJECT(object);
49
50 switch (prop_id) {
51 case 1:
52 self->a_int = g_value_get_int(value);
53 break;
54 default:
55 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
56 break;
57 }
58 }
59
gjstest_no_introspection_object_get_property(GObject * object,unsigned prop_id,GValue * value,GParamSpec * pspec)60 static void gjstest_no_introspection_object_get_property(GObject* object,
61 unsigned prop_id,
62 GValue* value,
63 GParamSpec* pspec) {
64 GjsTestNoIntrospectionObject* self =
65 GJSTEST_NO_INTROSPECTION_OBJECT(object);
66
67 switch (prop_id) {
68 case 1:
69 g_value_set_int(value, self->a_int);
70 break;
71 default:
72 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
73 break;
74 }
75 }
76
gjstest_no_introspection_object_class_init(GjsTestNoIntrospectionObjectClass * klass)77 static void gjstest_no_introspection_object_class_init(
78 GjsTestNoIntrospectionObjectClass* klass) {
79 GObjectClass* object_class = G_OBJECT_CLASS(klass);
80
81 object_class->set_property = gjstest_no_introspection_object_set_property;
82 object_class->get_property = gjstest_no_introspection_object_get_property;
83
84 g_object_class_install_property(
85 object_class, 1,
86 g_param_spec_int("a-int", "An integer", "An integer property", 0,
87 100000000, 0, G_PARAM_READWRITE));
88 }
89
gjstest_no_introspection_object_peek()90 GjsTestNoIntrospectionObject* gjstest_no_introspection_object_peek() {
91 return last_object;
92 }
93