objc2_javascript_core/generated/
JSVirtualMachine.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7
8use crate::*;
9
10#[cfg(feature = "objc2")]
11extern_class!(
12    /// An instance of JSVirtualMachine represents a single JavaScript "object space"
13    /// or set of execution resources. Thread safety is supported by locking the
14    /// virtual machine, with concurrent JavaScript execution supported by allocating
15    /// separate instances of JSVirtualMachine.
16    ///
17    /// A virtual machine may need to run deferred tasks on a run loop, such as garbage collection
18    /// or resolving WebAssembly compilations. By default, a virtual machine will use the run loop
19    /// of the thread it was initialized on. Currently, there is no API to change a
20    /// JSVirtualMachine's run loop once it has been initialized.
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsvirtualmachine?language=objc)
23    #[unsafe(super(NSObject))]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    #[cfg(feature = "objc2")]
26    pub struct JSVirtualMachine;
27);
28
29#[cfg(feature = "objc2")]
30extern_conformance!(
31    unsafe impl NSObjectProtocol for JSVirtualMachine {}
32);
33
34#[cfg(feature = "objc2")]
35impl JSVirtualMachine {
36    extern_methods!(
37        /// Create a new JSVirtualMachine.
38        #[unsafe(method(init))]
39        #[unsafe(method_family = init)]
40        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
41
42        /// Notify the JSVirtualMachine of an external object relationship.
43        ///
44        /// Allows clients of JSVirtualMachine to make the JavaScript runtime aware of
45        /// arbitrary external Objective-C object graphs. The runtime can then use
46        /// this information to retain any JavaScript values that are referenced
47        /// from somewhere in said object graph.
48        ///
49        /// For correct behavior clients must make their external object graphs
50        /// reachable from within the JavaScript runtime. If an Objective-C object is
51        /// reachable from within the JavaScript runtime, all managed references
52        /// transitively reachable from it as recorded using
53        /// -addManagedReference:withOwner: will be scanned by the garbage collector.
54        ///
55        /// Parameter `object`: The object that the owner points to.
56        ///
57        /// Parameter `owner`: The object that owns the pointed to object.
58        ///
59        /// # Safety
60        ///
61        /// - `object` should be of the correct type.
62        /// - `object` might not allow `None`.
63        /// - `owner` should be of the correct type.
64        /// - `owner` might not allow `None`.
65        #[unsafe(method(addManagedReference:withOwner:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn addManagedReference_withOwner(
68            &self,
69            object: Option<&AnyObject>,
70            owner: Option<&AnyObject>,
71        );
72
73        /// Notify the JSVirtualMachine that a previous object relationship no longer exists.
74        ///
75        /// The JavaScript runtime will continue to scan any references that were
76        /// reported to it by -addManagedReference:withOwner: until those references are removed.
77        ///
78        /// Parameter `object`: The object that was formerly owned.
79        ///
80        /// Parameter `owner`: The former owner.
81        ///
82        /// # Safety
83        ///
84        /// - `object` should be of the correct type.
85        /// - `object` might not allow `None`.
86        /// - `owner` should be of the correct type.
87        /// - `owner` might not allow `None`.
88        #[unsafe(method(removeManagedReference:withOwner:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn removeManagedReference_withOwner(
91            &self,
92            object: Option<&AnyObject>,
93            owner: Option<&AnyObject>,
94        );
95    );
96}
97
98/// Methods declared on superclass `NSObject`.
99#[cfg(feature = "objc2")]
100impl JSVirtualMachine {
101    extern_methods!(
102        #[unsafe(method(new))]
103        #[unsafe(method_family = new)]
104        pub unsafe fn new() -> Retained<Self>;
105    );
106}