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 #[unsafe(method(addManagedReference:withOwner:))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn addManagedReference_withOwner(
61 &self,
62 object: Option<&AnyObject>,
63 owner: Option<&AnyObject>,
64 );
65
66 /// Notify the JSVirtualMachine that a previous object relationship no longer exists.
67 ///
68 /// The JavaScript runtime will continue to scan any references that were
69 /// reported to it by -addManagedReference:withOwner: until those references are removed.
70 ///
71 /// Parameter `object`: The object that was formerly owned.
72 ///
73 /// Parameter `owner`: The former owner.
74 #[unsafe(method(removeManagedReference:withOwner:))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn removeManagedReference_withOwner(
77 &self,
78 object: Option<&AnyObject>,
79 owner: Option<&AnyObject>,
80 );
81 );
82}
83
84/// Methods declared on superclass `NSObject`.
85#[cfg(feature = "objc2")]
86impl JSVirtualMachine {
87 extern_methods!(
88 #[unsafe(method(new))]
89 #[unsafe(method_family = new)]
90 pub unsafe fn new() -> Retained<Self>;
91 );
92}