summaryrefslogtreecommitdiff
path: root/vapi/metadata/JavaScriptCore-4.0-custom.vala
blob: 34abdca9c0f9dc3b33305cd0c7f7069f4d83e0f6 (plain)
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
/**
 * Based on the work by
 *   Copyright 2011 Jiří Janoušek <janousek.jiri@gmail.com>
 *   Copyright 2017 Michael Gratton <mike@vee.net>
 */
[CCode (cprefix = "JS", gir_namespace = "JavaScript", gir_version = "4.0", lower_case_cprefix = "JS_")]
[Version (deprecated = true, deprecated_since = "2.22")]
namespace JS {
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "void", free_function = "JSClassRelease", has_type_id = false)]
	[Compact]
	public class Class {
		[CCode (cname = "JSClassRetain")]
		public JS.Class retain ();
		[CCode (cname = "JSClassRelease")]
		[DestroysInstance]
		public void release ();
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "const struct OpaqueJSContext", free_function = "", has_type_id = false)]
	[Compact]
	public class Context {
		[CCode (cname = "JSCheckScriptSyntax")]
		public bool check_script_syntax (JS.String script, JS.String? source_url = null, int starting_line_number = 1, out JS.Value? exception = null);
		[CCode (cname = "JSGarbageCollect")]
		public void collect_garbage ();
		[CCode (cname = "JSEvaluateScript")]
		public unowned JS.Value? evaluate_script (JS.String script, JS.Object? this_object = null, JS.String? source_url = null, int starting_line_number = 1, out JS.Value? exception = null);
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "struct OpaqueJSContext", free_function = "JSGlobalContextRelease", has_type_id = false)]
	[Compact]
	public class GlobalContext : JS.Context {
		[CCode (cname = "JSGlobalContextCreate")]
		public GlobalContext (JS.Class? global_object_class = null);
		[CCode (cname = "JSGlobalContextRelease")]
		[DestroysInstance]
		public void release ();
		[CCode (cname = "JSGlobalContextRetain")]
		public JS.GlobalContext retain ();
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "struct OpaqueJSValue", free_function = "", has_type_id = false)]
	[Compact]
	public class Object {
		[CCode (cname = "JSObjectCallAsFunction", instance_pos = 1.1)]
		public JS.Value call_as_function (JS.Context ctx, JS.Object? this_object, [CCode (array_length_pos = 2.5)] JS.Value[]? arguments, out JS.Value? exception);
		[CCode (cname = "JSObjectGetProperty", instance_pos = 1.1)]
		public JS.Value get_property (JS.Context ctx, JS.String property_name, out JS.Value? exception);
		[CCode (cname = "JSObjectHasProperty", instance_pos = 1.1)]
		public bool has_property (JS.Context ctx, JS.String property_name);
		[CCode (cname = "JSObjectMakeFunction")]
		public Object.make_function (JS.Context ctx, JS.String? name, [CCode (array_length_pos = 2.5)] JS.String[]? parameter_names, JS.String body, JS.String? source_url, int starting_line_number, out JS.Value? exception);
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "struct OpaqueJSString", free_function = "JSStringRelease", has_type_id = false)]
	[Compact]
	public class String {
		[CCode (cname = "JSStringCreateWithUTF8CString")]
		public String.create_with_utf8_cstring (string str);
		[CCode (cname = "JSStringGetLength")]
		public size_t get_length ();
		[CCode (cname = "JSStringGetMaximumUTF8CStringSize")]
		public size_t get_maximum_utf8_cstring_size ();
		[CCode (cname = "JSStringGetUTF8CString")]
		public size_t get_utf8_cstring ([CCode (array_length_type = "gsize")] uint8[] buffer);
		[CCode (cname = "JSStringIsEqual")]
		public bool is_equal (JS.String b);
		[CCode (cname = "JSStringIsEqualToUTF8CString")]
		public bool is_equal_to_utf8_cstring (string b);
		[CCode (cname = "JSStringRelease")]
		[DestroysInstance]
		public void release ();
		[CCode (cname = "JSStringRetain")]
		public JS.String retain ();
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "const struct OpaqueJSValue", free_function = "", has_type_id = false)]
	[Compact]
	public class Value {
		[CCode (cname = "JSValueGetType", instance_pos = 1.1)]
		public JS.Type get_type (JS.Context ctx);

		[CCode (cname = "JSValueGetTypedArrayType", instance_pos = 1.1)]
		public JS.TypedArrayType get_typed_array_type (JS.Context ctx, out JS.Value? exception = null);

		[CCode (cname = "JSValueIsArray", instance_pos = 1.1)]
		public bool is_array (JS.Context ctx);
		[CCode (cname = "JSValueIsBoolean", instance_pos = 1.1)]
		public bool is_boolean (JS.Context ctx);
		[CCode (cname = "JSValueIsDate", instance_pos = 1.1)]
		public bool is_date (JS.Context ctx);
		[CCode (cname = "JSValueIsNumber", instance_pos = 1.1)]
		public bool is_number (JS.Context ctx);
		[CCode (cname = "JSValueIsObject", instance_pos = 1.1)]
		public bool is_object (JS.Context ctx);
		[CCode (cname = "JSValueIsObjectOfClass", instance_pos = 1.1)]
		public bool is_object_of_class (JS.Context ctx, JS.Class js_class);
		[CCode (cname = "JSValueIsString", instance_pos = 1.1)]
		public bool is_string (JS.Context ctx);
		[CCode (cname = "JSValueIsUndefined", instance_pos = 1.1)]
		public bool is_undefined (JS.Context ctx);
		[CCode (cname = "JSValueIsNull", instance_pos = 1.1)]
		public bool is_null (JS.Context ctx);

		[CCode (cname = "JSValueIsEqual", instance_pos = 1.1)]
		public bool is_equal (JS.Context ctx, JS.Value b, out JS.Value? exception = null);
		[CCode (cname = "JSValueIsStrictEqual", instance_pos = 1.1)]
		public bool is_strict_equal (JS.Context ctx, JS.Value b);

		[CCode (cname = "JSValueToBoolean", instance_pos = 1.1)]
		public bool to_boolean (JS.Context ctx);
		[CCode (cname = "JSValueToNumber", instance_pos = 1.1)]
		public double to_number (JS.Context ctx, out JS.Value? exception = null);
		[CCode (cname = "JSValueToObject", instance_pos = 1.1)]
		public JS.Object to_object (JS.Context ctx, out JS.Value? exception = null);
		[CCode (cname = "JSValueToStringCopy", instance_pos = 1.1)]
		public JS.String to_string_copy (JS.Context ctx, out JS.Value? exception = null);

		[CCode (cname = "JSValueProtect", instance_pos = 1.1)]
		public void protect (JS.Context ctx);
		[CCode (cname = "JSValueUnprotect", instance_pos = 1.1)]
		public void unprotect (JS.Context ctx);
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "JSType", has_type_id = false)]
	public enum Type {
		[CCode (cname = "kJSTypeUndefined")]
		UNDEFINED,
		[CCode (cname = "kJSTypeNull")]
		NULL,
		[CCode (cname = "kJSTypeBoolean")]
		BOOLEAN,
		[CCode (cname = "kJSTypeNumber")]
		NUMBER,
		[CCode (cname = "kJSTypeString")]
		STRING,
		[CCode (cname = "kJSTypeObject")]
		OBJECT
	}
	[CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "JSTypedArrayType", has_type_id = false)]
	public enum TypedArrayType {
		[CCode (cname = "kJSTypedArrayTypeInt8Array")]
		INT8,
		[CCode (cname = "kJSTypedArrayTypeInt16Array")]
		INT16,
		[CCode (cname = "kJSTypedArrayTypeInt32Array")]
		INT32,
		[CCode (cname = "kJSTypedArrayTypeUint8Array")]
		UINT8,
		[CCode (cname = "kJSTypedArrayTypeUint8ClampedArray")]
		UINT8_CLAMPED,
		[CCode (cname = "kJSTypedArrayTypeUint16Array")]
		UINT16,
		[CCode (cname = "kJSTypedArrayTypeUint32Array")]
		UINT32,
		[CCode (cname = "kJSTypedArrayTypeFloat32Array")]
		FLOAT32,
		[CCode (cname = "kJSTypedArrayTypeFloat64Array")]
		FLOAT64,
		[CCode (cname = "kJSTypedArrayTypeArrayBuffer")]
		BUFFER,
		[CCode (cname = "kJSTypedArrayTypeNone")]
		NONE
	}
}

namespace JSC {
	public class Class : GLib.Object {
		public void add_property (string name, GLib.Type property_type, [CCode (delegate_target_pos = 4.33333, destroy_notify_pos = 4.66667, type = "GCallback")] owned JSC.ClassGetPropertyCb? getter, [CCode (delegate_target_pos = 4.33333, destroy_notify_pos = 4.66667, type = "GCallback")] owned JSC.ClassSetPropertyCb? setter);
	}
	[CCode (cname = "GCallback", instance_pos = 1.9)]
	public delegate T ClassGetPropertyCb<T> (JSC.Class instance);
	[CCode (cname = "GCallback", instance_pos = 2.9)]
	public delegate void ClassSetPropertyCb<T> (JSC.Class instance, T value);

	[CCode (cname = "GCallback", instance_pos = 1.9)]
	public delegate T ClassConstructorCb<T> (GLib.GenericArray<JSC.Value> values);
	[CCode (cname = "GCallback", instance_pos = 2.9)]
	public delegate T ClassMethodCb<T> (JSC.Class instance, GLib.GenericArray<JSC.Value> values);
}