Skip to main content

JS_IsCFunction

Function JS_IsCFunction 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_IsCFunction( _ctx: *mut JsContext, val: JsValue, func: *const c_void, magic: c_int, ) -> Bool
Expand description

JS_IsCFunction: whether the value is this C function (same pointer, same magic).

The reference compares the function object’s u.cfunc against the pointer it was given, which is how a method checks that it was called on the object it belongs to. Here the engine stores the pointer inside a boxed closure, so the comparison has to go through what JS_NewCFunction2 recorded; an identity this layer cannot see answers 0, which is the safe direction (a caller only ever uses the answer to add behaviour).

§Safety

val must be a live JSValue.