1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
|
/*
* Copyright (C) 2018 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#if !defined(__JSC_H_INSIDE__) && !defined(BUILDING_WEBKIT)
#error "Only <jsc/jsc.h> can be included directly."
#endif
#ifndef JSCValue_h
#define JSCValue_h
#include <glib-object.h>
#include <jsc/JSCDefines.h>
G_BEGIN_DECLS
#define JSC_TYPE_VALUE (jsc_value_get_type())
#if !ENABLE(2022_GLIB_API)
#define JSC_VALUE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JSC_TYPE_VALUE, JSCValue))
#define JSC_IS_VALUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), JSC_TYPE_VALUE))
#define JSC_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), JSC_TYPE_VALUE, JSCValueClass))
#define JSC_IS_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), JSC_TYPE_VALUE))
#define JSC_VALUE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), JSC_TYPE_VALUE, JSCValueClass))
struct _JSCValueClass {
GObjectClass parent_class;
void (*_jsc_reserved0) (void);
void (*_jsc_reserved1) (void);
void (*_jsc_reserved2) (void);
void (*_jsc_reserved3) (void);
};
#endif
JSC_DECLARE_FINAL_TYPE (JSCValue, jsc_value, JSC, VALUE, GObject)
typedef struct _JSCClass JSCClass;
typedef struct _JSCContext JSCContext;
typedef enum {
JSC_VALUE_PROPERTY_CONFIGURABLE = 1 << 0,
JSC_VALUE_PROPERTY_ENUMERABLE = 1 << 1,
JSC_VALUE_PROPERTY_WRITABLE = 1 << 2
} JSCValuePropertyFlags;
typedef enum {
JSC_TYPED_ARRAY_NONE = 0,
JSC_TYPED_ARRAY_INT8,
JSC_TYPED_ARRAY_INT16,
JSC_TYPED_ARRAY_INT32,
JSC_TYPED_ARRAY_INT64,
JSC_TYPED_ARRAY_UINT8,
JSC_TYPED_ARRAY_UINT8_CLAMPED,
JSC_TYPED_ARRAY_UINT16,
JSC_TYPED_ARRAY_UINT32,
JSC_TYPED_ARRAY_UINT64,
JSC_TYPED_ARRAY_FLOAT32,
JSC_TYPED_ARRAY_FLOAT64,
} JSCTypedArrayType;
JSC_API JSCContext *
jsc_value_get_context (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_undefined (JSCContext *context);
JSC_API gboolean
jsc_value_is_undefined (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_null (JSCContext *context);
JSC_API gboolean
jsc_value_is_null (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_number (JSCContext *context,
double number);
JSC_API gboolean
jsc_value_is_number (JSCValue *value);
JSC_API double
jsc_value_to_double (JSCValue *value);
JSC_API gint32
jsc_value_to_int32 (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_boolean (JSCContext *context,
gboolean value);
JSC_API gboolean
jsc_value_is_boolean (JSCValue *value);
JSC_API gboolean
jsc_value_to_boolean (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_string (JSCContext *context,
const char *string);
JSC_API JSCValue *
jsc_value_new_string_from_bytes (JSCContext *context,
GBytes *bytes);
JSC_API gboolean
jsc_value_is_string (JSCValue *value);
JSC_API char *
jsc_value_to_string (JSCValue *value);
JSC_API GBytes *
jsc_value_to_string_as_bytes (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_array (JSCContext *context,
GType first_item_type,
...);
JSC_API JSCValue *
jsc_value_new_array_from_garray (JSCContext *context,
GPtrArray *array);
JSC_API JSCValue *
jsc_value_new_array_from_strv (JSCContext *context,
const char *const *strv);
JSC_API gboolean
jsc_value_is_array (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_object (JSCContext *context,
gpointer instance,
JSCClass *jsc_class);
JSC_API gboolean
jsc_value_is_object (JSCValue *value);
JSC_API gboolean
jsc_value_object_is_instance_of (JSCValue *value,
const char *name);
JSC_API void
jsc_value_object_set_property (JSCValue *value,
const char *name,
JSCValue *property);
JSC_API JSCValue *
jsc_value_object_get_property (JSCValue *value,
const char *name);
JSC_API void
jsc_value_object_set_property_at_index (JSCValue *value,
guint index,
JSCValue *property);
JSC_API JSCValue *
jsc_value_object_get_property_at_index (JSCValue *value,
guint index);
JSC_API gboolean
jsc_value_object_has_property (JSCValue *value,
const char *name);
JSC_API gboolean
jsc_value_object_delete_property (JSCValue *value,
const char *name);
JSC_API gchar **
jsc_value_object_enumerate_properties (JSCValue *value);
JSC_API JSCValue *
jsc_value_object_invoke_method (JSCValue *value,
const char *name,
GType first_parameter_type,
...) G_GNUC_WARN_UNUSED_RESULT;
JSC_API JSCValue *
jsc_value_object_invoke_methodv (JSCValue *value,
const char *name,
guint n_parameters,
JSCValue **parameters) G_GNUC_WARN_UNUSED_RESULT;
JSC_API void
jsc_value_object_define_property_data (JSCValue *value,
const char *property_name,
JSCValuePropertyFlags flags,
JSCValue *property_value);
JSC_API void
jsc_value_object_define_property_accessor (JSCValue *value,
const char *property_name,
JSCValuePropertyFlags flags,
GType property_type,
GCallback getter,
GCallback setter,
gpointer user_data,
GDestroyNotify destroy_notify);
JSC_API JSCValue *
jsc_value_new_function (JSCContext *context,
const char *name,
GCallback callback,
gpointer user_data,
GDestroyNotify destroy_notify,
GType return_type,
guint n_params,
...);
JSC_API JSCValue *
jsc_value_new_functionv (JSCContext *context,
const char *name,
GCallback callback,
gpointer user_data,
GDestroyNotify destroy_notify,
GType return_type,
guint n_parameters,
GType *parameter_types);
JSC_API JSCValue *
jsc_value_new_function_variadic (JSCContext *context,
const char *name,
GCallback callback,
gpointer user_data,
GDestroyNotify destroy_notify,
GType return_type);
JSC_API gboolean
jsc_value_is_function (JSCValue *value);
JSC_API JSCValue *
jsc_value_function_call (JSCValue *value,
GType first_parameter_type,
...) G_GNUC_WARN_UNUSED_RESULT;
JSC_API JSCValue *
jsc_value_function_callv (JSCValue *value,
guint n_parameters,
JSCValue **parameters) G_GNUC_WARN_UNUSED_RESULT;
JSC_API JSCValue *
jsc_value_new_array_buffer (JSCContext *context,
gpointer data,
gsize size,
GDestroyNotify destroy_notify,
gpointer user_data);
JSC_API gboolean
jsc_value_is_array_buffer (JSCValue *value);
JSC_API gpointer
jsc_value_array_buffer_get_data (JSCValue *value,
gsize *size);
JSC_API gsize
jsc_value_array_buffer_get_size (JSCValue *value);
JSC_API JSCValue *
jsc_value_new_typed_array (JSCContext *context,
JSCTypedArrayType type,
gsize length);
JSC_API JSCValue *
jsc_value_new_typed_array_with_buffer (JSCValue *array_buffer,
JSCTypedArrayType type,
gsize offset,
gssize length);
JSC_API gboolean
jsc_value_is_typed_array (JSCValue *value);
JSC_API JSCTypedArrayType
jsc_value_typed_array_get_type (JSCValue *value);
JSC_API gpointer
jsc_value_typed_array_get_data (JSCValue *value,
gsize *length);
JSC_API gsize
jsc_value_typed_array_get_length (JSCValue *value);
JSC_API gsize
jsc_value_typed_array_get_size (JSCValue *value);
JSC_API gsize
jsc_value_typed_array_get_offset (JSCValue *value);
JSC_API JSCValue *
jsc_value_typed_array_get_buffer (JSCValue *value);
JSC_API gboolean
jsc_value_is_constructor (JSCValue *value);
JSC_API JSCValue *
jsc_value_constructor_call (JSCValue *value,
GType first_parameter_type,
...);
JSC_API JSCValue *
jsc_value_constructor_callv (JSCValue *value,
guint n_parameters,
JSCValue **parameters);
JSC_API JSCValue *
jsc_value_new_from_json (JSCContext *context,
const char *json);
JSC_API char *
jsc_value_to_json (JSCValue *value,
guint indent);
typedef void (*JSCExecutor) (JSCValue *resolve,
JSCValue *reject,
gpointer user_data);
JSC_API JSCValue *
jsc_value_new_promise (JSCContext *context,
JSCExecutor executor,
gpointer user_data);
G_END_DECLS
#endif /* JSCValue_h */
|