1/*
2 * Copyright (C) 2018 Igalia S.L.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if !defined(__JSC_H_INSIDE__) && !defined(JSC_COMPILATION) && !defined(WEBKIT2_COMPILATION)
21#error "Only <jsc/jsc.h> can be included directly."
22#endif
23
24#ifndef JSCClass_h
25#define JSCClass_h
26
27#include <glib-object.h>
28#include <jsc/JSCDefines.h>
29#include <jsc/JSCValue.h>
30
31G_BEGIN_DECLS
32
33#define JSC_TYPE_CLASS (jsc_class_get_type())
34#define JSC_CLASS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JSC_TYPE_CLASS, JSCClass))
35#define JSC_IS_CLASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JSC_TYPE_CLASS))
36
37typedef struct _JSCClass JSCClass;
38typedef struct _JSCClassClass JSCClassClass;
39
40typedef struct _JSCContext JSCContext;
41
42typedef JSCValue *(*JSCClassGetPropertyFunction) (JSCClass *jsc_class,
43 JSCContext *context,
44 gpointer instance,
45 const char *name);
46typedef gboolean (*JSCClassSetPropertyFunction) (JSCClass *jsc_class,
47 JSCContext *context,
48 gpointer instance,
49 const char *name,
50 JSCValue *value);
51typedef gboolean (*JSCClassHasPropertyFunction) (JSCClass *jsc_class,
52 JSCContext *context,
53 gpointer instance,
54 const char *name);
55typedef gboolean (*JSCClassDeletePropertyFunction) (JSCClass *jsc_class,
56 JSCContext *context,
57 gpointer instance,
58 const char *name);
59typedef gchar **(*JSCClassEnumeratePropertiesFunction) (JSCClass *jsc_class,
60 JSCContext *context,
61 gpointer instance);
62
63
64typedef struct {
65 JSCClassGetPropertyFunction get_property;
66 JSCClassSetPropertyFunction set_property;
67 JSCClassHasPropertyFunction has_property;
68 JSCClassDeletePropertyFunction delete_property;
69 JSCClassEnumeratePropertiesFunction enumerate_properties;
70
71 /*< private >*/
72 void (*_jsc_reserved0) (void);
73 void (*_jsc_reserved1) (void);
74 void (*_jsc_reserved2) (void);
75 void (*_jsc_reserved3) (void);
76} JSCClassVTable;
77
78JSC_API GType
79jsc_class_get_type (void);
80
81JSC_API const char *
82jsc_class_get_name (JSCClass *jsc_class);
83
84JSC_API JSCClass *
85jsc_class_get_parent (JSCClass *jsc_class);
86
87JSC_API JSCValue *
88jsc_class_add_constructor (JSCClass *jsc_class,
89 const char *name,
90 GCallback callback,
91 gpointer user_data,
92 GDestroyNotify destroy_notify,
93 GType return_type,
94 guint n_params,
95 ...);
96
97JSC_API JSCValue *
98jsc_class_add_constructorv (JSCClass *jsc_class,
99 const char *name,
100 GCallback callback,
101 gpointer user_data,
102 GDestroyNotify destroy_notify,
103 GType return_type,
104 guint n_parameters,
105 GType *parameter_types);
106
107JSC_API JSCValue *
108jsc_class_add_constructor_variadic (JSCClass *jsc_class,
109 const char *name,
110 GCallback callback,
111 gpointer user_data,
112 GDestroyNotify destroy_notify,
113 GType return_type);
114
115JSC_API void
116jsc_class_add_method (JSCClass *jsc_class,
117 const char *name,
118 GCallback callback,
119 gpointer user_data,
120 GDestroyNotify destroy_notify,
121 GType return_type,
122 guint n_params,
123 ...);
124
125JSC_API void
126jsc_class_add_methodv (JSCClass *jsc_class,
127 const char *name,
128 GCallback callback,
129 gpointer user_data,
130 GDestroyNotify destroy_notify,
131 GType return_type,
132 guint n_parameters,
133 GType *parameter_types);
134
135JSC_API void
136jsc_class_add_method_variadic (JSCClass *jsc_class,
137 const char *name,
138 GCallback callback,
139 gpointer user_data,
140 GDestroyNotify destroy_notify,
141 GType return_type);
142
143JSC_API void
144jsc_class_add_property (JSCClass *jsc_class,
145 const char *name,
146 GType property_type,
147 GCallback getter,
148 GCallback setter,
149 gpointer user_data,
150 GDestroyNotify destroy_notify);
151
152G_END_DECLS
153
154#endif /* JSCClass_h */
155