Initialize glib threads since it's needed by WebKitGtk soup http-backend build.
[pywebkitgtk.git] / gjs / gjs.h
blob19bf4d4ecffb45de0150720faedb9d2cb8d4506a
1 /*
2 Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 See the file COPYING for the full license text.
12 #ifndef __GJS_H__
13 #define __GJS_H__
15 #include <JavaScriptCore/JavaScript.h>
16 #include <glib-object.h>
18 G_BEGIN_DECLS
20 #define GJS_TYPE_VALUE \
21 (gjs_value_get_type ())
22 #define GJS_VALUE(obj) \
23 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GJS_TYPE_VALUE, GjsValue))
24 #define GJS_VALUE_CLASS(klass) \
25 (G_TYPE_CHECK_CLASS_CAST ((klass), GJS_TYPE_VALUE, GjsValueClass))
26 #define GJS_IS_VALUE(obj) \
27 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GJS_TYPE_VALUE))
28 #define GJS_IS_VALUE_CLASS(klass) \
29 (G_TYPE_CHECK_CLASS_TYPE ((klass), GJS_TYPE_VALUE))
30 #define GJS_VALUE_GET_CLASS(obj) \
31 (G_TYPE_INSTANCE_GET_CLASS ((obj), GJS_TYPE_VALUE, GjsValueClass))
33 typedef struct _GjsValue GjsValue;
34 typedef struct _GjsValueClass GjsValueClass;
36 struct _GjsValueClass
38 GObjectClass parent_class;
41 GType
42 gjs_value_get_type (void);
44 GjsValue*
45 gjs_value_new (JSContextRef js_context,
46 JSValueRef js_value);
48 gboolean
49 gjs_value_is_valid (GjsValue* value);
51 gboolean
52 gjs_value_is_object (GjsValue* value);
54 gboolean
55 gjs_value_has_attribute (GjsValue* value,
56 const gchar* name);
58 GjsValue*
59 gjs_value_get_attribute (GjsValue* value,
60 const gchar* name);
62 const gchar*
63 gjs_value_get_string (GjsValue* value);
65 const gchar*
66 gjs_value_get_attribute_string (GjsValue* value,
67 const gchar* name);
69 GjsValue*
70 gjs_value_get_nth_attribute (GjsValue* value,
71 guint n);
73 typedef void
74 (*GjsCallback) (GjsValue* value,
75 gpointer user_data);
77 void
78 gjs_value_foreach (GjsValue* value,
79 GjsCallback callback,
80 gpointer user_data);
82 void
83 gjs_value_forall (GjsValue* value,
84 GjsCallback callback,
85 gpointer user_data);
87 GjsValue*
88 gjs_value_get_by_name (GjsValue* value,
89 const gchar* name);
91 GjsValue*
92 gjs_value_get_elements_by_tag_name (GjsValue* value,
93 const gchar* name);
95 GjsValue*
96 gjs_value_execute (GjsValue* value,
97 const gchar* script,
98 gchar** exception);
100 JSValueRef
101 gjs_script_eval (JSContextRef js_context,
102 const gchar* script,
103 gchar** exception);
105 gboolean
106 gjs_script_check_syntax (JSContextRef js_context,
107 const gchar* script,
108 gchar** exception);
110 gboolean
111 gjs_script_from_file (JSContextRef js_context,
112 const gchar* filename,
113 gchar** exception);
115 gchar*
116 gjs_string_utf8 (JSStringRef js_string);
118 JSObjectRef
119 gjs_object_new (JSContextRef context,
120 const gchar* name,
121 gpointer instance);
123 JSGlobalContextRef
124 gjs_global_context_new (void);
126 G_END_DECLS
128 #endif /* __GJS_H__ */