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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use crate::*;
#[cfg(feature = "objc2")]
extern_class!(
/// An instance of JSVirtualMachine represents a single JavaScript "object space"
/// or set of execution resources. Thread safety is supported by locking the
/// virtual machine, with concurrent JavaScript execution supported by allocating
/// separate instances of JSVirtualMachine.
///
/// A virtual machine may need to run deferred tasks on a run loop, such as garbage collection
/// or resolving WebAssembly compilations. By default, a virtual machine will use the run loop
/// of the thread it was initialized on. Currently, there is no API to change a
/// JSVirtualMachine's run loop once it has been initialized.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsvirtualmachine?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "objc2")]
pub struct JSVirtualMachine;
);
#[cfg(feature = "objc2")]
extern_conformance!(
unsafe impl NSObjectProtocol for JSVirtualMachine {}
);
#[cfg(feature = "objc2")]
impl JSVirtualMachine {
extern_methods!(
/// Create a new JSVirtualMachine.
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Notify the JSVirtualMachine of an external object relationship.
///
/// Allows clients of JSVirtualMachine to make the JavaScript runtime aware of
/// arbitrary external Objective-C object graphs. The runtime can then use
/// this information to retain any JavaScript values that are referenced
/// from somewhere in said object graph.
///
/// For correct behavior clients must make their external object graphs
/// reachable from within the JavaScript runtime. If an Objective-C object is
/// reachable from within the JavaScript runtime, all managed references
/// transitively reachable from it as recorded using
/// -addManagedReference:withOwner: will be scanned by the garbage collector.
///
/// Parameter `object`: The object that the owner points to.
///
/// Parameter `owner`: The object that owns the pointed to object.
///
/// # Safety
///
/// - `object` should be of the correct type.
/// - `object` might not allow `None`.
/// - `owner` should be of the correct type.
/// - `owner` might not allow `None`.
#[unsafe(method(addManagedReference:withOwner:))]
#[unsafe(method_family = none)]
pub unsafe fn addManagedReference_withOwner(
&self,
object: Option<&AnyObject>,
owner: Option<&AnyObject>,
);
/// Notify the JSVirtualMachine that a previous object relationship no longer exists.
///
/// The JavaScript runtime will continue to scan any references that were
/// reported to it by -addManagedReference:withOwner: until those references are removed.
///
/// Parameter `object`: The object that was formerly owned.
///
/// Parameter `owner`: The former owner.
///
/// # Safety
///
/// - `object` should be of the correct type.
/// - `object` might not allow `None`.
/// - `owner` should be of the correct type.
/// - `owner` might not allow `None`.
#[unsafe(method(removeManagedReference:withOwner:))]
#[unsafe(method_family = none)]
pub unsafe fn removeManagedReference_withOwner(
&self,
object: Option<&AnyObject>,
owner: Option<&AnyObject>,
);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2")]
impl JSVirtualMachine {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}