objc2_javascript_core/generated/
JSBase.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejscontextgroup?language=objc)
12#[repr(C)]
13#[derive(Debug)]
14pub struct OpaqueJSContextGroup {
15    inner: [u8; 0],
16    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
17}
18
19#[cfg(feature = "objc2")]
20unsafe impl RefEncode for OpaqueJSContextGroup {
21    const ENCODING_REF: Encoding =
22        Encoding::Pointer(&Encoding::Struct("OpaqueJSContextGroup", &[]));
23}
24
25/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jscontextgroupref?language=objc)
26pub type JSContextGroupRef = *const OpaqueJSContextGroup;
27
28/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejscontext?language=objc)
29#[repr(C)]
30#[derive(Debug)]
31pub struct OpaqueJSContext {
32    inner: [u8; 0],
33    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
34}
35
36#[cfg(feature = "objc2")]
37unsafe impl RefEncode for OpaqueJSContext {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueJSContext", &[]));
39}
40
41/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jscontextref?language=objc)
42pub type JSContextRef = *const OpaqueJSContext;
43
44/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejsstring?language=objc)
45#[repr(C)]
46#[derive(Debug)]
47pub struct OpaqueJSString {
48    inner: [u8; 0],
49    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
50}
51
52#[cfg(feature = "objc2")]
53unsafe impl RefEncode for OpaqueJSString {
54    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueJSString", &[]));
55}
56
57/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsstringref?language=objc)
58pub type JSStringRef = *mut OpaqueJSString;
59
60/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejsclass?language=objc)
61#[repr(C)]
62#[derive(Debug)]
63pub struct OpaqueJSClass {
64    inner: [u8; 0],
65    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
66}
67
68#[cfg(feature = "objc2")]
69unsafe impl RefEncode for OpaqueJSClass {
70    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueJSClass", &[]));
71}
72
73/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsclassref?language=objc)
74pub type JSClassRef = *mut OpaqueJSClass;
75
76/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejspropertynamearray?language=objc)
77#[repr(C)]
78#[derive(Debug)]
79pub struct OpaqueJSPropertyNameArray {
80    inner: [u8; 0],
81    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
82}
83
84#[cfg(feature = "objc2")]
85unsafe impl RefEncode for OpaqueJSPropertyNameArray {
86    const ENCODING_REF: Encoding =
87        Encoding::Pointer(&Encoding::Struct("OpaqueJSPropertyNameArray", &[]));
88}
89
90/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertynamearrayref?language=objc)
91pub type JSPropertyNameArrayRef = *mut OpaqueJSPropertyNameArray;
92
93/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejspropertynameaccumulator?language=objc)
94#[repr(C)]
95#[derive(Debug)]
96pub struct OpaqueJSPropertyNameAccumulator {
97    inner: [u8; 0],
98    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
99}
100
101#[cfg(feature = "objc2")]
102unsafe impl RefEncode for OpaqueJSPropertyNameAccumulator {
103    const ENCODING_REF: Encoding =
104        Encoding::Pointer(&Encoding::Struct("OpaqueJSPropertyNameAccumulator", &[]));
105}
106
107/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertynameaccumulatorref?language=objc)
108pub type JSPropertyNameAccumulatorRef = *mut OpaqueJSPropertyNameAccumulator;
109
110/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jstypedarraybytesdeallocator?language=objc)
111pub type JSTypedArrayBytesDeallocator =
112    Option<unsafe extern "C-unwind" fn(*mut c_void, *mut c_void)>;
113
114/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/opaquejsvalue?language=objc)
115#[repr(C)]
116#[derive(Debug)]
117pub struct OpaqueJSValue {
118    inner: [u8; 0],
119    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
120}
121
122#[cfg(feature = "objc2")]
123unsafe impl RefEncode for OpaqueJSValue {
124    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueJSValue", &[]));
125}
126
127/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsvalueref?language=objc)
128pub type JSValueRef = *const OpaqueJSValue;
129
130extern "C-unwind" {
131    /// Evaluates a string of JavaScript.
132    ///
133    /// Parameter `ctx`: The execution context to use.
134    ///
135    /// Parameter `script`: A JSString containing the script to evaluate.
136    ///
137    /// Parameter `thisObject`: The object to use as "this," or NULL to use the global object as "this."
138    ///
139    /// Parameter `sourceURL`: A JSString containing a URL for the script's source file. This is used by debuggers and when reporting exceptions. Pass NULL if you do not care to include source file information.
140    ///
141    /// Parameter `startingLineNumber`: An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
142    ///
143    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
144    ///
145    /// Returns: The JSValue that results from evaluating script, or NULL if an exception is thrown.
146    pub fn JSEvaluateScript(
147        ctx: JSContextRef,
148        script: JSStringRef,
149        this_object: JSObjectRef,
150        source_url: JSStringRef,
151        starting_line_number: c_int,
152        exception: *mut JSValueRef,
153    ) -> JSValueRef;
154}
155
156extern "C-unwind" {
157    /// Checks for syntax errors in a string of JavaScript.
158    ///
159    /// Parameter `ctx`: The execution context to use.
160    ///
161    /// Parameter `script`: A JSString containing the script to check for syntax errors.
162    ///
163    /// Parameter `sourceURL`: A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
164    ///
165    /// Parameter `startingLineNumber`: An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
166    ///
167    /// Parameter `exception`: A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
168    ///
169    /// Returns: true if the script is syntactically correct, otherwise false.
170    pub fn JSCheckScriptSyntax(
171        ctx: JSContextRef,
172        script: JSStringRef,
173        source_url: JSStringRef,
174        starting_line_number: c_int,
175        exception: *mut JSValueRef,
176    ) -> bool;
177}
178
179extern "C-unwind" {
180    /// Performs a JavaScript garbage collection.
181    ///
182    /// Parameter `ctx`: The execution context to use.
183    ///
184    /// JavaScript values that are on the machine stack, in a register,
185    /// protected by JSValueProtect, set as the global object of an execution context,
186    /// or reachable from any such value will not be collected.
187    ///
188    /// During JavaScript execution, you are not required to call this function; the
189    /// JavaScript engine will garbage collect as needed. JavaScript values created
190    /// within a context group are automatically destroyed when the last reference
191    /// to the context group is released.
192    pub fn JSGarbageCollect(ctx: JSContextRef);
193}