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 | |
31 | G_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 | |
37 | typedef struct _JSCClass JSCClass; |
38 | typedef struct _JSCClassClass JSCClassClass; |
39 | |
40 | typedef struct _JSCContext JSCContext; |
41 | |
42 | typedef JSCValue *(*JSCClassGetPropertyFunction) (JSCClass *jsc_class, |
43 | JSCContext *context, |
44 | gpointer instance, |
45 | const char *name); |
46 | typedef gboolean (*JSCClassSetPropertyFunction) (JSCClass *jsc_class, |
47 | JSCContext *context, |
48 | gpointer instance, |
49 | const char *name, |
50 | JSCValue *value); |
51 | typedef gboolean (*JSCClassHasPropertyFunction) (JSCClass *jsc_class, |
52 | JSCContext *context, |
53 | gpointer instance, |
54 | const char *name); |
55 | typedef gboolean (*JSCClassDeletePropertyFunction) (JSCClass *jsc_class, |
56 | JSCContext *context, |
57 | gpointer instance, |
58 | const char *name); |
59 | typedef gchar **(*JSCClassEnumeratePropertiesFunction) (JSCClass *jsc_class, |
60 | JSCContext *context, |
61 | gpointer instance); |
62 | |
63 | |
64 | typedef 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 | |
78 | JSC_API GType |
79 | jsc_class_get_type (void); |
80 | |
81 | JSC_API const char * |
82 | jsc_class_get_name (JSCClass *jsc_class); |
83 | |
84 | JSC_API JSCClass * |
85 | jsc_class_get_parent (JSCClass *jsc_class); |
86 | |
87 | JSC_API JSCValue * |
88 | jsc_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 | |
97 | JSC_API JSCValue * |
98 | jsc_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 | |
107 | JSC_API JSCValue * |
108 | jsc_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 | |
115 | JSC_API void |
116 | jsc_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 | |
125 | JSC_API void |
126 | jsc_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 | |
135 | JSC_API void |
136 | jsc_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 | |
143 | JSC_API void |
144 | jsc_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 | |
152 | G_END_DECLS |
153 | |
154 | #endif /* JSCClass_h */ |
155 | |