use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;
use crate::*;
#[cfg(feature = "objc2")]
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "objc2")]
pub struct JSValue;
);
#[cfg(feature = "objc2")]
extern_conformance!(
unsafe impl NSObjectProtocol for JSValue {}
);
#[cfg(feature = "objc2")]
impl JSValue {
extern_methods!(
#[cfg(feature = "JSContext")]
#[unsafe(method(context))]
#[unsafe(method_family = none)]
pub unsafe fn context(&self) -> Option<Retained<JSContext>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithObject:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithObject_inContext(
value: Option<&AnyObject>,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithBool:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithBool_inContext(
value: bool,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithDouble:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithDouble_inContext(
value: c_double,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithInt32:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithInt32_inContext(
value: i32,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithUInt32:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithUInt32_inContext(
value: u32,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewObjectInContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewObjectInContext(
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewArrayInContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewArrayInContext(
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
#[unsafe(method(valueWithNewRegularExpressionFromPattern:flags:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewRegularExpressionFromPattern_flags_inContext(
pattern: Option<&NSString>,
flags: Option<&NSString>,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
#[unsafe(method(valueWithNewErrorFromMessage:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewErrorFromMessage_inContext(
message: Option<&NSString>,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "block2"))]
#[unsafe(method(valueWithNewPromiseInContext:fromExecutor:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewPromiseInContext_fromExecutor(
context: Option<&JSContext>,
callback: Option<&block2::DynBlock<dyn Fn(*mut JSValue, *mut JSValue)>>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewPromiseResolvedWithResult:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewPromiseResolvedWithResult_inContext(
result: Option<&AnyObject>,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewPromiseRejectedWithReason:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewPromiseRejectedWithReason_inContext(
reason: Option<&AnyObject>,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
#[unsafe(method(valueWithNewSymbolFromDescription:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewSymbolFromDescription_inContext(
description: Option<&NSString>,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
#[unsafe(method(valueWithNewBigIntFromString:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewBigIntFromString_inContext(
string: &NSString,
context: &JSContext,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewBigIntFromInt64:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewBigIntFromInt64_inContext(
int64: i64,
context: &JSContext,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewBigIntFromUInt64:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewBigIntFromUInt64_inContext(
uint64: u64,
context: &JSContext,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNewBigIntFromDouble:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNewBigIntFromDouble_inContext(
value: c_double,
context: &JSContext,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithNullInContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithNullInContext(
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSContext")]
#[unsafe(method(valueWithUndefinedInContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithUndefinedInContext(
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[unsafe(method(toObject))]
#[unsafe(method_family = none)]
pub unsafe fn toObject(&self) -> Option<Retained<AnyObject>>;
#[unsafe(method(toObjectOfClass:))]
#[unsafe(method_family = none)]
pub unsafe fn toObjectOfClass(
&self,
expected_class: Option<&AnyClass>,
) -> Option<Retained<AnyObject>>;
#[unsafe(method(toBool))]
#[unsafe(method_family = none)]
pub unsafe fn toBool(&self) -> bool;
#[unsafe(method(toDouble))]
#[unsafe(method_family = none)]
pub unsafe fn toDouble(&self) -> c_double;
#[unsafe(method(toInt32))]
#[unsafe(method_family = none)]
pub unsafe fn toInt32(&self) -> i32;
#[unsafe(method(toUInt32))]
#[unsafe(method_family = none)]
pub unsafe fn toUInt32(&self) -> u32;
#[unsafe(method(toInt64))]
#[unsafe(method_family = none)]
pub unsafe fn toInt64(&self) -> i64;
#[unsafe(method(toUInt64))]
#[unsafe(method_family = none)]
pub unsafe fn toUInt64(&self) -> u64;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(toNumber))]
#[unsafe(method_family = none)]
pub unsafe fn toNumber(&self) -> Option<Retained<NSNumber>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(toString))]
#[unsafe(method_family = none)]
pub unsafe fn toString(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(toDate))]
#[unsafe(method_family = none)]
pub unsafe fn toDate(&self) -> Option<Retained<NSDate>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(toArray))]
#[unsafe(method_family = none)]
pub unsafe fn toArray(&self) -> Option<Retained<NSArray>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(toDictionary))]
#[unsafe(method_family = none)]
pub unsafe fn toDictionary(&self) -> Option<Retained<NSDictionary>>;
#[unsafe(method(isUndefined))]
#[unsafe(method_family = none)]
pub unsafe fn isUndefined(&self) -> bool;
#[unsafe(method(isNull))]
#[unsafe(method_family = none)]
pub unsafe fn isNull(&self) -> bool;
#[unsafe(method(isBoolean))]
#[unsafe(method_family = none)]
pub unsafe fn isBoolean(&self) -> bool;
#[unsafe(method(isNumber))]
#[unsafe(method_family = none)]
pub unsafe fn isNumber(&self) -> bool;
#[unsafe(method(isString))]
#[unsafe(method_family = none)]
pub unsafe fn isString(&self) -> bool;
#[unsafe(method(isObject))]
#[unsafe(method_family = none)]
pub unsafe fn isObject(&self) -> bool;
#[unsafe(method(isArray))]
#[unsafe(method_family = none)]
pub unsafe fn isArray(&self) -> bool;
#[unsafe(method(isDate))]
#[unsafe(method_family = none)]
pub unsafe fn isDate(&self) -> bool;
#[unsafe(method(isSymbol))]
#[unsafe(method_family = none)]
pub unsafe fn isSymbol(&self) -> bool;
#[unsafe(method(isBigInt))]
#[unsafe(method_family = none)]
pub unsafe fn isBigInt(&self) -> bool;
#[unsafe(method(isInstanceOf:))]
#[unsafe(method_family = none)]
pub unsafe fn isInstanceOf(&self, value: Option<&AnyObject>) -> bool;
#[unsafe(method(isEqualToObject:))]
#[unsafe(method_family = none)]
pub unsafe fn isEqualToObject(&self, value: Option<&AnyObject>) -> bool;
#[unsafe(method(isEqualWithTypeCoercionToObject:))]
#[unsafe(method_family = none)]
pub unsafe fn isEqualWithTypeCoercionToObject(&self, value: Option<&AnyObject>) -> bool;
#[cfg(feature = "JSValueRef")]
#[unsafe(method(compareJSValue:))]
#[unsafe(method_family = none)]
pub unsafe fn compareJSValue(&self, other: &JSValue) -> JSRelationCondition;
#[cfg(feature = "JSValueRef")]
#[unsafe(method(compareInt64:))]
#[unsafe(method_family = none)]
pub unsafe fn compareInt64(&self, other: i64) -> JSRelationCondition;
#[cfg(feature = "JSValueRef")]
#[unsafe(method(compareUInt64:))]
#[unsafe(method_family = none)]
pub unsafe fn compareUInt64(&self, other: u64) -> JSRelationCondition;
#[cfg(feature = "JSValueRef")]
#[unsafe(method(compareDouble:))]
#[unsafe(method_family = none)]
pub unsafe fn compareDouble(&self, other: c_double) -> JSRelationCondition;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(callWithArguments:))]
#[unsafe(method_family = none)]
pub unsafe fn callWithArguments(
&self,
arguments: Option<&NSArray>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(constructWithArguments:))]
#[unsafe(method_family = none)]
pub unsafe fn constructWithArguments(
&self,
arguments: Option<&NSArray>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(invokeMethod:withArguments:))]
#[unsafe(method_family = none)]
pub unsafe fn invokeMethod_withArguments(
&self,
method: Option<&NSString>,
arguments: Option<&NSArray>,
) -> Option<Retained<JSValue>>;
);
}
#[cfg(feature = "objc2")]
impl JSValue {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
#[cfg(feature = "objc2")]
impl JSValue {
extern_methods!(
#[cfg(all(feature = "JSContext", feature = "objc2-core-foundation"))]
#[unsafe(method(valueWithPoint:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithPoint_inContext(
point: CGPoint,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
#[unsafe(method(valueWithRange:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithRange_inContext(
range: NSRange,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-core-foundation"))]
#[unsafe(method(valueWithRect:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithRect_inContext(
rect: CGRect,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(all(feature = "JSContext", feature = "objc2-core-foundation"))]
#[unsafe(method(valueWithSize:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithSize_inContext(
size: CGSize,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(toPoint))]
#[unsafe(method_family = none)]
pub unsafe fn toPoint(&self) -> CGPoint;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(toRange))]
#[unsafe(method_family = none)]
pub unsafe fn toRange(&self) -> NSRange;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(toRect))]
#[unsafe(method_family = none)]
pub unsafe fn toRect(&self) -> CGRect;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(toSize))]
#[unsafe(method_family = none)]
pub unsafe fn toSize(&self) -> CGSize;
);
}
#[cfg(feature = "objc2-foundation")]
pub type JSValueProperty = NSString;
#[cfg(feature = "objc2")]
impl JSValue {
extern_methods!(
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(valueForProperty:))]
#[unsafe(method_family = none)]
pub unsafe fn valueForProperty(
&self,
property: Option<&JSValueProperty>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(setValue:forProperty:))]
#[unsafe(method_family = none)]
pub unsafe fn setValue_forProperty(
&self,
value: Option<&AnyObject>,
property: Option<&JSValueProperty>,
);
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(deleteProperty:))]
#[unsafe(method_family = none)]
pub unsafe fn deleteProperty(&self, property: Option<&JSValueProperty>) -> bool;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(hasProperty:))]
#[unsafe(method_family = none)]
pub unsafe fn hasProperty(&self, property: Option<&JSValueProperty>) -> bool;
#[cfg(feature = "objc2-foundation")]
#[unsafe(method(defineProperty:descriptor:))]
#[unsafe(method_family = none)]
pub unsafe fn defineProperty_descriptor(
&self,
property: Option<&JSValueProperty>,
descriptor: Option<&AnyObject>,
);
#[unsafe(method(valueAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn valueAtIndex(&self, index: NSUInteger) -> Option<Retained<JSValue>>;
#[unsafe(method(setValue:atIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn setValue_atIndex(&self, value: Option<&AnyObject>, index: NSUInteger);
);
}
#[cfg(feature = "objc2")]
impl JSValue {
extern_methods!(
#[unsafe(method(objectForKeyedSubscript:))]
#[unsafe(method_family = none)]
pub unsafe fn objectForKeyedSubscript(
&self,
key: Option<&AnyObject>,
) -> Option<Retained<JSValue>>;
#[unsafe(method(objectAtIndexedSubscript:))]
#[unsafe(method_family = none)]
pub unsafe fn objectAtIndexedSubscript(
&self,
index: NSUInteger,
) -> Option<Retained<JSValue>>;
#[unsafe(method(setObject:forKeyedSubscript:))]
#[unsafe(method_family = none)]
pub unsafe fn setObject_forKeyedSubscript(
&self,
object: Option<&AnyObject>,
key: Option<&AnyObject>,
);
#[unsafe(method(setObject:atIndexedSubscript:))]
#[unsafe(method_family = none)]
pub unsafe fn setObject_atIndexedSubscript(
&self,
object: Option<&AnyObject>,
index: NSUInteger,
);
);
}
#[cfg(feature = "objc2")]
impl JSValue {
extern_methods!(
#[cfg(all(feature = "JSBase", feature = "JSContext"))]
#[unsafe(method(valueWithJSValueRef:inContext:))]
#[unsafe(method_family = none)]
pub unsafe fn valueWithJSValueRef_inContext(
value: JSValueRef,
context: Option<&JSContext>,
) -> Option<Retained<JSValue>>;
#[cfg(feature = "JSBase")]
#[unsafe(method(JSValueRef))]
#[unsafe(method_family = none)]
pub unsafe fn JSValueRef(&self) -> JSValueRef;
);
}
extern "C" {
#[cfg(feature = "objc2-foundation")]
pub static JSPropertyDescriptorWritableKey: Option<&'static NSString>;
}
extern "C" {
#[cfg(feature = "objc2-foundation")]
pub static JSPropertyDescriptorEnumerableKey: Option<&'static NSString>;
}
extern "C" {
#[cfg(feature = "objc2-foundation")]
pub static JSPropertyDescriptorConfigurableKey: Option<&'static NSString>;
}
extern "C" {
#[cfg(feature = "objc2-foundation")]
pub static JSPropertyDescriptorValueKey: Option<&'static NSString>;
}
extern "C" {
#[cfg(feature = "objc2-foundation")]
pub static JSPropertyDescriptorGetKey: Option<&'static NSString>;
}
extern "C" {
#[cfg(feature = "objc2-foundation")]
pub static JSPropertyDescriptorSetKey: Option<&'static NSString>;
}